pangu-vis-cli 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.
Files changed (3) hide show
  1. package/README.md +9 -9
  2. package/dist/index.js +44 -150
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -253,10 +253,10 @@ pv config
253
253
 
254
254
  **交互式配置项**:
255
255
 
256
- | 配置项 | 说明 | 默认值 |
257
- | -------------- | ------------------------------ | ------------ |
258
- | `autoRemove` | 打包后是否自动删除打包目录 | `yes` (true) |
259
- | `autoRemoveEs` | 打包后是否移除 es 目录 | `yes` (true) |
256
+ | 配置项 | 说明 | 默认值 |
257
+ | -------------- | -------------------------- | ------------ |
258
+ | `autoRemove` | 打包后是否自动删除打包目录 | `yes` (true) |
259
+ | `autoRemoveEs` | 打包后是否移除 es 目录 | `yes` (true) |
260
260
 
261
261
  **示例**:
262
262
 
@@ -337,11 +337,11 @@ CLI 配置信息存储在用户主目录:
337
337
 
338
338
  ### 配置项说明
339
339
 
340
- | 配置项 | 类型 | 说明 | 默认值 |
341
- | ----------------- | ------- | ------------------------------------------------------------ | ---------- |
342
- | `autoRemove` | boolean | 打包后是否自动删除打包目录 | `true` |
343
- | `autoRemoveEs` | boolean | 打包后是否自动删除 es 目录 | `true` |
344
- | `lastUpdateCheck` | number | 更新检查节流时间戳(可选) | 无 |
340
+ | 配置项 | 类型 | 说明 | 默认值 |
341
+ | ----------------- | ------- | ------------------------------------------------------------------------------ | ---------- |
342
+ | `autoRemove` | boolean | 打包后是否自动删除打包目录 | `true` |
343
+ | `autoRemoveEs` | boolean | 打包后是否自动删除 es 目录 | `true` |
344
+ | `lastUpdateCheck` | number | 更新检查节流时间戳(可选) | 无 |
345
345
  | `privateRegistry` | string | 私有 npm 源(可选,优先级:`PANGU_REGISTRY` 环境变量 > 配置文件 > 内网默认源) | 内网默认源 |
346
346
 
347
347
  ### 修改配置
package/dist/index.js CHANGED
@@ -1,36 +1,13 @@
1
1
  #!/usr/bin/env node
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
4
  var __esm = (fn, res) => function __init() {
9
5
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
6
  };
11
- var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
- };
14
7
  var __export = (target, all) => {
15
8
  for (var name in all)
16
9
  __defProp(target, name, { get: all[name], enumerable: true });
17
10
  };
18
- var __copyProps = (to4, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to4, key) && key !== except)
22
- __defProp(to4, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to4;
25
- };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
- // If the importer is in node compatibility mode or this is not an ESM
28
- // file that has been converted to a CommonJS file using a Babel-
29
- // compatible transform (i.e. "__esModule" has not been set), then set
30
- // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
- mod
33
- ));
34
11
 
35
12
  // src/types/cli.ts
36
13
  var DEFAULT_CLI_CONFIG;
@@ -148,84 +125,12 @@ var init_config = __esm({
148
125
  }
149
126
  });
150
127
 
151
- // node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
152
- var require_picocolors = __commonJS({
153
- "node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
154
- var p2 = process || {};
155
- var argv = p2.argv || [];
156
- var env = p2.env || {};
157
- var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
158
- var formatter = (open, close, replace = open) => (input) => {
159
- let string = "" + input, index = string.indexOf(close, open.length);
160
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
161
- };
162
- var replaceClose = (string, close, replace, index) => {
163
- let result = "", cursor = 0;
164
- do {
165
- result += string.substring(cursor, index) + replace;
166
- cursor = index + close.length;
167
- index = string.indexOf(close, cursor);
168
- } while (~index);
169
- return result + string.substring(cursor);
170
- };
171
- var createColors = (enabled = isColorSupported) => {
172
- let f = enabled ? formatter : () => String;
173
- return {
174
- isColorSupported: enabled,
175
- reset: f("\x1B[0m", "\x1B[0m"),
176
- bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
177
- dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
178
- italic: f("\x1B[3m", "\x1B[23m"),
179
- underline: f("\x1B[4m", "\x1B[24m"),
180
- inverse: f("\x1B[7m", "\x1B[27m"),
181
- hidden: f("\x1B[8m", "\x1B[28m"),
182
- strikethrough: f("\x1B[9m", "\x1B[29m"),
183
- black: f("\x1B[30m", "\x1B[39m"),
184
- red: f("\x1B[31m", "\x1B[39m"),
185
- green: f("\x1B[32m", "\x1B[39m"),
186
- yellow: f("\x1B[33m", "\x1B[39m"),
187
- blue: f("\x1B[34m", "\x1B[39m"),
188
- magenta: f("\x1B[35m", "\x1B[39m"),
189
- cyan: f("\x1B[36m", "\x1B[39m"),
190
- white: f("\x1B[37m", "\x1B[39m"),
191
- gray: f("\x1B[90m", "\x1B[39m"),
192
- bgBlack: f("\x1B[40m", "\x1B[49m"),
193
- bgRed: f("\x1B[41m", "\x1B[49m"),
194
- bgGreen: f("\x1B[42m", "\x1B[49m"),
195
- bgYellow: f("\x1B[43m", "\x1B[49m"),
196
- bgBlue: f("\x1B[44m", "\x1B[49m"),
197
- bgMagenta: f("\x1B[45m", "\x1B[49m"),
198
- bgCyan: f("\x1B[46m", "\x1B[49m"),
199
- bgWhite: f("\x1B[47m", "\x1B[49m"),
200
- blackBright: f("\x1B[90m", "\x1B[39m"),
201
- redBright: f("\x1B[91m", "\x1B[39m"),
202
- greenBright: f("\x1B[92m", "\x1B[39m"),
203
- yellowBright: f("\x1B[93m", "\x1B[39m"),
204
- blueBright: f("\x1B[94m", "\x1B[39m"),
205
- magentaBright: f("\x1B[95m", "\x1B[39m"),
206
- cyanBright: f("\x1B[96m", "\x1B[39m"),
207
- whiteBright: f("\x1B[97m", "\x1B[39m"),
208
- bgBlackBright: f("\x1B[100m", "\x1B[49m"),
209
- bgRedBright: f("\x1B[101m", "\x1B[49m"),
210
- bgGreenBright: f("\x1B[102m", "\x1B[49m"),
211
- bgYellowBright: f("\x1B[103m", "\x1B[49m"),
212
- bgBlueBright: f("\x1B[104m", "\x1B[49m"),
213
- bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
214
- bgCyanBright: f("\x1B[106m", "\x1B[49m"),
215
- bgWhiteBright: f("\x1B[107m", "\x1B[49m")
216
- };
217
- };
218
- module.exports = createColors();
219
- module.exports.createColors = createColors;
220
- }
221
- });
222
-
223
128
  // src/utils/log.ts
224
- var import_picocolors, log, exit;
129
+ import pc from "picocolors";
130
+ var log, exit;
225
131
  var init_log = __esm({
226
132
  "src/utils/log.ts"() {
227
133
  "use strict";
228
- import_picocolors = __toESM(require_picocolors(), 1);
229
134
  log = {
230
135
  /**
231
136
  * 输出成功消息(绿色)
@@ -233,7 +138,7 @@ var init_log = __esm({
233
138
  * @returns 无返回值
234
139
  */
235
140
  success(message) {
236
- process.stdout.write(`${import_picocolors.default.green(message)}
141
+ process.stdout.write(`${pc.green(message)}
237
142
  `);
238
143
  },
239
144
  /**
@@ -242,7 +147,7 @@ var init_log = __esm({
242
147
  * @returns 无返回值
243
148
  */
244
149
  err(message) {
245
- process.stderr.write(`${import_picocolors.default.bold(import_picocolors.default.red(message))}
150
+ process.stderr.write(`${pc.bold(pc.red(message))}
246
151
  `);
247
152
  },
248
153
  /**
@@ -251,7 +156,7 @@ var init_log = __esm({
251
156
  * @returns 无返回值
252
157
  */
253
158
  info(message) {
254
- process.stdout.write(`${import_picocolors.default.blue(message)}
159
+ process.stdout.write(`${pc.blue(message)}
255
160
  `);
256
161
  },
257
162
  /**
@@ -260,7 +165,7 @@ var init_log = __esm({
260
165
  * @returns 无返回值
261
166
  */
262
167
  warn(message) {
263
- process.stdout.write(`${import_picocolors.default.yellow(message)}
168
+ process.stdout.write(`${pc.yellow(message)}
264
169
  `);
265
170
  },
266
171
  /**
@@ -300,8 +205,6 @@ __export(process_exports, {
300
205
  getCdRelativePath: () => getCdRelativePath,
301
206
  getGitUser: () => getGitUser,
302
207
  getPackageName: () => getPackageName,
303
- get_plugin_latest_version: () => get_plugin_latest_version,
304
- get_plugin_version: () => get_plugin_version,
305
208
  runAsyncCmd: () => runAsyncCmd,
306
209
  userInfo: () => userInfo,
307
210
  wait: () => wait,
@@ -312,7 +215,7 @@ import { promisify } from "node:util";
312
215
  import { $ } from "execa";
313
216
  import figlet from "figlet";
314
217
  import _ from "lodash";
315
- var camelCase, upperFirst, detectPackageManager, userInfo, getPackageName, wait, welcomeCli, compareVersion, getCdRelativePath, runAsyncCmd, getGitUser, get_plugin_version, get_plugin_latest_version;
218
+ var camelCase, upperFirst, detectPackageManager, userInfo, getPackageName, wait, welcomeCli, compareVersion, getCdRelativePath, runAsyncCmd, getGitUser;
316
219
  var init_process = __esm({
317
220
  "src/utils/process.ts"() {
318
221
  "use strict";
@@ -389,21 +292,6 @@ var init_process = __esm({
389
292
  return "";
390
293
  }
391
294
  };
392
- get_plugin_version = async (pluginName) => {
393
- if (!pluginName) return "";
394
- try {
395
- const args = ["view", pluginName, "version"];
396
- const result = await $`npm ${args}`;
397
- return result.stdout.trim();
398
- } catch {
399
- return "";
400
- }
401
- };
402
- get_plugin_latest_version = async (pluginName, defaultVersion = "") => {
403
- if (!pluginName) return {};
404
- const version2 = await get_plugin_version(pluginName) || defaultVersion;
405
- return { [pluginName]: `^${version2}` };
406
- };
407
295
  }
408
296
  });
409
297
 
@@ -417,7 +305,7 @@ var init_package = __esm({
417
305
  "package.json"() {
418
306
  package_default = {
419
307
  name: "pangu-vis-cli",
420
- version: "1.2.0",
308
+ version: "1.2.1",
421
309
  description: "vis-cli",
422
310
  keywords: [
423
311
  "pangu-vis",
@@ -568,7 +456,6 @@ async function getLatestVersion(packageName, defaultValue) {
568
456
  signal: AbortSignal.timeout(5e3)
569
457
  });
570
458
  if (!response.ok) {
571
- latestVersionCache.set(cacheKey, defaultValue);
572
459
  return defaultValue;
573
460
  }
574
461
  const data = await response.json();
@@ -577,13 +464,10 @@ async function getLatestVersion(packageName, defaultValue) {
577
464
  latestVersionCache.set(cacheKey, result);
578
465
  return result;
579
466
  } catch (_error) {
580
- if (packageName) {
581
- latestVersionCache.set(`${packageName}\0${defaultValue ?? ""}`, defaultValue);
582
- }
583
467
  return defaultValue;
584
468
  }
585
469
  }
586
- async function get_plugin_latest_version2(packageName, defaultValue) {
470
+ async function get_plugin_latest_version(packageName, defaultValue) {
587
471
  if (!packageName) {
588
472
  return {};
589
473
  }
@@ -884,7 +768,7 @@ import { to as to2 } from "await-to-js";
884
768
  import fs4 from "fs-extra";
885
769
  import _2 from "lodash";
886
770
  import tar from "tar";
887
- var mergeWith, isArray, getPath, buildTarHandler, filterFile, scanDirHandle, updatePackageJson, outputVueName, isChartModuleRoot, scanFileFindChart, cachedScanResult, cachedScanRoot, scanAllDirectories, clearScanCache;
771
+ var mergeWith, isArray, getPath, buildTarHandler, filterFileWorker, filterFile, scanDirHandle, updatePackageJson, outputVueName, isChartModuleRoot, scanFileFindChart, cachedScanResult, cachedScanRoot, scanAllDirectories, clearScanCache;
888
772
  var init_fs = __esm({
889
773
  "src/utils/fs.ts"() {
890
774
  "use strict";
@@ -919,24 +803,36 @@ var init_fs = __esm({
919
803
  writeStream.on("error", reject);
920
804
  });
921
805
  };
806
+ filterFileWorker = async (dir, ignoreFiles) => {
807
+ const [err, resDir] = await to2(fs4.readdir(dir));
808
+ if (err) {
809
+ return exit(err.message);
810
+ }
811
+ await Promise.all(
812
+ resDir.map(async (v) => {
813
+ const itemPath = path4.resolve(dir, v);
814
+ if (ignoreFiles.includes(v)) {
815
+ await fs4.remove(itemPath);
816
+ return;
817
+ }
818
+ const itemStats = await fs4.stat(itemPath);
819
+ if (itemStats.isDirectory()) {
820
+ await filterFileWorker(itemPath, ignoreFiles);
821
+ }
822
+ })
823
+ );
824
+ };
922
825
  filterFile = async (dirPath, ignoreFiles = [".git", ".vscode", ".DS_Store", ".idea"]) => {
923
826
  const dir = dirPath || process.cwd();
924
827
  const res = await fs4.pathExists(dir);
925
828
  if (res) {
829
+ const rootSegments = dir.split(path4.sep);
830
+ if (ignoreFiles.some((ignoreFile) => rootSegments.includes(ignoreFile))) {
831
+ return;
832
+ }
926
833
  const isDir = await fs4.stat(dir);
927
834
  if (isDir.isDirectory()) {
928
- const [err, resDir] = await to2(fs4.readdir(dir));
929
- if (err) {
930
- return exit(err.message);
931
- }
932
- await Promise.all(resDir.map((v) => filterFile(path4.resolve(dir, v), ignoreFiles)));
933
- } else {
934
- for (const ignoreFile of ignoreFiles) {
935
- if (dir.includes(ignoreFile)) {
936
- await fs4.remove(dir);
937
- return;
938
- }
939
- }
835
+ await filterFileWorker(dir, ignoreFiles);
940
836
  }
941
837
  }
942
838
  };
@@ -1098,7 +994,7 @@ __export(utils_exports, {
1098
994
  getPath: () => getPath,
1099
995
  getPrivateSource: () => getPrivateSource,
1100
996
  get_cli_config: () => get_cli_config,
1101
- get_plugin_latest_version: () => get_plugin_latest_version2,
997
+ get_plugin_latest_version: () => get_plugin_latest_version,
1102
998
  get_update_log: () => get_update_log,
1103
999
  groupPrompts: () => groupPrompts,
1104
1000
  handleCancel: () => handleCancel,
@@ -1132,6 +1028,7 @@ __export(utils_exports, {
1132
1028
  wrapAsyncOperation: () => wrapAsyncOperation
1133
1029
  });
1134
1030
  import * as p from "@clack/prompts";
1031
+ import pc2 from "picocolors";
1135
1032
  async function textPrompt(options) {
1136
1033
  return promptUntilValid("text", options);
1137
1034
  }
@@ -1221,7 +1118,7 @@ async function progress(items, handler, options) {
1221
1118
  }
1222
1119
  }
1223
1120
  }
1224
- var import_picocolors2, spinner2, intro2, outro2, note2, handleCancel, normalizeValidationResult, validatePromptValue, promptUntilValid, promptHandlers, checkUpdate;
1121
+ var spinner2, intro2, outro2, note2, handleCancel, normalizeValidationResult, validatePromptValue, promptUntilValid, promptHandlers, checkUpdate;
1225
1122
  var init_utils = __esm({
1226
1123
  "src/utils/index.ts"() {
1227
1124
  "use strict";
@@ -1231,7 +1128,6 @@ var init_utils = __esm({
1231
1128
  init_error();
1232
1129
  init_fs();
1233
1130
  init_log();
1234
- import_picocolors2 = __toESM(require_picocolors(), 1);
1235
1131
  init_api();
1236
1132
  init_config();
1237
1133
  init_log();
@@ -1248,9 +1144,9 @@ var init_utils = __esm({
1248
1144
  message: (msg) => s.message(msg)
1249
1145
  };
1250
1146
  };
1251
- intro2 = (title) => p.intro(import_picocolors2.default.bgCyan(import_picocolors2.default.black(` ${title} `)));
1147
+ intro2 = (title) => p.intro(pc2.bgCyan(pc2.black(` ${title} `)));
1252
1148
  outro2 = (message) => {
1253
- if (message) p.outro(import_picocolors2.default.green(message));
1149
+ if (message) p.outro(pc2.green(message));
1254
1150
  else p.outro();
1255
1151
  };
1256
1152
  note2 = (message, title) => p.note(message, title);
@@ -1531,7 +1427,7 @@ async function getStandaloneDependencyVersion(packageName, defaultVersion, shoul
1531
1427
  [packageName]: `^${defaultVersion}`
1532
1428
  };
1533
1429
  }
1534
- return get_plugin_latest_version2(packageName, defaultVersion);
1430
+ return get_plugin_latest_version(packageName, defaultVersion);
1535
1431
  }
1536
1432
  async function handleChartTemplate(options) {
1537
1433
  const { projectName, projectPath, chartModule, author, chartType, chartId, isTs } = options;
@@ -1707,6 +1603,7 @@ import { fileURLToPath } from "node:url";
1707
1603
  import clear from "clear";
1708
1604
  import { $ as $3 } from "execa";
1709
1605
  import fs6 from "fs-extra";
1606
+ import pc3 from "picocolors";
1710
1607
  async function resolveTemplatePath(templateName, baseDir = __dirname) {
1711
1608
  const candidates = Array.from(new Set(getTemplatePathCandidates(templateName, baseDir)));
1712
1609
  for (const candidate of candidates) {
@@ -1819,19 +1716,18 @@ async function create(commandList = []) {
1819
1716
  installSpinner.stop();
1820
1717
  clear();
1821
1718
  await welcomeCli();
1822
- log.message(import_picocolors3.default.cyan("\n\u5B8C\u6210. \u73B0\u5728\u53EF\u4EE5\u6267\u884C:\n"));
1719
+ log.message(pc3.cyan("\n\u5B8C\u6210. \u73B0\u5728\u53EF\u4EE5\u6267\u884C:\n"));
1823
1720
  const cdPath = getCdRelativePath(process.cwd(), projectPath);
1824
1721
  log.success(` cd ${cdPath}`);
1825
1722
  log.success(` pnpm dev`);
1826
1723
  log.message("");
1827
1724
  clearScanCache();
1828
- outro2(import_picocolors3.default.green(`\u56FE\u8868 "${projectName}" \u521B\u5EFA\u6210\u529F!`));
1725
+ outro2(pc3.green(`\u56FE\u8868 "${projectName}" \u521B\u5EFA\u6210\u529F!`));
1829
1726
  }
1830
- var import_picocolors3, __filename, __dirname, getTemplatePathCandidates, CHART_TYPES;
1727
+ var __filename, __dirname, getTemplatePathCandidates, CHART_TYPES;
1831
1728
  var init_create = __esm({
1832
1729
  "src/create/index.ts"() {
1833
1730
  "use strict";
1834
- import_picocolors3 = __toESM(require_picocolors(), 1);
1835
1731
  init_schemas();
1836
1732
  init_utils();
1837
1733
  init_chart();
@@ -1876,7 +1772,6 @@ async function dev() {
1876
1772
  const packageJsonPath = join(cwd, "package.json");
1877
1773
  if (!await fs7.pathExists(packageJsonPath)) {
1878
1774
  exit("\u672A\u627E\u5230 package.json \u6587\u4EF6\uFF0C\u8BF7\u786E\u4FDD\u5728\u9879\u76EE\u6839\u76EE\u5F55\u6267\u884C\u6B64\u547D\u4EE4");
1879
- return;
1880
1775
  }
1881
1776
  let packageJson;
1882
1777
  try {
@@ -1888,7 +1783,6 @@ async function dev() {
1888
1783
  if (!packageJson.scripts?.dev) {
1889
1784
  log.info('\u793A\u4F8B\uFF1A{"scripts": {"dev": "vite"}}');
1890
1785
  exit("package.json \u4E2D\u672A\u5B9A\u4E49 dev \u811A\u672C\uFF0C\u8BF7\u5148\u6DFB\u52A0 dev \u811A\u672C");
1891
- return;
1892
1786
  }
1893
1787
  log.info(`\u6B63\u5728\u6267\u884C dev \u811A\u672C\uFF1A${packageJson.scripts.dev}`);
1894
1788
  let interrupted = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pangu-vis-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "vis-cli",
5
5
  "keywords": [
6
6
  "pangu-vis",