Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix offline mode not fully skipping npm packages #1689

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/core/src/projects/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { RnvContext } from '../context/types';
import { inquirerPrompt } from '../api';
import { getContext } from '../context/provider';
import { handleMutations } from './mutations';
import { isOfflineMode } from './utils';

export const checkIfProjectAndNodeModulesExists = async () => {
logDefault('checkIfProjectAndNodeModulesExists');
Expand Down Expand Up @@ -136,6 +137,10 @@ export const installPackageDependencies = async (failOnError = false) => {
return;
}

if (isOfflineMode('install package dependencies')) {
return;
}

c.runtime.forceBuildHookRebuild = true;
const customScript = _getInstallScript(c);

Expand Down
13 changes: 13 additions & 0 deletions packages/core/src/projects/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import path from 'path';
import { RnvContext } from '../context/types';
import { resolvePackage } from '../system/fs';
import { getContext } from '../context/provider';
import { logInfo } from '../logger';

export const resolveRelativePackage = (c: RnvContext, v: string) => {
if (v?.startsWith?.('./')) {
return path.join(c.paths.project.dir, v);
}
return resolvePackage(v);
};

export const isOfflineMode = (logMessage?: string) => {
if (getContext().program.opts().offline) {
if (logMessage) {
logInfo(`Skipping "${logMessage}" due to --offline option`);
}
return true;
} else {
return false;
}
};
3 changes: 2 additions & 1 deletion packages/engine-core/src/taskHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import {
checkForPluginDependencies,
getContext,
installPackageDependencies,
isOfflineMode,
logDefault,
logInfo,
overrideTemplatePlugins,
} from '@rnv/core';
import { configureFonts, isOfflineMode } from '@rnv/sdk-utils';
import { configureFonts } from '@rnv/sdk-utils';

export const installPackageDependenciesAndPlugins = async () => {
logDefault('installPackageDependenciesAndPlugins');
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-react-native/src/iosRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import {
getCurrentCommand,
inquirerPrompt,
RnvEnvContext,
isOfflineMode,
} from '@rnv/core';
import { EnvVars } from './env';
import shellQuote from 'shell-quote';
import path from 'path';
import crypto from 'crypto';
import { isOfflineMode } from '@rnv/sdk-utils';

export const packageReactNativeIOS = (isDev = false) => {
const c = getContext();
Expand Down
12 changes: 0 additions & 12 deletions packages/sdk-utils/src/getCliOptions.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/sdk-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ export * from './ipUtils';
export * from './utils';
export * from './target';
export * from './axiosUtils';
export * from './getCliOptions';
Loading