15815213711
2024-08-26 67b8b6731811983447e053d4396b3708c14dfe3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builder_util_1 = require("builder-util");
const chalk = require("chalk");
const electronVersion_1 = require("app-builder-lib/out/electron/electronVersion");
const fs_extra_1 = require("fs-extra");
const isCi = require("is-ci");
const path = require("path");
const read_config_file_1 = require("read-config-file");
const util_1 = require("builder-util/out/util");
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");
// tslint:disable:no-unused-expression
void 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("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 => create_self_signed_cert_1.createSelfSignedCert(argv.publisher)))
    .command("start", "Run application in a development mode using electron-webpack", yargs => yargs, wrap(() => 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"));
        read_config_file_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 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 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 yarn_1.nodeGypRebuild(args.platform, args.arch, { version: await electronVersion_1.getElectronVersion(projectDir), useCustomDist: true });
}
//# sourceMappingURL=cli.js.map