@weapp-core/init 1.0.9 → 1.1.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.
- package/dist/index.cjs +352 -101
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +340 -96
- package/package.json +5 -3
- package/templates/default/package.json +37 -0
- package/templates/default/postcss.config.js +6 -0
- package/templates/default/project.config.json +42 -0
- package/templates/default/project.private.config.json +7 -0
- package/templates/default/src/app.json +12 -0
- package/templates/default/src/app.scss +3 -0
- package/templates/default/src/app.ts +6 -0
- package/templates/default/src/components/navigation-bar/navigation-bar.json +7 -0
- package/templates/default/src/components/navigation-bar/navigation-bar.scss +0 -0
- package/templates/default/src/components/navigation-bar/navigation-bar.ts +3 -0
- package/templates/default/src/components/navigation-bar/navigation-bar.wxml +0 -0
- package/templates/default/src/pages/index/index.json +7 -0
- package/templates/default/src/pages/index/index.scss +0 -0
- package/templates/default/src/pages/index/index.ts +17 -0
- package/templates/default/src/pages/index/index.wxml +12 -0
- package/templates/default/src/pages/logs/logs.json +6 -0
- package/templates/default/src/pages/logs/logs.scss +0 -0
- package/templates/default/src/pages/logs/logs.ts +3 -0
- package/templates/default/src/pages/logs/logs.wxml +0 -0
- package/templates/default/src/sitemap.json +10 -0
- package/templates/default/src/theme.json +5 -0
- package/templates/default/src/utils/util.ts +0 -0
- package/templates/default/tailwind.config.ts +22 -0
- package/templates/default/tsconfig.json +46 -0
- package/templates/default/tsconfig.node.json +13 -0
- package/templates/default/vite-env.d.ts +1 -0
- package/templates/default/vite.config.ts +28 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,230 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import process2 from "node:process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
4
|
import logger from "@weapp-core/logger";
|
|
5
5
|
import { defu, get, set } from "@weapp-core/shared";
|
|
6
6
|
import fs from "fs-extra";
|
|
7
7
|
|
|
8
|
+
// ../../node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
9
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
10
|
+
function normalizeWindowsPath(input = "") {
|
|
11
|
+
if (!input) {
|
|
12
|
+
return input;
|
|
13
|
+
}
|
|
14
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
15
|
+
}
|
|
16
|
+
var _UNC_REGEX = /^[/\\]{2}/;
|
|
17
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
18
|
+
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
19
|
+
var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
20
|
+
var sep = "/";
|
|
21
|
+
var delimiter = ":";
|
|
22
|
+
var normalize = function(path2) {
|
|
23
|
+
if (path2.length === 0) {
|
|
24
|
+
return ".";
|
|
25
|
+
}
|
|
26
|
+
path2 = normalizeWindowsPath(path2);
|
|
27
|
+
const isUNCPath = path2.match(_UNC_REGEX);
|
|
28
|
+
const isPathAbsolute = isAbsolute(path2);
|
|
29
|
+
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
30
|
+
path2 = normalizeString(path2, !isPathAbsolute);
|
|
31
|
+
if (path2.length === 0) {
|
|
32
|
+
if (isPathAbsolute) {
|
|
33
|
+
return "/";
|
|
34
|
+
}
|
|
35
|
+
return trailingSeparator ? "./" : ".";
|
|
36
|
+
}
|
|
37
|
+
if (trailingSeparator) {
|
|
38
|
+
path2 += "/";
|
|
39
|
+
}
|
|
40
|
+
if (_DRIVE_LETTER_RE.test(path2)) {
|
|
41
|
+
path2 += "/";
|
|
42
|
+
}
|
|
43
|
+
if (isUNCPath) {
|
|
44
|
+
if (!isPathAbsolute) {
|
|
45
|
+
return `//./${path2}`;
|
|
46
|
+
}
|
|
47
|
+
return `//${path2}`;
|
|
48
|
+
}
|
|
49
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
50
|
+
};
|
|
51
|
+
var join = function(...arguments_) {
|
|
52
|
+
if (arguments_.length === 0) {
|
|
53
|
+
return ".";
|
|
54
|
+
}
|
|
55
|
+
let joined;
|
|
56
|
+
for (const argument of arguments_) {
|
|
57
|
+
if (argument && argument.length > 0) {
|
|
58
|
+
if (joined === void 0) {
|
|
59
|
+
joined = argument;
|
|
60
|
+
} else {
|
|
61
|
+
joined += `/${argument}`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (joined === void 0) {
|
|
66
|
+
return ".";
|
|
67
|
+
}
|
|
68
|
+
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
69
|
+
};
|
|
70
|
+
function cwd() {
|
|
71
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
72
|
+
return process.cwd().replace(/\\/g, "/");
|
|
73
|
+
}
|
|
74
|
+
return "/";
|
|
75
|
+
}
|
|
76
|
+
var resolve = function(...arguments_) {
|
|
77
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
78
|
+
let resolvedPath = "";
|
|
79
|
+
let resolvedAbsolute = false;
|
|
80
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
81
|
+
const path2 = index >= 0 ? arguments_[index] : cwd();
|
|
82
|
+
if (!path2 || path2.length === 0) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
resolvedPath = `${path2}/${resolvedPath}`;
|
|
86
|
+
resolvedAbsolute = isAbsolute(path2);
|
|
87
|
+
}
|
|
88
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
89
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
90
|
+
return `/${resolvedPath}`;
|
|
91
|
+
}
|
|
92
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
93
|
+
};
|
|
94
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
95
|
+
let res = "";
|
|
96
|
+
let lastSegmentLength = 0;
|
|
97
|
+
let lastSlash = -1;
|
|
98
|
+
let dots = 0;
|
|
99
|
+
let char = null;
|
|
100
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
101
|
+
if (index < path2.length) {
|
|
102
|
+
char = path2[index];
|
|
103
|
+
} else if (char === "/") {
|
|
104
|
+
break;
|
|
105
|
+
} else {
|
|
106
|
+
char = "/";
|
|
107
|
+
}
|
|
108
|
+
if (char === "/") {
|
|
109
|
+
if (lastSlash === index - 1 || dots === 1) ;
|
|
110
|
+
else if (dots === 2) {
|
|
111
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
112
|
+
if (res.length > 2) {
|
|
113
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
114
|
+
if (lastSlashIndex === -1) {
|
|
115
|
+
res = "";
|
|
116
|
+
lastSegmentLength = 0;
|
|
117
|
+
} else {
|
|
118
|
+
res = res.slice(0, lastSlashIndex);
|
|
119
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
120
|
+
}
|
|
121
|
+
lastSlash = index;
|
|
122
|
+
dots = 0;
|
|
123
|
+
continue;
|
|
124
|
+
} else if (res.length > 0) {
|
|
125
|
+
res = "";
|
|
126
|
+
lastSegmentLength = 0;
|
|
127
|
+
lastSlash = index;
|
|
128
|
+
dots = 0;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (allowAboveRoot) {
|
|
133
|
+
res += res.length > 0 ? "/.." : "..";
|
|
134
|
+
lastSegmentLength = 2;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
if (res.length > 0) {
|
|
138
|
+
res += `/${path2.slice(lastSlash + 1, index)}`;
|
|
139
|
+
} else {
|
|
140
|
+
res = path2.slice(lastSlash + 1, index);
|
|
141
|
+
}
|
|
142
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
143
|
+
}
|
|
144
|
+
lastSlash = index;
|
|
145
|
+
dots = 0;
|
|
146
|
+
} else if (char === "." && dots !== -1) {
|
|
147
|
+
++dots;
|
|
148
|
+
} else {
|
|
149
|
+
dots = -1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return res;
|
|
153
|
+
}
|
|
154
|
+
var isAbsolute = function(p) {
|
|
155
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
156
|
+
};
|
|
157
|
+
var toNamespacedPath = function(p) {
|
|
158
|
+
return normalizeWindowsPath(p);
|
|
159
|
+
};
|
|
160
|
+
var _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
161
|
+
var extname = function(p) {
|
|
162
|
+
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
163
|
+
return match && match[1] || "";
|
|
164
|
+
};
|
|
165
|
+
var relative = function(from, to) {
|
|
166
|
+
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
167
|
+
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
168
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
169
|
+
return _to.join("/");
|
|
170
|
+
}
|
|
171
|
+
const _fromCopy = [..._from];
|
|
172
|
+
for (const segment of _fromCopy) {
|
|
173
|
+
if (_to[0] !== segment) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
_from.shift();
|
|
177
|
+
_to.shift();
|
|
178
|
+
}
|
|
179
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
180
|
+
};
|
|
181
|
+
var dirname = function(p) {
|
|
182
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
183
|
+
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
184
|
+
segments[0] += "/";
|
|
185
|
+
}
|
|
186
|
+
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
187
|
+
};
|
|
188
|
+
var format = function(p) {
|
|
189
|
+
const segments = [p.root, p.dir, p.base ?? p.name + p.ext].filter(Boolean);
|
|
190
|
+
return normalizeWindowsPath(
|
|
191
|
+
p.root ? resolve(...segments) : segments.join("/")
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
var basename = function(p, extension) {
|
|
195
|
+
const lastSegment = normalizeWindowsPath(p).split("/").pop();
|
|
196
|
+
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
197
|
+
};
|
|
198
|
+
var parse = function(p) {
|
|
199
|
+
const root = normalizeWindowsPath(p).split("/").shift() || "/";
|
|
200
|
+
const base = basename(p);
|
|
201
|
+
const extension = extname(base);
|
|
202
|
+
return {
|
|
203
|
+
root,
|
|
204
|
+
dir: dirname(p),
|
|
205
|
+
base,
|
|
206
|
+
ext: extension,
|
|
207
|
+
name: base.slice(0, base.length - extension.length)
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
var path = {
|
|
211
|
+
__proto__: null,
|
|
212
|
+
basename,
|
|
213
|
+
delimiter,
|
|
214
|
+
dirname,
|
|
215
|
+
extname,
|
|
216
|
+
format,
|
|
217
|
+
isAbsolute,
|
|
218
|
+
join,
|
|
219
|
+
normalize,
|
|
220
|
+
normalizeString,
|
|
221
|
+
parse,
|
|
222
|
+
relative,
|
|
223
|
+
resolve,
|
|
224
|
+
sep,
|
|
225
|
+
toNamespacedPath
|
|
226
|
+
};
|
|
227
|
+
|
|
8
228
|
// src/context.ts
|
|
9
229
|
function createContext() {
|
|
10
230
|
return {
|
|
@@ -41,7 +261,109 @@ function createContext() {
|
|
|
41
261
|
};
|
|
42
262
|
}
|
|
43
263
|
|
|
264
|
+
// src/gitignore.ts
|
|
265
|
+
function getDefaultGitignore() {
|
|
266
|
+
return `# dependencies
|
|
267
|
+
node_modules
|
|
268
|
+
.pnp
|
|
269
|
+
.pnp.js
|
|
270
|
+
|
|
271
|
+
# testing
|
|
272
|
+
coverage
|
|
273
|
+
|
|
274
|
+
# next.js
|
|
275
|
+
.next/
|
|
276
|
+
out/
|
|
277
|
+
build
|
|
278
|
+
|
|
279
|
+
# misc
|
|
280
|
+
.DS_Store
|
|
281
|
+
*.pem
|
|
282
|
+
|
|
283
|
+
# debug
|
|
284
|
+
npm-debug.log*
|
|
285
|
+
yarn-debug.log*
|
|
286
|
+
yarn-error.log*
|
|
287
|
+
.pnpm-debug.log*
|
|
288
|
+
|
|
289
|
+
# local env files
|
|
290
|
+
.env.local
|
|
291
|
+
.env.development.local
|
|
292
|
+
.env.test.local
|
|
293
|
+
.env.production.local
|
|
294
|
+
|
|
295
|
+
# turbo
|
|
296
|
+
.turbo
|
|
297
|
+
|
|
298
|
+
dist
|
|
299
|
+
vite.config.ts.timestamp-*.mjs`;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/tsconfigJson.ts
|
|
303
|
+
function getDefaultTsconfigJson() {
|
|
304
|
+
return {
|
|
305
|
+
compilerOptions: {
|
|
306
|
+
target: "ES2020",
|
|
307
|
+
jsx: "preserve",
|
|
308
|
+
lib: [
|
|
309
|
+
"ES2020",
|
|
310
|
+
"DOM",
|
|
311
|
+
"DOM.Iterable"
|
|
312
|
+
],
|
|
313
|
+
useDefineForClassFields: true,
|
|
314
|
+
baseUrl: ".",
|
|
315
|
+
module: "ESNext",
|
|
316
|
+
moduleResolution: "bundler",
|
|
317
|
+
paths: {
|
|
318
|
+
"@/*": [
|
|
319
|
+
"./*"
|
|
320
|
+
]
|
|
321
|
+
},
|
|
322
|
+
resolveJsonModule: true,
|
|
323
|
+
types: [
|
|
324
|
+
"miniprogram-api-typings"
|
|
325
|
+
],
|
|
326
|
+
allowImportingTsExtensions: true,
|
|
327
|
+
allowJs: true,
|
|
328
|
+
strict: true,
|
|
329
|
+
noFallthroughCasesInSwitch: true,
|
|
330
|
+
noUnusedLocals: true,
|
|
331
|
+
noUnusedParameters: true,
|
|
332
|
+
noEmit: true,
|
|
333
|
+
isolatedModules: true,
|
|
334
|
+
skipLibCheck: true
|
|
335
|
+
},
|
|
336
|
+
references: [
|
|
337
|
+
{
|
|
338
|
+
path: "./tsconfig.node.json"
|
|
339
|
+
}
|
|
340
|
+
],
|
|
341
|
+
include: [
|
|
342
|
+
"**/*.ts",
|
|
343
|
+
"**/*.js"
|
|
344
|
+
],
|
|
345
|
+
exclude: [
|
|
346
|
+
"node_modules",
|
|
347
|
+
"dist"
|
|
348
|
+
]
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function getDefaultTsconfigNodeJson(include) {
|
|
352
|
+
return {
|
|
353
|
+
compilerOptions: {
|
|
354
|
+
composite: true,
|
|
355
|
+
module: "ESNext",
|
|
356
|
+
moduleResolution: "bundler",
|
|
357
|
+
strict: true,
|
|
358
|
+
allowSyntheticDefaultImports: true,
|
|
359
|
+
skipLibCheck: true
|
|
360
|
+
},
|
|
361
|
+
include
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
44
365
|
// src/index.ts
|
|
366
|
+
var __dirname2 = path.dirname(fileURLToPath(import.meta.url));
|
|
45
367
|
var ctx = createContext();
|
|
46
368
|
async function createOrUpdateProjectConfig(options) {
|
|
47
369
|
const { root, dest, cb, write, filename } = defu(
|
|
@@ -216,52 +538,7 @@ async function initTsJsonFiles(options) {
|
|
|
216
538
|
const tsNodeJsonFilename = ctx.tsconfigNode.name = "tsconfig.node.json";
|
|
217
539
|
const tsNodeJsonFilePath = ctx.tsconfigNode.path = path.resolve(root, tsNodeJsonFilename);
|
|
218
540
|
if (write) {
|
|
219
|
-
const tsJsonValue =
|
|
220
|
-
compilerOptions: {
|
|
221
|
-
target: "ES2020",
|
|
222
|
-
jsx: "preserve",
|
|
223
|
-
lib: [
|
|
224
|
-
"ES2020",
|
|
225
|
-
"DOM",
|
|
226
|
-
"DOM.Iterable"
|
|
227
|
-
],
|
|
228
|
-
useDefineForClassFields: true,
|
|
229
|
-
baseUrl: ".",
|
|
230
|
-
module: "ESNext",
|
|
231
|
-
moduleResolution: "bundler",
|
|
232
|
-
paths: {
|
|
233
|
-
"@/*": [
|
|
234
|
-
"./*"
|
|
235
|
-
]
|
|
236
|
-
},
|
|
237
|
-
resolveJsonModule: true,
|
|
238
|
-
types: [
|
|
239
|
-
"miniprogram-api-typings"
|
|
240
|
-
],
|
|
241
|
-
allowImportingTsExtensions: true,
|
|
242
|
-
allowJs: true,
|
|
243
|
-
strict: true,
|
|
244
|
-
noFallthroughCasesInSwitch: true,
|
|
245
|
-
noUnusedLocals: true,
|
|
246
|
-
noUnusedParameters: true,
|
|
247
|
-
noEmit: true,
|
|
248
|
-
isolatedModules: true,
|
|
249
|
-
skipLibCheck: true
|
|
250
|
-
},
|
|
251
|
-
references: [
|
|
252
|
-
{
|
|
253
|
-
path: "./tsconfig.node.json"
|
|
254
|
-
}
|
|
255
|
-
],
|
|
256
|
-
include: [
|
|
257
|
-
"**/*.ts",
|
|
258
|
-
"**/*.js"
|
|
259
|
-
],
|
|
260
|
-
exclude: [
|
|
261
|
-
"node_modules",
|
|
262
|
-
"dist"
|
|
263
|
-
]
|
|
264
|
-
};
|
|
541
|
+
const tsJsonValue = getDefaultTsconfigJson();
|
|
265
542
|
if (write) {
|
|
266
543
|
await fs.outputJSON(
|
|
267
544
|
tsJsonFilePath,
|
|
@@ -274,19 +551,9 @@ async function initTsJsonFiles(options) {
|
|
|
274
551
|
logger.log(`\u2728 \u8BBE\u7F6E ${tsJsonFilename} \u914D\u7F6E\u6587\u4EF6\u6210\u529F!`);
|
|
275
552
|
}
|
|
276
553
|
ctx.tsconfig.value = tsJsonValue;
|
|
277
|
-
const tsJsonNodeValue =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
module: "ESNext",
|
|
281
|
-
moduleResolution: "bundler",
|
|
282
|
-
strict: true,
|
|
283
|
-
allowSyntheticDefaultImports: true,
|
|
284
|
-
skipLibCheck: true
|
|
285
|
-
},
|
|
286
|
-
include: [
|
|
287
|
-
ctx.viteConfig.name
|
|
288
|
-
]
|
|
289
|
-
};
|
|
554
|
+
const tsJsonNodeValue = getDefaultTsconfigNodeJson([
|
|
555
|
+
ctx.viteConfig.name
|
|
556
|
+
]);
|
|
290
557
|
if (write) {
|
|
291
558
|
await fs.outputJSON(tsNodeJsonFilePath, tsJsonNodeValue, {
|
|
292
559
|
encoding: "utf8",
|
|
@@ -300,40 +567,7 @@ async function initTsJsonFiles(options) {
|
|
|
300
567
|
async function updateGitIgnore(options) {
|
|
301
568
|
const { root, write = true } = options;
|
|
302
569
|
const filepath = path.resolve(root, ".gitignore");
|
|
303
|
-
const data =
|
|
304
|
-
node_modules
|
|
305
|
-
.pnp
|
|
306
|
-
.pnp.js
|
|
307
|
-
|
|
308
|
-
# testing
|
|
309
|
-
coverage
|
|
310
|
-
|
|
311
|
-
# next.js
|
|
312
|
-
.next/
|
|
313
|
-
out/
|
|
314
|
-
build
|
|
315
|
-
|
|
316
|
-
# misc
|
|
317
|
-
.DS_Store
|
|
318
|
-
*.pem
|
|
319
|
-
|
|
320
|
-
# debug
|
|
321
|
-
npm-debug.log*
|
|
322
|
-
yarn-debug.log*
|
|
323
|
-
yarn-error.log*
|
|
324
|
-
.pnpm-debug.log*
|
|
325
|
-
|
|
326
|
-
# local env files
|
|
327
|
-
.env.local
|
|
328
|
-
.env.development.local
|
|
329
|
-
.env.test.local
|
|
330
|
-
.env.production.local
|
|
331
|
-
|
|
332
|
-
# turbo
|
|
333
|
-
.turbo
|
|
334
|
-
|
|
335
|
-
dist
|
|
336
|
-
vite.config.ts.timestamp-*.mjs`;
|
|
570
|
+
const data = getDefaultGitignore();
|
|
337
571
|
if (write) {
|
|
338
572
|
await fs.outputFile(filepath, data, {
|
|
339
573
|
encoding: "utf8"
|
|
@@ -342,7 +576,7 @@ vite.config.ts.timestamp-*.mjs`;
|
|
|
342
576
|
return data;
|
|
343
577
|
}
|
|
344
578
|
async function initConfig(options) {
|
|
345
|
-
const { root =
|
|
579
|
+
const { root = process2.cwd(), command } = options;
|
|
346
580
|
await createOrUpdateProjectConfig({ root });
|
|
347
581
|
await createOrUpdatePackageJson({ root, command });
|
|
348
582
|
await updateGitIgnore({ root });
|
|
@@ -353,9 +587,19 @@ async function initConfig(options) {
|
|
|
353
587
|
}
|
|
354
588
|
return ctx;
|
|
355
589
|
}
|
|
590
|
+
async function createProject(targetDir = "", templateDirName = "default") {
|
|
591
|
+
const targetTemplateDir = path.resolve(__dirname2, "../templates", templateDirName);
|
|
592
|
+
if (await fs.exists(targetTemplateDir)) {
|
|
593
|
+
await fs.copy(targetTemplateDir, targetDir);
|
|
594
|
+
logger.log(`\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!`);
|
|
595
|
+
} else {
|
|
596
|
+
logger.warn(`\u6CA1\u6709\u627E\u5230 ${templateDirName} \u6A21\u677F!`);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
356
599
|
export {
|
|
357
600
|
createOrUpdatePackageJson,
|
|
358
601
|
createOrUpdateProjectConfig,
|
|
602
|
+
createProject,
|
|
359
603
|
initConfig,
|
|
360
604
|
initTsDtsFile,
|
|
361
605
|
initTsJsonFiles,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/init",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"description": "@weapp-core/init",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"module": "./dist/index.js",
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
28
|
"files": [
|
|
29
|
-
"dist"
|
|
29
|
+
"dist",
|
|
30
|
+
"templates"
|
|
30
31
|
],
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"fs-extra": "^11.2.0",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"release": "pnpm publish",
|
|
42
43
|
"lint": "eslint .",
|
|
43
44
|
"lint:fix": "eslint . --fix",
|
|
44
|
-
"sync": "cnpm sync @weapp-core/init"
|
|
45
|
+
"sync": "cnpm sync @weapp-core/init",
|
|
46
|
+
"prepublish": "tsx scripts/prepublish.ts"
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "weapp-vite-tailwindcss-template",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"description": "原生微信小程序 weapp-vite + tailwindcss 模板",
|
|
7
|
+
"author": "ice breaker <1324318532@qq.com>",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/weapp-vite/weapp-vite.git",
|
|
12
|
+
"directory": "apps/weapp-vite-tailwindcss-template"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/weapp-vite/weapp-vite/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "weapp-vite dev",
|
|
20
|
+
"build": "weapp-vite build",
|
|
21
|
+
"open": "weapp-vite open",
|
|
22
|
+
"g": "weapp-vite generate",
|
|
23
|
+
"postinstall": "weapp-tw patch"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@egoist/tailwindcss-icons": "^1.8.1",
|
|
27
|
+
"@iconify-json/mdi": "^1.2.1",
|
|
28
|
+
"autoprefixer": "^10.4.20",
|
|
29
|
+
"miniprogram-api-typings": "latest",
|
|
30
|
+
"postcss": "^8.4.47",
|
|
31
|
+
"sass": "^1.79.5",
|
|
32
|
+
"tailwindcss": "^3.4.13",
|
|
33
|
+
"typescript": "latest",
|
|
34
|
+
"weapp-tailwindcss": "^3.5.3",
|
|
35
|
+
"weapp-vite": "workspace:*"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "项目配置文件",
|
|
3
|
+
"miniprogramRoot": "dist/",
|
|
4
|
+
"compileType": "miniprogram",
|
|
5
|
+
"setting": {
|
|
6
|
+
"babelSetting": {
|
|
7
|
+
"ignore": [],
|
|
8
|
+
"disablePlugins": [],
|
|
9
|
+
"outputPath": ""
|
|
10
|
+
},
|
|
11
|
+
"coverView": false,
|
|
12
|
+
"postcss": false,
|
|
13
|
+
"minified": false,
|
|
14
|
+
"enhance": true,
|
|
15
|
+
"showShadowRootInWxmlPanel": false,
|
|
16
|
+
"packNpmRelationList": [
|
|
17
|
+
{
|
|
18
|
+
"packageJsonPath": "./package.json",
|
|
19
|
+
"miniprogramNpmDistDir": "./dist"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"ignoreUploadUnusedFiles": true,
|
|
23
|
+
"compileHotReLoad": false,
|
|
24
|
+
"skylineRenderEnable": true,
|
|
25
|
+
"packNpmManually": true,
|
|
26
|
+
"es6": true
|
|
27
|
+
},
|
|
28
|
+
"simulatorType": "wechat",
|
|
29
|
+
"simulatorPluginLibVersion": {},
|
|
30
|
+
"condition": {},
|
|
31
|
+
"srcMiniprogramRoot": "dist/",
|
|
32
|
+
"editorSetting": {
|
|
33
|
+
"tabIndent": "insertSpaces",
|
|
34
|
+
"tabSize": 2
|
|
35
|
+
},
|
|
36
|
+
"libVersion": "2.32.3",
|
|
37
|
+
"packOptions": {
|
|
38
|
+
"ignore": [],
|
|
39
|
+
"include": []
|
|
40
|
+
},
|
|
41
|
+
"appid": "wx6ffee4673b257014"
|
|
42
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
|
3
|
+
"projectname": "weapp-vite-tailwindcss-template",
|
|
4
|
+
"setting": {
|
|
5
|
+
"compileHotReLoad": false
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://vite.icebreaker.top/app.json",
|
|
3
|
+
"pages": [
|
|
4
|
+
"pages/index/index",
|
|
5
|
+
"pages/logs/logs"
|
|
6
|
+
],
|
|
7
|
+
"window": {},
|
|
8
|
+
"style": "v2",
|
|
9
|
+
"componentFramework": "glass-easel",
|
|
10
|
+
"sitemapLocation": "sitemap.json",
|
|
11
|
+
"lazyCodeLoading": "requiredComponents"
|
|
12
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<view class="min-h-screen {{ mode === 'light'?'bg-gray-100':'bg-gray-900' }} transition-colors duration-500">
|
|
2
|
+
<view class="flex flex-col items-center pt-20 space-y-10">
|
|
3
|
+
<view class="flex space-x-8">
|
|
4
|
+
<view class="w-24 h-24 bg-[url(https://vite.icebreaker.top/logo.png)] bg-[length:100%_100%] bg-no-repeat"></view>
|
|
5
|
+
<view class="w-32 h-24 bg-[url(https://vite.icebreaker.top/tw-logo.png)] bg-[length:100%_100%] bg-no-repeat"></view>
|
|
6
|
+
</view>
|
|
7
|
+
<view class="bg-gradient-to-r from-green-400 to-sky-400 bg-clip-text text-xl font-extrabold text-transparent underline">
|
|
8
|
+
weapp-vite & weapp-tailwindcss
|
|
9
|
+
</view>
|
|
10
|
+
<view class="{{ mode === 'light' ? 'i-mdi-moon-waxing-crescent':'i-mdi-weather-sunny text-white' }} text-8xl" bind:tap="switchMode"></view>
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|