@rife/cli 0.0.6-beta.15 → 0.0.6-beta.16
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/dist/cjs/plugin/commander.cjs +5 -5
- package/dist/cjs/plugin/config.cjs +4 -4
- package/dist/cjs/plugin/package.cjs +2 -2
- package/dist/cjs/plugin/release.cjs +16 -16
- package/dist/cjs/runner.cjs +5 -5
- package/dist/cjs/sync.cjs +1 -1
- package/dist/cjs/util.cjs +2 -2
- package/dist/cli.js +22 -0
- package/dist/cli.js.map +1 -0
- package/dist/esm/plugin/commander.mjs +5 -5
- package/dist/esm/plugin/config.mjs +4 -4
- package/dist/esm/plugin/package.mjs +2 -2
- package/dist/esm/plugin/release.mjs +16 -16
- package/dist/esm/runner.mjs +5 -5
- package/dist/esm/sync.mjs +1 -1
- package/dist/esm/util.mjs +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.js +18 -0
- package/dist/logger.js.map +1 -0
- package/dist/plugin/commander.js +47 -0
- package/dist/plugin/commander.js.map +1 -0
- package/dist/plugin/compiler/compiler.js +166 -0
- package/dist/plugin/compiler/compiler.js.map +1 -0
- package/dist/plugin/compiler/index.js +87 -0
- package/dist/plugin/compiler/index.js.map +1 -0
- package/dist/plugin/compiler/swc.js +48 -0
- package/dist/plugin/compiler/swc.js.map +1 -0
- package/dist/plugin/compiler/tsc.js +75 -0
- package/dist/plugin/compiler/tsc.js.map +1 -0
- package/dist/plugin/config.js +77 -0
- package/dist/plugin/config.js.map +1 -0
- package/dist/plugin/index.js +9 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/package.js +32 -0
- package/dist/plugin/package.js.map +1 -0
- package/dist/plugin/release.js +102 -0
- package/dist/plugin/release.js.map +1 -0
- package/dist/runner.js +82 -0
- package/dist/runner.js.map +1 -0
- package/dist/sync.js +60 -0
- package/dist/sync.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/util.js +14 -0
- package/dist/util.js.map +1 -0
- package/package.json +8 -8
- package/src/cli.ts +23 -23
- package/src/index.ts +3 -3
- package/src/logger.ts +17 -17
- package/src/plugin/commander.ts +49 -49
- package/src/plugin/config.ts +78 -78
- package/src/plugin/release.ts +113 -113
- package/src/runner.ts +132 -132
- package/src/sync.ts +63 -63
- package/src/util.ts +9 -9
|
@@ -33,20 +33,20 @@ function pluginCommander() {
|
|
|
33
33
|
const { hook, command, config, z, logger } = runner;
|
|
34
34
|
const log = logger.withTag(pluginCommander.name);
|
|
35
35
|
hook.registerCommand.tapPromise(pluginCommander.name, async ()=>{
|
|
36
|
-
command.command('dev').description(
|
|
36
|
+
command.command('dev').description('启动开发').action(async ()=>{
|
|
37
37
|
process.env.NODE_ENV = 'development';
|
|
38
38
|
await hook.dev.promise();
|
|
39
39
|
});
|
|
40
|
-
command.command('build').description(
|
|
40
|
+
command.command('build').description('构建项目').action(async ()=>{
|
|
41
41
|
process.env.NODE_ENV = 'production';
|
|
42
42
|
await hook.build.promise();
|
|
43
43
|
});
|
|
44
|
-
command.command('release').description(
|
|
44
|
+
command.command('release').description('发布包').action(async ()=>{
|
|
45
45
|
await hook.release.promise();
|
|
46
46
|
});
|
|
47
|
-
command.command('deploy').description(
|
|
47
|
+
command.command('deploy').description('部署项目').action(async ()=>{
|
|
48
48
|
await hook.deploy.promise().catch((e)=>{
|
|
49
|
-
log.fail(
|
|
49
|
+
log.fail(`部署失败,${runner.duration},${e.message}`);
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -59,7 +59,7 @@ function pluginConfig() {
|
|
|
59
59
|
}
|
|
60
60
|
log.debug("filePath %s", filePath);
|
|
61
61
|
if (!filePath) {
|
|
62
|
-
log.error(
|
|
62
|
+
log.error(`找不到配置文件 app.(c|m)?js`);
|
|
63
63
|
process.exit(1);
|
|
64
64
|
}
|
|
65
65
|
let all = [];
|
|
@@ -81,15 +81,15 @@ function pluginConfig() {
|
|
|
81
81
|
}).default({}).safeParse(command.opts());
|
|
82
82
|
const name = result.data?.name;
|
|
83
83
|
if (name) {
|
|
84
|
-
log.debug(
|
|
84
|
+
log.debug(`指定 --name ${name}`);
|
|
85
85
|
const find = config.all.find((t)=>t.name === name);
|
|
86
86
|
if (!find) {
|
|
87
|
-
log.error(
|
|
87
|
+
log.error(`未找到 name '%s'`, name);
|
|
88
88
|
process.exit(1);
|
|
89
89
|
}
|
|
90
90
|
config.current = find;
|
|
91
91
|
} else {
|
|
92
|
-
log.debug(
|
|
92
|
+
log.debug('没有指定 --name,默认使用列表第一个');
|
|
93
93
|
config.current = config.all[0];
|
|
94
94
|
}
|
|
95
95
|
config.current.plugins.forEach((plugin)=>plugin.apply(runner));
|
|
@@ -47,14 +47,14 @@ function pluginPackage() {
|
|
|
47
47
|
const fileName = 'package.json';
|
|
48
48
|
const filePath = external_path_default().resolve(fileName);
|
|
49
49
|
if (!fs.existsSync(filePath)) {
|
|
50
|
-
log.error(
|
|
50
|
+
log.error(`找不到文件 ${fileName}`);
|
|
51
51
|
process.exit(1);
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
54
|
const data = require(filePath);
|
|
55
55
|
runner.package = data;
|
|
56
56
|
} catch (e) {
|
|
57
|
-
log.error(
|
|
57
|
+
log.error(`读取文件失败`, e.message);
|
|
58
58
|
process.exit(1);
|
|
59
59
|
}
|
|
60
60
|
});
|
|
@@ -36,41 +36,41 @@ function pluginRelease() {
|
|
|
36
36
|
hook.release.tapPromise(pluginRelease.name, async ()=>{
|
|
37
37
|
runner.clear();
|
|
38
38
|
await hook.build.promise();
|
|
39
|
-
log.start(
|
|
39
|
+
log.start('开始发布');
|
|
40
40
|
const packageVersion = runner.package.version;
|
|
41
41
|
const packageName = runner.package.name;
|
|
42
42
|
const url = `https://registry.npmjs.org/${packageName}`;
|
|
43
43
|
let nextVersion = packageVersion;
|
|
44
|
-
log.debug(
|
|
44
|
+
log.debug(`查询版本号 ${packageVersion} 是否存在`);
|
|
45
45
|
const res = await (await fetch(url)).json();
|
|
46
46
|
const exist = res?.versions?.[packageVersion];
|
|
47
47
|
if (exist) {
|
|
48
48
|
const split = packageVersion.split('.');
|
|
49
49
|
split[split.length - 1] = Number(split[split.length - 1]) + 1;
|
|
50
50
|
nextVersion = split.join('.');
|
|
51
|
-
log.debug(
|
|
51
|
+
log.debug(`版本号 ${packageVersion} 存在,更新版本号为 ${nextVersion}`);
|
|
52
52
|
const text = fs.readFileSync('./package.json').toString();
|
|
53
53
|
const nextText = text.replace(new RegExp(`"version":\\s*"${packageVersion}"`), `"version": "${nextVersion}"`);
|
|
54
54
|
fs.writeFileSync('./package.json', nextText);
|
|
55
55
|
}
|
|
56
|
-
log.debug(
|
|
57
|
-
log.info(
|
|
56
|
+
log.debug(`版本号 ${packageVersion} 不存在`);
|
|
57
|
+
log.info(`版本号为 ${nextVersion}`);
|
|
58
58
|
const tempDir = "./node_modules/.rife/release/";
|
|
59
|
-
log.info(
|
|
59
|
+
log.info(`清空目录 ${tempDir}`);
|
|
60
60
|
fs.emptyDirSync(tempDir);
|
|
61
61
|
const pack = `pnpm pack --pack-destination ${tempDir} --json`;
|
|
62
|
-
log.info(
|
|
62
|
+
log.info(`打包文件 ${pack}`);
|
|
63
63
|
const packOutput = JSON.parse((0, external_child_process_namespaceObject.execSync)(pack).toString());
|
|
64
64
|
const filename = packOutput.filename;
|
|
65
65
|
for (const item of packOutput.files)log.debug(item.path);
|
|
66
66
|
const debug = false;
|
|
67
67
|
const publish = `pnpm publish ${filename} --registry https://registry.npmjs.org --no-git-checks ${debug ? '--dry-run' : ''}`;
|
|
68
|
-
log.info(
|
|
68
|
+
log.info(`发布文件 ${publish}`);
|
|
69
69
|
(0, external_child_process_namespaceObject.execSync)(publish, {
|
|
70
70
|
stdio: 'inherit'
|
|
71
71
|
});
|
|
72
|
-
log.success(
|
|
73
|
-
log.info(
|
|
72
|
+
log.success(`发布成功,${runner.duration}`);
|
|
73
|
+
log.info('同步版本');
|
|
74
74
|
let hasSync = false;
|
|
75
75
|
while(true){
|
|
76
76
|
const res = await queryVersion(packageName);
|
|
@@ -78,20 +78,20 @@ function pluginRelease() {
|
|
|
78
78
|
const exist = Boolean(nextManifest);
|
|
79
79
|
const latest = res?.['dist-tags']?.latest;
|
|
80
80
|
if (exist) {
|
|
81
|
-
log.debug(
|
|
81
|
+
log.debug(`同步版本存在`);
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
|
-
log.info(
|
|
84
|
+
log.info(`检查版本 ${nextVersion} 不存在,最新版本为 ${latest}`);
|
|
85
85
|
if (!hasSync) {
|
|
86
86
|
hasSync = true;
|
|
87
|
-
log.start(
|
|
87
|
+
log.start(`开始同步`);
|
|
88
88
|
const sync = await syncVersion(packageName);
|
|
89
|
-
if (true === sync.ok) log.info(
|
|
90
|
-
else log.debug(
|
|
89
|
+
if (true === sync.ok) log.info(`调用同步接口成功,日志 https://registry.npmmirror.com/-/package/${packageName}/syncs/${sync.id}/log`);
|
|
90
|
+
else log.debug(`调用同步接口失败,%j`, sync);
|
|
91
91
|
}
|
|
92
92
|
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
|
93
93
|
}
|
|
94
|
-
log.success(
|
|
94
|
+
log.success(`同步成功,${runner.duration}`);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
};
|
package/dist/cjs/runner.cjs
CHANGED
|
@@ -74,9 +74,9 @@ var __webpack_exports__ = {};
|
|
|
74
74
|
const perfStart = performance.now();
|
|
75
75
|
const { Command } = __webpack_require__("commander");
|
|
76
76
|
const command = new Command();
|
|
77
|
-
command.option('--debug',
|
|
78
|
-
command.option('-n, --name <string>',
|
|
79
|
-
command.option('-h, --help',
|
|
77
|
+
command.option('--debug', '打开调试日志');
|
|
78
|
+
command.option('-n, --name <string>', '执行指定配置');
|
|
79
|
+
command.option('-h, --help', '帮助');
|
|
80
80
|
command.parse();
|
|
81
81
|
const args = external_zod_default().object({
|
|
82
82
|
debug: external_zod_default().boolean().default(false)
|
|
@@ -111,13 +111,13 @@ var __webpack_exports__ = {};
|
|
|
111
111
|
glob: external_util_cjs_namespaceObject.glob.glob,
|
|
112
112
|
get duration () {
|
|
113
113
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
114
|
-
return
|
|
114
|
+
return `耗时 ${duration} s`;
|
|
115
115
|
},
|
|
116
116
|
tempDir: './node_modules/.rife/',
|
|
117
117
|
clear: ()=>{
|
|
118
118
|
console.clear();
|
|
119
119
|
process.stdout.write('\x1b[3J');
|
|
120
|
-
console.log(`${utils_namespaceObject.colors.bgBlue(
|
|
120
|
+
console.log(`${utils_namespaceObject.colors.bgBlue(' 项目名称 ')} ${runner.package.name} \n`);
|
|
121
121
|
},
|
|
122
122
|
throwError: (message, options)=>{
|
|
123
123
|
throw new Error(message, options);
|
package/dist/cjs/sync.cjs
CHANGED
|
@@ -17,7 +17,7 @@ async function sync(name) {
|
|
|
17
17
|
method: 'PUT'
|
|
18
18
|
});
|
|
19
19
|
const body = await res.json();
|
|
20
|
-
if (true === body.ok) console.log(
|
|
20
|
+
if (true === body.ok) console.log(`同步 ${name} 成功`);
|
|
21
21
|
return body;
|
|
22
22
|
}
|
|
23
23
|
const list = [
|
package/dist/cjs/util.cjs
CHANGED
|
@@ -33,8 +33,8 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
getDuration: ()=>getDuration,
|
|
37
36
|
glob: ()=>external_glob_namespaceObject,
|
|
37
|
+
getDuration: ()=>getDuration,
|
|
38
38
|
fs: ()=>external_fs_extra_default()
|
|
39
39
|
});
|
|
40
40
|
const external_fs_extra_namespaceObject = require("fs-extra");
|
|
@@ -42,7 +42,7 @@ var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_
|
|
|
42
42
|
const external_glob_namespaceObject = require("glob");
|
|
43
43
|
const getDuration = (perfStart)=>{
|
|
44
44
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
45
|
-
return
|
|
45
|
+
return `耗时 ${duration} s`;
|
|
46
46
|
};
|
|
47
47
|
exports.fs = __webpack_exports__.fs;
|
|
48
48
|
exports.getDuration = __webpack_exports__.getDuration;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const plugin_1 = require("./plugin");
|
|
4
|
+
const runner_1 = require("./runner");
|
|
5
|
+
const plugins = [
|
|
6
|
+
(0, plugin_1.pluginPackage)(), //
|
|
7
|
+
(0, plugin_1.pluginConfig)(),
|
|
8
|
+
(0, plugin_1.pluginCommander)(),
|
|
9
|
+
(0, plugin_1.pluginRelease)(),
|
|
10
|
+
];
|
|
11
|
+
const runner = (0, runner_1.createRunner)();
|
|
12
|
+
plugins.forEach(plugin => plugin.apply(runner));
|
|
13
|
+
(async () => {
|
|
14
|
+
await runner.hook.loadPackage.promise();
|
|
15
|
+
await runner.hook.loadConfig.promise();
|
|
16
|
+
await runner.hook.validateConfig.promise();
|
|
17
|
+
await runner.hook.applyConfig.promise();
|
|
18
|
+
await runner.hook.validatePlugin.promise();
|
|
19
|
+
await runner.hook.registerCommand.promise();
|
|
20
|
+
await runner.hook.startCommand.promise();
|
|
21
|
+
})();
|
|
22
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAAA,qCAAuF;AACvF,qCAAgD;AAEhD,MAAM,OAAO,GAAa;IACtB,IAAA,sBAAa,GAAE,EAAE,EAAE;IACnB,IAAA,qBAAY,GAAE;IACd,IAAA,wBAAe,GAAE;IACjB,IAAA,sBAAa,GAAE;CAClB,CAAC;AAEF,MAAM,MAAM,GAAG,IAAA,qBAAY,GAAE,CAAC;AAE9B,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAEhD,CAAC,KAAK,IAAI,EAAE;IACR,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IACxC,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IACvC,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAC3C,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IACxC,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAC3C,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;IAC5C,MAAM,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;AAC7C,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -7,20 +7,20 @@ function pluginCommander() {
|
|
|
7
7
|
const { hook, command, config, z, logger } = runner;
|
|
8
8
|
const log = logger.withTag(pluginCommander.name);
|
|
9
9
|
hook.registerCommand.tapPromise(pluginCommander.name, async ()=>{
|
|
10
|
-
command.command('dev').description(
|
|
10
|
+
command.command('dev').description('启动开发').action(async ()=>{
|
|
11
11
|
process.env.NODE_ENV = 'development';
|
|
12
12
|
await hook.dev.promise();
|
|
13
13
|
});
|
|
14
|
-
command.command('build').description(
|
|
14
|
+
command.command('build').description('构建项目').action(async ()=>{
|
|
15
15
|
process.env.NODE_ENV = 'production';
|
|
16
16
|
await hook.build.promise();
|
|
17
17
|
});
|
|
18
|
-
command.command('release').description(
|
|
18
|
+
command.command('release').description('发布包').action(async ()=>{
|
|
19
19
|
await hook.release.promise();
|
|
20
20
|
});
|
|
21
|
-
command.command('deploy').description(
|
|
21
|
+
command.command('deploy').description('部署项目').action(async ()=>{
|
|
22
22
|
await hook.deploy.promise().catch((e)=>{
|
|
23
|
-
log.fail(
|
|
23
|
+
log.fail(`部署失败,${runner.duration},${e.message}`);
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
});
|
|
@@ -23,7 +23,7 @@ function pluginConfig() {
|
|
|
23
23
|
}
|
|
24
24
|
log.debug("filePath %s", filePath);
|
|
25
25
|
if (!filePath) {
|
|
26
|
-
log.error(
|
|
26
|
+
log.error(`找不到配置文件 app.(c|m)?js`);
|
|
27
27
|
process.exit(1);
|
|
28
28
|
}
|
|
29
29
|
let all = [];
|
|
@@ -45,15 +45,15 @@ function pluginConfig() {
|
|
|
45
45
|
}).default({}).safeParse(command.opts());
|
|
46
46
|
const name = result.data?.name;
|
|
47
47
|
if (name) {
|
|
48
|
-
log.debug(
|
|
48
|
+
log.debug(`指定 --name ${name}`);
|
|
49
49
|
const find = config.all.find((t)=>t.name === name);
|
|
50
50
|
if (!find) {
|
|
51
|
-
log.error(
|
|
51
|
+
log.error(`未找到 name '%s'`, name);
|
|
52
52
|
process.exit(1);
|
|
53
53
|
}
|
|
54
54
|
config.current = find;
|
|
55
55
|
} else {
|
|
56
|
-
log.debug(
|
|
56
|
+
log.debug('没有指定 --name,默认使用列表第一个');
|
|
57
57
|
config.current = config.all[0];
|
|
58
58
|
}
|
|
59
59
|
config.current.plugins.forEach((plugin)=>plugin.apply(runner));
|
|
@@ -11,14 +11,14 @@ function pluginPackage() {
|
|
|
11
11
|
const fileName = 'package.json';
|
|
12
12
|
const filePath = path.resolve(fileName);
|
|
13
13
|
if (!fs.existsSync(filePath)) {
|
|
14
|
-
log.error(
|
|
14
|
+
log.error(`找不到文件 ${fileName}`);
|
|
15
15
|
process.exit(1);
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
18
|
const data = require(filePath);
|
|
19
19
|
runner.package = data;
|
|
20
20
|
} catch (e) {
|
|
21
|
-
log.error(
|
|
21
|
+
log.error(`读取文件失败`, e.message);
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -10,41 +10,41 @@ function pluginRelease() {
|
|
|
10
10
|
hook.release.tapPromise(pluginRelease.name, async ()=>{
|
|
11
11
|
runner.clear();
|
|
12
12
|
await hook.build.promise();
|
|
13
|
-
log.start(
|
|
13
|
+
log.start('开始发布');
|
|
14
14
|
const packageVersion = runner.package.version;
|
|
15
15
|
const packageName = runner.package.name;
|
|
16
16
|
const url = `https://registry.npmjs.org/${packageName}`;
|
|
17
17
|
let nextVersion = packageVersion;
|
|
18
|
-
log.debug(
|
|
18
|
+
log.debug(`查询版本号 ${packageVersion} 是否存在`);
|
|
19
19
|
const res = await (await fetch(url)).json();
|
|
20
20
|
const exist = res?.versions?.[packageVersion];
|
|
21
21
|
if (exist) {
|
|
22
22
|
const split = packageVersion.split('.');
|
|
23
23
|
split[split.length - 1] = Number(split[split.length - 1]) + 1;
|
|
24
24
|
nextVersion = split.join('.');
|
|
25
|
-
log.debug(
|
|
25
|
+
log.debug(`版本号 ${packageVersion} 存在,更新版本号为 ${nextVersion}`);
|
|
26
26
|
const text = fs.readFileSync('./package.json').toString();
|
|
27
27
|
const nextText = text.replace(new RegExp(`"version":\\s*"${packageVersion}"`), `"version": "${nextVersion}"`);
|
|
28
28
|
fs.writeFileSync('./package.json', nextText);
|
|
29
29
|
}
|
|
30
|
-
log.debug(
|
|
31
|
-
log.info(
|
|
30
|
+
log.debug(`版本号 ${packageVersion} 不存在`);
|
|
31
|
+
log.info(`版本号为 ${nextVersion}`);
|
|
32
32
|
const tempDir = "./node_modules/.rife/release/";
|
|
33
|
-
log.info(
|
|
33
|
+
log.info(`清空目录 ${tempDir}`);
|
|
34
34
|
fs.emptyDirSync(tempDir);
|
|
35
35
|
const pack = `pnpm pack --pack-destination ${tempDir} --json`;
|
|
36
|
-
log.info(
|
|
36
|
+
log.info(`打包文件 ${pack}`);
|
|
37
37
|
const packOutput = JSON.parse(execSync(pack).toString());
|
|
38
38
|
const filename = packOutput.filename;
|
|
39
39
|
for (const item of packOutput.files)log.debug(item.path);
|
|
40
40
|
const debug = false;
|
|
41
41
|
const publish = `pnpm publish ${filename} --registry https://registry.npmjs.org --no-git-checks ${debug ? '--dry-run' : ''}`;
|
|
42
|
-
log.info(
|
|
42
|
+
log.info(`发布文件 ${publish}`);
|
|
43
43
|
execSync(publish, {
|
|
44
44
|
stdio: 'inherit'
|
|
45
45
|
});
|
|
46
|
-
log.success(
|
|
47
|
-
log.info(
|
|
46
|
+
log.success(`发布成功,${runner.duration}`);
|
|
47
|
+
log.info('同步版本');
|
|
48
48
|
let hasSync = false;
|
|
49
49
|
while(true){
|
|
50
50
|
const res = await queryVersion(packageName);
|
|
@@ -52,20 +52,20 @@ function pluginRelease() {
|
|
|
52
52
|
const exist = Boolean(nextManifest);
|
|
53
53
|
const latest = res?.['dist-tags']?.latest;
|
|
54
54
|
if (exist) {
|
|
55
|
-
log.debug(
|
|
55
|
+
log.debug(`同步版本存在`);
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
58
|
-
log.info(
|
|
58
|
+
log.info(`检查版本 ${nextVersion} 不存在,最新版本为 ${latest}`);
|
|
59
59
|
if (!hasSync) {
|
|
60
60
|
hasSync = true;
|
|
61
|
-
log.start(
|
|
61
|
+
log.start(`开始同步`);
|
|
62
62
|
const sync = await syncVersion(packageName);
|
|
63
|
-
if (true === sync.ok) log.info(
|
|
64
|
-
else log.debug(
|
|
63
|
+
if (true === sync.ok) log.info(`调用同步接口成功,日志 https://registry.npmmirror.com/-/package/${packageName}/syncs/${sync.id}/log`);
|
|
64
|
+
else log.debug(`调用同步接口失败,%j`, sync);
|
|
65
65
|
}
|
|
66
66
|
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
|
67
67
|
}
|
|
68
|
-
log.success(
|
|
68
|
+
log.success(`同步成功,${runner.duration}`);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
};
|
package/dist/esm/runner.mjs
CHANGED
|
@@ -38,9 +38,9 @@ function createRunner() {
|
|
|
38
38
|
const perfStart = performance.now();
|
|
39
39
|
const { Command } = __webpack_require__("commander");
|
|
40
40
|
const command = new Command();
|
|
41
|
-
command.option('--debug',
|
|
42
|
-
command.option('-n, --name <string>',
|
|
43
|
-
command.option('-h, --help',
|
|
41
|
+
command.option('--debug', '打开调试日志');
|
|
42
|
+
command.option('-n, --name <string>', '执行指定配置');
|
|
43
|
+
command.option('-h, --help', '帮助');
|
|
44
44
|
command.parse();
|
|
45
45
|
const args = zod.object({
|
|
46
46
|
debug: zod.boolean().default(false)
|
|
@@ -75,13 +75,13 @@ function createRunner() {
|
|
|
75
75
|
glob: glob.glob,
|
|
76
76
|
get duration () {
|
|
77
77
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
78
|
-
return
|
|
78
|
+
return `耗时 ${duration} s`;
|
|
79
79
|
},
|
|
80
80
|
tempDir: './node_modules/.rife/',
|
|
81
81
|
clear: ()=>{
|
|
82
82
|
console.clear();
|
|
83
83
|
process.stdout.write('\x1b[3J');
|
|
84
|
-
console.log(`${colors.bgBlue(
|
|
84
|
+
console.log(`${colors.bgBlue(' 项目名称 ')} ${runner.package.name} \n`);
|
|
85
85
|
},
|
|
86
86
|
throwError: (message, options)=>{
|
|
87
87
|
throw new Error(message, options);
|
package/dist/esm/sync.mjs
CHANGED
|
@@ -18,7 +18,7 @@ async function sync(name) {
|
|
|
18
18
|
method: 'PUT'
|
|
19
19
|
});
|
|
20
20
|
const body = await res.json();
|
|
21
|
-
if (true === body.ok) console.log(
|
|
21
|
+
if (true === body.ok) console.log(`同步 ${name} 成功`);
|
|
22
22
|
return body;
|
|
23
23
|
}
|
|
24
24
|
const list = [
|
package/dist/esm/util.mjs
CHANGED
|
@@ -4,6 +4,6 @@ import fs_extra from "fs-extra";
|
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_glob__ from "glob";
|
|
5
5
|
const getDuration = (perfStart)=>{
|
|
6
6
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
7
|
-
return
|
|
7
|
+
return `耗时 ${duration} s`;
|
|
8
8
|
};
|
|
9
9
|
export { fs_extra as fs, getDuration, __WEBPACK_EXTERNAL_MODULE_glob__ as glob };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fs = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./runner"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./plugin"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./logger"), exports);
|
|
8
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
9
|
+
exports.fs = fs_extra_1.default;
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mDAAyB;AACzB,mDAAyB;AACzB,mDAAyB;AAQzB,gEAA0B;AAEjB,aAFF,kBAAE,CAEE"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLogger = createLogger;
|
|
4
|
+
const consola_1 = require("consola");
|
|
5
|
+
function createLogger(options) {
|
|
6
|
+
const instance = (0, consola_1.createConsola)({
|
|
7
|
+
level: options?.debug ? 4 : 3,
|
|
8
|
+
// fancy: false,
|
|
9
|
+
formatOptions: {
|
|
10
|
+
// columns: 80,
|
|
11
|
+
// colors: false,
|
|
12
|
+
compact: false,
|
|
13
|
+
date: false,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return instance;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;AAEA,oCAaC;AAfD,qCAAwC;AAExC,SAAgB,YAAY,CAAC,OAA6B;IACtD,MAAM,QAAQ,GAAG,IAAA,uBAAa,EAAC;QAC3B,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,gBAAgB;QAChB,aAAa,EAAE;YACX,eAAe;YACf,iBAAiB;YACjB,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,KAAK;SACd;KACJ,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pluginCommander = pluginCommander;
|
|
4
|
+
function pluginCommander() {
|
|
5
|
+
const plugin = {
|
|
6
|
+
name: pluginCommander.name,
|
|
7
|
+
apply: runner => {
|
|
8
|
+
const { hook, command, config, z, logger } = runner;
|
|
9
|
+
const log = logger.withTag(pluginCommander.name);
|
|
10
|
+
hook.registerCommand.tapPromise(pluginCommander.name, async () => {
|
|
11
|
+
command
|
|
12
|
+
.command('dev')
|
|
13
|
+
.description('启动开发')
|
|
14
|
+
.action(async () => {
|
|
15
|
+
process.env.NODE_ENV = 'development';
|
|
16
|
+
await hook.dev.promise();
|
|
17
|
+
});
|
|
18
|
+
command
|
|
19
|
+
.command('build')
|
|
20
|
+
.description('构建项目')
|
|
21
|
+
.action(async () => {
|
|
22
|
+
process.env.NODE_ENV = 'production';
|
|
23
|
+
await hook.build.promise();
|
|
24
|
+
});
|
|
25
|
+
command
|
|
26
|
+
.command('release')
|
|
27
|
+
.description('发布包')
|
|
28
|
+
.action(async () => {
|
|
29
|
+
await hook.release.promise();
|
|
30
|
+
});
|
|
31
|
+
command
|
|
32
|
+
.command('deploy')
|
|
33
|
+
.description('部署项目')
|
|
34
|
+
.action(async () => {
|
|
35
|
+
await hook.deploy.promise().catch(e => {
|
|
36
|
+
log.fail(`部署失败,${runner.duration},${e.message}`);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
hook.startCommand.tapPromise(pluginCommander.name, async () => {
|
|
41
|
+
await command.parseAsync(process.argv);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
return plugin;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=commander.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commander.js","sourceRoot":"","sources":["../../src/plugin/commander.ts"],"names":[],"mappings":";;AAEA,0CA8CC;AA9CD,SAAgB,eAAe;IAC3B,MAAM,MAAM,GAAW;QACnB,IAAI,EAAE,eAAe,CAAC,IAAI;QAC1B,KAAK,EAAE,MAAM,CAAC,EAAE;YACZ,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;YACpD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;gBAC7D,OAAO;qBACF,OAAO,CAAC,KAAK,CAAC;qBACd,WAAW,CAAC,MAAM,CAAC;qBACnB,MAAM,CAAC,KAAK,IAAI,EAAE;oBACf,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAC;oBACrC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC7B,CAAC,CAAC,CAAC;gBAEP,OAAO;qBACF,OAAO,CAAC,OAAO,CAAC;qBAChB,WAAW,CAAC,MAAM,CAAC;qBACnB,MAAM,CAAC,KAAK,IAAI,EAAE;oBACf,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;oBACpC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBAC/B,CAAC,CAAC,CAAC;gBAEP,OAAO;qBACF,OAAO,CAAC,SAAS,CAAC;qBAClB,WAAW,CAAC,KAAK,CAAC;qBAClB,MAAM,CAAC,KAAK,IAAI,EAAE;oBACf,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;gBACjC,CAAC,CAAC,CAAC;gBAEP,OAAO;qBACF,OAAO,CAAC,QAAQ,CAAC;qBACjB,WAAW,CAAC,MAAM,CAAC;qBACnB,MAAM,CAAC,KAAK,IAAI,EAAE;oBACf,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;wBAClC,GAAG,CAAC,IAAI,CAAC,QAAQ,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;oBACrD,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;gBAC1D,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;IACF,OAAO,MAAM,CAAC;AAClB,CAAC"}
|