@yannick-z/modulo 0.3.2 → 0.3.4

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/882.js DELETED
@@ -1,697 +0,0 @@
1
- import node_readline from "node:readline";
2
- import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
3
- import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
4
- export const __webpack_id__ = "882";
5
- export const __webpack_ids__ = [
6
- "882"
7
- ];
8
- export const __webpack_modules__ = {
9
- "./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
10
- __webpack_require__.r(__webpack_exports__);
11
- __webpack_require__.d(__webpack_exports__, {
12
- init_tool: ()=>init_tool
13
- });
14
- var external_node_fs_ = __webpack_require__("node:fs");
15
- var external_node_path_ = __webpack_require__("node:path");
16
- var external_picocolors_ = __webpack_require__("picocolors");
17
- var src_config = __webpack_require__("./src/config/index.ts");
18
- async function cli_confirm(message) {
19
- const rl = node_readline.createInterface({
20
- input: process.stdin,
21
- output: process.stdout
22
- });
23
- return new Promise((resolve)=>{
24
- rl.question(`${external_picocolors_["default"].yellow(message)} (Y/n) `, (answer)=>{
25
- rl.close();
26
- resolve("y" === answer.toLowerCase() || "" === answer);
27
- });
28
- });
29
- }
30
- var json = __webpack_require__("./src/tools/json.ts");
31
- const star_line = "**********************";
32
- async function modify_scripts() {
33
- const packagejson = (0, src_config.mJ)();
34
- const new_scripts = {
35
- ...packagejson.scripts || {},
36
- "build:page": "modulo build page",
37
- "build:module": "modulo build module",
38
- "build:all": "modulo build all",
39
- build: "modulo build all",
40
- "dev:page": "modulo dev page",
41
- "dev:module": "modulo dev module",
42
- "watch:page": "modulo build page --watch=true",
43
- "watch:module": "modulo build module --watch=true"
44
- };
45
- console.log(external_picocolors_["default"].magentaBright(`\n${star_line}\n修改package.json中的scripts\n新的内容修改后如下:\n${JSON.stringify(new_scripts, null, 2)}\n${star_line}`));
46
- const confirmed = await cli_confirm("\n确定修改吗?");
47
- if (!confirmed) return void console.log("取消修改");
48
- const success = (0, json.Q)((0, external_node_path_.resolve)(process.cwd(), "package.json"), (data)=>{
49
- data.scripts = new_scripts;
50
- return data;
51
- });
52
- if (success) console.log(external_picocolors_["default"].green(`\npackage.json修改成功`));
53
- else console.log(external_picocolors_["default"].red(`\npackage.json修改失败`));
54
- }
55
- var presets = __webpack_require__("./src/config/presets.ts");
56
- const vue2_example_externals = {
57
- vue: {
58
- importName: [
59
- "vue",
60
- "Vue"
61
- ],
62
- url: "https://cdn.jsdelivr.net/npm/vue@2.7.16/+esm"
63
- }
64
- };
65
- const react19_example_externals = {
66
- react: {
67
- importName: [
68
- "react",
69
- "React"
70
- ],
71
- url: "https://esm.sh/react@19.2.4"
72
- },
73
- "react-dom": "https://esm.sh/react-dom@19.2.4",
74
- "react/jsx-runtime": "https://esm.sh/react@19.2.4/jsx-runtime"
75
- };
76
- const common_example_externals = {
77
- jquery: "https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js",
78
- rxjs: "https://cdn.jsdelivr.net/npm/rxjs@7.8.2/+esm"
79
- };
80
- const example_externals_presets = {
81
- vue2: {
82
- ...vue2_example_externals,
83
- ...common_example_externals
84
- },
85
- react19: {
86
- ...react19_example_externals,
87
- ...common_example_externals
88
- }
89
- };
90
- function get_example_config(preset) {
91
- console.log(external_picocolors_["default"].magenta(`\n${star_line}\n默认配置文件中的externals内容为推荐内容\n请注意手动替换配置文件中externals的url,以保证符合项目需求\n如果不需要externals部分依赖,也可以将他们从列表中删除\n${star_line}\n`));
92
- let externals = common_example_externals;
93
- if (preset) {
94
- if ("react19" === preset) externals = example_externals_presets.react19;
95
- else if ("vue2" === preset || "vue2" === preset) externals = example_externals_presets.vue2;
96
- }
97
- return {
98
- input: presets.pw.input,
99
- output: {
100
- filenameHash: true
101
- },
102
- url: {
103
- base: "/"
104
- },
105
- alias: presets.rH,
106
- html: {
107
- root: "app",
108
- title: "Modulo Page",
109
- meta: {},
110
- tags: [
111
- {
112
- tag: "script",
113
- attrs: {
114
- src: "/packages/webhost/dist/webhost.system.js"
115
- },
116
- append: false,
117
- publicPath: false
118
- }
119
- ]
120
- },
121
- dev_server: {
122
- proxy: presets.pw.dev_server.proxy
123
- },
124
- externals
125
- };
126
- }
127
- const default_config_file_name = "modulo.config.ts";
128
- async function create_config_file(args) {
129
- const path = args.init.path || default_config_file_name;
130
- console.log(external_picocolors_["default"].blue("即将创建配置文件"), path);
131
- const filepath = (0, external_node_path_.resolve)(process.cwd(), path);
132
- if ((0, external_node_fs_.existsSync)(filepath)) if (args.init.force) console.log(external_picocolors_["default"].bgRed(external_picocolors_["default"].white("配置文件已存在,将覆盖")));
133
- else {
134
- console.log(external_picocolors_["default"].red("配置文件已存在,是否覆盖?"));
135
- const rl = node_readline.createInterface({
136
- input: process.stdin,
137
- output: process.stdout
138
- });
139
- const answer = await new Promise((resolve)=>{
140
- rl.question("\n请输入(Y/N) ", (answer)=>{
141
- rl.close();
142
- resolve(answer);
143
- });
144
- });
145
- if ("y" !== answer.toLowerCase()) return void console.log("取消创建");
146
- }
147
- const config = get_example_config(args.init.preset);
148
- const ext = (0, external_node_path_.extname)(path);
149
- let content = "";
150
- content = ".ts" === ext ? `import type { UserConfig } from "@yannick-z/modulo";
151
-
152
- const config: UserConfig = ${JSON.stringify(config, null, 2)};
153
-
154
- export default config;
155
- ` : ".js" === ext ? `/** @type {import('@yannick-z/modulo').UserConfig} */
156
- export default ${JSON.stringify(config, null, 2)};
157
- ` : JSON.stringify(config, null, 2);
158
- (0, external_node_fs_.writeFileSync)(filepath, content);
159
- console.log(external_picocolors_["default"].green("创建成功"), filepath);
160
- }
161
- async function create_project(args) {
162
- const { path, preset } = args.init;
163
- if (!path) {
164
- console.error(external_picocolors_["default"].red("请指定项目路径: modulo init project --path <project-path>"));
165
- process.exit(1);
166
- }
167
- const projectRoot = (0, external_node_path_.resolve)(process.cwd(), path);
168
- if ((0, external_node_fs_.existsSync)(projectRoot)) {
169
- if (!args.init.force) {
170
- console.error(external_picocolors_["default"].red(`目录 ${path} 已存在,请使用 --force 覆盖或选择其他路径`));
171
- process.exit(1);
172
- }
173
- } else (0, external_node_fs_.mkdirSync)(projectRoot, {
174
- recursive: true
175
- });
176
- console.log(external_picocolors_["default"].blue(`正在初始化项目到: ${projectRoot}`));
177
- const originalCwd = process.cwd();
178
- process.chdir(projectRoot);
179
- try {
180
- const packageJson = {
181
- name: path.split("/").pop() || "modulo-project",
182
- version: "0.0.0",
183
- type: "module",
184
- scripts: {
185
- lint: "biome lint .",
186
- format: "biome format --write .",
187
- check: "biome check --write ."
188
- },
189
- dependencies: {},
190
- devDependencies: {
191
- "@yannick-z/modulo": "^0.2.0",
192
- typescript: "^5.0.0",
193
- "@biomejs/biome": "2.4.4"
194
- }
195
- };
196
- if ("vue2" === preset) packageJson.dependencies = {
197
- vue: "2.7.16"
198
- };
199
- else if ("react19" === preset) packageJson.dependencies = {
200
- react: "19.2.4",
201
- "react-dom": "19.2.4"
202
- };
203
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "package.json"), JSON.stringify(packageJson, null, 2));
204
- console.log(external_picocolors_["default"].green("创建 package.json 成功"));
205
- (0, src_config.mJ)(projectRoot);
206
- const tsConfig = {
207
- compilerOptions: {
208
- target: "ESNext",
209
- module: "ESNext",
210
- moduleResolution: "bundler",
211
- strict: true,
212
- jsx: "react19" === preset ? "react-jsx" : "preserve",
213
- esModuleInterop: true,
214
- skipLibCheck: true,
215
- forceConsistentCasingInFileNames: true,
216
- baseUrl: ".",
217
- paths: {
218
- "@/*": [
219
- "src/*"
220
- ]
221
- }
222
- },
223
- include: [
224
- "src/**/*",
225
- "modulo.config.ts"
226
- ]
227
- };
228
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
229
- console.log(external_picocolors_["default"].green("创建 tsconfig.json 成功"));
230
- (0, external_node_fs_.mkdirSync)((0, external_node_path_.resolve)(projectRoot, "src/pages/index"), {
231
- recursive: true
232
- });
233
- if ("vue2" === preset) {
234
- const vueContent = `<template>
235
- <div id="app">
236
- <h1>Hello Modulo + Vue 2</h1>
237
- </div>
238
- </template>
239
-
240
- <script lang="ts">
241
- import Vue from 'vue';
242
- export default Vue.extend({
243
- name: 'App'
244
- });
245
- </script>
246
-
247
- <style scoped>
248
- h1 {
249
- color: #42b983;
250
- }
251
- </style>
252
- `;
253
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "src/pages/index/App.vue"), vueContent);
254
- const indexContent = `import Vue from 'vue';
255
- import App from './App.vue';
256
-
257
- new Vue({
258
- render: h => h(App)
259
- }).$mount('#app');
260
- `;
261
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "src/pages/index/index.ts"), indexContent);
262
- const shimContent = `declare module '*.vue' {
263
- import Vue from 'vue';
264
- export default Vue;
265
- }
266
- `;
267
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "src/shim-vue.d.ts"), shimContent);
268
- } else if ("react19" === preset) {
269
- const appContent = `import { useState } from 'react';
270
-
271
- export function App() {
272
- const [count, setCount] = useState(0);
273
- return (
274
- <div>
275
- <h1>Hello Modulo + React 19</h1>
276
- <button onClick={() => setCount(count + 1)}>Count: {count}</button>
277
- </div>
278
- );
279
- }
280
- `;
281
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "src/pages/index/App.tsx"), appContent);
282
- const indexContent = `import { createRoot } from 'react-dom/client';
283
- import { App } from './App';
284
-
285
- const root = createRoot(document.getElementById('app')!);
286
- root.render(<App />);
287
- `;
288
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "src/pages/index/index.tsx"), indexContent);
289
- }
290
- const configArgs = {
291
- ...args,
292
- init: {
293
- ...args.init,
294
- path: ""
295
- }
296
- };
297
- await create_config_file(configArgs);
298
- modify_scripts();
299
- const biomeConfig = {
300
- $schema: "https://biomejs.dev/schemas/1.9.4/schema.json",
301
- vcs: {
302
- enabled: false,
303
- clientKind: "git",
304
- useIgnoreFile: false
305
- },
306
- files: {
307
- ignoreUnknown: false,
308
- ignore: []
309
- },
310
- formatter: {
311
- enabled: true,
312
- indentStyle: "tab"
313
- },
314
- organizeImports: {
315
- enabled: true
316
- },
317
- linter: {
318
- enabled: true,
319
- rules: {
320
- recommended: true
321
- }
322
- },
323
- javascript: {
324
- formatter: {
325
- quoteStyle: "double"
326
- }
327
- }
328
- };
329
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, "biome.json"), JSON.stringify(biomeConfig, null, 2));
330
- console.log(external_picocolors_["default"].green("创建 biome.json 成功"));
331
- const vscodeExtensions = {
332
- recommendations: [
333
- "biomejs.biome"
334
- ]
335
- };
336
- (0, external_node_fs_.mkdirSync)((0, external_node_path_.resolve)(projectRoot, ".vscode"), {
337
- recursive: true
338
- });
339
- (0, external_node_fs_.writeFileSync)((0, external_node_path_.resolve)(projectRoot, ".vscode/extensions.json"), JSON.stringify(vscodeExtensions, null, 2));
340
- console.log(external_picocolors_["default"].green("创建 .vscode/extensions.json 成功"));
341
- console.log(external_picocolors_["default"].green("\n项目初始化完成!\n"));
342
- console.log(external_picocolors_["default"].cyan(` cd ${path}`));
343
- console.log(external_picocolors_["default"].cyan(" npm install"));
344
- console.log(external_picocolors_["default"].cyan(" npm run dev page\n"));
345
- } catch (error) {
346
- console.error(external_picocolors_["default"].red("项目初始化失败:"), error);
347
- } finally{
348
- process.chdir(originalCwd);
349
- }
350
- }
351
- function init_tool(args) {
352
- if ("config" === args.target) create_config_file(args);
353
- if ("script" === args.target) modify_scripts();
354
- if ("project" === args.target) create_project(args);
355
- }
356
- },
357
- "./src/config/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
358
- __webpack_require__.d(__webpack_exports__, {
359
- eP: ()=>get_global_config,
360
- mJ: ()=>get_packagejson
361
- });
362
- var external_node_path_ = __webpack_require__("node:path");
363
- var external_node_process_ = __webpack_require__("node:process");
364
- var external_node_fs_ = __webpack_require__("node:fs");
365
- var external_node_url_ = __webpack_require__("node:url");
366
- var log = __webpack_require__("./src/tools/log.ts");
367
- var file = __webpack_require__("./src/tools/file.ts");
368
- var json = __webpack_require__("./src/tools/json.ts");
369
- var panic = __webpack_require__("./src/tools/panic.ts");
370
- function merge_user_config(target, input) {
371
- for(const key in input){
372
- const from = input[key];
373
- const to = target[key];
374
- if (typeof from === typeof to && key in target) if (Array.isArray(to)) {
375
- (0, panic.a)(!Array.isArray(from));
376
- target[key] = [
377
- ...to,
378
- ...from
379
- ];
380
- } else if ("object" == typeof to) merge_user_config(to, from);
381
- else target[key] = from;
382
- else {
383
- target[key] = from;
384
- continue;
385
- }
386
- }
387
- }
388
- var presets = __webpack_require__("./src/config/presets.ts");
389
- const root = (0, external_node_process_.cwd)();
390
- let packagejson = null;
391
- function get_packagejson(customRoot = root) {
392
- if (packagejson) {
393
- if (customRoot !== root) {
394
- const newPackageJson = (0, json.a)((0, file.Cr)(customRoot, "package.json"));
395
- (0, panic.a)(!newPackageJson, "根目录下没有package.json");
396
- (0, panic.a)(!newPackageJson.name, "package.json缺少name字段");
397
- return newPackageJson;
398
- }
399
- } else {
400
- packagejson = (0, json.a)((0, file.Cr)(customRoot, "package.json"));
401
- (0, panic.a)(!packagejson, "根目录下没有package.json");
402
- (0, panic.a)(!packagejson.name, "package.json缺少name字段");
403
- }
404
- return packagejson;
405
- }
406
- let global_config;
407
- async function get_global_config(args) {
408
- if (!global_config) {
409
- let configPath = args.pack.config;
410
- if (!configPath) {
411
- const candidates = [
412
- "modulo.config.ts",
413
- "modulo.config.js",
414
- "modulo.config.json"
415
- ];
416
- for (const f of candidates){
417
- const p = (0, external_node_path_.resolve)(root, f);
418
- if ((0, external_node_fs_.existsSync)(p)) {
419
- configPath = p;
420
- break;
421
- }
422
- }
423
- }
424
- if (!configPath) throw new Error("根目录下没有配置文件 (modulo.config.ts/js/json)");
425
- const resolvedConfigPath = (0, external_node_path_.resolve)(root, configPath);
426
- let user_config;
427
- try {
428
- const fileUrl = (0, external_node_url_.pathToFileURL)(resolvedConfigPath).href;
429
- const mod = await import(fileUrl);
430
- user_config = mod.default || mod;
431
- } catch (e) {
432
- console.error(`无法加载配置文件: ${resolvedConfigPath}`);
433
- throw e;
434
- }
435
- (0, panic.a)(!user_config, "根目录下没有配置文件");
436
- (0, log.n)("input user config", user_config);
437
- if (user_config.extends) {
438
- const extend_config_path = (0, external_node_path_.resolve)(root, user_config.extends);
439
- try {
440
- const extend_fileUrl = (0, external_node_url_.pathToFileURL)(extend_config_path).href;
441
- const extend_mod = await import(extend_fileUrl);
442
- const extend_config = extend_mod.default || extend_mod;
443
- (0, log.n)("extend config", extend_config);
444
- merge_user_config(presets.pw, extend_config);
445
- } catch (e) {
446
- console.error(`无法加载继承的配置文件: ${extend_config_path}`);
447
- throw e;
448
- }
449
- }
450
- merge_user_config(presets.pw, user_config);
451
- const _config = presets.pw;
452
- const src = (0, external_node_path_.resolve)(root, _config.input.src);
453
- const input = {
454
- modules: (0, external_node_path_.resolve)(src, _config.input.modules),
455
- pages: (0, external_node_path_.resolve)(src, _config.input.pages),
456
- src: src
457
- };
458
- const dist = (0, external_node_path_.resolve)(root, _config.output.dist);
459
- const output = {
460
- ..._config.output,
461
- dist: dist,
462
- modules: (0, external_node_path_.resolve)(dist, _config.output.modules),
463
- pages: (0, external_node_path_.resolve)(dist, _config.output.pages)
464
- };
465
- const html = _config.html?.template ? {
466
- ..._config.html,
467
- template: (0, external_node_path_.resolve)(root, _config.html.template)
468
- } : _config.html;
469
- const define = Object.fromEntries(Object.entries({
470
- ..._config.define,
471
- "import.meta.env.MOUNT_ID": _config.html.root
472
- }).map(([k, v])=>[
473
- k,
474
- JSON.stringify(v)
475
- ]));
476
- (0, log.n)("当前模式", process.env.NODE_ENV);
477
- const minify = true === _config.minify ? presets.Cw : _config.minify;
478
- const alias = Object.fromEntries(Object.entries(_config.alias).map(([k, v])=>[
479
- k,
480
- v.replace("{input.src}", input.src)
481
- ]));
482
- global_config = {
483
- ..._config,
484
- define,
485
- html,
486
- input,
487
- minify,
488
- output,
489
- alias
490
- };
491
- (0, log.n)("global config", global_config);
492
- }
493
- return global_config;
494
- }
495
- },
496
- "./src/config/presets.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
497
- __webpack_require__.d(__webpack_exports__, {
498
- Cw: ()=>preset_minify_config,
499
- pw: ()=>preset_config,
500
- rH: ()=>preset_alias
501
- });
502
- const preset_alias = {
503
- "@": "{input.src}"
504
- };
505
- const preset_dev_server_config = {
506
- open: false,
507
- port: 8080,
508
- proxy: {}
509
- };
510
- const preset_input_dirs = {
511
- src: "src",
512
- pages: "pages",
513
- modules: "modules"
514
- };
515
- const preset_output_dirs = {
516
- dist: "dist",
517
- pages: "",
518
- modules: "modules",
519
- filenameHash: true
520
- };
521
- const default_html_config = {
522
- meta: {},
523
- root: "",
524
- tags: [],
525
- template: "",
526
- title: ""
527
- };
528
- const preset_ui_libs = {
529
- react19: "19.2.4",
530
- vue2: "2.7.16"
531
- };
532
- const preset_minify_config = {
533
- js: true,
534
- jsOptions: {
535
- minimizerOptions: {
536
- compress: {
537
- dead_code: true,
538
- defaults: false,
539
- toplevel: true,
540
- unused: true
541
- },
542
- format: {
543
- comments: "some",
544
- ecma: 2015,
545
- preserve_annotations: true,
546
- safari10: true,
547
- semicolons: false
548
- },
549
- mangle: true,
550
- minify: true
551
- }
552
- }
553
- };
554
- const preset_url_config = {
555
- base: "/",
556
- cdn: ""
557
- };
558
- const preset_config = {
559
- analyze: false,
560
- define: {},
561
- dev_server: preset_dev_server_config,
562
- externals: {},
563
- html: default_html_config,
564
- input: preset_input_dirs,
565
- minify: preset_minify_config,
566
- output: preset_output_dirs,
567
- ui_lib: preset_ui_libs,
568
- url: preset_url_config,
569
- alias: preset_alias,
570
- webhost: true,
571
- autoExternal: true,
572
- externalsType: "importmap"
573
- };
574
- },
575
- "./src/tools/file.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
576
- __webpack_require__.d(__webpack_exports__, {
577
- Cr: ()=>resolve_and_read,
578
- Ke: ()=>find_entry_file,
579
- t2: ()=>exists,
580
- xh: ()=>get_directories
581
- });
582
- var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
583
- var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
584
- var picocolors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("picocolors");
585
- var _log_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/tools/log.ts");
586
- function read_file(path, error_msg, throwError = false) {
587
- try {
588
- return (0, node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync)(path, "utf8");
589
- } catch (error) {
590
- const msg = error_msg || `文件无法访问或者不存在: ${path}`;
591
- (0, _log_ts__WEBPACK_IMPORTED_MODULE_3__.n)("read_file error", msg, error);
592
- if (throwError) throw new Error(msg);
593
- console.log(picocolors__WEBPACK_IMPORTED_MODULE_2__["default"].red(msg));
594
- return "";
595
- }
596
- }
597
- function resolve_and_read(root, name) {
598
- const fullpath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.resolve)(root, name);
599
- (0, _log_ts__WEBPACK_IMPORTED_MODULE_3__.n)(`resolve file: ${name}`, "result is:", fullpath);
600
- return read_file(fullpath);
601
- }
602
- function get_directories(path) {
603
- try {
604
- if (!(0, node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(path)) return [];
605
- return (0, node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync)(path).filter((file)=>{
606
- const fullPath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(path, file);
607
- return (0, node_fs__WEBPACK_IMPORTED_MODULE_0__.statSync)(fullPath).isDirectory();
608
- });
609
- } catch (error) {
610
- (0, _log_ts__WEBPACK_IMPORTED_MODULE_3__.n)("get_directories error", path, error);
611
- return [];
612
- }
613
- }
614
- function find_entry_file(dir, candidates, extensions = [
615
- ".ts",
616
- ".tsx",
617
- ".js",
618
- ".jsx",
619
- ".vue"
620
- ]) {
621
- for (const name of candidates)for (const ext of extensions){
622
- const filename = `${name}${ext}`;
623
- const filepath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(dir, filename);
624
- if ((0, node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(filepath) && (0, node_fs__WEBPACK_IMPORTED_MODULE_0__.statSync)(filepath).isFile()) return filepath;
625
- }
626
- }
627
- function exists(path) {
628
- const isExist = (0, node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(path);
629
- (0, _log_ts__WEBPACK_IMPORTED_MODULE_3__.n)(`check exists: ${path}`, isExist);
630
- return isExist;
631
- }
632
- },
633
- "./src/tools/json.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
634
- __webpack_require__.d(__webpack_exports__, {
635
- Q: ()=>update_json_file,
636
- a: ()=>jsonparse
637
- });
638
- var picocolors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("picocolors");
639
- var node_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:fs");
640
- function jsonparse(input, defaultValue) {
641
- try {
642
- if (input) return JSON.parse(input);
643
- return defaultValue;
644
- } catch (e) {
645
- console.error(picocolors__WEBPACK_IMPORTED_MODULE_0__["default"].red(`JSON.parse failed\n${e}`));
646
- return defaultValue;
647
- }
648
- }
649
- function update_json_file(path, updater, createIfNotExist = false) {
650
- try {
651
- let data;
652
- try {
653
- const content = (0, node_fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync)(path, "utf-8");
654
- const parsed = jsonparse(content);
655
- if (parsed) data = parsed;
656
- else if (createIfNotExist) data = {};
657
- else {
658
- console.error(picocolors__WEBPACK_IMPORTED_MODULE_0__["default"].red(`Failed to parse JSON file: ${path}`));
659
- return false;
660
- }
661
- } catch (error) {
662
- if ("ENOENT" === error.code && createIfNotExist) data = {};
663
- else {
664
- console.error(picocolors__WEBPACK_IMPORTED_MODULE_0__["default"].red(`Failed to read file: ${path}`));
665
- return false;
666
- }
667
- }
668
- const newData = updater(data);
669
- (0, node_fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync)(path, JSON.stringify(newData, null, 2) + "\n");
670
- return true;
671
- } catch (e) {
672
- console.error(picocolors__WEBPACK_IMPORTED_MODULE_0__["default"].red(`Failed to update JSON file: ${path}\n${e}`));
673
- return false;
674
- }
675
- }
676
- },
677
- "./src/tools/panic.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
678
- __webpack_require__.d(__webpack_exports__, {
679
- a: ()=>PANIC_IF
680
- });
681
- var node_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:process");
682
- var picocolors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("picocolors");
683
- const alert = "! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !";
684
- function PANIC_IF(status = false, msg = "SOMETHING'S WRONG", halt = true) {
685
- if (status) {
686
- console.log(picocolors__WEBPACK_IMPORTED_MODULE_1__["default"].bgRed(picocolors__WEBPACK_IMPORTED_MODULE_1__["default"].white(`\n${alert}\n\n${msg}\n\n${alert}`)), "\n");
687
- halt && (0, node_process__WEBPACK_IMPORTED_MODULE_0__.exit)(1);
688
- }
689
- }
690
- },
691
- "node:process": function(module) {
692
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__;
693
- },
694
- "node:url": function(module) {
695
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__;
696
- }
697
- };