muon-ui 0.6.0 → 0.8.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/README.md +1 -0
- package/dist/cli.cjs +530 -28
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/native/{linux64 → linux-amd64}/muon-bootstrap +0 -0
- package/dist/native/linux-amd64/muon-builder +0 -0
- package/dist/native/{linuxarm64 → linux-arm64}/muon-bootstrap +0 -0
- package/dist/native/{linuxarm64/muon-prepare → linux-arm64/muon-builder} +0 -0
- package/dist/native/{linuxarm → linux-armhf}/muon-bootstrap +0 -0
- package/dist/native/{linuxarm/muon-prepare → linux-armhf/muon-builder} +0 -0
- package/dist/native/muon-bootstrap.png +0 -0
- package/dist/native/{windows64 → windows-amd64}/muon-bootstrap.exe +0 -0
- package/dist/native/windows-amd64/muon-builder.exe +0 -0
- package/dist/native/{windows32 → windows-i686}/muon-bootstrap.exe +0 -0
- package/dist/native/windows-i686/muon-builder.exe +0 -0
- package/dist/runtime/{linux64 → linux-amd64}/CREDITS.md +24 -97
- package/dist/runtime/{linux64 → linux-amd64}/libmuon-ui.so +0 -0
- package/dist/runtime/linux-amd64/muon-core +0 -0
- package/dist/runtime/{linuxarm → linux-arm64}/CREDITS.md +24 -97
- package/dist/runtime/linux-arm64/libmuon-ui.so +0 -0
- package/dist/runtime/linux-arm64/muon-core +0 -0
- package/dist/runtime/{windows32 → linux-armhf}/CREDITS.md +24 -97
- package/dist/runtime/{linuxarm → linux-armhf}/libmuon-ui.so +0 -0
- package/dist/runtime/linux-armhf/muon-core +0 -0
- package/dist/runtime/{linuxarm64 → windows-amd64}/CREDITS.md +24 -97
- package/dist/runtime/{windows64 → windows-amd64}/libcardio.dll +0 -0
- package/dist/runtime/windows-amd64/libmuon-ui.dll +0 -0
- package/dist/runtime/windows-amd64/muon-core.exe +0 -0
- package/dist/runtime/windows-i686/CREDITS.md +290 -0
- package/dist/runtime/{windows32 → windows-i686}/libcardio.dll +0 -0
- package/dist/runtime/windows-i686/libmuon-ui.dll +0 -0
- package/dist/runtime/{windows64 → windows-i686}/muon-core.exe +0 -0
- package/dist/{vite-options-KNDVcH-e.cjs → vite-internals-ChWiL2TL.cjs} +1450 -236
- package/dist/vite-internals-ChWiL2TL.cjs.map +1 -0
- package/dist/vite.cjs +28 -6
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +1091 -165
- package/dist/vite.mjs.map +1 -1
- package/images/muon-120.png +0 -0
- package/muon.d.ts +162 -27
- package/package.json +14 -10
- package/vite.d.ts +172 -15
- package/dist/native/linux64/muon-prepare +0 -0
- package/dist/native/windows32/muon-prepare.exe +0 -0
- package/dist/native/windows64/muon-prepare.exe +0 -0
- package/dist/runtime/linux64/muon-core +0 -0
- package/dist/runtime/linuxarm/muon-core +0 -0
- package/dist/runtime/linuxarm64/libmuon-ui.so +0 -0
- package/dist/runtime/linuxarm64/muon-core +0 -0
- package/dist/runtime/windows32/libmuon-ui.dll +0 -0
- package/dist/runtime/windows32/muon-core.exe +0 -0
- package/dist/runtime/windows64/CREDITS.md +0 -363
- package/dist/runtime/windows64/libmuon-ui.dll +0 -0
- package/dist/vite-options-KNDVcH-e.cjs.map +0 -1
- /package/dist/runtime/{linux64 → linux-amd64}/libcardio.so +0 -0
- /package/dist/runtime/{linuxarm64 → linux-arm64}/libcardio.so +0 -0
- /package/dist/runtime/{linuxarm → linux-armhf}/libcardio.so +0 -0
- /package/dist/runtime/{windows64 → windows-amd64}/libgcc_s_seh-1.dll +0 -0
- /package/dist/runtime/{windows64 → windows-amd64}/libstdc++-6.dll +0 -0
- /package/dist/runtime/{windows32 → windows-i686}/libgcc_s_dw2-1.dll +0 -0
- /package/dist/runtime/{windows32 → windows-i686}/libstdc++-6.dll +0 -0
package/dist/cli.cjs
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*!
|
|
3
3
|
* name: muon-ui
|
|
4
|
-
* version: 0.
|
|
4
|
+
* version: 0.8.0
|
|
5
5
|
* description: A multi-platform GUI application framework that uses CEF as its backend
|
|
6
6
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
7
7
|
* license: MIT
|
|
8
8
|
* repository.url: https://github.com/kekyo/muon-ui.git
|
|
9
|
-
* git.commit.hash:
|
|
9
|
+
* git.commit.hash: 9bb6148e155dab16c4ca441073b144e21981b038
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
11
|
+
const require_vite_internals = require("./vite-internals-ChWiL2TL.cjs");
|
|
12
12
|
let commander = require("commander");
|
|
13
13
|
let node_child_process = require("node:child_process");
|
|
14
14
|
let node_fs = require("node:fs");
|
|
15
15
|
let node_fs_promises = require("node:fs/promises");
|
|
16
16
|
let node_path = require("node:path");
|
|
17
|
+
let adm_zip = require("adm-zip");
|
|
18
|
+
adm_zip = require_vite_internals.__toESM(adm_zip, 1);
|
|
19
|
+
let tar_vern = require("tar-vern");
|
|
17
20
|
//#region src/dev.ts
|
|
18
|
-
var import_dist =
|
|
21
|
+
var import_dist = require_vite_internals.require_dist();
|
|
19
22
|
var muonRecycleExitCode = 88;
|
|
20
23
|
var defaultProjectConfigFileNames = [
|
|
21
24
|
"muon.json5",
|
|
@@ -23,7 +26,7 @@ var defaultProjectConfigFileNames = [
|
|
|
23
26
|
"muon.json"
|
|
24
27
|
];
|
|
25
28
|
var resolveFromRoot = (root, path) => (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(root, path);
|
|
26
|
-
var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29
|
+
var isJsonObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27
30
|
var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
28
31
|
var fileExists = async (path) => {
|
|
29
32
|
try {
|
|
@@ -66,7 +69,7 @@ var loadViteMuonOptions = async (cwd) => {
|
|
|
66
69
|
};
|
|
67
70
|
const config = loaded.config;
|
|
68
71
|
const root = typeof config.root === "string" ? (0, node_path.resolve)(cwd, config.root) : (0, node_path.resolve)(cwd);
|
|
69
|
-
const muonPlugins = (await
|
|
72
|
+
const muonPlugins = (await require_vite_internals.flattenVitePluginOptions(config.plugins)).map((plugin) => require_vite_internals.getMuonVitePluginOptions(plugin)).filter((pluginOptions) => pluginOptions !== void 0);
|
|
70
73
|
if (muonPlugins.length > 1) throw new Error("Multiple muon() plugin definitions were found in vite.config.*.");
|
|
71
74
|
return {
|
|
72
75
|
root,
|
|
@@ -84,7 +87,7 @@ var resolveProjectConfigPath = async (root, configPath) => {
|
|
|
84
87
|
if (await fileExists(candidatePath)) return candidatePath;
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
|
-
var readJsonObjectFile = async (filePath, label) => {
|
|
90
|
+
var readJsonObjectFile$1 = async (filePath, label) => {
|
|
88
91
|
let content;
|
|
89
92
|
try {
|
|
90
93
|
content = await (0, node_fs_promises.readFile)(filePath, "utf8");
|
|
@@ -97,7 +100,7 @@ var readJsonObjectFile = async (filePath, label) => {
|
|
|
97
100
|
} catch (error) {
|
|
98
101
|
throw new Error(`${label} could not be parsed: ${filePath}: ${getErrorMessage(error)}`);
|
|
99
102
|
}
|
|
100
|
-
if (!isJsonObject(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
|
|
103
|
+
if (!isJsonObject$1(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
|
|
101
104
|
return parsed;
|
|
102
105
|
};
|
|
103
106
|
var resolveProjectConfig = async (root, configPath) => {
|
|
@@ -108,14 +111,14 @@ var resolveProjectConfig = async (root, configPath) => {
|
|
|
108
111
|
};
|
|
109
112
|
return {
|
|
110
113
|
configPath: resolvedConfigPath,
|
|
111
|
-
config: await readJsonObjectFile(resolvedConfigPath, "muon config")
|
|
114
|
+
config: await readJsonObjectFile$1(resolvedConfigPath, "muon config")
|
|
112
115
|
};
|
|
113
116
|
};
|
|
114
117
|
var readConfigAssetSourcePath = (config) => {
|
|
115
118
|
if (config === void 0) return;
|
|
116
119
|
const asset = config.asset;
|
|
117
120
|
if (asset === void 0) return;
|
|
118
|
-
if (!isJsonObject(asset)) throw new Error("muon config asset must be an object when present.");
|
|
121
|
+
if (!isJsonObject$1(asset)) throw new Error("muon config asset must be an object when present.");
|
|
119
122
|
const sourcePath = asset.sourcePath;
|
|
120
123
|
if (sourcePath === void 0) return;
|
|
121
124
|
if (typeof sourcePath !== "string") throw new Error("muon config asset.sourcePath must be a string.");
|
|
@@ -201,8 +204,8 @@ var runMuonDev = async (options = {}) => {
|
|
|
201
204
|
const platform = options.platform ?? process.platform;
|
|
202
205
|
const architecture = options.architecture ?? process.arch;
|
|
203
206
|
const environment = options.environment ?? process.env;
|
|
204
|
-
const target =
|
|
205
|
-
const muonPath =
|
|
207
|
+
const target = require_vite_internals.getDefaultMuonPrepareTarget(platform, architecture);
|
|
208
|
+
const muonPath = require_vite_internals.resolveMuonRuntimePath({
|
|
206
209
|
root,
|
|
207
210
|
target,
|
|
208
211
|
muonPath: options.muonPath ?? pluginOptions?.muonPath
|
|
@@ -213,8 +216,8 @@ var runMuonDev = async (options = {}) => {
|
|
|
213
216
|
const projectConfig = await resolveProjectConfig(root, options.configPath);
|
|
214
217
|
const asset = await resolveAssetSource(root, options.assetSourcePath, projectConfig);
|
|
215
218
|
const overrideConfigPath = (0, node_path.join)(root, ".muon", "dev", "muon.dev.json");
|
|
216
|
-
await
|
|
217
|
-
const preparedRuntime = await
|
|
219
|
+
await require_vite_internals.ensureMuonGitignoreEntry(root);
|
|
220
|
+
const preparedRuntime = await require_vite_internals.runMuonPrepare({
|
|
218
221
|
muonPath,
|
|
219
222
|
cefPath,
|
|
220
223
|
stageDir: stagePath,
|
|
@@ -226,9 +229,9 @@ var runMuonDev = async (options = {}) => {
|
|
|
226
229
|
environment,
|
|
227
230
|
cwd: root
|
|
228
231
|
});
|
|
229
|
-
if (preparedRuntime.stagePath === void 0) throw new Error("muon-
|
|
232
|
+
if (preparedRuntime.stagePath === void 0) throw new Error("muon-builder did not return a staged runtime path.");
|
|
230
233
|
await writeMuonDevOverrideConfig(overrideConfigPath, createMuonDevOverrideConfig(asset.overrideAssetSourcePath, enableDebugger));
|
|
231
|
-
const muonExecutablePath =
|
|
234
|
+
const muonExecutablePath = require_vite_internals.getMuonExecutablePath(preparedRuntime.stagePath, platform);
|
|
232
235
|
const exitCode = await runMuonExecutable(muonExecutablePath, [...projectConfig.configPath === void 0 ? [] : [projectConfig.configPath], overrideConfigPath], environment);
|
|
233
236
|
return {
|
|
234
237
|
root,
|
|
@@ -244,9 +247,441 @@ var runMuonDev = async (options = {}) => {
|
|
|
244
247
|
};
|
|
245
248
|
};
|
|
246
249
|
//#endregion
|
|
250
|
+
//#region src/pack.ts
|
|
251
|
+
var AdmZip = __resolveDefaultExport(adm_zip.default, false);
|
|
252
|
+
globalThis.__screwUpIsInCJS_733954c41a89 = true;
|
|
253
|
+
function __resolveDefaultExport(module, isESM) {
|
|
254
|
+
const __isInCJS = typeof globalThis !== "undefined" && globalThis.__screwUpIsInCJS_733954c41a89 === true;
|
|
255
|
+
const maybe = module;
|
|
256
|
+
const hasDefault = !!(maybe && typeof maybe === "object" && "default" in maybe);
|
|
257
|
+
const unwrapNamespaceDefault = (value) => {
|
|
258
|
+
if (!value || typeof value !== "object") return value;
|
|
259
|
+
const inner = value;
|
|
260
|
+
if ((inner.__esModule === true || typeof Symbol !== "undefined" && inner[Symbol.toStringTag] === "Module") && "default" in inner) return inner.default;
|
|
261
|
+
return value;
|
|
262
|
+
};
|
|
263
|
+
const resolvedDefault = hasDefault ? unwrapNamespaceDefault(maybe.default) : void 0;
|
|
264
|
+
if (__isInCJS) return hasDefault ? resolvedDefault ?? module : module;
|
|
265
|
+
if (isESM) {
|
|
266
|
+
if (hasDefault) return resolvedDefault;
|
|
267
|
+
throw new Error("Default export not found.");
|
|
268
|
+
}
|
|
269
|
+
return hasDefault ? resolvedDefault ?? module : module;
|
|
270
|
+
}
|
|
271
|
+
var supportedPackTypes = [
|
|
272
|
+
"zip",
|
|
273
|
+
"tar.gz",
|
|
274
|
+
"deb",
|
|
275
|
+
"nsis"
|
|
276
|
+
];
|
|
277
|
+
var defaultArtifactsDirectory = "artifacts";
|
|
278
|
+
var defaultPackageBuildDirectory = ".muon/pack";
|
|
279
|
+
var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
280
|
+
var readJsonObjectFile = async (path) => {
|
|
281
|
+
const parsed = (0, import_dist.parse)(await (0, node_fs_promises.readFile)(path, "utf8"));
|
|
282
|
+
if (!isJsonObject(parsed)) throw new Error(`JSON file must contain an object: ${path}`);
|
|
283
|
+
return parsed;
|
|
284
|
+
};
|
|
285
|
+
var readPackageJson = async (root) => {
|
|
286
|
+
return await readJsonObjectFile((0, node_path.join)(root, "package.json"));
|
|
287
|
+
};
|
|
288
|
+
var sanitizePackageName = (value) => {
|
|
289
|
+
const sanitized = (value.startsWith("@") ? value.slice(value.indexOf("/") + 1) : value).trim().toLowerCase().replace(/[^a-z0-9+.-]+/g, "-").replace(/^[.+-]+/g, "").replace(/[.+-]+$/g, "");
|
|
290
|
+
return sanitized.length > 0 ? sanitized : "muon-app";
|
|
291
|
+
};
|
|
292
|
+
var stringifyAuthor = (value) => {
|
|
293
|
+
if (typeof value === "string") return value;
|
|
294
|
+
if (!isJsonObject(value) || typeof value.name !== "string") return;
|
|
295
|
+
return value.email === void 0 || typeof value.email !== "string" ? value.name : `${value.name} <${value.email}>`;
|
|
296
|
+
};
|
|
297
|
+
var resolveMetadata = (packageJson, options) => {
|
|
298
|
+
const packageNameSource = options.packageName ?? (typeof packageJson.name === "string" ? packageJson.name : void 0);
|
|
299
|
+
if (packageNameSource === void 0 || packageNameSource.trim() === "") throw new Error("package.json name is required for muon pack.");
|
|
300
|
+
const version = options.packageVersion ?? (typeof packageJson.version === "string" ? packageJson.version : void 0);
|
|
301
|
+
if (version === void 0 || version.trim() === "") throw new Error("package.json version is required for muon pack.");
|
|
302
|
+
const description = options.description ?? (typeof packageJson.description === "string" ? packageJson.description : "Muon application");
|
|
303
|
+
const author = options.author ?? stringifyAuthor(packageJson.author) ?? "Unknown";
|
|
304
|
+
return {
|
|
305
|
+
packageName: sanitizePackageName(packageNameSource),
|
|
306
|
+
version,
|
|
307
|
+
description,
|
|
308
|
+
author
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
var createPackMetadataPackageJson = (packageJson, metadata) => ({
|
|
312
|
+
...packageJson,
|
|
313
|
+
version: metadata.version
|
|
314
|
+
});
|
|
315
|
+
var normalizePackTypes = (types) => {
|
|
316
|
+
if (types === void 0) return [...supportedPackTypes];
|
|
317
|
+
const normalized = types.flatMap((value) => value.split(",")).map((value) => value.trim().toLowerCase()).map((value) => value === "tgz" ? "tar.gz" : value).filter((value) => value.length > 0);
|
|
318
|
+
if (normalized.length === 0) throw new Error("Specify at least one package type with --type.");
|
|
319
|
+
for (const type of normalized) if (!supportedPackTypes.includes(type)) throw new Error(`Unsupported muon pack type: ${type}`);
|
|
320
|
+
return [...new Set(normalized)];
|
|
321
|
+
};
|
|
322
|
+
var packTargetSelectorTargets = {
|
|
323
|
+
linux: [
|
|
324
|
+
"linux-amd64",
|
|
325
|
+
"linux-armhf",
|
|
326
|
+
"linux-arm64"
|
|
327
|
+
],
|
|
328
|
+
windows: ["windows-i686", "windows-amd64"],
|
|
329
|
+
amd64: ["linux-amd64", "windows-amd64"],
|
|
330
|
+
arm64: ["linux-arm64"],
|
|
331
|
+
armhf: ["linux-armhf"],
|
|
332
|
+
i686: ["windows-i686"]
|
|
333
|
+
};
|
|
334
|
+
var normalizePackTargetSelector = (selector) => {
|
|
335
|
+
const normalized = selector.trim().toLowerCase();
|
|
336
|
+
if (require_vite_internals.allMuonTargets.includes(normalized)) return [normalized];
|
|
337
|
+
const targets = packTargetSelectorTargets[normalized];
|
|
338
|
+
if (targets !== void 0) return targets;
|
|
339
|
+
throw new Error(`Unsupported muon pack target selector: ${selector}`);
|
|
340
|
+
};
|
|
341
|
+
var normalizePackTargetSelectors = (selectors) => {
|
|
342
|
+
const targets = selectors.flatMap((selector) => selector.split(",")).map((selector) => selector.trim()).filter((selector) => selector.length > 0).flatMap((selector) => normalizePackTargetSelector(selector));
|
|
343
|
+
return [...new Set(targets)];
|
|
344
|
+
};
|
|
345
|
+
var normalizePluginBuildTargets = (targets) => {
|
|
346
|
+
return [...new Set(targets.map((target) => require_vite_internals.normalizeMuonTarget(target, "muon pack target")))];
|
|
347
|
+
};
|
|
348
|
+
var resolvePackTargetCandidates = (options, pluginBuildOptions) => {
|
|
349
|
+
if (options.allTargets === true) return [...require_vite_internals.allMuonTargets];
|
|
350
|
+
if (options.targets !== void 0 && options.targets.length > 0) return normalizePackTargetSelectors(options.targets);
|
|
351
|
+
if (options.allTargets === false) return [require_vite_internals.getDefaultMuonBuildTarget()];
|
|
352
|
+
if (pluginBuildOptions.allTargets === true) return [...require_vite_internals.allMuonTargets];
|
|
353
|
+
if (pluginBuildOptions.targets !== void 0 && pluginBuildOptions.targets.length > 0) return normalizePluginBuildTargets(pluginBuildOptions.targets);
|
|
354
|
+
if (pluginBuildOptions.allTargets === false) return [require_vite_internals.getDefaultMuonBuildTarget()];
|
|
355
|
+
return [...require_vite_internals.allMuonTargets];
|
|
356
|
+
};
|
|
357
|
+
var packTypeSupportsTarget = (type, target) => {
|
|
358
|
+
const descriptor = require_vite_internals.getMuonTargetDescriptor(target);
|
|
359
|
+
return type === "zip" && descriptor.os === "windows" || type === "tar.gz" && descriptor.os === "linux" || type === "deb" && descriptor.os === "linux" || type === "nsis" && descriptor.os === "windows";
|
|
360
|
+
};
|
|
361
|
+
var createPackTargetPlan = (types, targets) => {
|
|
362
|
+
const plan = targets.map((target) => ({
|
|
363
|
+
target,
|
|
364
|
+
types: types.filter((type) => packTypeSupportsTarget(type, target))
|
|
365
|
+
})).filter((entry) => entry.types.length > 0);
|
|
366
|
+
if (plan.length === 0) throw new Error("No valid muon pack target and type combinations.");
|
|
367
|
+
return plan;
|
|
368
|
+
};
|
|
369
|
+
var runTool = async (executable, args, cwd, environment) => {
|
|
370
|
+
const child = (0, node_child_process.spawn)(executable, [...args], {
|
|
371
|
+
cwd,
|
|
372
|
+
env: environment,
|
|
373
|
+
stdio: [
|
|
374
|
+
"ignore",
|
|
375
|
+
"pipe",
|
|
376
|
+
"pipe"
|
|
377
|
+
]
|
|
378
|
+
});
|
|
379
|
+
let stderr = "";
|
|
380
|
+
child.stderr.setEncoding("utf8");
|
|
381
|
+
child.stderr.on("data", (chunk) => {
|
|
382
|
+
stderr += chunk;
|
|
383
|
+
});
|
|
384
|
+
const exitCode = await new Promise((resolvePromise, reject) => {
|
|
385
|
+
child.once("error", reject);
|
|
386
|
+
child.once("close", (code) => {
|
|
387
|
+
resolvePromise(code ?? 1);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
if (exitCode !== 0) throw new Error(`${executable} failed with exit code ${exitCode}: ${stderr.trim()}`);
|
|
391
|
+
};
|
|
392
|
+
var statOrUndefined = async (path) => {
|
|
393
|
+
try {
|
|
394
|
+
return await (0, node_fs_promises.stat)(path);
|
|
395
|
+
} catch {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
var addDirectoryToZip = async (zip, directory, entryRoot) => {
|
|
400
|
+
const walk = async (currentDirectory) => {
|
|
401
|
+
const entries = await (0, node_fs_promises.readdir)(currentDirectory, { withFileTypes: true });
|
|
402
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
403
|
+
for (const entry of entries) {
|
|
404
|
+
const path = (0, node_path.join)(currentDirectory, entry.name);
|
|
405
|
+
if (entry.isDirectory()) await walk(path);
|
|
406
|
+
else if (entry.isFile()) {
|
|
407
|
+
const stats = await (0, node_fs_promises.stat)(path);
|
|
408
|
+
const relativePath = (0, node_path.relative)(directory, path).split(node_path.sep).join("/");
|
|
409
|
+
zip.addFile(`${entryRoot}/${relativePath}`, await (0, node_fs_promises.readFile)(path), void 0, stats.mode << 16);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
await walk(directory);
|
|
414
|
+
};
|
|
415
|
+
var packageZip = async (target, metadata, artifactsRoot) => {
|
|
416
|
+
const zip = new AdmZip();
|
|
417
|
+
await addDirectoryToZip(zip, target.outputPath, target.distributionDirectoryName);
|
|
418
|
+
const outputPath = (0, node_path.join)(artifactsRoot, `${metadata.packageName}-${metadata.version}-${target.target}.zip`);
|
|
419
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
|
|
420
|
+
await (0, node_fs_promises.writeFile)(outputPath, zip.toBuffer());
|
|
421
|
+
return {
|
|
422
|
+
type: "zip",
|
|
423
|
+
target: target.target,
|
|
424
|
+
path: outputPath
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
var toArchivePath = (path) => path.split(node_path.sep).join("/");
|
|
428
|
+
var createTarGzEntryGenerator = async function* (directory, entryRoot) {
|
|
429
|
+
yield await (0, tar_vern.createDirectoryItem)(entryRoot, "exceptName", { directoryPath: directory });
|
|
430
|
+
const walk = async function* (currentDirectory) {
|
|
431
|
+
const entries = await (0, node_fs_promises.readdir)(currentDirectory, { withFileTypes: true });
|
|
432
|
+
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
433
|
+
for (const entry of entries) {
|
|
434
|
+
const path = (0, node_path.join)(currentDirectory, entry.name);
|
|
435
|
+
const entryName = `${entryRoot}/${toArchivePath((0, node_path.relative)(directory, path))}`;
|
|
436
|
+
if (entry.isDirectory()) {
|
|
437
|
+
yield await (0, tar_vern.createDirectoryItem)(entryName, "exceptName", { directoryPath: path });
|
|
438
|
+
yield* walk(path);
|
|
439
|
+
} else if (entry.isFile()) yield await (0, tar_vern.createReadFileItem)(entryName, path, "exceptName");
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
yield* walk(directory);
|
|
443
|
+
};
|
|
444
|
+
var packageTarGz = async (target, metadata, artifactsRoot) => {
|
|
445
|
+
const outputPath = (0, node_path.join)(artifactsRoot, `${metadata.packageName}-${metadata.version}-${target.target}.tar.gz`);
|
|
446
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
|
|
447
|
+
await (0, tar_vern.storeReaderToFile)((0, tar_vern.createTarPacker)(createTarGzEntryGenerator(target.outputPath, target.distributionDirectoryName), "gzip"), outputPath);
|
|
448
|
+
return {
|
|
449
|
+
type: "tar.gz",
|
|
450
|
+
target: target.target,
|
|
451
|
+
path: outputPath
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
var packageDeb = async (root, target, metadata, artifactsRoot, packageBuildRoot, environment) => {
|
|
455
|
+
const descriptor = require_vite_internals.getMuonTargetDescriptor(target.target);
|
|
456
|
+
if (descriptor.os !== "linux") throw new Error(`Unsupported deb target: ${target.target}`);
|
|
457
|
+
const architecture = descriptor.arch;
|
|
458
|
+
const packageRoot = (0, node_path.join)(packageBuildRoot, "deb", `${metadata.packageName}-${target.target}`);
|
|
459
|
+
await (0, node_fs_promises.rm)(packageRoot, {
|
|
460
|
+
recursive: true,
|
|
461
|
+
force: true
|
|
462
|
+
});
|
|
463
|
+
const installedDist = (0, node_path.join)((0, node_path.join)(packageRoot, "usr", "lib", metadata.packageName), target.distributionDirectoryName);
|
|
464
|
+
await (0, node_fs_promises.mkdir)(installedDist, { recursive: true });
|
|
465
|
+
await (0, node_fs_promises.cp)(target.outputPath, installedDist, { recursive: true });
|
|
466
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(installedDist, "muon-install.json"), `${JSON.stringify({
|
|
467
|
+
type: "deb",
|
|
468
|
+
packageName: metadata.packageName,
|
|
469
|
+
launcherPath: `/usr/bin/${metadata.packageName}`
|
|
470
|
+
}, void 0, 2)}\n`);
|
|
471
|
+
const binPath = (0, node_path.join)(packageRoot, "usr", "bin", metadata.packageName);
|
|
472
|
+
const launcherName = (0, node_path.basename)(target.launcherPath);
|
|
473
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(binPath), { recursive: true });
|
|
474
|
+
await (0, node_fs_promises.writeFile)(binPath, [
|
|
475
|
+
"#!/usr/bin/env bash",
|
|
476
|
+
"set -euo pipefail",
|
|
477
|
+
`exec ${JSON.stringify(`/usr/lib/${metadata.packageName}/${target.distributionDirectoryName}/${launcherName}`)} "$@"`,
|
|
478
|
+
""
|
|
479
|
+
].join("\n"));
|
|
480
|
+
await (0, node_fs_promises.chmod)(binPath, 493);
|
|
481
|
+
if (target.linuxDesktop === void 0) throw new Error(`Linux desktop metadata is unavailable: ${target.target}`);
|
|
482
|
+
const applicationsPath = (0, node_path.join)(packageRoot, "usr", "share", "applications", `${target.linuxDesktop.desktopId}.desktop`);
|
|
483
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(applicationsPath), { recursive: true });
|
|
484
|
+
await (0, node_fs_promises.writeFile)(applicationsPath, require_vite_internals.createLinuxDesktopEntry({
|
|
485
|
+
desktop: target.linuxDesktop,
|
|
486
|
+
exec: `${require_vite_internals.quoteDesktopExecArgument(`/usr/bin/${metadata.packageName}`)} --muon-launch-from=normal`,
|
|
487
|
+
tryExec: `/usr/bin/${metadata.packageName}`,
|
|
488
|
+
icon: target.linuxDesktop.desktopId
|
|
489
|
+
}));
|
|
490
|
+
const iconPath = (0, node_path.join)(packageRoot, "usr", "share", "icons", "hicolor", "256x256", "apps", `${target.linuxDesktop.desktopId}.png`);
|
|
491
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(iconPath), { recursive: true });
|
|
492
|
+
await (0, node_fs_promises.cp)((0, node_path.join)(target.outputPath, target.linuxDesktop.iconFileName), iconPath);
|
|
493
|
+
const controlPath = (0, node_path.join)(packageRoot, "DEBIAN", "control");
|
|
494
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(controlPath), { recursive: true });
|
|
495
|
+
await (0, node_fs_promises.writeFile)(controlPath, [
|
|
496
|
+
`Package: ${metadata.packageName}`,
|
|
497
|
+
`Version: ${metadata.version}`,
|
|
498
|
+
`Architecture: ${architecture}`,
|
|
499
|
+
`Maintainer: ${metadata.author}`,
|
|
500
|
+
`Description: ${metadata.description}`,
|
|
501
|
+
""
|
|
502
|
+
].join("\n"));
|
|
503
|
+
const outputPath = (0, node_path.join)(artifactsRoot, `${metadata.packageName}-${metadata.version}-${architecture}.deb`);
|
|
504
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
|
|
505
|
+
await runTool("dpkg-deb", [
|
|
506
|
+
"--build",
|
|
507
|
+
packageRoot,
|
|
508
|
+
outputPath
|
|
509
|
+
], root, environment);
|
|
510
|
+
return {
|
|
511
|
+
type: "deb",
|
|
512
|
+
target: target.target,
|
|
513
|
+
path: outputPath
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
var escapeNsis = (value) => value.replaceAll("\\", "\\\\").replaceAll("\"", "$\\\"");
|
|
517
|
+
var nsisUninstallRegistryRoot = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
|
|
518
|
+
var createNsisUninstallRegistryKey = (appId) => `${nsisUninstallRegistryRoot}\\${appId}`;
|
|
519
|
+
var packageNsis = async (root, target, metadata, appId, windowsResource, artifactsRoot, packageBuildRoot, environment) => {
|
|
520
|
+
const descriptor = require_vite_internals.getMuonTargetDescriptor(target.target);
|
|
521
|
+
if (descriptor.os !== "windows") throw new Error(`Unsupported nsis target: ${target.target}`);
|
|
522
|
+
const scriptPath = (0, node_path.join)(packageBuildRoot, "nsis", `${metadata.packageName}-${target.target}.nsi`);
|
|
523
|
+
const outputPath = (0, node_path.join)(artifactsRoot, `${metadata.packageName}-${metadata.version}-${descriptor.arch}-setup.exe`);
|
|
524
|
+
const launcherFileName = (0, node_path.basename)(target.launcherPath);
|
|
525
|
+
const uninstallRegistryKey = createNsisUninstallRegistryKey(appId);
|
|
526
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(scriptPath), { recursive: true });
|
|
527
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
|
|
528
|
+
const iconPath = windowsResource.iconPath === void 0 ? void 0 : (0, node_path.join)((0, node_path.dirname)(scriptPath), `${metadata.packageName}-${target.target}.ico`);
|
|
529
|
+
if (windowsResource.iconPath !== void 0 && iconPath !== void 0) await require_vite_internals.createWindowsIconFromPngFile(windowsResource.iconPath, iconPath);
|
|
530
|
+
await (0, node_fs_promises.writeFile)(scriptPath, [
|
|
531
|
+
"Unicode true",
|
|
532
|
+
`Name "${escapeNsis(metadata.packageName)}"`,
|
|
533
|
+
`OutFile "${escapeNsis(outputPath)}"`,
|
|
534
|
+
`InstallDir "$LOCALAPPDATA\\Programs\\${escapeNsis(metadata.packageName)}"`,
|
|
535
|
+
"RequestExecutionLevel user",
|
|
536
|
+
"ShowInstDetails nevershow",
|
|
537
|
+
"AutoCloseWindow true",
|
|
538
|
+
...createNsisResourceDirectives(windowsResource, iconPath),
|
|
539
|
+
"Page instfiles",
|
|
540
|
+
"Section",
|
|
541
|
+
" SetOutPath \"$INSTDIR\"",
|
|
542
|
+
` File /r "${escapeNsis(target.outputPath)}\\*"`,
|
|
543
|
+
` CreateShortCut "$SMPROGRAMS\\${escapeNsis(metadata.packageName)}.lnk" "$INSTDIR\\${escapeNsis(launcherFileName)}"`,
|
|
544
|
+
" WriteUninstaller \"$INSTDIR\\Uninstall.exe\"",
|
|
545
|
+
` WriteRegStr HKCU "${escapeNsis(uninstallRegistryKey)}" "DisplayName" "${escapeNsis(metadata.packageName)}"`,
|
|
546
|
+
` WriteRegStr HKCU "${escapeNsis(uninstallRegistryKey)}" "DisplayVersion" "${escapeNsis(metadata.version)}"`,
|
|
547
|
+
` WriteRegStr HKCU "${escapeNsis(uninstallRegistryKey)}" "Publisher" "${escapeNsis(metadata.author)}"`,
|
|
548
|
+
` WriteRegStr HKCU "${escapeNsis(uninstallRegistryKey)}" "InstallLocation" "$INSTDIR"`,
|
|
549
|
+
` WriteRegStr HKCU "${escapeNsis(uninstallRegistryKey)}" "DisplayIcon" "$\\"$INSTDIR\\${escapeNsis(launcherFileName)}$\\""`,
|
|
550
|
+
` WriteRegStr HKCU "${escapeNsis(uninstallRegistryKey)}" "UninstallString" "$\\"$INSTDIR\\Uninstall.exe$\\" /S"`,
|
|
551
|
+
` WriteRegStr HKCU "${escapeNsis(uninstallRegistryKey)}" "QuietUninstallString" "$\\"$INSTDIR\\Uninstall.exe$\\" /S"`,
|
|
552
|
+
` WriteRegDWORD HKCU "${escapeNsis(uninstallRegistryKey)}" "NoModify" 1`,
|
|
553
|
+
` WriteRegDWORD HKCU "${escapeNsis(uninstallRegistryKey)}" "NoRepair" 1`,
|
|
554
|
+
"SectionEnd",
|
|
555
|
+
"",
|
|
556
|
+
"Section \"Uninstall\"",
|
|
557
|
+
` Delete "$SMPROGRAMS\\${escapeNsis(metadata.packageName)}.lnk"`,
|
|
558
|
+
` DeleteRegKey HKCU "${escapeNsis(uninstallRegistryKey)}"`,
|
|
559
|
+
" RMDir /r \"$INSTDIR\"",
|
|
560
|
+
` RMDir /r "$LOCALAPPDATA\\${escapeNsis(appId)}"`,
|
|
561
|
+
"SectionEnd",
|
|
562
|
+
"",
|
|
563
|
+
"Function .onInstSuccess",
|
|
564
|
+
" IfSilent +3",
|
|
565
|
+
" SetOutPath \"$INSTDIR\"",
|
|
566
|
+
` Exec "$\\"$INSTDIR\\${escapeNsis(launcherFileName)}$\\""`,
|
|
567
|
+
"FunctionEnd",
|
|
568
|
+
""
|
|
569
|
+
].join("\n"));
|
|
570
|
+
await runTool("makensis", [scriptPath], root, environment);
|
|
571
|
+
if (await statOrUndefined(outputPath) === void 0) throw new Error(`makensis did not create installer: ${outputPath}`);
|
|
572
|
+
return {
|
|
573
|
+
type: "nsis",
|
|
574
|
+
target: target.target,
|
|
575
|
+
path: outputPath
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
var createNsisResourceDirectives = (resource, iconPath) => {
|
|
579
|
+
const lines = [];
|
|
580
|
+
if (iconPath !== void 0) {
|
|
581
|
+
lines.push(`Icon "${escapeNsis(iconPath)}"`);
|
|
582
|
+
lines.push(`UninstallIcon "${escapeNsis(iconPath)}"`);
|
|
583
|
+
}
|
|
584
|
+
lines.push(`VIProductVersion "${escapeNsis(resource.fixedVersion)}"`);
|
|
585
|
+
lines.push(`VIFileVersion "${escapeNsis(resource.fixedVersion)}"`);
|
|
586
|
+
lines.push(`VIAddVersionKey /LANG=${resource.language} "CompanyName" "${escapeNsis(resource.companyName)}"`);
|
|
587
|
+
lines.push(`VIAddVersionKey /LANG=${resource.language} "FileDescription" "${escapeNsis(resource.fileDescription)}"`);
|
|
588
|
+
lines.push(`VIAddVersionKey /LANG=${resource.language} "FileVersion" "${escapeNsis(resource.version)}"`);
|
|
589
|
+
lines.push(`VIAddVersionKey /LANG=${resource.language} "ProductName" "${escapeNsis(resource.productName)}"`);
|
|
590
|
+
lines.push(`VIAddVersionKey /LANG=${resource.language} "ProductVersion" "${escapeNsis(resource.version)}"`);
|
|
591
|
+
if (resource.copyright !== void 0) lines.push(`VIAddVersionKey /LANG=${resource.language} "LegalCopyright" "${escapeNsis(resource.copyright)}"`);
|
|
592
|
+
return lines;
|
|
593
|
+
};
|
|
594
|
+
var reapplyPackWindowsResources = async (targets, resource, root, environment) => {
|
|
595
|
+
for (const target of targets) if (require_vite_internals.getMuonTargetDescriptor(target.target).os === "windows") await require_vite_internals.updateWindowsPeResources({
|
|
596
|
+
executablePath: target.launcherPath,
|
|
597
|
+
resource,
|
|
598
|
+
environment,
|
|
599
|
+
cwd: root
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Runs the Muon build sequence and creates redistributable packages.
|
|
604
|
+
*
|
|
605
|
+
* @param options Pack options.
|
|
606
|
+
* @returns Generated package artifacts.
|
|
607
|
+
*/
|
|
608
|
+
var packMuonApp = async (options) => {
|
|
609
|
+
const cwd = (0, node_path.resolve)(options.root ?? process.cwd());
|
|
610
|
+
const environment = options.environment ?? process.env;
|
|
611
|
+
const project = await require_vite_internals.loadMuonBuildSequenceProject(cwd);
|
|
612
|
+
const root = project.root;
|
|
613
|
+
const packageJson = await readPackageJson(root);
|
|
614
|
+
const metadata = resolveMetadata(packageJson, options);
|
|
615
|
+
const artifactsRoot = (0, node_path.resolve)(root, options.artifactsDir ?? defaultArtifactsDirectory);
|
|
616
|
+
const packageBuildRoot = (0, node_path.resolve)(root, defaultPackageBuildDirectory);
|
|
617
|
+
const types = normalizePackTypes(options.types);
|
|
618
|
+
const pluginBuildOptions = require_vite_internals.resolveMuonViteBuildOptions(project.pluginOptions);
|
|
619
|
+
const targetPlan = createPackTargetPlan(types, resolvePackTargetCandidates(options, pluginBuildOptions));
|
|
620
|
+
const buildOptions = {
|
|
621
|
+
root: cwd,
|
|
622
|
+
targets: targetPlan.map((entry) => entry.target),
|
|
623
|
+
allTargets: false
|
|
624
|
+
};
|
|
625
|
+
const windowsResourceOptions = require_vite_internals.mergeMuonWindowsResourceOptions(options.windowsResource, pluginBuildOptions.windowsResource);
|
|
626
|
+
const linuxDesktopOptions = require_vite_internals.mergeMuonLinuxDesktopOptions(options.linuxDesktop, pluginBuildOptions.linuxDesktop);
|
|
627
|
+
if (options.configPath !== void 0) buildOptions.configPath = options.configPath;
|
|
628
|
+
if (options.appName !== void 0) buildOptions.appName = options.appName;
|
|
629
|
+
if (options.appId !== void 0) buildOptions.appId = options.appId;
|
|
630
|
+
if (options.packageDirectory !== void 0) buildOptions.packageDirectory = options.packageDirectory;
|
|
631
|
+
if (windowsResourceOptions !== void 0) buildOptions.windowsResource = windowsResourceOptions;
|
|
632
|
+
if (linuxDesktopOptions !== void 0) buildOptions.linuxDesktop = linuxDesktopOptions;
|
|
633
|
+
const windowsResourceConfig = await require_vite_internals.readMuonConfigForWindowsResource(root, options.configPath);
|
|
634
|
+
const windowsResource = await require_vite_internals.resolveMuonWindowsResource({
|
|
635
|
+
root,
|
|
636
|
+
packageDirectory: options.packageDirectory ?? pluginBuildOptions.packageDirectory ?? "",
|
|
637
|
+
packageJson: createPackMetadataPackageJson(packageJson, metadata),
|
|
638
|
+
muonConfig: windowsResourceConfig.config,
|
|
639
|
+
muonConfigDirectory: windowsResourceConfig.directory,
|
|
640
|
+
options: windowsResourceOptions,
|
|
641
|
+
defaults: {
|
|
642
|
+
productName: metadata.packageName,
|
|
643
|
+
fileDescription: metadata.description,
|
|
644
|
+
companyName: metadata.author,
|
|
645
|
+
version: metadata.version,
|
|
646
|
+
copyright: void 0
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
const build = await require_vite_internals.runMuonBuildSequence(buildOptions, project);
|
|
650
|
+
if (options.packageVersion !== void 0) await reapplyPackWindowsResources(build.targets, windowsResource, root, environment);
|
|
651
|
+
const typesByTarget = new Map(targetPlan.map((entry) => [entry.target, entry.types]));
|
|
652
|
+
await (0, node_fs_promises.rm)(packageBuildRoot, {
|
|
653
|
+
recursive: true,
|
|
654
|
+
force: true
|
|
655
|
+
});
|
|
656
|
+
await (0, node_fs_promises.rm)((0, node_path.join)(artifactsRoot, "deb"), {
|
|
657
|
+
recursive: true,
|
|
658
|
+
force: true
|
|
659
|
+
});
|
|
660
|
+
await (0, node_fs_promises.rm)((0, node_path.join)(artifactsRoot, "nsis"), {
|
|
661
|
+
recursive: true,
|
|
662
|
+
force: true
|
|
663
|
+
});
|
|
664
|
+
await (0, node_fs_promises.mkdir)(artifactsRoot, { recursive: true });
|
|
665
|
+
const artifacts = [];
|
|
666
|
+
for (const target of build.targets) for (const type of typesByTarget.get(target.target) ?? []) if (type === "zip") artifacts.push(await packageZip(target, metadata, artifactsRoot));
|
|
667
|
+
else if (type === "tar.gz") artifacts.push(await packageTarGz(target, metadata, artifactsRoot));
|
|
668
|
+
else if (type === "deb") artifacts.push(await packageDeb(root, target, metadata, artifactsRoot, packageBuildRoot, environment));
|
|
669
|
+
else artifacts.push(await packageNsis(root, target, metadata, build.appId, windowsResource, artifactsRoot, packageBuildRoot, environment));
|
|
670
|
+
return {
|
|
671
|
+
root,
|
|
672
|
+
packageName: metadata.packageName,
|
|
673
|
+
version: metadata.version,
|
|
674
|
+
appName: build.appName,
|
|
675
|
+
appId: build.appId,
|
|
676
|
+
build,
|
|
677
|
+
targets: build.targets,
|
|
678
|
+
artifacts
|
|
679
|
+
};
|
|
680
|
+
};
|
|
681
|
+
//#endregion
|
|
247
682
|
//#region src/generated/packageMetadata.ts
|
|
248
|
-
var version = "0.
|
|
249
|
-
var git_commit_hash = "
|
|
683
|
+
var version = "0.8.0";
|
|
684
|
+
var git_commit_hash = "9bb6148e155dab16c4ca441073b144e21981b038";
|
|
250
685
|
//#endregion
|
|
251
686
|
//#region src/cli.ts
|
|
252
687
|
var readTargetValues = (value) => {
|
|
@@ -255,6 +690,16 @@ var readTargetValues = (value) => {
|
|
|
255
690
|
var appendTargetValues = (value, previous) => {
|
|
256
691
|
return [...previous, ...readTargetValues(value)];
|
|
257
692
|
};
|
|
693
|
+
var appendPackTypeValues = (value, previous) => {
|
|
694
|
+
return [...previous ?? [], ...readTargetValues(value)];
|
|
695
|
+
};
|
|
696
|
+
var readCommaSeparatedValues = (value) => value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
697
|
+
var readBooleanValue = (value, label) => {
|
|
698
|
+
const normalized = value.trim().toLowerCase();
|
|
699
|
+
if (normalized === "true" || normalized === "1" || normalized === "yes") return true;
|
|
700
|
+
if (normalized === "false" || normalized === "0" || normalized === "no") return false;
|
|
701
|
+
throw new Error(`${label} must be true or false.`);
|
|
702
|
+
};
|
|
258
703
|
var validateEmbedConfigOptions = (options) => {
|
|
259
704
|
if (options.runtimePath !== void 0 && options.corePath !== void 0) throw new Error("Specify at most one of --runtime-path or --core-path.");
|
|
260
705
|
if (options.runtimePath === void 0 && options.corePath === void 0 && options.bootstrapPath === void 0) throw new Error("Specify at least one of --runtime-path, --core-path, or --bootstrap-path.");
|
|
@@ -262,28 +707,82 @@ var validateEmbedConfigOptions = (options) => {
|
|
|
262
707
|
if (options.runtimePath !== void 0 && options.output !== void 0) throw new Error("--output requires --core-path.");
|
|
263
708
|
if (options.bootstrapPath === void 0 && options.outputBootstrap !== void 0) throw new Error("--output-bootstrap requires --bootstrap-path.");
|
|
264
709
|
};
|
|
710
|
+
var createWindowsResourceOptions = (commandOptions) => {
|
|
711
|
+
const options = {};
|
|
712
|
+
if (commandOptions.windowsIcon !== void 0) options.iconPath = commandOptions.windowsIcon;
|
|
713
|
+
if (commandOptions.windowsProductName !== void 0) options.productName = commandOptions.windowsProductName;
|
|
714
|
+
if (commandOptions.windowsFileDescription !== void 0) options.fileDescription = commandOptions.windowsFileDescription;
|
|
715
|
+
if (commandOptions.windowsCompanyName !== void 0) options.companyName = commandOptions.windowsCompanyName;
|
|
716
|
+
if (commandOptions.windowsVersion !== void 0) options.version = commandOptions.windowsVersion;
|
|
717
|
+
if (commandOptions.windowsCopyright !== void 0) options.copyright = commandOptions.windowsCopyright;
|
|
718
|
+
return Object.keys(options).length === 0 ? void 0 : options;
|
|
719
|
+
};
|
|
720
|
+
var createLinuxDesktopOptions = (commandOptions) => {
|
|
721
|
+
const options = {};
|
|
722
|
+
if (commandOptions.linuxDesktopId !== void 0) options.desktopId = commandOptions.linuxDesktopId;
|
|
723
|
+
if (commandOptions.linuxName !== void 0) options.name = commandOptions.linuxName;
|
|
724
|
+
if (commandOptions.linuxComment !== void 0) options.comment = commandOptions.linuxComment;
|
|
725
|
+
if (commandOptions.linuxIcon !== void 0) options.iconPath = commandOptions.linuxIcon;
|
|
726
|
+
if (commandOptions.linuxCategories !== void 0) options.categories = readCommaSeparatedValues(commandOptions.linuxCategories);
|
|
727
|
+
if (commandOptions.linuxStartupNotify !== void 0) options.startupNotify = readBooleanValue(commandOptions.linuxStartupNotify, "--linux-startup-notify");
|
|
728
|
+
return Object.keys(options).length === 0 ? void 0 : options;
|
|
729
|
+
};
|
|
265
730
|
var runBuildCommand = async (commandOptions) => {
|
|
266
731
|
const targets = commandOptions.target;
|
|
267
732
|
if (commandOptions.all === true && targets.length > 0) throw new Error("Specify either --all or --target, not both.");
|
|
268
733
|
const buildOptions = {
|
|
269
734
|
root: process.cwd(),
|
|
270
|
-
|
|
735
|
+
defaultAllTargets: false
|
|
271
736
|
};
|
|
272
737
|
if (targets.length > 0) buildOptions.targets = targets;
|
|
738
|
+
if (commandOptions.all === true) buildOptions.allTargets = true;
|
|
273
739
|
if (commandOptions.assets !== void 0) buildOptions.assetSourcePath = commandOptions.assets;
|
|
274
740
|
if (commandOptions.config !== void 0) buildOptions.configPath = commandOptions.config;
|
|
741
|
+
const windowsResource = createWindowsResourceOptions(commandOptions);
|
|
742
|
+
if (windowsResource !== void 0) buildOptions.windowsResource = windowsResource;
|
|
743
|
+
const linuxDesktop = createLinuxDesktopOptions(commandOptions);
|
|
744
|
+
if (linuxDesktop !== void 0) buildOptions.linuxDesktop = linuxDesktop;
|
|
275
745
|
if (commandOptions.outDir !== void 0) buildOptions.outputRoot = commandOptions.outDir;
|
|
276
746
|
if (commandOptions.name !== void 0) buildOptions.appName = commandOptions.name;
|
|
277
|
-
|
|
747
|
+
if (commandOptions.appId !== void 0) buildOptions.appId = commandOptions.appId;
|
|
748
|
+
if (commandOptions.packageDirectory !== void 0) buildOptions.packageDirectory = commandOptions.packageDirectory;
|
|
749
|
+
const result = await require_vite_internals.runMuonBuildSequence(buildOptions);
|
|
278
750
|
if (commandOptions.json === true) console.log(JSON.stringify(result, null, 2));
|
|
279
751
|
else for (const target of result.targets) console.log(target.outputPath);
|
|
280
752
|
};
|
|
753
|
+
var runPackCommand = async (commandOptions) => {
|
|
754
|
+
const targets = commandOptions.target;
|
|
755
|
+
if (commandOptions.all === true && targets.length > 0) throw new Error("Specify either --all or --target, not both.");
|
|
756
|
+
const packOptions = {
|
|
757
|
+
root: process.cwd(),
|
|
758
|
+
environment: process.env
|
|
759
|
+
};
|
|
760
|
+
if (commandOptions.type !== void 0) packOptions.types = commandOptions.type;
|
|
761
|
+
if (targets.length > 0) packOptions.targets = targets;
|
|
762
|
+
if (commandOptions.all !== void 0) packOptions.allTargets = commandOptions.all;
|
|
763
|
+
if (commandOptions.config !== void 0) packOptions.configPath = commandOptions.config;
|
|
764
|
+
const windowsResource = createWindowsResourceOptions(commandOptions);
|
|
765
|
+
if (windowsResource !== void 0) packOptions.windowsResource = windowsResource;
|
|
766
|
+
const linuxDesktop = createLinuxDesktopOptions(commandOptions);
|
|
767
|
+
if (linuxDesktop !== void 0) packOptions.linuxDesktop = linuxDesktop;
|
|
768
|
+
if (commandOptions.name !== void 0) packOptions.appName = commandOptions.name;
|
|
769
|
+
if (commandOptions.appId !== void 0) packOptions.appId = commandOptions.appId;
|
|
770
|
+
if (commandOptions.packageDirectory !== void 0) packOptions.packageDirectory = commandOptions.packageDirectory;
|
|
771
|
+
if (commandOptions.artifactsDir !== void 0) packOptions.artifactsDir = commandOptions.artifactsDir;
|
|
772
|
+
if (commandOptions.packageName !== void 0) packOptions.packageName = commandOptions.packageName;
|
|
773
|
+
if (commandOptions.packageVersion !== void 0) packOptions.packageVersion = commandOptions.packageVersion;
|
|
774
|
+
if (commandOptions.description !== void 0) packOptions.description = commandOptions.description;
|
|
775
|
+
if (commandOptions.author !== void 0) packOptions.author = commandOptions.author;
|
|
776
|
+
const result = await packMuonApp(packOptions);
|
|
777
|
+
if (commandOptions.json === true) console.log(JSON.stringify(result, null, 2));
|
|
778
|
+
else for (const artifact of result.artifacts) console.log(artifact.path);
|
|
779
|
+
};
|
|
281
780
|
var runPrepareCommand = async (commandOptions) => {
|
|
282
|
-
const result = await
|
|
781
|
+
const result = await require_vite_internals.runMuonPrepare({
|
|
283
782
|
muonPath: commandOptions.muonPath ?? "",
|
|
284
783
|
cefPath: commandOptions.cefPath,
|
|
285
784
|
stageDir: commandOptions.stageDir,
|
|
286
|
-
target: commandOptions.target ??
|
|
785
|
+
target: commandOptions.target ?? require_vite_internals.getDefaultMuonPrepareTarget(process.platform, process.arch),
|
|
287
786
|
cacheDir: commandOptions.cacheDir,
|
|
288
787
|
force: commandOptions.force === true,
|
|
289
788
|
quiet: commandOptions.quiet === true,
|
|
@@ -311,7 +810,7 @@ var runDevCommand = async (commandOptions, command) => {
|
|
|
311
810
|
if (result.exitCode !== 0) process.exitCode = result.exitCode;
|
|
312
811
|
};
|
|
313
812
|
var runInitCommand = async () => {
|
|
314
|
-
const result = await
|
|
813
|
+
const result = await require_vite_internals.ensureMuonGitignoreEntry(process.cwd());
|
|
315
814
|
console.log(result.changed ? `Updated ${result.gitignorePath}` : result.gitignorePath);
|
|
316
815
|
};
|
|
317
816
|
var printEmbedConfigResult = (result, json) => {
|
|
@@ -321,16 +820,16 @@ var printEmbedConfigResult = (result, json) => {
|
|
|
321
820
|
var runEmbedConfigCommand = async (commandOptions) => {
|
|
322
821
|
validateEmbedConfigOptions(commandOptions);
|
|
323
822
|
const configPath = commandOptions.config ?? "";
|
|
324
|
-
const coreResult = commandOptions.corePath !== void 0 ? await
|
|
823
|
+
const coreResult = commandOptions.corePath !== void 0 ? await require_vite_internals.embedMuonConfigInCoreFile({
|
|
325
824
|
corePath: commandOptions.corePath,
|
|
326
825
|
configPath,
|
|
327
826
|
outputPath: commandOptions.output
|
|
328
|
-
}) : commandOptions.runtimePath !== void 0 ? await
|
|
827
|
+
}) : commandOptions.runtimePath !== void 0 ? await require_vite_internals.embedMuonConfigInRuntime({
|
|
329
828
|
runtimePath: commandOptions.runtimePath,
|
|
330
829
|
configPath,
|
|
331
830
|
outputRuntimePath: commandOptions.outputRuntimePath
|
|
332
831
|
}) : void 0;
|
|
333
|
-
const bootstrapResult = commandOptions.bootstrapPath === void 0 ? void 0 : await
|
|
832
|
+
const bootstrapResult = commandOptions.bootstrapPath === void 0 ? void 0 : await require_vite_internals.embedMuonConfigInBootstrapFile({
|
|
334
833
|
bootstrapPath: commandOptions.bootstrapPath,
|
|
335
834
|
configPath,
|
|
336
835
|
outputPath: commandOptions.outputBootstrap
|
|
@@ -353,16 +852,19 @@ var createCliCommand = () => {
|
|
|
353
852
|
program.outputHelp({ error: true });
|
|
354
853
|
process.exitCode = 1;
|
|
355
854
|
});
|
|
356
|
-
program.command("build").description("Build CEF-free Muon app distribution directories").option("--target <target>", "target
|
|
855
|
+
program.command("build").description("Build CEF-free Muon app distribution directories").option("--target <target>", "public target or comma-separated public targets", appendTargetValues, []).option("--all", "build all supported targets").option("--assets <path>", "asset root path").option("--config <path>", "muon config path").option("--windows-icon <path>", "Windows PNG icon resource path").option("--windows-product-name <name>", "Windows product name").option("--windows-file-description <text>", "Windows file description").option("--windows-company-name <name>", "Windows company name").option("--windows-version <version>", "Windows resource version").option("--windows-copyright <text>", "Windows legal copyright").option("--linux-desktop-id <id>", "Linux desktop entry identifier").option("--linux-name <name>", "Linux desktop display name").option("--linux-comment <text>", "Linux desktop comment").option("--linux-icon <path>", "Linux desktop PNG icon path").option("--linux-categories <list>", "Linux desktop categories").option("--linux-startup-notify <boolean>", "Linux startup notification").option("--out-dir <path>", "output root directory").option("--name <name>", "launcher file name").option("--app-id <id>", "stable application identifier").option("--package-directory <path>", "Muon package dist directory").option("--json", "write result as JSON").action(async (options) => {
|
|
357
856
|
await runBuildCommand(options);
|
|
358
857
|
});
|
|
858
|
+
program.command("pack").description("Build and package a Muon app").option("--type <type>", "package type or comma-separated package types: zip, tar.gz, tgz, deb, nsis (default: all)", appendPackTypeValues).option("--target <target>", "public target, platform, arch, or comma-separated selectors", appendTargetValues, []).option("--all", "build all supported targets").option("--config <path>", "muon config path").option("--windows-icon <path>", "Windows PNG icon resource path").option("--windows-product-name <name>", "Windows product name").option("--windows-file-description <text>", "Windows file description").option("--windows-company-name <name>", "Windows company name").option("--windows-version <version>", "Windows resource version").option("--windows-copyright <text>", "Windows legal copyright").option("--linux-desktop-id <id>", "Linux desktop entry identifier").option("--linux-name <name>", "Linux desktop display name").option("--linux-comment <text>", "Linux desktop comment").option("--linux-icon <path>", "Linux desktop PNG icon path").option("--linux-categories <list>", "Linux desktop categories").option("--linux-startup-notify <boolean>", "Linux startup notification").option("--name <name>", "launcher file name").option("--app-id <id>", "stable application identifier").option("--package-directory <path>", "Muon package dist directory").option("--artifacts-dir <path>", "package artifact output directory").option("--package-name <name>", "package name override").option("--package-version <version>", "package version override").option("--description <text>", "package description override").option("--author <text>", "package author override").option("--json", "write result as JSON").action(async (options) => {
|
|
859
|
+
await runPackCommand(options);
|
|
860
|
+
});
|
|
359
861
|
const devCommand = program.command("dev").description("Launch Muon directly with local development assets").option("--muon-path <path>", "Muon runtime file root").option("--cef-path <path>", "CEF file root").option("--stage-dir <path>", "prepared runtime output directory").option("--config <path>", "muon config path").option("--assets <path>", "development asset directory").option("--no-debugger", "disable Muon debugger defaults").option("--json", "write result as JSON").action(async (options) => {
|
|
360
862
|
await runDevCommand(options, devCommand);
|
|
361
863
|
});
|
|
362
864
|
program.command("init").description("Initialize Muon project helper files").action(async () => {
|
|
363
865
|
await runInitCommand();
|
|
364
866
|
});
|
|
365
|
-
program.command("prepare").description("Prepare a Muon runtime with CEF files").requiredOption("--muon-path <path>", "Muon runtime file root").option("--cef-path <path>", "CEF file root").option("--stage-dir <path>", "prepared runtime output directory").option("--target <target>", "prepare target").option("--cache-dir <path>", "CEF artifact cache directory").option("--force", "rebuild an existing prepared runtime").option("-q, --quiet", "suppress native
|
|
867
|
+
program.command("prepare").description("Prepare a Muon runtime with CEF files").requiredOption("--muon-path <path>", "Muon runtime file root").option("--cef-path <path>", "CEF file root").option("--stage-dir <path>", "prepared runtime output directory").option("--target <target>", "prepare target").option("--cache-dir <path>", "CEF artifact cache directory").option("--force", "rebuild an existing prepared runtime").option("-q, --quiet", "suppress native builder progress messages").option("--json", "write result as JSON").action(async (options) => {
|
|
366
868
|
await runPrepareCommand(options);
|
|
367
869
|
});
|
|
368
870
|
program.command("embed-config").description("Embed muon.json into Muon runtime files").option("--runtime-path <path>", "prepared runtime directory").option("--core-path <path>", "muon-core executable path").option("--bootstrap-path <path>", "muon-bootstrap executable path").requiredOption("--config <path>", "muon config path").option("--output-runtime-path <path>", "patched runtime output directory").option("--output <path>", "patched muon-core output path").option("--output-bootstrap <path>", "patched bootstrap output path").option("--json", "write result as JSON").action(async (options) => {
|