@tomjs/hbuilderx-cli 1.2.0 → 1.3.0
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/index.js +21 -4
- package/dist/types.d.ts +4 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -29,9 +29,16 @@ async function getConfig(opts) {
|
|
|
29
29
|
return (await explorer.search())?.config || {};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/constant.ts
|
|
34
|
+
const LOG_PREFIX = "[tomjs:hbuilderx]";
|
|
35
|
+
|
|
32
36
|
//#endregion
|
|
33
37
|
//#region src/util.ts
|
|
34
|
-
const logger = new Logger({
|
|
38
|
+
const logger = new Logger({
|
|
39
|
+
prefix: LOG_PREFIX,
|
|
40
|
+
time: true
|
|
41
|
+
});
|
|
35
42
|
const isWindows = process.platform === "win32";
|
|
36
43
|
let _opts = {};
|
|
37
44
|
function setOptions(opts) {
|
|
@@ -122,7 +129,7 @@ function createWatcher(paths, callback) {
|
|
|
122
129
|
let ready = false;
|
|
123
130
|
watcher.on("ready", async () => {
|
|
124
131
|
ready = true;
|
|
125
|
-
logger.info(
|
|
132
|
+
logger.info(`监听 ${watchPaths.map((s) => colors.green(s))}`);
|
|
126
133
|
await callback();
|
|
127
134
|
});
|
|
128
135
|
watcher.on("all", async (event, path$1) => {
|
|
@@ -148,9 +155,9 @@ async function watchFiles(opts) {
|
|
|
148
155
|
}
|
|
149
156
|
async function genDtsFromPkg(pkgPath, opts) {
|
|
150
157
|
const pkg = await readJson(pkgPath);
|
|
151
|
-
if (!pkg) return logger.error(`${colors.
|
|
158
|
+
if (!pkg) return logger.error(`${colors.blue("package.json")} 文件解析失败`);
|
|
152
159
|
const contributes = pkg.contributes;
|
|
153
|
-
if (!contributes) return logger.error(`${colors.
|
|
160
|
+
if (!contributes) return logger.error(`${colors.blue("package.json")} 文件缺少 contributes 属性`);
|
|
154
161
|
const code = `// 通过 @tomjs/hbuilderx-cli 生成的 d.ts 文件
|
|
155
162
|
declare module 'hbuilderx' {
|
|
156
163
|
${getCommandCode(contributes, opts)}
|
|
@@ -258,6 +265,7 @@ Usage
|
|
|
258
265
|
Options
|
|
259
266
|
--watch, -w 监听 package.json,生产 d.ts 文件
|
|
260
267
|
--pack, -p 生成插件打包文件
|
|
268
|
+
--flag, -f 日志标识:time/symbol/none,默认 "time"
|
|
261
269
|
--config 指定配置文件,如 "hx-cli.config.mjs"
|
|
262
270
|
--verbose 显示更多信息
|
|
263
271
|
--help, -h 显示帮助信息
|
|
@@ -280,6 +288,14 @@ Examples
|
|
|
280
288
|
type: "boolean",
|
|
281
289
|
shortFlag: "p"
|
|
282
290
|
},
|
|
291
|
+
flag: {
|
|
292
|
+
type: "string",
|
|
293
|
+
choices: [
|
|
294
|
+
"time",
|
|
295
|
+
"symbol",
|
|
296
|
+
"none"
|
|
297
|
+
]
|
|
298
|
+
},
|
|
283
299
|
verbose: {
|
|
284
300
|
type: "boolean",
|
|
285
301
|
default: false
|
|
@@ -299,6 +315,7 @@ if (flags.help) cli.showHelp(0);
|
|
|
299
315
|
else if (flags.version) cli.showVersion();
|
|
300
316
|
else {
|
|
301
317
|
logger.enableDebug(flags.verbose);
|
|
318
|
+
logger.setOptions({ flag: flags.flag || "time" });
|
|
302
319
|
const cliOpts = Object.assign({ cwd: input[0] }, flags);
|
|
303
320
|
logger.debug("cli options:", cliOpts);
|
|
304
321
|
const config = await getConfig(cliOpts);
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/hbuilderx-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "为 HBuilderX 开发插件提供便利的 cli 工具,根据 package.json 中的 contributes 配置,为 hbuilderx 的命令、视图等 API 提供 id 提示",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Tom Gao",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"node": ">=20"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@tomjs/logger": "^
|
|
38
|
+
"@tomjs/logger": "^3.0.0",
|
|
39
39
|
"@tomjs/node": "^2.2.3",
|
|
40
40
|
"archiver": "^7.0.1",
|
|
41
41
|
"chokidar": "^5.0.0",
|