create-rezor 0.0.0 → 0.1.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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/outfile.js +368 -0
  4. package/package.json +35 -7
  5. package/template/base/_editorconfig +9 -0
  6. package/template/base/_gitignore +6 -0
  7. package/template/base/_npmrc +1 -0
  8. package/template/base/package.json.ejs +102 -0
  9. package/template/base/postcss.config.js +17 -0
  10. package/template/base/project.config.json +69 -0
  11. package/template/base/src/app.css +18 -0
  12. package/template/base/src/app.json +35 -0
  13. package/template/base/src/components/count-button/index.html +3 -0
  14. package/template/base/src/components/count-button/index.json +3 -0
  15. package/template/base/src/images/home-dark-selected.png +0 -0
  16. package/template/base/src/images/home-dark.png +0 -0
  17. package/template/base/src/images/home-light-selected.png +0 -0
  18. package/template/base/src/images/home-light.png +0 -0
  19. package/template/base/src/images/mine-dark-selected.png +0 -0
  20. package/template/base/src/images/mine-dark.png +0 -0
  21. package/template/base/src/images/mine-light-selected.png +0 -0
  22. package/template/base/src/images/mine-light.png +0 -0
  23. package/template/base/src/pages/home/index.css +28 -0
  24. package/template/base/src/pages/home/index.html +8 -0
  25. package/template/base/src/pages/home/index.json +5 -0
  26. package/template/base/src/pages/mine/index.css +28 -0
  27. package/template/base/src/pages/mine/index.html +8 -0
  28. package/template/base/src/pages/mine/index.json +5 -0
  29. package/template/base/src/sitemap.json +9 -0
  30. package/template/base/src/theme.json +20 -0
  31. package/template/eslint/eslint.config.js.ejs +89 -0
  32. package/template/javascript/babel.config.js +63 -0
  33. package/template/javascript/build.js +339 -0
  34. package/template/javascript/jsconfig.json +12 -0
  35. package/template/javascript/src/app.js +12 -0
  36. package/template/javascript/src/components/count-button/index.js +16 -0
  37. package/template/javascript/src/contexts/theme.js +3 -0
  38. package/template/javascript/src/pages/home/index.js +15 -0
  39. package/template/javascript/src/pages/mine/index.js +15 -0
  40. package/template/prettier/prettier.config.js +5 -0
  41. package/template/stylelint/_stylelintignore +1 -0
  42. package/template/stylelint/stylelint.config.js +15 -0
  43. package/template/typescript/babel.config.js +64 -0
  44. package/template/typescript/build.js +339 -0
  45. package/template/typescript/src/app.ts +12 -0
  46. package/template/typescript/src/components/count-button/index.ts +16 -0
  47. package/template/typescript/src/contexts/theme.ts +3 -0
  48. package/template/typescript/src/pages/home/index.ts +15 -0
  49. package/template/typescript/src/pages/mine/index.ts +15 -0
  50. package/template/typescript/tsconfig.json +20 -0
  51. package/template/vitest/__tests__/utils/index.spec.js +10 -0
  52. package/template/vitest/_gitignore +7 -0
  53. package/template/vitest/_stylelintignore +2 -0
  54. package/template/vitest/jsconfig.json +12 -0
  55. package/template/vitest/src/utils/index.js +12 -0
  56. package/template/vitest/vitest.config.js +21 -0
  57. package/template/vitest-typescript/__tests__/utils/index.spec.ts +10 -0
  58. package/template/vitest-typescript/_gitignore +7 -0
  59. package/template/vitest-typescript/_stylelintignore +2 -0
  60. package/template/vitest-typescript/src/utils/index.ts +12 -0
  61. package/template/vitest-typescript/tsconfig.json +20 -0
  62. package/template/vitest-typescript/vitest.config.ts +21 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Yang Mingshan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # create-rezor
2
+
3
+ 创建 Rezor 小程序项目的最佳方案。
4
+
5
+ ## 使用
6
+
7
+ 要使用 `create-rezor` 创建一个全新的 Rezor 小程序项目,请直接在终端内运行以下命令:
8
+
9
+ ```bash
10
+ npm create rezor@latest
11
+ ```
12
+
13
+ <!-- prettier-ignore -->
14
+ > [!NOTE]
15
+ > `@latest` **不能**省略,否则 `npm` 可能会使用已缓存的旧版本。
16
+
17
+ ## 致谢
18
+
19
+ 此项目由 [create-vue](https://github.com/vuejs/create-vue) 修改而来。
20
+
21
+ ## 许可证
22
+
23
+ [MIT](https://opensource.org/licenses/MIT)
24
+
25
+ Copyright (c) 2026-present Yang Mingshan
package/outfile.js ADDED
@@ -0,0 +1,368 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
3
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import process from 'node:process';
7
+ import { fileURLToPath } from 'node:url';
8
+ import ejs from 'ejs';
9
+ import prompts from 'prompts';
10
+ import { red, green, bold } from 'kolorist';
11
+ const defaultBanner = 'Rezor - 拥有原生性能的 React 小程序框架';
12
+ // Generated by the following code:
13
+ //
14
+ // require('gradient-string')([
15
+ // { color: '#f472b6', pos: 0 },
16
+ // { color: '#f472b6', pos: 0.1 },
17
+ // { color: '#818cf8', pos: 1 }
18
+ // ])('Rezor - 拥有原生性能的 React 小程序框架')
19
+ //
20
+ // Use the output directly here to keep the bundle small.
21
+ const gradientBanner = '\u001b[38;2;244;114;182mR\u001b[39m\u001b[38;2;244;114;182me\u001b[39m\u001b[38;2;244;114;182mz\u001b[39m\u001b[38;2;238;115;185mo\u001b[39m\u001b[38;2;233;117;189mr\u001b[39m \u001b[38;2;227;118;192m-\u001b[39m \u001b[38;2;221;119;195m拥\u001b[39m\u001b[38;2;215;121;199m有\u001b[39m\u001b[38;2;210;122;202m原\u001b[39m\u001b[38;2;204;123;205m生\u001b[39m\u001b[38;2;198;124;208m性\u001b[39m\u001b[38;2;192;126;212m能\u001b[39m\u001b[38;2;187;127;215m的\u001b[39m \u001b[38;2;181;128;218mR\u001b[39m\u001b[38;2;175;130;222me\u001b[39m\u001b[38;2;169;131;225ma\u001b[39m\u001b[38;2;164;132;228mc\u001b[39m\u001b[38;2;158;134;232mt\u001b[39m \u001b[38;2;152;135;235m小\u001b[39m\u001b[38;2;146;136;238m程\u001b[39m\u001b[38;2;141;137;241m序\u001b[39m\u001b[38;2;135;139;245m框\u001b[39m\u001b[38;2;129;140;248m架\u001b[39m';
22
+ function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
23
+ for (const filename of fs.readdirSync(dir)) {
24
+ if (filename === '.git') {
25
+ continue;
26
+ }
27
+ const fullpath = path.resolve(dir, filename);
28
+ if (fs.lstatSync(fullpath).isDirectory()) {
29
+ postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback);
30
+ dirCallback(fullpath);
31
+ continue;
32
+ }
33
+ fileCallback(fullpath);
34
+ }
35
+ }
36
+ function isValidPackageName(projectName) {
37
+ return /^(?:@[a-z\d-*~][a-z\d-*._~]*\/)?[a-z\d-~][a-z\d-._~]*$/.test(projectName);
38
+ }
39
+ function toValidPackageName(projectName) {
40
+ return projectName
41
+ .trim()
42
+ .toLowerCase()
43
+ .replaceAll(/\s+/g, '-')
44
+ .replace(/^[._]/, '')
45
+ .replaceAll(/[^a-z\d-~]+/g, '-');
46
+ }
47
+ function canSkipEmptying(dir) {
48
+ if (!fs.existsSync(dir)) {
49
+ return true;
50
+ }
51
+ const files = fs.readdirSync(dir);
52
+ if (files.length === 0) {
53
+ return true;
54
+ }
55
+ if (files.length === 1 && files[0] === '.git') {
56
+ return true;
57
+ }
58
+ return false;
59
+ }
60
+ function emptyDir(dir) {
61
+ if (!fs.existsSync(dir)) {
62
+ return;
63
+ }
64
+ postOrderDirectoryTraverse(dir, (dir) => {
65
+ fs.rmdirSync(dir);
66
+ }, (file) => {
67
+ fs.unlinkSync(file);
68
+ });
69
+ }
70
+ function renderTemplate(src, dest, result) {
71
+ const stats = fs.statSync(src);
72
+ if (stats.isDirectory()) {
73
+ // If it's a directory, render its subdirectories and files recursively
74
+ fs.mkdirSync(dest, { recursive: true });
75
+ for (const file of fs.readdirSync(src)) {
76
+ renderTemplate(path.resolve(src, file), path.resolve(dest, /^_[a-z]/.test(file) ? file.replace('_', '.') : file), result);
77
+ }
78
+ return;
79
+ }
80
+ const filename = path.basename(src);
81
+ if (filename.endsWith('.ejs')) {
82
+ const template = fs.readFileSync(src, 'utf8');
83
+ let content = ejs.render(template, result);
84
+ if (filename === 'package.json.ejs') {
85
+ content = content.replaceAll(',\n trailing-comma', '');
86
+ }
87
+ fs.writeFileSync(dest.replace(/\.ejs$/, ''), content);
88
+ return;
89
+ }
90
+ if (filename === 'project.config.json') {
91
+ const project = JSON.parse(fs.readFileSync(src, 'utf8'));
92
+ project.projectname = result.packageName;
93
+ fs.writeFileSync(dest, JSON.stringify(project, null, 2) + '\n');
94
+ return;
95
+ }
96
+ if (filename === 'app.json') {
97
+ const app = JSON.parse(fs.readFileSync(src, 'utf8'));
98
+ app.window.navigationBarTitleText = result.packageName;
99
+ fs.writeFileSync(dest, JSON.stringify(app, null, 2) + '\n');
100
+ return;
101
+ }
102
+ fs.copyFileSync(src, dest);
103
+ }
104
+ function getCommand(packageManager, scriptName) {
105
+ if (scriptName === 'install') {
106
+ return packageManager === 'yarn' ? 'yarn' : `${packageManager} install`;
107
+ }
108
+ return ['npm', 'bun'].includes(packageManager) ?
109
+ `${packageManager} run ${scriptName}`
110
+ : `${packageManager} ${scriptName}`;
111
+ }
112
+ function generateReadme({ packageManager, projectName, needsTypeScript, needsVitest, needsEslint, needsStylelint, needsPrettier, }) {
113
+ let readme = `# ${projectName}
114
+
115
+ ⚠️ 注意:将此项目导入微信开发者工具时请选择项目根目录而非 \`dist\` 目录。
116
+
117
+ 更多信息请访问官方文档:[rezor.dev](https://rezor.dev)
118
+
119
+ ## 依赖安装
120
+
121
+ \`\`\`sh
122
+ ${getCommand(packageManager, 'install')}
123
+ \`\`\`
124
+
125
+ ## 本地开发
126
+
127
+ \`\`\`sh
128
+ ${getCommand(packageManager, 'dev')}
129
+ \`\`\`
130
+
131
+ ## 生产构建
132
+
133
+ \`\`\`sh
134
+ ${getCommand(packageManager, 'build')}
135
+ \`\`\`
136
+ `;
137
+ if (needsPrettier) {
138
+ readme += `
139
+ ## 代码格式化
140
+
141
+ \`\`\`sh
142
+ ${getCommand(packageManager, 'format')}
143
+ \`\`\`
144
+ `;
145
+ }
146
+ if (needsEslint) {
147
+ readme += `
148
+ ## ${needsTypeScript ? 'TS' : 'JS'} 代码质量检测
149
+
150
+ \`\`\`sh
151
+ ${getCommand(packageManager, needsStylelint ? 'lint:script' : 'lint')}
152
+ \`\`\`
153
+ `;
154
+ }
155
+ if (needsStylelint) {
156
+ readme += `
157
+ ## CSS 代码质量检测
158
+
159
+ \`\`\`sh
160
+ ${getCommand(packageManager, needsEslint ? 'lint:style' : 'lint')}
161
+ \`\`\`
162
+ `;
163
+ }
164
+ if (needsTypeScript) {
165
+ readme += `
166
+ ## 类型检测
167
+
168
+ \`\`\`sh
169
+ ${getCommand(packageManager, 'type-check')}
170
+ \`\`\`
171
+ `;
172
+ }
173
+ if (needsVitest) {
174
+ readme += `
175
+ ## 单元测试
176
+
177
+ \`\`\`sh
178
+ ${getCommand(packageManager, 'test')}
179
+ \`\`\`
180
+ `;
181
+ }
182
+ return readme;
183
+ }
184
+ async function init() {
185
+ console.log();
186
+ console.log(process.stdout.isTTY && process.stdout.getColorDepth() > 8 ?
187
+ gradientBanner
188
+ : defaultBanner);
189
+ console.log();
190
+ const cwd = process.cwd();
191
+ let targetDir = process.argv[2];
192
+ const defaultProjectName = targetDir ?? 'rezor-project';
193
+ let result = {};
194
+ try {
195
+ // Prompts:
196
+ // - Project name:
197
+ // - whether to overwrite the existing directory or not?
198
+ // - enter a valid package name for package.json
199
+ result = await prompts([
200
+ {
201
+ name: 'projectName',
202
+ type: targetDir ? null : 'text',
203
+ message: '请输入项目名称:',
204
+ initial: defaultProjectName,
205
+ onState(state) {
206
+ targetDir = String(state.value).trim() || defaultProjectName;
207
+ },
208
+ },
209
+ {
210
+ name: 'shouldOverwrite',
211
+ type: () => (canSkipEmptying(targetDir) ? null : 'toggle'),
212
+ message() {
213
+ const dirForPrompt = targetDir === '.' ? '当前目录' : `目标文件夹 "${targetDir}"`;
214
+ return `${dirForPrompt} 非空,是否覆盖?`;
215
+ },
216
+ initial: true,
217
+ active: '是',
218
+ inactive: '否',
219
+ },
220
+ {
221
+ name: 'overwriteChecker',
222
+ type(_, values) {
223
+ if (values.shouldOverwrite === false) {
224
+ throw new Error(red('✖') + ` 操作取消`);
225
+ }
226
+ return null;
227
+ },
228
+ },
229
+ {
230
+ name: 'packageName',
231
+ type: () => (isValidPackageName(targetDir) ? null : 'text'),
232
+ message: '请输入包名称:',
233
+ initial: () => toValidPackageName(targetDir),
234
+ validate: (dir) => isValidPackageName(dir) || '无效的 package.json 名称',
235
+ },
236
+ {
237
+ name: 'needsTypeScript',
238
+ type: 'toggle',
239
+ message: '是否使用 TypeScript 语法?',
240
+ initial: false,
241
+ active: '是',
242
+ inactive: '否',
243
+ },
244
+ {
245
+ name: 'needsVitest',
246
+ type: 'toggle',
247
+ message: '是否引入 Vitest 用于单元测试?',
248
+ initial: false,
249
+ active: '是',
250
+ inactive: '否',
251
+ },
252
+ {
253
+ name: 'needsEslint',
254
+ type: 'toggle',
255
+ message: (_, values) => `是否引入 ESLint 用于 ${values.needsTypeScript ? 'TS' : 'JS'} 代码质量检测?`,
256
+ initial: false,
257
+ active: '是',
258
+ inactive: '否',
259
+ },
260
+ {
261
+ name: 'needsStylelint',
262
+ type: 'toggle',
263
+ message: '是否引入 Stylelint 用于 CSS 代码质量检测?',
264
+ initial: false,
265
+ active: '是',
266
+ inactive: '否',
267
+ },
268
+ {
269
+ name: 'needsPrettier',
270
+ type: 'toggle',
271
+ message: '是否引入 Prettier 用于代码格式化?',
272
+ initial: false,
273
+ active: '是',
274
+ inactive: '否',
275
+ },
276
+ ], {
277
+ onCancel() {
278
+ throw new Error(red('✖') + ` 操作取消`);
279
+ },
280
+ });
281
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
282
+ }
283
+ catch (error) {
284
+ console.error(error.message);
285
+ process.exit(1);
286
+ }
287
+ // `initial` won't take effect if the prompt type is null
288
+ // so we still have to assign the default values here
289
+ const { projectName, shouldOverwrite = false, packageName = projectName ?? defaultProjectName, needsTypeScript = false, needsVitest = false, needsEslint = false, needsStylelint = false, needsPrettier = false, } = result;
290
+ const root = path.join(cwd, targetDir);
291
+ if (fs.existsSync(root) && shouldOverwrite) {
292
+ emptyDir(root);
293
+ }
294
+ else if (!fs.existsSync(root)) {
295
+ fs.mkdirSync(root);
296
+ }
297
+ console.log(`\n正在初始化项目 ${root}...`);
298
+ const templateRoot = fileURLToPath(new URL('template', import.meta.url));
299
+ // Instructions:
300
+ // Supported package managers: pnpm > yarn > bun > npm
301
+ const userAgent = process.env.npm_config_user_agent ?? '';
302
+ const packageManager = userAgent.includes('pnpm') ? 'pnpm'
303
+ : userAgent.includes('yarn') ? 'yarn'
304
+ : userAgent.includes('bun') ? 'bun'
305
+ : 'npm';
306
+ const render = (templateName) => {
307
+ renderTemplate(path.resolve(templateRoot, templateName), root, {
308
+ packageName,
309
+ needsTypeScript,
310
+ needsVitest,
311
+ needsEslint,
312
+ needsStylelint,
313
+ needsPrettier,
314
+ packageManager: ['npm', 'bun'].includes(packageManager) ? '' : (userAgent.split(' ')[0].replace('/', '@')),
315
+ });
316
+ };
317
+ render('base');
318
+ if (needsTypeScript) {
319
+ render('typescript');
320
+ }
321
+ else {
322
+ render('javascript');
323
+ }
324
+ if (needsEslint) {
325
+ render('eslint');
326
+ }
327
+ if (needsStylelint) {
328
+ render('stylelint');
329
+ }
330
+ if (needsPrettier) {
331
+ render('prettier');
332
+ }
333
+ // Vitest should be the last one to render.
334
+ if (needsVitest) {
335
+ if (needsTypeScript) {
336
+ render('vitest-typescript');
337
+ }
338
+ else {
339
+ render('vitest');
340
+ }
341
+ }
342
+ fs.writeFileSync(path.resolve(root, 'README.md'), generateReadme({
343
+ packageManager,
344
+ projectName: projectName ?? packageName ?? defaultProjectName,
345
+ needsTypeScript,
346
+ needsVitest,
347
+ needsEslint,
348
+ needsStylelint,
349
+ needsPrettier,
350
+ }));
351
+ console.log(`\n项目初始化完成,可执行以下命令:\n`);
352
+ if (root !== cwd) {
353
+ const cdProjectName = path.relative(cwd, root);
354
+ console.log(` ${bold(green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}`);
355
+ }
356
+ console.log(` ${bold(green(getCommand(packageManager, 'install')))}`);
357
+ if (needsPrettier) {
358
+ console.log(` ${bold(green(getCommand(packageManager, 'format')))}`);
359
+ }
360
+ console.log(` ${bold(green(getCommand(packageManager, 'dev')))}`);
361
+ console.log();
362
+ }
363
+ try {
364
+ await init();
365
+ }
366
+ catch (error) {
367
+ console.error(error);
368
+ }
package/package.json CHANGED
@@ -1,12 +1,40 @@
1
1
  {
2
2
  "name": "create-rezor",
3
- "version": "0.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "keywords": [],
7
- "author": "",
8
- "license": "ISC",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Rezor 脚手架",
6
+ "bin": {
7
+ "create-rezor": "outfile.js"
8
+ },
9
+ "files": [
10
+ "outfile.js",
11
+ "template"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18.19.1 <19 || >=20.6.1"
15
+ },
16
+ "repository": "https://github.com/rezorjs/create-rezor.git",
17
+ "author": "Yang Mingshan <y.mingshan3@gmail.com>",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "ejs": "^5.0.1",
21
+ "kolorist": "^1.8.0",
22
+ "prompts": "^2.4.2"
23
+ },
24
+ "devDependencies": {
25
+ "@eslint/js": "^10.0.1",
26
+ "@types/ejs": "^3.1.5",
27
+ "@types/node": "^25.5.0",
28
+ "@types/prompts": "^2.4.9",
29
+ "eslint": "^10.1.0",
30
+ "prettier": "^3.8.1",
31
+ "typescript": "^6.0.2",
32
+ "typescript-eslint": "^8.58.0"
33
+ },
9
34
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
35
+ "format": "prettier --check \"**/*.{js,ts,json,md}\"",
36
+ "lint": "eslint .",
37
+ "type": "tsc --noEmit",
38
+ "build": "tsc && mv index.js outfile.js"
11
39
  }
12
40
  }
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ node_modules
3
+ dist
4
+ *.log*
5
+ .vscode
6
+ .idea
@@ -0,0 +1 @@
1
+ registry=https://registry.npmmirror.com/
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "<%- packageName %>",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ <%_ if (packageManager) { _%>
7
+ "packageManager": "<%- packageManager %>",
8
+ <%_ } _%>
9
+ "engines": {
10
+ "node": ">=18.19.1 <19 || >=20.6.1"
11
+ },
12
+ "scripts": {
13
+ <%_ if (needsPrettier) { _%>
14
+ "format": "prettier --write \"**/*.{js<% if (needsEslint) { %>,cjs<% } %><% if (needsTypeScript) { %>,ts<% } %>,json,css,html,md}\"",
15
+ <%_ } _%>
16
+ <%_ if (needsEslint) { _%>
17
+ "lint<% if (needsStylelint) { %>:script<% } %>": "eslint .",
18
+ <%_ } _%>
19
+ <%_ if (needsStylelint) { _%>
20
+ "lint<% if (needsEslint) { %>:style<% } %>": "stylelint \"src/**/*.css\"",
21
+ <%_ } _%>
22
+ <%_ if (needsTypeScript) { _%>
23
+ "type-check": "tsc",
24
+ <%_ } _%>
25
+ <%_ if (needsVitest) { _%>
26
+ "test": "vitest",
27
+ <%_ } _%>
28
+ "dev": "cross-env NODE_ENV=development node build.js",
29
+ "build": "cross-env NODE_ENV=production node build.js"
30
+ },
31
+ "dependencies": {
32
+ "@babel/runtime": "^7.29.2",
33
+ "rezor": "^0.1.0",
34
+ trailing-comma
35
+ },
36
+ "devDependencies": {
37
+ "@babel/core": "^7.29.0",
38
+ "@babel/plugin-transform-runtime": "^7.29.0",
39
+ "@babel/preset-env": "^7.29.2",
40
+ <%_ if (needsTypeScript) { _%>
41
+ "@babel/preset-typescript": "^7.28.5",
42
+ <%_ } _%>
43
+ "@babel/traverse": "^7.29.0",
44
+ "@babel/types": "^7.29.0",
45
+ <%_ if (needsEslint) { _%>
46
+ "@eslint/js": "^10.0.1",
47
+ <%_ } _%>
48
+ "@rollup/plugin-commonjs": "^29.0.2",
49
+ "@rollup/plugin-node-resolve": "^16.0.3",
50
+ "@rollup/plugin-replace": "^6.0.3",
51
+ "@rollup/plugin-terser": "^1.0.0",
52
+ <%_ if (needsTypeScript && needsVitest) { _%>
53
+ "@types/node": "^25.5.2",
54
+ <%_ } _%>
55
+ <%_ if (needsVitest) { _%>
56
+ "@vitest/coverage-v8": "^4.1.2",
57
+ <%_ } _%>
58
+ "babel-plugin-autocomplete-index": "^0.2.0",
59
+ "babel-plugin-module-resolver": "^5.0.3",
60
+ "babel-plugin-transform-inline-environment-variables": "^0.4.4",
61
+ "chokidar": "^5.0.0",
62
+ "cross-env": "^10.1.0",
63
+ <%_ if (needsEslint) { _%>
64
+ "eslint": "^10.2.0",
65
+ <%_ if (needsPrettier) { _%>
66
+ "eslint-config-prettier": "^10.1.8",
67
+ <%_ } _%>
68
+ <%_ } _%>
69
+ "fs-extra": "^11.3.4",
70
+ <%_ if (needsEslint) { _%>
71
+ "globals": "^17.4.0",
72
+ <%_ } _%>
73
+ "kolorist": "^1.8.0",
74
+ "local-pkg": "^1.1.2",
75
+ "postcss": "^8.5.8",
76
+ "postcss-load-config": "^6.0.1",
77
+ "postcss-pxtorpx-pro": "^2.0.0",
78
+ <%_ if (needsPrettier) { _%>
79
+ "prettier": "^3.8.1",
80
+ <%_ } _%>
81
+ "rollup": "^4.60.1",
82
+ <%_ if (needsStylelint) { _%>
83
+ "stylelint": "^17.6.0",
84
+ "stylelint-config-standard": "^40.0.0",
85
+ <%_ } _%>
86
+ "terser": "^5.46.1",
87
+ <%_ if (needsTypeScript) { _%>
88
+ "typescript": "^6.0.2",
89
+ <%_ } _%>
90
+ <%_ if (needsTypeScript && needsEslint) { _%>
91
+ "typescript-eslint": "^8.58.0",
92
+ <%_ } _%>
93
+ <%_ if (needsVitest) { _%>
94
+ "vitest": "^4.1.2",
95
+ <%_ } _%>
96
+ trailing-comma
97
+ },
98
+ "browserslist": [
99
+ "iOS >= 10",
100
+ "Chrome >= 63"
101
+ ]
102
+ }
@@ -0,0 +1,17 @@
1
+ import pxtorpx from 'postcss-pxtorpx-pro';
2
+
3
+ const config = {
4
+ plugins: [
5
+ {
6
+ postcssPlugin: 'postcss-import-css-to-wxss',
7
+ AtRule: {
8
+ import: (atRule) => {
9
+ atRule.params = atRule.params.replace('.css', '.wxss');
10
+ },
11
+ },
12
+ },
13
+ pxtorpx({ transform: (x) => x }),
14
+ ],
15
+ };
16
+
17
+ export default config;
@@ -0,0 +1,69 @@
1
+ {
2
+ "description": "项目配置文件",
3
+ "miniprogramRoot": "dist/",
4
+ "packOptions": {
5
+ "ignore": [],
6
+ "include": []
7
+ },
8
+ "setting": {
9
+ "urlCheck": false,
10
+ "es6": false,
11
+ "enhance": false,
12
+ "postcss": false,
13
+ "preloadBackgroundData": false,
14
+ "minified": false,
15
+ "newFeature": true,
16
+ "coverView": true,
17
+ "nodeModules": false,
18
+ "autoAudits": false,
19
+ "showShadowRootInWxmlPanel": false,
20
+ "scopeDataCheck": false,
21
+ "uglifyFileName": false,
22
+ "checkInvalidKey": true,
23
+ "checkSiteMap": true,
24
+ "uploadWithSourceMap": false,
25
+ "compileHotReLoad": true,
26
+ "lazyloadPlaceholderEnable": false,
27
+ "useMultiFrameRuntime": true,
28
+ "useApiHook": true,
29
+ "useApiHostProcess": true,
30
+ "babelSetting": {
31
+ "ignore": [],
32
+ "disablePlugins": [],
33
+ "outputPath": ""
34
+ },
35
+ "useIsolateContext": false,
36
+ "userConfirmedUseIsolateContext": false,
37
+ "userConfirmedBundleSwitch": false,
38
+ "packNpmManually": false,
39
+ "packNpmRelationList": [],
40
+ "minifyWXSS": true,
41
+ "disableUseStrict": false,
42
+ "minifyWXML": true,
43
+ "showES6CompileOption": false,
44
+ "useCompilerPlugins": false,
45
+ "ignoreUploadUnusedFiles": true,
46
+ "compileWorklet": false,
47
+ "localPlugins": false,
48
+ "condition": false,
49
+ "swc": false,
50
+ "disableSWC": true,
51
+ "skylineRenderEnable": false,
52
+ "useStaticServer": false,
53
+ "useLanDebug": false,
54
+ "ignoreDevUnusedFiles": true,
55
+ "bigPackageSizeSupport": false
56
+ },
57
+ "compileType": "miniprogram",
58
+ "libVersion": "development",
59
+ "appid": "",
60
+ "projectname": "rezor-project",
61
+ "simulatorType": "wechat",
62
+ "simulatorPluginLibVersion": {},
63
+ "condition": {},
64
+ "srcMiniprogramRoot": "dist/",
65
+ "editorSetting": {
66
+ "tabIndent": "insertSpaces",
67
+ "tabSize": 2
68
+ }
69
+ }
@@ -0,0 +1,18 @@
1
+ page {
2
+ color: #181818;
3
+ font-size: 28px;
4
+ font-family:
5
+ ui-sans-serif,
6
+ system-ui,
7
+ -apple-system,
8
+ BlinkMacSystemFont,
9
+ sans-serif;
10
+ background: #fff;
11
+ }
12
+
13
+ @media (prefers-color-scheme: dark) {
14
+ page {
15
+ color: #fff;
16
+ background: #181818;
17
+ }
18
+ }