@ikaros-cli/ikaros 1.0.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.
- package/dist/cli.js +371 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/node/cli.ts
|
|
10
|
+
import { cac } from "cac";
|
|
11
|
+
|
|
12
|
+
// package.json
|
|
13
|
+
var name = "@ikaros-cli/ikaros-cli";
|
|
14
|
+
var version = "1.0.0";
|
|
15
|
+
|
|
16
|
+
// src/node/utils/tools.ts
|
|
17
|
+
import chalk from "chalk";
|
|
18
|
+
var cliPackageJson = { version, name };
|
|
19
|
+
var rootDir = process.cwd();
|
|
20
|
+
|
|
21
|
+
// src/node/utils/build-rollup-config.ts
|
|
22
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
23
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
24
|
+
import json from "@rollup/plugin-json";
|
|
25
|
+
import esbuild from "rollup-plugin-esbuild";
|
|
26
|
+
import obfuscator from "rollup-plugin-obfuscator";
|
|
27
|
+
|
|
28
|
+
// src/node/utils/build-vite-config.ts
|
|
29
|
+
import { join } from "node:path";
|
|
30
|
+
|
|
31
|
+
// src/node/plugins/vite-plugin/external-builtins.ts
|
|
32
|
+
import { builtinModules } from "node:module";
|
|
33
|
+
var externalBuiltins = () => {
|
|
34
|
+
return {
|
|
35
|
+
name: "@ikaros-cli/external-builtins",
|
|
36
|
+
config(config) {
|
|
37
|
+
const nativeModules = builtinModules.filter((e) => !e.startsWith("_"));
|
|
38
|
+
const builtins = [
|
|
39
|
+
"electron",
|
|
40
|
+
...nativeModules,
|
|
41
|
+
...nativeModules.map((m) => `node:${m}`)
|
|
42
|
+
];
|
|
43
|
+
config.build ??= {};
|
|
44
|
+
config.build.rollupOptions ??= {};
|
|
45
|
+
let external = config.build.rollupOptions.external;
|
|
46
|
+
if (Array.isArray(external) || typeof external === "string" || external instanceof RegExp) {
|
|
47
|
+
external = builtins.concat(external);
|
|
48
|
+
} else if (typeof external === "function") {
|
|
49
|
+
const original = external;
|
|
50
|
+
external = function(source, importer, isResolved) {
|
|
51
|
+
if (builtins.includes(source)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return original(source, importer, isResolved);
|
|
55
|
+
};
|
|
56
|
+
} else {
|
|
57
|
+
external = builtins;
|
|
58
|
+
}
|
|
59
|
+
config.build.rollupOptions.external = external;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/node/utils/build-vite-config.ts
|
|
65
|
+
var getUserConfig = (config) => {
|
|
66
|
+
const {
|
|
67
|
+
renderer,
|
|
68
|
+
entryDir,
|
|
69
|
+
outputDir,
|
|
70
|
+
target,
|
|
71
|
+
mode
|
|
72
|
+
} = config;
|
|
73
|
+
const { viteOption } = renderer ?? {};
|
|
74
|
+
const root = join(rootDir, entryDir);
|
|
75
|
+
const outDir = join(rootDir, outputDir);
|
|
76
|
+
const defineConfig = {
|
|
77
|
+
base: "./",
|
|
78
|
+
root,
|
|
79
|
+
build: {
|
|
80
|
+
reportCompressedSize: false,
|
|
81
|
+
outDir
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const viteConfig = Object.assign({}, viteOption, defineConfig);
|
|
85
|
+
return {
|
|
86
|
+
mode,
|
|
87
|
+
target,
|
|
88
|
+
entryDir,
|
|
89
|
+
outputDir,
|
|
90
|
+
viteOption: viteConfig
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
var buildViteConfig = (userConfig) => {
|
|
94
|
+
const { viteOption, mode, target } = getUserConfig(userConfig);
|
|
95
|
+
const plugins = viteOption.plugins || [];
|
|
96
|
+
if (mode !== "web") {
|
|
97
|
+
plugins.push(externalBuiltins());
|
|
98
|
+
}
|
|
99
|
+
if (target === "mobile" && mode === "web") {
|
|
100
|
+
}
|
|
101
|
+
viteOption.plugins = plugins;
|
|
102
|
+
return viteOption;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/node/utils/load-config.ts
|
|
106
|
+
import { dirname, extname, isAbsolute, join as join2, resolve } from "node:path";
|
|
107
|
+
import { pathToFileURL } from "node:url";
|
|
108
|
+
import { createRequire } from "node:module";
|
|
109
|
+
import { parse } from "yaml";
|
|
110
|
+
import fs from "fs";
|
|
111
|
+
import fsp from "node:fs/promises";
|
|
112
|
+
import fse from "fs-extra";
|
|
113
|
+
import { build } from "esbuild";
|
|
114
|
+
async function transformConfig(input, isESM = false) {
|
|
115
|
+
const result = await build({
|
|
116
|
+
absWorkingDir: process.cwd(),
|
|
117
|
+
entryPoints: [input],
|
|
118
|
+
outfile: "out.js",
|
|
119
|
+
write: false,
|
|
120
|
+
platform: "node",
|
|
121
|
+
bundle: true,
|
|
122
|
+
format: isESM ? "esm" : "cjs",
|
|
123
|
+
sourcemap: "inline",
|
|
124
|
+
metafile: true,
|
|
125
|
+
plugins: [
|
|
126
|
+
// 对裸模块,进行 external 处理,即不打包到 bundle
|
|
127
|
+
{
|
|
128
|
+
name: "externalize-deps",
|
|
129
|
+
setup(build2) {
|
|
130
|
+
build2.onResolve({ filter: /.*/ }, (args) => {
|
|
131
|
+
const id = args.path;
|
|
132
|
+
if (!id.startsWith(".") && !isAbsolute(id)) {
|
|
133
|
+
return {
|
|
134
|
+
external: true
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// 省略其他插件
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
const { text } = result.outputFiles[0];
|
|
144
|
+
return {
|
|
145
|
+
code: text,
|
|
146
|
+
dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
var _require = createRequire(pathToFileURL(resolve()));
|
|
150
|
+
async function requireConfig(fileName, code, isESM = false) {
|
|
151
|
+
if (isESM) {
|
|
152
|
+
const fileBase = `${fileName}.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
153
|
+
const fileNameTmp = `${fileBase}.mjs`;
|
|
154
|
+
const fileUrl = `${pathToFileURL(fileBase)}.mjs`;
|
|
155
|
+
await fsp.writeFile(fileNameTmp, code);
|
|
156
|
+
try {
|
|
157
|
+
return (await import(fileUrl)).default;
|
|
158
|
+
} finally {
|
|
159
|
+
fs.unlink(fileNameTmp, () => {
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const extension = extname(fileName);
|
|
164
|
+
const realFileName = fs.realpathSync(fileName);
|
|
165
|
+
const loaderExt = extension in _require.extensions ? extension : ".js";
|
|
166
|
+
const defaultLoader = _require.extensions[loaderExt];
|
|
167
|
+
_require.extensions[loaderExt] = (module, filename) => {
|
|
168
|
+
if (filename === realFileName) {
|
|
169
|
+
;
|
|
170
|
+
module._compile(code, filename);
|
|
171
|
+
} else {
|
|
172
|
+
defaultLoader(module, filename);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
delete __require.cache[__require.resolve(fileName)];
|
|
176
|
+
const raw = _require(fileName);
|
|
177
|
+
_require.extensions[loaderExt] = defaultLoader;
|
|
178
|
+
return raw.__esModule ? raw.default : raw;
|
|
179
|
+
}
|
|
180
|
+
async function resultConfig(filePath, isESM = false) {
|
|
181
|
+
const { code } = await transformConfig(filePath, isESM);
|
|
182
|
+
return requireConfig(filePath, code, isESM);
|
|
183
|
+
}
|
|
184
|
+
var fileType = /* @__PURE__ */ new Map();
|
|
185
|
+
fileType.set(".mjs", async (filePath) => {
|
|
186
|
+
const fileUrl = pathToFileURL(filePath);
|
|
187
|
+
return (await import(fileUrl.href)).default;
|
|
188
|
+
});
|
|
189
|
+
fileType.set(".ts", async (filePath) => {
|
|
190
|
+
return await resultConfig(filePath, true);
|
|
191
|
+
});
|
|
192
|
+
fileType.set(".json", async (filePath) => {
|
|
193
|
+
return await fse.readJson(filePath);
|
|
194
|
+
});
|
|
195
|
+
fileType.set(".yaml", async (filePath) => {
|
|
196
|
+
const text = await fsp.readFile(filePath, "utf8");
|
|
197
|
+
return parse(text);
|
|
198
|
+
});
|
|
199
|
+
async function resolveConfig({
|
|
200
|
+
configFile
|
|
201
|
+
}) {
|
|
202
|
+
let suffix;
|
|
203
|
+
let configPath = process.cwd();
|
|
204
|
+
let configName = "ikaros-cli.config";
|
|
205
|
+
const configList = ["ts", "mjs", "json", "yaml"].map(
|
|
206
|
+
(suffix2) => `${join2(configPath, configName)}.${suffix2}`
|
|
207
|
+
);
|
|
208
|
+
const index = (await Promise.all(configList.map((element) => {
|
|
209
|
+
return fse.pathExists(element);
|
|
210
|
+
}))).findIndex(Boolean);
|
|
211
|
+
if (index < 0)
|
|
212
|
+
return void 0;
|
|
213
|
+
suffix = extname(configList[index]);
|
|
214
|
+
configPath = resolve(configPath, `${configName}${suffix}`);
|
|
215
|
+
if (configFile) {
|
|
216
|
+
configPath = dirname(configFile);
|
|
217
|
+
suffix = extname(configFile);
|
|
218
|
+
}
|
|
219
|
+
if (!fileType.has(suffix))
|
|
220
|
+
throw new Error("No configuration file ! ");
|
|
221
|
+
return fileType.get(suffix)(configPath);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/node/utils/get-config.ts
|
|
225
|
+
var getConfig = async (configFile) => {
|
|
226
|
+
const config = {
|
|
227
|
+
mode: "web",
|
|
228
|
+
target: "web",
|
|
229
|
+
entryDir: "src",
|
|
230
|
+
outputDir: "dist",
|
|
231
|
+
main: {},
|
|
232
|
+
renderer: {}
|
|
233
|
+
};
|
|
234
|
+
let fileConfig = void 0;
|
|
235
|
+
fileConfig = await resolveConfig({ configFile });
|
|
236
|
+
if (fileConfig) {
|
|
237
|
+
return fileConfig;
|
|
238
|
+
}
|
|
239
|
+
return config;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/node/utils/logger.ts
|
|
243
|
+
import readline from "node:readline";
|
|
244
|
+
import colors from "picocolors";
|
|
245
|
+
var LogLevels = {
|
|
246
|
+
silent: 0,
|
|
247
|
+
error: 1,
|
|
248
|
+
warn: 2,
|
|
249
|
+
info: 3
|
|
250
|
+
};
|
|
251
|
+
var lastType;
|
|
252
|
+
var lastMsg;
|
|
253
|
+
var sameCount = 0;
|
|
254
|
+
function clearScreen() {
|
|
255
|
+
const repeatCount = process.stdout.rows - 2;
|
|
256
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
|
257
|
+
console.log(blank);
|
|
258
|
+
readline.cursorTo(process.stdout, 0, 0);
|
|
259
|
+
readline.clearScreenDown(process.stdout);
|
|
260
|
+
}
|
|
261
|
+
function createLogger(level = "info", options = {}) {
|
|
262
|
+
if (options.customLogger) {
|
|
263
|
+
return options.customLogger;
|
|
264
|
+
}
|
|
265
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
|
266
|
+
const {
|
|
267
|
+
prefix = "[ikaros-cli]",
|
|
268
|
+
allowClearScreen = true,
|
|
269
|
+
timestamp = true,
|
|
270
|
+
error
|
|
271
|
+
} = options;
|
|
272
|
+
const thresh = LogLevels[level];
|
|
273
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
|
274
|
+
const clear = canClearScreen ? clearScreen : () => {
|
|
275
|
+
};
|
|
276
|
+
function output(type, msg, options2 = {}) {
|
|
277
|
+
if (thresh >= LogLevels[type]) {
|
|
278
|
+
const method = type === "info" ? "log" : type;
|
|
279
|
+
const format = () => {
|
|
280
|
+
if (timestamp) {
|
|
281
|
+
const tag = type === "info" ? colors.cyan(colors.bold(prefix)) : type === "warn" ? colors.yellow(colors.bold(prefix)) : colors.red(colors.bold(prefix));
|
|
282
|
+
return `${colors.dim((/* @__PURE__ */ new Date()).toLocaleTimeString())} ${tag} ${msg}`;
|
|
283
|
+
} else {
|
|
284
|
+
return msg;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
if (error) {
|
|
288
|
+
loggedErrors.add(error);
|
|
289
|
+
}
|
|
290
|
+
if (canClearScreen) {
|
|
291
|
+
if (type === lastType && msg === lastMsg) {
|
|
292
|
+
sameCount++;
|
|
293
|
+
clear();
|
|
294
|
+
console[method](format(), colors.yellow(`(x${sameCount + 1})`));
|
|
295
|
+
} else {
|
|
296
|
+
sameCount = 0;
|
|
297
|
+
lastMsg = msg;
|
|
298
|
+
lastType = type;
|
|
299
|
+
if (options2.clear) {
|
|
300
|
+
clear();
|
|
301
|
+
}
|
|
302
|
+
console[method](format());
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
console[method](format());
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
|
310
|
+
const logger2 = {
|
|
311
|
+
hasWarned: false,
|
|
312
|
+
info(msg, opts) {
|
|
313
|
+
output("info", msg, opts);
|
|
314
|
+
},
|
|
315
|
+
warn(msg, opts) {
|
|
316
|
+
logger2.hasWarned = true;
|
|
317
|
+
output("warn", msg, opts);
|
|
318
|
+
},
|
|
319
|
+
warnOnce(msg, opts) {
|
|
320
|
+
if (warnedMessages.has(msg))
|
|
321
|
+
return;
|
|
322
|
+
logger2.hasWarned = true;
|
|
323
|
+
output("warn", msg, opts);
|
|
324
|
+
warnedMessages.add(msg);
|
|
325
|
+
},
|
|
326
|
+
error(msg, opts) {
|
|
327
|
+
logger2.hasWarned = true;
|
|
328
|
+
output("error", msg, opts);
|
|
329
|
+
},
|
|
330
|
+
clearScreen(type) {
|
|
331
|
+
if (thresh >= LogLevels[type]) {
|
|
332
|
+
clear();
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
hasErrorLogged(error2) {
|
|
336
|
+
return loggedErrors.has(error2);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
return logger2;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// src/node/runner/dev-runner.ts
|
|
343
|
+
import { createServer } from "vite";
|
|
344
|
+
var logger = createLogger("info", { prefix: "ikaros-cli:runner" });
|
|
345
|
+
var devRunner = async (fileName) => {
|
|
346
|
+
const config = await getConfig(fileName);
|
|
347
|
+
const { mode, target } = config;
|
|
348
|
+
logger.info(`mode: ${mode}, target: ${target}`);
|
|
349
|
+
const viteConfig = buildViteConfig(config);
|
|
350
|
+
if (mode === "web") {
|
|
351
|
+
const server = await createServer({ configFile: false, ...viteConfig });
|
|
352
|
+
await server.listen();
|
|
353
|
+
server.printUrls();
|
|
354
|
+
server.bindCLIShortcuts({ print: true });
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// src/node/cli.ts
|
|
360
|
+
var cli = cac("ikaros");
|
|
361
|
+
cli.option("-m , --mode <mode>", "[dev | prod | test | sit | ...] \u73AF\u5883\u6A21\u5F0F ").option("dev, server", "\u5F00\u53D1\u73AF\u5883\u542F\u52A8,\u5141\u8BB8\u8854\u63A5m[mode]\u53C2\u6570\u6765\u63A7\u5236\u5F53\u524D\u73AF\u5883").option("build", "\u6253\u5305\u6A21\u5F0F\uFF0C");
|
|
362
|
+
cli.command("[config-file]", "start dev server").alias("dev").alias("server").action(async (configFile, options) => {
|
|
363
|
+
devRunner(configFile);
|
|
364
|
+
});
|
|
365
|
+
cli.command("build [root]", "build app with mode").alias("build").action(async (options) => {
|
|
366
|
+
console.log("build mode", options);
|
|
367
|
+
});
|
|
368
|
+
cli.help();
|
|
369
|
+
cli.version(cliPackageJson.version);
|
|
370
|
+
cli.parse();
|
|
371
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/cli.ts","../package.json","../src/node/utils/tools.ts","../src/node/utils/build-rollup-config.ts","../src/node/utils/build-vite-config.ts","../src/node/plugins/vite-plugin/external-builtins.ts","../src/node/utils/load-config.ts","../src/node/utils/get-config.ts","../src/node/utils/logger.ts","../src/node/runner/dev-runner.ts"],"sourcesContent":["import { cac } from 'cac'\nimport { cliPackageJson } from './utils/tools'\nimport { devRunner } from './runner/dev-runner'\n\nconst cli = cac('ikaros')\n\ncli\n .option('-m , --mode <mode>', '[dev | prod | test | sit | ...] 环境模式 ')\n .option('dev, server', '开发环境启动,允许衔接m[mode]参数来控制当前环境')\n .option('build', '打包模式,')\n\ninterface GlobalCLIOptions {\n '--': string[]\n m: string\n mode: string\n}\n\ncli\n .command('[config-file]', 'start dev server')\n .alias('dev')\n .alias('server')\n .action(async (configFile: undefined | string, options: GlobalCLIOptions) => {\n devRunner(configFile)\n })\n\ncli\n .command('build [root]', 'build app with mode')\n .alias('build')\n .action(async (options: GlobalCLIOptions) => {\n console.log('build mode', options)\n })\n\ncli.help()\ncli.version(cliPackageJson.version)\ncli.parse()","{\n \"name\": \"@ikaros-cli/ikaros-cli\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"type\": \"module\",\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"dts\": \"tsup --dts\",\n \"build\": \"tsup\"\n },\n \"keywords\": [\n \"electron\",\n \"vue\",\n \"vite\"\n ],\n \"author\": \"sky <https://github.com/umbrella22>\",\n \"license\": \"MIT\",\n \"main\": \"dist/cli.js\",\n \"module\": \"dist/cli.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"ikaros-cli\": \"dist/cli.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"peerDependencies\": {\n \"electron\": \">=29.0.0\"\n },\n \"engines\": {\n \"node\": \">=18.0.0\",\n \"npm\": \">=9.5.0\"\n },\n \"dependencies\": {\n \"@rollup/plugin-alias\": \"^5.1.0\",\n \"@rollup/plugin-commonjs\": \"^25.0.7\",\n \"@rollup/plugin-json\": \"^6.1.0\",\n \"@rollup/plugin-node-resolve\": \"^15.2.3\",\n \"@rollup/plugin-replace\": \"^5.0.5\",\n \"cac\": \"^6.7.14\",\n \"chalk\": \"^5.3.0\",\n \"dotenv\": \"^16.4.5\",\n \"electron-builder\": \"^23.6.0\",\n \"esbuild\": \"^0.19.12\",\n \"fs-extra\": \"^11.2.0\",\n \"glob\": \"^10.3.15\",\n \"inquirer\": \"^9.2.22\",\n \"javascript-obfuscator\": \"^4.1.0\",\n \"picocolors\": \"^1.0.1\",\n \"portfinder\": \"^1.0.32\",\n \"postcss-px-to-viewport-8-plugin\": \"^1.2.5\",\n \"rollup\": \"^4.17.2\",\n \"rollup-plugin-esbuild\": \"^6.1.1\",\n \"rollup-plugin-obfuscator\": \"^1.1.0\",\n \"vite\": \"^5.2.11\",\n \"yaml\": \"^2.4.2\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0.4\"\n }\n}","import { version, name } from '../../../package.json'\nimport chalk from \"chalk\"\n\n/**\n * cli package.json\n */\nexport const cliPackageJson = { version, name }\n\nexport const rootDir = process.cwd()\n\nexport function logStats(proc: string, data: any) {\n let log = \"\";\n\n log += chalk.yellow.bold(\n `┏ ${proc} \"Process\" ${new Array(\n 19 - proc.length + 1\n ).join(\"-\")}`\n );\n log += \"\\n\\n\";\n\n if (typeof data === \"object\") {\n data\n .toString({\n colors: true,\n chunks: false,\n })\n .split(/\\r?\\n/)\n .forEach((line: string) => {\n log += \" \" + line + \"\\n\";\n });\n } else {\n log += ` ${data}\\n`;\n }\n\n log += \"\\n\" + chalk.yellow.bold(`┗ ${new Array(28 + 1).join(\"-\")}`) + \"\\n\";\n console.log(log);\n}\n\nexport function removeJunk(chunk: string) {\n // Example: 2018-08-10 22:48:42.866 Electron[90311:4883863] *** WARNING: Textured window <AtomNSWindow: 0x7fb75f68a770>\n if (\n /\\d+-\\d+-\\d+ \\d+:\\d+:\\d+\\.\\d+ Electron(?: Helper)?\\[\\d+:\\d+] /.test(chunk)\n ) {\n return false;\n }\n\n // Example: [90789:0810/225804.894349:ERROR:CONSOLE(105)] \"Uncaught (in promise) Error: Could not instantiate: ProductRegistryImpl.Registry\", source: chrome-devtools://devtools/bundled/inspector.js (105)\n if (/\\[\\d+:\\d+\\/|\\d+\\.\\d+:ERROR:CONSOLE\\(\\d+\\)\\]/.test(chunk)) {\n return false;\n }\n\n // Example: ALSA lib confmisc.c:767:(parse_card) cannot find card '0'\n if (/ALSA lib [a-z]+\\.c:\\d+:\\([a-z_]+\\)/.test(chunk)) {\n return false;\n }\n return chunk;\n}\n\n","import { nodeResolve } from '@rollup/plugin-node-resolve'\nimport { builtinModules } from 'node:module'\nimport commonjs from '@rollup/plugin-commonjs'\nimport json from '@rollup/plugin-json'\nimport esbuild, { type Options } from 'rollup-plugin-esbuild'\nimport obfuscator from 'rollup-plugin-obfuscator'\nimport type { RollupOptions } from 'rollup'\nimport type { IkarosUserConfig } from '../user-config'\nimport { rootDir } from './tools'\nimport { join } from 'node:path'\n\ninterface RollupExOptions {\n inputFile: string\n outputFile: string\n}\n\n/**\n * Build rollup config\n */\nconst getRollupConfig = (\n config: IkarosUserConfig,\n options?: RollupExOptions,\n) => {\n const {\n main,\n entryDir,\n outputDir,\n } = config\n const {\n rollupOption,\n obfuscate,\n obfuscateOptions,\n esbuildOption,\n } = main ?? {}\n if (!options) {\n options = {\n inputFile: 'index.js',\n outputFile: 'main.js',\n }\n }\n const { inputFile, outputFile } = options\n const input = join(rootDir, entryDir, inputFile)\n const output = join(rootDir, outputDir, outputFile)\n const defineConfig: RollupOptions = {\n input,\n output: {\n file: output,\n format: 'cjs',\n exports: 'auto',\n sourcemap: false,\n },\n }\n const rollupConfig = Object.assign({}, rollupOption, defineConfig)\n\n return {\n obfuscate,\n entryDir,\n outputDir,\n rollupConfig,\n obfuscateOptions,\n esbuildOption,\n }\n}\n\nexport const buildRollupConfig = (\n userConfig: IkarosUserConfig,\n options?: RollupExOptions,\n): RollupOptions => {\n const { rollupConfig, obfuscate, obfuscateOptions, esbuildOption } =\n getRollupConfig(userConfig, options)\n const { external, plugins } = rollupConfig\n const exExternal = external || []\n const exPlugins = plugins || []\n\n const defaultEsbuildOption: Options = {\n include: /\\.[jt]s?$/,\n exclude: /node_modules/,\n target: 'esnext',\n // Add extra loaders\n loaders: {\n '.json': 'json',\n '.js': 'jsx',\n },\n }\n\n if (Array.isArray(exExternal)) {\n exExternal.push(...builtinModules)\n }\n\n if (Array.isArray(exPlugins)) {\n exPlugins.push(\n commonjs(),\n json(),\n nodeResolve(),\n esbuild(esbuildOption ?? defaultEsbuildOption),\n )\n if (obfuscate) {\n exPlugins.push(obfuscator(obfuscateOptions ?? {\n global: true,\n }))\n }\n }\n\n rollupConfig.plugins = exPlugins\n rollupConfig.external = exExternal\n\n return rollupConfig\n}\n","import { join } from 'node:path'\nimport type { UserConfig } from 'vite'\nimport type { IkarosUserConfig } from '../user-config'\nimport { rootDir } from './tools'\nimport { externalBuiltins } from '../plugins/vite-plugin/external-builtins'\nimport { } from \"../plugins/vite-plugin/fix-name-lose\"\n\nconst getUserConfig = (config: IkarosUserConfig) => {\n const {\n renderer,\n entryDir,\n outputDir,\n target,\n mode,\n } = config\n const { viteOption } = renderer ?? {}\n const root = join(rootDir, entryDir)\n const outDir = join(rootDir, outputDir)\n const defineConfig: UserConfig = {\n base: './',\n root,\n build: {\n reportCompressedSize: false,\n outDir,\n },\n }\n const viteConfig = Object.assign({}, viteOption, defineConfig)\n return {\n mode,\n target,\n entryDir,\n outputDir,\n viteOption: viteConfig,\n }\n}\n\nexport const buildViteConfig = (userConfig: IkarosUserConfig): UserConfig => {\n const { viteOption, mode, target } = getUserConfig(userConfig)\n\n const plugins = viteOption.plugins || []\n\n if (mode !== 'web') {\n plugins.push(externalBuiltins(),)\n }\n if (target === 'mobile' && mode === 'web') {\n // TODO 记得添加移动端插件\n\n }\n\n\n viteOption.plugins = plugins\n\n return viteOption\n}\n","import { builtinModules } from 'node:module'\n\nimport type { Plugin } from 'vite'\n\n/**\n * `electron` and Node.js built-in modules should always be externalize.\n */\nexport const externalBuiltins = () => {\n return <Plugin>{\n name: '@ikaros-cli/external-builtins',\n config(config) {\n const nativeModules = builtinModules.filter((e) => !e.startsWith('_'))\n const builtins = [\n 'electron',\n ...nativeModules,\n ...nativeModules.map((m) => `node:${m}`),\n ]\n\n config.build ??= {}\n config.build.rollupOptions ??= {}\n\n let external = config.build.rollupOptions.external\n if (\n Array.isArray(external) ||\n typeof external === 'string' ||\n external instanceof RegExp\n ) {\n external = builtins.concat(external as string[])\n } else if (typeof external === 'function') {\n const original = external\n external = function (source, importer, isResolved) {\n if (builtins.includes(source)) {\n return true\n }\n return original(source, importer, isResolved)\n }\n } else {\n external = builtins\n }\n config.build.rollupOptions.external = external\n },\n }\n}\n","import { dirname, extname, isAbsolute, join, resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { createRequire } from 'node:module'\nimport { parse } from 'yaml'\nimport fs from 'fs'\nimport fsp from 'node:fs/promises'\nimport fse from 'fs-extra'\nimport { build } from 'esbuild'\nimport type { IkarosUserConfig } from '../user-config.ts'\n\nasync function transformConfig(input: string, isESM = false) {\n const result = await build({\n absWorkingDir: process.cwd(),\n entryPoints: [input],\n outfile: 'out.js',\n write: false,\n platform: 'node',\n bundle: true,\n format: isESM ? 'esm' : 'cjs',\n sourcemap: 'inline',\n metafile: true,\n plugins: [\n // 对裸模块,进行 external 处理,即不打包到 bundle\n {\n name: 'externalize-deps',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const id = args.path\n // 排除相对路径和绝对路径\n if (!id.startsWith('.') && !isAbsolute(id)) {\n return {\n external: true,\n }\n }\n })\n },\n },\n // 省略其他插件\n ],\n })\n\n const { text } = result.outputFiles[0]\n return {\n code: text,\n dependencies: result.metafile ? Object.keys(result.metafile.inputs) : [],\n }\n}\n\ninterface NodeModuleWithCompile extends NodeModule {\n _compile(code: string, filename: string): any\n}\nconst _require = createRequire(pathToFileURL(resolve()))\nasync function requireConfig(fileName: string, code: string, isESM = false) {\n\n if (isESM) {\n const fileBase = `${fileName}.timestamp-${Date.now()}-${Math.random()\n .toString(16)\n .slice(2)}`\n const fileNameTmp = `${fileBase}.mjs`\n const fileUrl = `${pathToFileURL(fileBase)}.mjs`\n await fsp.writeFile(fileNameTmp, code)\n try {\n return (await import(fileUrl)).default\n } finally {\n fs.unlink(fileNameTmp, () => { }) // Ignore errors\n }\n }\n\n const extension = extname(fileName)\n const realFileName = fs.realpathSync(fileName)\n const loaderExt = extension in _require.extensions ? extension : '.js'\n\n // 保存老的 require 行为\n const defaultLoader = _require.extensions[loaderExt]!\n // 临时重写当前配置文件后缀的 require 行为\n _require.extensions[loaderExt] = (module: NodeModule, filename: string) => {\n // 只处理配置文件\n if (filename === realFileName) {\n // 直接调用 compile,传入编译好的代码\n ; (module as NodeModuleWithCompile)._compile(code, filename)\n } else {\n defaultLoader(module, filename)\n }\n }\n // 清除缓存\n // eslint-disable-next-line unicorn/prefer-module\n delete require.cache[require.resolve(fileName)]\n const raw = _require(fileName)\n // 恢复原生require行为\n _require.extensions[loaderExt] = defaultLoader\n // 如果是esm编译过的__esModule为true\n return raw.__esModule ? raw.default : raw\n}\n\nasync function resultConfig(filePath: string, isESM = false) {\n const { code } = await transformConfig(filePath, isESM)\n return requireConfig(filePath, code, isESM)\n}\n\n\ntype FileType = '.mjs' | '.ts' | '.json' | '.yaml'\n\nconst fileType = new Map<FileType, (filePath: string) => Promise<any>>()\n\n// fileType.set('.js', async (filePath) => {\n// const pkg = await fse.readJson(resolve(process.cwd(), 'package.json'))\n// const { type = 'commonjs' } = pkg\n// return new Promise((resolve) => {\n// if (type === 'module') {\n// const fileUrl = pathToFileURL(filePath)\n// import(fileUrl.href)\n// .then((config) => config?.default)\n// .then(resolve)\n// }\n\n// // commonjs\n// resultConfig(filePath).then(resolve)\n// })\n// })\n\nfileType.set('.mjs', async (filePath) => {\n const fileUrl = pathToFileURL(filePath)\n return (await import(fileUrl.href)).default\n})\n\nfileType.set('.ts', async (filePath) => {\n return await resultConfig(filePath, true)\n})\n\n\nfileType.set('.json', async (filePath) => {\n return await fse.readJson(filePath)\n})\n\nfileType.set('.yaml', async (filePath) => {\n const text = await fsp.readFile(filePath, 'utf8')\n return parse(text)\n})\n\n/**\n * @description 解析配置文件\n * @date 2024-05-22\n * @param {string} configFile 文件路径,可选,若不传入则会在项目根目录寻找配置文件\n * @returns {Promise<IkarosUserConfig | undefined>}\n */\nexport async function resolveConfig({\n configFile\n}: {\n configFile?: string\n}): Promise<IkarosUserConfig | undefined> {\n let suffix: FileType | undefined\n let configPath = process.cwd()\n let configName = 'ikaros-cli.config'\n\n const configList = ['ts', 'mjs', 'json', 'yaml'].map(\n (suffix) => `${join(configPath, configName)}.${suffix}`,\n )\n const index = (\n await Promise.all(configList.map((element) => {\n return fse.pathExists(element)\n }))\n ).findIndex(Boolean)\n if (index < 0) return undefined\n\n suffix = extname(configList[index]) as FileType\n\n configPath = resolve(configPath, `${configName}${suffix}`)\n\n if (configFile) {\n configPath = dirname(configFile)\n suffix = extname(configFile) as FileType\n }\n\n if (!fileType.has(suffix)) throw new Error('No configuration file ! ')\n return fileType.get(suffix)!(configPath)\n}\n","import type { IkarosUserConfig } from \"..\"\nimport { resolveConfig } from \"./load-config\"\n\nexport const getConfig = async (configFile?: string): Promise<IkarosUserConfig> => {\n const config: IkarosUserConfig = {\n mode: 'web',\n target: 'web',\n entryDir: 'src',\n outputDir: 'dist',\n main: {},\n renderer: {}\n }\n let fileConfig: IkarosUserConfig | undefined = undefined\n\n fileConfig = await resolveConfig({ configFile });\n if (fileConfig) {\n return fileConfig\n }\n return config;\n}","/* eslint no-console: 0 */\n\nimport readline from 'node:readline'\nimport colors from 'picocolors'\nimport type { RollupError } from 'rollup'\n\nexport type LogType = 'error' | 'warn' | 'info'\nexport type LogLevel = LogType | 'silent'\nexport interface Logger {\n info(msg: string, options?: LogOptions): void\n warn(msg: string, options?: LogOptions): void\n warnOnce(msg: string, options?: LogOptions): void\n error(msg: string, options?: LogErrorOptions): void\n clearScreen(type: LogType): void\n hasErrorLogged(error: Error | RollupError): boolean\n hasWarned: boolean\n}\n\nexport interface LogOptions {\n clear?: boolean\n timestamp?: boolean\n}\n\nexport interface LogErrorOptions extends LogOptions {\n error?: Error | RollupError | null\n}\n\nexport const LogLevels: Record<LogLevel, number> = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n}\n\nlet lastType: LogType | undefined\nlet lastMsg: string | undefined\nlet sameCount = 0\n\nfunction clearScreen() {\n const repeatCount = process.stdout.rows - 2\n const blank = repeatCount > 0 ? '\\n'.repeat(repeatCount) : ''\n console.log(blank)\n readline.cursorTo(process.stdout, 0, 0)\n readline.clearScreenDown(process.stdout)\n}\n\nexport interface LoggerOptions {\n prefix?: string\n allowClearScreen?: boolean\n customLogger?: Logger\n timestamp?: string\n error?: Error | RollupError\n}\n\nexport function createLogger(\n level: LogLevel = 'info',\n options: LoggerOptions = {},\n): Logger {\n if (options.customLogger) {\n return options.customLogger\n }\n\n const loggedErrors = new WeakSet<Error | RollupError>()\n const {\n prefix = '[ikaros-cli]',\n allowClearScreen = true,\n timestamp = true,\n error,\n } = options\n const thresh = LogLevels[level]\n const canClearScreen =\n allowClearScreen && process.stdout.isTTY && !process.env.CI\n const clear = canClearScreen ? clearScreen : () => { }\n\n function output(type: LogType, msg: string, options: LogErrorOptions = {}) {\n if (thresh >= LogLevels[type]) {\n const method = type === 'info' ? 'log' : type\n const format = () => {\n if (timestamp) {\n const tag =\n type === 'info'\n ? colors.cyan(colors.bold(prefix))\n : type === 'warn'\n ? colors.yellow(colors.bold(prefix))\n : colors.red(colors.bold(prefix))\n return `${colors.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`\n } else {\n return msg\n }\n }\n if (error) {\n loggedErrors.add(error)\n }\n if (canClearScreen) {\n if (type === lastType && msg === lastMsg) {\n sameCount++\n clear()\n console[method](format(), colors.yellow(`(x${sameCount + 1})`))\n } else {\n sameCount = 0\n lastMsg = msg\n lastType = type\n if (options.clear) {\n clear()\n }\n console[method](format())\n }\n } else {\n console[method](format())\n }\n }\n }\n\n const warnedMessages = new Set<string>()\n\n const logger: Logger = {\n hasWarned: false,\n info(msg, opts) {\n output('info', msg, opts)\n },\n warn(msg, opts) {\n logger.hasWarned = true\n output('warn', msg, opts)\n },\n warnOnce(msg, opts) {\n if (warnedMessages.has(msg)) return\n logger.hasWarned = true\n output('warn', msg, opts)\n warnedMessages.add(msg)\n },\n error(msg, opts) {\n logger.hasWarned = true\n output('error', msg, opts)\n },\n clearScreen(type) {\n if (thresh >= LogLevels[type]) {\n clear()\n }\n },\n hasErrorLogged(error) {\n return loggedErrors.has(error)\n },\n }\n\n return logger\n}\n","import { buildRollupConfig } from \"../utils/build-rollup-config\";\nimport { buildViteConfig } from \"../utils/build-vite-config\";\nimport { getConfig } from \"../utils/get-config\";\nimport { createLogger } from \"../utils/logger\";\nimport { createServer } from \"vite\"\n\n\nconst logger = createLogger('info', { prefix: 'ikaros-cli:runner' })\n\nexport const devRunner = async (fileName?: string): Promise<void> => {\n const config = await getConfig(fileName)\n const { mode, target } = config\n logger.info(`mode: ${mode}, target: ${target}`)\n const viteConfig = buildViteConfig(config)\n if (mode === 'web') {\n const server = await createServer({ configFile: false, ...viteConfig })\n await server.listen()\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n return\n }\n\n}"],"mappings":";;;;;;;;;AAAA,SAAS,WAAW;;;ACClB,WAAQ;AACR,cAAW;;;ACDb,OAAO,WAAW;AAKX,IAAM,iBAAiB,EAAE,SAAS,KAAK;AAEvC,IAAM,UAAU,QAAQ,IAAI;;;ACRnC,SAAS,mBAAmB;AAE5B,OAAO,cAAc;AACrB,OAAO,UA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IACA,YAAY,MAAM;AAChB,UAAI,UAAU,UAAU,IAAI,GAAG;AAC7B,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,eAAeC,QAAO;AACpB,aAAO,aAAa,IAAIA,MAAK;AAAA,IAC/B;AAAA,EACF;AAEA,SAAOD;AACT;;;AC7IA,SAAS,oBAAoB;AAG7B,IAAM,SAAS,aAAa,QAAQ,EAAE,QAAQ,oBAAoB,CAAC;AAE5D,IAAM,YAAY,OAAO,aAAqC;AACnE,QAAM,SAAS,MAAM,UAAU,QAAQ;AACvC,QAAM,EAAE,MAAM,OAAO,IAAI;AACzB,SAAO,KAAK,SAAS,IAAI,aAAa,MAAM,EAAE;AAC9C,QAAM,aAAa,gBAAgB,MAAM;AACzC,MAAI,SAAS,OAAO;AAClB,UAAM,SAAS,MAAM,aAAa,EAAE,YAAY,OAAO,GAAG,WAAW,CAAC;AACtE,UAAM,OAAO,OAAO;AACpB,WAAO,UAAU;AACjB,WAAO,iBAAiB,EAAE,OAAO,KAAK,CAAC;AACvC;AAAA,EACF;AAEF;;;ATlBA,IAAM,MAAM,IAAI,QAAQ;AAExB,IACG,OAAO,sBAAsB,2DAAuC,EACpE,OAAO,eAAe,4HAA6B,EACnD,OAAO,SAAS,gCAAO;AAQ1B,IACG,QAAQ,iBAAiB,kBAAkB,EAC3C,MAAM,KAAK,EACX,MAAM,QAAQ,EACd,OAAO,OAAO,YAAgC,YAA8B;AAC3E,YAAU,UAAU;AACtB,CAAC;AAEH,IACG,QAAQ,gBAAgB,qBAAqB,EAC7C,MAAM,OAAO,EACb,OAAO,OAAO,YAA8B;AAC3C,UAAQ,IAAI,cAAc,OAAO;AACnC,CAAC;AAEH,IAAI,KAAK;AACT,IAAI,QAAQ,eAAe,OAAO;AAClC,IAAI,MAAM;","names":["join","build","suffix","join","options","logger","error"]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/node/user-config.ts
|
|
2
|
+
var defineConfig = (config) => config;
|
|
3
|
+
|
|
4
|
+
// package.json
|
|
5
|
+
var version = "1.0.0";
|
|
6
|
+
|
|
7
|
+
// src/node/index.ts
|
|
8
|
+
var version2 = version;
|
|
9
|
+
export {
|
|
10
|
+
defineConfig,
|
|
11
|
+
version2 as version
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/user-config.ts","../package.json","../src/node/index.ts"],"sourcesContent":["import type { RollupOptions } from 'rollup'\nimport type { Options } from 'rollup-plugin-esbuild'\nimport type { RollupPluginObfuscatorOptions } from 'rollup-plugin-obfuscator'\nimport type { UserConfig } from 'vite'\n\ntype Preload =\n | {\n name: string\n entry: string\n }\n | string\nexport interface MainConfig {\n /** rollup配置 */\n rollupOption?: RollupOptions\n /** 是否混淆 */\n obfuscate?: boolean\n /** 是否生成字节码 */\n bytecode?: boolean\n /** 混淆配置 */\n obfuscateOptions?: RollupPluginObfuscatorOptions\n /** esbuild配置 */\n esbuildOption?: Options\n}\nexport interface RendererConfig {\n /** vite配置 */\n viteOption?: UserConfig\n}\nexport interface PreloadConfig extends MainConfig {\n /** 预加载脚本入口 */\n entry: Preload | Preload[]\n}\n\nexport interface BaseConfig {\n /** 模式:网页或者是客户端*/\n mode: 'web' | 'client'\n /** 标志:仅web模式生效 */\n target: 'web' | 'mobile'\n /** 入口目录 */\n entryDir: string\n /** 输出目录 */\n outputDir: string\n}\n\nexport interface IkarosUserConfig extends BaseConfig {\n /** 主进程配置 */\n main?: MainConfig\n /** 渲染进程配置 */\n renderer?: RendererConfig\n /** 预加载配置 */\n preload?: PreloadConfig\n}\nexport type ConfigEnv = {\n mode: BaseConfig['mode']\n target: BaseConfig['target']\n command: 'serve' | 'build'\n}\nexport type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>\n\n/** 辅助工具函数 */\nexport const defineConfig = (config: IkarosUserConfig) => config","{\n \"name\": \"@ikaros-cli/ikaros-cli\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"type\": \"module\",\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"dts\": \"tsup --dts\",\n \"build\": \"tsup\"\n },\n \"keywords\": [\n \"electron\",\n \"vue\",\n \"vite\"\n ],\n \"author\": \"sky <https://github.com/umbrella22>\",\n \"license\": \"MIT\",\n \"main\": \"dist/cli.js\",\n \"module\": \"dist/cli.js\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"ikaros-cli\": \"dist/cli.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"peerDependencies\": {\n \"electron\": \">=29.0.0\"\n },\n \"engines\": {\n \"node\": \">=18.0.0\",\n \"npm\": \">=9.5.0\"\n },\n \"dependencies\": {\n \"@rollup/plugin-alias\": \"^5.1.0\",\n \"@rollup/plugin-commonjs\": \"^25.0.7\",\n \"@rollup/plugin-json\": \"^6.1.0\",\n \"@rollup/plugin-node-resolve\": \"^15.2.3\",\n \"@rollup/plugin-replace\": \"^5.0.5\",\n \"cac\": \"^6.7.14\",\n \"chalk\": \"^5.3.0\",\n \"dotenv\": \"^16.4.5\",\n \"electron-builder\": \"^23.6.0\",\n \"esbuild\": \"^0.19.12\",\n \"fs-extra\": \"^11.2.0\",\n \"glob\": \"^10.3.15\",\n \"inquirer\": \"^9.2.22\",\n \"javascript-obfuscator\": \"^4.1.0\",\n \"picocolors\": \"^1.0.1\",\n \"portfinder\": \"^1.0.32\",\n \"postcss-px-to-viewport-8-plugin\": \"^1.2.5\",\n \"rollup\": \"^4.17.2\",\n \"rollup-plugin-esbuild\": \"^6.1.1\",\n \"rollup-plugin-obfuscator\": \"^1.1.0\",\n \"vite\": \"^5.2.11\",\n \"yaml\": \"^2.4.2\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0.4\"\n }\n}","// 所有配置类型\nexport * from './user-config'\n\n// 虽然 ./utils.ts 也有导出,但为了节省标记树摇,这里做独立导出\nimport { version as _version } from '../../package.json'\n\n// 重命名导出\n/** 版本号 */\nexport const version = _version"],"mappings":";AA2DO,IAAM,eAAe,CAAC,WAA6B;;;ACzDxD,cAAW;;;ACMN,IAAMA,WAAU;","names":["version"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ikaros-cli/ikaros",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org/",
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/umbrella22/ikaros#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/umbrella22/ikaros.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/umbrella22/ikaros/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"electron",
|
|
20
|
+
"vue",
|
|
21
|
+
"vite"
|
|
22
|
+
],
|
|
23
|
+
"author": "sky <https://github.com/umbrella22>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"main": "dist/cli.js",
|
|
26
|
+
"module": "dist/cli.js",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"bin": {
|
|
29
|
+
"ikaros": "dist/cli.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"electron": ">=29.0.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0",
|
|
39
|
+
"npm": ">=9.5.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@rollup/plugin-alias": "^5.1.0",
|
|
43
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
44
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
46
|
+
"@rollup/plugin-replace": "^5.0.5",
|
|
47
|
+
"cac": "^6.7.14",
|
|
48
|
+
"chalk": "^5.3.0",
|
|
49
|
+
"dotenv": "^16.4.5",
|
|
50
|
+
"electron-builder": "^23.6.0",
|
|
51
|
+
"esbuild": "^0.19.12",
|
|
52
|
+
"fs-extra": "^11.2.0",
|
|
53
|
+
"glob": "^10.3.15",
|
|
54
|
+
"inquirer": "^9.2.22",
|
|
55
|
+
"javascript-obfuscator": "^4.1.0",
|
|
56
|
+
"picocolors": "^1.0.1",
|
|
57
|
+
"portfinder": "^1.0.32",
|
|
58
|
+
"postcss-px-to-viewport-8-plugin": "^1.2.5",
|
|
59
|
+
"rollup": "^4.17.2",
|
|
60
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
61
|
+
"rollup-plugin-obfuscator": "^1.1.0",
|
|
62
|
+
"vite": "^5.2.11",
|
|
63
|
+
"yaml": "^2.4.2"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/fs-extra": "^11.0.4"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"dev": "tsup --watch",
|
|
70
|
+
"dts": "tsup --dts",
|
|
71
|
+
"build": "tsup"
|
|
72
|
+
}
|
|
73
|
+
}
|