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

Added -lf option to run the lock file update with the --force flag #152

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Placeholder for the next version (at the beginning of the line):
## **WORK IN PROGRESS**
-->
## **WORK IN PROGRESS**
* Added "-lf" option to run the lock file update with the `--force` flag

## 3.6.0 (2023-07-03)
* `git` plugin: Add the `--tagOnly` flag to only create a tag without pushing the commit to the release branch.

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ If you want the release script to add a new empty placeholder to the changelog a

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.

#### Pass the `--force` flag to the package manager when updating the lockfile (`--force-update-lockfile` or `-lf`)

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.

### `version` plugin options

#### Replace the version in additional files (`--versionFiles`)
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
testEnvironment: "node",
testRunner: "jest-jasmine2", // https://github.com/jestjs/jest/issues/11698
roots: [
"<rootDir>/packages/release-script/src",
"<rootDir>/packages/core/src",
Expand Down Expand Up @@ -40,6 +41,6 @@ module.exports = {
collectCoverageFrom: ["packages/**/src/**/*.ts", "!packages/**/src/**/*.test.ts"],
coverageReporters: ["lcov", "html", "text-summary"],
transform: {
"^.+.tsx?$": "babel-jest",
"^.+\\.tsx?$": "babel-jest",
},
};
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"packages/*"
],
"devDependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.9",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@babel/core": "^7.19.1",
"@babel/plugin-transform-typescript": "^7.19.1",
"@babel/preset-env": "^7.19.1",
"@babel/preset-typescript": "^7.18.6",
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
"@tsconfig/node12": "^1.0.9",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.4.1",
"@types/jest": "^29.0.2",
"@types/node": "^12.20.50",
"@types/semver": "^7.3.9",
"@types/yargs": "^17.0.10",
Expand All @@ -36,11 +36,13 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"jest": "^29.0.3",
"jest-extended": "^3.1.0",
"jest-jasmine2": "^29.7.0",
"prettier": "^2.6.2",
"source-map-support": "^0.5.21",
"ts-node": "^10.7.0",
"typescript": "~4.6.3"
"typescript": "~4.8.3"
},
"resolutions": {
"minimist": "^1.2.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"node": ">=12.20"
},
"dependencies": {
"@alcalzone/pak": "^0.8.1",
"@alcalzone/pak": "^0.10.0",
"@alcalzone/release-script-core": "3.5.9",
"alcalzone-shared": "^4.0.1",
"fs-extra": "^10.1.0",
Expand Down
17 changes: 14 additions & 3 deletions packages/plugin-package/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class PackagePlugin implements Plugin {
type: "boolean",
default: true,
},
forceUpdateLockfile: {
alias: ["force-update-lockfile", "lf"],
description: "Update the lockfile before committing, using the --force flag",
type: "boolean",
default: false,
},
});
}

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

if (context.argv.updateLockfile) {
context.cli.log(`updating lockfile...`);
if (context.argv.updateLockfile || context.argv.forceUpdateLockfile) {
context.cli.log(
`updating lockfile...${
context.argv.forceUpdateLockfile ? " (with --force)" : ""
}`,
);
const pak = await detectPackageManager({
cwd: context.cwd,
setCwdToPackageRoot: true,
Expand All @@ -325,6 +335,7 @@ Alternatively, you can use ${context.cli.colors.blue("lerna")} to manage the mon
if (!context.argv.dryRun) {
const result = await pak.install(undefined, {
ignoreScripts: true,
force: !!context.argv.forceUpdateLockfile,
});
if (!result.success) {
context.cli.error(`Updating lockfile failed: ${result.stderr}`);
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

// Avoid runtime imports that are unnecessary
"importsNotUsedAsValues": "error",
// "ignoreDeprecations": "5.0",

// Required for TS debugging
"sourceMap": true,
"inlineSourceMap": false,

// Make jest-extended work in tests
"types": ["jest-extended"],
"types": ["node", "jest", "jest-extended"],

"preserveWatchOutput": true
},
Expand Down
Loading
Loading