@rife/cli 0.0.6-beta.2 → 0.0.6-beta.21
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/cli.cjs +25 -0
- package/dist/cjs/index.cjs +79 -0
- package/dist/cjs/logger.cjs +48 -0
- package/dist/cjs/plugin/commander.cjs +66 -0
- package/dist/cjs/plugin/config.cjs +109 -0
- package/dist/cjs/plugin/index.cjs +79 -0
- package/dist/cjs/plugin/package.cjs +71 -0
- package/dist/cjs/plugin/release.cjs +129 -0
- package/dist/cjs/runner.cjs +141 -0
- package/dist/{sync.js → cjs/sync.cjs} +12 -23
- package/dist/cjs/util.cjs +67 -0
- package/dist/esm/cli.mjs +21 -0
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/logger.mjs +16 -0
- package/dist/esm/plugin/commander.mjs +34 -0
- package/dist/esm/plugin/config.mjs +67 -0
- package/dist/esm/plugin/index.mjs +6 -0
- package/dist/{plugin/package.js → esm/plugin/package.mjs} +10 -13
- package/dist/esm/plugin/release.mjs +97 -0
- package/dist/esm/runner.mjs +96 -0
- package/dist/esm/sync.mjs +46 -0
- package/dist/esm/util.mjs +12 -0
- package/package.json +29 -27
- package/src/cli.ts +23 -19
- package/src/index.ts +4 -3
- package/src/logger.ts +17 -34
- package/src/plugin/commander.ts +51 -44
- package/src/plugin/config.ts +26 -9
- package/src/plugin/index.ts +1 -1
- package/src/plugin/package.ts +0 -3
- package/src/plugin/release.ts +113 -32
- package/src/runner.ts +134 -88
- package/src/sync.ts +63 -63
- package/src/util.ts +14 -0
- package/dist/build.js +0 -3
- package/dist/build.js.map +0 -1
- package/dist/cli.js +0 -18
- package/dist/cli.js.map +0 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/logger.js +0 -26
- package/dist/logger.js.map +0 -1
- package/dist/plugin/commander.js +0 -42
- package/dist/plugin/commander.js.map +0 -1
- package/dist/plugin/compiler/compiler.js +0 -166
- package/dist/plugin/compiler/compiler.js.map +0 -1
- package/dist/plugin/compiler/index.js +0 -83
- package/dist/plugin/compiler/index.js.map +0 -1
- package/dist/plugin/compiler/swc.js +0 -47
- package/dist/plugin/compiler/swc.js.map +0 -1
- package/dist/plugin/compiler/tsc.js +0 -75
- package/dist/plugin/compiler/tsc.js.map +0 -1
- package/dist/plugin/config.js +0 -61
- package/dist/plugin/config.js.map +0 -1
- package/dist/plugin/index.js +0 -8
- package/dist/plugin/index.js.map +0 -1
- package/dist/plugin/package.js.map +0 -1
- package/dist/plugin/release.js +0 -32
- package/dist/plugin/release.js.map +0 -1
- package/dist/pnpmfile.js +0 -153
- package/dist/runner.js +0 -53
- package/dist/runner.js.map +0 -1
- package/dist/sync.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/build.ts +0 -0
- package/src/plugin/compiler/compiler.ts +0 -198
- package/src/plugin/compiler/index.ts +0 -109
- package/src/plugin/compiler/swc.ts +0 -55
- package/src/plugin/compiler/tsc.ts +0 -101
- package/src/pnpmfile.ts +0 -147
- package/src/test/pnpmfile.test.ts +0 -223
package/dist/cjs/cli.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_exports__ = {};
|
|
3
|
+
const index_cjs_namespaceObject = require("./plugin/index.cjs");
|
|
4
|
+
const external_runner_cjs_namespaceObject = require("./runner.cjs");
|
|
5
|
+
const plugins = [
|
|
6
|
+
(0, index_cjs_namespaceObject.pluginPackage)(),
|
|
7
|
+
(0, index_cjs_namespaceObject.pluginConfig)(),
|
|
8
|
+
(0, index_cjs_namespaceObject.pluginCommander)(),
|
|
9
|
+
(0, index_cjs_namespaceObject.pluginRelease)()
|
|
10
|
+
];
|
|
11
|
+
const runner = (0, external_runner_cjs_namespaceObject.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
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
23
|
+
Object.defineProperty(exports, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./logger" (module) {
|
|
4
|
+
module.exports = require("./logger.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./plugin" (module) {
|
|
7
|
+
module.exports = require("./plugin/index.cjs");
|
|
8
|
+
},
|
|
9
|
+
"./runner" (module) {
|
|
10
|
+
module.exports = require("./runner.cjs");
|
|
11
|
+
},
|
|
12
|
+
"./util" (module) {
|
|
13
|
+
module.exports = require("./util.cjs");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __webpack_module_cache__ = {};
|
|
17
|
+
function __webpack_require__(moduleId) {
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.n = (module)=>{
|
|
28
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
+
__webpack_require__.d(getter, {
|
|
30
|
+
a: getter
|
|
31
|
+
});
|
|
32
|
+
return getter;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
37
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: definition[key]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
45
|
+
})();
|
|
46
|
+
(()=>{
|
|
47
|
+
__webpack_require__.r = (exports1)=>{
|
|
48
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
49
|
+
value: 'Module'
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __webpack_exports__ = {};
|
|
57
|
+
(()=>{
|
|
58
|
+
__webpack_require__.r(__webpack_exports__);
|
|
59
|
+
var _runner__rspack_import_0 = __webpack_require__("./runner");
|
|
60
|
+
var __rspack_reexport = {};
|
|
61
|
+
for(const __rspack_import_key in _runner__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_runner__rspack_import_0[__rspack_import_key];
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
63
|
+
var _plugin__rspack_import_1 = __webpack_require__("./plugin");
|
|
64
|
+
var __rspack_reexport = {};
|
|
65
|
+
for(const __rspack_import_key in _plugin__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_plugin__rspack_import_1[__rspack_import_key];
|
|
66
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
67
|
+
var _logger__rspack_import_2 = __webpack_require__("./logger");
|
|
68
|
+
var __rspack_reexport = {};
|
|
69
|
+
for(const __rspack_import_key in _logger__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_logger__rspack_import_2[__rspack_import_key];
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
71
|
+
var _util__rspack_import_3 = __webpack_require__("./util");
|
|
72
|
+
var __rspack_reexport = {};
|
|
73
|
+
for(const __rspack_import_key in _util__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_util__rspack_import_3[__rspack_import_key];
|
|
74
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
75
|
+
})();
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createLogger: ()=>createLogger
|
|
28
|
+
});
|
|
29
|
+
const external_consola_namespaceObject = require("consola");
|
|
30
|
+
function createLogger(options) {
|
|
31
|
+
const instance = (0, external_consola_namespaceObject.createConsola)({
|
|
32
|
+
level: options?.debug ? 4 : 3,
|
|
33
|
+
throttle: 10,
|
|
34
|
+
throttleMin: 500,
|
|
35
|
+
formatOptions: {
|
|
36
|
+
compact: false,
|
|
37
|
+
date: false
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return instance;
|
|
41
|
+
}
|
|
42
|
+
exports.createLogger = __webpack_exports__.createLogger;
|
|
43
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
44
|
+
"createLogger"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
pluginCommander: ()=>pluginCommander
|
|
28
|
+
});
|
|
29
|
+
function pluginCommander() {
|
|
30
|
+
const plugin = {
|
|
31
|
+
name: pluginCommander.name,
|
|
32
|
+
apply: (runner)=>{
|
|
33
|
+
const { hook, command, config, z, logger } = runner;
|
|
34
|
+
const log = logger.withTag(pluginCommander.name);
|
|
35
|
+
hook.registerCommand.tapPromise(pluginCommander.name, async ()=>{
|
|
36
|
+
command.command('dev').description('启动开发').action(async ()=>{
|
|
37
|
+
process.env.NODE_ENV = 'development';
|
|
38
|
+
await hook.dev.promise();
|
|
39
|
+
});
|
|
40
|
+
command.command('build').description('构建项目').action(async ()=>{
|
|
41
|
+
process.env.NODE_ENV = 'production';
|
|
42
|
+
await hook.build.promise();
|
|
43
|
+
});
|
|
44
|
+
command.command('release').description('发布包').action(async ()=>{
|
|
45
|
+
await hook.release.promise();
|
|
46
|
+
});
|
|
47
|
+
command.command('deploy').description('部署项目').action(async ()=>{
|
|
48
|
+
await hook.deploy.promise().catch((e)=>{
|
|
49
|
+
log.fail(`部署失败,${runner.duration},${e.message}`);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
hook.startCommand.tapPromise(pluginCommander.name, async ()=>{
|
|
54
|
+
await command.parseAsync(process.argv);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return plugin;
|
|
59
|
+
}
|
|
60
|
+
exports.pluginCommander = __webpack_exports__.pluginCommander;
|
|
61
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
62
|
+
"pluginCommander"
|
|
63
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
64
|
+
Object.defineProperty(exports, '__esModule', {
|
|
65
|
+
value: true
|
|
66
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
pluginConfig: ()=>pluginConfig
|
|
37
|
+
});
|
|
38
|
+
const external_path_namespaceObject = require("path");
|
|
39
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
40
|
+
function pluginConfig() {
|
|
41
|
+
const plugin = {
|
|
42
|
+
name: pluginConfig.name,
|
|
43
|
+
apply: (runner)=>{
|
|
44
|
+
const { logger, hook, config, command, fs, z } = runner;
|
|
45
|
+
const log = logger.withTag(pluginConfig.name);
|
|
46
|
+
hook.loadConfig.tapPromise(pluginConfig.name, async ()=>{
|
|
47
|
+
let filePath = '';
|
|
48
|
+
const mjs = 'app.mjs';
|
|
49
|
+
const fileNames = [
|
|
50
|
+
'app.js',
|
|
51
|
+
'app.cjs',
|
|
52
|
+
mjs
|
|
53
|
+
];
|
|
54
|
+
let isEsm = false;
|
|
55
|
+
for (const fileName of fileNames)if (await fs.exists(fileName)) {
|
|
56
|
+
filePath = external_path_default().posix.resolve(fileName);
|
|
57
|
+
isEsm = fileName === mjs;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
log.debug("filePath %s", filePath);
|
|
61
|
+
if (!filePath) {
|
|
62
|
+
log.error("找不到配置文件 app.(c|m)?js");
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
let all = [];
|
|
66
|
+
all = isEsm ? (await import(filePath)).default : require(filePath);
|
|
67
|
+
runner.config.all = all;
|
|
68
|
+
});
|
|
69
|
+
hook.validateConfig.tapPromise(pluginConfig.name, async ()=>{
|
|
70
|
+
const validation = z.array(z.object({
|
|
71
|
+
name: z.string().trim().min(1)
|
|
72
|
+
})).min(1).safeParse(config.all);
|
|
73
|
+
if (!validation.success) {
|
|
74
|
+
log.error(validation.error.message);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
hook.applyConfig.tapPromise(pluginConfig.name, async ()=>{
|
|
79
|
+
const result = z.object({
|
|
80
|
+
name: z.string().trim()
|
|
81
|
+
}).default({
|
|
82
|
+
name: ''
|
|
83
|
+
}).safeParse(command.opts());
|
|
84
|
+
const name = result.data?.name;
|
|
85
|
+
if (name) {
|
|
86
|
+
log.debug(`指定 --name ${name}`);
|
|
87
|
+
const find = config.all.find((t)=>t.name === name);
|
|
88
|
+
if (!find) {
|
|
89
|
+
log.error("未找到 name '%s'", name);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
config.current = find;
|
|
93
|
+
} else {
|
|
94
|
+
log.debug('没有指定 --name,默认使用列表第一个');
|
|
95
|
+
config.current = config.all[0];
|
|
96
|
+
}
|
|
97
|
+
config.current.plugins.forEach((plugin)=>plugin.apply(runner));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return plugin;
|
|
102
|
+
}
|
|
103
|
+
exports.pluginConfig = __webpack_exports__.pluginConfig;
|
|
104
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
105
|
+
"pluginConfig"
|
|
106
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
107
|
+
Object.defineProperty(exports, '__esModule', {
|
|
108
|
+
value: true
|
|
109
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./commander" (module) {
|
|
4
|
+
module.exports = require("./commander.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./config" (module) {
|
|
7
|
+
module.exports = require("./config.cjs");
|
|
8
|
+
},
|
|
9
|
+
"./package" (module) {
|
|
10
|
+
module.exports = require("./package.cjs");
|
|
11
|
+
},
|
|
12
|
+
"./release" (module) {
|
|
13
|
+
module.exports = require("./release.cjs");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __webpack_module_cache__ = {};
|
|
17
|
+
function __webpack_require__(moduleId) {
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.n = (module)=>{
|
|
28
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
+
__webpack_require__.d(getter, {
|
|
30
|
+
a: getter
|
|
31
|
+
});
|
|
32
|
+
return getter;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
37
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: definition[key]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
45
|
+
})();
|
|
46
|
+
(()=>{
|
|
47
|
+
__webpack_require__.r = (exports1)=>{
|
|
48
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
49
|
+
value: 'Module'
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __webpack_exports__ = {};
|
|
57
|
+
(()=>{
|
|
58
|
+
__webpack_require__.r(__webpack_exports__);
|
|
59
|
+
var _config__rspack_import_0 = __webpack_require__("./config");
|
|
60
|
+
var __rspack_reexport = {};
|
|
61
|
+
for(const __rspack_import_key in _config__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_config__rspack_import_0[__rspack_import_key];
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
63
|
+
var _package__rspack_import_1 = __webpack_require__("./package");
|
|
64
|
+
var __rspack_reexport = {};
|
|
65
|
+
for(const __rspack_import_key in _package__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_package__rspack_import_1[__rspack_import_key];
|
|
66
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
67
|
+
var _commander__rspack_import_2 = __webpack_require__("./commander");
|
|
68
|
+
var __rspack_reexport = {};
|
|
69
|
+
for(const __rspack_import_key in _commander__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_commander__rspack_import_2[__rspack_import_key];
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
71
|
+
var _release__rspack_import_3 = __webpack_require__("./release");
|
|
72
|
+
var __rspack_reexport = {};
|
|
73
|
+
for(const __rspack_import_key in _release__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_release__rspack_import_3[__rspack_import_key];
|
|
74
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
75
|
+
})();
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
pluginPackage: ()=>pluginPackage
|
|
37
|
+
});
|
|
38
|
+
const external_path_namespaceObject = require("path");
|
|
39
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
40
|
+
function pluginPackage() {
|
|
41
|
+
const plugin = {
|
|
42
|
+
name: pluginPackage.name,
|
|
43
|
+
apply: (runner)=>{
|
|
44
|
+
const { logger, hook, fs } = runner;
|
|
45
|
+
const log = logger.withTag(pluginPackage.name);
|
|
46
|
+
hook.loadPackage.tapPromise(pluginPackage.name, async ()=>{
|
|
47
|
+
const fileName = 'package.json';
|
|
48
|
+
const filePath = external_path_default().resolve(fileName);
|
|
49
|
+
if (!fs.existsSync(filePath)) {
|
|
50
|
+
log.error(`找不到文件 ${fileName}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const data = require(filePath);
|
|
55
|
+
runner.package = data;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
log.error("读取文件失败", e.message);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return plugin;
|
|
64
|
+
}
|
|
65
|
+
exports.pluginPackage = __webpack_exports__.pluginPackage;
|
|
66
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
67
|
+
"pluginPackage"
|
|
68
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
69
|
+
Object.defineProperty(exports, '__esModule', {
|
|
70
|
+
value: true
|
|
71
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
pluginRelease: ()=>pluginRelease
|
|
28
|
+
});
|
|
29
|
+
const external_child_process_namespaceObject = require("child_process");
|
|
30
|
+
function pluginRelease() {
|
|
31
|
+
const plugin = {
|
|
32
|
+
name: pluginRelease.name,
|
|
33
|
+
apply: (runner)=>{
|
|
34
|
+
const { logger, hook, fs } = runner;
|
|
35
|
+
const log = logger.withTag(pluginRelease.name);
|
|
36
|
+
hook.release.tapPromise(pluginRelease.name, async ()=>{
|
|
37
|
+
runner.clear();
|
|
38
|
+
await hook.build.promise();
|
|
39
|
+
log.start('开始发布');
|
|
40
|
+
const packageVersion = runner.package.version;
|
|
41
|
+
const packageName = runner.package.name;
|
|
42
|
+
const url = `https://registry.npmjs.org/${packageName}`;
|
|
43
|
+
let nextVersion = packageVersion;
|
|
44
|
+
log.debug(`查询版本号 ${packageVersion} 是否存在`);
|
|
45
|
+
const res = await (await fetch(url)).json();
|
|
46
|
+
const exist = res?.versions?.[packageVersion];
|
|
47
|
+
if (exist) {
|
|
48
|
+
const split = packageVersion.split('.');
|
|
49
|
+
split[split.length - 1] = Number(split[split.length - 1]) + 1;
|
|
50
|
+
nextVersion = split.join('.');
|
|
51
|
+
log.debug(`版本号 ${packageVersion} 存在,更新版本号为 ${nextVersion}`);
|
|
52
|
+
const text = fs.readFileSync('./package.json').toString();
|
|
53
|
+
const nextText = text.replace(new RegExp(`"version":\\s*"${packageVersion}"`), `"version": "${nextVersion}"`);
|
|
54
|
+
fs.writeFileSync('./package.json', nextText);
|
|
55
|
+
}
|
|
56
|
+
log.debug(`版本号 ${packageVersion} 不存在`);
|
|
57
|
+
log.info(`版本号为 ${nextVersion}`);
|
|
58
|
+
const tempDir = "./node_modules/.rife/release/";
|
|
59
|
+
log.info(`清空目录 ${tempDir}`);
|
|
60
|
+
fs.emptyDirSync(tempDir);
|
|
61
|
+
const pack = `pnpm pack --pack-destination ${tempDir} --json`;
|
|
62
|
+
log.info(`打包文件 ${pack}`);
|
|
63
|
+
const packOutput = JSON.parse((0, external_child_process_namespaceObject.execSync)(pack).toString());
|
|
64
|
+
const filename = packOutput.filename;
|
|
65
|
+
for (const item of packOutput.files)log.debug(item.path);
|
|
66
|
+
const debug = false;
|
|
67
|
+
const publish = `pnpm publish ${filename} --registry https://registry.npmjs.org --no-git-checks --tag beta ${debug ? '--dry-run' : ''}`;
|
|
68
|
+
log.info(`发布文件 ${publish}`);
|
|
69
|
+
(0, external_child_process_namespaceObject.execSync)(publish, {
|
|
70
|
+
stdio: 'inherit'
|
|
71
|
+
});
|
|
72
|
+
log.success(`发布成功,${runner.duration}`);
|
|
73
|
+
log.info('同步版本');
|
|
74
|
+
let hasSync = false;
|
|
75
|
+
while(true){
|
|
76
|
+
const res = await queryVersion(packageName);
|
|
77
|
+
const nextManifest = res?.versions?.[nextVersion];
|
|
78
|
+
const exist = Boolean(nextManifest);
|
|
79
|
+
const latest = res?.['dist-tags']?.latest;
|
|
80
|
+
if (exist) {
|
|
81
|
+
log.debug("同步版本存在");
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
log.info(`检查版本 ${nextVersion} 不存在,最新版本为 ${latest}`);
|
|
85
|
+
if (!hasSync) {
|
|
86
|
+
hasSync = true;
|
|
87
|
+
log.start("开始同步");
|
|
88
|
+
const sync = await syncVersion(packageName);
|
|
89
|
+
if (true === sync.ok) log.info(`调用同步接口成功,日志 https://registry.npmmirror.com/-/package/${packageName}/syncs/${sync.id}/log`);
|
|
90
|
+
else log.debug("调用同步接口失败,%j", sync);
|
|
91
|
+
}
|
|
92
|
+
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
|
93
|
+
}
|
|
94
|
+
log.success(`同步成功,最新版本为 ${nextVersion},${runner.duration}`);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return plugin;
|
|
99
|
+
}
|
|
100
|
+
async function queryVersion(packageName) {
|
|
101
|
+
const res = await (await fetch(`https://registry.npmmirror.com/${packageName}?t=${Math.random()}`)).json();
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
async function syncVersion(packageName) {
|
|
105
|
+
const sync = await (await fetch(`https://registry-direct.npmmirror.com/-/package/${packageName}/syncs`, {
|
|
106
|
+
headers: {
|
|
107
|
+
accept: '*/*',
|
|
108
|
+
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
109
|
+
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
|
|
110
|
+
'sec-ch-ua-mobile': '?0',
|
|
111
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
112
|
+
'sec-fetch-dest': 'empty',
|
|
113
|
+
'sec-fetch-mode': 'cors',
|
|
114
|
+
'sec-fetch-site': 'same-site',
|
|
115
|
+
Referer: 'https://npmmirror.com/',
|
|
116
|
+
'Referrer-Policy': 'strict-origin-when-cross-origin'
|
|
117
|
+
},
|
|
118
|
+
body: null,
|
|
119
|
+
method: 'PUT'
|
|
120
|
+
})).json();
|
|
121
|
+
return sync;
|
|
122
|
+
}
|
|
123
|
+
exports.pluginRelease = __webpack_exports__.pluginRelease;
|
|
124
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
125
|
+
"pluginRelease"
|
|
126
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
127
|
+
Object.defineProperty(exports, '__esModule', {
|
|
128
|
+
value: true
|
|
129
|
+
});
|