Skip to content

Commit 920a119

Browse files
Added -lf option to run the lock file update with the --force flag (#152)
Co-authored-by: Dominic Griesel <[email protected]>
1 parent e9b895a commit 920a119

File tree

8 files changed

+1755
-2199
lines changed

8 files changed

+1755
-2199
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Placeholder for the next version (at the beginning of the line):
44
## **WORK IN PROGRESS**
55
-->
6+
## **WORK IN PROGRESS**
7+
* Added "-lf" option to run the lock file update with the `--force` flag
8+
69
## 3.6.0 (2023-07-03)
710
* `git` plugin: Add the `--tagOnly` flag to only create a tag without pushing the commit to the release branch.
811

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ If you want the release script to add a new empty placeholder to the changelog a
350350
351351
After bumping the version, the lockfile is normally synchronized with `package.json` to avoid errors on CI. If this is not desirable, you can disable the behavior.
352352
353+
#### Pass the `--force` flag to the package manager when updating the lockfile (`--force-update-lockfile` or `-lf`)
354+
355+
In some cases it is necessary to pass the `--force` flag to the package manager when updating the lockfile. This can be done with this option. Depending on the package manager in use, this option may or may not do anything.
356+
353357
### `version` plugin options
354358
355359
#### Replace the version in additional files (`--versionFiles`)

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
testEnvironment: "node",
3+
testRunner: "jest-jasmine2", // https://github.com/jestjs/jest/issues/11698
34
roots: [
45
"<rootDir>/packages/release-script/src",
56
"<rootDir>/packages/core/src",
@@ -40,6 +41,6 @@ module.exports = {
4041
collectCoverageFrom: ["packages/**/src/**/*.ts", "!packages/**/src/**/*.test.ts"],
4142
coverageReporters: ["lcov", "html", "text-summary"],
4243
transform: {
43-
"^.+.tsx?$": "babel-jest",
44+
"^.+\\.tsx?$": "babel-jest",
4445
},
4546
};

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"packages/*"
1818
],
1919
"devDependencies": {
20-
"@babel/cli": "^7.17.6",
21-
"@babel/core": "^7.17.9",
22-
"@babel/preset-env": "^7.16.11",
23-
"@babel/preset-typescript": "^7.16.7",
20+
"@babel/core": "^7.19.1",
21+
"@babel/plugin-transform-typescript": "^7.19.1",
22+
"@babel/preset-env": "^7.19.1",
23+
"@babel/preset-typescript": "^7.18.6",
2424
"@commitlint/cli": "^13.2.1",
2525
"@commitlint/config-conventional": "^13.2.0",
2626
"@tsconfig/node12": "^1.0.9",
2727
"@types/fs-extra": "^9.0.13",
28-
"@types/jest": "^27.4.1",
28+
"@types/jest": "^29.0.2",
2929
"@types/node": "^12.20.50",
3030
"@types/semver": "^7.3.9",
3131
"@types/yargs": "^17.0.10",
@@ -36,11 +36,13 @@
3636
"eslint-config-prettier": "^8.5.0",
3737
"eslint-plugin-prettier": "^4.0.0",
3838
"husky": "^7.0.4",
39-
"jest": "^27.5.1",
39+
"jest": "^29.0.3",
40+
"jest-extended": "^3.1.0",
41+
"jest-jasmine2": "^29.7.0",
4042
"prettier": "^2.6.2",
4143
"source-map-support": "^0.5.21",
4244
"ts-node": "^10.7.0",
43-
"typescript": "~4.6.3"
45+
"typescript": "~4.8.3"
4446
},
4547
"resolutions": {
4648
"minimist": "^1.2.6"

packages/plugin-package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"node": ">=12.20"
3838
},
3939
"dependencies": {
40-
"@alcalzone/pak": "^0.8.1",
40+
"@alcalzone/pak": "^0.10.0",
4141
"@alcalzone/release-script-core": "3.5.9",
4242
"alcalzone-shared": "^4.0.1",
4343
"fs-extra": "^10.1.0",

packages/plugin-package/src/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ class PackagePlugin implements Plugin {
5858
type: "boolean",
5959
default: true,
6060
},
61+
forceUpdateLockfile: {
62+
alias: ["force-update-lockfile", "lf"],
63+
description: "Update the lockfile before committing, using the --force flag",
64+
type: "boolean",
65+
default: false,
66+
},
6167
});
6268
}
6369

@@ -309,12 +315,16 @@ Alternatively, you can use ${context.cli.colors.blue("lerna")} to manage the mon
309315
}
310316
} else if (stage.id === "commit") {
311317
if (context.hasData("monorepo") && context.getData("monorepo") === "yarn") {
312-
// Not necessary, when using yarn workspaces this was done during the edit stage
318+
// Not necessary, when using yarn workspaces, this was done during the edit stage
313319
return;
314320
}
315321

316-
if (context.argv.updateLockfile) {
317-
context.cli.log(`updating lockfile...`);
322+
if (context.argv.updateLockfile || context.argv.forceUpdateLockfile) {
323+
context.cli.log(
324+
`updating lockfile...${
325+
context.argv.forceUpdateLockfile ? " (with --force)" : ""
326+
}`,
327+
);
318328
const pak = await detectPackageManager({
319329
cwd: context.cwd,
320330
setCwdToPackageRoot: true,
@@ -325,6 +335,7 @@ Alternatively, you can use ${context.cli.colors.blue("lerna")} to manage the mon
325335
if (!context.argv.dryRun) {
326336
const result = await pak.install(undefined, {
327337
ignoreScripts: true,
338+
force: !!context.argv.forceUpdateLockfile,
328339
});
329340
if (!result.success) {
330341
context.cli.error(`Updating lockfile failed: ${result.stderr}`);

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717

1818
// Avoid runtime imports that are unnecessary
1919
"importsNotUsedAsValues": "error",
20+
// "ignoreDeprecations": "5.0",
2021

2122
// Required for TS debugging
2223
"sourceMap": true,
2324
"inlineSourceMap": false,
2425

2526
// Make jest-extended work in tests
26-
"types": ["jest-extended"],
27+
"types": ["node", "jest", "jest-extended"],
2728

2829
"preserveWatchOutput": true
2930
},

0 commit comments

Comments
 (0)