@varlet/release 0.2.1 → 0.2.3
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/README.md +12 -6
- package/README.zh-CN.md +12 -6
- package/bin/index.js +3 -1
- package/dist/index.cjs +33 -10
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +33 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,8 +68,9 @@ npx vr publish
|
|
|
68
68
|
| Params | Instructions |
|
|
69
69
|
| ---------------------- | ------------------- |
|
|
70
70
|
| -r --remote \<remote\> | Specify remote name |
|
|
71
|
-
| -s --skip-npm-publish | Skip npm publish
|
|
72
|
-
| -
|
|
71
|
+
| -s --skip-npm-publish | Skip npm publish |
|
|
72
|
+
| -sc --skip-changelog | Skip generate changelog |
|
|
73
|
+
| -sgt --skip-git-tag | Skip git tag |
|
|
73
74
|
|
|
74
75
|
#### changelog
|
|
75
76
|
|
|
@@ -89,9 +90,9 @@ npx vr publish
|
|
|
89
90
|
|
|
90
91
|
#### publish
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
| 参数 | 说明 |
|
|
94
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
95
|
+
| -c --check-remote-version | Detects whether the remote version of the npm package is the same as the package version to be published locally, and if it is, skip the release |
|
|
95
96
|
|
|
96
97
|
### Custom Handle
|
|
97
98
|
|
|
@@ -120,11 +121,16 @@ release({ task })
|
|
|
120
121
|
#### Types
|
|
121
122
|
|
|
122
123
|
```ts
|
|
123
|
-
|
|
124
|
+
interface PublishCommandOptions {
|
|
125
|
+
preRelease?: boolean
|
|
126
|
+
checkRemoteVersion?: boolean
|
|
127
|
+
}
|
|
128
|
+
function publish({ preRelease, checkRemoteVersion }: PublishCommandOptions): Promise<void>
|
|
124
129
|
function updateVersion(version: string): void
|
|
125
130
|
interface ReleaseCommandOptions {
|
|
126
131
|
remote?: string
|
|
127
132
|
skipNpmPublish?: boolean
|
|
133
|
+
skipChangelog?: boolean
|
|
128
134
|
skipGitTag?: boolean
|
|
129
135
|
task?(): Promise<void>
|
|
130
136
|
}
|
package/README.zh-CN.md
CHANGED
|
@@ -68,8 +68,9 @@ npx vr publish
|
|
|
68
68
|
| 参数 | 说明 |
|
|
69
69
|
| ---------------------- | ---------------- |
|
|
70
70
|
| -r --remote \<remote\> | 指定远程仓库名称 |
|
|
71
|
-
| -s --skip-npm-publish | 跳过 npm 发布
|
|
72
|
-
| -
|
|
71
|
+
| -s --skip-npm-publish | 跳过 npm 发布 |
|
|
72
|
+
| -sc --skip-changelog | 跳过生成变更日志 |
|
|
73
|
+
| -sgt --skip-git-tag | 跳过 git tag |
|
|
73
74
|
|
|
74
75
|
#### changelog
|
|
75
76
|
|
|
@@ -89,9 +90,9 @@ npx vr publish
|
|
|
89
90
|
|
|
90
91
|
#### publish
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
| 参数 | 说明 |
|
|
94
|
+
| ------------------------- | --------------------------------------------------------------------- |
|
|
95
|
+
| -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
|
|
95
96
|
|
|
96
97
|
### 自定义处理
|
|
97
98
|
|
|
@@ -120,11 +121,16 @@ release({ task })
|
|
|
120
121
|
#### 类型
|
|
121
122
|
|
|
122
123
|
```ts
|
|
123
|
-
|
|
124
|
+
interface PublishCommandOptions {
|
|
125
|
+
preRelease?: boolean
|
|
126
|
+
checkRemoteVersion?: boolean
|
|
127
|
+
}
|
|
128
|
+
function publish({ preRelease, checkRemoteVersion }: PublishCommandOptions): Promise<void>
|
|
124
129
|
function updateVersion(version: string): void
|
|
125
130
|
interface ReleaseCommandOptions {
|
|
126
131
|
remote?: string
|
|
127
132
|
skipNpmPublish?: boolean
|
|
133
|
+
skipChangelog?: boolean
|
|
128
134
|
skipGitTag?: boolean
|
|
129
135
|
task?(): Promise<void>
|
|
130
136
|
}
|
package/bin/index.js
CHANGED
|
@@ -8,14 +8,16 @@ program
|
|
|
8
8
|
.command('release')
|
|
9
9
|
.option('-r --remote <remote>', 'Remote name')
|
|
10
10
|
.option('-s --skip-npm-publish', 'Skip npm publish')
|
|
11
|
+
.option('-sc --skip-changelog', 'Skip generate changelog')
|
|
11
12
|
.option('-sgt --skip-git-tag', 'Skip git tag')
|
|
12
13
|
.description('Release all packages and generate changelogs')
|
|
13
14
|
.action(async (options) => release(options))
|
|
14
15
|
|
|
15
16
|
program
|
|
16
17
|
.command('publish')
|
|
18
|
+
.option('-c --check-remote-version', 'Check remote version')
|
|
17
19
|
.description('Publish to npm')
|
|
18
|
-
.action(async () => publish())
|
|
20
|
+
.action(async (options) => publish(options))
|
|
19
21
|
|
|
20
22
|
program
|
|
21
23
|
.command('changelog')
|
package/dist/index.cjs
CHANGED
|
@@ -100,9 +100,23 @@ async function isWorktreeEmpty() {
|
|
|
100
100
|
const ret = await (0, import_execa.execa)("git", ["status", "--porcelain"]);
|
|
101
101
|
return !ret.stdout;
|
|
102
102
|
}
|
|
103
|
-
async function publish(preRelease) {
|
|
103
|
+
async function publish({ preRelease, checkRemoteVersion }) {
|
|
104
104
|
const s = (0, import_nanospinner2.createSpinner)("Publishing all packages").start();
|
|
105
105
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
106
|
+
if (checkRemoteVersion) {
|
|
107
|
+
const packageJson = getPackageJsons().find((packageJson2) => !packageJson2.config.private);
|
|
108
|
+
if (packageJson) {
|
|
109
|
+
const { config } = packageJson;
|
|
110
|
+
try {
|
|
111
|
+
await (0, import_execa.execa)("npm", ["view", `${config.name}@${config.version}`, "version"]);
|
|
112
|
+
s.warn({
|
|
113
|
+
text: `The npm package has a same remote version ${config.version}, publishing automatically skipped.`
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
} catch {
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
106
120
|
if (preRelease) {
|
|
107
121
|
args.push("--tag", "alpha");
|
|
108
122
|
}
|
|
@@ -120,20 +134,27 @@ async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
|
120
134
|
await (0, import_execa.execa)("git", ["commit", "-m", `v${version}`]);
|
|
121
135
|
if (!skipGitTag) {
|
|
122
136
|
await (0, import_execa.execa)("git", ["tag", `v${version}`]);
|
|
137
|
+
await (0, import_execa.execa)("git", ["push", remote, `v${version}`]);
|
|
123
138
|
}
|
|
124
|
-
await (0, import_execa.execa)("git", ["push", remote, `v${version}`]);
|
|
125
139
|
const ret = await (0, import_execa.execa)("git", ["push"]);
|
|
126
140
|
s.success({ text: "Push remote repository successfully" });
|
|
127
141
|
ret.stdout && logger_default.info(ret.stdout);
|
|
128
142
|
}
|
|
143
|
+
function getPackageJsons() {
|
|
144
|
+
const packageJsons = ["package.json", ...import_glob.glob.sync("packages/*/package.json")];
|
|
145
|
+
return packageJsons.map((path) => {
|
|
146
|
+
const filePath = (0, import_path2.resolve)(cwd, path);
|
|
147
|
+
return {
|
|
148
|
+
config: readJSONSync(filePath),
|
|
149
|
+
filePath
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
129
153
|
function updateVersion(version) {
|
|
130
|
-
const packageJsons =
|
|
131
|
-
packageJsons.
|
|
132
|
-
packageJsons.forEach((path) => {
|
|
133
|
-
const file = (0, import_path2.resolve)(cwd, path);
|
|
134
|
-
const config = readJSONSync(file);
|
|
154
|
+
const packageJsons = getPackageJsons();
|
|
155
|
+
packageJsons.forEach(({ config, filePath }) => {
|
|
135
156
|
config.version = version;
|
|
136
|
-
writeFileSync(
|
|
157
|
+
writeFileSync(filePath, JSON.stringify(config, null, 2));
|
|
137
158
|
});
|
|
138
159
|
}
|
|
139
160
|
async function confirmRegistry() {
|
|
@@ -214,10 +235,12 @@ async function release(options) {
|
|
|
214
235
|
await options.task();
|
|
215
236
|
}
|
|
216
237
|
if (!options.skipNpmPublish) {
|
|
217
|
-
await publish(isPreRelease);
|
|
238
|
+
await publish({ preRelease: isPreRelease });
|
|
218
239
|
}
|
|
219
240
|
if (!isPreRelease) {
|
|
220
|
-
|
|
241
|
+
if (!options.skipChangelog) {
|
|
242
|
+
await changelog();
|
|
243
|
+
}
|
|
221
244
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
|
222
245
|
}
|
|
223
246
|
logger_default.success(`Release version ${expectVersion} successfully!`);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
interface PublishCommandOptions {
|
|
2
|
+
preRelease?: boolean;
|
|
3
|
+
checkRemoteVersion?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare function publish({ preRelease, checkRemoteVersion }: PublishCommandOptions): Promise<void>;
|
|
2
6
|
declare function updateVersion(version: string): void;
|
|
3
7
|
interface ReleaseCommandOptions {
|
|
4
8
|
remote?: string;
|
|
5
9
|
skipNpmPublish?: boolean;
|
|
10
|
+
skipChangelog?: boolean;
|
|
6
11
|
skipGitTag?: boolean;
|
|
7
12
|
task?(): Promise<void>;
|
|
8
13
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
interface PublishCommandOptions {
|
|
2
|
+
preRelease?: boolean;
|
|
3
|
+
checkRemoteVersion?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare function publish({ preRelease, checkRemoteVersion }: PublishCommandOptions): Promise<void>;
|
|
2
6
|
declare function updateVersion(version: string): void;
|
|
3
7
|
interface ReleaseCommandOptions {
|
|
4
8
|
remote?: string;
|
|
5
9
|
skipNpmPublish?: boolean;
|
|
10
|
+
skipChangelog?: boolean;
|
|
6
11
|
skipGitTag?: boolean;
|
|
7
12
|
task?(): Promise<void>;
|
|
8
13
|
}
|
package/dist/index.js
CHANGED
|
@@ -57,9 +57,23 @@ async function isWorktreeEmpty() {
|
|
|
57
57
|
const ret = await execa("git", ["status", "--porcelain"]);
|
|
58
58
|
return !ret.stdout;
|
|
59
59
|
}
|
|
60
|
-
async function publish(preRelease) {
|
|
60
|
+
async function publish({ preRelease, checkRemoteVersion }) {
|
|
61
61
|
const s = createSpinner2("Publishing all packages").start();
|
|
62
62
|
const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
|
|
63
|
+
if (checkRemoteVersion) {
|
|
64
|
+
const packageJson = getPackageJsons().find((packageJson2) => !packageJson2.config.private);
|
|
65
|
+
if (packageJson) {
|
|
66
|
+
const { config } = packageJson;
|
|
67
|
+
try {
|
|
68
|
+
await execa("npm", ["view", `${config.name}@${config.version}`, "version"]);
|
|
69
|
+
s.warn({
|
|
70
|
+
text: `The npm package has a same remote version ${config.version}, publishing automatically skipped.`
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
63
77
|
if (preRelease) {
|
|
64
78
|
args.push("--tag", "alpha");
|
|
65
79
|
}
|
|
@@ -77,20 +91,27 @@ async function pushGit(version, remote = "origin", skipGitTag = false) {
|
|
|
77
91
|
await execa("git", ["commit", "-m", `v${version}`]);
|
|
78
92
|
if (!skipGitTag) {
|
|
79
93
|
await execa("git", ["tag", `v${version}`]);
|
|
94
|
+
await execa("git", ["push", remote, `v${version}`]);
|
|
80
95
|
}
|
|
81
|
-
await execa("git", ["push", remote, `v${version}`]);
|
|
82
96
|
const ret = await execa("git", ["push"]);
|
|
83
97
|
s.success({ text: "Push remote repository successfully" });
|
|
84
98
|
ret.stdout && logger_default.info(ret.stdout);
|
|
85
99
|
}
|
|
100
|
+
function getPackageJsons() {
|
|
101
|
+
const packageJsons = ["package.json", ...glob.sync("packages/*/package.json")];
|
|
102
|
+
return packageJsons.map((path) => {
|
|
103
|
+
const filePath = resolve(cwd, path);
|
|
104
|
+
return {
|
|
105
|
+
config: readJSONSync(filePath),
|
|
106
|
+
filePath
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
86
110
|
function updateVersion(version) {
|
|
87
|
-
const packageJsons =
|
|
88
|
-
packageJsons.
|
|
89
|
-
packageJsons.forEach((path) => {
|
|
90
|
-
const file = resolve(cwd, path);
|
|
91
|
-
const config = readJSONSync(file);
|
|
111
|
+
const packageJsons = getPackageJsons();
|
|
112
|
+
packageJsons.forEach(({ config, filePath }) => {
|
|
92
113
|
config.version = version;
|
|
93
|
-
writeFileSync(
|
|
114
|
+
writeFileSync(filePath, JSON.stringify(config, null, 2));
|
|
94
115
|
});
|
|
95
116
|
}
|
|
96
117
|
async function confirmRegistry() {
|
|
@@ -171,10 +192,12 @@ async function release(options) {
|
|
|
171
192
|
await options.task();
|
|
172
193
|
}
|
|
173
194
|
if (!options.skipNpmPublish) {
|
|
174
|
-
await publish(isPreRelease);
|
|
195
|
+
await publish({ preRelease: isPreRelease });
|
|
175
196
|
}
|
|
176
197
|
if (!isPreRelease) {
|
|
177
|
-
|
|
198
|
+
if (!options.skipChangelog) {
|
|
199
|
+
await changelog();
|
|
200
|
+
}
|
|
178
201
|
await pushGit(expectVersion, options.remote, options.skipGitTag);
|
|
179
202
|
}
|
|
180
203
|
logger_default.success(`Release version ${expectVersion} successfully!`);
|