Skip to content

Commit 6e9cc49

Browse files
committed
wip
1 parent d77ec8d commit 6e9cc49

6 files changed

Lines changed: 91 additions & 28 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
runs-on: ubuntu-latest
1717
name: Unit tests
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020

2121
- uses: actions/setup-node@v4
2222
with:
23-
node-version: "20"
23+
node-version: 20
2424
cache: "yarn"
2525

2626
- name: Install dependencies

.pnp.cjs

Lines changed: 21 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.yarnrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
compressionLevel: mixed
22

3+
enableScripts: false
4+
35
enableGlobalCache: false
46

57
npmPublishRegistry: "https://registry.npmjs.org"
68

9+
plugins:
10+
- ./plugin-ci-version.cjs
11+
712
supportedArchitectures:
813
cpu:
914
- x64

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"lint-staged": "^16.1.0",
6262
"prettier": "^3.5.3",
6363
"prettier-plugin-packagejson": "^2.5.15",
64-
"rollup": "^4.53.0",
6564
"typescript": "^5.8.3",
6665
"vitest": "^3.2.4"
6766
}

plugin-ci-version.cjs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module.exports = {
2+
name: `plugin-ci-version`,
3+
factory: (require) => {
4+
const { BaseCommand, WorkspaceRequiredError } = require(`@yarnpkg/cli`);
5+
const { Cache, Configuration, Project } = require(`@yarnpkg/core`);
6+
const semver = require("semver");
7+
const { Option } = require(`clipanion`);
8+
9+
class CiVersion extends BaseCommand {
10+
static paths = [[`ci-version`]];
11+
12+
strategy = Option.String();
13+
14+
async execute() {
15+
const configuration = await Configuration.find(
16+
this.context.cwd,
17+
this.context.plugins,
18+
);
19+
const { project, workspace } = await Project.find(
20+
configuration,
21+
this.context.cwd,
22+
);
23+
const cache = await Cache.find(configuration);
24+
25+
if (!workspace)
26+
throw new WorkspaceRequiredError(project.cwd, this.context.cwd);
27+
28+
const valid = semver.valid(this.strategy);
29+
if (!valid)
30+
throw new Error(`should be a valid semver: ${this.strategy}`);
31+
32+
const currentVersion = workspace.manifest.version;
33+
if (currentVersion === this.strategy) {
34+
this.context.stdout.write(
35+
`workspace ${workspace.manifest.raw.name} already has specified version ${this.strategy}\n`,
36+
);
37+
return;
38+
}
39+
40+
workspace.manifest.version = this.strategy;
41+
42+
this.context.stdout.write(
43+
`updating workspace ${workspace.manifest.raw.name} from ${currentVersion} to ${this.strategy}\n`,
44+
);
45+
46+
return await project.installWithNewReport(
47+
{
48+
json: this.json,
49+
stdout: this.context.stdout,
50+
},
51+
{
52+
cache,
53+
},
54+
);
55+
}
56+
}
57+
58+
return {
59+
commands: [CiVersion],
60+
};
61+
},
62+
};

yarn.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,6 @@ __metadata:
22422242
lint-staged: "npm:^16.1.0"
22432243
prettier: "npm:^3.5.3"
22442244
prettier-plugin-packagejson: "npm:^2.5.15"
2245-
rollup: "npm:^4.53.0"
22462245
typescript: "npm:^5.8.3"
22472246
vitest: "npm:^3.2.4"
22482247
languageName: unknown
@@ -5996,7 +5995,7 @@ __metadata:
59965995
languageName: node
59975996
linkType: hard
59985997

5999-
"rollup@npm:^4.43.0, rollup@npm:^4.53.0":
5998+
"rollup@npm:^4.43.0":
60005999
version: 4.53.0
60016000
resolution: "rollup@npm:4.53.0"
60026001
dependencies:

0 commit comments

Comments
 (0)