Skip to content

Commit

Permalink
Merge pull request #1800 from flexn-io/fix/overrides_when_version_cha…
Browse files Browse the repository at this point in the history
…nges

fix/overrides_when_version_changes + add --skipOverridesCheck
  • Loading branch information
pauliusguzas authored Nov 29, 2024
2 parents 90531b9 + d536485 commit ed0ea0f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/core/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ export const overrideFileContents = (
} else if (overrideExists) {
if (originalExists) {
if (fk.includes(override[fk])) {
foundRegEx = true;
fileToFix = fileToFix.replace(originalRegEx, `${override[fk]}`);
logSuccess(
`${chalk().bold.white(dest)} requires override by: ${chalk().bold.white(
Expand Down Expand Up @@ -875,6 +876,8 @@ export const overrideFileContents = (
appliedOverrides[packageName].version = packageVersion;
fsWriteFileSync(dest, fileToFix);
_writeAppliedOverrides(appliedOverrides, appliedOverrideFilePath);
} else if (foundRegEx) {
fsWriteFileSync(dest, fileToFix);
}
} else {
logDebug(`overrideFileContents Warning: path does not exist ${dest}`);
Expand Down Expand Up @@ -1095,7 +1098,11 @@ export const overrideTemplatePlugins = async () => {
logDefault('overrideTemplatePlugins');

const c = getContext();

const { skipOverridesCheck } = c.program.opts();
if (skipOverridesCheck) {
logInfo(`Plugin overrides will not be applied because --skipOverridesCheck parameter was passed.`);
return true;
}
const rnvPluginsDirs = c.paths.scopedConfigTemplates.pluginTemplatesDirs;
const appPluginDirs = c.paths.appConfig.pluginDirs;

Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/tasks/taskOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ export const RnvTaskOptions = createTaskOptionsMap([
altKey: 'skipDependencyCheck',
description: 'Skips auto update of npm dependencies if mismatch found',
},
{
key: 'skip-overrides-check',
altKey: 'skipOverridesCheck',
description:
'Skips applying plugin overrides. Useful for avoiding unnecessary checks on every run when overrides are already applied.',
},
{
key: 'offline',
description: 'Run without connecting to the internet whenever possible',
Expand Down Expand Up @@ -238,6 +244,7 @@ export const RnvTaskCoreOptionPresets = createTaskOptionsPreset({
RnvTaskOptions.noIntro,
RnvTaskOptions.offline,
RnvTaskOptions.skipDependencyCheck,
RnvTaskOptions.skipOverridesCheck,
],
});

Expand Down
7 changes: 6 additions & 1 deletion packages/template-starter/scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
logError,
RnvFileName,
fsExistsSync,
fsMkdirSync,
fsReadFileSync,
removeDirSync,
revertOverrideToOriginal,
Expand Down Expand Up @@ -40,7 +41,11 @@ const RNV_HOME_DIR = path.join(__dirname, '..');
})();

const resetOverrides = async () => {
const overrideDir = path.join(process.cwd(), '.rnv', 'overrides');
const rnvFolder = path.join(process.cwd(), '.rnv');
if (!fsExistsSync(rnvFolder)) {
fsMkdirSync(rnvFolder);
}
const overrideDir = path.join(rnvFolder, 'overrides');

const appliedOverrideFilePath = path.join(overrideDir, RnvFileName.appliedOverride);

Expand Down

0 comments on commit ed0ea0f

Please sign in to comment.