Skip to content

Commit

Permalink
fix offline mode not fully skipping npm packages
Browse files Browse the repository at this point in the history
(cherry picked from commit 1136172)
  • Loading branch information
locksten committed Sep 4, 2024
1 parent 0858f77 commit e7ea7f3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
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';

0 comments on commit e7ea7f3

Please sign in to comment.