@modern-js/plugin-changeset 1.2.0 → 1.2.1

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @modern-js/plugin-changeset
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 83166714: change .npmignore
8
+ - Updated dependencies [83166714]
9
+ - Updated dependencies [c3de9882]
10
+ - Updated dependencies [33ff48af]
11
+ - @modern-js/core@1.3.2
12
+ - @modern-js/i18n-cli-language-detector@1.2.1
13
+ - @modern-js/plugin-i18n@1.2.1
14
+ - @modern-js/utils@1.2.2
15
+
3
16
  ## 1.2.0
4
17
 
5
18
  ### Minor Changes
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.0",
14
+ "version": "1.2.1",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -35,13 +35,13 @@
35
35
  "@babel/runtime": "^7",
36
36
  "@changesets/cli": "2.16.0",
37
37
  "@changesets/git": "^1.1.2",
38
- "@modern-js/i18n-cli-language-detector": "^1.2.0",
39
- "@modern-js/plugin-i18n": "^1.2.0",
40
- "@modern-js/utils": "^1.2.0",
38
+ "@modern-js/i18n-cli-language-detector": "^1.2.1",
39
+ "@modern-js/plugin-i18n": "^1.2.1",
40
+ "@modern-js/utils": "^1.2.2",
41
41
  "execa": "^5.1.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@modern-js/core": "^1.3.0",
44
+ "@modern-js/core": "^1.3.2",
45
45
  "@scripts/build": "0.0.0",
46
46
  "@types/jest": "^26",
47
47
  "@types/node": "^14",
@@ -50,7 +50,7 @@
50
50
  "@scripts/jest-config": "0.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@modern-js/core": "^1.3.0"
53
+ "@modern-js/core": "^1.3.2"
54
54
  },
55
55
  "sideEffects": false,
56
56
  "modernConfig": {
@@ -1,52 +0,0 @@
1
- import { CHANGESET_PATH, execaWithStreamLog } from '../utils';
2
-
3
- interface BumpOptions {
4
- snapshot: boolean | string;
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
- if (typeof snapshot === 'string') {
17
- params.push(snapshot);
18
- }
19
- }
20
-
21
- if (ignore) {
22
- ignore.forEach(pkg => {
23
- params.push('--ignore');
24
- params.push(pkg);
25
- });
26
- }
27
-
28
- if (canary) {
29
- await execaWithStreamLog(process.execPath, [
30
- CHANGESET_PATH,
31
- 'pre',
32
- 'enter',
33
- preid || 'next',
34
- ]);
35
- try {
36
- await execaWithStreamLog(process.execPath, params);
37
- await execaWithStreamLog(process.execPath, [
38
- CHANGESET_PATH,
39
- 'pre',
40
- 'exit',
41
- ]);
42
- } catch (e) {
43
- await execaWithStreamLog(process.execPath, [
44
- CHANGESET_PATH,
45
- 'pre',
46
- 'exit',
47
- ]);
48
- }
49
- } else {
50
- await execaWithStreamLog(process.execPath, params);
51
- }
52
- }
@@ -1,40 +0,0 @@
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
- const packageManager = await getPackageManager(appDir);
20
- logger.warn(
21
- i18n.t(localeKeys.command.change.no_packages, {
22
- packageManager:
23
- packageManager === 'yarn' ? 'yarn' : `${packageManager} run`,
24
- }),
25
- );
26
- return;
27
- }
28
- }
29
- const { empty, open } = options;
30
- const params = [CHANGESET_PATH, 'add'];
31
- if (empty) {
32
- params.push('--empty');
33
- }
34
-
35
- if (open) {
36
- params.push('--open');
37
- }
38
-
39
- await execaWithStreamLog(process.execPath, params);
40
- }
@@ -1,4 +0,0 @@
1
- export * from './change';
2
- export * from './bump';
3
- export * from './pre';
4
- export * from './release';
@@ -1,11 +0,0 @@
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(process.execPath, params);
11
- }
@@ -1,58 +0,0 @@
1
- import path from 'path';
2
- import { getPackageManager, isModernjsMonorepo, fs } from '@modern-js/utils';
3
- import { tag as gitTag } from '@changesets/git';
4
- import { CHANGESET_PATH, execaWithStreamLog } from '../utils';
5
-
6
- interface PublishOptions {
7
- tag: string;
8
- ignoreScripts: boolean;
9
- gitChecks: boolean;
10
- }
11
- // eslint-disable-next-line max-statements
12
- export async function release(options: PublishOptions) {
13
- const appDir = process.cwd();
14
- const isMonorepo = isModernjsMonorepo(appDir);
15
- const packageManager = await getPackageManager(process.cwd());
16
-
17
- const params = ['publish'];
18
-
19
- const { tag, ignoreScripts, gitChecks } = options;
20
-
21
- if (tag) {
22
- params.push('--tag');
23
- params.push(tag);
24
- }
25
-
26
- if (!isMonorepo || packageManager === 'yarn') {
27
- await execaWithStreamLog(process.execPath, [CHANGESET_PATH, ...params]);
28
- return;
29
- }
30
-
31
- params.push('-r');
32
- params.push('--filter');
33
- params.push('{./packages}');
34
- params.push('--report-summary');
35
-
36
- if (ignoreScripts) {
37
- params.push('--ignore-scripts');
38
- }
39
-
40
- if (!gitChecks) {
41
- params.push('--no-git-checks');
42
- }
43
-
44
- await execaWithStreamLog(packageManager, params);
45
-
46
- const pnpmPublishSummaryFile = path.join(appDir, 'pnpm-publish-summary.json');
47
- const publishInfo: {
48
- publishedPackages: Array<{ name: string; version: string }>;
49
- } = await fs.readJSON(pnpmPublishSummaryFile, 'utf-8');
50
-
51
- await Promise.all(
52
- (publishInfo.publishedPackages || []).map(pkg =>
53
- gitTag(`${pkg.name}@${pkg.version}`, appDir),
54
- ),
55
- );
56
-
57
- await fs.remove(pnpmPublishSummaryFile);
58
- }
package/src/index.ts DELETED
@@ -1,63 +0,0 @@
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(
33
- '--snapshot [snapshot]',
34
- i18n.t(localeKeys.command.bump.snapshot),
35
- false,
36
- )
37
- .action((options: any) => bump(options));
38
-
39
- program
40
- .command('pre <enter|exit> [tag]')
41
- .description(i18n.t(localeKeys.command.pre.describe))
42
- .action((type: 'enter' | 'exit', tag?: string) => pre(type, tag));
43
-
44
- program
45
- .command('release')
46
- .description(i18n.t(localeKeys.command.release.describe))
47
- .option('--tag <tag>', i18n.t(localeKeys.command.release.tag), '')
48
- .option(
49
- '--ignore-scripts',
50
- i18n.t(localeKeys.command.release.ignore_scripts),
51
- '',
52
- )
53
- .option(
54
- '--no-git-checks',
55
- i18n.t(localeKeys.command.release.no_git_checks),
56
- '',
57
- )
58
- .action((options: any) => release(options));
59
- },
60
- };
61
- },
62
- { name: '@modern-js/plugin-changeset' },
63
- ) as any;
package/src/locale/en.ts DELETED
@@ -1,29 +0,0 @@
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
- ignore_scripts:
24
- 'publish command ignore npm scripts, only can use in pnpm monorepo',
25
- no_git_checks:
26
- 'publish command ignore checking if current branch is your publish branch, clean, and up-to-date, only can use in pnpm monorepo',
27
- },
28
- },
29
- };
@@ -1,9 +0,0 @@
1
- import { I18n } from '@modern-js/plugin-i18n';
2
- import { ZH_LOCALE } from './zh';
3
- import { EN_LOCALE } from './en';
4
-
5
- const i18n = new I18n();
6
-
7
- const localeKeys = i18n.init('zh', { zh: ZH_LOCALE, en: EN_LOCALE });
8
-
9
- export { i18n, localeKeys };
package/src/locale/zh.ts DELETED
@@ -1,29 +0,0 @@
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
- ignore_scripts:
24
- '发布时忽略 package.json 中的 scripts 命令,仅支持在 pnpm monorepo 中使用',
25
- no_git_checks:
26
- '发布命令忽略检查当前分支是否是发布分支,干净且最新,仅支持在 pnpm monorepo 中使用',
27
- },
28
- },
29
- };
@@ -1,12 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export * from './changeset';
2
- export * from './language';
@@ -1,6 +0,0 @@
1
- import { I18CLILanguageDetector } from '@modern-js/i18n-cli-language-detector';
2
-
3
- export function getLocaleLanguage() {
4
- const detector = new I18CLILanguageDetector();
5
- return detector.detect();
6
- }