@hlw-uni/mp-cli 1.0.23 → 1.0.25

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/bin/cli.js CHANGED
@@ -210,46 +210,59 @@ async function replaceTemplateVars(dir, vars) {
210
210
  }
211
211
  function printBanner() {
212
212
  const c = import_chalk.default;
213
- const rainbow = (t) => t.split("").map((ch, i) => {
214
- const colors = [c.red, c.yellow, c.green, c.cyan, c.blue, c.magenta];
215
- return colors[i % colors.length](ch);
216
- }).join("");
217
213
  function visualWidth(s) {
218
214
  let w = 0;
219
215
  for (const ch of s) {
220
216
  const code = ch.codePointAt(0);
221
- if (code >= 11904 && code <= 40959) w += 2;
222
- else if (code >= 65280 && code <= 65519) w += 2;
217
+ if (code >= 11904 && code <= 40959 || code >= 65280 && code <= 65519) w += 2;
223
218
  else w += 1;
224
219
  }
225
220
  return w;
226
221
  }
227
- const W = 44;
228
- const inner = W - 4;
229
- const b = c.cyanBright;
230
- const row = (plainMeasure, colored) => {
231
- const pad = " ".repeat(Math.max(0, inner - visualWidth(plainMeasure)));
232
- console.log(` ${b("\u2551")} ${colored}${pad} ${b("\u2551")}`);
222
+ const W = 50;
223
+ const ind = " ";
224
+ const row = (plain, colored) => {
225
+ const pad = " ".repeat(Math.max(0, W - visualWidth(plain)));
226
+ console.log(`${ind}${c.dim("\u2502")} ${colored}${pad} ${c.dim("\u2502")}`);
227
+ };
228
+ const blank = () => console.log(`${ind}${c.dim("\u2502")}${" ".repeat(W + 2)}${c.dim("\u2502")}`);
229
+ const nameChars = "hlw-uni-mp".split("");
230
+ const nameColors = [
231
+ c.cyanBright,
232
+ c.cyanBright,
233
+ c.cyanBright,
234
+ c.dim,
235
+ c.blueBright,
236
+ c.blueBright,
237
+ c.blueBright,
238
+ c.dim,
239
+ c.magentaBright,
240
+ c.magentaBright
241
+ ];
242
+ const nameGrad = nameChars.map((ch, i) => nameColors[i](ch)).join(c.dim(" "));
243
+ const namePlain = "h l w - u n i - m p";
244
+ const badge = ` v${version} `;
245
+ const titleGap = W - 3 - namePlain.length - badge.length;
246
+ const titleLine = c.cyan("\u273B") + " " + nameGrad + " ".repeat(Math.max(0, titleGap)) + c.bgCyan.black(badge);
247
+ const cmdColW = 16;
248
+ const cmdRow = (cmd, arg, desc) => {
249
+ const full = arg ? `${cmd} ${arg}` : cmd;
250
+ const padLen = Math.max(0, cmdColW - full.length);
251
+ const plain = ` \u276F ${full}${" ".repeat(padLen)}${desc}`;
252
+ const colored = ` ${c.cyan("\u276F")} ${c.bold.white(cmd)}` + (arg ? ` ${c.dim(arg)}` : "") + " ".repeat(padLen) + c.dim(desc);
253
+ row(plain, colored);
233
254
  };
234
255
  console.log();
235
- console.log(rainbow(" \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"));
236
- console.log(rainbow(" \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"));
237
- console.log(rainbow(" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"));
238
- console.log(rainbow(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551"));
239
- console.log(rainbow(" \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551"));
240
- console.log(rainbow(" \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
241
- console.log();
242
- console.log(" " + b("\u2554" + "\u2550".repeat(W) + "\u2557"));
243
- const badge = ` ${version} `;
244
- row(
245
- `\u25C6 hlw-uni CLI ${badge}`,
246
- `${c.magentaBright("\u25C6")} ${c.bold.white("hlw-uni")} ${c.cyanBright("CLI")} ${c.black.bgYellowBright(badge)}`
247
- );
248
- const subPlain = ` UniApp \u5C0F\u7A0B\u5E8F\u811A\u624B\u67B6\u751F\u6210\u5668`;
249
- row(subPlain, ` ${c.dim.gray("UniApp")} ${c.gray("\u5C0F\u7A0B\u5E8F\u811A\u624B\u67B6\u751F\u6210\u5668")}`);
250
- console.log(" " + b("\u255A" + "\u2550".repeat(W) + "\u255D"));
251
- console.log();
252
- console.log(" " + c.dim.cyan("\u25B8") + " " + c.dim("hlw-uni-mp --help"));
256
+ console.log(`${ind}${c.dim("\u256D" + "\u2500".repeat(W + 2) + "\u256E")}`);
257
+ blank();
258
+ console.log(`${ind}${c.dim("\u2502")} ${titleLine} ${c.dim("\u2502")}`);
259
+ blank();
260
+ row(" UniApp \u5C0F\u7A0B\u5E8F\u811A\u624B\u67B6\u751F\u6210\u5668", ` ${c.white("UniApp \u5C0F\u7A0B\u5E8F\u811A\u624B\u67B6\u751F\u6210\u5668")}`);
261
+ blank();
262
+ cmdRow("create", "<name>", "\u5F00\u59CB\u521B\u5EFA\u65B0\u9879\u76EE");
263
+ cmdRow("--help", "", "\u67E5\u770B\u6240\u6709\u547D\u4EE4");
264
+ blank();
265
+ console.log(`${ind}${c.dim("\u2570" + "\u2500".repeat(W + 2) + "\u256F")}`);
253
266
  console.log();
254
267
  }
255
268
  var config = require_config();
package/bin/cli.ts CHANGED
@@ -106,51 +106,65 @@ async function replaceTemplateVars(dir: string, vars: Record<string, string>) {
106
106
 
107
107
  function printBanner() {
108
108
  const c = chalk;
109
- const rainbow = (t: string) =>
110
- t.split('').map((ch, i) => {
111
- const colors = [c.red, c.yellow, c.green, c.cyan, c.blue, c.magenta];
112
- return colors[i % colors.length](ch);
113
- }).join('');
114
109
 
115
- /** 终端里常见 CJK / 全角约占 2 列,用于对齐框线 */
116
110
  function visualWidth(s: string): number {
117
111
  let w = 0;
118
112
  for (const ch of s) {
119
113
  const code = ch.codePointAt(0)!;
120
- if (code >= 0x2e80 && code <= 0x9fff) w += 2;
121
- else if (code >= 0xff00 && code <= 0xffef) w += 2;
114
+ if ((code >= 0x2e80 && code <= 0x9fff) || (code >= 0xff00 && code <= 0xffef)) w += 2;
122
115
  else w += 1;
123
116
  }
124
117
  return w;
125
118
  }
126
119
 
127
- const W = 44;
128
- const inner = W - 4;
129
- const b = c.cyanBright;
130
- const row = (plainMeasure: string, colored: string) => {
131
- const pad = ' '.repeat(Math.max(0, inner - visualWidth(plainMeasure)));
132
- console.log(` ${b('')} ${colored}${pad} ${b('')}`);
120
+ const W = 50;
121
+ const ind = ' ';
122
+
123
+ const row = (plain: string, colored: string) => {
124
+ const pad = ' '.repeat(Math.max(0, W - visualWidth(plain)));
125
+ console.log(`${ind}${c.dim('')} ${colored}${pad} ${c.dim('')}`);
126
+ };
127
+ const blank = () => console.log(`${ind}${c.dim('│')}${' '.repeat(W + 2)}${c.dim('│')}`);
128
+
129
+ // 工具名:字母间距 + 三段渐变色(cyan → blue → magenta)
130
+ const nameChars = 'hlw-uni-mp'.split('');
131
+ const nameColors = [c.cyanBright, c.cyanBright, c.cyanBright, c.dim,
132
+ c.blueBright, c.blueBright, c.blueBright, c.dim,
133
+ c.magentaBright, c.magentaBright];
134
+ const nameGrad = nameChars.map((ch, i) => nameColors[i](ch)).join(c.dim(' '));
135
+ const namePlain = 'h l w - u n i - m p'; // 19 chars,用于宽度计算
136
+
137
+ // 版本徽章 + 标题行排版
138
+ const badge = ` v${version} `;
139
+ const titleGap = W - 3 /* ✻ */ - namePlain.length - badge.length;
140
+ const titleLine = c.cyan('✻') + ' ' + nameGrad
141
+ + ' '.repeat(Math.max(0, titleGap))
142
+ + c.bgCyan.black(badge);
143
+
144
+ // 命令行(两列对齐)
145
+ const cmdColW = 16;
146
+ const cmdRow = (cmd: string, arg: string, desc: string) => {
147
+ const full = arg ? `${cmd} ${arg}` : cmd;
148
+ const padLen = Math.max(0, cmdColW - full.length);
149
+ const plain = ` ❯ ${full}${' '.repeat(padLen)}${desc}`;
150
+ const colored = ` ${c.cyan('❯')} ${c.bold.white(cmd)}`
151
+ + (arg ? ` ${c.dim(arg)}` : '')
152
+ + ' '.repeat(padLen)
153
+ + c.dim(desc);
154
+ row(plain, colored);
133
155
  };
134
156
 
135
157
  console.log();
136
- console.log(rainbow(' ██╗ ██╗ ██████╗ ████████╗███████╗██████╗ ███████╗'));
137
- console.log(rainbow(' ██║ ██║██╔═══██╗╚══██╔══╝██╔════╝██╔══██╗██╔════╝'));
138
- console.log(rainbow(' ███████║██║ ██║ ██║ █████╗ ██████╔╝███████╗'));
139
- console.log(rainbow(' ██╔══██║██║ ██║ ██║ ██╔══╝ ██╔══██╗╚════██║'));
140
- console.log(rainbow(' ██║ ██║╚██████╔╝ ██║ ███████╗██║ ██║███████║'));
141
- console.log(rainbow(' ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝'));
142
- console.log();
143
- console.log(' ' + b('' + ''.repeat(W) + '╗'));
144
- const badge = ` ${version} `;
145
- row(
146
- `◆ hlw-uni CLI ${badge}`,
147
- `${c.magentaBright('◆')} ${c.bold.white('hlw-uni')} ${c.cyanBright('CLI')} ${c.black.bgYellowBright(badge)}`,
148
- );
149
- const subPlain = ` UniApp 小程序脚手架生成器`;
150
- row(subPlain, ` ${c.dim.gray('UniApp')} ${c.gray('小程序脚手架生成器')}`);
151
- console.log(' ' + b('╚' + '═'.repeat(W) + '╝'));
152
- console.log();
153
- console.log(' ' + c.dim.cyan('▸') + ' ' + c.dim('hlw-uni-mp --help'));
158
+ console.log(`${ind}${c.dim('╭' + '─'.repeat(W + 2) + '╮')}`);
159
+ blank();
160
+ console.log(`${ind}${c.dim('')} ${titleLine} ${c.dim('│')}`);
161
+ blank();
162
+ row(' UniApp 小程序脚手架生成器', ` ${c.white('UniApp 小程序脚手架生成器')}`);
163
+ blank();
164
+ cmdRow('create', '<name>', '开始创建新项目');
165
+ cmdRow('--help', '', '查看所有命令');
166
+ blank();
167
+ console.log(`${ind}${c.dim('╰' + '─'.repeat(W + 2) + '╯')}`);
154
168
  console.log();
155
169
  }
156
170
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-cli",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "uniapp 小程序脚手架生成器",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -11,8 +11,8 @@
11
11
  "@dcloudio/uni-app-plus": "3.0.0-4080420251103001",
12
12
  "@dcloudio/uni-components": "3.0.0-4080420251103001",
13
13
  "@dcloudio/uni-mp-toutiao": "3.0.0-4080420251103001",
14
- "@hlw-uni/mp-core": "^1.0.10",
15
- "@hlw-uni/mp-vue": "^1.0.3",
14
+ "@hlw-uni/mp-core": "^1.0.11",
15
+ "@hlw-uni/mp-vue": "^1.0.4",
16
16
  "@vueuse/core": "^10.9.0",
17
17
  "pinia": "^2.1.7",
18
18
  "pinia-plugin-unistorage": "^1.2.3",
@@ -22,9 +22,8 @@
22
22
  "@dcloudio/types": "^3.4.8",
23
23
  "@dcloudio/uni-cli-shared": "3.0.0-4080420251103001",
24
24
  "@dcloudio/vite-plugin-uni": "3.0.0-4080420251103001",
25
- "@hlw-uni/mp-vite-plugin": "^1.0.10",
25
+ "@hlw-uni/mp-vite-plugin": "^1.0.11",
26
26
  "@unocss/transformer-directives": "^66.1.1",
27
- "@vue/tsconfig": "^0.1.3",
28
27
  "sass": "^1.70.0",
29
28
  "typescript": "^4.9.4",
30
29
  "unocss": "^66.0.0",
@@ -1,15 +1,21 @@
1
- {
2
- "extends": "@vue/tsconfig/tsconfig.json",
3
- "compilerOptions": {
4
- "target": "ESNext",
5
- "module": "ESNext",
6
- "moduleResolution": "Node",
7
- "verbatimModuleSyntax": false,
8
- "paths": {
9
- "@/*": ["./src/*"]
10
- },
11
- "types": ["@dcloudio/types", "vite/client"]
12
- },
13
- "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
14
- "exclude": ["node_modules", "dist", "unpackage"]
15
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "resolveJsonModule": true,
7
+ "jsx": "preserve",
8
+ "strict": true,
9
+ "noImplicitThis": true,
10
+ "isolatedModules": true,
11
+ "esModuleInterop": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "skipLibCheck": true,
14
+ "verbatimModuleSyntax": false,
15
+ "paths": {
16
+ "@/*": ["./src/*"]
17
+ }
18
+ },
19
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
20
+ "exclude": ["node_modules", "dist", "unpackage"]
21
+ }
@@ -12,8 +12,8 @@
12
12
  "@dcloudio/uni-app-plus": "3.0.0-4080420251103001",
13
13
  "@dcloudio/uni-components": "3.0.0-4080420251103001",
14
14
  "@dcloudio/uni-mp-weixin": "3.0.0-4080420251103001",
15
- "@hlw-uni/mp-core": "^1.0.10",
16
- "@hlw-uni/mp-vue": "^1.0.3",
15
+ "@hlw-uni/mp-core": "^1.0.11",
16
+ "@hlw-uni/mp-vue": "^1.0.4",
17
17
  "@vueuse/core": "^10.9.0",
18
18
  "pinia": "^2.1.7",
19
19
  "pinia-plugin-unistorage": "^0.1.2",
@@ -23,9 +23,8 @@
23
23
  "@dcloudio/types": "^3.4.8",
24
24
  "@dcloudio/uni-cli-shared": "3.0.0-4080420251103001",
25
25
  "@dcloudio/vite-plugin-uni": "3.0.0-4080420251103001",
26
- "@hlw-uni/mp-vite-plugin": "^1.0.10",
26
+ "@hlw-uni/mp-vite-plugin": "^1.0.11",
27
27
  "@unocss/transformer-directives": "^65.4.3",
28
- "@vue/tsconfig": "^0.1.3",
29
28
  "sass": "^1.70.0",
30
29
  "typescript": "^4.9.4",
31
30
  "unocss": "^65.4.3",
@@ -1,14 +1,20 @@
1
1
  {
2
- "extends": "@vue/tsconfig/tsconfig.json",
3
2
  "compilerOptions": {
4
3
  "target": "ESNext",
5
4
  "module": "ESNext",
6
5
  "moduleResolution": "Node",
6
+ "resolveJsonModule": true,
7
+ "jsx": "preserve",
8
+ "strict": true,
9
+ "noImplicitThis": true,
10
+ "isolatedModules": true,
11
+ "esModuleInterop": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "skipLibCheck": true,
7
14
  "verbatimModuleSyntax": false,
8
15
  "paths": {
9
16
  "@/*": ["./src/*"]
10
- },
11
- "types": ["@dcloudio/types", "vite/client"]
17
+ }
12
18
  },
13
19
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
14
20
  "exclude": ["node_modules", "dist", "unpackage"]