@jpp-toolkit/plugin-changesets 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/dist/index.d.mts +116 -0
- package/dist/index.mjs +317 -0
- package/dist/index.mjs.map +1 -0
- package/oclif.config.js +13 -0
- package/oclif.manifest.json +285 -0
- package/package.json +60 -0
- package/src/add-changeset-command.ts +56 -0
- package/src/changeset-command.ts +19 -0
- package/src/index.ts +17 -0
- package/src/init-changeset-command.ts +22 -0
- package/src/pre-changeset-command.ts +48 -0
- package/src/publish-changeset-command.ts +62 -0
- package/src/status-changeset-command.ts +65 -0
- package/src/tag-changeset-command.ts +25 -0
- package/src/version-changeset-command.ts +52 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Julien Papini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Command } from "@jpp-toolkit/core";
|
|
2
|
+
import * as _oclif_core_interfaces3 from "@oclif/core/interfaces";
|
|
3
|
+
|
|
4
|
+
//#region src/changeset-command.d.ts
|
|
5
|
+
declare abstract class ChangesetCommand extends Command {
|
|
6
|
+
protected _execChangeset(args?: string[]): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/add-changeset-command.d.ts
|
|
10
|
+
declare class AddChangesetCommand extends ChangesetCommand {
|
|
11
|
+
static summary: string;
|
|
12
|
+
static description: string;
|
|
13
|
+
static flags: {
|
|
14
|
+
empty: _oclif_core_interfaces3.BooleanFlag<boolean>;
|
|
15
|
+
open: _oclif_core_interfaces3.BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
static examples: {
|
|
18
|
+
description: string;
|
|
19
|
+
command: string;
|
|
20
|
+
}[];
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/init-changeset-command.d.ts
|
|
25
|
+
declare class InitChangesetCommand extends ChangesetCommand {
|
|
26
|
+
static summary: string;
|
|
27
|
+
static description: string;
|
|
28
|
+
static examples: {
|
|
29
|
+
description: string;
|
|
30
|
+
command: string;
|
|
31
|
+
}[];
|
|
32
|
+
run(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/pre-changeset-command.d.ts
|
|
36
|
+
declare class PreChangesetCommand extends ChangesetCommand {
|
|
37
|
+
static summary: string;
|
|
38
|
+
static description: string;
|
|
39
|
+
static args: {
|
|
40
|
+
action: _oclif_core_interfaces3.Arg<string, Record<string, unknown>>;
|
|
41
|
+
tag: _oclif_core_interfaces3.Arg<string | undefined, Record<string, unknown>>;
|
|
42
|
+
};
|
|
43
|
+
static examples: {
|
|
44
|
+
description: string;
|
|
45
|
+
command: string;
|
|
46
|
+
}[];
|
|
47
|
+
run(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/publish-changeset-command.d.ts
|
|
51
|
+
declare class PublishChangesetCommand extends ChangesetCommand {
|
|
52
|
+
static summary: string;
|
|
53
|
+
static description: string;
|
|
54
|
+
static flags: {
|
|
55
|
+
otp: _oclif_core_interfaces3.OptionFlag<string | undefined, _oclif_core_interfaces3.CustomOptions>;
|
|
56
|
+
tag: _oclif_core_interfaces3.OptionFlag<string | undefined, _oclif_core_interfaces3.CustomOptions>;
|
|
57
|
+
'no-git-tag': _oclif_core_interfaces3.BooleanFlag<boolean>;
|
|
58
|
+
};
|
|
59
|
+
static examples: {
|
|
60
|
+
description: string;
|
|
61
|
+
command: string;
|
|
62
|
+
}[];
|
|
63
|
+
run(): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/status-changeset-command.d.ts
|
|
67
|
+
declare class StatusChangesetCommand extends ChangesetCommand {
|
|
68
|
+
static summary: string;
|
|
69
|
+
static description: string;
|
|
70
|
+
static flags: {
|
|
71
|
+
verbose: _oclif_core_interfaces3.BooleanFlag<boolean>;
|
|
72
|
+
output: _oclif_core_interfaces3.OptionFlag<string | undefined, _oclif_core_interfaces3.CustomOptions>;
|
|
73
|
+
since: _oclif_core_interfaces3.OptionFlag<string | undefined, _oclif_core_interfaces3.CustomOptions>;
|
|
74
|
+
};
|
|
75
|
+
static examples: {
|
|
76
|
+
description: string;
|
|
77
|
+
command: string;
|
|
78
|
+
}[];
|
|
79
|
+
run(): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/tag-changeset-command.d.ts
|
|
83
|
+
declare class TagChangesetCommand extends ChangesetCommand {
|
|
84
|
+
static summary: string;
|
|
85
|
+
static description: string;
|
|
86
|
+
run(): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/version-changeset-command.d.ts
|
|
90
|
+
declare class VersionChangesetCommand extends ChangesetCommand {
|
|
91
|
+
static summary: string;
|
|
92
|
+
static description: string;
|
|
93
|
+
static flags: {
|
|
94
|
+
ignore: _oclif_core_interfaces3.OptionFlag<string | undefined, _oclif_core_interfaces3.CustomOptions>;
|
|
95
|
+
snapshot: _oclif_core_interfaces3.OptionFlag<string | undefined, _oclif_core_interfaces3.CustomOptions>;
|
|
96
|
+
};
|
|
97
|
+
static examples: {
|
|
98
|
+
description: string;
|
|
99
|
+
command: string;
|
|
100
|
+
}[];
|
|
101
|
+
run(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/index.d.ts
|
|
105
|
+
declare const commands: {
|
|
106
|
+
'changeset:init': typeof InitChangesetCommand;
|
|
107
|
+
'changeset:add': typeof AddChangesetCommand;
|
|
108
|
+
'changeset:version': typeof VersionChangesetCommand;
|
|
109
|
+
'changeset:publish': typeof PublishChangesetCommand;
|
|
110
|
+
'changeset:status': typeof StatusChangesetCommand;
|
|
111
|
+
'changeset:pre': typeof PreChangesetCommand;
|
|
112
|
+
'changeset:tag': typeof TagChangesetCommand;
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
export { commands };
|
|
116
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { Args, Flags } from "@oclif/core";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { Command } from "@jpp-toolkit/core";
|
|
5
|
+
import { findProjectRoot } from "@jpp-toolkit/utils";
|
|
6
|
+
import { execa } from "execa";
|
|
7
|
+
|
|
8
|
+
//#region src/changeset-command.ts
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const CHANGESET_BIN = path.resolve(require.resolve("@changesets/cli/package.json"), "../bin.js");
|
|
11
|
+
var ChangesetCommand = class extends Command {
|
|
12
|
+
async _execChangeset(args = []) {
|
|
13
|
+
if ((await execa(CHANGESET_BIN, args, {
|
|
14
|
+
cwd: findProjectRoot(),
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
reject: false
|
|
17
|
+
})).failed) process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/add-changeset-command.ts
|
|
23
|
+
var AddChangesetCommand = class AddChangesetCommand extends ChangesetCommand {
|
|
24
|
+
static summary = "Add a new changeset to the project.";
|
|
25
|
+
static description = `
|
|
26
|
+
This is the main command people use to interact with the changesets.
|
|
27
|
+
|
|
28
|
+
This command will ask you a series of questions, first about what packages you want to release,
|
|
29
|
+
then what semver bump type for each package, then it will ask for a summary of the entire changeset.
|
|
30
|
+
The final step will show the changeset it will generate and confirm that you want to add it.
|
|
31
|
+
|
|
32
|
+
Once confirmed, the changeset will be written a Markdown file that contains the summary and YAML
|
|
33
|
+
front matter which stores the packages that will be released and the semver bump types for them.
|
|
34
|
+
`;
|
|
35
|
+
static flags = {
|
|
36
|
+
empty: Flags.boolean({
|
|
37
|
+
char: "e",
|
|
38
|
+
description: "Create an empty changeset without prompts.",
|
|
39
|
+
default: false
|
|
40
|
+
}),
|
|
41
|
+
open: Flags.boolean({
|
|
42
|
+
char: "o",
|
|
43
|
+
description: "Open the changeset in the default editor after creating it.",
|
|
44
|
+
default: false
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
static examples = [
|
|
48
|
+
{
|
|
49
|
+
description: "Add a new changeset to the project.",
|
|
50
|
+
command: "<%= config.bin %> <%= command.id %>"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
description: "Add an empty changeset without any prompts.",
|
|
54
|
+
command: "<%= config.bin %> <%= command.id %> --empty"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
description: "Add a new changeset and open it in the default editor.",
|
|
58
|
+
command: "<%= config.bin %> <%= command.id %> --open"
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
async run() {
|
|
62
|
+
const { flags } = await this.parse(AddChangesetCommand);
|
|
63
|
+
const args = ["add"];
|
|
64
|
+
if (flags.empty) args.push("--empty");
|
|
65
|
+
if (flags.open) args.push("--open");
|
|
66
|
+
await this._execChangeset(args);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/init-changeset-command.ts
|
|
72
|
+
var InitChangesetCommand = class extends ChangesetCommand {
|
|
73
|
+
static summary = "Sets up the .changeset folder.";
|
|
74
|
+
static description = `
|
|
75
|
+
This command sets up the .changeset folder. It generates a readme and a config file.
|
|
76
|
+
The config file includes the default options and comments on what these options represent.
|
|
77
|
+
You should run this command once when you are setting up changesets.
|
|
78
|
+
`;
|
|
79
|
+
static examples = [{
|
|
80
|
+
description: "Initialize changesets in your repository.",
|
|
81
|
+
command: "<%= config.bin %> <%= command.id %>"
|
|
82
|
+
}];
|
|
83
|
+
async run() {
|
|
84
|
+
await this._execChangeset(["init"]);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/pre-changeset-command.ts
|
|
90
|
+
var PreChangesetCommand = class PreChangesetCommand extends ChangesetCommand {
|
|
91
|
+
static summary = "Enters and exits pre-release mode for packages.";
|
|
92
|
+
static description = `
|
|
93
|
+
The pre command enters and exits pre mode. The command does not do any actual versioning, when doing
|
|
94
|
+
a pre-release, you should run changeset pre enter next(or a different tag, the tag is what is in
|
|
95
|
+
versions and is the npm dist tag) and then do the normal release process with changeset version and
|
|
96
|
+
changeset publish.
|
|
97
|
+
`;
|
|
98
|
+
static args = {
|
|
99
|
+
action: Args.string({
|
|
100
|
+
name: "action",
|
|
101
|
+
required: true,
|
|
102
|
+
description: "The pre-release action to perform.",
|
|
103
|
+
options: ["enter", "exit"]
|
|
104
|
+
}),
|
|
105
|
+
tag: Args.string({
|
|
106
|
+
name: "tag",
|
|
107
|
+
required: false,
|
|
108
|
+
description: "The pre-release tag to use when entering pre-release mode."
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
static examples = [{
|
|
112
|
+
description: "Enter pre-release mode with the \"next\" tag.",
|
|
113
|
+
command: "<%= config.bin %> <%= command.id %> enter next"
|
|
114
|
+
}, {
|
|
115
|
+
description: "Exit pre-release mode.",
|
|
116
|
+
command: "<%= config.bin %> <%= command.id %> exit"
|
|
117
|
+
}];
|
|
118
|
+
async run() {
|
|
119
|
+
const { args } = await this.parse(PreChangesetCommand);
|
|
120
|
+
const commandArgs = ["pre", args.action];
|
|
121
|
+
if (args.action === "enter" && args.tag) commandArgs.push("--tag", args.tag);
|
|
122
|
+
await this._execChangeset(commandArgs);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/publish-changeset-command.ts
|
|
128
|
+
var PublishChangesetCommand = class PublishChangesetCommand extends ChangesetCommand {
|
|
129
|
+
static summary = "Publishes changes to npm, and creates git tags.";
|
|
130
|
+
static description = `
|
|
131
|
+
This publishes changes to npm, and creates git tags. This works by going into each package, checking
|
|
132
|
+
if the version it has in its package.json is published on npm, and if it is not, running the npm
|
|
133
|
+
publish. If you are using pnpm as a package manager, this automatically detects it and uses pnpm
|
|
134
|
+
publish instead.
|
|
135
|
+
`;
|
|
136
|
+
static flags = {
|
|
137
|
+
"otp": Flags.string({
|
|
138
|
+
char: "o",
|
|
139
|
+
description: "One-time password for publishing to npm.",
|
|
140
|
+
required: false
|
|
141
|
+
}),
|
|
142
|
+
"tag": Flags.string({
|
|
143
|
+
char: "t",
|
|
144
|
+
description: "Tag to publish the package under.",
|
|
145
|
+
required: false
|
|
146
|
+
}),
|
|
147
|
+
"no-git-tag": Flags.boolean({
|
|
148
|
+
description: "Skip creating a git tag after publishing.",
|
|
149
|
+
required: false,
|
|
150
|
+
default: false
|
|
151
|
+
})
|
|
152
|
+
};
|
|
153
|
+
static examples = [
|
|
154
|
+
{
|
|
155
|
+
description: "Publish packages to npm and create git tags.",
|
|
156
|
+
command: "<%= config.bin %> <%= command.id %>"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
description: "Publish packages with a one-time password.",
|
|
160
|
+
command: "<%= config.bin %> <%= command.id %> --otp 123456"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
description: "Publish packages under a specific tag.",
|
|
164
|
+
command: "<%= config.bin %> <%= command.id %> --tag beta"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
description: "Publish packages without creating git tags.",
|
|
168
|
+
command: "<%= config.bin %> <%= command.id %> --no-git-tag"
|
|
169
|
+
}
|
|
170
|
+
];
|
|
171
|
+
async run() {
|
|
172
|
+
const { flags } = await this.parse(PublishChangesetCommand);
|
|
173
|
+
const args = ["publish"];
|
|
174
|
+
if (flags.otp) args.push("--otp", flags.otp);
|
|
175
|
+
if (flags.tag) args.push("--tag", flags.tag);
|
|
176
|
+
if (flags["no-git-tag"]) args.push("--no-git-tag");
|
|
177
|
+
await this._execChangeset(args);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/status-changeset-command.ts
|
|
183
|
+
var StatusChangesetCommand = class StatusChangesetCommand extends ChangesetCommand {
|
|
184
|
+
static summary = "Provides information about the changesets that currently exist.";
|
|
185
|
+
static description = `
|
|
186
|
+
The status command provides information about the changesets that currently exist. If there are no
|
|
187
|
+
changesets present, it exits with an error status code.
|
|
188
|
+
`;
|
|
189
|
+
static flags = {
|
|
190
|
+
verbose: Flags.boolean({
|
|
191
|
+
char: "v",
|
|
192
|
+
description: "Use if you want to know the new versions, and get a link to the relevant changeset summary.",
|
|
193
|
+
required: false,
|
|
194
|
+
default: false
|
|
195
|
+
}),
|
|
196
|
+
output: Flags.string({
|
|
197
|
+
char: "o",
|
|
198
|
+
description: "Allows you to write the JSON object of the status output for consumption by other tools, such as CI.",
|
|
199
|
+
required: false
|
|
200
|
+
}),
|
|
201
|
+
since: Flags.string({
|
|
202
|
+
char: "s",
|
|
203
|
+
description: "Only display information about changesets since a specific branch or git tag (such as main, or the git hash of latest).",
|
|
204
|
+
required: false
|
|
205
|
+
})
|
|
206
|
+
};
|
|
207
|
+
static examples = [
|
|
208
|
+
{
|
|
209
|
+
description: "Get the status of changesets in the project.",
|
|
210
|
+
command: "<%= config.bin %> <%= command.id %>"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
description: "Get a verbose status of changesets, including new versions and links to summaries.",
|
|
214
|
+
command: "<%= config.bin %> <%= command.id %> --verbose"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
description: "Output the status of changesets as a JSON object.",
|
|
218
|
+
command: "<%= config.bin %> <%= command.id %> --output status.json"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
description: "Get the status of changesets since a specific branch or git tag.",
|
|
222
|
+
command: "<%= config.bin %> <%= command.id %> --since main"
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
async run() {
|
|
226
|
+
const { flags } = await this.parse(StatusChangesetCommand);
|
|
227
|
+
const args = ["status"];
|
|
228
|
+
if (flags.verbose) args.push("--verbose");
|
|
229
|
+
if (flags.output) args.push("--output", flags.output);
|
|
230
|
+
if (flags.since) args.push("--since", flags.since);
|
|
231
|
+
await this._execChangeset(args);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/tag-changeset-command.ts
|
|
237
|
+
var TagChangesetCommand = class extends ChangesetCommand {
|
|
238
|
+
static summary = "Creates git tags for the current version of all packages.";
|
|
239
|
+
static description = `
|
|
240
|
+
The tag command creates git tags for the current version of all packages. The tags created are
|
|
241
|
+
equivalent to those created by changeset publish, but the tag command does not publish anything to
|
|
242
|
+
npm.
|
|
243
|
+
|
|
244
|
+
This is helpful in situations where a different tool, such as pnpm publish -r, is used to publish
|
|
245
|
+
packages instead of changeset. For situations where changeset publish is executed, running changeset
|
|
246
|
+
tag is not needed.
|
|
247
|
+
|
|
248
|
+
The git tags in monorepos are created in the format pkg-name@version-number and are based on the
|
|
249
|
+
current version number of the package.json for each package. Note that in single-package
|
|
250
|
+
repositories, the git tag will include v before the version number, for example, v1.0.0. It is
|
|
251
|
+
expected that changeset version is run before changeset tag, so the package.json versions are
|
|
252
|
+
updated before the git tags are created.
|
|
253
|
+
`;
|
|
254
|
+
async run() {
|
|
255
|
+
await this._execChangeset(["tag"]);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/version-changeset-command.ts
|
|
261
|
+
var VersionChangesetCommand = class VersionChangesetCommand extends ChangesetCommand {
|
|
262
|
+
static summary = "Takes changesets that have been made and updates versions and dependencies of packages, as well as writing changelogs.";
|
|
263
|
+
static description = `
|
|
264
|
+
This is one of two commands responsible for releasing packages. The version command takes changesets
|
|
265
|
+
that have been made and updates versions and dependencies of packages, as well as writing
|
|
266
|
+
changelogs. It is responsible for all file changes to versions before publishing to npm.
|
|
267
|
+
`;
|
|
268
|
+
static flags = {
|
|
269
|
+
ignore: Flags.string({
|
|
270
|
+
char: "i",
|
|
271
|
+
description: "Comma-separated list of packages to ignore when versioning.",
|
|
272
|
+
required: false
|
|
273
|
+
}),
|
|
274
|
+
snapshot: Flags.string({
|
|
275
|
+
char: "s",
|
|
276
|
+
description: "Create snapshot versions with the given tag.",
|
|
277
|
+
required: false
|
|
278
|
+
})
|
|
279
|
+
};
|
|
280
|
+
static examples = [
|
|
281
|
+
{
|
|
282
|
+
description: "Version packages based on changesets.",
|
|
283
|
+
command: "<%= config.bin %> <%= command.id %>"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
description: "Version packages while ignoring specific packages.",
|
|
287
|
+
command: "<%= config.bin %> <%= command.id %> --ignore package-a,package-b"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
description: "Version packages with snapshot versions.",
|
|
291
|
+
command: "<%= config.bin %> <%= command.id %> --snapshot beta"
|
|
292
|
+
}
|
|
293
|
+
];
|
|
294
|
+
async run() {
|
|
295
|
+
const { flags } = await this.parse(VersionChangesetCommand);
|
|
296
|
+
const args = ["version"];
|
|
297
|
+
if (flags.ignore) args.push("--ignore", flags.ignore);
|
|
298
|
+
if (flags.snapshot) args.push("--snapshot", flags.snapshot);
|
|
299
|
+
await this._execChangeset(args);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/index.ts
|
|
305
|
+
const commands = {
|
|
306
|
+
"changeset:init": InitChangesetCommand,
|
|
307
|
+
"changeset:add": AddChangesetCommand,
|
|
308
|
+
"changeset:version": VersionChangesetCommand,
|
|
309
|
+
"changeset:publish": PublishChangesetCommand,
|
|
310
|
+
"changeset:status": StatusChangesetCommand,
|
|
311
|
+
"changeset:pre": PreChangesetCommand,
|
|
312
|
+
"changeset:tag": TagChangesetCommand
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
//#endregion
|
|
316
|
+
export { commands };
|
|
317
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["args: string[]","commandArgs: string[]","args: string[]","args: string[]","args: string[]"],"sources":["../src/changeset-command.ts","../src/add-changeset-command.ts","../src/init-changeset-command.ts","../src/pre-changeset-command.ts","../src/publish-changeset-command.ts","../src/status-changeset-command.ts","../src/tag-changeset-command.ts","../src/version-changeset-command.ts","../src/index.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { Command } from '@jpp-toolkit/core';\nimport { findProjectRoot } from '@jpp-toolkit/utils';\nimport { execa } from 'execa';\n\nconst require = createRequire(import.meta.url);\n\nconst CHANGESET_BIN = path.resolve(require.resolve('@changesets/cli/package.json'), '../bin.js');\n\nexport abstract class ChangesetCommand extends Command {\n protected async _execChangeset(args: string[] = []): Promise<void> {\n const cwd = findProjectRoot();\n const result = await execa(CHANGESET_BIN, args, { cwd, stdio: 'inherit', reject: false });\n\n if (result.failed) process.exit(1);\n }\n}\n","import { Flags } from '@oclif/core';\n\nimport { ChangesetCommand } from './changeset-command';\n\nexport class AddChangesetCommand extends ChangesetCommand {\n static override summary = 'Add a new changeset to the project.';\n\n static override description = `\nThis is the main command people use to interact with the changesets.\n\nThis command will ask you a series of questions, first about what packages you want to release,\nthen what semver bump type for each package, then it will ask for a summary of the entire changeset.\nThe final step will show the changeset it will generate and confirm that you want to add it.\n\nOnce confirmed, the changeset will be written a Markdown file that contains the summary and YAML\nfront matter which stores the packages that will be released and the semver bump types for them.\n`;\n\n static override flags = {\n empty: Flags.boolean({\n char: 'e',\n description: 'Create an empty changeset without prompts.',\n default: false,\n }),\n open: Flags.boolean({\n char: 'o',\n description: 'Open the changeset in the default editor after creating it.',\n default: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Add a new changeset to the project.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description: 'Add an empty changeset without any prompts.',\n command: '<%= config.bin %> <%= command.id %> --empty',\n },\n {\n description: 'Add a new changeset and open it in the default editor.',\n command: '<%= config.bin %> <%= command.id %> --open',\n },\n ];\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(AddChangesetCommand);\n\n const args: string[] = ['add'];\n if (flags.empty) args.push('--empty');\n if (flags.open) args.push('--open');\n\n await this._execChangeset(args);\n }\n}\n","import { ChangesetCommand } from './changeset-command';\n\nexport class InitChangesetCommand extends ChangesetCommand {\n static override summary = 'Sets up the .changeset folder.';\n\n static override description = `\nThis command sets up the .changeset folder. It generates a readme and a config file.\nThe config file includes the default options and comments on what these options represent.\nYou should run this command once when you are setting up changesets.\n`;\n\n static override examples = [\n {\n description: 'Initialize changesets in your repository.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n ];\n\n public async run(): Promise<void> {\n await this._execChangeset(['init']);\n }\n}\n","import { Args } from '@oclif/core';\n\nimport { ChangesetCommand } from './changeset-command';\n\nexport class PreChangesetCommand extends ChangesetCommand {\n static override summary = 'Enters and exits pre-release mode for packages.';\n\n static override description = `\nThe pre command enters and exits pre mode. The command does not do any actual versioning, when doing\na pre-release, you should run changeset pre enter next(or a different tag, the tag is what is in\nversions and is the npm dist tag) and then do the normal release process with changeset version and\nchangeset publish.\n`;\n\n static override args = {\n action: Args.string({\n name: 'action',\n required: true,\n description: 'The pre-release action to perform.',\n options: ['enter', 'exit'],\n }),\n tag: Args.string({\n name: 'tag',\n required: false,\n description: 'The pre-release tag to use when entering pre-release mode.',\n }),\n };\n\n static override examples = [\n {\n description: 'Enter pre-release mode with the \"next\" tag.',\n command: '<%= config.bin %> <%= command.id %> enter next',\n },\n {\n description: 'Exit pre-release mode.',\n command: '<%= config.bin %> <%= command.id %> exit',\n },\n ];\n\n public async run(): Promise<void> {\n const { args } = await this.parse(PreChangesetCommand);\n\n const commandArgs: string[] = ['pre', args.action];\n if (args.action === 'enter' && args.tag) commandArgs.push('--tag', args.tag);\n\n await this._execChangeset(commandArgs);\n }\n}\n","import { Flags } from '@oclif/core';\n\nimport { ChangesetCommand } from './changeset-command';\n\nexport class PublishChangesetCommand extends ChangesetCommand {\n static override summary = 'Publishes changes to npm, and creates git tags.';\n\n static override description = `\nThis publishes changes to npm, and creates git tags. This works by going into each package, checking\nif the version it has in its package.json is published on npm, and if it is not, running the npm\npublish. If you are using pnpm as a package manager, this automatically detects it and uses pnpm\npublish instead.\n`;\n\n static override flags = {\n 'otp': Flags.string({\n char: 'o',\n description: 'One-time password for publishing to npm.',\n required: false,\n }),\n 'tag': Flags.string({\n char: 't',\n description: 'Tag to publish the package under.',\n required: false,\n }),\n 'no-git-tag': Flags.boolean({\n description: 'Skip creating a git tag after publishing.',\n required: false,\n default: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Publish packages to npm and create git tags.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description: 'Publish packages with a one-time password.',\n command: '<%= config.bin %> <%= command.id %> --otp 123456',\n },\n {\n description: 'Publish packages under a specific tag.',\n command: '<%= config.bin %> <%= command.id %> --tag beta',\n },\n {\n description: 'Publish packages without creating git tags.',\n command: '<%= config.bin %> <%= command.id %> --no-git-tag',\n },\n ];\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(PublishChangesetCommand);\n\n const args: string[] = ['publish'];\n if (flags.otp) args.push('--otp', flags.otp);\n if (flags.tag) args.push('--tag', flags.tag);\n if (flags['no-git-tag']) args.push('--no-git-tag');\n\n await this._execChangeset(args);\n }\n}\n","import { Flags } from '@oclif/core';\n\nimport { ChangesetCommand } from './changeset-command';\n\nexport class StatusChangesetCommand extends ChangesetCommand {\n static override summary = 'Provides information about the changesets that currently exist.';\n\n static override description = `\nThe status command provides information about the changesets that currently exist. If there are no\nchangesets present, it exits with an error status code.\n`;\n\n static override flags = {\n verbose: Flags.boolean({\n char: 'v',\n description:\n 'Use if you want to know the new versions, and get a link to the relevant changeset summary.',\n required: false,\n default: false,\n }),\n output: Flags.string({\n char: 'o',\n description:\n 'Allows you to write the JSON object of the status output for consumption by other tools, such as CI.',\n required: false,\n }),\n since: Flags.string({\n char: 's',\n description:\n 'Only display information about changesets since a specific branch or git tag (such as main, or the git hash of latest).',\n required: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Get the status of changesets in the project.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description:\n 'Get a verbose status of changesets, including new versions and links to summaries.',\n command: '<%= config.bin %> <%= command.id %> --verbose',\n },\n {\n description: 'Output the status of changesets as a JSON object.',\n command: '<%= config.bin %> <%= command.id %> --output status.json',\n },\n {\n description: 'Get the status of changesets since a specific branch or git tag.',\n command: '<%= config.bin %> <%= command.id %> --since main',\n },\n ];\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(StatusChangesetCommand);\n\n const args: string[] = ['status'];\n if (flags.verbose) args.push('--verbose');\n if (flags.output) args.push('--output', flags.output);\n if (flags.since) args.push('--since', flags.since);\n\n await this._execChangeset(args);\n }\n}\n","import { ChangesetCommand } from './changeset-command';\n\nexport class TagChangesetCommand extends ChangesetCommand {\n static override summary = 'Creates git tags for the current version of all packages.';\n\n static override description = `\nThe tag command creates git tags for the current version of all packages. The tags created are\nequivalent to those created by changeset publish, but the tag command does not publish anything to\nnpm.\n\nThis is helpful in situations where a different tool, such as pnpm publish -r, is used to publish\npackages instead of changeset. For situations where changeset publish is executed, running changeset\ntag is not needed.\n\nThe git tags in monorepos are created in the format pkg-name@version-number and are based on the\ncurrent version number of the package.json for each package. Note that in single-package\nrepositories, the git tag will include v before the version number, for example, v1.0.0. It is\nexpected that changeset version is run before changeset tag, so the package.json versions are\nupdated before the git tags are created.\n`;\n\n public async run(): Promise<void> {\n await this._execChangeset(['tag']);\n }\n}\n","import { Flags } from '@oclif/core';\n\nimport { ChangesetCommand } from './changeset-command';\n\nexport class VersionChangesetCommand extends ChangesetCommand {\n static override summary =\n 'Takes changesets that have been made and updates versions and dependencies of packages, as well as writing changelogs.';\n\n static override description = `\nThis is one of two commands responsible for releasing packages. The version command takes changesets\nthat have been made and updates versions and dependencies of packages, as well as writing\nchangelogs. It is responsible for all file changes to versions before publishing to npm.\n`;\n\n static override flags = {\n ignore: Flags.string({\n char: 'i',\n description: 'Comma-separated list of packages to ignore when versioning.',\n required: false,\n }),\n snapshot: Flags.string({\n char: 's',\n description: 'Create snapshot versions with the given tag.',\n required: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Version packages based on changesets.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description: 'Version packages while ignoring specific packages.',\n command: '<%= config.bin %> <%= command.id %> --ignore package-a,package-b',\n },\n {\n description: 'Version packages with snapshot versions.',\n command: '<%= config.bin %> <%= command.id %> --snapshot beta',\n },\n ];\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(VersionChangesetCommand);\n\n const args: string[] = ['version'];\n if (flags.ignore) args.push('--ignore', flags.ignore);\n if (flags.snapshot) args.push('--snapshot', flags.snapshot);\n\n await this._execChangeset(args);\n }\n}\n","import { AddChangesetCommand } from './add-changeset-command';\nimport { InitChangesetCommand } from './init-changeset-command';\nimport { PreChangesetCommand } from './pre-changeset-command';\nimport { PublishChangesetCommand } from './publish-changeset-command';\nimport { StatusChangesetCommand } from './status-changeset-command';\nimport { TagChangesetCommand } from './tag-changeset-command';\nimport { VersionChangesetCommand } from './version-changeset-command';\n\nexport const commands = {\n 'changeset:init': InitChangesetCommand,\n 'changeset:add': AddChangesetCommand,\n 'changeset:version': VersionChangesetCommand,\n 'changeset:publish': PublishChangesetCommand,\n 'changeset:status': StatusChangesetCommand,\n 'changeset:pre': PreChangesetCommand,\n 'changeset:tag': TagChangesetCommand,\n};\n"],"mappings":";;;;;;;;AAOA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,MAAM,gBAAgB,KAAK,QAAQ,QAAQ,QAAQ,+BAA+B,EAAE,YAAY;AAEhG,IAAsB,mBAAtB,cAA+C,QAAQ;CACnD,MAAgB,eAAe,OAAiB,EAAE,EAAiB;AAI/D,OAFe,MAAM,MAAM,eAAe,MAAM;GAAE,KADtC,iBAAiB;GAC0B,OAAO;GAAW,QAAQ;GAAO,CAAC,EAE9E,OAAQ,SAAQ,KAAK,EAAE;;;;;;ACZ1C,IAAa,sBAAb,MAAa,4BAA4B,iBAAiB;CACtD,OAAgB,UAAU;CAE1B,OAAgB,cAAc;;;;;;;;;;CAW9B,OAAgB,QAAQ;EACpB,OAAO,MAAM,QAAQ;GACjB,MAAM;GACN,aAAa;GACb,SAAS;GACZ,CAAC;EACF,MAAM,MAAM,QAAQ;GAChB,MAAM;GACN,aAAa;GACb,SAAS;GACZ,CAAC;EACL;CAED,OAAgB,WAAW;EACvB;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,oBAAoB;EAEvD,MAAMA,OAAiB,CAAC,MAAM;AAC9B,MAAI,MAAM,MAAO,MAAK,KAAK,UAAU;AACrC,MAAI,MAAM,KAAM,MAAK,KAAK,SAAS;AAEnC,QAAM,KAAK,eAAe,KAAK;;;;;;ACnDvC,IAAa,uBAAb,cAA0C,iBAAiB;CACvD,OAAgB,UAAU;CAE1B,OAAgB,cAAc;;;;;CAM9B,OAAgB,WAAW,CACvB;EACI,aAAa;EACb,SAAS;EACZ,CACJ;CAED,MAAa,MAAqB;AAC9B,QAAM,KAAK,eAAe,CAAC,OAAO,CAAC;;;;;;ACf3C,IAAa,sBAAb,MAAa,4BAA4B,iBAAiB;CACtD,OAAgB,UAAU;CAE1B,OAAgB,cAAc;;;;;;CAO9B,OAAgB,OAAO;EACnB,QAAQ,KAAK,OAAO;GAChB,MAAM;GACN,UAAU;GACV,aAAa;GACb,SAAS,CAAC,SAAS,OAAO;GAC7B,CAAC;EACF,KAAK,KAAK,OAAO;GACb,MAAM;GACN,UAAU;GACV,aAAa;GAChB,CAAC;EACL;CAED,OAAgB,WAAW,CACvB;EACI,aAAa;EACb,SAAS;EACZ,EACD;EACI,aAAa;EACb,SAAS;EACZ,CACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EAAE,SAAS,MAAM,KAAK,MAAM,oBAAoB;EAEtD,MAAMC,cAAwB,CAAC,OAAO,KAAK,OAAO;AAClD,MAAI,KAAK,WAAW,WAAW,KAAK,IAAK,aAAY,KAAK,SAAS,KAAK,IAAI;AAE5E,QAAM,KAAK,eAAe,YAAY;;;;;;ACzC9C,IAAa,0BAAb,MAAa,gCAAgC,iBAAiB;CAC1D,OAAgB,UAAU;CAE1B,OAAgB,cAAc;;;;;;CAO9B,OAAgB,QAAQ;EACpB,OAAO,MAAM,OAAO;GAChB,MAAM;GACN,aAAa;GACb,UAAU;GACb,CAAC;EACF,OAAO,MAAM,OAAO;GAChB,MAAM;GACN,aAAa;GACb,UAAU;GACb,CAAC;EACF,cAAc,MAAM,QAAQ;GACxB,aAAa;GACb,UAAU;GACV,SAAS;GACZ,CAAC;EACL;CAED,OAAgB,WAAW;EACvB;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,wBAAwB;EAE3D,MAAMC,OAAiB,CAAC,UAAU;AAClC,MAAI,MAAM,IAAK,MAAK,KAAK,SAAS,MAAM,IAAI;AAC5C,MAAI,MAAM,IAAK,MAAK,KAAK,SAAS,MAAM,IAAI;AAC5C,MAAI,MAAM,cAAe,MAAK,KAAK,eAAe;AAElD,QAAM,KAAK,eAAe,KAAK;;;;;;ACvDvC,IAAa,yBAAb,MAAa,+BAA+B,iBAAiB;CACzD,OAAgB,UAAU;CAE1B,OAAgB,cAAc;;;;CAK9B,OAAgB,QAAQ;EACpB,SAAS,MAAM,QAAQ;GACnB,MAAM;GACN,aACI;GACJ,UAAU;GACV,SAAS;GACZ,CAAC;EACF,QAAQ,MAAM,OAAO;GACjB,MAAM;GACN,aACI;GACJ,UAAU;GACb,CAAC;EACF,OAAO,MAAM,OAAO;GAChB,MAAM;GACN,aACI;GACJ,UAAU;GACb,CAAC;EACL;CAED,OAAgB,WAAW;EACvB;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aACI;GACJ,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,uBAAuB;EAE1D,MAAMC,OAAiB,CAAC,SAAS;AACjC,MAAI,MAAM,QAAS,MAAK,KAAK,YAAY;AACzC,MAAI,MAAM,OAAQ,MAAK,KAAK,YAAY,MAAM,OAAO;AACrD,MAAI,MAAM,MAAO,MAAK,KAAK,WAAW,MAAM,MAAM;AAElD,QAAM,KAAK,eAAe,KAAK;;;;;;AC5DvC,IAAa,sBAAb,cAAyC,iBAAiB;CACtD,OAAgB,UAAU;CAE1B,OAAgB,cAAc;;;;;;;;;;;;;;;CAgB9B,MAAa,MAAqB;AAC9B,QAAM,KAAK,eAAe,CAAC,MAAM,CAAC;;;;;;AClB1C,IAAa,0BAAb,MAAa,gCAAgC,iBAAiB;CAC1D,OAAgB,UACZ;CAEJ,OAAgB,cAAc;;;;;CAM9B,OAAgB,QAAQ;EACpB,QAAQ,MAAM,OAAO;GACjB,MAAM;GACN,aAAa;GACb,UAAU;GACb,CAAC;EACF,UAAU,MAAM,OAAO;GACnB,MAAM;GACN,aAAa;GACb,UAAU;GACb,CAAC;EACL;CAED,OAAgB,WAAW;EACvB;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACD;GACI,aAAa;GACb,SAAS;GACZ;EACJ;CAED,MAAa,MAAqB;EAC9B,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,wBAAwB;EAE3D,MAAMC,OAAiB,CAAC,UAAU;AAClC,MAAI,MAAM,OAAQ,MAAK,KAAK,YAAY,MAAM,OAAO;AACrD,MAAI,MAAM,SAAU,MAAK,KAAK,cAAc,MAAM,SAAS;AAE3D,QAAM,KAAK,eAAe,KAAK;;;;;;ACzCvC,MAAa,WAAW;CACpB,kBAAkB;CAClB,iBAAiB;CACjB,qBAAqB;CACrB,qBAAqB;CACrB,oBAAoB;CACpB,iBAAiB;CACjB,iBAAiB;CACpB"}
|
package/oclif.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
description: 'Plugin that add the changeset command to the jpp cli.',
|
|
3
|
+
commands: {
|
|
4
|
+
strategy: 'explicit',
|
|
5
|
+
target: './dist/index.mjs',
|
|
6
|
+
identifier: 'commands',
|
|
7
|
+
},
|
|
8
|
+
topics: {
|
|
9
|
+
changeset: {
|
|
10
|
+
description: 'Commands for managing changesets.',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
{
|
|
2
|
+
"commands": {
|
|
3
|
+
"changeset:init": {
|
|
4
|
+
"aliases": [],
|
|
5
|
+
"args": {},
|
|
6
|
+
"description": "\nThis command sets up the .changeset folder. It generates a readme and a config file.\nThe config file includes the default options and comments on what these options represent.\nYou should run this command once when you are setting up changesets.\n",
|
|
7
|
+
"examples": [
|
|
8
|
+
{
|
|
9
|
+
"description": "Initialize changesets in your repository.",
|
|
10
|
+
"command": "<%= config.bin %> <%= command.id %>"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"flags": {},
|
|
14
|
+
"hasDynamicHelp": false,
|
|
15
|
+
"hiddenAliases": [],
|
|
16
|
+
"id": "changeset:init",
|
|
17
|
+
"pluginAlias": "@jpp-toolkit/plugin-changesets",
|
|
18
|
+
"pluginName": "@jpp-toolkit/plugin-changesets",
|
|
19
|
+
"pluginType": "core",
|
|
20
|
+
"strict": true,
|
|
21
|
+
"summary": "Sets up the .changeset folder."
|
|
22
|
+
},
|
|
23
|
+
"changeset:add": {
|
|
24
|
+
"aliases": [],
|
|
25
|
+
"args": {},
|
|
26
|
+
"description": "\nThis is the main command people use to interact with the changesets.\n\nThis command will ask you a series of questions, first about what packages you want to release,\nthen what semver bump type for each package, then it will ask for a summary of the entire changeset.\nThe final step will show the changeset it will generate and confirm that you want to add it.\n\nOnce confirmed, the changeset will be written a Markdown file that contains the summary and YAML\nfront matter which stores the packages that will be released and the semver bump types for them.\n",
|
|
27
|
+
"examples": [
|
|
28
|
+
{
|
|
29
|
+
"description": "Add a new changeset to the project.",
|
|
30
|
+
"command": "<%= config.bin %> <%= command.id %>"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"description": "Add an empty changeset without any prompts.",
|
|
34
|
+
"command": "<%= config.bin %> <%= command.id %> --empty"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"description": "Add a new changeset and open it in the default editor.",
|
|
38
|
+
"command": "<%= config.bin %> <%= command.id %> --open"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"flags": {
|
|
42
|
+
"empty": {
|
|
43
|
+
"char": "e",
|
|
44
|
+
"description": "Create an empty changeset without prompts.",
|
|
45
|
+
"name": "empty",
|
|
46
|
+
"allowNo": false,
|
|
47
|
+
"type": "boolean"
|
|
48
|
+
},
|
|
49
|
+
"open": {
|
|
50
|
+
"char": "o",
|
|
51
|
+
"description": "Open the changeset in the default editor after creating it.",
|
|
52
|
+
"name": "open",
|
|
53
|
+
"allowNo": false,
|
|
54
|
+
"type": "boolean"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"hasDynamicHelp": false,
|
|
58
|
+
"hiddenAliases": [],
|
|
59
|
+
"id": "changeset:add",
|
|
60
|
+
"pluginAlias": "@jpp-toolkit/plugin-changesets",
|
|
61
|
+
"pluginName": "@jpp-toolkit/plugin-changesets",
|
|
62
|
+
"pluginType": "core",
|
|
63
|
+
"strict": true,
|
|
64
|
+
"summary": "Add a new changeset to the project."
|
|
65
|
+
},
|
|
66
|
+
"changeset:version": {
|
|
67
|
+
"aliases": [],
|
|
68
|
+
"args": {},
|
|
69
|
+
"description": "\nThis is one of two commands responsible for releasing packages. The version command takes changesets\nthat have been made and updates versions and dependencies of packages, as well as writing\nchangelogs. It is responsible for all file changes to versions before publishing to npm.\n",
|
|
70
|
+
"examples": [
|
|
71
|
+
{
|
|
72
|
+
"description": "Version packages based on changesets.",
|
|
73
|
+
"command": "<%= config.bin %> <%= command.id %>"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"description": "Version packages while ignoring specific packages.",
|
|
77
|
+
"command": "<%= config.bin %> <%= command.id %> --ignore package-a,package-b"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"description": "Version packages with snapshot versions.",
|
|
81
|
+
"command": "<%= config.bin %> <%= command.id %> --snapshot beta"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"flags": {
|
|
85
|
+
"ignore": {
|
|
86
|
+
"char": "i",
|
|
87
|
+
"description": "Comma-separated list of packages to ignore when versioning.",
|
|
88
|
+
"name": "ignore",
|
|
89
|
+
"required": false,
|
|
90
|
+
"hasDynamicHelp": false,
|
|
91
|
+
"multiple": false,
|
|
92
|
+
"type": "option"
|
|
93
|
+
},
|
|
94
|
+
"snapshot": {
|
|
95
|
+
"char": "s",
|
|
96
|
+
"description": "Create snapshot versions with the given tag.",
|
|
97
|
+
"name": "snapshot",
|
|
98
|
+
"required": false,
|
|
99
|
+
"hasDynamicHelp": false,
|
|
100
|
+
"multiple": false,
|
|
101
|
+
"type": "option"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"hasDynamicHelp": false,
|
|
105
|
+
"hiddenAliases": [],
|
|
106
|
+
"id": "changeset:version",
|
|
107
|
+
"pluginAlias": "@jpp-toolkit/plugin-changesets",
|
|
108
|
+
"pluginName": "@jpp-toolkit/plugin-changesets",
|
|
109
|
+
"pluginType": "core",
|
|
110
|
+
"strict": true,
|
|
111
|
+
"summary": "Takes changesets that have been made and updates versions and dependencies of packages, as well as writing changelogs."
|
|
112
|
+
},
|
|
113
|
+
"changeset:publish": {
|
|
114
|
+
"aliases": [],
|
|
115
|
+
"args": {},
|
|
116
|
+
"description": "\nThis publishes changes to npm, and creates git tags. This works by going into each package, checking\nif the version it has in its package.json is published on npm, and if it is not, running the npm\npublish. If you are using pnpm as a package manager, this automatically detects it and uses pnpm\npublish instead.\n",
|
|
117
|
+
"examples": [
|
|
118
|
+
{
|
|
119
|
+
"description": "Publish packages to npm and create git tags.",
|
|
120
|
+
"command": "<%= config.bin %> <%= command.id %>"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"description": "Publish packages with a one-time password.",
|
|
124
|
+
"command": "<%= config.bin %> <%= command.id %> --otp 123456"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"description": "Publish packages under a specific tag.",
|
|
128
|
+
"command": "<%= config.bin %> <%= command.id %> --tag beta"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"description": "Publish packages without creating git tags.",
|
|
132
|
+
"command": "<%= config.bin %> <%= command.id %> --no-git-tag"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"flags": {
|
|
136
|
+
"otp": {
|
|
137
|
+
"char": "o",
|
|
138
|
+
"description": "One-time password for publishing to npm.",
|
|
139
|
+
"name": "otp",
|
|
140
|
+
"required": false,
|
|
141
|
+
"hasDynamicHelp": false,
|
|
142
|
+
"multiple": false,
|
|
143
|
+
"type": "option"
|
|
144
|
+
},
|
|
145
|
+
"tag": {
|
|
146
|
+
"char": "t",
|
|
147
|
+
"description": "Tag to publish the package under.",
|
|
148
|
+
"name": "tag",
|
|
149
|
+
"required": false,
|
|
150
|
+
"hasDynamicHelp": false,
|
|
151
|
+
"multiple": false,
|
|
152
|
+
"type": "option"
|
|
153
|
+
},
|
|
154
|
+
"no-git-tag": {
|
|
155
|
+
"description": "Skip creating a git tag after publishing.",
|
|
156
|
+
"name": "no-git-tag",
|
|
157
|
+
"required": false,
|
|
158
|
+
"allowNo": false,
|
|
159
|
+
"type": "boolean"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"hasDynamicHelp": false,
|
|
163
|
+
"hiddenAliases": [],
|
|
164
|
+
"id": "changeset:publish",
|
|
165
|
+
"pluginAlias": "@jpp-toolkit/plugin-changesets",
|
|
166
|
+
"pluginName": "@jpp-toolkit/plugin-changesets",
|
|
167
|
+
"pluginType": "core",
|
|
168
|
+
"strict": true,
|
|
169
|
+
"summary": "Publishes changes to npm, and creates git tags."
|
|
170
|
+
},
|
|
171
|
+
"changeset:status": {
|
|
172
|
+
"aliases": [],
|
|
173
|
+
"args": {},
|
|
174
|
+
"description": "\nThe status command provides information about the changesets that currently exist. If there are no\nchangesets present, it exits with an error status code.\n",
|
|
175
|
+
"examples": [
|
|
176
|
+
{
|
|
177
|
+
"description": "Get the status of changesets in the project.",
|
|
178
|
+
"command": "<%= config.bin %> <%= command.id %>"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"description": "Get a verbose status of changesets, including new versions and links to summaries.",
|
|
182
|
+
"command": "<%= config.bin %> <%= command.id %> --verbose"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"description": "Output the status of changesets as a JSON object.",
|
|
186
|
+
"command": "<%= config.bin %> <%= command.id %> --output status.json"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"description": "Get the status of changesets since a specific branch or git tag.",
|
|
190
|
+
"command": "<%= config.bin %> <%= command.id %> --since main"
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
"flags": {
|
|
194
|
+
"verbose": {
|
|
195
|
+
"char": "v",
|
|
196
|
+
"description": "Use if you want to know the new versions, and get a link to the relevant changeset summary.",
|
|
197
|
+
"name": "verbose",
|
|
198
|
+
"required": false,
|
|
199
|
+
"allowNo": false,
|
|
200
|
+
"type": "boolean"
|
|
201
|
+
},
|
|
202
|
+
"output": {
|
|
203
|
+
"char": "o",
|
|
204
|
+
"description": "Allows you to write the JSON object of the status output for consumption by other tools, such as CI.",
|
|
205
|
+
"name": "output",
|
|
206
|
+
"required": false,
|
|
207
|
+
"hasDynamicHelp": false,
|
|
208
|
+
"multiple": false,
|
|
209
|
+
"type": "option"
|
|
210
|
+
},
|
|
211
|
+
"since": {
|
|
212
|
+
"char": "s",
|
|
213
|
+
"description": "Only display information about changesets since a specific branch or git tag (such as main, or the git hash of latest).",
|
|
214
|
+
"name": "since",
|
|
215
|
+
"required": false,
|
|
216
|
+
"hasDynamicHelp": false,
|
|
217
|
+
"multiple": false,
|
|
218
|
+
"type": "option"
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"hasDynamicHelp": false,
|
|
222
|
+
"hiddenAliases": [],
|
|
223
|
+
"id": "changeset:status",
|
|
224
|
+
"pluginAlias": "@jpp-toolkit/plugin-changesets",
|
|
225
|
+
"pluginName": "@jpp-toolkit/plugin-changesets",
|
|
226
|
+
"pluginType": "core",
|
|
227
|
+
"strict": true,
|
|
228
|
+
"summary": "Provides information about the changesets that currently exist."
|
|
229
|
+
},
|
|
230
|
+
"changeset:pre": {
|
|
231
|
+
"aliases": [],
|
|
232
|
+
"args": {
|
|
233
|
+
"action": {
|
|
234
|
+
"description": "The pre-release action to perform.",
|
|
235
|
+
"name": "action",
|
|
236
|
+
"options": [
|
|
237
|
+
"enter",
|
|
238
|
+
"exit"
|
|
239
|
+
],
|
|
240
|
+
"required": true
|
|
241
|
+
},
|
|
242
|
+
"tag": {
|
|
243
|
+
"description": "The pre-release tag to use when entering pre-release mode.",
|
|
244
|
+
"name": "tag",
|
|
245
|
+
"required": false
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"description": "\nThe pre command enters and exits pre mode. The command does not do any actual versioning, when doing\na pre-release, you should run changeset pre enter next(or a different tag, the tag is what is in\nversions and is the npm dist tag) and then do the normal release process with changeset version and\nchangeset publish.\n",
|
|
249
|
+
"examples": [
|
|
250
|
+
{
|
|
251
|
+
"description": "Enter pre-release mode with the \"next\" tag.",
|
|
252
|
+
"command": "<%= config.bin %> <%= command.id %> enter next"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"description": "Exit pre-release mode.",
|
|
256
|
+
"command": "<%= config.bin %> <%= command.id %> exit"
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
"flags": {},
|
|
260
|
+
"hasDynamicHelp": false,
|
|
261
|
+
"hiddenAliases": [],
|
|
262
|
+
"id": "changeset:pre",
|
|
263
|
+
"pluginAlias": "@jpp-toolkit/plugin-changesets",
|
|
264
|
+
"pluginName": "@jpp-toolkit/plugin-changesets",
|
|
265
|
+
"pluginType": "core",
|
|
266
|
+
"strict": true,
|
|
267
|
+
"summary": "Enters and exits pre-release mode for packages."
|
|
268
|
+
},
|
|
269
|
+
"changeset:tag": {
|
|
270
|
+
"aliases": [],
|
|
271
|
+
"args": {},
|
|
272
|
+
"description": "\nThe tag command creates git tags for the current version of all packages. The tags created are\nequivalent to those created by changeset publish, but the tag command does not publish anything to\nnpm.\n\nThis is helpful in situations where a different tool, such as pnpm publish -r, is used to publish\npackages instead of changeset. For situations where changeset publish is executed, running changeset\ntag is not needed.\n\nThe git tags in monorepos are created in the format pkg-name@version-number and are based on the\ncurrent version number of the package.json for each package. Note that in single-package\nrepositories, the git tag will include v before the version number, for example, v1.0.0. It is\nexpected that changeset version is run before changeset tag, so the package.json versions are\nupdated before the git tags are created.\n",
|
|
273
|
+
"flags": {},
|
|
274
|
+
"hasDynamicHelp": false,
|
|
275
|
+
"hiddenAliases": [],
|
|
276
|
+
"id": "changeset:tag",
|
|
277
|
+
"pluginAlias": "@jpp-toolkit/plugin-changesets",
|
|
278
|
+
"pluginName": "@jpp-toolkit/plugin-changesets",
|
|
279
|
+
"pluginType": "core",
|
|
280
|
+
"strict": true,
|
|
281
|
+
"summary": "Creates git tags for the current version of all packages."
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
"version": "0.0.11"
|
|
285
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jpp-toolkit/plugin-changesets",
|
|
3
|
+
"version": "0.0.11",
|
|
4
|
+
"description": "Plugin that add the changeset command to the jpp cli.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"jpp",
|
|
7
|
+
"plugin",
|
|
8
|
+
"changesets"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/jpapini/jpp-toolkit/tree/main/packages/plugin-changesets#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/jpapini/jpp-toolkit/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/jpapini/jpp-toolkit.git",
|
|
17
|
+
"directory": "packages/plugin-changesets"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Julien Papini <julien.papini@gmail.com> (https://github.com/jpapini)",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.mts",
|
|
25
|
+
"default": "./dist/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"src",
|
|
32
|
+
"oclif.config.js",
|
|
33
|
+
"oclif.manifest.json"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@changesets/cli": "2.29.8",
|
|
37
|
+
"@oclif/core": "4.8.0",
|
|
38
|
+
"execa": "9.6.1",
|
|
39
|
+
"@jpp-toolkit/core": "0.0.11",
|
|
40
|
+
"@jpp-toolkit/utils": "0.0.11"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"oclif": "4.22.52"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": "24",
|
|
47
|
+
"pnpm": "10"
|
|
48
|
+
},
|
|
49
|
+
"volta": {
|
|
50
|
+
"extends": "../../package.json"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"typecheck": "tsc --noEmit --pretty",
|
|
57
|
+
"dev": "build-lib --watch",
|
|
58
|
+
"build": "build-lib"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
|
|
3
|
+
import { ChangesetCommand } from './changeset-command';
|
|
4
|
+
|
|
5
|
+
export class AddChangesetCommand extends ChangesetCommand {
|
|
6
|
+
static override summary = 'Add a new changeset to the project.';
|
|
7
|
+
|
|
8
|
+
static override description = `
|
|
9
|
+
This is the main command people use to interact with the changesets.
|
|
10
|
+
|
|
11
|
+
This command will ask you a series of questions, first about what packages you want to release,
|
|
12
|
+
then what semver bump type for each package, then it will ask for a summary of the entire changeset.
|
|
13
|
+
The final step will show the changeset it will generate and confirm that you want to add it.
|
|
14
|
+
|
|
15
|
+
Once confirmed, the changeset will be written a Markdown file that contains the summary and YAML
|
|
16
|
+
front matter which stores the packages that will be released and the semver bump types for them.
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
static override flags = {
|
|
20
|
+
empty: Flags.boolean({
|
|
21
|
+
char: 'e',
|
|
22
|
+
description: 'Create an empty changeset without prompts.',
|
|
23
|
+
default: false,
|
|
24
|
+
}),
|
|
25
|
+
open: Flags.boolean({
|
|
26
|
+
char: 'o',
|
|
27
|
+
description: 'Open the changeset in the default editor after creating it.',
|
|
28
|
+
default: false,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
static override examples = [
|
|
33
|
+
{
|
|
34
|
+
description: 'Add a new changeset to the project.',
|
|
35
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
description: 'Add an empty changeset without any prompts.',
|
|
39
|
+
command: '<%= config.bin %> <%= command.id %> --empty',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: 'Add a new changeset and open it in the default editor.',
|
|
43
|
+
command: '<%= config.bin %> <%= command.id %> --open',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
public async run(): Promise<void> {
|
|
48
|
+
const { flags } = await this.parse(AddChangesetCommand);
|
|
49
|
+
|
|
50
|
+
const args: string[] = ['add'];
|
|
51
|
+
if (flags.empty) args.push('--empty');
|
|
52
|
+
if (flags.open) args.push('--open');
|
|
53
|
+
|
|
54
|
+
await this._execChangeset(args);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { Command } from '@jpp-toolkit/core';
|
|
5
|
+
import { findProjectRoot } from '@jpp-toolkit/utils';
|
|
6
|
+
import { execa } from 'execa';
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
|
|
10
|
+
const CHANGESET_BIN = path.resolve(require.resolve('@changesets/cli/package.json'), '../bin.js');
|
|
11
|
+
|
|
12
|
+
export abstract class ChangesetCommand extends Command {
|
|
13
|
+
protected async _execChangeset(args: string[] = []): Promise<void> {
|
|
14
|
+
const cwd = findProjectRoot();
|
|
15
|
+
const result = await execa(CHANGESET_BIN, args, { cwd, stdio: 'inherit', reject: false });
|
|
16
|
+
|
|
17
|
+
if (result.failed) process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AddChangesetCommand } from './add-changeset-command';
|
|
2
|
+
import { InitChangesetCommand } from './init-changeset-command';
|
|
3
|
+
import { PreChangesetCommand } from './pre-changeset-command';
|
|
4
|
+
import { PublishChangesetCommand } from './publish-changeset-command';
|
|
5
|
+
import { StatusChangesetCommand } from './status-changeset-command';
|
|
6
|
+
import { TagChangesetCommand } from './tag-changeset-command';
|
|
7
|
+
import { VersionChangesetCommand } from './version-changeset-command';
|
|
8
|
+
|
|
9
|
+
export const commands = {
|
|
10
|
+
'changeset:init': InitChangesetCommand,
|
|
11
|
+
'changeset:add': AddChangesetCommand,
|
|
12
|
+
'changeset:version': VersionChangesetCommand,
|
|
13
|
+
'changeset:publish': PublishChangesetCommand,
|
|
14
|
+
'changeset:status': StatusChangesetCommand,
|
|
15
|
+
'changeset:pre': PreChangesetCommand,
|
|
16
|
+
'changeset:tag': TagChangesetCommand,
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChangesetCommand } from './changeset-command';
|
|
2
|
+
|
|
3
|
+
export class InitChangesetCommand extends ChangesetCommand {
|
|
4
|
+
static override summary = 'Sets up the .changeset folder.';
|
|
5
|
+
|
|
6
|
+
static override description = `
|
|
7
|
+
This command sets up the .changeset folder. It generates a readme and a config file.
|
|
8
|
+
The config file includes the default options and comments on what these options represent.
|
|
9
|
+
You should run this command once when you are setting up changesets.
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
static override examples = [
|
|
13
|
+
{
|
|
14
|
+
description: 'Initialize changesets in your repository.',
|
|
15
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
public async run(): Promise<void> {
|
|
20
|
+
await this._execChangeset(['init']);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
|
|
3
|
+
import { ChangesetCommand } from './changeset-command';
|
|
4
|
+
|
|
5
|
+
export class PreChangesetCommand extends ChangesetCommand {
|
|
6
|
+
static override summary = 'Enters and exits pre-release mode for packages.';
|
|
7
|
+
|
|
8
|
+
static override description = `
|
|
9
|
+
The pre command enters and exits pre mode. The command does not do any actual versioning, when doing
|
|
10
|
+
a pre-release, you should run changeset pre enter next(or a different tag, the tag is what is in
|
|
11
|
+
versions and is the npm dist tag) and then do the normal release process with changeset version and
|
|
12
|
+
changeset publish.
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
static override args = {
|
|
16
|
+
action: Args.string({
|
|
17
|
+
name: 'action',
|
|
18
|
+
required: true,
|
|
19
|
+
description: 'The pre-release action to perform.',
|
|
20
|
+
options: ['enter', 'exit'],
|
|
21
|
+
}),
|
|
22
|
+
tag: Args.string({
|
|
23
|
+
name: 'tag',
|
|
24
|
+
required: false,
|
|
25
|
+
description: 'The pre-release tag to use when entering pre-release mode.',
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
static override examples = [
|
|
30
|
+
{
|
|
31
|
+
description: 'Enter pre-release mode with the "next" tag.',
|
|
32
|
+
command: '<%= config.bin %> <%= command.id %> enter next',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
description: 'Exit pre-release mode.',
|
|
36
|
+
command: '<%= config.bin %> <%= command.id %> exit',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
public async run(): Promise<void> {
|
|
41
|
+
const { args } = await this.parse(PreChangesetCommand);
|
|
42
|
+
|
|
43
|
+
const commandArgs: string[] = ['pre', args.action];
|
|
44
|
+
if (args.action === 'enter' && args.tag) commandArgs.push('--tag', args.tag);
|
|
45
|
+
|
|
46
|
+
await this._execChangeset(commandArgs);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
|
|
3
|
+
import { ChangesetCommand } from './changeset-command';
|
|
4
|
+
|
|
5
|
+
export class PublishChangesetCommand extends ChangesetCommand {
|
|
6
|
+
static override summary = 'Publishes changes to npm, and creates git tags.';
|
|
7
|
+
|
|
8
|
+
static override description = `
|
|
9
|
+
This publishes changes to npm, and creates git tags. This works by going into each package, checking
|
|
10
|
+
if the version it has in its package.json is published on npm, and if it is not, running the npm
|
|
11
|
+
publish. If you are using pnpm as a package manager, this automatically detects it and uses pnpm
|
|
12
|
+
publish instead.
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
static override flags = {
|
|
16
|
+
'otp': Flags.string({
|
|
17
|
+
char: 'o',
|
|
18
|
+
description: 'One-time password for publishing to npm.',
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
'tag': Flags.string({
|
|
22
|
+
char: 't',
|
|
23
|
+
description: 'Tag to publish the package under.',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
'no-git-tag': Flags.boolean({
|
|
27
|
+
description: 'Skip creating a git tag after publishing.',
|
|
28
|
+
required: false,
|
|
29
|
+
default: false,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
static override examples = [
|
|
34
|
+
{
|
|
35
|
+
description: 'Publish packages to npm and create git tags.',
|
|
36
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
description: 'Publish packages with a one-time password.',
|
|
40
|
+
command: '<%= config.bin %> <%= command.id %> --otp 123456',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
description: 'Publish packages under a specific tag.',
|
|
44
|
+
command: '<%= config.bin %> <%= command.id %> --tag beta',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
description: 'Publish packages without creating git tags.',
|
|
48
|
+
command: '<%= config.bin %> <%= command.id %> --no-git-tag',
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
public async run(): Promise<void> {
|
|
53
|
+
const { flags } = await this.parse(PublishChangesetCommand);
|
|
54
|
+
|
|
55
|
+
const args: string[] = ['publish'];
|
|
56
|
+
if (flags.otp) args.push('--otp', flags.otp);
|
|
57
|
+
if (flags.tag) args.push('--tag', flags.tag);
|
|
58
|
+
if (flags['no-git-tag']) args.push('--no-git-tag');
|
|
59
|
+
|
|
60
|
+
await this._execChangeset(args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
|
|
3
|
+
import { ChangesetCommand } from './changeset-command';
|
|
4
|
+
|
|
5
|
+
export class StatusChangesetCommand extends ChangesetCommand {
|
|
6
|
+
static override summary = 'Provides information about the changesets that currently exist.';
|
|
7
|
+
|
|
8
|
+
static override description = `
|
|
9
|
+
The status command provides information about the changesets that currently exist. If there are no
|
|
10
|
+
changesets present, it exits with an error status code.
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
static override flags = {
|
|
14
|
+
verbose: Flags.boolean({
|
|
15
|
+
char: 'v',
|
|
16
|
+
description:
|
|
17
|
+
'Use if you want to know the new versions, and get a link to the relevant changeset summary.',
|
|
18
|
+
required: false,
|
|
19
|
+
default: false,
|
|
20
|
+
}),
|
|
21
|
+
output: Flags.string({
|
|
22
|
+
char: 'o',
|
|
23
|
+
description:
|
|
24
|
+
'Allows you to write the JSON object of the status output for consumption by other tools, such as CI.',
|
|
25
|
+
required: false,
|
|
26
|
+
}),
|
|
27
|
+
since: Flags.string({
|
|
28
|
+
char: 's',
|
|
29
|
+
description:
|
|
30
|
+
'Only display information about changesets since a specific branch or git tag (such as main, or the git hash of latest).',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
static override examples = [
|
|
36
|
+
{
|
|
37
|
+
description: 'Get the status of changesets in the project.',
|
|
38
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
description:
|
|
42
|
+
'Get a verbose status of changesets, including new versions and links to summaries.',
|
|
43
|
+
command: '<%= config.bin %> <%= command.id %> --verbose',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
description: 'Output the status of changesets as a JSON object.',
|
|
47
|
+
command: '<%= config.bin %> <%= command.id %> --output status.json',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
description: 'Get the status of changesets since a specific branch or git tag.',
|
|
51
|
+
command: '<%= config.bin %> <%= command.id %> --since main',
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
public async run(): Promise<void> {
|
|
56
|
+
const { flags } = await this.parse(StatusChangesetCommand);
|
|
57
|
+
|
|
58
|
+
const args: string[] = ['status'];
|
|
59
|
+
if (flags.verbose) args.push('--verbose');
|
|
60
|
+
if (flags.output) args.push('--output', flags.output);
|
|
61
|
+
if (flags.since) args.push('--since', flags.since);
|
|
62
|
+
|
|
63
|
+
await this._execChangeset(args);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChangesetCommand } from './changeset-command';
|
|
2
|
+
|
|
3
|
+
export class TagChangesetCommand extends ChangesetCommand {
|
|
4
|
+
static override summary = 'Creates git tags for the current version of all packages.';
|
|
5
|
+
|
|
6
|
+
static override description = `
|
|
7
|
+
The tag command creates git tags for the current version of all packages. The tags created are
|
|
8
|
+
equivalent to those created by changeset publish, but the tag command does not publish anything to
|
|
9
|
+
npm.
|
|
10
|
+
|
|
11
|
+
This is helpful in situations where a different tool, such as pnpm publish -r, is used to publish
|
|
12
|
+
packages instead of changeset. For situations where changeset publish is executed, running changeset
|
|
13
|
+
tag is not needed.
|
|
14
|
+
|
|
15
|
+
The git tags in monorepos are created in the format pkg-name@version-number and are based on the
|
|
16
|
+
current version number of the package.json for each package. Note that in single-package
|
|
17
|
+
repositories, the git tag will include v before the version number, for example, v1.0.0. It is
|
|
18
|
+
expected that changeset version is run before changeset tag, so the package.json versions are
|
|
19
|
+
updated before the git tags are created.
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
public async run(): Promise<void> {
|
|
23
|
+
await this._execChangeset(['tag']);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
|
|
3
|
+
import { ChangesetCommand } from './changeset-command';
|
|
4
|
+
|
|
5
|
+
export class VersionChangesetCommand extends ChangesetCommand {
|
|
6
|
+
static override summary =
|
|
7
|
+
'Takes changesets that have been made and updates versions and dependencies of packages, as well as writing changelogs.';
|
|
8
|
+
|
|
9
|
+
static override description = `
|
|
10
|
+
This is one of two commands responsible for releasing packages. The version command takes changesets
|
|
11
|
+
that have been made and updates versions and dependencies of packages, as well as writing
|
|
12
|
+
changelogs. It is responsible for all file changes to versions before publishing to npm.
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
static override flags = {
|
|
16
|
+
ignore: Flags.string({
|
|
17
|
+
char: 'i',
|
|
18
|
+
description: 'Comma-separated list of packages to ignore when versioning.',
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
snapshot: Flags.string({
|
|
22
|
+
char: 's',
|
|
23
|
+
description: 'Create snapshot versions with the given tag.',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static override examples = [
|
|
29
|
+
{
|
|
30
|
+
description: 'Version packages based on changesets.',
|
|
31
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: 'Version packages while ignoring specific packages.',
|
|
35
|
+
command: '<%= config.bin %> <%= command.id %> --ignore package-a,package-b',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
description: 'Version packages with snapshot versions.',
|
|
39
|
+
command: '<%= config.bin %> <%= command.id %> --snapshot beta',
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
public async run(): Promise<void> {
|
|
44
|
+
const { flags } = await this.parse(VersionChangesetCommand);
|
|
45
|
+
|
|
46
|
+
const args: string[] = ['version'];
|
|
47
|
+
if (flags.ignore) args.push('--ignore', flags.ignore);
|
|
48
|
+
if (flags.snapshot) args.push('--snapshot', flags.snapshot);
|
|
49
|
+
|
|
50
|
+
await this._execChangeset(args);
|
|
51
|
+
}
|
|
52
|
+
}
|