Skip to content

Commit

Permalink
feat(js): hide generate lock file behind flag
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Jan 17, 2023
1 parent ed68d35 commit a97f639
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/generated/packages/js/executors/swc.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
"items": { "type": "string" },
"description": "List of target names that annotate a build target for a project",
"default": ["build"]
},
"generateLockfile": {
"type": "boolean",
"description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.",
"default": false,
"x-priority": "internal"
}
},
"required": ["main", "outputPath", "tsConfig"],
Expand Down
6 changes: 6 additions & 0 deletions docs/generated/packages/js/executors/tsc.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
"items": { "type": "string" },
"description": "List of target names that annotate a build target for a project",
"default": ["build"]
},
"generateLockfile": {
"type": "boolean",
"description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.",
"default": false,
"x-priority": "internal"
}
},
"required": ["main", "outputPath", "tsConfig"],
Expand Down
6 changes: 6 additions & 0 deletions packages/js/src/executors/swc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
},
"description": "List of target names that annotate a build target for a project",
"default": ["build"]
},
"generateLockfile": {
"type": "boolean",
"description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.",
"default": false,
"x-priority": "internal"
}
},
"required": ["main", "outputPath", "tsConfig"],
Expand Down
6 changes: 6 additions & 0 deletions packages/js/src/executors/tsc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
},
"description": "List of target names that annotate a build target for a project",
"default": ["build"]
},
"generateLockfile": {
"type": "boolean",
"description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.",
"default": false,
"x-priority": "internal"
}
},
"required": ["main", "outputPath", "tsConfig"],
Expand Down
12 changes: 8 additions & 4 deletions packages/js/src/utils/package-json/update-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface UpdatePackageJsonOption {
excludeLibsInPackageJson?: boolean;
updateBuildableProjectDepsInPackageJson?: boolean;
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
generateLockfile?: boolean;
}

export function updatePackageJson(
Expand Down Expand Up @@ -84,10 +85,13 @@ export function updatePackageJson(

// save files
writeJsonFile(`${options.outputPath}/package.json`, packageJson);
const lockFile = createLockFile(packageJson);
writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, {
encoding: 'utf-8',
});

if (options.generateLockfile) {
const lockFile = createLockFile(packageJson);
writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, {
encoding: 'utf-8',
});
}
}

function addMissingDependencies(
Expand Down
1 change: 1 addition & 0 deletions packages/js/src/utils/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface ExecutorOptions {
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
external?: 'all' | 'none' | string[];
externalBuildTargets?: string[];
generateLockfile?: boolean;
}

export interface NormalizedExecutorOptions extends ExecutorOptions {
Expand Down

0 comments on commit a97f639

Please sign in to comment.