app-builder-lib 25.0.5 → 25.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/codeSign/windowsCodeSign.d.ts +2 -31
- package/out/codeSign/windowsCodeSign.js +28 -246
- package/out/codeSign/windowsCodeSign.js.map +1 -1
- package/out/codeSign/windowsSignAzureManager.d.ts +12 -0
- package/out/codeSign/windowsSignAzureManager.js +81 -0
- package/out/codeSign/windowsSignAzureManager.js.map +1 -0
- package/out/codeSign/windowsSignToolManager.d.ts +53 -0
- package/out/codeSign/windowsSignToolManager.js +341 -0
- package/out/codeSign/windowsSignToolManager.js.map +1 -0
- package/out/configuration.d.ts +14 -12
- package/out/configuration.js.map +1 -1
- package/out/electron/electronVersion.js +3 -3
- package/out/electron/electronVersion.js.map +1 -1
- package/out/electron/electronWin.js +1 -1
- package/out/electron/electronWin.js.map +1 -1
- package/out/electron/injectFFMPEG.js +1 -1
- package/out/electron/injectFFMPEG.js.map +1 -1
- package/out/index.d.ts +5 -4
- package/out/index.js +4 -4
- package/out/index.js.map +1 -1
- package/out/macPackager.js +2 -1
- package/out/macPackager.js.map +1 -1
- package/out/options/winOptions.d.ts +89 -4
- package/out/options/winOptions.js.map +1 -1
- package/out/packager.d.ts +1 -1
- package/out/packager.js +12 -12
- package/out/packager.js.map +1 -1
- package/out/platformPackager.d.ts +4 -5
- package/out/platformPackager.js +4 -50
- package/out/platformPackager.js.map +1 -1
- package/out/publish/PublishManager.js +3 -3
- package/out/publish/PublishManager.js.map +1 -1
- package/out/targets/AppxTarget.js +6 -5
- package/out/targets/AppxTarget.js.map +1 -1
- package/out/targets/FpmTarget.js +1 -1
- package/out/targets/FpmTarget.js.map +1 -1
- package/out/targets/nsis/nsisOptions.d.ts +1 -2
- package/out/targets/nsis/nsisOptions.js.map +1 -1
- package/out/util/NodeModuleCopyHelper.js +2 -2
- package/out/util/NodeModuleCopyHelper.js.map +1 -1
- package/out/util/{config.d.ts → config/config.d.ts} +1 -1
- package/out/util/{config.js → config/config.js} +7 -7
- package/out/util/config/config.js.map +1 -0
- package/out/util/config/load.d.ts +21 -0
- package/out/util/config/load.js +128 -0
- package/out/util/config/load.js.map +1 -0
- package/out/util/packageDependencies.d.ts +1 -1
- package/out/util/packageDependencies.js +4 -2
- package/out/util/packageDependencies.js.map +1 -1
- package/out/util/resolve.d.ts +2 -0
- package/out/util/resolve.js +54 -0
- package/out/util/resolve.js.map +1 -0
- package/out/version.d.ts +1 -1
- package/out/version.js +1 -1
- package/out/version.js.map +1 -1
- package/out/winPackager.d.ts +6 -7
- package/out/winPackager.js +28 -103
- package/out/winPackager.js.map +1 -1
- package/package.json +15 -11
- package/scheme.json +150 -2
- package/out/util/config.js.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findAndReadConfig = findAndReadConfig;
|
|
4
|
+
exports.orNullIfFileNotExist = orNullIfFileNotExist;
|
|
5
|
+
exports.orIfFileNotExist = orIfFileNotExist;
|
|
6
|
+
exports.loadConfig = loadConfig;
|
|
7
|
+
exports.getConfig = getConfig;
|
|
8
|
+
exports.loadParentConfig = loadParentConfig;
|
|
9
|
+
exports.loadEnv = loadEnv;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const js_yaml_1 = require("js-yaml");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const dotenv_1 = require("dotenv");
|
|
14
|
+
const config_file_ts_1 = require("config-file-ts");
|
|
15
|
+
const dotenv_expand_1 = require("dotenv-expand");
|
|
16
|
+
const resolve_1 = require("../resolve");
|
|
17
|
+
const builder_util_1 = require("builder-util");
|
|
18
|
+
async function readConfig(configFile, request) {
|
|
19
|
+
const data = await fs_1.promises.readFile(configFile, "utf8");
|
|
20
|
+
let result;
|
|
21
|
+
if (configFile.endsWith(".json5") || configFile.endsWith(".json")) {
|
|
22
|
+
result = require("json5").parse(data);
|
|
23
|
+
}
|
|
24
|
+
else if (configFile.endsWith(".js") || configFile.endsWith(".cjs") || configFile.endsWith(".mjs")) {
|
|
25
|
+
const json = await orNullIfFileNotExist(fs_1.promises.readFile(path.join(process.cwd(), "package.json"), "utf8"));
|
|
26
|
+
const moduleType = json === null ? null : JSON.parse(json).type;
|
|
27
|
+
result = await (0, resolve_1.resolveModule)(moduleType, configFile);
|
|
28
|
+
if (result.default != null) {
|
|
29
|
+
result = result.default;
|
|
30
|
+
}
|
|
31
|
+
if (typeof result === "function") {
|
|
32
|
+
result = result(request);
|
|
33
|
+
}
|
|
34
|
+
result = await Promise.resolve(result);
|
|
35
|
+
}
|
|
36
|
+
else if (configFile.endsWith(".ts")) {
|
|
37
|
+
result = (0, config_file_ts_1.loadTsConfig)(configFile);
|
|
38
|
+
if (typeof result === "function") {
|
|
39
|
+
result = result(request);
|
|
40
|
+
}
|
|
41
|
+
result = await Promise.resolve(result);
|
|
42
|
+
}
|
|
43
|
+
else if (configFile.endsWith(".toml")) {
|
|
44
|
+
result = require("toml").parse(data);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
result = (0, js_yaml_1.load)(data);
|
|
48
|
+
}
|
|
49
|
+
return { result, configFile };
|
|
50
|
+
}
|
|
51
|
+
async function findAndReadConfig(request) {
|
|
52
|
+
const prefix = request.configFilename;
|
|
53
|
+
for (const configFile of [`${prefix}.yml`, `${prefix}.yaml`, `${prefix}.json`, `${prefix}.json5`, `${prefix}.toml`, `${prefix}.js`, `${prefix}.cjs`, `${prefix}.ts`]) {
|
|
54
|
+
const data = await orNullIfFileNotExist(readConfig(path.join(request.projectDir, configFile), request));
|
|
55
|
+
if (data != null) {
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
function orNullIfFileNotExist(promise) {
|
|
62
|
+
return orIfFileNotExist(promise, null);
|
|
63
|
+
}
|
|
64
|
+
function orIfFileNotExist(promise, fallbackValue) {
|
|
65
|
+
return promise.catch(e => {
|
|
66
|
+
if (e.code === "ENOENT" || e.code === "ENOTDIR") {
|
|
67
|
+
return fallbackValue;
|
|
68
|
+
}
|
|
69
|
+
throw e;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async function loadConfig(request) {
|
|
73
|
+
let packageMetadata = request.packageMetadata == null ? null : await request.packageMetadata.value;
|
|
74
|
+
if (packageMetadata == null) {
|
|
75
|
+
const json = await orNullIfFileNotExist(fs_1.promises.readFile(path.join(request.projectDir, "package.json"), "utf8"));
|
|
76
|
+
packageMetadata = json == null ? null : JSON.parse(json);
|
|
77
|
+
}
|
|
78
|
+
const data = packageMetadata == null ? null : packageMetadata[request.packageKey];
|
|
79
|
+
return data == null ? findAndReadConfig(request) : { result: data, configFile: null };
|
|
80
|
+
}
|
|
81
|
+
function getConfig(request, configPath) {
|
|
82
|
+
if (configPath == null) {
|
|
83
|
+
return loadConfig(request);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return readConfig(path.resolve(request.projectDir, configPath), request);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function loadParentConfig(request, spec) {
|
|
90
|
+
let isFileSpec;
|
|
91
|
+
if (spec.startsWith("file:")) {
|
|
92
|
+
spec = spec.substring("file:".length);
|
|
93
|
+
isFileSpec = true;
|
|
94
|
+
}
|
|
95
|
+
let parentConfig = await orNullIfFileNotExist(readConfig(path.resolve(request.projectDir, spec), request));
|
|
96
|
+
if (parentConfig == null && isFileSpec !== true) {
|
|
97
|
+
let resolved = null;
|
|
98
|
+
try {
|
|
99
|
+
resolved = require.resolve(spec);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// ignore
|
|
103
|
+
}
|
|
104
|
+
if (resolved != null) {
|
|
105
|
+
parentConfig = await readConfig(resolved, request);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (parentConfig == null) {
|
|
109
|
+
throw new Error(`Cannot find parent config file: ${spec}`);
|
|
110
|
+
}
|
|
111
|
+
return parentConfig;
|
|
112
|
+
}
|
|
113
|
+
async function loadEnv(envFile) {
|
|
114
|
+
const data = await orNullIfFileNotExist(fs_1.promises.readFile(envFile, "utf8"));
|
|
115
|
+
if (data == null) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const parsed = (0, dotenv_1.parse)(data);
|
|
119
|
+
builder_util_1.log.info({ envFile }, "injecting environment");
|
|
120
|
+
Object.entries(parsed).forEach(([key, value]) => {
|
|
121
|
+
if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
|
|
122
|
+
process.env[key] = value;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
(0, dotenv_expand_1.expand)({ parsed });
|
|
126
|
+
return parsed;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/util/config/load.ts"],"names":[],"mappings":";;AA6CA,8CAUC;AAED,oDAEC;AAED,4CAOC;AAUD,gCASC;AAED,8BAMC;AAED,4CA0BC;AAED,0BAgBC;AA7ID,2BAAmC;AACnC,qCAA8B;AAC9B,6BAA4B;AAE5B,mCAA0C;AAC1C,mDAA6C;AAC7C,iDAAwD;AACxD,wCAA0C;AAC1C,+CAAkC;AAOlC,KAAK,UAAU,UAAU,CAAI,UAAkB,EAAE,OAA0B;IACzE,MAAM,IAAI,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAClD,IAAI,MAAW,CAAA;IACf,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;SAAM,IAAI,UAAU,CAAC,QAAQ,CAA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,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAC1B,CAAC;IACH,CAAC,CAAC,CAAA;IACF,IAAA,sBAAM,EAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAClB,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { promises as fs } from \"fs\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport { Lazy } from \"lazy-val\"\nimport { parse as parseEnv } from \"dotenv\"\nimport { loadTsConfig } from \"config-file-ts\"\nimport { DotenvParseInput, expand } from \"dotenv-expand\"\nimport { resolveModule } from \"../resolve\"\nimport { log } from \"builder-util\"\n\nexport interface ReadConfigResult<T> {\n readonly result: T\n readonly configFile: string | null\n}\n\nasync function readConfig<T>(configFile: string, request: ReadConfigRequest): Promise<ReadConfigResult<T>> {\n const data = await fs.readFile(configFile, \"utf8\")\n let result: any\n if (configFile.endsWith(\".json5\") || configFile.endsWith(\".json\")) {\n result = require(\"json5\").parse(data)\n } else if (configFile.endsWith(\".js\") || configFile.endsWith(\".cjs\") || configFile.endsWith(\".mjs\")) {\n const json = await orNullIfFileNotExist(fs.readFile(path.join(process.cwd(), \"package.json\"), \"utf8\"))\n const moduleType = json === null ? null : JSON.parse(json).type\n result = await resolveModule(moduleType, configFile)\n if (result.default != null) {\n result = result.default\n }\n if (typeof result === \"function\") {\n result = result(request)\n }\n result = await Promise.resolve(result)\n } else if (configFile.endsWith(\".ts\")) {\n result = loadTsConfig(configFile)\n if (typeof result === \"function\") {\n result = result(request)\n }\n result = await Promise.resolve(result)\n } else if (configFile.endsWith(\".toml\")) {\n result = require(\"toml\").parse(data)\n } else {\n result = load(data)\n }\n return { result, configFile }\n}\n\nexport async function findAndReadConfig<T>(request: ReadConfigRequest): Promise<ReadConfigResult<T> | null> {\n const prefix = request.configFilename\n for (const configFile of [`${prefix}.yml`, `${prefix}.yaml`, `${prefix}.json`, `${prefix}.json5`, `${prefix}.toml`, `${prefix}.js`, `${prefix}.cjs`, `${prefix}.ts`]) {\n const data = await orNullIfFileNotExist(readConfig<T>(path.join(request.projectDir, configFile), request))\n if (data != null) {\n return data\n }\n }\n\n return null\n}\n\nexport function orNullIfFileNotExist<T>(promise: Promise<T>): Promise<T | null> {\n return orIfFileNotExist(promise, null)\n}\n\nexport function orIfFileNotExist<T>(promise: Promise<T>, fallbackValue: T): Promise<T> {\n return promise.catch(e => {\n if (e.code === \"ENOENT\" || e.code === \"ENOTDIR\") {\n return fallbackValue\n }\n throw e\n })\n}\n\nexport interface ReadConfigRequest {\n packageKey: string\n configFilename: string\n\n projectDir: string\n packageMetadata: Lazy<{ [key: string]: any } | null> | null\n}\n\nexport async function loadConfig<T>(request: ReadConfigRequest): Promise<ReadConfigResult<T> | null> {\n let packageMetadata = request.packageMetadata == null ? null : await request.packageMetadata.value\n if (packageMetadata == null) {\n const json = await orNullIfFileNotExist(fs.readFile(path.join(request.projectDir, \"package.json\"), \"utf8\"))\n packageMetadata = json == null ? null : JSON.parse(json)\n }\n\n const data: T = packageMetadata == null ? null : packageMetadata[request.packageKey]\n return data == null ? findAndReadConfig<T>(request) : { result: data, configFile: null }\n}\n\nexport function getConfig<T>(request: ReadConfigRequest, configPath?: string | null): Promise<ReadConfigResult<T> | null> {\n if (configPath == null) {\n return loadConfig<T>(request)\n } else {\n return readConfig<T>(path.resolve(request.projectDir, configPath), request)\n }\n}\n\nexport async function loadParentConfig<T>(request: ReadConfigRequest, spec: string): Promise<ReadConfigResult<T>> {\n let isFileSpec: boolean | undefined\n if (spec.startsWith(\"file:\")) {\n spec = spec.substring(\"file:\".length)\n isFileSpec = true\n }\n\n let parentConfig = await orNullIfFileNotExist(readConfig<T>(path.resolve(request.projectDir, spec), request))\n if (parentConfig == null && isFileSpec !== true) {\n let resolved: string | null = null\n try {\n resolved = require.resolve(spec)\n } catch (e) {\n // ignore\n }\n\n if (resolved != null) {\n parentConfig = await readConfig<T>(resolved, request)\n }\n }\n\n if (parentConfig == null) {\n throw new Error(`Cannot find parent config file: ${spec}`)\n }\n\n return parentConfig\n}\n\nexport async function loadEnv(envFile: string) {\n const data = await orNullIfFileNotExist(fs.readFile(envFile, \"utf8\"))\n if (data == null) {\n return null\n }\n\n const parsed = parseEnv<DotenvParseInput>(data)\n\n log.info({ envFile }, \"injecting environment\")\n Object.entries(parsed).forEach(([key, value]) => {\n if (!Object.prototype.hasOwnProperty.call(process.env, key)) {\n process.env[key] = value\n }\n })\n expand({ parsed })\n return parsed\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Lazy } from "lazy-val";
|
|
2
|
-
export declare function createLazyProductionDeps(projectDir: string, excludedDependencies: Array<string> | null): Lazy<
|
|
2
|
+
export declare function createLazyProductionDeps<T extends boolean>(projectDir: string, excludedDependencies: Array<string> | null, flatten: T): Lazy<(T extends true ? NodeModuleInfo : NodeModuleDirInfo)[]>;
|
|
3
3
|
export interface NodeModuleDirInfo {
|
|
4
4
|
readonly dir: string;
|
|
5
5
|
readonly deps: Array<NodeModuleInfo>;
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createLazyProductionDeps = createLazyProductionDeps;
|
|
4
4
|
const lazy_val_1 = require("lazy-val");
|
|
5
5
|
const appBuilder_1 = require("./appBuilder");
|
|
6
|
-
function createLazyProductionDeps(projectDir, excludedDependencies) {
|
|
6
|
+
function createLazyProductionDeps(projectDir, excludedDependencies, flatten) {
|
|
7
7
|
return new lazy_val_1.Lazy(async () => {
|
|
8
|
-
const args = ["node-dep-tree", "--
|
|
8
|
+
const args = ["node-dep-tree", "--dir", projectDir];
|
|
9
|
+
if (flatten)
|
|
10
|
+
args.push("--flatten");
|
|
9
11
|
if (excludedDependencies != null) {
|
|
10
12
|
for (const name of excludedDependencies) {
|
|
11
13
|
args.push("--exclude-dep", name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageDependencies.js","sourceRoot":"","sources":["../../src/util/packageDependencies.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"packageDependencies.js","sourceRoot":"","sources":["../../src/util/packageDependencies.ts"],"names":[],"mappings":";;AAGA,4DAWC;AAdD,uCAA+B;AAC/B,6CAAsD;AAEtD,SAAgB,wBAAwB,CAAoB,UAAkB,EAAE,oBAA0C,EAAE,OAAU;IACpI,OAAO,IAAI,eAAI,CAAC,KAAK,IAAI,EAAE;QACzB,MAAM,IAAI,GAAG,CAAC,eAAe,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;QACnD,IAAI,OAAO;YAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACnC,IAAI,oBAAoB,IAAI,IAAI,EAAE,CAAC;YACjC,KAAK,MAAM,IAAI,IAAI,oBAAoB,EAAE,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;YAClC,CAAC;QACH,CAAC;QACD,OAAO,IAAA,oCAAuB,EAA6D,IAAI,CAAC,CAAA;IAClG,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { Lazy } from \"lazy-val\"\nimport { executeAppBuilderAsJson } from \"./appBuilder\"\n\nexport function createLazyProductionDeps<T extends boolean>(projectDir: string, excludedDependencies: Array<string> | null, flatten: T) {\n return new Lazy(async () => {\n const args = [\"node-dep-tree\", \"--dir\", projectDir]\n if (flatten) args.push(\"--flatten\")\n if (excludedDependencies != null) {\n for (const name of excludedDependencies) {\n args.push(\"--exclude-dep\", name)\n }\n }\n return executeAppBuilderAsJson<Array<T extends true ? NodeModuleInfo : NodeModuleDirInfo>>(args)\n })\n}\n\nexport interface NodeModuleDirInfo {\n readonly dir: string\n readonly deps: Array<NodeModuleInfo>\n}\n\nexport interface NodeModuleInfo {\n readonly name: string\n readonly version: string\n readonly dir: string\n readonly conflictDependency: Array<NodeModuleInfo>\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveModule = resolveModule;
|
|
4
|
+
exports.resolveFunction = resolveFunction;
|
|
5
|
+
const log_1 = require("builder-util/out/log");
|
|
6
|
+
const debug_1 = require("debug");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
async function resolveModule(type, name) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const extension = path.extname(name).toLowerCase();
|
|
12
|
+
const isModuleType = type === "module";
|
|
13
|
+
try {
|
|
14
|
+
if (extension === ".mjs" || (extension === ".js" && isModuleType)) {
|
|
15
|
+
const fileUrl = (0, url_1.pathToFileURL)(name).href;
|
|
16
|
+
return await eval("import('" + fileUrl + "')");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
log_1.log.debug({ moduleName: name, message: (_a = error.message) !== null && _a !== void 0 ? _a : error.stack }, "Unable to dynamically import, falling back to `require`");
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return require(name);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
log_1.log.error({ moduleName: name, message: (_b = error.message) !== null && _b !== void 0 ? _b : error.stack }, "Unable to `require`");
|
|
27
|
+
throw new Error((_c = error.message) !== null && _c !== void 0 ? _c : error.stack);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function resolveFunction(type, executor, name) {
|
|
31
|
+
if (executor == null || typeof executor !== "string") {
|
|
32
|
+
return executor;
|
|
33
|
+
}
|
|
34
|
+
let p = executor;
|
|
35
|
+
if (p.startsWith(".")) {
|
|
36
|
+
p = path.resolve(p);
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
p = require.resolve(p);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
(0, debug_1.default)(e);
|
|
43
|
+
p = path.resolve(p);
|
|
44
|
+
}
|
|
45
|
+
const m = await resolveModule(type, p);
|
|
46
|
+
const namedExport = m[name];
|
|
47
|
+
if (namedExport == null) {
|
|
48
|
+
return m.default || m;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return namedExport;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/util/resolve.ts"],"names":[],"mappings":";;AAKA,sCAiBC;AAED,0CAwBC;AAhDD,8CAA0C;AAC1C,iCAAyB;AACzB,6BAA4B;AAC5B,6BAAmC;AAE5B,KAAK,UAAU,aAAa,CAAI,IAAwB,EAAE,IAAY;;IAC3E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;IAClD,MAAM,YAAY,GAAG,IAAI,KAAK,QAAQ,CAAA;IACtC,IAAI,CAAC;QACH,IAAI,SAAS,KAAK,MAAM,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI,YAAY,CAAC,EAAE,CAAC;YAClE,MAAM,OAAO,GAAG,IAAA,mBAAa,EAAC,IAAI,CAAC,CAAC,IAAI,CAAA;YACxC,OAAO,MAAM,IAAI,CAAC,UAAU,GAAG,OAAO,GAAG,IAAI,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,SAAG,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,KAAK,EAAE,EAAE,yDAAyD,CAAC,CAAA;IACnI,CAAC;IACD,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,SAAG,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,KAAK,EAAE,EAAE,qBAAqB,CAAC,CAAA;QAC7F,MAAM,IAAI,KAAK,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,KAAK,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,eAAe,CAAI,IAAwB,EAAE,QAAoB,EAAE,IAAY;IACnG,IAAI,QAAQ,IAAI,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACrD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,IAAI,CAAC,GAAG,QAAkB,CAAA;IAC1B,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;IAED,IAAI,CAAC;QACH,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAA,eAAK,EAAC,CAAC,CAAC,CAAA;QACR,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;IAED,MAAM,CAAC,GAAQ,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IAC3C,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;IAC3B,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,CAAC,CAAC,OAAO,IAAI,CAAC,CAAA;IACvB,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAAA;IACpB,CAAC;AACH,CAAC","sourcesContent":["import { log } from \"builder-util/out/log\"\nimport debug from \"debug\"\nimport * as path from \"path\"\nimport { pathToFileURL } from \"url\"\n\nexport async function resolveModule<T>(type: string | undefined, name: string): Promise<T> {\n const extension = path.extname(name).toLowerCase()\n const isModuleType = type === \"module\"\n try {\n if (extension === \".mjs\" || (extension === \".js\" && isModuleType)) {\n const fileUrl = pathToFileURL(name).href\n return await eval(\"import('\" + fileUrl + \"')\")\n }\n } catch (error: any) {\n log.debug({ moduleName: name, message: error.message ?? error.stack }, \"Unable to dynamically import, falling back to `require`\")\n }\n try {\n return require(name)\n } catch (error: any) {\n log.error({ moduleName: name, message: error.message ?? error.stack }, \"Unable to `require`\")\n throw new Error(error.message ?? error.stack)\n }\n}\n\nexport async function resolveFunction<T>(type: string | undefined, executor: T | string, name: string): Promise<T> {\n if (executor == null || typeof executor !== \"string\") {\n return executor\n }\n\n let p = executor as string\n if (p.startsWith(\".\")) {\n p = path.resolve(p)\n }\n\n try {\n p = require.resolve(p)\n } catch (e: any) {\n debug(e)\n p = path.resolve(p)\n }\n\n const m: any = await resolveModule(type, p)\n const namedExport = m[name]\n if (namedExport == null) {\n return m.default || m\n } else {\n return namedExport\n }\n}\n"]}
|
package/out/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "25.
|
|
1
|
+
export declare const PACKAGE_VERSION = "25.1.1";
|
package/out/version.js
CHANGED
package/out/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"25.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const PACKAGE_VERSION = \"25.1.1\"\n"]}
|
package/out/winPackager.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { Arch, FileTransformer } from "builder-util";
|
|
2
|
-
import { MemoLazy } from "builder-util-runtime";
|
|
3
2
|
import { Lazy } from "lazy-val";
|
|
4
|
-
import {
|
|
3
|
+
import { WindowsSignToolManager } from "./codeSign/windowsSignToolManager";
|
|
5
4
|
import { AfterPackContext } from "./configuration";
|
|
6
5
|
import { Target } from "./core";
|
|
7
6
|
import { RequestedExecutionLevel, WindowsConfiguration } from "./options/winOptions";
|
|
8
7
|
import { Packager } from "./packager";
|
|
9
8
|
import { PlatformPackager } from "./platformPackager";
|
|
10
9
|
import { VmManager } from "./vm/vm";
|
|
10
|
+
import { WindowsSignAzureManager } from "./codeSign/windowsSignAzureManager";
|
|
11
11
|
export declare class WinPackager extends PlatformPackager<WindowsConfiguration> {
|
|
12
|
-
|
|
13
|
-
private _iconPath;
|
|
12
|
+
_iconPath: Lazy<string | null>;
|
|
14
13
|
readonly vm: Lazy<VmManager>;
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
14
|
+
readonly signtoolManager: Lazy<WindowsSignToolManager>;
|
|
15
|
+
readonly azureSignManager: Lazy<WindowsSignAzureManager>;
|
|
17
16
|
get isForceCodeSigningVerification(): boolean;
|
|
18
17
|
constructor(info: Packager);
|
|
19
18
|
get defaultTarget(): Array<string>;
|
|
20
|
-
protected doGetCscPassword(): string | undefined | null;
|
|
21
19
|
createTargets(targets: Array<string>, mapper: (name: string, factory: (outDir: string) => Target) => void): void;
|
|
22
20
|
getIconPath(): Promise<string | null>;
|
|
21
|
+
doGetCscPassword(): string | undefined | null;
|
|
23
22
|
sign(file: string, logMessagePrefix?: string): Promise<boolean>;
|
|
24
23
|
private doSign;
|
|
25
24
|
signAndEditResources(file: string, arch: Arch, outDir: string, internalName?: string | null, requestedExecutionLevel?: RequestedExecutionLevel | null): Promise<void>;
|
package/out/winPackager.js
CHANGED
|
@@ -3,14 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WinPackager = void 0;
|
|
4
4
|
const bluebird_lst_1 = require("bluebird-lst");
|
|
5
5
|
const builder_util_1 = require("builder-util");
|
|
6
|
-
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
7
6
|
const crypto_1 = require("crypto");
|
|
8
7
|
const promises_1 = require("fs/promises");
|
|
9
8
|
const isCI = require("is-ci");
|
|
10
9
|
const lazy_val_1 = require("lazy-val");
|
|
11
10
|
const path = require("path");
|
|
12
|
-
const
|
|
13
|
-
const windowsCodeSign_1 = require("./codeSign/windowsCodeSign");
|
|
11
|
+
const windowsSignToolManager_1 = require("./codeSign/windowsSignToolManager");
|
|
14
12
|
const core_1 = require("./core");
|
|
15
13
|
const platformPackager_1 = require("./platformPackager");
|
|
16
14
|
const NsisTarget_1 = require("./targets/nsis/NsisTarget");
|
|
@@ -22,94 +20,25 @@ const flags_1 = require("./util/flags");
|
|
|
22
20
|
const timer_1 = require("./util/timer");
|
|
23
21
|
const vm_1 = require("./vm/vm");
|
|
24
22
|
const wine_1 = require("./wine");
|
|
23
|
+
const windowsCodeSign_1 = require("./codeSign/windowsCodeSign");
|
|
24
|
+
const windowsSignAzureManager_1 = require("./codeSign/windowsSignAzureManager");
|
|
25
25
|
class WinPackager extends platformPackager_1.PlatformPackager {
|
|
26
26
|
get isForceCodeSigningVerification() {
|
|
27
27
|
return this.platformSpecificBuildOptions.verifyUpdateCodeSignature !== false;
|
|
28
28
|
}
|
|
29
29
|
constructor(info) {
|
|
30
30
|
super(info, core_1.Platform.WINDOWS);
|
|
31
|
-
this.cscInfo = new builder_util_runtime_1.MemoLazy(() => this.platformSpecificBuildOptions, platformSpecificBuildOptions => {
|
|
32
|
-
if (platformSpecificBuildOptions.certificateSubjectName != null || platformSpecificBuildOptions.certificateSha1 != null) {
|
|
33
|
-
return this.vm.value
|
|
34
|
-
.then(vm => (0, windowsCodeSign_1.getCertificateFromStoreInfo)(platformSpecificBuildOptions, vm))
|
|
35
|
-
.catch((e) => {
|
|
36
|
-
// https://github.com/electron-userland/electron-builder/pull/2397
|
|
37
|
-
if (platformSpecificBuildOptions.sign == null) {
|
|
38
|
-
throw e;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
builder_util_1.log.debug({ error: e }, "getCertificateFromStoreInfo error");
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
const certificateFile = platformSpecificBuildOptions.certificateFile;
|
|
47
|
-
if (certificateFile != null) {
|
|
48
|
-
const certificatePassword = this.getCscPassword();
|
|
49
|
-
return Promise.resolve({
|
|
50
|
-
file: certificateFile,
|
|
51
|
-
password: certificatePassword == null ? null : certificatePassword.trim(),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
const cscLink = this.getCscLink("WIN_CSC_LINK");
|
|
55
|
-
if (cscLink == null || cscLink === "") {
|
|
56
|
-
return Promise.resolve(null);
|
|
57
|
-
}
|
|
58
|
-
return ((0, codesign_1.importCertificate)(cscLink, this.info.tempDirManager, this.projectDir)
|
|
59
|
-
// before then
|
|
60
|
-
.catch((e) => {
|
|
61
|
-
if (e instanceof builder_util_1.InvalidConfigurationError) {
|
|
62
|
-
throw new builder_util_1.InvalidConfigurationError(`Env WIN_CSC_LINK is not correct, cannot resolve: ${e.message}`);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
throw e;
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
.then(path => {
|
|
69
|
-
return {
|
|
70
|
-
file: path,
|
|
71
|
-
password: this.getCscPassword(),
|
|
72
|
-
};
|
|
73
|
-
}));
|
|
74
|
-
});
|
|
75
31
|
this._iconPath = new lazy_val_1.Lazy(() => this.getOrConvertIcon("ico"));
|
|
76
32
|
this.vm = new lazy_val_1.Lazy(() => (process.platform === "win32" ? Promise.resolve(new vm_1.VmManager()) : (0, vm_1.getWindowsVm)(this.debugLogger)));
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
else if (publisherName != null) {
|
|
83
|
-
return (0, builder_util_1.asArray)(publisherName);
|
|
84
|
-
}
|
|
85
|
-
const certInfo = await this.lazyCertInfo.value;
|
|
86
|
-
return certInfo == null ? null : [certInfo.commonName];
|
|
87
|
-
});
|
|
88
|
-
this.lazyCertInfo = new builder_util_runtime_1.MemoLazy(() => this.cscInfo, async (csc) => {
|
|
89
|
-
const cscInfo = await csc.value;
|
|
90
|
-
if (cscInfo == null) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
if ("subject" in cscInfo) {
|
|
94
|
-
const bloodyMicrosoftSubjectDn = cscInfo.subject;
|
|
95
|
-
return {
|
|
96
|
-
commonName: (0, builder_util_runtime_1.parseDn)(bloodyMicrosoftSubjectDn).get("CN"),
|
|
97
|
-
bloodyMicrosoftSubjectDn,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const cscFile = cscInfo.file;
|
|
101
|
-
if (cscFile == null) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
return await (0, windowsCodeSign_1.getCertInfo)(cscFile, cscInfo.password || "");
|
|
105
|
-
});
|
|
33
|
+
this.signtoolManager = new lazy_val_1.Lazy(() => Promise.resolve(new windowsSignToolManager_1.WindowsSignToolManager(this)));
|
|
34
|
+
this.azureSignManager = new lazy_val_1.Lazy(() => Promise.resolve(new windowsSignAzureManager_1.WindowsSignAzureManager(this)).then(async (manager) => {
|
|
35
|
+
await manager.initializeProviderModules();
|
|
36
|
+
return manager;
|
|
37
|
+
}));
|
|
106
38
|
}
|
|
107
39
|
get defaultTarget() {
|
|
108
40
|
return ["nsis"];
|
|
109
41
|
}
|
|
110
|
-
doGetCscPassword() {
|
|
111
|
-
return (0, platformPackager_1.chooseNotNull)((0, platformPackager_1.chooseNotNull)(this.platformSpecificBuildOptions.certificatePassword, process.env.WIN_CSC_KEY_PASSWORD), super.doGetCscPassword());
|
|
112
|
-
}
|
|
113
42
|
createTargets(targets, mapper) {
|
|
114
43
|
let copyElevateHelper;
|
|
115
44
|
const getCopyElevateHelper = () => {
|
|
@@ -163,17 +92,20 @@ class WinPackager extends platformPackager_1.PlatformPackager {
|
|
|
163
92
|
getIconPath() {
|
|
164
93
|
return this._iconPath.value;
|
|
165
94
|
}
|
|
95
|
+
doGetCscPassword() {
|
|
96
|
+
var _a;
|
|
97
|
+
return (0, platformPackager_1.chooseNotNull)((0, platformPackager_1.chooseNotNull)((0, platformPackager_1.chooseNotNull)((_a = this.platformSpecificBuildOptions.signtoolOptions) === null || _a === void 0 ? void 0 : _a.certificatePassword, this.platformSpecificBuildOptions.certificatePassword), process.env.WIN_CSC_KEY_PASSWORD), super.doGetCscPassword());
|
|
98
|
+
}
|
|
166
99
|
async sign(file, logMessagePrefix) {
|
|
100
|
+
var _a;
|
|
167
101
|
const signOptions = {
|
|
168
102
|
path: file,
|
|
169
|
-
name: this.appInfo.productName,
|
|
170
|
-
site: await this.appInfo.computePackageUrl(),
|
|
171
103
|
options: this.platformSpecificBuildOptions,
|
|
172
104
|
};
|
|
173
|
-
const cscInfo = await this.cscInfo.value;
|
|
105
|
+
const cscInfo = await (await this.signtoolManager.value).cscInfo.value;
|
|
174
106
|
if (cscInfo == null) {
|
|
175
|
-
if (this.platformSpecificBuildOptions.sign != null) {
|
|
176
|
-
return (0, windowsCodeSign_1.
|
|
107
|
+
if ((0, platformPackager_1.chooseNotNull)((_a = this.platformSpecificBuildOptions.signtoolOptions) === null || _a === void 0 ? void 0 : _a.sign, this.platformSpecificBuildOptions.sign) != null) {
|
|
108
|
+
return (0, windowsCodeSign_1.signWindows)(signOptions, this);
|
|
177
109
|
}
|
|
178
110
|
else if (this.forceCodeSigning) {
|
|
179
111
|
throw new builder_util_1.InvalidConfigurationError(`App is not signed and "forceCodeSigning" is set to true, please ensure that code signing configuration is correct, please see https://electron.build/code-signing`);
|
|
@@ -201,31 +133,24 @@ class WinPackager extends platformPackager_1.PlatformPackager {
|
|
|
201
133
|
}
|
|
202
134
|
return this.doSign({
|
|
203
135
|
...signOptions,
|
|
204
|
-
cscInfo,
|
|
205
136
|
options: {
|
|
206
137
|
...this.platformSpecificBuildOptions,
|
|
207
138
|
},
|
|
208
139
|
});
|
|
209
140
|
}
|
|
210
141
|
async doSign(options) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
142
|
+
return (0, builder_util_1.retry)(() => (0, windowsCodeSign_1.signWindows)(options, this), 3, 500, 500, 0, (e) => {
|
|
143
|
+
// https://github.com/electron-userland/electron-builder/issues/1414
|
|
144
|
+
const message = e.message;
|
|
145
|
+
if (message != null && message.includes("Couldn't resolve host name")) {
|
|
146
|
+
builder_util_1.log.warn({ error: message }, `cannot sign`);
|
|
214
147
|
return true;
|
|
215
148
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const message = e.message;
|
|
219
|
-
if (message != null && message.includes("Couldn't resolve host name")) {
|
|
220
|
-
builder_util_1.log.warn({ error: message, attempt: i + 1 }, `cannot sign`);
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
throw e;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return false;
|
|
149
|
+
return false;
|
|
150
|
+
});
|
|
227
151
|
}
|
|
228
152
|
async signAndEditResources(file, arch, outDir, internalName, requestedExecutionLevel) {
|
|
153
|
+
var _a, _b;
|
|
229
154
|
const appInfo = this.appInfo;
|
|
230
155
|
const files = [];
|
|
231
156
|
const args = [
|
|
@@ -258,7 +183,7 @@ class WinPackager extends platformPackager_1.PlatformPackager {
|
|
|
258
183
|
args.push("--set-icon", it);
|
|
259
184
|
});
|
|
260
185
|
const config = this.config;
|
|
261
|
-
const cscInfoForCacheDigest = !(0, flags_1.isBuildCacheEnabled)() || isCI || config.electronDist != null ? null : await this.cscInfo.value;
|
|
186
|
+
const cscInfoForCacheDigest = !(0, flags_1.isBuildCacheEnabled)() || isCI || config.electronDist != null ? null : await (await this.signtoolManager.value).cscInfo.value;
|
|
262
187
|
let buildCacheManager = null;
|
|
263
188
|
// resources editing doesn't change executable for the same input and executed quickly - no need to complicate
|
|
264
189
|
if (cscInfoForCacheDigest != null) {
|
|
@@ -271,8 +196,8 @@ class WinPackager extends platformPackager_1.PlatformPackager {
|
|
|
271
196
|
hash.update(config.electronVersion || "no electronVersion");
|
|
272
197
|
hash.update(JSON.stringify(this.platformSpecificBuildOptions));
|
|
273
198
|
hash.update(JSON.stringify(args));
|
|
274
|
-
hash.update(this.platformSpecificBuildOptions.certificateSha1 || "no certificateSha1");
|
|
275
|
-
hash.update(this.platformSpecificBuildOptions.certificateSubjectName || "no subjectName");
|
|
199
|
+
hash.update((0, platformPackager_1.chooseNotNull)((_a = this.platformSpecificBuildOptions.signtoolOptions) === null || _a === void 0 ? void 0 : _a.certificateSha1, this.platformSpecificBuildOptions.certificateSha1) || "no certificateSha1");
|
|
200
|
+
hash.update((0, platformPackager_1.chooseNotNull)((_b = this.platformSpecificBuildOptions.signtoolOptions) === null || _b === void 0 ? void 0 : _b.certificateSubjectName, this.platformSpecificBuildOptions.certificateSubjectName) || "no subjectName");
|
|
276
201
|
buildCacheManager = new cacheManager_1.BuildCacheManager(outDir, file, arch);
|
|
277
202
|
if (await buildCacheManager.copyIfValid(await (0, cacheManager_1.digest)(hash, files))) {
|
|
278
203
|
timer.end();
|
|
@@ -286,7 +211,7 @@ class WinPackager extends platformPackager_1.PlatformPackager {
|
|
|
286
211
|
await (0, builder_util_1.executeAppBuilder)(["rcedit", "--args", JSON.stringify(args)], undefined /* child-process */, {}, 3 /* retry three times */);
|
|
287
212
|
}
|
|
288
213
|
else if (this.info.framework.name === "electron") {
|
|
289
|
-
const vendorPath = await (0,
|
|
214
|
+
const vendorPath = await (0, windowsSignToolManager_1.getSignVendorPath)();
|
|
290
215
|
await (0, wine_1.execWine)(path.join(vendorPath, "rcedit-ia32.exe"), path.join(vendorPath, "rcedit-x64.exe"), args);
|
|
291
216
|
}
|
|
292
217
|
await this.sign(file);
|