oclif 4.8.8 → 4.9.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/lib/commands/generate.js +1 -0
- package/lib/commands/pack/deb.d.ts +1 -0
- package/lib/commands/pack/deb.js +9 -1
- package/lib/commands/pack/macos.d.ts +1 -0
- package/lib/commands/pack/macos.js +9 -1
- package/lib/commands/pack/tarballs.d.ts +1 -0
- package/lib/commands/pack/tarballs.js +2 -0
- package/lib/commands/pack/win.d.ts +1 -0
- package/lib/commands/pack/win.js +9 -1
- package/lib/generator.d.ts +4 -4
- package/lib/tarballs/build.d.ts +5 -2
- package/lib/tarballs/build.js +154 -152
- package/lib/tarballs/config.d.ts +10 -10
- package/oclif.manifest.json +43 -1
- package/package.json +2 -2
package/lib/commands/generate.js
CHANGED
|
@@ -234,6 +234,7 @@ class Generate extends generator_1.GeneratorCommand {
|
|
|
234
234
|
await (0, promises_1.rm)((0, node_path_1.join)(location, 'yarn.lock'));
|
|
235
235
|
}
|
|
236
236
|
await (0, generator_1.exec)(`${packageManager} install`, { cwd: location, silent: false });
|
|
237
|
+
await (0, generator_1.exec)(`${packageManager} run build`, { cwd: location, silent: false });
|
|
237
238
|
await (0, generator_1.exec)(`${(0, node_path_1.join)(location, 'node_modules', '.bin', 'oclif')} readme`, {
|
|
238
239
|
cwd: location,
|
|
239
240
|
// When testing this command in development, you get noisy compilation errors as a result of running
|
|
@@ -3,6 +3,7 @@ export default class PackDeb extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
compression: Interfaces.OptionFlag<"xz" | "gzip" | "none" | "zstd" | undefined, Interfaces.CustomOptions>;
|
|
6
|
+
'prune-lockfiles': Interfaces.BooleanFlag<boolean>;
|
|
6
7
|
root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
7
8
|
tarball: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
8
9
|
};
|
package/lib/commands/pack/deb.js
CHANGED
|
@@ -80,10 +80,12 @@ class PackDeb extends core_1.Command {
|
|
|
80
80
|
description: 'For more details see the `-Zcompress-type` section at https://man7.org/linux/man-pages/man1/dpkg-deb.1.html',
|
|
81
81
|
summary: 'Override the default compression used by dpkg-deb.',
|
|
82
82
|
}),
|
|
83
|
+
'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.', exclusive: ['tarball'] }),
|
|
83
84
|
root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
|
|
84
85
|
tarball: core_1.Flags.string({
|
|
85
86
|
char: 't',
|
|
86
87
|
description: 'Optionally specify a path to a tarball already generated by NPM.',
|
|
88
|
+
exclusive: ['prune-lockfiles'],
|
|
87
89
|
required: false,
|
|
88
90
|
}),
|
|
89
91
|
};
|
|
@@ -94,7 +96,13 @@ class PackDeb extends core_1.Command {
|
|
|
94
96
|
const { flags } = await this.parse(PackDeb);
|
|
95
97
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
96
98
|
const { config } = buildConfig;
|
|
97
|
-
await Tarballs.build(buildConfig, {
|
|
99
|
+
await Tarballs.build(buildConfig, {
|
|
100
|
+
pack: false,
|
|
101
|
+
parallel: true,
|
|
102
|
+
platform: 'linux',
|
|
103
|
+
pruneLockfiles: flags['prune-lockfiles'],
|
|
104
|
+
tarball: flags.tarball,
|
|
105
|
+
});
|
|
98
106
|
const dist = buildConfig.dist('deb');
|
|
99
107
|
await fs.emptyDir(dist);
|
|
100
108
|
const build = async (arch) => {
|
|
@@ -3,6 +3,7 @@ export default class PackMacos extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
'additional-cli': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
6
|
+
'prune-lockfiles': Interfaces.BooleanFlag<boolean>;
|
|
6
7
|
root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
7
8
|
tarball: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
8
9
|
targets: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
@@ -157,6 +157,7 @@ class PackMacos extends core_1.Command {
|
|
|
157
157
|
the CLI should already exist in a directory named after the CLI that is the root of the tarball produced by "oclif pack:tarballs"`,
|
|
158
158
|
hidden: true,
|
|
159
159
|
}),
|
|
160
|
+
'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.', exclusive: ['tarball'] }),
|
|
160
161
|
root: core_1.Flags.string({
|
|
161
162
|
char: 'r',
|
|
162
163
|
default: '.',
|
|
@@ -166,6 +167,7 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
166
167
|
tarball: core_1.Flags.string({
|
|
167
168
|
char: 't',
|
|
168
169
|
description: 'Optionally specify a path to a tarball already generated by NPM.',
|
|
170
|
+
exclusive: ['prune-lockfiles'],
|
|
169
171
|
required: false,
|
|
170
172
|
}),
|
|
171
173
|
targets: core_1.Flags.string({
|
|
@@ -186,7 +188,13 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
186
188
|
this.error('package.json must have oclif.macos.identifier set');
|
|
187
189
|
const macos = c.macos;
|
|
188
190
|
const packageIdentifier = macos.identifier;
|
|
189
|
-
await Tarballs.build(buildConfig, {
|
|
191
|
+
await Tarballs.build(buildConfig, {
|
|
192
|
+
pack: false,
|
|
193
|
+
parallel: true,
|
|
194
|
+
platform: 'darwin',
|
|
195
|
+
pruneLockfiles: flags['prune-lockfiles'],
|
|
196
|
+
tarball: flags.tarball,
|
|
197
|
+
});
|
|
190
198
|
const scriptsDir = path.join(buildConfig.tmp, 'macos/scripts');
|
|
191
199
|
await fs.emptyDir(buildConfig.dist('macos'));
|
|
192
200
|
const noBundleConfigurationPath = path.join(buildConfig.tmp, 'macos', 'no-bundle.plist');
|
|
@@ -3,6 +3,7 @@ export default class PackTarballs extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
parallel: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
'prune-lockfiles': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
7
|
root: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
8
|
tarball: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
9
|
targets: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -31,6 +31,7 @@ class PackTarballs extends core_1.Command {
|
|
|
31
31
|
Add a pretarball script to your package.json if you need to run any scripts before the tarball is created.`;
|
|
32
32
|
static flags = {
|
|
33
33
|
parallel: core_1.Flags.boolean({ description: 'Build tarballs in parallel.' }),
|
|
34
|
+
'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.' }),
|
|
34
35
|
root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
|
|
35
36
|
tarball: core_1.Flags.string({
|
|
36
37
|
char: 'l',
|
|
@@ -51,6 +52,7 @@ Add a pretarball script to your package.json if you need to run any scripts befo
|
|
|
51
52
|
}
|
|
52
53
|
await Tarballs.build(buildConfig, {
|
|
53
54
|
parallel: flags.parallel,
|
|
55
|
+
pruneLockfiles: flags['prune-lockfiles'],
|
|
54
56
|
tarball: flags.tarball,
|
|
55
57
|
});
|
|
56
58
|
}
|
|
@@ -4,6 +4,7 @@ export default class PackWin extends Command {
|
|
|
4
4
|
static flags: {
|
|
5
5
|
'additional-cli': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
6
6
|
'defender-exclusion': Interfaces.OptionFlag<"hidden" | "checked" | "unchecked", Interfaces.CustomOptions>;
|
|
7
|
+
'prune-lockfiles': Interfaces.BooleanFlag<boolean>;
|
|
7
8
|
root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
8
9
|
tarball: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
9
10
|
targets: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
package/lib/commands/pack/win.js
CHANGED
|
@@ -242,6 +242,7 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
242
242
|
description: 'There is no way to set a hidden checkbox with "true" as a default...the user can always allow full security',
|
|
243
243
|
summary: `Set to "checked" or "unchecked" to set the default value for the checkbox. Set to "hidden" to hide the option (will let defender do its thing).`,
|
|
244
244
|
}),
|
|
245
|
+
'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.', exclusive: ['tarball'] }),
|
|
245
246
|
root: core_1.Flags.string({
|
|
246
247
|
char: 'r',
|
|
247
248
|
default: '.',
|
|
@@ -251,6 +252,7 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
251
252
|
tarball: core_1.Flags.string({
|
|
252
253
|
char: 't',
|
|
253
254
|
description: 'Optionally specify a path to a tarball already generated by NPM.',
|
|
255
|
+
exclusive: ['prune-lockfiles'],
|
|
254
256
|
required: false,
|
|
255
257
|
}),
|
|
256
258
|
targets: core_1.Flags.string({
|
|
@@ -265,7 +267,13 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
265
267
|
const { config } = buildConfig;
|
|
266
268
|
const nsisCustomization = config.nsisCustomization ? (0, node_fs_1.readFileSync)(config.nsisCustomization, 'utf8') : '';
|
|
267
269
|
const arches = buildConfig.targets.filter((t) => t.platform === 'win32').map((t) => t.arch);
|
|
268
|
-
await Tarballs.build(buildConfig, {
|
|
270
|
+
await Tarballs.build(buildConfig, {
|
|
271
|
+
pack: false,
|
|
272
|
+
parallel: true,
|
|
273
|
+
platform: 'win32',
|
|
274
|
+
pruneLockfiles: flags['prune-lockfiles'],
|
|
275
|
+
tarball: flags.tarball,
|
|
276
|
+
});
|
|
269
277
|
await Promise.all(arches.map(async (arch) => {
|
|
270
278
|
const installerBase = path.join(buildConfig.tmp, `windows-${arch}-installer`);
|
|
271
279
|
await (0, promises_1.rm)(installerBase, { force: true, recursive: true });
|
package/lib/generator.d.ts
CHANGED
|
@@ -28,15 +28,15 @@ export type GetFlagOrPromptOptions = {
|
|
|
28
28
|
*/
|
|
29
29
|
type: 'input' | 'select';
|
|
30
30
|
};
|
|
31
|
-
export declare function exec(command: string, opts?:
|
|
31
|
+
export declare function exec(command: string, opts?: {
|
|
32
32
|
silent?: boolean;
|
|
33
|
-
}): Promise<{
|
|
33
|
+
} & ExecOptions): Promise<{
|
|
34
34
|
stderr: string;
|
|
35
35
|
stdout: string;
|
|
36
36
|
}>;
|
|
37
|
-
export declare function readPJSON(location: string): Promise<(
|
|
37
|
+
export declare function readPJSON(location: string): Promise<({
|
|
38
38
|
scripts: Record<string, string>;
|
|
39
|
-
}) | undefined>;
|
|
39
|
+
} & Interfaces.PJSON.CLI) | undefined>;
|
|
40
40
|
export declare function makeFlags<T extends Record<string, FlaggablePrompt>>(flaggablePrompts: T): FlagsOfPrompts<T>;
|
|
41
41
|
export declare abstract class GeneratorCommand<T extends typeof Command> extends Command {
|
|
42
42
|
protected args: Args<T>;
|
package/lib/tarballs/build.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { BuildConfig } from './config';
|
|
2
|
-
|
|
2
|
+
type BuildOptions = {
|
|
3
3
|
pack?: boolean;
|
|
4
4
|
parallel?: boolean;
|
|
5
5
|
platform?: string;
|
|
6
|
+
pruneLockfiles?: boolean;
|
|
6
7
|
tarball?: string;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function build(c: BuildConfig, options?: BuildOptions): Promise<void>;
|
|
10
|
+
export {};
|
package/lib/tarballs/build.js
CHANGED
|
@@ -86,168 +86,170 @@ const copyCoreYarnFiles = async (yarnRootPath, workspacePath) => {
|
|
|
86
86
|
await copyYarnDirectory('./.yarn/plugins/', yarnRootPath, workspacePath);
|
|
87
87
|
};
|
|
88
88
|
async function build(c, options = {}) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
await
|
|
102
|
-
|
|
103
|
-
await Promise.all(files.map((i) => (0, fs_extra_1.move)(path.join(c.workspace(), 'package', i.name), path.join(c.workspace(), i.name))));
|
|
104
|
-
await Promise.all([
|
|
105
|
-
(0, promises_1.rm)(path.join(c.workspace(), 'package'), { recursive: true }),
|
|
106
|
-
(0, promises_1.rm)(path.join(c.workspace(), path.basename(tarball)), { recursive: true }),
|
|
107
|
-
(0, fs_extra_1.remove)(path.join(c.workspace(), 'bin', 'run.cmd')),
|
|
108
|
-
]);
|
|
109
|
-
};
|
|
110
|
-
const updatePJSON = async () => {
|
|
111
|
-
const pjsonPath = path.join(c.workspace(), 'package.json');
|
|
112
|
-
const pjson = await (0, fs_extra_1.readJSON)(pjsonPath);
|
|
113
|
-
pjson.version = config.version;
|
|
114
|
-
pjson.oclif.update = pjson.oclif.update || {};
|
|
115
|
-
pjson.oclif.update.s3 = pjson.oclif.update.s3 || {};
|
|
116
|
-
pjson.oclif.update.s3.bucket = c.s3Config.bucket;
|
|
117
|
-
await (0, fs_extra_1.writeJSON)(pjsonPath, pjson, { spaces: 2 });
|
|
118
|
-
};
|
|
119
|
-
const addDependencies = async () => {
|
|
120
|
-
const yarnRoot = (0, find_yarn_workspace_root_1.default)(c.root) || c.root;
|
|
121
|
-
if (isYarnProject(yarnRoot)) {
|
|
122
|
-
await copyCoreYarnFiles(yarnRoot, c.workspace());
|
|
123
|
-
const { stdout } = await exec('yarn -v');
|
|
124
|
-
const yarnVersion = stdout.charAt(0);
|
|
125
|
-
if (yarnVersion === '1') {
|
|
126
|
-
await exec('yarn --no-progress --production --non-interactive', { cwd: c.workspace() });
|
|
127
|
-
}
|
|
128
|
-
else if (yarnVersion === '2') {
|
|
129
|
-
throw new Error('Yarn 2 is not supported yet. Try using Yarn 1, or Yarn 3');
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
try {
|
|
133
|
-
await exec('yarn workspaces focus --production', { cwd: c.workspace() });
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
if (error instanceof Error && error.message.includes('Command not found')) {
|
|
137
|
-
throw new Error('Missing workspace tools. Run `yarn plugin import workspace-tools`.');
|
|
138
|
-
}
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
const lockpath = (0, node_fs_1.existsSync)(path.join(c.root, 'package-lock.json'))
|
|
145
|
-
? path.join(c.root, 'package-lock.json')
|
|
146
|
-
: path.join(c.root, 'npm-shrinkwrap.json');
|
|
147
|
-
await (0, fs_extra_1.copy)(lockpath, path.join(c.workspace(), path.basename(lockpath)));
|
|
148
|
-
await exec('npm install --production', { cwd: c.workspace() });
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const pretarball = async () => {
|
|
152
|
-
const pjson = await (0, fs_extra_1.readJSON)(path.join(c.workspace(), 'package.json'));
|
|
153
|
-
const yarnRoot = (0, find_yarn_workspace_root_1.default)(c.root) || c.root;
|
|
154
|
-
const yarn = (0, node_fs_1.existsSync)(path.join(yarnRoot, 'yarn.lock'));
|
|
155
|
-
if (pjson.scripts.pretarball) {
|
|
156
|
-
yarn
|
|
157
|
-
? await exec('yarn run pretarball', { cwd: c.workspace() })
|
|
158
|
-
: await exec('npm run pretarball', { cwd: c.workspace() });
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const buildTarget = async (target) => {
|
|
162
|
-
const workspace = c.workspace(target);
|
|
163
|
-
const gzLocalKey = (0, upload_util_1.templateShortKey)('versioned', {
|
|
164
|
-
arch: target.arch,
|
|
165
|
-
bin: c.config.bin,
|
|
166
|
-
ext: '.tar.gz',
|
|
167
|
-
platform: target.platform,
|
|
168
|
-
sha: c.gitSha,
|
|
169
|
-
version: config.version,
|
|
170
|
-
});
|
|
171
|
-
const xzLocalKey = (0, upload_util_1.templateShortKey)('versioned', {
|
|
172
|
-
arch: target.arch,
|
|
173
|
-
bin: c.config.bin,
|
|
174
|
-
ext: '.tar.xz',
|
|
175
|
-
platform: target.platform,
|
|
176
|
-
sha: c.gitSha,
|
|
177
|
-
version: config.version,
|
|
178
|
-
});
|
|
179
|
-
const base = path.basename(gzLocalKey);
|
|
180
|
-
(0, log_1.log)(`building target ${base}`);
|
|
181
|
-
(0, log_1.log)('copying workspace', c.workspace(), workspace);
|
|
182
|
-
await (0, fs_extra_1.emptyDir)(workspace);
|
|
183
|
-
await (0, fs_extra_1.copy)(c.workspace(), workspace);
|
|
184
|
-
await (0, node_1.fetchNodeBinary)({
|
|
185
|
-
arch: target.arch,
|
|
186
|
-
nodeVersion: c.nodeVersion,
|
|
187
|
-
output: path.join(workspace, 'bin', 'node'),
|
|
188
|
-
platform: target.platform,
|
|
189
|
-
tmp: path.join(config.root, 'tmp'),
|
|
190
|
-
});
|
|
191
|
-
if (options.pack === false)
|
|
192
|
-
return;
|
|
193
|
-
if (options.parallel) {
|
|
194
|
-
await Promise.all([pack(workspace, c.dist(gzLocalKey)), ...(xz ? [pack(workspace, c.dist(xzLocalKey))] : [])]);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
await pack(workspace, c.dist(gzLocalKey));
|
|
198
|
-
if (xz)
|
|
199
|
-
await pack(workspace, c.dist(xzLocalKey));
|
|
200
|
-
}
|
|
201
|
-
if (!c.updateConfig.s3.host)
|
|
202
|
-
return;
|
|
203
|
-
const rollout = typeof c.updateConfig.autoupdate === 'object' && c.updateConfig.autoupdate.rollout;
|
|
204
|
-
const gzCloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, c.gitSha, c.updateConfig.s3)}/${gzLocalKey}`;
|
|
205
|
-
const xzCloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, c.gitSha, c.updateConfig.s3)}/${xzLocalKey}`;
|
|
206
|
-
const [sha256gz, sha256xz] = await Promise.all([
|
|
207
|
-
(0, util_1.hash)('sha256', c.dist(gzLocalKey)),
|
|
208
|
-
...(xz ? [(0, util_1.hash)('sha256', c.dist(xzLocalKey))] : []),
|
|
209
|
-
]);
|
|
210
|
-
const manifest = {
|
|
211
|
-
baseDir: (0, upload_util_1.templateShortKey)('baseDir', { ...target, bin: c.config.bin }),
|
|
212
|
-
gz: config.s3Url(gzCloudKey),
|
|
213
|
-
node: {
|
|
214
|
-
compatible: config.pjson.engines.node,
|
|
215
|
-
recommended: c.nodeVersion,
|
|
216
|
-
},
|
|
217
|
-
rollout: rollout === false ? undefined : rollout,
|
|
218
|
-
sha: c.gitSha,
|
|
219
|
-
sha256gz,
|
|
220
|
-
sha256xz,
|
|
221
|
-
version: config.version,
|
|
222
|
-
xz: xz ? config.s3Url(xzCloudKey) : undefined,
|
|
223
|
-
};
|
|
224
|
-
const manifestFilepath = c.dist((0, upload_util_1.templateShortKey)('manifest', {
|
|
225
|
-
arch: target.arch,
|
|
226
|
-
bin: c.config.bin,
|
|
227
|
-
platform: target.platform,
|
|
228
|
-
sha: c.gitSha,
|
|
229
|
-
version: config.version,
|
|
230
|
-
}));
|
|
231
|
-
await (0, fs_extra_1.writeJSON)(manifestFilepath, manifest, { spaces: 2 });
|
|
232
|
-
};
|
|
233
|
-
(0, log_1.log)(`gathering workspace for ${config.bin} to ${c.workspace()}`);
|
|
234
|
-
await extractCLI(options.tarball ?? (await packCLI()));
|
|
235
|
-
await updatePJSON();
|
|
236
|
-
await addDependencies();
|
|
237
|
-
await (0, bin_1.writeBinScripts)({ baseWorkspace: c.workspace(), config, nodeOptions: c.nodeOptions, nodeVersion: c.nodeVersion });
|
|
238
|
-
await pretarball();
|
|
89
|
+
(0, log_1.log)(`gathering workspace for ${c.config.bin} to ${c.workspace()}`);
|
|
90
|
+
await extractCLI(options.tarball ?? (await packCLI(c)), c);
|
|
91
|
+
await updatePJSON(c);
|
|
92
|
+
await addDependencies(c);
|
|
93
|
+
await (0, bin_1.writeBinScripts)({
|
|
94
|
+
baseWorkspace: c.workspace(),
|
|
95
|
+
config: c.config,
|
|
96
|
+
nodeOptions: c.nodeOptions,
|
|
97
|
+
nodeVersion: c.nodeVersion,
|
|
98
|
+
});
|
|
99
|
+
await pretarball(c);
|
|
100
|
+
if (options.pruneLockfiles) {
|
|
101
|
+
await removeLockfiles(c);
|
|
102
|
+
}
|
|
239
103
|
const targetsToBuild = c.targets.filter((t) => !options.platform || options.platform === t.platform);
|
|
240
104
|
if (options.parallel) {
|
|
241
105
|
(0, log_1.log)(`will build ${targetsToBuild.length} targets in parallel`);
|
|
242
|
-
await Promise.all(targetsToBuild.map((t) => buildTarget(t)));
|
|
106
|
+
await Promise.all(targetsToBuild.map((t) => buildTarget(t, c, options)));
|
|
243
107
|
}
|
|
244
108
|
else {
|
|
245
109
|
(0, log_1.log)(`will build ${targetsToBuild.length} targets sequentially`);
|
|
246
110
|
for (const target of targetsToBuild) {
|
|
247
111
|
// eslint-disable-next-line no-await-in-loop
|
|
248
|
-
await buildTarget(target);
|
|
112
|
+
await buildTarget(target, c, options);
|
|
249
113
|
}
|
|
250
114
|
(0, log_1.log)(`finished building ${targetsToBuild.length} targets sequentially`);
|
|
251
115
|
}
|
|
252
116
|
}
|
|
253
117
|
exports.build = build;
|
|
118
|
+
const isLockFile = (f) => f.endsWith('package-lock.json') ||
|
|
119
|
+
f.endsWith('yarn.lock') ||
|
|
120
|
+
f.endsWith('npm-shrinkwrap.json') ||
|
|
121
|
+
f.endsWith('oclif.lock') ||
|
|
122
|
+
f.endsWith('pnpm-lock.yaml');
|
|
123
|
+
/** recursively remove all lockfiles from tarball after installing dependencies */
|
|
124
|
+
const removeLockfiles = async (c) => {
|
|
125
|
+
const files = await (0, promises_1.readdir)(c.workspace(), { recursive: true });
|
|
126
|
+
const lockfiles = files.filter((f) => isLockFile(f)).map((f) => path.join(c.workspace(), f));
|
|
127
|
+
(0, log_1.log)(`removing ${lockfiles.length} lockfiles`);
|
|
128
|
+
await Promise.all(lockfiles.map((f) => (0, fs_extra_1.remove)(f)));
|
|
129
|
+
};
|
|
130
|
+
/** runs the pretarball script from the cli being packed */
|
|
131
|
+
const pretarball = async (c) => {
|
|
132
|
+
const pjson = await (0, fs_extra_1.readJSON)(path.join(c.workspace(), 'package.json'));
|
|
133
|
+
if (!pjson.scripts.pretarball)
|
|
134
|
+
return;
|
|
135
|
+
const yarnRoot = (0, find_yarn_workspace_root_1.default)(c.root) || c.root;
|
|
136
|
+
const hasYarnLock = (0, node_fs_1.existsSync)(path.join(yarnRoot, 'yarn.lock'));
|
|
137
|
+
const script = `${hasYarnLock ? 'yarn' : 'npm'} run pretarball`;
|
|
138
|
+
(0, log_1.log)(`running pretarball via ${script} in ${c.workspace()}`);
|
|
139
|
+
await exec(script, { cwd: c.workspace() });
|
|
140
|
+
};
|
|
141
|
+
const updatePJSON = async (c) => {
|
|
142
|
+
const pjsonPath = path.join(c.workspace(), 'package.json');
|
|
143
|
+
const pjson = await (0, fs_extra_1.readJSON)(pjsonPath);
|
|
144
|
+
pjson.version = c.config.version;
|
|
145
|
+
pjson.oclif.update = pjson.oclif.update ?? {};
|
|
146
|
+
pjson.oclif.update.s3 = pjson.oclif.update.s3 ?? {};
|
|
147
|
+
pjson.oclif.update.s3.bucket = c.s3Config.bucket;
|
|
148
|
+
await (0, fs_extra_1.writeJSON)(pjsonPath, pjson, { spaces: 2 });
|
|
149
|
+
};
|
|
150
|
+
const addDependencies = async (c) => {
|
|
151
|
+
const yarnRoot = (0, find_yarn_workspace_root_1.default)(c.root) || c.root;
|
|
152
|
+
if (isYarnProject(yarnRoot)) {
|
|
153
|
+
await copyCoreYarnFiles(yarnRoot, c.workspace());
|
|
154
|
+
const { stdout } = await exec('yarn -v');
|
|
155
|
+
const yarnVersion = stdout.charAt(0);
|
|
156
|
+
if (yarnVersion === '1') {
|
|
157
|
+
await exec('yarn --no-progress --production --non-interactive', { cwd: c.workspace() });
|
|
158
|
+
}
|
|
159
|
+
else if (yarnVersion === '2') {
|
|
160
|
+
throw new Error('Yarn 2 is not supported yet. Try using Yarn 1, or Yarn 3');
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
try {
|
|
164
|
+
await exec('yarn workspaces focus --production', { cwd: c.workspace() });
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (error instanceof Error && error.message.includes('Command not found')) {
|
|
168
|
+
throw new Error('Missing workspace tools. Run `yarn plugin import workspace-tools`.');
|
|
169
|
+
}
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const lockpath = (0, node_fs_1.existsSync)(path.join(c.root, 'package-lock.json'))
|
|
176
|
+
? path.join(c.root, 'package-lock.json')
|
|
177
|
+
: path.join(c.root, 'npm-shrinkwrap.json');
|
|
178
|
+
await (0, fs_extra_1.copy)(lockpath, path.join(c.workspace(), path.basename(lockpath)));
|
|
179
|
+
await exec('npm install --production', { cwd: c.workspace() });
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const packCLI = async (c) => {
|
|
183
|
+
const { stdout } = await exec('npm pack --unsafe-perm', { cwd: c.root });
|
|
184
|
+
return path.join(c.root, stdout.trim().split('\n').pop());
|
|
185
|
+
};
|
|
186
|
+
const extractCLI = async (tarball, c) => {
|
|
187
|
+
const workspace = c.workspace();
|
|
188
|
+
await (0, fs_extra_1.emptyDir)(workspace);
|
|
189
|
+
const tarballNewLocation = path.join(workspace, path.basename(tarball));
|
|
190
|
+
await (0, fs_extra_1.move)(tarball, tarballNewLocation);
|
|
191
|
+
const tarCommand = `tar -xzf "${tarballNewLocation}"${process.platform === 'win32' ? ' --force-local' : ''}`;
|
|
192
|
+
await exec(tarCommand, { cwd: workspace });
|
|
193
|
+
const files = await (0, promises_1.readdir)(path.join(workspace, 'package'), { withFileTypes: true });
|
|
194
|
+
await Promise.all(files.map((i) => (0, fs_extra_1.move)(path.join(workspace, 'package', i.name), path.join(workspace, i.name))));
|
|
195
|
+
await Promise.all([
|
|
196
|
+
(0, promises_1.rm)(path.join(workspace, 'package'), { recursive: true }),
|
|
197
|
+
(0, promises_1.rm)(path.join(workspace, path.basename(tarball)), { recursive: true }),
|
|
198
|
+
(0, fs_extra_1.remove)(path.join(workspace, 'bin', 'run.cmd')),
|
|
199
|
+
]);
|
|
200
|
+
};
|
|
201
|
+
const buildTarget = async (target, c, options) => {
|
|
202
|
+
const workspace = c.workspace(target);
|
|
203
|
+
const { arch, platform } = target;
|
|
204
|
+
const { bin, version } = c.config;
|
|
205
|
+
const { gitSha: sha } = c;
|
|
206
|
+
const templateShortKeyCommonOptions = { arch, bin, platform, sha, version };
|
|
207
|
+
const [gzLocalKey, xzLocalKey] = ['.tar.gz', '.tar.xz'].map((ext) => (0, upload_util_1.templateShortKey)('versioned', { ...templateShortKeyCommonOptions, ext }));
|
|
208
|
+
const base = path.basename(gzLocalKey);
|
|
209
|
+
(0, log_1.log)(`building target ${base}`);
|
|
210
|
+
(0, log_1.log)('copying workspace', c.workspace(), workspace);
|
|
211
|
+
await (0, fs_extra_1.emptyDir)(workspace);
|
|
212
|
+
await (0, fs_extra_1.copy)(c.workspace(), workspace);
|
|
213
|
+
await (0, node_1.fetchNodeBinary)({
|
|
214
|
+
arch,
|
|
215
|
+
nodeVersion: c.nodeVersion,
|
|
216
|
+
output: path.join(workspace, 'bin', 'node'),
|
|
217
|
+
platform,
|
|
218
|
+
tmp: path.join(c.config.root, 'tmp'),
|
|
219
|
+
});
|
|
220
|
+
if (options.pack === false)
|
|
221
|
+
return;
|
|
222
|
+
if (options.parallel) {
|
|
223
|
+
await Promise.all([pack(workspace, c.dist(gzLocalKey)), ...(c.xz ? [pack(workspace, c.dist(xzLocalKey))] : [])]);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
await pack(workspace, c.dist(gzLocalKey));
|
|
227
|
+
if (c.xz)
|
|
228
|
+
await pack(workspace, c.dist(xzLocalKey));
|
|
229
|
+
}
|
|
230
|
+
if (!c.updateConfig.s3.host)
|
|
231
|
+
return;
|
|
232
|
+
const rollout = typeof c.updateConfig.autoupdate === 'object' && c.updateConfig.autoupdate.rollout;
|
|
233
|
+
const gzCloudKey = `${(0, upload_util_1.commitAWSDir)(version, sha, c.updateConfig.s3)}/${gzLocalKey}`;
|
|
234
|
+
const xzCloudKey = `${(0, upload_util_1.commitAWSDir)(version, sha, c.updateConfig.s3)}/${xzLocalKey}`;
|
|
235
|
+
const [sha256gz, sha256xz] = await Promise.all([
|
|
236
|
+
(0, util_1.hash)('sha256', c.dist(gzLocalKey)),
|
|
237
|
+
...(c.xz ? [(0, util_1.hash)('sha256', c.dist(xzLocalKey))] : []),
|
|
238
|
+
]);
|
|
239
|
+
const manifest = {
|
|
240
|
+
baseDir: (0, upload_util_1.templateShortKey)('baseDir', { ...target, bin }),
|
|
241
|
+
gz: c.config.s3Url(gzCloudKey),
|
|
242
|
+
node: {
|
|
243
|
+
compatible: c.config.pjson.engines.node,
|
|
244
|
+
recommended: c.nodeVersion,
|
|
245
|
+
},
|
|
246
|
+
rollout: rollout === false ? undefined : rollout,
|
|
247
|
+
sha,
|
|
248
|
+
sha256gz,
|
|
249
|
+
sha256xz,
|
|
250
|
+
version,
|
|
251
|
+
xz: c.xz ? c.config.s3Url(xzCloudKey) : undefined,
|
|
252
|
+
};
|
|
253
|
+
const manifestFilepath = c.dist((0, upload_util_1.templateShortKey)('manifest', templateShortKeyCommonOptions));
|
|
254
|
+
await (0, fs_extra_1.writeJSON)(manifestFilepath, manifest, { spaces: 2 });
|
|
255
|
+
};
|
package/lib/tarballs/config.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ObjectCannedACL } from '@aws-sdk/client-s3';
|
|
2
2
|
import { Interfaces } from '@oclif/core';
|
|
3
3
|
export declare const TARGETS: string[];
|
|
4
|
-
export type S3Config =
|
|
4
|
+
export type S3Config = {
|
|
5
|
+
acl?: ObjectCannedACL;
|
|
6
|
+
} & {
|
|
5
7
|
folder?: string;
|
|
6
8
|
indexVersionLimit?: number;
|
|
7
|
-
} &
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type UpdateConfig = BuildConfig['config']['pjson']['oclif']['update'] & {
|
|
11
|
-
s3?: BuildConfig['config']['pjson']['oclif']['update']['s3'] & {
|
|
9
|
+
} & BuildConfig['updateConfig']['s3'];
|
|
10
|
+
export type UpdateConfig = {
|
|
11
|
+
s3?: {
|
|
12
12
|
acl?: ObjectCannedACL;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export
|
|
13
|
+
} & BuildConfig['config']['pjson']['oclif']['update']['s3'];
|
|
14
|
+
} & BuildConfig['config']['pjson']['oclif']['update'];
|
|
15
|
+
export type BuildConfig = {
|
|
16
16
|
config: Interfaces.Config;
|
|
17
17
|
dist(input: string): string;
|
|
18
18
|
gitSha: string;
|
|
@@ -31,7 +31,7 @@ export interface BuildConfig {
|
|
|
31
31
|
platform: Interfaces.PlatformTypes;
|
|
32
32
|
}): string;
|
|
33
33
|
xz: boolean;
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
35
|
export declare function gitSha(cwd: string, options?: {
|
|
36
36
|
short?: boolean;
|
|
37
37
|
}): Promise<string>;
|
package/oclif.manifest.json
CHANGED
|
@@ -647,6 +647,15 @@
|
|
|
647
647
|
],
|
|
648
648
|
"type": "option"
|
|
649
649
|
},
|
|
650
|
+
"prune-lockfiles": {
|
|
651
|
+
"description": "remove lockfiles in the tarball.",
|
|
652
|
+
"exclusive": [
|
|
653
|
+
"tarball"
|
|
654
|
+
],
|
|
655
|
+
"name": "prune-lockfiles",
|
|
656
|
+
"allowNo": false,
|
|
657
|
+
"type": "boolean"
|
|
658
|
+
},
|
|
650
659
|
"root": {
|
|
651
660
|
"char": "r",
|
|
652
661
|
"description": "Path to oclif CLI root.",
|
|
@@ -660,6 +669,9 @@
|
|
|
660
669
|
"tarball": {
|
|
661
670
|
"char": "t",
|
|
662
671
|
"description": "Optionally specify a path to a tarball already generated by NPM.",
|
|
672
|
+
"exclusive": [
|
|
673
|
+
"prune-lockfiles"
|
|
674
|
+
],
|
|
663
675
|
"name": "tarball",
|
|
664
676
|
"required": false,
|
|
665
677
|
"hasDynamicHelp": false,
|
|
@@ -697,6 +709,15 @@
|
|
|
697
709
|
"multiple": false,
|
|
698
710
|
"type": "option"
|
|
699
711
|
},
|
|
712
|
+
"prune-lockfiles": {
|
|
713
|
+
"description": "remove lockfiles in the tarball.",
|
|
714
|
+
"exclusive": [
|
|
715
|
+
"tarball"
|
|
716
|
+
],
|
|
717
|
+
"name": "prune-lockfiles",
|
|
718
|
+
"allowNo": false,
|
|
719
|
+
"type": "boolean"
|
|
720
|
+
},
|
|
700
721
|
"root": {
|
|
701
722
|
"char": "r",
|
|
702
723
|
"description": "Path to oclif CLI root.",
|
|
@@ -710,6 +731,9 @@
|
|
|
710
731
|
"tarball": {
|
|
711
732
|
"char": "t",
|
|
712
733
|
"description": "Optionally specify a path to a tarball already generated by NPM.",
|
|
734
|
+
"exclusive": [
|
|
735
|
+
"prune-lockfiles"
|
|
736
|
+
],
|
|
713
737
|
"name": "tarball",
|
|
714
738
|
"required": false,
|
|
715
739
|
"hasDynamicHelp": false,
|
|
@@ -752,6 +776,12 @@
|
|
|
752
776
|
"allowNo": false,
|
|
753
777
|
"type": "boolean"
|
|
754
778
|
},
|
|
779
|
+
"prune-lockfiles": {
|
|
780
|
+
"description": "remove lockfiles in the tarball.",
|
|
781
|
+
"name": "prune-lockfiles",
|
|
782
|
+
"allowNo": false,
|
|
783
|
+
"type": "boolean"
|
|
784
|
+
},
|
|
755
785
|
"root": {
|
|
756
786
|
"char": "r",
|
|
757
787
|
"description": "Path to oclif CLI root.",
|
|
@@ -830,6 +860,15 @@
|
|
|
830
860
|
],
|
|
831
861
|
"type": "option"
|
|
832
862
|
},
|
|
863
|
+
"prune-lockfiles": {
|
|
864
|
+
"description": "remove lockfiles in the tarball.",
|
|
865
|
+
"exclusive": [
|
|
866
|
+
"tarball"
|
|
867
|
+
],
|
|
868
|
+
"name": "prune-lockfiles",
|
|
869
|
+
"allowNo": false,
|
|
870
|
+
"type": "boolean"
|
|
871
|
+
},
|
|
833
872
|
"root": {
|
|
834
873
|
"char": "r",
|
|
835
874
|
"description": "Path to oclif CLI root.",
|
|
@@ -843,6 +882,9 @@
|
|
|
843
882
|
"tarball": {
|
|
844
883
|
"char": "t",
|
|
845
884
|
"description": "Optionally specify a path to a tarball already generated by NPM.",
|
|
885
|
+
"exclusive": [
|
|
886
|
+
"prune-lockfiles"
|
|
887
|
+
],
|
|
846
888
|
"name": "tarball",
|
|
847
889
|
"required": false,
|
|
848
890
|
"hasDynamicHelp": false,
|
|
@@ -1032,5 +1074,5 @@
|
|
|
1032
1074
|
]
|
|
1033
1075
|
}
|
|
1034
1076
|
},
|
|
1035
|
-
"version": "4.
|
|
1077
|
+
"version": "4.9.0"
|
|
1036
1078
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oclif",
|
|
3
3
|
"description": "oclif: create your own CLI",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.9.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bin": {
|
|
7
7
|
"oclif": "bin/run.js"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"commitlint": "^18",
|
|
54
54
|
"eslint": "^8.57.0",
|
|
55
55
|
"eslint-config-oclif": "^5.1.1",
|
|
56
|
-
"eslint-config-oclif-typescript": "^3.1.
|
|
56
|
+
"eslint-config-oclif-typescript": "^3.1.5",
|
|
57
57
|
"eslint-config-prettier": "^9.0.0",
|
|
58
58
|
"eslint-plugin-perfectionist": "^2.6.0",
|
|
59
59
|
"husky": "^9",
|