@modern-js/plugin-changeset 1.0.0-alpha.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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/js/modern/commands/bump.js +34 -0
- package/dist/js/modern/commands/change.js +33 -0
- package/dist/js/modern/commands/index.js +4 -0
- package/dist/js/modern/commands/pre.js +10 -0
- package/dist/js/modern/commands/release.js +16 -0
- package/dist/js/modern/index.js +27 -0
- package/dist/js/modern/locale/en.js +24 -0
- package/dist/js/modern/locale/index.js +9 -0
- package/dist/js/modern/locale/zh.js +24 -0
- package/dist/js/modern/utils/changeset.js +10 -0
- package/dist/js/modern/utils/index.js +2 -0
- package/dist/js/modern/utils/language.js +5 -0
- package/dist/js/node/commands/bump.js +42 -0
- package/dist/js/node/commands/change.js +44 -0
- package/dist/js/node/commands/index.js +57 -0
- package/dist/js/node/commands/pre.js +18 -0
- package/dist/js/node/commands/release.js +25 -0
- package/dist/js/node/index.js +41 -0
- package/dist/js/node/locale/en.js +31 -0
- package/dist/js/node/locale/index.js +20 -0
- package/dist/js/node/locale/zh.js +31 -0
- package/dist/js/node/utils/changeset.js +24 -0
- package/dist/js/node/utils/index.js +31 -0
- package/dist/js/node/utils/language.js +13 -0
- package/dist/types/commands/bump.d.ts +8 -0
- package/dist/types/commands/change.d.ts +6 -0
- package/dist/types/commands/index.d.ts +4 -0
- package/dist/types/commands/pre.d.ts +1 -0
- package/dist/types/commands/release.d.ts +5 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/locale/en.d.ts +24 -0
- package/dist/types/locale/index.d.ts +50 -0
- package/dist/types/locale/zh.d.ts +24 -0
- package/dist/types/utils/changeset.d.ts +3 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/language.d.ts +1 -0
- package/modern.config.js +2 -0
- package/package.json +46 -0
- package/src/commands/bump.ts +41 -0
- package/src/commands/change.ts +38 -0
- package/src/commands/index.ts +4 -0
- package/src/commands/pre.ts +11 -0
- package/src/commands/release.ts +19 -0
- package/src/index.ts +49 -0
- package/src/locale/en.ts +25 -0
- package/src/locale/index.ts +9 -0
- package/src/locale/zh.ts +25 -0
- package/src/utils/changeset.ts +12 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/language.ts +6 -0
- package/tsconfig.json +13 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @modern-js/plugin-changeset
|
|
2
|
+
|
|
3
|
+
## 1.0.0-alpha.3
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- feat: initial
|
|
7
|
+
- Updated dependencies [undefined]
|
|
8
|
+
- @modern-js/core@1.0.0-alpha.3
|
|
9
|
+
- @modern-js/i18n-cli-language-detector@1.0.0-alpha.3
|
|
10
|
+
- @modern-js/plugin-i18n@1.0.0-alpha.3
|
|
11
|
+
- @modern-js/utils@1.0.0-alpha.3
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Modern.js
|
|
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/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
<p align="center">
|
|
3
|
+
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<p align="center">现代 Web 工程体系</p>
|
|
7
|
+
|
|
8
|
+
## 背景
|
|
9
|
+
- [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
|
|
10
|
+
- [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
|
|
11
|
+
|
|
12
|
+
## 计划
|
|
13
|
+
|
|
14
|
+
Modern.js 的 1.0.0.rc 版已经发到 npm,目前在做测试改进,README 文档之后统一提供(现阶段加入测试和开发,可以发 [issue](https://github.com/modern-js-dev/modern.js/issues) 留微信联系),完整的文档站计划在10月14日上线
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
2
|
+
export async function bump(options) {
|
|
3
|
+
const {
|
|
4
|
+
snapshot,
|
|
5
|
+
canary,
|
|
6
|
+
preid,
|
|
7
|
+
ignore
|
|
8
|
+
} = options;
|
|
9
|
+
const params = [CHANGESET_PATH, 'version'];
|
|
10
|
+
|
|
11
|
+
if (snapshot) {
|
|
12
|
+
params.push('--snapshot');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (ignore) {
|
|
16
|
+
ignore.forEach(pkg => {
|
|
17
|
+
params.push('--ignore');
|
|
18
|
+
params.push(pkg);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (canary) {
|
|
23
|
+
await execaWithStreamLog('node', [CHANGESET_PATH, 'pre', 'enter', preid || 'next']);
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
await execaWithStreamLog('node', params);
|
|
27
|
+
await execaWithStreamLog('node', [CHANGESET_PATH, 'pre', 'exit']);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
await execaWithStreamLog('node', [CHANGESET_PATH, 'pre', 'exit']);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
await execaWithStreamLog('node', params);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isMonorepo, getMonorepoPackages, getPackageManager, logger } from '@modern-js/utils';
|
|
2
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
3
|
+
import { i18n, localeKeys } from "../locale";
|
|
4
|
+
export async function change(options) {
|
|
5
|
+
const appDir = process.cwd();
|
|
6
|
+
|
|
7
|
+
if (isMonorepo(appDir)) {
|
|
8
|
+
const packages = getMonorepoPackages(appDir);
|
|
9
|
+
|
|
10
|
+
if (packages.length === 0) {
|
|
11
|
+
logger.warn(i18n.t(localeKeys.command.change.no_packages, {
|
|
12
|
+
packageManager: getPackageManager(appDir)
|
|
13
|
+
}));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
empty,
|
|
20
|
+
open
|
|
21
|
+
} = options;
|
|
22
|
+
const params = [CHANGESET_PATH, 'add'];
|
|
23
|
+
|
|
24
|
+
if (empty) {
|
|
25
|
+
params.push('--empty');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (open) {
|
|
29
|
+
params.push('--open');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await execaWithStreamLog('node', params);
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
2
|
+
export async function pre(type, tag = 'next') {
|
|
3
|
+
const params = [CHANGESET_PATH, 'pre', type];
|
|
4
|
+
|
|
5
|
+
if (type === 'enter') {
|
|
6
|
+
params.push(tag);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
await execaWithStreamLog('node', params);
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getPackageManager } from '@modern-js/utils';
|
|
2
|
+
import { execaWithStreamLog } from "../utils";
|
|
3
|
+
export async function release(options) {
|
|
4
|
+
const packageManager = getPackageManager(process.cwd());
|
|
5
|
+
const {
|
|
6
|
+
tag
|
|
7
|
+
} = options;
|
|
8
|
+
const params = ['publish', '-r', '--ignore-scripts'];
|
|
9
|
+
|
|
10
|
+
if (tag) {
|
|
11
|
+
params.push('--tag');
|
|
12
|
+
params.push(tag);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
await execaWithStreamLog(packageManager, params);
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createPlugin } from '@modern-js/core';
|
|
2
|
+
import { change, bump, pre, release } from "./commands";
|
|
3
|
+
import { i18n, localeKeys } from "./locale";
|
|
4
|
+
import { getLocaleLanguage } from "./utils";
|
|
5
|
+
export default createPlugin(() => {
|
|
6
|
+
// initial cli language
|
|
7
|
+
i18n.changeLanguage({
|
|
8
|
+
locale: getLocaleLanguage()
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
plugins() {
|
|
12
|
+
return [{}];
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
commands({
|
|
16
|
+
program
|
|
17
|
+
}) {
|
|
18
|
+
program.command('change').description(i18n.t(localeKeys.command.change.describe)).option('--empty', i18n.t(localeKeys.command.change.empty), false).option('--open', i18n.t(localeKeys.command.change.open), false).action(options => change(options));
|
|
19
|
+
program.command('bump').description(i18n.t(localeKeys.command.bump.describe)).option('--canary', i18n.t(localeKeys.command.bump.canary), false).option('--preid <tag>', i18n.t(localeKeys.command.bump.preid), 'next').option('--snapshot', i18n.t(localeKeys.command.bump.snapshot), false).action(options => bump(options));
|
|
20
|
+
program.command('pre <enter|exit> [tag]').description(i18n.t(localeKeys.command.pre.describe)).action((type, tag) => pre(type, tag));
|
|
21
|
+
program.command('release').description(i18n.t(localeKeys.command.release.describe)).option('--tag <tag>', i18n.t(localeKeys.command.release.tag), '').action(options => release(options));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
};
|
|
25
|
+
}, {
|
|
26
|
+
name: '@modern-js/plugin-changeset'
|
|
27
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const EN_LOCALE = {
|
|
2
|
+
command: {
|
|
3
|
+
change: {
|
|
4
|
+
describe: 'create changeset',
|
|
5
|
+
empty: 'create an empty changeset',
|
|
6
|
+
open: 'opens the created changeset in an external editor',
|
|
7
|
+
no_packages: 'not find sub-project,please use `{packageManager} new` to create sub-project'
|
|
8
|
+
},
|
|
9
|
+
bump: {
|
|
10
|
+
describe: 'auto update publish version and changelog using changeset',
|
|
11
|
+
canary: 'create a prerelease version of publishing for testing',
|
|
12
|
+
preid: 'specify the identifier when versioning a prerelease',
|
|
13
|
+
snapshot: 'create a special kind of publishing for testing',
|
|
14
|
+
ignore: 'skip packages from being published'
|
|
15
|
+
},
|
|
16
|
+
pre: {
|
|
17
|
+
describe: 'enters and exits pre mode'
|
|
18
|
+
},
|
|
19
|
+
release: {
|
|
20
|
+
describe: 'publish changes to npm',
|
|
21
|
+
tag: 'publish use special tag'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const ZH_LOCALE = {
|
|
2
|
+
command: {
|
|
3
|
+
change: {
|
|
4
|
+
describe: '创建变更集',
|
|
5
|
+
empty: '创建空变更集',
|
|
6
|
+
open: '使用编辑器中打开创建的变更集',
|
|
7
|
+
no_packages: '未找到子项目,请先执行 「{packageManager} new」 命令创建子项目'
|
|
8
|
+
},
|
|
9
|
+
bump: {
|
|
10
|
+
describe: '使用变更集自动更新发布版本和变更日志',
|
|
11
|
+
canary: '创建一个预发布版本进行测试',
|
|
12
|
+
preid: '在对预发布版本进行版本控制时指定标识符',
|
|
13
|
+
snapshot: '创建一个特殊版本进行测试',
|
|
14
|
+
ignore: '跳过部分包发布版本'
|
|
15
|
+
},
|
|
16
|
+
pre: {
|
|
17
|
+
describe: '进入和退出预发布模式'
|
|
18
|
+
},
|
|
19
|
+
release: {
|
|
20
|
+
describe: '发布 npm 包',
|
|
21
|
+
tag: '发布 npm 包使用特定的 tag'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
export const CHANGESET_PATH = require.resolve('@changesets/cli');
|
|
3
|
+
export function execaWithStreamLog(command, args) {
|
|
4
|
+
const promise = execa(command, args, {
|
|
5
|
+
stdin: 'inherit',
|
|
6
|
+
stdout: 'inherit',
|
|
7
|
+
stderr: 'inherit'
|
|
8
|
+
});
|
|
9
|
+
return promise;
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bump = bump;
|
|
7
|
+
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
|
|
10
|
+
async function bump(options) {
|
|
11
|
+
const {
|
|
12
|
+
snapshot,
|
|
13
|
+
canary,
|
|
14
|
+
preid,
|
|
15
|
+
ignore
|
|
16
|
+
} = options;
|
|
17
|
+
const params = [_utils.CHANGESET_PATH, 'version'];
|
|
18
|
+
|
|
19
|
+
if (snapshot) {
|
|
20
|
+
params.push('--snapshot');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (ignore) {
|
|
24
|
+
ignore.forEach(pkg => {
|
|
25
|
+
params.push('--ignore');
|
|
26
|
+
params.push(pkg);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (canary) {
|
|
31
|
+
await (0, _utils.execaWithStreamLog)('node', [_utils.CHANGESET_PATH, 'pre', 'enter', preid || 'next']);
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
await (0, _utils.execaWithStreamLog)('node', params);
|
|
35
|
+
await (0, _utils.execaWithStreamLog)('node', [_utils.CHANGESET_PATH, 'pre', 'exit']);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
await (0, _utils.execaWithStreamLog)('node', [_utils.CHANGESET_PATH, 'pre', 'exit']);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
await (0, _utils.execaWithStreamLog)('node', params);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.change = change;
|
|
7
|
+
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
var _utils2 = require("../utils");
|
|
11
|
+
|
|
12
|
+
var _locale = require("../locale");
|
|
13
|
+
|
|
14
|
+
async function change(options) {
|
|
15
|
+
const appDir = process.cwd();
|
|
16
|
+
|
|
17
|
+
if ((0, _utils.isMonorepo)(appDir)) {
|
|
18
|
+
const packages = (0, _utils.getMonorepoPackages)(appDir);
|
|
19
|
+
|
|
20
|
+
if (packages.length === 0) {
|
|
21
|
+
_utils.logger.warn(_locale.i18n.t(_locale.localeKeys.command.change.no_packages, {
|
|
22
|
+
packageManager: (0, _utils.getPackageManager)(appDir)
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
empty,
|
|
31
|
+
open
|
|
32
|
+
} = options;
|
|
33
|
+
const params = [_utils2.CHANGESET_PATH, 'add'];
|
|
34
|
+
|
|
35
|
+
if (empty) {
|
|
36
|
+
params.push('--empty');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (open) {
|
|
40
|
+
params.push('--open');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await (0, _utils2.execaWithStreamLog)('node', params);
|
|
44
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _change = require("./change");
|
|
8
|
+
|
|
9
|
+
Object.keys(_change).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _change[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _change[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _bump = require("./bump");
|
|
21
|
+
|
|
22
|
+
Object.keys(_bump).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _bump[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _bump[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _pre = require("./pre");
|
|
34
|
+
|
|
35
|
+
Object.keys(_pre).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _pre[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _pre[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _release = require("./release");
|
|
47
|
+
|
|
48
|
+
Object.keys(_release).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _release[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _release[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pre = pre;
|
|
7
|
+
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
|
|
10
|
+
async function pre(type, tag = 'next') {
|
|
11
|
+
const params = [_utils.CHANGESET_PATH, 'pre', type];
|
|
12
|
+
|
|
13
|
+
if (type === 'enter') {
|
|
14
|
+
params.push(tag);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await (0, _utils.execaWithStreamLog)('node', params);
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.release = release;
|
|
7
|
+
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
var _utils2 = require("../utils");
|
|
11
|
+
|
|
12
|
+
async function release(options) {
|
|
13
|
+
const packageManager = (0, _utils.getPackageManager)(process.cwd());
|
|
14
|
+
const {
|
|
15
|
+
tag
|
|
16
|
+
} = options;
|
|
17
|
+
const params = ['publish', '-r', '--ignore-scripts'];
|
|
18
|
+
|
|
19
|
+
if (tag) {
|
|
20
|
+
params.push('--tag');
|
|
21
|
+
params.push(tag);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await (0, _utils2.execaWithStreamLog)(packageManager, params);
|
|
25
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _core = require("@modern-js/core");
|
|
9
|
+
|
|
10
|
+
var _commands = require("./commands");
|
|
11
|
+
|
|
12
|
+
var _locale = require("./locale");
|
|
13
|
+
|
|
14
|
+
var _utils = require("./utils");
|
|
15
|
+
|
|
16
|
+
var _default = (0, _core.createPlugin)(() => {
|
|
17
|
+
// initial cli language
|
|
18
|
+
_locale.i18n.changeLanguage({
|
|
19
|
+
locale: (0, _utils.getLocaleLanguage)()
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
plugins() {
|
|
24
|
+
return [{}];
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
commands({
|
|
28
|
+
program
|
|
29
|
+
}) {
|
|
30
|
+
program.command('change').description(_locale.i18n.t(_locale.localeKeys.command.change.describe)).option('--empty', _locale.i18n.t(_locale.localeKeys.command.change.empty), false).option('--open', _locale.i18n.t(_locale.localeKeys.command.change.open), false).action(options => (0, _commands.change)(options));
|
|
31
|
+
program.command('bump').description(_locale.i18n.t(_locale.localeKeys.command.bump.describe)).option('--canary', _locale.i18n.t(_locale.localeKeys.command.bump.canary), false).option('--preid <tag>', _locale.i18n.t(_locale.localeKeys.command.bump.preid), 'next').option('--snapshot', _locale.i18n.t(_locale.localeKeys.command.bump.snapshot), false).action(options => (0, _commands.bump)(options));
|
|
32
|
+
program.command('pre <enter|exit> [tag]').description(_locale.i18n.t(_locale.localeKeys.command.pre.describe)).action((type, tag) => (0, _commands.pre)(type, tag));
|
|
33
|
+
program.command('release').description(_locale.i18n.t(_locale.localeKeys.command.release.describe)).option('--tag <tag>', _locale.i18n.t(_locale.localeKeys.command.release.tag), '').action(options => (0, _commands.release)(options));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
};
|
|
37
|
+
}, {
|
|
38
|
+
name: '@modern-js/plugin-changeset'
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EN_LOCALE = void 0;
|
|
7
|
+
const EN_LOCALE = {
|
|
8
|
+
command: {
|
|
9
|
+
change: {
|
|
10
|
+
describe: 'create changeset',
|
|
11
|
+
empty: 'create an empty changeset',
|
|
12
|
+
open: 'opens the created changeset in an external editor',
|
|
13
|
+
no_packages: 'not find sub-project,please use `{packageManager} new` to create sub-project'
|
|
14
|
+
},
|
|
15
|
+
bump: {
|
|
16
|
+
describe: 'auto update publish version and changelog using changeset',
|
|
17
|
+
canary: 'create a prerelease version of publishing for testing',
|
|
18
|
+
preid: 'specify the identifier when versioning a prerelease',
|
|
19
|
+
snapshot: 'create a special kind of publishing for testing',
|
|
20
|
+
ignore: 'skip packages from being published'
|
|
21
|
+
},
|
|
22
|
+
pre: {
|
|
23
|
+
describe: 'enters and exits pre mode'
|
|
24
|
+
},
|
|
25
|
+
release: {
|
|
26
|
+
describe: 'publish changes to npm',
|
|
27
|
+
tag: 'publish use special tag'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.EN_LOCALE = EN_LOCALE;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.localeKeys = exports.i18n = void 0;
|
|
7
|
+
|
|
8
|
+
var _pluginI18n = require("@modern-js/plugin-i18n");
|
|
9
|
+
|
|
10
|
+
var _zh = require("./zh");
|
|
11
|
+
|
|
12
|
+
var _en = require("./en");
|
|
13
|
+
|
|
14
|
+
const i18n = new _pluginI18n.I18n();
|
|
15
|
+
exports.i18n = i18n;
|
|
16
|
+
const localeKeys = i18n.init('zh', {
|
|
17
|
+
zh: _zh.ZH_LOCALE,
|
|
18
|
+
en: _en.EN_LOCALE
|
|
19
|
+
});
|
|
20
|
+
exports.localeKeys = localeKeys;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ZH_LOCALE = void 0;
|
|
7
|
+
const ZH_LOCALE = {
|
|
8
|
+
command: {
|
|
9
|
+
change: {
|
|
10
|
+
describe: '创建变更集',
|
|
11
|
+
empty: '创建空变更集',
|
|
12
|
+
open: '使用编辑器中打开创建的变更集',
|
|
13
|
+
no_packages: '未找到子项目,请先执行 「{packageManager} new」 命令创建子项目'
|
|
14
|
+
},
|
|
15
|
+
bump: {
|
|
16
|
+
describe: '使用变更集自动更新发布版本和变更日志',
|
|
17
|
+
canary: '创建一个预发布版本进行测试',
|
|
18
|
+
preid: '在对预发布版本进行版本控制时指定标识符',
|
|
19
|
+
snapshot: '创建一个特殊版本进行测试',
|
|
20
|
+
ignore: '跳过部分包发布版本'
|
|
21
|
+
},
|
|
22
|
+
pre: {
|
|
23
|
+
describe: '进入和退出预发布模式'
|
|
24
|
+
},
|
|
25
|
+
release: {
|
|
26
|
+
describe: '发布 npm 包',
|
|
27
|
+
tag: '发布 npm 包使用特定的 tag'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.ZH_LOCALE = ZH_LOCALE;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CHANGESET_PATH = void 0;
|
|
7
|
+
exports.execaWithStreamLog = execaWithStreamLog;
|
|
8
|
+
|
|
9
|
+
var _execa = _interopRequireDefault(require("execa"));
|
|
10
|
+
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
|
|
13
|
+
const CHANGESET_PATH = require.resolve('@changesets/cli');
|
|
14
|
+
|
|
15
|
+
exports.CHANGESET_PATH = CHANGESET_PATH;
|
|
16
|
+
|
|
17
|
+
function execaWithStreamLog(command, args) {
|
|
18
|
+
const promise = (0, _execa.default)(command, args, {
|
|
19
|
+
stdin: 'inherit',
|
|
20
|
+
stdout: 'inherit',
|
|
21
|
+
stderr: 'inherit'
|
|
22
|
+
});
|
|
23
|
+
return promise;
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _changeset = require("./changeset");
|
|
8
|
+
|
|
9
|
+
Object.keys(_changeset).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _changeset[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _changeset[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _language = require("./language");
|
|
21
|
+
|
|
22
|
+
Object.keys(_language).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _language[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _language[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLocaleLanguage = getLocaleLanguage;
|
|
7
|
+
|
|
8
|
+
var _i18nCliLanguageDetector = require("@modern-js/i18n-cli-language-detector");
|
|
9
|
+
|
|
10
|
+
function getLocaleLanguage() {
|
|
11
|
+
const detector = new _i18nCliLanguageDetector.I18CLILanguageDetector();
|
|
12
|
+
return detector.detect();
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pre(type: 'enter' | 'exit', tag?: string): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const EN_LOCALE: {
|
|
2
|
+
command: {
|
|
3
|
+
change: {
|
|
4
|
+
describe: string;
|
|
5
|
+
empty: string;
|
|
6
|
+
open: string;
|
|
7
|
+
no_packages: string;
|
|
8
|
+
};
|
|
9
|
+
bump: {
|
|
10
|
+
describe: string;
|
|
11
|
+
canary: string;
|
|
12
|
+
preid: string;
|
|
13
|
+
snapshot: string;
|
|
14
|
+
ignore: string;
|
|
15
|
+
};
|
|
16
|
+
pre: {
|
|
17
|
+
describe: string;
|
|
18
|
+
};
|
|
19
|
+
release: {
|
|
20
|
+
describe: string;
|
|
21
|
+
tag: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { I18n } from '@modern-js/plugin-i18n';
|
|
2
|
+
declare const i18n: I18n;
|
|
3
|
+
declare const localeKeys: {
|
|
4
|
+
command: {
|
|
5
|
+
change: {
|
|
6
|
+
describe: string;
|
|
7
|
+
empty: string;
|
|
8
|
+
open: string;
|
|
9
|
+
no_packages: string;
|
|
10
|
+
};
|
|
11
|
+
bump: {
|
|
12
|
+
describe: string;
|
|
13
|
+
canary: string;
|
|
14
|
+
preid: string;
|
|
15
|
+
snapshot: string;
|
|
16
|
+
ignore: string;
|
|
17
|
+
};
|
|
18
|
+
pre: {
|
|
19
|
+
describe: string;
|
|
20
|
+
};
|
|
21
|
+
release: {
|
|
22
|
+
describe: string;
|
|
23
|
+
tag: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
command: {
|
|
28
|
+
change: {
|
|
29
|
+
describe: string;
|
|
30
|
+
empty: string;
|
|
31
|
+
open: string;
|
|
32
|
+
no_packages: string;
|
|
33
|
+
};
|
|
34
|
+
bump: {
|
|
35
|
+
describe: string;
|
|
36
|
+
canary: string;
|
|
37
|
+
preid: string;
|
|
38
|
+
snapshot: string;
|
|
39
|
+
ignore: string;
|
|
40
|
+
};
|
|
41
|
+
pre: {
|
|
42
|
+
describe: string;
|
|
43
|
+
};
|
|
44
|
+
release: {
|
|
45
|
+
describe: string;
|
|
46
|
+
tag: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export { i18n, localeKeys };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const ZH_LOCALE: {
|
|
2
|
+
command: {
|
|
3
|
+
change: {
|
|
4
|
+
describe: string;
|
|
5
|
+
empty: string;
|
|
6
|
+
open: string;
|
|
7
|
+
no_packages: string;
|
|
8
|
+
};
|
|
9
|
+
bump: {
|
|
10
|
+
describe: string;
|
|
11
|
+
canary: string;
|
|
12
|
+
preid: string;
|
|
13
|
+
snapshot: string;
|
|
14
|
+
ignore: string;
|
|
15
|
+
};
|
|
16
|
+
pre: {
|
|
17
|
+
describe: string;
|
|
18
|
+
};
|
|
19
|
+
release: {
|
|
20
|
+
describe: string;
|
|
21
|
+
tag: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLocaleLanguage(): string;
|
package/modern.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@modern-js/plugin-changeset",
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
|
+
"jsnext:source": "./src/index.ts",
|
|
5
|
+
"types": "./dist/types/index.d.ts",
|
|
6
|
+
"main": "./dist/js/node/index.js",
|
|
7
|
+
"module": "./dist/js/treeshaking/index.js",
|
|
8
|
+
"jsnext:modern": "./dist/js/modern/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"node": {
|
|
12
|
+
"import": "./dist/js/modern/index.js",
|
|
13
|
+
"require": "./dist/js/node/index.js"
|
|
14
|
+
},
|
|
15
|
+
"default": "./dist/js/treeshaking/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./cli": "./dist/js/node/index.js"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@babel/runtime": "^7",
|
|
21
|
+
"@changesets/cli": "2.16.0",
|
|
22
|
+
"@modern-js/core": "^1.0.0-alpha.3",
|
|
23
|
+
"@modern-js/i18n-cli-language-detector": "^1.0.0-alpha.3",
|
|
24
|
+
"@modern-js/plugin-i18n": "^1.0.0-alpha.3",
|
|
25
|
+
"@modern-js/utils": "^1.0.0-alpha.3",
|
|
26
|
+
"execa": "^5.1.1"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/jest": "^26",
|
|
30
|
+
"@types/node": "^14",
|
|
31
|
+
"typescript": "^4",
|
|
32
|
+
"@modern-js/plugin-testing": "^1.0.0-alpha.3",
|
|
33
|
+
"@modern-js/module-tools": "^1.0.0-alpha.3"
|
|
34
|
+
},
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"modernConfig": {
|
|
37
|
+
"output": {
|
|
38
|
+
"packageMode": "node-js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"new": "modern new",
|
|
43
|
+
"build": "modern build",
|
|
44
|
+
"test": "modern test --passWithNoTests"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CHANGESET_PATH, execaWithStreamLog } from '../utils';
|
|
2
|
+
|
|
3
|
+
interface BumpOptions {
|
|
4
|
+
snapshot: boolean;
|
|
5
|
+
canary: boolean;
|
|
6
|
+
preid: string;
|
|
7
|
+
ignore: string[];
|
|
8
|
+
}
|
|
9
|
+
export async function bump(options: BumpOptions) {
|
|
10
|
+
const { snapshot, canary, preid, ignore } = options;
|
|
11
|
+
|
|
12
|
+
const params = [CHANGESET_PATH, 'version'];
|
|
13
|
+
|
|
14
|
+
if (snapshot) {
|
|
15
|
+
params.push('--snapshot');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (ignore) {
|
|
19
|
+
ignore.forEach(pkg => {
|
|
20
|
+
params.push('--ignore');
|
|
21
|
+
params.push(pkg);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (canary) {
|
|
26
|
+
await execaWithStreamLog('node', [
|
|
27
|
+
CHANGESET_PATH,
|
|
28
|
+
'pre',
|
|
29
|
+
'enter',
|
|
30
|
+
preid || 'next',
|
|
31
|
+
]);
|
|
32
|
+
try {
|
|
33
|
+
await execaWithStreamLog('node', params);
|
|
34
|
+
await execaWithStreamLog('node', [CHANGESET_PATH, 'pre', 'exit']);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
await execaWithStreamLog('node', [CHANGESET_PATH, 'pre', 'exit']);
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
await execaWithStreamLog('node', params);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isMonorepo,
|
|
3
|
+
getMonorepoPackages,
|
|
4
|
+
getPackageManager,
|
|
5
|
+
logger,
|
|
6
|
+
} from '@modern-js/utils';
|
|
7
|
+
import { CHANGESET_PATH, execaWithStreamLog } from '../utils';
|
|
8
|
+
import { i18n, localeKeys } from '../locale';
|
|
9
|
+
|
|
10
|
+
interface ChangeOptions {
|
|
11
|
+
empty: boolean;
|
|
12
|
+
open: boolean;
|
|
13
|
+
}
|
|
14
|
+
export async function change(options: ChangeOptions) {
|
|
15
|
+
const appDir = process.cwd();
|
|
16
|
+
if (isMonorepo(appDir)) {
|
|
17
|
+
const packages = getMonorepoPackages(appDir);
|
|
18
|
+
if (packages.length === 0) {
|
|
19
|
+
logger.warn(
|
|
20
|
+
i18n.t(localeKeys.command.change.no_packages, {
|
|
21
|
+
packageManager: getPackageManager(appDir),
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const { empty, open } = options;
|
|
28
|
+
const params = [CHANGESET_PATH, 'add'];
|
|
29
|
+
if (empty) {
|
|
30
|
+
params.push('--empty');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (open) {
|
|
34
|
+
params.push('--open');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
await execaWithStreamLog('node', params);
|
|
38
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CHANGESET_PATH, execaWithStreamLog } from '../utils';
|
|
2
|
+
|
|
3
|
+
export async function pre(type: 'enter' | 'exit', tag = 'next') {
|
|
4
|
+
const params = [CHANGESET_PATH, 'pre', type];
|
|
5
|
+
|
|
6
|
+
if (type === 'enter') {
|
|
7
|
+
params.push(tag);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
await execaWithStreamLog('node', params);
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getPackageManager } from '@modern-js/utils';
|
|
2
|
+
import { execaWithStreamLog } from '../utils';
|
|
3
|
+
|
|
4
|
+
interface PublishOptions {
|
|
5
|
+
tag: string;
|
|
6
|
+
}
|
|
7
|
+
export async function release(options: PublishOptions) {
|
|
8
|
+
const packageManager = getPackageManager(process.cwd());
|
|
9
|
+
|
|
10
|
+
const { tag } = options;
|
|
11
|
+
const params = ['publish', '-r', '--ignore-scripts'];
|
|
12
|
+
|
|
13
|
+
if (tag) {
|
|
14
|
+
params.push('--tag');
|
|
15
|
+
params.push(tag);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await execaWithStreamLog(packageManager, params);
|
|
19
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createPlugin } from '@modern-js/core';
|
|
2
|
+
import { change, bump, pre, release } from './commands';
|
|
3
|
+
import { i18n, localeKeys } from './locale';
|
|
4
|
+
import { getLocaleLanguage } from './utils';
|
|
5
|
+
|
|
6
|
+
export default createPlugin(
|
|
7
|
+
() => {
|
|
8
|
+
// initial cli language
|
|
9
|
+
i18n.changeLanguage({ locale: getLocaleLanguage() });
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
plugins() {
|
|
13
|
+
return [{}];
|
|
14
|
+
},
|
|
15
|
+
commands({ program }: any) {
|
|
16
|
+
program
|
|
17
|
+
.command('change')
|
|
18
|
+
.description(i18n.t(localeKeys.command.change.describe))
|
|
19
|
+
.option('--empty', i18n.t(localeKeys.command.change.empty), false)
|
|
20
|
+
.option('--open', i18n.t(localeKeys.command.change.open), false)
|
|
21
|
+
.action((options: any) => change(options));
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.command('bump')
|
|
25
|
+
.description(i18n.t(localeKeys.command.bump.describe))
|
|
26
|
+
.option('--canary', i18n.t(localeKeys.command.bump.canary), false)
|
|
27
|
+
.option(
|
|
28
|
+
'--preid <tag>',
|
|
29
|
+
i18n.t(localeKeys.command.bump.preid),
|
|
30
|
+
'next',
|
|
31
|
+
)
|
|
32
|
+
.option('--snapshot', i18n.t(localeKeys.command.bump.snapshot), false)
|
|
33
|
+
.action((options: any) => bump(options));
|
|
34
|
+
|
|
35
|
+
program
|
|
36
|
+
.command('pre <enter|exit> [tag]')
|
|
37
|
+
.description(i18n.t(localeKeys.command.pre.describe))
|
|
38
|
+
.action((type: 'enter' | 'exit', tag?: string) => pre(type, tag));
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command('release')
|
|
42
|
+
.description(i18n.t(localeKeys.command.release.describe))
|
|
43
|
+
.option('--tag <tag>', i18n.t(localeKeys.command.release.tag), '')
|
|
44
|
+
.action((options: any) => release(options));
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
{ name: '@modern-js/plugin-changeset' },
|
|
49
|
+
) as any;
|
package/src/locale/en.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const EN_LOCALE = {
|
|
2
|
+
command: {
|
|
3
|
+
change: {
|
|
4
|
+
describe: 'create changeset',
|
|
5
|
+
empty: 'create an empty changeset',
|
|
6
|
+
open: 'opens the created changeset in an external editor',
|
|
7
|
+
no_packages:
|
|
8
|
+
'not find sub-project,please use `{packageManager} new` to create sub-project',
|
|
9
|
+
},
|
|
10
|
+
bump: {
|
|
11
|
+
describe: 'auto update publish version and changelog using changeset',
|
|
12
|
+
canary: 'create a prerelease version of publishing for testing',
|
|
13
|
+
preid: 'specify the identifier when versioning a prerelease',
|
|
14
|
+
snapshot: 'create a special kind of publishing for testing',
|
|
15
|
+
ignore: 'skip packages from being published',
|
|
16
|
+
},
|
|
17
|
+
pre: {
|
|
18
|
+
describe: 'enters and exits pre mode',
|
|
19
|
+
},
|
|
20
|
+
release: {
|
|
21
|
+
describe: 'publish changes to npm',
|
|
22
|
+
tag: 'publish use special tag',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
package/src/locale/zh.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const ZH_LOCALE = {
|
|
2
|
+
command: {
|
|
3
|
+
change: {
|
|
4
|
+
describe: '创建变更集',
|
|
5
|
+
empty: '创建空变更集',
|
|
6
|
+
open: '使用编辑器中打开创建的变更集',
|
|
7
|
+
no_packages:
|
|
8
|
+
'未找到子项目,请先执行 「{packageManager} new」 命令创建子项目',
|
|
9
|
+
},
|
|
10
|
+
bump: {
|
|
11
|
+
describe: '使用变更集自动更新发布版本和变更日志',
|
|
12
|
+
canary: '创建一个预发布版本进行测试',
|
|
13
|
+
preid: '在对预发布版本进行版本控制时指定标识符',
|
|
14
|
+
snapshot: '创建一个特殊版本进行测试',
|
|
15
|
+
ignore: '跳过部分包发布版本',
|
|
16
|
+
},
|
|
17
|
+
pre: {
|
|
18
|
+
describe: '进入和退出预发布模式',
|
|
19
|
+
},
|
|
20
|
+
release: {
|
|
21
|
+
describe: '发布 npm 包',
|
|
22
|
+
tag: '发布 npm 包使用特定的 tag',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
|
|
3
|
+
export const CHANGESET_PATH = require.resolve('@changesets/cli');
|
|
4
|
+
|
|
5
|
+
export function execaWithStreamLog(command: string, args: string[]) {
|
|
6
|
+
const promise = execa(command, args, {
|
|
7
|
+
stdin: 'inherit',
|
|
8
|
+
stdout: 'inherit',
|
|
9
|
+
stderr: 'inherit',
|
|
10
|
+
});
|
|
11
|
+
return promise;
|
|
12
|
+
}
|
package/tsconfig.json
ADDED