oclif 3.3.1 → 3.4.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/.oclif.manifest.json +1 -1
- package/lib/aws.js +2 -2
- package/lib/commands/pack/deb.js +46 -28
- package/lib/commands/pack/macos.js +24 -20
- package/lib/commands/pack/tarballs.js +0 -3
- package/lib/commands/pack/win.js +43 -41
- package/lib/commands/promote.js +73 -112
- package/lib/commands/upload/deb.js +27 -15
- package/lib/commands/upload/macos.js +3 -5
- package/lib/commands/upload/tarballs.js +12 -27
- package/lib/commands/upload/win.js +4 -6
- package/lib/log.js +2 -2
- package/lib/tarballs/bin.js +7 -8
- package/lib/tarballs/build.js +48 -49
- package/lib/tarballs/config.js +9 -6
- package/lib/tarballs/node.js +28 -18
- package/lib/util.d.ts +2 -0
- package/lib/util.js +21 -1
- package/package.json +7 -9
package/.oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"3.
|
|
1
|
+
{"version":"3.4.0","commands":{"generate":{"id":"generate","description":"generate a new CLI\nThis will clone the template repo 'oclif/hello-world' and update package properties","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"name","description":"directory name of new project","required":true}]},"manifest":{"id":"manifest","description":"generates plugin manifest json","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"path","description":"path to plugin","default":"."}]},"promote":{"id":"promote","description":"promote CLI builds to a S3 release channel","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to the oclif CLI project root","required":true,"multiple":false,"default":"."},"version":{"name":"version","type":"option","description":"semantic version of the CLI to promote","required":true,"multiple":false},"sha":{"name":"sha","type":"option","description":"7-digit short git commit SHA of the CLI to promote","required":true,"multiple":false},"channel":{"name":"channel","type":"option","description":"which channel to promote to","required":true,"multiple":false,"default":"stable"},"targets":{"name":"targets","type":"option","char":"t","description":"comma-separated targets to promote (e.g.: linux-arm,win32-x64)","multiple":false},"deb":{"name":"deb","type":"boolean","char":"d","description":"promote debian artifacts","allowNo":false},"macos":{"name":"macos","type":"boolean","char":"m","description":"promote macOS pkg","allowNo":false},"win":{"name":"win","type":"boolean","char":"w","description":"promote Windows exe","allowNo":false},"max-age":{"name":"max-age","type":"option","char":"a","description":"cache control max-age in seconds","multiple":false,"default":"86400"},"xz":{"name":"xz","type":"boolean","description":"also upload xz","allowNo":true},"indexes":{"name":"indexes","type":"boolean","description":"append the promoted urls into the index files","allowNo":false}},"args":[]},"readme":{"id":"readme","description":"adds commands to README.md in current directory\nThe readme must have any of the following tags inside of it for it to be replaced or else it will do nothing:\n# Usage\n<!-- usage -->\n# Commands\n<!-- commands -->\n# Table of contents\n<!-- toc -->\n\nCustomize the code URL prefix by setting oclif.repositoryPrefix in package.json.\n","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"output directory for multi docs","required":true,"multiple":false,"default":"docs"},"multi":{"name":"multi","type":"boolean","description":"create a different markdown page for each topic","allowNo":false},"aliases":{"name":"aliases","type":"boolean","description":"include aliases in the command list","allowNo":true}},"args":[]},"generate:command":{"id":"generate:command","description":"add a command to an existing CLI or plugin","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","description":"overwrite existing files","allowNo":false}},"args":[{"name":"name","description":"name of command","required":true}]},"generate:hook":{"id":"generate:hook","description":"add a hook to an existing CLI or plugin","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","description":"overwrite existing files","allowNo":false},"event":{"name":"event","type":"option","description":"event to run hook on","multiple":false,"default":"init"}},"args":[{"name":"name","description":"name of hook (snake_case)","required":true}]},"pack:deb":{"id":"pack:deb","description":"pack CLI into debian package","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"tarball":{"name":"tarball","type":"option","char":"t","description":"optionally specify a path to a tarball already generated by NPM","required":false,"multiple":false}},"args":[]},"pack:macos":{"id":"pack:macos","description":"pack CLI into macOS .pkg","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"additional-cli":{"name":"additional-cli","type":"option","description":"an Oclif CLI other than the one listed in config.bin that should be made available to the user\nthe CLI should already exist in a directory named after the CLI that is the root of the tarball produced by \"oclif pack:tarballs\"","hidden":true,"multiple":false},"tarball":{"name":"tarball","type":"option","char":"t","description":"optionally specify a path to a tarball already generated by NPM","required":false,"multiple":false},"targets":{"name":"targets","type":"option","description":"comma-separated targets to pack (e.g.: darwin-x64,darwin-arm64)","multiple":false}},"args":[]},"pack:tarballs":{"id":"pack:tarballs","description":"packages oclif CLI into tarballs\n\nThis can be used to create oclif CLIs that use the system node or that come preloaded with a node binary.\n","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"targets":{"name":"targets","type":"option","char":"t","description":"comma-separated targets to pack (e.g.: linux-arm,win32-x64)","multiple":false},"xz":{"name":"xz","type":"boolean","description":"also build xz","allowNo":true},"parallel":{"name":"parallel","type":"boolean","description":"build tarballs in parallel","allowNo":false},"tarball":{"name":"tarball","type":"option","char":"l","description":"optionally specify a path to a tarball already generated by NPM","required":false,"multiple":false}},"args":[]},"pack:win":{"id":"pack:win","description":"create windows installer from oclif CLI\n\n This command requires WINDOWS_SIGNING (prefixed with the name of your executable, e.g. OCLIF_WINDOWS_SIGNING_PASS) to be set in the environment","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"additional-cli":{"name":"additional-cli","type":"option","description":"an Oclif CLI other than the one listed in config.bin that should be made available to the user\nthe CLI should already exist in a directory named after the CLI that is the root of the tarball produced by \"oclif pack:tarballs\"","hidden":true,"multiple":false},"tarball":{"name":"tarball","type":"option","char":"t","description":"optionally specify a path to a tarball already generated by NPM","required":false,"multiple":false}},"args":[]},"upload:deb":{"id":"upload:deb","description":"upload deb package built with pack:deb","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."}},"args":[]},"upload:macos":{"id":"upload:macos","description":"upload macos installers built with pack:macos","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"targets":{"name":"targets","type":"option","char":"t","description":"comma-separated targets to upload (e.g.: darwin-x64,darwin-arm64)","multiple":false}},"args":[]},"upload:tarballs":{"id":"upload:tarballs","description":"upload an oclif CLI to S3\n\n\"aws-sdk\" will need to be installed as a devDependency to upload.\n","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"targets":{"name":"targets","type":"option","char":"t","description":"comma-separated targets to upload (e.g.: linux-arm,win32-x64)","multiple":false},"xz":{"name":"xz","type":"boolean","description":"also upload xz","allowNo":true}},"args":[]},"upload:win":{"id":"upload:win","description":"upload windows installers built with pack:win","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."}},"args":[]}}}
|
package/lib/aws.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fs = require("fs-extra");
|
|
4
|
-
const qq = require("qqjs");
|
|
5
4
|
const log_1 = require("./log");
|
|
5
|
+
const util_1 = require("./util");
|
|
6
6
|
const debug = log_1.debug.new('aws');
|
|
7
7
|
const cache = {};
|
|
8
8
|
const aws = {
|
|
@@ -53,7 +53,7 @@ exports.default = {
|
|
|
53
53
|
get s3() {
|
|
54
54
|
return {
|
|
55
55
|
uploadFile: (local, options) => new Promise((resolve, reject) => {
|
|
56
|
-
(0, log_1.log)('s3:uploadFile',
|
|
56
|
+
(0, log_1.log)('s3:uploadFile', (0, util_1.prettifyPaths)(local), `s3://${options.Bucket}/${options.Key}`);
|
|
57
57
|
options.Body = fs.createReadStream(local);
|
|
58
58
|
aws.s3.upload(options, err => {
|
|
59
59
|
if (err)
|
package/lib/commands/pack/deb.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
+
const fs = require("fs-extra");
|
|
4
5
|
const _ = require("lodash");
|
|
5
|
-
const
|
|
6
|
+
const path = require("path");
|
|
6
7
|
const Tarballs = require("../../tarballs");
|
|
7
8
|
const upload_util_1 = require("../../upload-util");
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const node_util_1 = require("node:util");
|
|
11
|
+
const exec = (0, node_util_1.promisify)(child_process_1.exec);
|
|
8
12
|
const scripts = {
|
|
9
13
|
/* eslint-disable no-useless-escape */
|
|
10
14
|
bin: (config) => `#!/usr/bin/env bash
|
|
@@ -48,44 +52,52 @@ class PackDeb extends core_1.Command {
|
|
|
48
52
|
const { flags } = await this.parse(PackDeb);
|
|
49
53
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
50
54
|
const { config } = buildConfig;
|
|
51
|
-
await Tarballs.build(buildConfig, { platform: 'linux', pack: false, tarball: flags.tarball });
|
|
55
|
+
await Tarballs.build(buildConfig, { platform: 'linux', pack: false, tarball: flags.tarball, parallel: true });
|
|
52
56
|
const dist = buildConfig.dist('deb');
|
|
53
|
-
await
|
|
57
|
+
await fs.emptyDir(dist);
|
|
54
58
|
const build = async (arch) => {
|
|
59
|
+
this.log(`building debian / ${arch}`);
|
|
55
60
|
const target = { platform: 'linux', arch };
|
|
56
61
|
const versionedDebBase = (0, upload_util_1.templateShortKey)('deb', { bin: config.bin, versionShaRevision: (0, upload_util_1.debVersion)(buildConfig), arch: (0, upload_util_1.debArch)(arch) });
|
|
57
|
-
const workspace =
|
|
58
|
-
await
|
|
59
|
-
await
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
await
|
|
64
|
-
await
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
const workspace = path.join(buildConfig.tmp, 'apt', versionedDebBase.replace('.deb', '.apt'));
|
|
63
|
+
await fs.remove(workspace);
|
|
64
|
+
await Promise.all([
|
|
65
|
+
fs.promises.mkdir(path.join(workspace, 'DEBIAN'), { recursive: true }),
|
|
66
|
+
fs.promises.mkdir(path.join(workspace, 'usr', 'bin'), { recursive: true }),
|
|
67
|
+
]);
|
|
68
|
+
await fs.copy(buildConfig.workspace(target), path.join(workspace, 'usr', 'lib', config.dirname));
|
|
69
|
+
await Promise.all([
|
|
70
|
+
// usr/lib/oclif/bin/oclif (the executable)
|
|
71
|
+
fs.promises.writeFile(path.join(workspace, 'usr', 'lib', config.dirname, 'bin', config.bin), scripts.bin(config), { mode: 0o755 }),
|
|
72
|
+
fs.promises.writeFile(path.join(workspace, 'DEBIAN', 'control'), scripts.control(buildConfig, (0, upload_util_1.debArch)(arch))),
|
|
73
|
+
]);
|
|
74
|
+
// symlink usr/bin/oclif points to usr/lib/oclif/bin/oclif
|
|
75
|
+
await exec(`ln -s "${path.join('..', 'lib', config.dirname, 'bin', config.bin)}" "${config.bin}"`, { cwd: path.join(workspace, 'usr', 'bin') });
|
|
76
|
+
await exec(`sudo chown -R root "${workspace}"`);
|
|
77
|
+
await exec(`sudo chgrp -R root "${workspace}"`);
|
|
78
|
+
await exec(`dpkg --build "${workspace}" "${path.join(dist, versionedDebBase)}"`);
|
|
79
|
+
this.log(`finished building debian / ${arch}`);
|
|
70
80
|
};
|
|
71
81
|
const arches = _.uniq(buildConfig.targets
|
|
72
82
|
.filter(t => t.platform === 'linux')
|
|
73
83
|
.map(t => t.arch));
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
await
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
await Promise.all(arches.map(a => build(a)));
|
|
85
|
+
await exec('apt-ftparchive packages . > Packages', { cwd: dist });
|
|
86
|
+
this.log('debian packages created');
|
|
87
|
+
await Promise.all([
|
|
88
|
+
exec('gzip -c Packages > Packages.gz', { cwd: dist }),
|
|
89
|
+
exec('bzip2 -k Packages', { cwd: dist }),
|
|
90
|
+
exec('xz -k Packages', { cwd: dist }),
|
|
91
|
+
packForFTP(buildConfig, config, dist),
|
|
92
|
+
]);
|
|
93
|
+
this.log('debian packages archived');
|
|
84
94
|
const gpgKey = config.scopedEnvVar('DEB_KEY');
|
|
85
95
|
if (gpgKey) {
|
|
86
|
-
|
|
87
|
-
await
|
|
96
|
+
this.log('adding gpg signatures to Release');
|
|
97
|
+
await exec(`gpg --digest-algo SHA512 --clearsign -u ${gpgKey} -o InRelease Release`, { cwd: dist });
|
|
98
|
+
await exec(`gpg --digest-algo SHA512 -abs -u ${gpgKey} -o Release.gpg Release`, { cwd: dist });
|
|
88
99
|
}
|
|
100
|
+
this.log('debian packing complete');
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
exports.default = PackDeb;
|
|
@@ -94,3 +106,9 @@ PackDeb.flags = {
|
|
|
94
106
|
root: core_1.Flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
|
|
95
107
|
tarball: core_1.Flags.string({ char: 't', description: 'optionally specify a path to a tarball already generated by NPM', required: false }),
|
|
96
108
|
};
|
|
109
|
+
async function packForFTP(buildConfig, config, dist) {
|
|
110
|
+
const ftparchive = path.join(buildConfig.tmp, 'apt', 'apt-ftparchive.conf');
|
|
111
|
+
await fs.promises.mkdir(path.basename(ftparchive), { recursive: true });
|
|
112
|
+
await fs.writeFile(ftparchive, scripts.ftparchive(config));
|
|
113
|
+
await exec(`apt-ftparchive -c "${ftparchive}" release . > Release`, { cwd: dist });
|
|
114
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
3
4
|
const _ = require("lodash");
|
|
4
|
-
const
|
|
5
|
+
const fs = require("fs-extra");
|
|
5
6
|
const core_1 = require("@oclif/core");
|
|
6
7
|
const Tarballs = require("../../tarballs");
|
|
7
8
|
const upload_util_1 = require("../../upload-util");
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const node_util_1 = require("node:util");
|
|
11
|
+
const exec = (0, node_util_1.promisify)(child_process_1.exec);
|
|
8
12
|
const noBundleConfiguration = `<?xml version="1.0" encoding="UTF-8"?>
|
|
9
13
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
10
14
|
<plist version="1.0">
|
|
@@ -65,7 +69,7 @@ while [ "$1" != "-y" ]; do
|
|
|
65
69
|
done
|
|
66
70
|
|
|
67
71
|
echo "Application uninstalling process started"
|
|
68
|
-
# remove link to
|
|
72
|
+
# remove link to shortcut file
|
|
69
73
|
find "/usr/local/bin/" -name "${config.bin}" | xargs rm
|
|
70
74
|
${additionalCLI ? `find "/usr/local/bin/" -name "${additionalCLI}" | xargs rm` : ''}
|
|
71
75
|
if [ $? -eq 0 ]
|
|
@@ -123,28 +127,30 @@ class PackMacos extends core_1.Command {
|
|
|
123
127
|
this.error('package.json must have oclif.macos.identifier set');
|
|
124
128
|
const macos = c.macos;
|
|
125
129
|
const packageIdentifier = macos.identifier;
|
|
126
|
-
await Tarballs.build(buildConfig, { platform: 'darwin', pack: false, tarball: flags.tarball });
|
|
127
|
-
const scriptsDir =
|
|
128
|
-
await
|
|
129
|
-
const noBundleConfigurationPath =
|
|
130
|
+
await Tarballs.build(buildConfig, { platform: 'darwin', pack: false, tarball: flags.tarball, parallel: true });
|
|
131
|
+
const scriptsDir = path.join(buildConfig.tmp, 'macos/scripts');
|
|
132
|
+
await fs.emptyDir(buildConfig.dist('macos'));
|
|
133
|
+
const noBundleConfigurationPath = path.join(buildConfig.tmp, 'macos', 'no-bundle.plist');
|
|
130
134
|
const build = async (arch) => {
|
|
131
135
|
const templateKey = (0, upload_util_1.templateShortKey)('macos', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
|
|
132
136
|
const dist = buildConfig.dist(`macos/${templateKey}`);
|
|
133
137
|
const rootDir = buildConfig.workspace({ platform: 'darwin', arch });
|
|
134
138
|
const writeNoBundleConfiguration = async () => {
|
|
135
|
-
await
|
|
136
|
-
await
|
|
139
|
+
await fs.mkdir(path.dirname(noBundleConfigurationPath), { recursive: true });
|
|
140
|
+
await fs.writeFile(noBundleConfigurationPath, noBundleConfiguration, { mode: 0o755 });
|
|
137
141
|
};
|
|
138
142
|
const writeScript = async (script) => {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
await
|
|
142
|
-
await
|
|
143
|
+
const scriptLocation = script === 'uninstall' ? [rootDir, 'bin'] : [scriptsDir];
|
|
144
|
+
scriptLocation.push(script);
|
|
145
|
+
await fs.mkdir(path.dirname(path.join(...scriptLocation)), { recursive: true });
|
|
146
|
+
await fs.writeFile(path.join(...scriptLocation), scripts[script](config, flags['additional-cli']), { mode: 0o755 });
|
|
143
147
|
};
|
|
144
|
-
await
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
await Promise.all([
|
|
149
|
+
writeNoBundleConfiguration(),
|
|
150
|
+
writeScript('preinstall'),
|
|
151
|
+
writeScript('postinstall'),
|
|
152
|
+
writeScript('uninstall'),
|
|
153
|
+
]);
|
|
148
154
|
/* eslint-disable array-element-newline */
|
|
149
155
|
const args = [
|
|
150
156
|
'--root', rootDir,
|
|
@@ -163,14 +169,12 @@ class PackMacos extends core_1.Command {
|
|
|
163
169
|
if (process.env.OSX_KEYCHAIN)
|
|
164
170
|
args.push('--keychain', process.env.OSX_KEYCHAIN);
|
|
165
171
|
args.push(dist);
|
|
166
|
-
await
|
|
172
|
+
await exec(`pkgbuild ${args.join(' ')}`);
|
|
167
173
|
};
|
|
168
174
|
const arches = _.uniq(buildConfig.targets
|
|
169
175
|
.filter(t => t.platform === 'darwin')
|
|
170
176
|
.map(t => t.arch));
|
|
171
|
-
|
|
172
|
-
for (const a of arches)
|
|
173
|
-
await build(a);
|
|
177
|
+
await Promise.all(arches.map(a => build(a)));
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
exports.default = PackMacos;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const qq = require("qqjs");
|
|
5
4
|
const Tarballs = require("../../tarballs");
|
|
6
5
|
class PackTarballs extends core_1.Command {
|
|
7
6
|
async run() {
|
|
8
7
|
var _a;
|
|
9
|
-
const prevCwd = qq.cwd();
|
|
10
8
|
if (process.platform === 'win32')
|
|
11
9
|
throw new Error('pack does not function on windows');
|
|
12
10
|
const { flags } = await this.parse(PackTarballs);
|
|
@@ -18,7 +16,6 @@ class PackTarballs extends core_1.Command {
|
|
|
18
16
|
tarball: flags.tarball,
|
|
19
17
|
parallel: flags.parallel,
|
|
20
18
|
});
|
|
21
|
-
qq.cd(prevCwd);
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
exports.default = PackTarballs;
|
package/lib/commands/pack/win.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs-extra");
|
|
5
6
|
const Tarballs = require("../../tarballs");
|
|
6
7
|
const upload_util_1 = require("../../upload-util");
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const node_util_1 = require("node:util");
|
|
10
|
+
const exec = (0, node_util_1.promisify)(child_process_1.exec);
|
|
7
11
|
const scripts = {
|
|
8
12
|
/* eslint-disable no-useless-escape */
|
|
9
13
|
// eslint-disable-next-line unicorn/no-useless-undefined
|
|
@@ -199,58 +203,37 @@ class PackWin extends core_1.Command {
|
|
|
199
203
|
const { flags } = await this.parse(PackWin);
|
|
200
204
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
201
205
|
const { config } = buildConfig;
|
|
202
|
-
await Tarballs.build(buildConfig, { platform: 'win32', pack: false, tarball: flags.tarball });
|
|
206
|
+
await Tarballs.build(buildConfig, { platform: 'win32', pack: false, tarball: flags.tarball, parallel: true });
|
|
203
207
|
const arches = buildConfig.targets.filter(t => t.platform === 'win32').map(t => t.arch);
|
|
204
|
-
|
|
205
|
-
const installerBase =
|
|
206
|
-
|
|
207
|
-
await
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
await
|
|
218
|
-
// eslint-disable-next-line no-await-in-loop
|
|
219
|
-
await qq.x(`makensis ${installerBase}/${config.bin}.nsi | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
|
208
|
+
await Promise.all(arches.map(async (arch) => {
|
|
209
|
+
const installerBase = path.join(buildConfig.tmp, `windows-${arch}-installer`);
|
|
210
|
+
await fs.promises.rm(installerBase, { recursive: true, force: true });
|
|
211
|
+
await fs.promises.mkdir(path.join(installerBase, 'bin'), { recursive: true });
|
|
212
|
+
await Promise.all([
|
|
213
|
+
fs.writeFile(path.join(installerBase, 'bin', `${config.bin}.cmd`), scripts.cmd(config)),
|
|
214
|
+
fs.writeFile(path.join(installerBase, 'bin', `${config.bin}`), scripts.sh(config)),
|
|
215
|
+
fs.writeFile(path.join(installerBase, `${config.bin}.nsi`), scripts.nsis(config, arch)),
|
|
216
|
+
].concat(flags['additional-cli'] ? [
|
|
217
|
+
fs.writeFile(path.join(installerBase, 'bin', `${flags['additional-cli']}.cmd`), scripts.cmd(config, flags['additional-cli'])),
|
|
218
|
+
fs.writeFile(path.join(installerBase, 'bin', `${flags['additional-cli']}`), scripts.sh({ bin: flags['additional-cli'] })),
|
|
219
|
+
] : []));
|
|
220
|
+
await fs.move(buildConfig.workspace({ platform: 'win32', arch }), path.join(installerBase, 'client'));
|
|
221
|
+
await exec(`makensis ${installerBase}/${config.bin}.nsi | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
|
220
222
|
const templateKey = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
|
|
221
223
|
const o = buildConfig.dist(`win32/${templateKey}`);
|
|
222
|
-
|
|
223
|
-
await qq.mv([installerBase, 'installer.exe'], o);
|
|
224
|
+
await fs.move(path.join(installerBase, 'installer.exe'), o);
|
|
224
225
|
const windows = config.pjson.oclif.windows;
|
|
225
226
|
if (windows && windows.name && windows.keypath) {
|
|
226
|
-
|
|
227
|
-
// eslint-disable-next-line no-await-in-loop
|
|
228
|
-
await qq.mv(o, buildLocationUnsigned);
|
|
229
|
-
const pass = config.scopedEnvVar('WINDOWS_SIGNING_PASS');
|
|
230
|
-
if (!pass) {
|
|
231
|
-
throw new Error(`${config.scopedEnvVarKey('WINDOWS_SIGNING_PASS')} not set in the environment`);
|
|
232
|
-
}
|
|
233
|
-
/* eslint-disable array-element-newline */
|
|
234
|
-
const args = [
|
|
235
|
-
'-pkcs12', windows.keypath,
|
|
236
|
-
'-pass', pass,
|
|
237
|
-
'-n', windows.name,
|
|
238
|
-
'-i', windows.homepage || config.pjson.homepage,
|
|
239
|
-
'-h', 'sha512',
|
|
240
|
-
'-in', buildLocationUnsigned,
|
|
241
|
-
'-out', o,
|
|
242
|
-
];
|
|
243
|
-
// eslint-disable-next-line no-await-in-loop
|
|
244
|
-
await qq.x('osslsigncode', args);
|
|
227
|
+
await signWindows(o, arch, config, windows);
|
|
245
228
|
}
|
|
246
229
|
else
|
|
247
230
|
this.debug('Skipping windows exe signing');
|
|
248
231
|
this.log(`built ${o}`);
|
|
249
|
-
}
|
|
232
|
+
}));
|
|
250
233
|
}
|
|
251
234
|
async checkForNSIS() {
|
|
252
235
|
try {
|
|
253
|
-
await
|
|
236
|
+
await exec('makensis');
|
|
254
237
|
}
|
|
255
238
|
catch (error) {
|
|
256
239
|
if (error.code === 1)
|
|
@@ -284,3 +267,22 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
284
267
|
required: false,
|
|
285
268
|
}),
|
|
286
269
|
};
|
|
270
|
+
async function signWindows(o, arch, config, windows) {
|
|
271
|
+
const buildLocationUnsigned = o.replace(`${arch}.exe`, `${arch}-unsigned.exe`);
|
|
272
|
+
await fs.move(o, buildLocationUnsigned);
|
|
273
|
+
const pass = config.scopedEnvVar('WINDOWS_SIGNING_PASS');
|
|
274
|
+
if (!pass) {
|
|
275
|
+
throw new Error(`${config.scopedEnvVarKey('WINDOWS_SIGNING_PASS')} not set in the environment`);
|
|
276
|
+
}
|
|
277
|
+
/* eslint-disable array-element-newline */
|
|
278
|
+
const args = [
|
|
279
|
+
'-pkcs12', windows.keypath,
|
|
280
|
+
'-pass', pass,
|
|
281
|
+
'-n', `"${windows.name}"`,
|
|
282
|
+
'-i', windows.homepage || config.pjson.homepage,
|
|
283
|
+
'-h', 'sha512',
|
|
284
|
+
'-in', buildLocationUnsigned,
|
|
285
|
+
'-out', o,
|
|
286
|
+
];
|
|
287
|
+
await exec(`osslsigncode sign ${args}.join(' ')`);
|
|
288
|
+
}
|