main funcions fixes

This commit is contained in:
2025-09-29 22:06:11 +09:00
parent 40e016e128
commit c8c3274527
7995 changed files with 1517998 additions and 1057 deletions

View File

@@ -0,0 +1,25 @@
import { Arch } from "builder-util";
import { PackagerOptions, Platform } from "app-builder-lib";
import { PublishOptions } from "electron-publish";
import * as yargs from "yargs";
export declare function createYargs(): yargs.Argv<unknown>;
export interface BuildOptions extends PackagerOptions, PublishOptions {
}
export interface CliOptions extends PackagerOptions, PublishOptions {
x64?: boolean;
ia32?: boolean;
armv7l?: boolean;
arm64?: boolean;
universal?: boolean;
dir?: boolean;
}
/** @private */
export declare function normalizeOptions(args: CliOptions): BuildOptions;
/** @private */
export declare function coerceTypes(host: any): any;
export declare function createTargets(platforms: Array<Platform>, type?: string | null, arch?: string | null): Map<Platform, Map<Arch, Array<string>>>;
export declare function build(rawOptions?: CliOptions): Promise<Array<string>>;
/**
* @private
*/
export declare function configureBuildCommand(yargs: yargs.Argv): yargs.Argv;

View File

@@ -0,0 +1,268 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createYargs = createYargs;
exports.normalizeOptions = normalizeOptions;
exports.coerceTypes = coerceTypes;
exports.createTargets = createTargets;
exports.build = build;
exports.configureBuildCommand = configureBuildCommand;
const builder_util_1 = require("builder-util");
const chalk = require("chalk");
const app_builder_lib_1 = require("app-builder-lib");
const yargs = require("yargs");
function createYargs() {
return yargs.parserConfiguration({
"camel-case-expansion": false,
});
}
/** @private */
function normalizeOptions(args) {
if (args.targets != null) {
return args;
}
const targets = new Map();
function processTargets(platform, types) {
function commonArch(currentIfNotSpecified) {
const result = Array();
if (args.x64) {
result.push(builder_util_1.Arch.x64);
}
if (args.armv7l) {
result.push(builder_util_1.Arch.armv7l);
}
if (args.arm64) {
result.push(builder_util_1.Arch.arm64);
}
if (args.ia32) {
result.push(builder_util_1.Arch.ia32);
}
if (args.universal) {
result.push(builder_util_1.Arch.universal);
}
return result.length === 0 && currentIfNotSpecified ? [(0, builder_util_1.archFromString)(process.arch)] : result;
}
let archToType = targets.get(platform);
if (archToType == null) {
archToType = new Map();
targets.set(platform, archToType);
}
if (types.length === 0) {
const defaultTargetValue = args.dir ? [app_builder_lib_1.DIR_TARGET] : [];
for (const arch of commonArch(args.dir === true)) {
archToType.set(arch, defaultTargetValue);
}
return;
}
for (const type of types) {
const suffixPos = type.lastIndexOf(":");
if (suffixPos > 0) {
(0, builder_util_1.addValue)(archToType, (0, builder_util_1.archFromString)(type.substring(suffixPos + 1)), type.substring(0, suffixPos));
}
else {
for (const arch of commonArch(true)) {
(0, builder_util_1.addValue)(archToType, arch, type);
}
}
}
}
if (args.mac != null) {
processTargets(app_builder_lib_1.Platform.MAC, args.mac);
}
if (args.linux != null) {
processTargets(app_builder_lib_1.Platform.LINUX, args.linux);
}
if (args.win != null) {
processTargets(app_builder_lib_1.Platform.WINDOWS, args.win);
}
if (targets.size === 0) {
processTargets(app_builder_lib_1.Platform.current(), []);
}
const result = { ...args };
result.targets = targets;
delete result.dir;
delete result.mac;
delete result.linux;
delete result.win;
const r = result;
delete r.m;
delete r.o;
delete r.l;
delete r.w;
delete r.windows;
delete r.macos;
delete r.$0;
delete r._;
delete r.version;
delete r.help;
delete r.c;
delete r.p;
delete r.pd;
delete result.ia32;
delete result.x64;
delete result.armv7l;
delete result.arm64;
delete result.universal;
let config = result.config;
// config is array when combining dot-notation values with a config file value
// https://github.com/electron-userland/electron-builder/issues/2016
if (Array.isArray(config)) {
const newConfig = {};
for (const configItem of config) {
if (typeof configItem === "object") {
(0, builder_util_1.deepAssign)(newConfig, configItem);
}
else if (typeof configItem === "string") {
newConfig.extends = configItem;
}
}
config = newConfig;
result.config = newConfig;
}
// AJV cannot coerce "null" string to null if string is also allowed (because null string is a valid value)
if (config != null && typeof config !== "string") {
if (config.extraMetadata != null) {
coerceTypes(config.extraMetadata);
}
// ability to disable code sign using -c.mac.identity=null
if (config.mac != null) {
coerceValue(config.mac, "identity");
}
// fix Boolean type by coerceTypes
if (config.nsis != null) {
coerceTypes(config.nsis);
}
if (config.nsisWeb != null) {
coerceTypes(config.nsisWeb);
}
}
if ("project" in r && !("projectDir" in result)) {
result.projectDir = r.project;
}
delete r.project;
return result;
}
function coerceValue(host, key) {
const value = host[key];
if (value === "true") {
host[key] = true;
}
else if (value === "false") {
host[key] = false;
}
else if (value === "null") {
host[key] = null;
}
else if (key === "version" && typeof value === "number") {
host[key] = value.toString();
}
else if (value != null && typeof value === "object") {
coerceTypes(value);
}
}
/** @private */
function coerceTypes(host) {
for (const key of Object.getOwnPropertyNames(host)) {
coerceValue(host, key);
}
return host;
}
function createTargets(platforms, type, arch) {
const targets = new Map();
for (const platform of platforms) {
const archs = arch === "all" ? (platform === app_builder_lib_1.Platform.MAC ? [builder_util_1.Arch.x64, builder_util_1.Arch.arm64, builder_util_1.Arch.universal] : [builder_util_1.Arch.x64, builder_util_1.Arch.ia32]) : [(0, builder_util_1.archFromString)(arch == null ? process.arch : arch)];
const archToType = new Map();
targets.set(platform, archToType);
for (const arch of archs) {
archToType.set(arch, type == null ? [] : [type]);
}
}
return targets;
}
function build(rawOptions) {
const buildOptions = normalizeOptions(rawOptions || {});
return (0, app_builder_lib_1.build)(buildOptions, new app_builder_lib_1.Packager(buildOptions));
}
/**
* @private
*/
function configureBuildCommand(yargs) {
const publishGroup = "Publishing:";
const buildGroup = "Building:";
return yargs
.option("mac", {
group: buildGroup,
alias: ["m", "o", "macos"],
description: `Build for macOS, accepts target list (see ${chalk.underline("https://goo.gl/5uHuzj")}).`,
type: "array",
})
.option("linux", {
group: buildGroup,
alias: "l",
description: `Build for Linux, accepts target list (see ${chalk.underline("https://goo.gl/4vwQad")})`,
type: "array",
})
.option("win", {
group: buildGroup,
alias: ["w", "windows"],
description: `Build for Windows, accepts target list (see ${chalk.underline("https://goo.gl/jYsTEJ")})`,
type: "array",
})
.option("x64", {
group: buildGroup,
description: "Build for x64",
type: "boolean",
})
.option("ia32", {
group: buildGroup,
description: "Build for ia32",
type: "boolean",
})
.option("armv7l", {
group: buildGroup,
description: "Build for armv7l",
type: "boolean",
})
.option("arm64", {
group: buildGroup,
description: "Build for arm64",
type: "boolean",
})
.option("universal", {
group: buildGroup,
description: "Build for universal",
type: "boolean",
})
.option("dir", {
group: buildGroup,
description: "Build unpacked dir. Useful to test.",
type: "boolean",
})
.option("publish", {
group: publishGroup,
alias: "p",
description: `Publish artifacts, see ${chalk.underline("https://goo.gl/tSFycD")}`,
choices: ["onTag", "onTagOrDraft", "always", "never", undefined],
})
.option("prepackaged", {
alias: ["pd"],
group: buildGroup,
description: "The path to prepackaged app (to pack in a distributable format)",
})
.option("projectDir", {
alias: ["project"],
group: buildGroup,
description: "The path to project directory. Defaults to current working directory.",
})
.option("config", {
alias: ["c"],
group: buildGroup,
description: "The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see " + chalk.underline("https://goo.gl/YFRJOM"),
})
.group(["help", "version"], "Other:")
.example("electron-builder -mwl", "build for macOS, Windows and Linux")
.example("electron-builder --linux deb tar.xz", "build deb and tar.xz for Linux")
.example("electron-builder --win --ia32", "build for Windows ia32")
.example("electron-builder -c.extraMetadata.foo=bar", "set package.json property `foo` to `bar`")
.example("electron-builder --config.nsis.unicode=false", "configure unicode options for NSIS");
}
//# sourceMappingURL=builder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
#! /usr/bin/env node
export {};

View File

@@ -0,0 +1,70 @@
#! /usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builder_util_1 = require("builder-util");
const chalk = require("chalk");
const fs_extra_1 = require("fs-extra");
const isCi = require("is-ci");
const path = require("path");
const load_1 = require("app-builder-lib/out/util/config/load");
const builder_1 = require("../builder");
const create_self_signed_cert_1 = require("./create-self-signed-cert");
const install_app_deps_1 = require("./install-app-deps");
const start_1 = require("./start");
const yarn_1 = require("app-builder-lib/out/util/yarn");
const electronVersion_1 = require("app-builder-lib/out/electron/electronVersion");
const publish_1 = require("../publish");
// tslint:disable:no-unused-expression
void (0, builder_1.createYargs)()
.command(["build", "*"], "Build", builder_1.configureBuildCommand, wrap(builder_1.build))
.command("install-app-deps", "Install app deps", install_app_deps_1.configureInstallAppDepsCommand, wrap(install_app_deps_1.installAppDeps))
.command("node-gyp-rebuild", "Rebuild own native code", install_app_deps_1.configureInstallAppDepsCommand /* yes, args the same as for install app deps */, wrap(rebuildAppNativeCode))
.command("publish", "Publish a list of artifacts", publish_1.configurePublishCommand, wrap(publish_1.publish))
.command("create-self-signed-cert", "Create self-signed code signing cert for Windows apps", yargs => yargs
.option("publisher", {
alias: ["p"],
type: "string",
requiresArg: true,
description: "The publisher name",
})
.demandOption("publisher"), wrap(argv => (0, create_self_signed_cert_1.createSelfSignedCert)(argv.publisher)))
.command("start", "Run application in a development mode using electron-webpack", yargs => yargs, wrap(() => (0, start_1.start)()))
.help()
.epilog(`See ${chalk.underline("https://electron.build")} for more documentation.`)
.strict()
.recommendCommands().argv;
function wrap(task) {
return (args) => {
checkIsOutdated().catch((e) => builder_util_1.log.warn({ error: e }, "cannot check updates"));
(0, load_1.loadEnv)(path.join(process.cwd(), "electron-builder.env"))
.then(() => task(args))
.catch(error => {
process.exitCode = 1;
// https://github.com/electron-userland/electron-builder/issues/2940
process.on("exit", () => (process.exitCode = 1));
if (error instanceof builder_util_1.InvalidConfigurationError) {
builder_util_1.log.error(null, error.message);
}
else if (!(error instanceof builder_util_1.ExecError) || !error.alreadyLogged) {
builder_util_1.log.error({ failedTask: task.name, stackTrace: error.stack }, error.message);
}
});
};
}
async function checkIsOutdated() {
if (isCi || process.env.NO_UPDATE_NOTIFIER != null) {
return;
}
const pkg = await (0, fs_extra_1.readJson)(path.join(__dirname, "..", "..", "package.json"));
if (pkg.version === "0.0.0-semantic-release") {
return;
}
const UpdateNotifier = require("simple-update-notifier");
await UpdateNotifier({ pkg });
}
async function rebuildAppNativeCode(args) {
const projectDir = process.cwd();
// this script must be used only for electron
return (0, yarn_1.nodeGypRebuild)(args.platform, args.arch, { version: await (0, electronVersion_1.getElectronVersion)(projectDir), useCustomDist: true });
}
//# sourceMappingURL=cli.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSelfSignedCert = createSelfSignedCert;
const filename_1 = require("app-builder-lib/out/util/filename");
const builder_util_1 = require("builder-util");
const chalk = require("chalk");
const windowsSignToolManager_1 = require("app-builder-lib/out/codeSign/windowsSignToolManager");
const promises_1 = require("fs/promises");
const path = require("path");
/** @internal */
async function createSelfSignedCert(publisher) {
const tmpDir = new builder_util_1.TmpDir("create-self-signed-cert");
const targetDir = process.cwd();
const tempPrefix = path.join(await tmpDir.getTempDir({ prefix: "self-signed-cert-creator" }), (0, filename_1.sanitizeFileName)(publisher));
const cer = `${tempPrefix}.cer`;
const pvk = `${tempPrefix}.pvk`;
builder_util_1.log.info(chalk.bold('When asked to enter a password ("Create Private Key Password"), please select "None".'));
try {
await (0, promises_1.mkdir)(path.dirname(tempPrefix), { recursive: true });
const vendorPath = path.join(await (0, windowsSignToolManager_1.getSignVendorPath)(), "windows-10", process.arch);
await (0, builder_util_1.exec)(path.join(vendorPath, "makecert.exe"), ["-r", "-h", "0", "-n", `CN=${quoteString(publisher)}`, "-eku", "1.3.6.1.5.5.7.3.3", "-pe", "-sv", pvk, cer]);
const pfx = path.join(targetDir, `${(0, filename_1.sanitizeFileName)(publisher)}.pfx`);
await (0, builder_util_1.unlinkIfExists)(pfx);
await (0, builder_util_1.exec)(path.join(vendorPath, "pvk2pfx.exe"), ["-pvk", pvk, "-spc", cer, "-pfx", pfx]);
builder_util_1.log.info({ file: pfx }, `created. Please see https://electron.build/code-signing how to use it to sign.`);
const certLocation = "Cert:\\LocalMachine\\TrustedPeople";
builder_util_1.log.info({ file: pfx, certLocation }, `importing. Operation will be succeed only if runned from root. Otherwise import file manually.`);
await (0, builder_util_1.spawn)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "Import-PfxCertificate", "-FilePath", `"${pfx}"`, "-CertStoreLocation", certLocation]);
}
finally {
await tmpDir.cleanup();
}
}
function quoteString(s) {
if (!s.includes(",") && !s.includes('"')) {
return s;
}
return `"${s.replace(/"/g, '\\"')}"`;
}
//# sourceMappingURL=create-self-signed-cert.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-self-signed-cert.js","sourceRoot":"","sources":["../../src/cli/create-self-signed-cert.ts"],"names":[],"mappings":";;AAQA,oDAyBC;AAjCD,gEAAoE;AACpE,+CAAuE;AACvE,+BAA8B;AAC9B,gGAAuF;AACvF,0CAAmC;AACnC,6BAA4B;AAE5B,gBAAgB;AACT,KAAK,UAAU,oBAAoB,CAAC,SAAiB;IAC1D,MAAM,MAAM,GAAG,IAAI,qBAAM,CAAC,yBAAyB,CAAC,CAAA;IACpD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC,EAAE,IAAA,2BAAgB,EAAC,SAAS,CAAC,CAAC,CAAA;IAC1H,MAAM,GAAG,GAAG,GAAG,UAAU,MAAM,CAAA;IAC/B,MAAM,GAAG,GAAG,GAAG,UAAU,MAAM,CAAA;IAE/B,kBAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,uFAAuF,CAAC,CAAC,CAAA;IAE7G,IAAI,CAAC;QACH,MAAM,IAAA,gBAAK,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,IAAA,0CAAiB,GAAE,EAAE,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QACnF,MAAM,IAAA,mBAAI,EAAC,IAAI,C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CAAA;IACV,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAA;AACtC,CAAC","sourcesContent":["import { sanitizeFileName } from \"app-builder-lib/out/util/filename\"\nimport { exec, log, spawn, TmpDir, unlinkIfExists } from \"builder-util\"\nimport * as chalk from \"chalk\"\nimport { getSignVendorPath } from \"app-builder-lib/out/codeSign/windowsSignToolManager\"\nimport { mkdir } from \"fs/promises\"\nimport * as path from \"path\"\n\n/** @internal */\nexport async function createSelfSignedCert(publisher: string) {\n const tmpDir = new TmpDir(\"create-self-signed-cert\")\n const targetDir = process.cwd()\n const tempPrefix = path.join(await tmpDir.getTempDir({ prefix: \"self-signed-cert-creator\" }), sanitizeFileName(publisher))\n const cer = `${tempPrefix}.cer`\n const pvk = `${tempPrefix}.pvk`\n\n log.info(chalk.bold('When asked to enter a password (\"Create Private Key Password\"), please select \"None\".'))\n\n try {\n await mkdir(path.dirname(tempPrefix), { recursive: true })\n const vendorPath = path.join(await getSignVendorPath(), \"windows-10\", process.arch)\n await exec(path.join(vendorPath, \"makecert.exe\"), [\"-r\", \"-h\", \"0\", \"-n\", `CN=${quoteString(publisher)}`, \"-eku\", \"1.3.6.1.5.5.7.3.3\", \"-pe\", \"-sv\", pvk, cer])\n\n const pfx = path.join(targetDir, `${sanitizeFileName(publisher)}.pfx`)\n await unlinkIfExists(pfx)\n await exec(path.join(vendorPath, \"pvk2pfx.exe\"), [\"-pvk\", pvk, \"-spc\", cer, \"-pfx\", pfx])\n log.info({ file: pfx }, `created. Please see https://electron.build/code-signing how to use it to sign.`)\n\n const certLocation = \"Cert:\\\\LocalMachine\\\\TrustedPeople\"\n log.info({ file: pfx, certLocation }, `importing. Operation will be succeed only if runned from root. Otherwise import file manually.`)\n await spawn(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"Import-PfxCertificate\", \"-FilePath\", `\"${pfx}\"`, \"-CertStoreLocation\", certLocation])\n } finally {\n await tmpDir.cleanup()\n }\n}\n\nfunction quoteString(s: string): string {\n if (!s.includes(\",\") && !s.includes('\"')) {\n return s\n }\n\n return `\"${s.replace(/\"/g, '\\\\\"')}\"`\n}\n"]}

View File

@@ -0,0 +1,2 @@
#! /usr/bin/env node
export {};

View File

@@ -0,0 +1,69 @@
#! /usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configureInstallAppDepsCommand = configureInstallAppDepsCommand;
exports.installAppDeps = installAppDeps;
const electronVersion_1 = require("app-builder-lib/out/electron/electronVersion");
const config_1 = require("app-builder-lib/out/util/config/config");
const yarn_1 = require("app-builder-lib/out/util/yarn");
const version_1 = require("app-builder-lib/out/version");
const packageDependencies_1 = require("app-builder-lib/out/util/packageDependencies");
const builder_util_1 = require("builder-util");
const fs_extra_1 = require("fs-extra");
const lazy_val_1 = require("lazy-val");
const path = require("path");
const load_1 = require("app-builder-lib/out/util/config/load");
const yargs = require("yargs");
/** @internal */
function configureInstallAppDepsCommand(yargs) {
// https://github.com/yargs/yargs/issues/760
// demandOption is required to be set
return yargs
.parserConfiguration({
"camel-case-expansion": false,
})
.option("platform", {
choices: ["linux", "darwin", "win32"],
default: process.platform,
description: "The target platform",
})
.option("arch", {
choices: (0, builder_util_1.getArchCliNames)().concat("all"),
default: process.arch === "arm" ? "armv7l" : process.arch,
description: "The target arch",
});
}
/** @internal */
async function installAppDeps(args) {
try {
builder_util_1.log.info({ version: version_1.PACKAGE_VERSION }, "electron-builder");
}
catch (e) {
// error in dev mode without babel
if (!(e instanceof ReferenceError)) {
throw e;
}
}
const projectDir = process.cwd();
const packageMetadata = new lazy_val_1.Lazy(() => (0, load_1.orNullIfFileNotExist)((0, fs_extra_1.readJson)(path.join(projectDir, "package.json"))));
const config = await (0, config_1.getConfig)(projectDir, null, null, packageMetadata);
const [appDir, version] = await Promise.all([
(0, config_1.computeDefaultAppDirectory)(projectDir, (0, builder_util_1.use)(config.directories, it => it.app)),
(0, electronVersion_1.getElectronVersion)(projectDir, config),
]);
// if two package.json — force full install (user wants to install/update app deps in addition to dev)
await (0, yarn_1.installOrRebuild)(config, appDir, {
frameworkInfo: { version, useCustomDist: true },
platform: args.platform,
arch: args.arch,
productionDeps: (0, packageDependencies_1.createLazyProductionDeps)(appDir, null, false),
}, appDir !== projectDir);
}
function main() {
return installAppDeps(configureInstallAppDepsCommand(yargs).argv);
}
if (require.main === module) {
builder_util_1.log.warn("please use as subcommand: electron-builder install-app-deps");
main().catch(builder_util_1.printErrorAndExit);
}
//# sourceMappingURL=install-app-deps.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"install-app-deps.js","sourceRoot":"","sources":["../../src/cli/install-app-deps.ts"],"names":[],"mappings":";;;AAeA,wEAiBC;AAGD,wCAiCC;AAlED,kFAAiF;AACjF,mEAA8F;AAC9F,wDAAgE;AAChE,yDAA6D;AAC7D,sFAAuF;AACvF,+CAA2E;AAC3E,uCAAmC;AACnC,uCAA+B;AAC/B,6BAA4B;AAC5B,+DAA2E;AAC3E,+BAA8B;AAE9B,gBAAgB;AAChB,SAAgB,8BAA8B,CAAC,KAAiB;IAC9D,4CAA4C;IAC5C,qCAAqC;IACrC,OAAO,KAAK;SACT,mBAAmB,CAAC;QACnB,sBAAsB,EAAE,KAAK;KAC9B,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAClB,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;QACrC,OAAO,EAAE,OAAO,CAAC,QAAQ;QACzB,WAAW,EAAE,qBAAqB;KACnC,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,OAAO,EAAE,IAAA,8BAAe,GAAE,CAAC,MAAM,CAAC,KAAK,CAAC;QACxC,OAAO,EAAE,OAAO,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;QACzD,WAAW,EAAE,iBAAiB;KAC/B,CAAC,CAAA;AACN,CAAC;AAED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,CACtB,CAAA;AACH,CAAC;AAED,SAAS,IAAI;IACX,OAAO,cAAc,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAA;AACnE,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,kBAAG,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAA;IACvE,IAAI,EAAE,CAAC,KAAK,CAAC,gCAAiB,CAAC,CAAA;AACjC,CAAC","sourcesContent":["#! /usr/bin/env node\n\nimport { getElectronVersion } from \"app-builder-lib/out/electron/electronVersion\"\nimport { computeDefaultAppDirectory, getConfig } from \"app-builder-lib/out/util/config/config\"\nimport { installOrRebuild } from \"app-builder-lib/out/util/yarn\"\nimport { PACKAGE_VERSION } from \"app-builder-lib/out/version\"\nimport { createLazyProductionDeps } from \"app-builder-lib/out/util/packageDependencies\"\nimport { getArchCliNames, log, use, printErrorAndExit } from \"builder-util\"\nimport { readJson } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { orNullIfFileNotExist } from \"app-builder-lib/out/util/config/load\"\nimport * as yargs from \"yargs\"\n\n/** @internal */\nexport function configureInstallAppDepsCommand(yargs: yargs.Argv): yargs.Argv {\n // https://github.com/yargs/yargs/issues/760\n // demandOption is required to be set\n return yargs\n .parserConfiguration({\n \"camel-case-expansion\": false,\n })\n .option(\"platform\", {\n choices: [\"linux\", \"darwin\", \"win32\"],\n default: process.platform,\n description: \"The target platform\",\n })\n .option(\"arch\", {\n choices: getArchCliNames().concat(\"all\"),\n default: process.arch === \"arm\" ? \"armv7l\" : process.arch,\n description: \"The target arch\",\n })\n}\n\n/** @internal */\nexport async function installAppDeps(args: any) {\n try {\n log.info({ version: PACKAGE_VERSION }, \"electron-builder\")\n } catch (e: any) {\n // error in dev mode without babel\n if (!(e instanceof ReferenceError)) {\n throw e\n }\n }\n\n const projectDir = process.cwd()\n const packageMetadata = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, \"package.json\"))))\n const config = await getConfig(projectDir, null, null, packageMetadata)\n const [appDir, version] = await Promise.all<string>([\n computeDefaultAppDirectory(\n projectDir,\n use(config.directories, it => it.app)\n ),\n getElectronVersion(projectDir, config),\n ])\n\n // if two package.json — force full install (user wants to install/update app deps in addition to dev)\n await installOrRebuild(\n config,\n appDir,\n {\n frameworkInfo: { version, useCustomDist: true },\n platform: args.platform,\n arch: args.arch,\n productionDeps: createLazyProductionDeps(appDir, null, false),\n },\n appDir !== projectDir\n )\n}\n\nfunction main() {\n return installAppDeps(configureInstallAppDepsCommand(yargs).argv)\n}\n\nif (require.main === module) {\n log.warn(\"please use as subcommand: electron-builder install-app-deps\")\n main().catch(printErrorAndExit)\n}\n"]}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.start = start;
/** @internal */
function start() {
require("electron-webpack/dev-runner");
return Promise.resolve();
}
//# sourceMappingURL=start.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":";;AACA,sBAGC;AAJD,gBAAgB;AAChB,SAAgB,KAAK;IACnB,OAAO,CAAC,6BAA6B,CAAC,CAAA;IACtC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["/** @internal */\nexport function start() {\n require(\"electron-webpack/dev-runner\")\n return Promise.resolve()\n}\n"]}

View File

@@ -0,0 +1,6 @@
export { getArchSuffix, Arch, archFromString, log } from "builder-util";
export { build, CliOptions, createTargets } from "./builder";
export { publish, publishArtifactsWithOptions } from "./publish";
export { TargetConfiguration, Platform, Target, DIR_TARGET, BeforeBuildContext, SourceRepositoryInfo, TargetSpecificOptions, TargetConfigType, DEFAULT_TARGET, CompressionLevel, MacConfiguration, DmgOptions, MasConfiguration, MacOsTargetName, PkgOptions, DmgContent, DmgWindow, PlatformSpecificBuildOptions, AsarOptions, FileSet, LinuxConfiguration, DebOptions, CommonLinuxOptions, LinuxTargetSpecificOptions, AppImageOptions, Configuration, AfterPackContext, MetadataDirectories, Protocol, ReleaseInfo, ElectronBrandingOptions, ElectronDownloadOptions, SnapOptions, CommonWindowsInstallerConfiguration, FileAssociation, MsiOptions, AppXOptions, WindowsConfiguration, Packager, BuildResult, PackagerOptions, ArtifactCreated, ArtifactBuildStarted, NsisOptions, NsisWebOptions, PortableOptions, CommonNsisOptions, SquirrelWindowsOptions, WindowsSignOptions, CustomWindowsSignTaskConfiguration, WindowsSignTaskConfiguration, CustomWindowsSign, FileCodeSigningInfo, CertificateFromStoreInfo, Metadata, AuthorMetadata, RepositoryInfo, AppInfo, UploadTask, PublishManager, PublishOptions, ProgressInfo, MacPackager, WinPackager, LinuxPackager, } from "app-builder-lib";
export { buildForge, ForgeOptions } from "app-builder-lib";
export { CancellationToken } from "builder-util-runtime";

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CancellationToken = exports.buildForge = exports.LinuxPackager = exports.WinPackager = exports.MacPackager = exports.PublishManager = exports.AppInfo = exports.Packager = exports.DEFAULT_TARGET = exports.DIR_TARGET = exports.Target = exports.Platform = exports.publishArtifactsWithOptions = exports.publish = exports.createTargets = exports.build = exports.log = exports.archFromString = exports.Arch = exports.getArchSuffix = void 0;
var builder_util_1 = require("builder-util");
Object.defineProperty(exports, "getArchSuffix", { enumerable: true, get: function () { return builder_util_1.getArchSuffix; } });
Object.defineProperty(exports, "Arch", { enumerable: true, get: function () { return builder_util_1.Arch; } });
Object.defineProperty(exports, "archFromString", { enumerable: true, get: function () { return builder_util_1.archFromString; } });
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return builder_util_1.log; } });
var builder_1 = require("./builder");
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return builder_1.build; } });
Object.defineProperty(exports, "createTargets", { enumerable: true, get: function () { return builder_1.createTargets; } });
var publish_1 = require("./publish");
Object.defineProperty(exports, "publish", { enumerable: true, get: function () { return publish_1.publish; } });
Object.defineProperty(exports, "publishArtifactsWithOptions", { enumerable: true, get: function () { return publish_1.publishArtifactsWithOptions; } });
var app_builder_lib_1 = require("app-builder-lib");
Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return app_builder_lib_1.Platform; } });
Object.defineProperty(exports, "Target", { enumerable: true, get: function () { return app_builder_lib_1.Target; } });
Object.defineProperty(exports, "DIR_TARGET", { enumerable: true, get: function () { return app_builder_lib_1.DIR_TARGET; } });
Object.defineProperty(exports, "DEFAULT_TARGET", { enumerable: true, get: function () { return app_builder_lib_1.DEFAULT_TARGET; } });
Object.defineProperty(exports, "Packager", { enumerable: true, get: function () { return app_builder_lib_1.Packager; } });
Object.defineProperty(exports, "AppInfo", { enumerable: true, get: function () { return app_builder_lib_1.AppInfo; } });
Object.defineProperty(exports, "PublishManager", { enumerable: true, get: function () { return app_builder_lib_1.PublishManager; } });
Object.defineProperty(exports, "MacPackager", { enumerable: true, get: function () { return app_builder_lib_1.MacPackager; } });
Object.defineProperty(exports, "WinPackager", { enumerable: true, get: function () { return app_builder_lib_1.WinPackager; } });
Object.defineProperty(exports, "LinuxPackager", { enumerable: true, get: function () { return app_builder_lib_1.LinuxPackager; } });
var app_builder_lib_2 = require("app-builder-lib");
Object.defineProperty(exports, "buildForge", { enumerable: true, get: function () { return app_builder_lib_2.buildForge; } });
var builder_util_runtime_1 = require("builder-util-runtime");
Object.defineProperty(exports, "CancellationToken", { enumerable: true, get: function () { return builder_util_runtime_1.CancellationToken; } });
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AAA9D,6GAAA,aAAa,OAAA;AAAE,oGAAA,IAAI,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,mGAAA,GAAG,OAAA;AACjD,qCAA4D;AAAnD,gGAAA,KAAK,OAAA;AAAc,wGAAA,aAAa,OAAA;AACzC,qCAAgE;AAAvD,kGAAA,OAAO,OAAA;AAAE,sHAAA,2BAA2B,OAAA;AAC7C,mDAkEwB;AAhEtB,2GAAA,QAAQ,OAAA;AACR,yGAAA,MAAM,OAAA;AACN,6GAAA,UAAU,OAAA;AAKV,iHAAA,cAAc,OAAA;AA8Bd,2GAAA,QAAQ,OAAA;AAmBR,0GAAA,OAAO,OAAA;AAEP,iHAAA,cAAc,OAAA;AAGd,8GAAA,WAAW,OAAA;AACX,8GAAA,WAAW,OAAA;AACX,gHAAA,aAAa,OAAA;AAEf,mDAA0D;AAAjD,6GAAA,UAAU,OAAA;AACnB,6DAAwD;AAA/C,yHAAA,iBAAiB,OAAA","sourcesContent":["export { getArchSuffix, Arch, archFromString, log } from \"builder-util\"\nexport { build, CliOptions, createTargets } from \"./builder\"\nexport { publish, publishArtifactsWithOptions } from \"./publish\"\nexport {\n TargetConfiguration,\n Platform,\n Target,\n DIR_TARGET,\n BeforeBuildContext,\n SourceRepositoryInfo,\n TargetSpecificOptions,\n TargetConfigType,\n DEFAULT_TARGET,\n CompressionLevel,\n MacConfiguration,\n DmgOptions,\n MasConfiguration,\n MacOsTargetName,\n PkgOptions,\n DmgContent,\n DmgWindow,\n PlatformSpecificBuildOptions,\n AsarOptions,\n FileSet,\n LinuxConfiguration,\n DebOptions,\n CommonLinuxOptions,\n LinuxTargetSpecificOptions,\n AppImageOptions,\n Configuration,\n AfterPackContext,\n MetadataDirectories,\n Protocol,\n ReleaseInfo,\n ElectronBrandingOptions,\n ElectronDownloadOptions,\n SnapOptions,\n CommonWindowsInstallerConfiguration,\n FileAssociation,\n MsiOptions,\n AppXOptions,\n WindowsConfiguration,\n Packager,\n BuildResult,\n PackagerOptions,\n ArtifactCreated,\n ArtifactBuildStarted,\n NsisOptions,\n NsisWebOptions,\n PortableOptions,\n CommonNsisOptions,\n SquirrelWindowsOptions,\n WindowsSignOptions,\n CustomWindowsSignTaskConfiguration,\n WindowsSignTaskConfiguration,\n CustomWindowsSign,\n FileCodeSigningInfo,\n CertificateFromStoreInfo,\n Metadata,\n AuthorMetadata,\n RepositoryInfo,\n AppInfo,\n UploadTask,\n PublishManager,\n PublishOptions,\n ProgressInfo,\n MacPackager,\n WinPackager,\n LinuxPackager,\n} from \"app-builder-lib\"\nexport { buildForge, ForgeOptions } from \"app-builder-lib\"\nexport { CancellationToken } from \"builder-util-runtime\"\n"]}

View File

@@ -0,0 +1,12 @@
#! /usr/bin/env node
import { UploadTask } from "app-builder-lib";
import { Publish } from "app-builder-lib/out/core";
export declare function publish(args: {
files: string[];
version: string | undefined;
config: string | undefined;
}): Promise<UploadTask[] | null>;
export declare function publishArtifactsWithOptions(uploadOptions: {
file: string;
arch: string | null;
}[], buildVersion?: string, configurationFilePath?: string, publishConfiguration?: Publish): Promise<UploadTask[] | null>;

View File

@@ -0,0 +1,102 @@
#! /usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configurePublishCommand = configurePublishCommand;
exports.publish = publish;
exports.publishArtifactsWithOptions = publishArtifactsWithOptions;
const app_builder_lib_1 = require("app-builder-lib");
const platformPackager_1 = require("app-builder-lib/out/platformPackager");
const config_1 = require("app-builder-lib/out/util/config/config");
const builder_util_1 = require("builder-util");
const builder_util_2 = require("builder-util");
const chalk = require("chalk");
const path = require("path");
const yargs = require("yargs");
const builder_1 = require("./builder");
/** @internal */
function configurePublishCommand(yargs) {
// https://github.com/yargs/yargs/issues/760
// demandOption is required to be set
return yargs
.parserConfiguration({
"camel-case-expansion": false,
})
.option("files", {
alias: "f",
string: true,
type: "array",
requiresArg: true,
description: "The file(s) to upload to your publisher",
})
.option("version", {
alias: ["v"],
type: "string",
description: "The app/build version used when searching for an upload release (used by some Publishers)",
})
.option("config", {
alias: ["c"],
type: "string",
description: "The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see " + chalk.underline("https://goo.gl/YFRJOM"),
})
.demandOption("files");
}
async function publish(args) {
const uploadTasks = args.files.map(f => {
return {
file: path.resolve(f),
arch: null,
};
});
return publishArtifactsWithOptions(uploadTasks, args.version, args.config);
}
async function publishArtifactsWithOptions(uploadOptions, buildVersion, configurationFilePath, publishConfiguration) {
const projectDir = process.cwd();
const config = await (0, config_1.getConfig)(projectDir, configurationFilePath || null, { publish: publishConfiguration, detectUpdateChannel: false });
const buildOptions = (0, builder_1.normalizeOptions)({ config });
(0, app_builder_lib_1.checkBuildRequestOptions)(buildOptions);
const uniqueUploads = Array.from(new Set(uploadOptions));
const tasks = uniqueUploads.map(({ file, arch }) => {
const filename = path.basename(file);
return { file, arch: arch ? (0, builder_util_1.archFromString)(arch) : null, safeArtifactName: (0, platformPackager_1.computeSafeArtifactNameIfNeeded)(filename, () => filename) };
});
return publishPackageWithTasks(buildOptions, tasks, buildVersion);
}
async function publishPackageWithTasks(options, uploadTasks, buildVersion, cancellationToken = new app_builder_lib_1.CancellationToken(), packager = new app_builder_lib_1.Packager(options, cancellationToken)) {
await packager.validateConfig();
const appInfo = new app_builder_lib_1.AppInfo(packager, buildVersion);
const publishManager = new app_builder_lib_1.PublishManager(packager, options, cancellationToken);
const sigIntHandler = () => {
builder_util_1.log.warn("cancelled by SIGINT");
packager.cancellationToken.cancel();
publishManager.cancelTasks();
};
process.once("SIGINT", sigIntHandler);
try {
const publishConfigurations = await publishManager.getGlobalPublishConfigurations();
if (publishConfigurations == null || publishConfigurations.length === 0) {
throw new builder_util_1.InvalidConfigurationError("unable to find any publish configuration");
}
for (const newArtifact of uploadTasks) {
for (const publishConfiguration of publishConfigurations) {
publishManager.scheduleUpload(publishConfiguration, newArtifact, appInfo);
}
}
await publishManager.awaitTasks();
return uploadTasks;
}
catch (error) {
packager.cancellationToken.cancel();
publishManager.cancelTasks();
process.removeListener("SIGINT", sigIntHandler);
builder_util_1.log.error({ message: (error.stack || error.message || error).toString() }, "error publishing");
}
return null;
}
function main() {
return publish(configurePublishCommand(yargs).argv);
}
if (require.main === module) {
builder_util_1.log.warn("please use as subcommand: electron-builder publish");
main().catch(builder_util_2.printErrorAndExit);
}
//# sourceMappingURL=publish.js.map

File diff suppressed because one or more lines are too long