@depup/oclif 4.22.92-depup.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/LICENSE +21 -0
- package/README.md +44 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +7 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +7 -0
- package/changes.json +62 -0
- package/lib/aws.d.ts +22 -0
- package/lib/aws.js +146 -0
- package/lib/commands/generate/command.d.ts +12 -0
- package/lib/commands/generate/command.js +44 -0
- package/lib/commands/generate/hook.d.ts +12 -0
- package/lib/commands/generate/hook.js +87 -0
- package/lib/commands/generate.d.ts +67 -0
- package/lib/commands/generate.js +269 -0
- package/lib/commands/init.d.ts +39 -0
- package/lib/commands/init.js +165 -0
- package/lib/commands/lock.d.ts +4 -0
- package/lib/commands/lock.js +70 -0
- package/lib/commands/manifest.d.ts +13 -0
- package/lib/commands/manifest.js +156 -0
- package/lib/commands/pack/deb.d.ts +13 -0
- package/lib/commands/pack/deb.js +194 -0
- package/lib/commands/pack/macos.d.ts +14 -0
- package/lib/commands/pack/macos.js +273 -0
- package/lib/commands/pack/tarballs.d.ts +15 -0
- package/lib/commands/pack/tarballs.js +77 -0
- package/lib/commands/pack/win.d.ts +16 -0
- package/lib/commands/pack/win.js +398 -0
- package/lib/commands/promote.d.ts +20 -0
- package/lib/commands/promote.js +305 -0
- package/lib/commands/readme.d.ts +19 -0
- package/lib/commands/readme.js +143 -0
- package/lib/commands/upload/deb.d.ts +10 -0
- package/lib/commands/upload/deb.js +113 -0
- package/lib/commands/upload/macos.d.ts +11 -0
- package/lib/commands/upload/macos.js +92 -0
- package/lib/commands/upload/tarballs.d.ts +12 -0
- package/lib/commands/upload/tarballs.js +135 -0
- package/lib/commands/upload/win.d.ts +11 -0
- package/lib/commands/upload/win.js +97 -0
- package/lib/generator.d.ts +57 -0
- package/lib/generator.js +184 -0
- package/lib/help-compatibility.d.ts +11 -0
- package/lib/help-compatibility.js +22 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -0
- package/lib/log.d.ts +2 -0
- package/lib/log.js +13 -0
- package/lib/readme-generator.d.ts +38 -0
- package/lib/readme-generator.js +305 -0
- package/lib/tarballs/bin.d.ts +7 -0
- package/lib/tarballs/bin.js +126 -0
- package/lib/tarballs/build.d.ts +10 -0
- package/lib/tarballs/build.js +250 -0
- package/lib/tarballs/config.d.ts +45 -0
- package/lib/tarballs/config.js +132 -0
- package/lib/tarballs/index.d.ts +4 -0
- package/lib/tarballs/index.js +20 -0
- package/lib/tarballs/node.d.ts +10 -0
- package/lib/tarballs/node.js +78 -0
- package/lib/upload-util.d.ts +17 -0
- package/lib/upload-util.js +56 -0
- package/lib/util.d.ts +18 -0
- package/lib/util.js +160 -0
- package/lib/version-indexes.d.ts +9 -0
- package/lib/version-indexes.js +119 -0
- package/oclif.manifest.json +1199 -0
- package/package.json +217 -0
- package/templates/cli/commonjs/.mocharc.json.ejs +11 -0
- package/templates/cli/commonjs/.vscode/launch.json.ejs +20 -0
- package/templates/cli/commonjs/bin/dev.cmd.ejs +3 -0
- package/templates/cli/commonjs/bin/dev.js.ejs +7 -0
- package/templates/cli/commonjs/bin/run.cmd.ejs +3 -0
- package/templates/cli/commonjs/bin/run.js.ejs +7 -0
- package/templates/cli/commonjs/eslint.config.mjs.ejs +19 -0
- package/templates/cli/commonjs/tsconfig.json.ejs +11 -0
- package/templates/cli/esm/.mocharc.json.ejs +15 -0
- package/templates/cli/esm/.vscode/launch.json.ejs +22 -0
- package/templates/cli/esm/bin/dev.cmd.ejs +3 -0
- package/templates/cli/esm/bin/dev.js.ejs +5 -0
- package/templates/cli/esm/bin/run.cmd.ejs +3 -0
- package/templates/cli/esm/bin/run.js.ejs +5 -0
- package/templates/cli/esm/eslint.config.mjs.ejs +9 -0
- package/templates/cli/esm/tsconfig.json.ejs +15 -0
- package/templates/cli/shared/.github/workflows/onPushToMain.yml.ejs +56 -0
- package/templates/cli/shared/.github/workflows/onRelease.yml.ejs +21 -0
- package/templates/cli/shared/.github/workflows/test.yml.ejs +23 -0
- package/templates/cli/shared/.gitignore.ejs +27 -0
- package/templates/cli/shared/.prettierrc.json.ejs +1 -0
- package/templates/cli/shared/README.md.ejs +396 -0
- package/templates/cli/shared/package.json.ejs +73 -0
- package/templates/cli/shared/src/commands/hello/index.ts.ejs +22 -0
- package/templates/cli/shared/src/commands/hello/world.ts.ejs +16 -0
- package/templates/cli/shared/src/index.ts.ejs +1 -0
- package/templates/cli/shared/test/commands/hello/index.test.ts.ejs +9 -0
- package/templates/cli/shared/test/commands/hello/world.test.ts.ejs +9 -0
- package/templates/cli/shared/test/tsconfig.json.ejs +9 -0
- package/templates/src/command.ts.ejs +27 -0
- package/templates/src/hook.ts.ejs +7 -0
- package/templates/src/init/dev.cmd.ejs +12 -0
- package/templates/src/init/dev.js.ejs +17 -0
- package/templates/src/init/run.cmd.ejs +3 -0
- package/templates/src/init/run.js.ejs +17 -0
- package/templates/test/command.test.ts.ejs +14 -0
- package/templates/test/hook.test.ts.ejs +9 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.build = build;
|
|
7
|
+
const core_1 = require("@oclif/core");
|
|
8
|
+
const find_yarn_workspace_root_1 = __importDefault(require("find-yarn-workspace-root"));
|
|
9
|
+
const fs_extra_1 = require("fs-extra");
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const promises_1 = require("node:fs/promises");
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const node_util_1 = require("node:util");
|
|
15
|
+
const log_1 = require("../log");
|
|
16
|
+
const upload_util_1 = require("../upload-util");
|
|
17
|
+
const util_1 = require("../util");
|
|
18
|
+
const bin_1 = require("./bin");
|
|
19
|
+
const node_1 = require("./node");
|
|
20
|
+
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
21
|
+
const pack = async (from, to, c) => {
|
|
22
|
+
const cwd = node_path_1.default.dirname(from);
|
|
23
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(to), { recursive: true });
|
|
24
|
+
(0, log_1.log)(`packing tarball from ${(0, util_1.prettifyPaths)(node_path_1.default.dirname(from))} to ${(0, util_1.prettifyPaths)(to)}`);
|
|
25
|
+
const platformFlag = c.tarFlags?.[process.platform] ?? '';
|
|
26
|
+
if (to.endsWith('gz')) {
|
|
27
|
+
return exec(`tar czf ${to} ${node_path_1.default.basename(from)} ${platformFlag}`, { cwd });
|
|
28
|
+
}
|
|
29
|
+
await exec(`tar cfJ ${to} ${node_path_1.default.basename(from)} ${platformFlag}`, { cwd });
|
|
30
|
+
};
|
|
31
|
+
const isYarnProject = (yarnRootPath) => {
|
|
32
|
+
const yarnLockFileName = 'yarn.lock';
|
|
33
|
+
const rootYarnLockFilePath = node_path_1.default.join(yarnRootPath, yarnLockFileName);
|
|
34
|
+
return (0, node_fs_1.existsSync)(rootYarnLockFilePath);
|
|
35
|
+
};
|
|
36
|
+
const copyYarnDirectory = async (relativePath, yarnRootPath, workspacePath) => {
|
|
37
|
+
const rootYarnDirectoryPath = node_path_1.default.join(yarnRootPath, relativePath);
|
|
38
|
+
const workspaceYarnDirectoryPath = node_path_1.default.join(workspacePath, relativePath);
|
|
39
|
+
if ((0, node_fs_1.existsSync)(rootYarnDirectoryPath)) {
|
|
40
|
+
// create the directory if it does not exist
|
|
41
|
+
if (!(0, node_fs_1.existsSync)(workspaceYarnDirectoryPath)) {
|
|
42
|
+
await (0, promises_1.mkdir)(workspaceYarnDirectoryPath, { recursive: true });
|
|
43
|
+
}
|
|
44
|
+
// recursively copy all files in the directory
|
|
45
|
+
await (0, fs_extra_1.copy)(rootYarnDirectoryPath, workspaceYarnDirectoryPath);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const copyCoreYarnFiles = async (yarnRootPath, workspacePath) => {
|
|
49
|
+
// copy yarn dependencies lock file
|
|
50
|
+
const yarnLockFileName = 'yarn.lock';
|
|
51
|
+
const rootYarnLockFilePath = node_path_1.default.join(yarnRootPath, yarnLockFileName);
|
|
52
|
+
const workspaceYarnLockFilePath = node_path_1.default.join(workspacePath, yarnLockFileName);
|
|
53
|
+
if ((0, node_fs_1.existsSync)(rootYarnLockFilePath)) {
|
|
54
|
+
await (0, fs_extra_1.copy)(rootYarnLockFilePath, workspaceYarnLockFilePath);
|
|
55
|
+
}
|
|
56
|
+
// copy yarn configuration file
|
|
57
|
+
const yarnConfigFileName = '.yarnrc.yml';
|
|
58
|
+
const rootYarnConfigFilePath = node_path_1.default.join(yarnRootPath, yarnConfigFileName);
|
|
59
|
+
const workspaceYarnConfigFilePath = node_path_1.default.join(workspacePath, yarnConfigFileName);
|
|
60
|
+
if ((0, node_fs_1.existsSync)(rootYarnConfigFilePath)) {
|
|
61
|
+
await (0, fs_extra_1.copy)(rootYarnConfigFilePath, workspaceYarnConfigFilePath);
|
|
62
|
+
}
|
|
63
|
+
// copy yarn releases e.g. yarn may be installed via a local config path like "yarnPath"
|
|
64
|
+
await copyYarnDirectory('./.yarn/releases/', yarnRootPath, workspacePath);
|
|
65
|
+
// copy yarn plugins if they exists
|
|
66
|
+
await copyYarnDirectory('./.yarn/plugins/', yarnRootPath, workspacePath);
|
|
67
|
+
// copy yarn patches if they exists
|
|
68
|
+
await copyYarnDirectory('./.yarn/patches/', yarnRootPath, workspacePath);
|
|
69
|
+
};
|
|
70
|
+
async function build(c, options = {}) {
|
|
71
|
+
(0, log_1.log)(`gathering workspace for ${c.config.bin} to ${c.workspace()}`);
|
|
72
|
+
await extractCLI(options.tarball ?? (await packCLI(c)), c);
|
|
73
|
+
await updatePJSON(c);
|
|
74
|
+
await addDependencies(c);
|
|
75
|
+
await (0, bin_1.writeBinScripts)({
|
|
76
|
+
baseWorkspace: c.workspace(),
|
|
77
|
+
config: c.config,
|
|
78
|
+
nodeOptions: c.nodeOptions,
|
|
79
|
+
nodeVersion: c.nodeVersion,
|
|
80
|
+
});
|
|
81
|
+
await pretarball(c);
|
|
82
|
+
if (options.pruneLockfiles) {
|
|
83
|
+
await removeLockfiles(c);
|
|
84
|
+
}
|
|
85
|
+
if (!c.updateConfig.s3?.host || !c.updateConfig.s3?.bucket) {
|
|
86
|
+
core_1.ux.warn('No S3 bucket or host configured. CLI will not be able to update itself.');
|
|
87
|
+
}
|
|
88
|
+
const targetsToBuild = c.targets.filter((t) => !options.platform || options.platform === t.platform);
|
|
89
|
+
if (options.parallel) {
|
|
90
|
+
(0, log_1.log)(`will build ${targetsToBuild.length} targets in parallel`);
|
|
91
|
+
await Promise.all(targetsToBuild.map((t) => buildTarget(t, c, options)));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
(0, log_1.log)(`will build ${targetsToBuild.length} targets sequentially`);
|
|
95
|
+
for (const target of targetsToBuild) {
|
|
96
|
+
// eslint-disable-next-line no-await-in-loop
|
|
97
|
+
await buildTarget(target, c, options);
|
|
98
|
+
}
|
|
99
|
+
(0, log_1.log)(`finished building ${targetsToBuild.length} targets sequentially`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const isLockFile = (f) => f.endsWith('package-lock.json') ||
|
|
103
|
+
f.endsWith('yarn.lock') ||
|
|
104
|
+
f.endsWith('npm-shrinkwrap.json') ||
|
|
105
|
+
f.endsWith('oclif.lock') ||
|
|
106
|
+
f.endsWith('pnpm-lock.yaml');
|
|
107
|
+
/** recursively remove all lockfiles from tarball after installing dependencies */
|
|
108
|
+
const removeLockfiles = async (c) => {
|
|
109
|
+
const files = await (0, promises_1.readdir)(c.workspace(), { recursive: true });
|
|
110
|
+
const lockfiles = files.filter((f) => isLockFile(f)).map((f) => node_path_1.default.join(c.workspace(), f));
|
|
111
|
+
(0, log_1.log)(`removing ${lockfiles.length} lockfiles`);
|
|
112
|
+
await Promise.all(lockfiles.map((f) => (0, fs_extra_1.remove)(f)));
|
|
113
|
+
};
|
|
114
|
+
/** runs the pretarball script from the cli being packed */
|
|
115
|
+
const pretarball = async (c) => {
|
|
116
|
+
const pjson = await (0, fs_extra_1.readJSON)(node_path_1.default.join(c.workspace(), 'package.json'));
|
|
117
|
+
if (!pjson.scripts.pretarball)
|
|
118
|
+
return;
|
|
119
|
+
const yarnRoot = (0, find_yarn_workspace_root_1.default)(c.root) || c.root;
|
|
120
|
+
let script = 'npm run pretarball';
|
|
121
|
+
if ((0, node_fs_1.existsSync)(node_path_1.default.join(yarnRoot, 'yarn.lock')))
|
|
122
|
+
script = 'yarn run pretarball';
|
|
123
|
+
else if ((0, node_fs_1.existsSync)(node_path_1.default.join(c.root, 'pnpm-lock.yaml')))
|
|
124
|
+
script = 'pnpm run pretarball';
|
|
125
|
+
(0, log_1.log)(`running pretarball via ${script} in ${c.workspace()}`);
|
|
126
|
+
await exec(script, { cwd: c.workspace() });
|
|
127
|
+
};
|
|
128
|
+
const updatePJSON = async (c) => {
|
|
129
|
+
const pjsonPath = node_path_1.default.join(c.workspace(), 'package.json');
|
|
130
|
+
const pjson = await (0, fs_extra_1.readJSON)(pjsonPath);
|
|
131
|
+
pjson.version = c.config.version;
|
|
132
|
+
pjson.oclif = pjson.oclif ?? {};
|
|
133
|
+
pjson.oclif.update = pjson.oclif.update ?? {};
|
|
134
|
+
pjson.oclif.update.s3 = pjson.oclif.update.s3 ?? {};
|
|
135
|
+
pjson.oclif.update.s3.bucket = c.s3Config.bucket;
|
|
136
|
+
await (0, fs_extra_1.writeJSON)(pjsonPath, pjson, { spaces: 2 });
|
|
137
|
+
};
|
|
138
|
+
const addDependencies = async (c) => {
|
|
139
|
+
const yarnRoot = (0, find_yarn_workspace_root_1.default)(c.root) || c.root;
|
|
140
|
+
if (isYarnProject(yarnRoot)) {
|
|
141
|
+
await copyCoreYarnFiles(yarnRoot, c.workspace());
|
|
142
|
+
const { stdout } = await exec('yarn -v');
|
|
143
|
+
const yarnVersion = stdout.charAt(0);
|
|
144
|
+
if (yarnVersion === '1') {
|
|
145
|
+
await exec('yarn --no-progress --production --non-interactive', { cwd: c.workspace() });
|
|
146
|
+
}
|
|
147
|
+
else if (yarnVersion === '2') {
|
|
148
|
+
throw new Error('Yarn 2 is not supported yet. Try using Yarn 1, or Yarn 3');
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
try {
|
|
152
|
+
await exec('yarn workspaces focus --production', { cwd: c.workspace() });
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (error instanceof Error && error.message.includes('Command not found')) {
|
|
156
|
+
throw new Error('Missing workspace tools. Run `yarn plugin import workspace-tools`.');
|
|
157
|
+
}
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else if ((0, node_fs_1.existsSync)(node_path_1.default.join(c.root, 'pnpm-lock.yaml'))) {
|
|
163
|
+
await (0, fs_extra_1.copy)(node_path_1.default.join(c.root, 'pnpm-lock.yaml'), node_path_1.default.join(c.workspace(), 'pnpm-lock.yaml'));
|
|
164
|
+
await exec('pnpm install --production', { cwd: c.workspace() });
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const lockpath = (0, node_fs_1.existsSync)(node_path_1.default.join(c.root, 'package-lock.json'))
|
|
168
|
+
? node_path_1.default.join(c.root, 'package-lock.json')
|
|
169
|
+
: node_path_1.default.join(c.root, 'npm-shrinkwrap.json');
|
|
170
|
+
await (0, fs_extra_1.copy)(lockpath, node_path_1.default.join(c.workspace(), node_path_1.default.basename(lockpath)));
|
|
171
|
+
await exec('npm install --production', { cwd: c.workspace() });
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const packCLI = async (c) => {
|
|
175
|
+
const { stdout } = await exec('npm pack --unsafe-perm', { cwd: c.root });
|
|
176
|
+
return node_path_1.default.join(c.root, stdout.trim().split('\n').pop());
|
|
177
|
+
};
|
|
178
|
+
const extractCLI = async (tarball, c) => {
|
|
179
|
+
const workspace = c.workspace();
|
|
180
|
+
await (0, fs_extra_1.emptyDir)(workspace);
|
|
181
|
+
const tarballNewLocation = node_path_1.default.join(workspace, node_path_1.default.basename(tarball));
|
|
182
|
+
await (0, fs_extra_1.move)(tarball, tarballNewLocation);
|
|
183
|
+
const tarCommand = `tar -xzf "${tarballNewLocation}"${process.platform === 'win32' ? ' --force-local' : ''}`;
|
|
184
|
+
await exec(tarCommand, { cwd: workspace });
|
|
185
|
+
const files = await (0, promises_1.readdir)(node_path_1.default.join(workspace, 'package'), { withFileTypes: true });
|
|
186
|
+
await Promise.all(files.map((i) => (0, fs_extra_1.move)(node_path_1.default.join(workspace, 'package', i.name), node_path_1.default.join(workspace, i.name))));
|
|
187
|
+
await Promise.all([
|
|
188
|
+
(0, promises_1.rm)(node_path_1.default.join(workspace, 'package'), { recursive: true }),
|
|
189
|
+
(0, promises_1.rm)(node_path_1.default.join(workspace, node_path_1.default.basename(tarball)), { recursive: true }),
|
|
190
|
+
(0, fs_extra_1.remove)(node_path_1.default.join(workspace, 'bin', 'run.cmd')),
|
|
191
|
+
]);
|
|
192
|
+
};
|
|
193
|
+
const buildTarget = async (target, c, options) => {
|
|
194
|
+
const workspace = c.workspace(target);
|
|
195
|
+
const { arch, platform } = target;
|
|
196
|
+
const { bin, version } = c.config;
|
|
197
|
+
const { gitSha: sha } = c;
|
|
198
|
+
const templateShortKeyCommonOptions = { arch, bin, platform, sha, version };
|
|
199
|
+
const [gzLocalKey, xzLocalKey] = ['.tar.gz', '.tar.xz'].map((ext) => (0, upload_util_1.templateShortKey)('versioned', { ...templateShortKeyCommonOptions, ext }));
|
|
200
|
+
const base = node_path_1.default.basename(gzLocalKey);
|
|
201
|
+
(0, log_1.log)(`building target ${base}`);
|
|
202
|
+
(0, log_1.log)('copying workspace', c.workspace(), workspace);
|
|
203
|
+
await (0, fs_extra_1.emptyDir)(workspace);
|
|
204
|
+
await (0, fs_extra_1.copy)(c.workspace(), workspace);
|
|
205
|
+
await (0, node_1.fetchNodeBinary)({
|
|
206
|
+
arch,
|
|
207
|
+
nodeVersion: c.nodeVersion,
|
|
208
|
+
output: node_path_1.default.join(workspace, 'bin', 'node'),
|
|
209
|
+
platform,
|
|
210
|
+
tmp: node_path_1.default.join(c.config.root, 'tmp'),
|
|
211
|
+
});
|
|
212
|
+
if (options.pack === false)
|
|
213
|
+
return;
|
|
214
|
+
if (options.parallel) {
|
|
215
|
+
await Promise.all([
|
|
216
|
+
pack(workspace, c.dist(gzLocalKey), c),
|
|
217
|
+
...(c.xz ? [pack(workspace, c.dist(xzLocalKey), c)] : []),
|
|
218
|
+
]);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
await pack(workspace, c.dist(gzLocalKey), c);
|
|
222
|
+
if (c.xz)
|
|
223
|
+
await pack(workspace, c.dist(xzLocalKey), c);
|
|
224
|
+
}
|
|
225
|
+
if (!c.updateConfig.s3?.host)
|
|
226
|
+
return;
|
|
227
|
+
const rollout = typeof c.updateConfig.autoupdate === 'object' && c.updateConfig.autoupdate.rollout;
|
|
228
|
+
const gzCloudKey = `${(0, upload_util_1.commitAWSDir)(version, sha, c.updateConfig.s3)}/${gzLocalKey}`;
|
|
229
|
+
const xzCloudKey = `${(0, upload_util_1.commitAWSDir)(version, sha, c.updateConfig.s3)}/${xzLocalKey}`;
|
|
230
|
+
const [sha256gz, sha256xz] = await Promise.all([
|
|
231
|
+
(0, util_1.hash)('sha256', c.dist(gzLocalKey)),
|
|
232
|
+
...(c.xz ? [(0, util_1.hash)('sha256', c.dist(xzLocalKey))] : []),
|
|
233
|
+
]);
|
|
234
|
+
const manifest = {
|
|
235
|
+
baseDir: (0, upload_util_1.templateShortKey)('baseDir', { ...target, bin }),
|
|
236
|
+
gz: c.config.s3Url(gzCloudKey),
|
|
237
|
+
node: {
|
|
238
|
+
compatible: c.config.pjson.engines.node,
|
|
239
|
+
recommended: c.nodeVersion,
|
|
240
|
+
},
|
|
241
|
+
rollout: rollout === false ? undefined : rollout,
|
|
242
|
+
sha,
|
|
243
|
+
sha256gz,
|
|
244
|
+
sha256xz,
|
|
245
|
+
version,
|
|
246
|
+
xz: c.xz ? c.config.s3Url(xzCloudKey) : undefined,
|
|
247
|
+
};
|
|
248
|
+
const manifestFilepath = c.dist((0, upload_util_1.templateShortKey)('manifest', templateShortKeyCommonOptions));
|
|
249
|
+
await (0, fs_extra_1.writeJSON)(manifestFilepath, manifest, { spaces: 2 });
|
|
250
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ObjectCannedACL } from '@aws-sdk/client-s3';
|
|
2
|
+
import { Interfaces } from '@oclif/core';
|
|
3
|
+
export declare const TARGETS: string[];
|
|
4
|
+
type TarFlags = Interfaces.OclifConfiguration['tarFlags'];
|
|
5
|
+
export type S3Config = BuildConfig['updateConfig']['s3'] & {
|
|
6
|
+
acl?: ObjectCannedACL;
|
|
7
|
+
} & {
|
|
8
|
+
folder?: string;
|
|
9
|
+
indexVersionLimit?: number;
|
|
10
|
+
};
|
|
11
|
+
export type UpdateConfig = Interfaces.OclifConfiguration['update'] & {
|
|
12
|
+
s3?: Interfaces.S3 & {
|
|
13
|
+
acl?: ObjectCannedACL;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type BuildConfig = {
|
|
17
|
+
config: Interfaces.Config;
|
|
18
|
+
dist(input: string): string;
|
|
19
|
+
gitSha: string;
|
|
20
|
+
nodeOptions: string[];
|
|
21
|
+
nodeVersion: string;
|
|
22
|
+
root: string;
|
|
23
|
+
s3Config: S3Config;
|
|
24
|
+
tarFlags?: TarFlags;
|
|
25
|
+
targets: {
|
|
26
|
+
arch: Interfaces.ArchTypes;
|
|
27
|
+
platform: Interfaces.PlatformTypes;
|
|
28
|
+
}[];
|
|
29
|
+
tmp: string;
|
|
30
|
+
updateConfig: UpdateConfig;
|
|
31
|
+
workspace(target?: {
|
|
32
|
+
arch: Interfaces.ArchTypes;
|
|
33
|
+
platform: Interfaces.PlatformTypes;
|
|
34
|
+
}): string;
|
|
35
|
+
xz: boolean;
|
|
36
|
+
};
|
|
37
|
+
export declare function gitSha(cwd: string, options?: {
|
|
38
|
+
short?: boolean;
|
|
39
|
+
}): Promise<string>;
|
|
40
|
+
export declare function buildConfig(root: string, options?: {
|
|
41
|
+
sha?: string;
|
|
42
|
+
targets?: string[];
|
|
43
|
+
xz?: boolean;
|
|
44
|
+
}): Promise<BuildConfig>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.TARGETS = void 0;
|
|
40
|
+
exports.gitSha = gitSha;
|
|
41
|
+
exports.buildConfig = buildConfig;
|
|
42
|
+
const core_1 = require("@oclif/core");
|
|
43
|
+
const node_child_process_1 = require("node:child_process");
|
|
44
|
+
const promises_1 = require("node:fs/promises");
|
|
45
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
46
|
+
const node_util_1 = require("node:util");
|
|
47
|
+
const semver = __importStar(require("semver"));
|
|
48
|
+
const upload_util_1 = require("../upload-util");
|
|
49
|
+
const util_1 = require("../util");
|
|
50
|
+
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
51
|
+
exports.TARGETS = [
|
|
52
|
+
'linux-x64',
|
|
53
|
+
'linux-arm',
|
|
54
|
+
'linux-arm64',
|
|
55
|
+
'win32-x64',
|
|
56
|
+
'win32-x86',
|
|
57
|
+
'win32-arm64',
|
|
58
|
+
'darwin-x64',
|
|
59
|
+
'darwin-arm64',
|
|
60
|
+
];
|
|
61
|
+
const DEFAULT_TAR_FLAGS = { win32: '--force-local' };
|
|
62
|
+
async function gitSha(cwd, options = {}) {
|
|
63
|
+
const args = options.short ? ['rev-parse', '--short', 'HEAD'] : ['rev-parse', 'HEAD'];
|
|
64
|
+
const { stdout } = await exec(`git ${args.join(' ')}`, { cwd });
|
|
65
|
+
return stdout.trim();
|
|
66
|
+
}
|
|
67
|
+
async function Tmp(config) {
|
|
68
|
+
const tmp = node_path_1.default.join(config.root, 'tmp');
|
|
69
|
+
await (0, promises_1.mkdir)(tmp, { recursive: true });
|
|
70
|
+
return tmp;
|
|
71
|
+
}
|
|
72
|
+
async function buildConfig(root, options = {}) {
|
|
73
|
+
const config = await core_1.Config.load({ devPlugins: false, root: node_path_1.default.resolve(root), userPlugins: false });
|
|
74
|
+
root = config.root;
|
|
75
|
+
const _gitSha = options.sha ?? (await gitSha(root, { short: true }));
|
|
76
|
+
// eslint-disable-next-line new-cap
|
|
77
|
+
const tmp = await Tmp(config);
|
|
78
|
+
const updateConfig = (config.pjson.oclif.update || {});
|
|
79
|
+
updateConfig.s3 = updateConfig.s3 || {};
|
|
80
|
+
const nodeVersion = updateConfig.node?.version || process.versions.node;
|
|
81
|
+
const nodeOptions = (0, util_1.castArray)((updateConfig.node ?? {}).options ?? []);
|
|
82
|
+
const targets = (0, util_1.compact)(options.targets || updateConfig.node?.targets || exports.TARGETS)
|
|
83
|
+
.filter((t) => {
|
|
84
|
+
if (t === 'darwin-arm64' && semver.lt(nodeVersion, '16.0.0')) {
|
|
85
|
+
core_1.ux.warn('darwin-arm64 is only supported for node >=16.0.0. Skipping...');
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (t === 'linux-arm' && semver.gt(nodeVersion, '24.0.0')) {
|
|
89
|
+
core_1.ux.warn('linux-arm is not supported for Node.js 24 and later. Skipping...');
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (t === 'win32-x86' && semver.gt(nodeVersion, '24.0.0')) {
|
|
93
|
+
core_1.ux.warn('win32-x86 is not supported for Node.js 24 and later. Skipping...');
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (t === 'win32-arm64' && semver.lt(nodeVersion, '20.0.0')) {
|
|
97
|
+
core_1.ux.warn('win32-arm64 is only supported for node >=20.0.0. Skipping...');
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
})
|
|
102
|
+
.map((t) => {
|
|
103
|
+
const [platform, arch] = t.split('-');
|
|
104
|
+
return { arch, platform };
|
|
105
|
+
});
|
|
106
|
+
const s3Config = {
|
|
107
|
+
...updateConfig.s3,
|
|
108
|
+
acl: updateConfig.s3.acl,
|
|
109
|
+
};
|
|
110
|
+
const existingTarFlags = config.pjson.oclif.tarFlags;
|
|
111
|
+
const tarFlags = existingTarFlags ? { ...DEFAULT_TAR_FLAGS, ...existingTarFlags } : DEFAULT_TAR_FLAGS;
|
|
112
|
+
return {
|
|
113
|
+
config,
|
|
114
|
+
dist: (...args) => node_path_1.default.join(config.root, 'dist', ...args),
|
|
115
|
+
gitSha: _gitSha,
|
|
116
|
+
nodeOptions,
|
|
117
|
+
nodeVersion,
|
|
118
|
+
root,
|
|
119
|
+
s3Config,
|
|
120
|
+
tarFlags,
|
|
121
|
+
targets,
|
|
122
|
+
tmp,
|
|
123
|
+
updateConfig,
|
|
124
|
+
workspace(target) {
|
|
125
|
+
const base = node_path_1.default.join(config.root, 'tmp');
|
|
126
|
+
if (target && target.platform)
|
|
127
|
+
return node_path_1.default.join(base, [target.platform, target.arch].join('-'), (0, upload_util_1.templateShortKey)('baseDir', { bin: config.bin }));
|
|
128
|
+
return node_path_1.default.join(base, (0, upload_util_1.templateShortKey)('baseDir', { bin: config.bin }));
|
|
129
|
+
},
|
|
130
|
+
xz: options?.xz ?? updateConfig?.s3?.xz ?? true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./bin"), exports);
|
|
18
|
+
__exportStar(require("./build"), exports);
|
|
19
|
+
__exportStar(require("./config"), exports);
|
|
20
|
+
__exportStar(require("./node"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Interfaces } from '@oclif/core';
|
|
2
|
+
type Options = {
|
|
3
|
+
arch: 'armv7l' | Interfaces.ArchTypes;
|
|
4
|
+
nodeVersion: string;
|
|
5
|
+
output: string;
|
|
6
|
+
platform: Interfaces.PlatformTypes;
|
|
7
|
+
tmp: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function fetchNodeBinary({ arch, nodeVersion, output, platform, tmp }: Options): Promise<string>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchNodeBinary = fetchNodeBinary;
|
|
7
|
+
const async_retry_1 = __importDefault(require("async-retry"));
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const node_child_process_1 = require("node:child_process");
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const promises_1 = require("node:fs/promises");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const promises_2 = require("node:stream/promises");
|
|
14
|
+
const node_util_1 = require("node:util");
|
|
15
|
+
const log_1 = require("../log");
|
|
16
|
+
const util_1 = require("../util");
|
|
17
|
+
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
18
|
+
const RETRY_TIMEOUT_MS = 1000;
|
|
19
|
+
async function fetchNodeBinary({ arch, nodeVersion, output, platform, tmp }) {
|
|
20
|
+
if (arch === 'arm')
|
|
21
|
+
arch = 'armv7l';
|
|
22
|
+
let nodeBase = `node-v${nodeVersion}-${platform}-${arch}`;
|
|
23
|
+
let tarball = node_path_1.default.join(tmp, 'node', `${nodeBase}.tar.xz`);
|
|
24
|
+
let url = `https://nodejs.org/dist/v${nodeVersion}/${nodeBase}.tar.xz`;
|
|
25
|
+
if (platform === 'win32') {
|
|
26
|
+
await (0, util_1.checkFor7Zip)();
|
|
27
|
+
nodeBase = `node-v${nodeVersion}-win-${arch}`;
|
|
28
|
+
tarball = node_path_1.default.join(tmp, 'node', `${nodeBase}.7z`);
|
|
29
|
+
url = `https://nodejs.org/dist/v${nodeVersion}/${nodeBase}.7z`;
|
|
30
|
+
output += '.exe';
|
|
31
|
+
}
|
|
32
|
+
let cache = node_path_1.default.join(tmp, 'cache', `node-v${nodeVersion}-${platform}-${arch}`);
|
|
33
|
+
if (platform === 'win32')
|
|
34
|
+
cache += '.exe';
|
|
35
|
+
const download = async () => {
|
|
36
|
+
(0, log_1.log)(`downloading ${nodeBase} (${url})`);
|
|
37
|
+
await Promise.all([(0, fs_extra_1.ensureDir)(node_path_1.default.join(tmp, 'cache', nodeVersion)), (0, fs_extra_1.ensureDir)(node_path_1.default.join(tmp, 'node'))]);
|
|
38
|
+
const shasums = node_path_1.default.join(tmp, 'cache', nodeVersion, 'SHASUMS256.txt.asc');
|
|
39
|
+
const { default: got } = await import('got');
|
|
40
|
+
if (!(0, node_fs_1.existsSync)(shasums)) {
|
|
41
|
+
await (0, promises_2.pipeline)(got.stream(`https://nodejs.org/dist/v${nodeVersion}/SHASUMS256.txt.asc`), (0, node_fs_1.createWriteStream)(shasums));
|
|
42
|
+
}
|
|
43
|
+
const basedir = node_path_1.default.dirname(tarball);
|
|
44
|
+
await (0, promises_1.mkdir)(basedir, { recursive: true });
|
|
45
|
+
await (0, promises_2.pipeline)(got.stream(url), (0, node_fs_1.createWriteStream)(tarball));
|
|
46
|
+
if (platform !== 'win32')
|
|
47
|
+
await exec(`grep "${node_path_1.default.basename(tarball)}" "${shasums}" | shasum -a 256 -c -`, { cwd: basedir });
|
|
48
|
+
};
|
|
49
|
+
const extract = async () => {
|
|
50
|
+
(0, log_1.log)(`extracting ${nodeBase}`);
|
|
51
|
+
const nodeTmp = node_path_1.default.join(tmp, 'node');
|
|
52
|
+
await (0, promises_1.mkdir)(nodeTmp, { recursive: true });
|
|
53
|
+
await (0, promises_1.mkdir)(node_path_1.default.dirname(cache), { recursive: true });
|
|
54
|
+
if (platform === 'win32') {
|
|
55
|
+
await exec(`7z x -bd -y "${tarball}"`, { cwd: nodeTmp });
|
|
56
|
+
await (0, fs_extra_1.move)(node_path_1.default.join(nodeTmp, nodeBase, 'node.exe'), node_path_1.default.join(cache, 'node.exe'));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
await exec(`tar -C "${tmp}/node" -xJf "${tarball}"`);
|
|
60
|
+
await (0, fs_extra_1.move)(node_path_1.default.join(nodeTmp, nodeBase, 'bin', 'node'), node_path_1.default.join(cache, 'node'));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
if (!(0, node_fs_1.existsSync)(cache)) {
|
|
64
|
+
await (0, async_retry_1.default)(download, {
|
|
65
|
+
factor: 1,
|
|
66
|
+
maxTimeout: RETRY_TIMEOUT_MS,
|
|
67
|
+
minTimeout: RETRY_TIMEOUT_MS,
|
|
68
|
+
onRetry(_e, attempt) {
|
|
69
|
+
(0, log_1.log)(`retrying node download (attempt ${attempt})`);
|
|
70
|
+
},
|
|
71
|
+
retries: 3,
|
|
72
|
+
});
|
|
73
|
+
await extract();
|
|
74
|
+
}
|
|
75
|
+
await (0, fs_extra_1.copy)(node_path_1.default.join(cache, getFilename(platform)), output);
|
|
76
|
+
return output;
|
|
77
|
+
}
|
|
78
|
+
const getFilename = (platform) => (platform === 'win32' ? 'node.exe' : 'node');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Interfaces } from '@oclif/core';
|
|
2
|
+
import { BuildConfig as TarballConfig } from './tarballs/config';
|
|
3
|
+
export declare function commitAWSDir(version: string, sha: string, s3Config: TarballConfig['s3Config']): string;
|
|
4
|
+
export declare function channelAWSDir(channel: string, s3Config: TarballConfig['s3Config']): string;
|
|
5
|
+
type TemplateOptions = Interfaces.Config.s3Key.Options | {
|
|
6
|
+
arch?: DebArch | Interfaces.ArchTypes;
|
|
7
|
+
bin?: string;
|
|
8
|
+
ext?: '.tar.gz' | '.tar.xz';
|
|
9
|
+
sha?: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
versionShaRevision?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function templateShortKey(type: 'deb' | 'macos' | 'win32' | keyof Interfaces.S3Templates, options?: TemplateOptions): string;
|
|
14
|
+
export type DebArch = 'amd64' | 'arm64' | 'armel' | 'i386';
|
|
15
|
+
export declare function debArch(arch: Interfaces.ArchTypes): DebArch;
|
|
16
|
+
export declare function debVersion(buildConfig: TarballConfig): string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.commitAWSDir = commitAWSDir;
|
|
7
|
+
exports.channelAWSDir = channelAWSDir;
|
|
8
|
+
exports.templateShortKey = templateShortKey;
|
|
9
|
+
exports.debArch = debArch;
|
|
10
|
+
exports.debVersion = debVersion;
|
|
11
|
+
const ejs_1 = require("ejs");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
function commitAWSDir(version, sha, s3Config) {
|
|
14
|
+
let s3SubDir = s3Config.folder || '';
|
|
15
|
+
if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/')
|
|
16
|
+
s3SubDir = `${s3SubDir}/`;
|
|
17
|
+
return node_path_1.default.posix.join(s3SubDir, 'versions', version, sha);
|
|
18
|
+
}
|
|
19
|
+
function channelAWSDir(channel, s3Config) {
|
|
20
|
+
let s3SubDir = s3Config.folder || '';
|
|
21
|
+
if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/')
|
|
22
|
+
s3SubDir = `${s3SubDir}/`;
|
|
23
|
+
return node_path_1.default.posix.join(s3SubDir, 'channels', channel);
|
|
24
|
+
}
|
|
25
|
+
// TODO: refactor this key name lookup helper to oclif/core
|
|
26
|
+
function templateShortKey(type, options) {
|
|
27
|
+
if (!options)
|
|
28
|
+
options = {
|
|
29
|
+
root: '.',
|
|
30
|
+
};
|
|
31
|
+
const templates = {
|
|
32
|
+
baseDir: '<%- bin %>',
|
|
33
|
+
deb: '<%- bin %>_<%- versionShaRevision %>_<%- arch %>.deb',
|
|
34
|
+
macos: '<%- bin %>-v<%- version %>-<%- sha %>-<%- arch %>.pkg',
|
|
35
|
+
manifest: '<%- bin %>-v<%- version %>-<%- sha %>-<%- platform %>-<%- arch %>-buildmanifest',
|
|
36
|
+
unversioned: '<%- bin %>-<%- platform %>-<%- arch %><%- ext %>',
|
|
37
|
+
versioned: '<%- bin %>-v<%- version %>-<%- sha %>-<%- platform %>-<%- arch %><%- ext %>',
|
|
38
|
+
win32: '<%- bin %>-v<%- version %>-<%- sha %>-<%- arch %>.exe',
|
|
39
|
+
};
|
|
40
|
+
return (0, ejs_1.render)(templates[type], { ...options });
|
|
41
|
+
}
|
|
42
|
+
function debArch(arch) {
|
|
43
|
+
if (arch === 'x64')
|
|
44
|
+
return 'amd64';
|
|
45
|
+
if (arch === 'x86')
|
|
46
|
+
return 'i386';
|
|
47
|
+
if (arch === 'arm')
|
|
48
|
+
return 'armel';
|
|
49
|
+
if (arch === 'arm64')
|
|
50
|
+
return 'arm64';
|
|
51
|
+
throw new Error(`invalid arch: ${arch}`);
|
|
52
|
+
}
|
|
53
|
+
function debVersion(buildConfig) {
|
|
54
|
+
return `${buildConfig.config.version.split('-')[0]}.${buildConfig.gitSha}-1`;
|
|
55
|
+
// see debian_revision: https://www.debian.org/doc/debian-policy/ch-controlfields.html
|
|
56
|
+
}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function castArray<T>(input?: T | T[]): T[];
|
|
2
|
+
export declare function uniqBy<T>(arr: T[], fn: (cur: T) => unknown): T[];
|
|
3
|
+
export declare function compact<T>(a: (T | undefined)[]): T[];
|
|
4
|
+
export declare function uniq<T>(arr: T[]): T[];
|
|
5
|
+
type Types = boolean | number | string | undefined;
|
|
6
|
+
export declare function sortBy<T>(arr: T[], fn: (i: T) => Types | Types[]): T[];
|
|
7
|
+
interface VersionsObject {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const sortVersionsObjectByKeysDesc: (input: VersionsObject) => VersionsObject;
|
|
11
|
+
export declare const prettifyPaths: (input: unknown) => string;
|
|
12
|
+
export declare const hash: (algo: string, fp: string | string[]) => Promise<string>;
|
|
13
|
+
export declare function checkFor7Zip(): Promise<void>;
|
|
14
|
+
export declare function isEmpty(obj: Record<string, unknown>): boolean;
|
|
15
|
+
export declare function validateBin(bin: string): boolean;
|
|
16
|
+
export declare function isS3Compatible(endpoint: string | undefined): boolean;
|
|
17
|
+
export declare function getS3ChecksumConfig(endpoint: string | undefined, envValue: string | undefined): string | undefined;
|
|
18
|
+
export {};
|