oclif 4.17.19 → 4.17.21
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/bin/dev.js +2 -1
- package/lib/commands/generate.js +15 -15
- package/lib/commands/manifest.d.ts +1 -2
- package/lib/commands/manifest.js +21 -34
- package/lib/commands/pack/deb.js +17 -14
- package/lib/commands/pack/macos.js +9 -6
- package/lib/commands/pack/win.js +16 -13
- package/lib/commands/promote.js +3 -3
- package/lib/commands/readme.js +3 -3
- package/lib/commands/upload/deb.js +2 -2
- package/lib/generator.d.ts +4 -4
- package/lib/generator.js +8 -8
- package/lib/log.js +2 -35
- package/lib/readme-generator.js +1 -0
- package/lib/tarballs/bin.js +7 -4
- package/lib/tarballs/build.js +38 -68
- package/lib/tarballs/config.d.ts +6 -6
- package/lib/tarballs/config.js +10 -7
- package/lib/tarballs/node.js +13 -46
- package/lib/upload-util.d.ts +2 -2
- package/lib/util.js +1 -1
- package/lib/version-indexes.js +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +10 -10
- package/templates/cli/commonjs/bin/dev.js.ejs +2 -1
- package/templates/cli/commonjs/eslint.config.mjs.ejs +19 -0
- package/templates/cli/esm/bin/dev.js.ejs +0 -1
- package/templates/cli/esm/eslint.config.mjs.ejs +9 -0
- package/templates/cli/shared/package.json.ejs +8 -8
- package/templates/cli/shared/src/commands/hello/index.ts.ejs +0 -3
- package/templates/cli/shared/src/commands/hello/world.ts.ejs +0 -3
- package/templates/src/command.ts.ejs +0 -3
- package/templates/cli/shared/.eslintignore.ejs +0 -1
- package/templates/cli/shared/.eslintrc.json.ejs +0 -3
package/bin/dev.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ts-node
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
3
4
|
;(async () => {
|
|
4
5
|
const oclif = await import('@oclif/core')
|
|
5
6
|
await oclif.execute({development: true, dir: __dirname})
|
package/lib/commands/generate.js
CHANGED
|
@@ -180,6 +180,21 @@ Head to oclif.io/docs/introduction to learn more about building CLIs with oclif.
|
|
|
180
180
|
debug(`${moduleType} files %O`, moduleSpecificFiles);
|
|
181
181
|
await Promise.all([...sharedFiles, ...moduleSpecificFiles].map(async (file) => {
|
|
182
182
|
switch (file.name) {
|
|
183
|
+
case '.gitignore.ejs': {
|
|
184
|
+
await this.template(file.src, file.destination, { packageManager });
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case 'onPushToMain.yml.ejs':
|
|
188
|
+
case 'onRelease.yml.ejs':
|
|
189
|
+
case 'test.yml.ejs': {
|
|
190
|
+
await this.template(file.src, file.destination, {
|
|
191
|
+
exec: packageManager === 'yarn' ? packageManager : `${packageManager} exec`,
|
|
192
|
+
install: packageManager === 'yarn' ? packageManager : `${packageManager} install`,
|
|
193
|
+
packageManager,
|
|
194
|
+
run: packageManager === 'yarn' ? packageManager : `${packageManager} run`,
|
|
195
|
+
});
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
183
198
|
case 'package.json.ejs': {
|
|
184
199
|
const data = {
|
|
185
200
|
author,
|
|
@@ -195,25 +210,10 @@ Head to oclif.io/docs/introduction to learn more about building CLIs with oclif.
|
|
|
195
210
|
await this.template(file.src, file.destination, data);
|
|
196
211
|
break;
|
|
197
212
|
}
|
|
198
|
-
case '.gitignore.ejs': {
|
|
199
|
-
await this.template(file.src, file.destination, { packageManager });
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
213
|
case 'README.md.ejs': {
|
|
203
214
|
await this.template(file.src, file.destination, { description, name, repository });
|
|
204
215
|
break;
|
|
205
216
|
}
|
|
206
|
-
case 'onPushToMain.yml.ejs':
|
|
207
|
-
case 'onRelease.yml.ejs':
|
|
208
|
-
case 'test.yml.ejs': {
|
|
209
|
-
await this.template(file.src, file.destination, {
|
|
210
|
-
exec: packageManager === 'yarn' ? packageManager : `${packageManager} exec`,
|
|
211
|
-
install: packageManager === 'yarn' ? packageManager : `${packageManager} install`,
|
|
212
|
-
packageManager,
|
|
213
|
-
run: packageManager === 'yarn' ? packageManager : `${packageManager} run`,
|
|
214
|
-
});
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
217
|
default: {
|
|
218
218
|
await this.template(file.src, file.destination);
|
|
219
219
|
}
|
package/lib/commands/manifest.js
CHANGED
|
@@ -32,16 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
const core_1 = require("@oclif/core");
|
|
37
40
|
const fs_extra_1 = require("fs-extra");
|
|
38
41
|
const node_child_process_1 = require("node:child_process");
|
|
39
42
|
const os = __importStar(require("node:os"));
|
|
40
|
-
const
|
|
41
|
-
const node_stream_1 = require("node:stream");
|
|
42
|
-
const node_util_1 = require("node:util");
|
|
43
|
-
const semver_1 = require("semver");
|
|
44
|
-
const pipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
|
|
43
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
45
44
|
async function fileExists(filePath) {
|
|
46
45
|
try {
|
|
47
46
|
await (0, fs_extra_1.access)(filePath);
|
|
@@ -70,25 +69,21 @@ class Manifest extends core_1.Command {
|
|
|
70
69
|
}
|
|
71
70
|
catch { }
|
|
72
71
|
const { args } = await this.parse(Manifest);
|
|
73
|
-
const root =
|
|
74
|
-
const packageJson = (0, fs_extra_1.readJSONSync)('package.json');
|
|
72
|
+
const root = node_path_1.default.resolve(args.path);
|
|
73
|
+
const packageJson = (0, fs_extra_1.readJSONSync)(node_path_1.default.join(root, 'package.json'));
|
|
75
74
|
let jitPluginManifests = [];
|
|
76
75
|
if (flags.jit && packageJson.oclif?.jitPlugins) {
|
|
77
76
|
this.debug('jitPlugins: %s', packageJson.oclif.jitPlugins);
|
|
78
77
|
const tmpDir = os.tmpdir();
|
|
79
|
-
const { default: got } = await import('got');
|
|
80
78
|
const promises = Object.entries(packageJson.oclif.jitPlugins).map(async ([jitPlugin, version]) => {
|
|
81
79
|
const pluginDir = jitPlugin.replace('/', '-').replace('@', '');
|
|
82
|
-
const fullPath =
|
|
80
|
+
const fullPath = node_path_1.default.join(tmpDir, pluginDir);
|
|
83
81
|
if (await fileExists(fullPath))
|
|
84
82
|
await (0, fs_extra_1.remove)(fullPath);
|
|
85
83
|
await (0, fs_extra_1.mkdir)(fullPath, { recursive: true });
|
|
86
|
-
const
|
|
87
|
-
const tarballUrl = await this.getTarballUrl(jitPlugin, resolvedVersion);
|
|
88
|
-
const tarball = path.join(fullPath, path.basename(tarballUrl));
|
|
89
|
-
await pipeline(got.stream(tarballUrl), (0, fs_extra_1.createWriteStream)(tarball));
|
|
84
|
+
const tarball = await this.downloadTarball(jitPlugin, version, fullPath);
|
|
90
85
|
await this.executeCommand(`tar -xzf "${tarball}"`, { cwd: fullPath });
|
|
91
|
-
const manifest = (await (0, fs_extra_1.readJSON)(
|
|
86
|
+
const manifest = (await (0, fs_extra_1.readJSON)(node_path_1.default.join(fullPath, 'package', 'oclif.manifest.json')));
|
|
92
87
|
for (const command of Object.values(manifest.commands)) {
|
|
93
88
|
command.pluginType = 'jit';
|
|
94
89
|
}
|
|
@@ -123,7 +118,7 @@ class Manifest extends core_1.Command {
|
|
|
123
118
|
});
|
|
124
119
|
}
|
|
125
120
|
const dotfile = plugin.pjson.files.find((f) => f.endsWith('.oclif.manifest.json'));
|
|
126
|
-
const file =
|
|
121
|
+
const file = node_path_1.default.join(plugin.root, `${dotfile ? '.' : ''}oclif.manifest.json`);
|
|
127
122
|
for (const manifest of jitPluginManifests) {
|
|
128
123
|
plugin.manifest.commands = { ...plugin.manifest.commands, ...manifest.commands };
|
|
129
124
|
}
|
|
@@ -131,6 +126,17 @@ class Manifest extends core_1.Command {
|
|
|
131
126
|
this.log(`wrote manifest to ${file}`);
|
|
132
127
|
return plugin.manifest;
|
|
133
128
|
}
|
|
129
|
+
async downloadTarball(plugin, version, tarballStoragePath) {
|
|
130
|
+
const { stderr } = await this.executeCommand(`npm pack ${plugin}@${version} --pack-destination "${tarballStoragePath}" --json`);
|
|
131
|
+
// You can `npm pack` with multiple modules to download multiple at a time. There will be at least 1 if the command
|
|
132
|
+
// succeeded.
|
|
133
|
+
const tarballs = JSON.parse(stderr);
|
|
134
|
+
if (!Array.isArray(tarballs) || tarballs.length !== 1) {
|
|
135
|
+
throw new Error(`Could not download tarballs for ${plugin}. Tarball download was not in the correct format.`);
|
|
136
|
+
}
|
|
137
|
+
const { filename } = tarballs[0];
|
|
138
|
+
return node_path_1.default.join(tarballStoragePath, filename);
|
|
139
|
+
}
|
|
134
140
|
async executeCommand(command, options) {
|
|
135
141
|
return new Promise((resolve) => {
|
|
136
142
|
(0, node_child_process_1.exec)(command, options, (error, stderr, stdout) => {
|
|
@@ -146,24 +152,5 @@ class Manifest extends core_1.Command {
|
|
|
146
152
|
});
|
|
147
153
|
});
|
|
148
154
|
}
|
|
149
|
-
async getTarballUrl(plugin, version) {
|
|
150
|
-
const { stderr } = await this.executeCommand(`npm view ${plugin}@${version} --json`);
|
|
151
|
-
const { dist } = JSON.parse(stderr);
|
|
152
|
-
return dist.tarball;
|
|
153
|
-
}
|
|
154
|
-
async getVersion(plugin, version) {
|
|
155
|
-
if (version.startsWith('^') || version.startsWith('~')) {
|
|
156
|
-
// Grab latest from npm to get all the versions so we can find the max satisfying version.
|
|
157
|
-
// We explicitly ask for latest since this command is typically run inside of `npm prepack`,
|
|
158
|
-
// which sets the npm_config_tag env var, which is used as the default anytime a tag isn't
|
|
159
|
-
// provided to `npm view`. This can be problematic if you're building the `nightly` version
|
|
160
|
-
// of a CLI and all the JIT plugins don't have a `nightly` tag themselves.
|
|
161
|
-
// TL;DR - always ask for latest to avoid potentially requesting a non-existent tag.
|
|
162
|
-
const { stderr } = await this.executeCommand(`npm view ${plugin}@latest --json`);
|
|
163
|
-
const { versions } = JSON.parse(stderr);
|
|
164
|
-
return (0, semver_1.maxSatisfying)(versions, version) ?? version.replace('^', '').replace('~', '');
|
|
165
|
-
}
|
|
166
|
-
return version;
|
|
167
|
-
}
|
|
168
155
|
}
|
|
169
156
|
exports.default = Manifest;
|
package/lib/commands/pack/deb.js
CHANGED
|
@@ -32,12 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
const core_1 = require("@oclif/core");
|
|
37
40
|
const fs = __importStar(require("fs-extra"));
|
|
38
41
|
const node_child_process_1 = require("node:child_process");
|
|
39
42
|
const fsPromises = __importStar(require("node:fs/promises"));
|
|
40
|
-
const
|
|
43
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
41
44
|
const node_util_1 = require("node:util");
|
|
42
45
|
const Tarballs = __importStar(require("../../tarballs"));
|
|
43
46
|
const upload_util_1 = require("../../upload-util");
|
|
@@ -123,29 +126,29 @@ class PackDeb extends core_1.Command {
|
|
|
123
126
|
bin: config.bin,
|
|
124
127
|
versionShaRevision: (0, upload_util_1.debVersion)(buildConfig),
|
|
125
128
|
});
|
|
126
|
-
const workspace =
|
|
129
|
+
const workspace = node_path_1.default.join(buildConfig.tmp, 'apt', versionedDebBase.replace('.deb', '.apt'));
|
|
127
130
|
await fs.remove(workspace);
|
|
128
131
|
await Promise.all([
|
|
129
|
-
fsPromises.mkdir(
|
|
130
|
-
fsPromises.mkdir(
|
|
132
|
+
fsPromises.mkdir(node_path_1.default.join(workspace, 'DEBIAN'), { recursive: true }),
|
|
133
|
+
fsPromises.mkdir(node_path_1.default.join(workspace, 'usr', 'bin'), { recursive: true }),
|
|
131
134
|
]);
|
|
132
|
-
await fs.copy(buildConfig.workspace(target),
|
|
135
|
+
await fs.copy(buildConfig.workspace(target), node_path_1.default.join(workspace, 'usr', 'lib', config.dirname));
|
|
133
136
|
await Promise.all([
|
|
134
137
|
// usr/lib/oclif/bin/oclif (the executable)
|
|
135
|
-
fsPromises.writeFile(
|
|
136
|
-
fsPromises.writeFile(
|
|
138
|
+
fsPromises.writeFile(node_path_1.default.join(workspace, 'usr', 'lib', config.dirname, 'bin', config.bin), scripts.bin(config), { mode: 0o755 }),
|
|
139
|
+
fsPromises.writeFile(node_path_1.default.join(workspace, 'DEBIAN', 'control'), scripts.control(buildConfig, (0, upload_util_1.debArch)(arch))),
|
|
137
140
|
]);
|
|
138
141
|
// symlink usr/bin/oclif points to usr/lib/oclif/bin/oclif
|
|
139
|
-
await exec(`ln -s "${
|
|
140
|
-
cwd:
|
|
142
|
+
await exec(`ln -s "${node_path_1.default.join('..', 'lib', config.dirname, 'bin', config.bin)}" "${config.bin}"`, {
|
|
143
|
+
cwd: node_path_1.default.join(workspace, 'usr', 'bin'),
|
|
141
144
|
});
|
|
142
|
-
config.binAliases?.map((alias) => exec(`ln -sf "${
|
|
143
|
-
cwd:
|
|
145
|
+
config.binAliases?.map((alias) => exec(`ln -sf "${node_path_1.default.join('..', 'lib', config.dirname, 'bin', config.bin)}" "${alias}"`, {
|
|
146
|
+
cwd: node_path_1.default.join(workspace, 'usr', 'bin'),
|
|
144
147
|
}));
|
|
145
148
|
await exec(`sudo chown -R root "${workspace}"`);
|
|
146
149
|
await exec(`sudo chgrp -R root "${workspace}"`);
|
|
147
150
|
const dpkgDeb = flags.compression ? `dpkg-deb --build "-Z${flags.compression}"` : 'dpkg-deb --build';
|
|
148
|
-
await exec(`${dpkgDeb} "${workspace}" "${
|
|
151
|
+
await exec(`${dpkgDeb} "${workspace}" "${node_path_1.default.join(dist, versionedDebBase)}"`);
|
|
149
152
|
this.log(`finished building debian / ${arch}`);
|
|
150
153
|
};
|
|
151
154
|
const arches = (0, util_1.uniq)(buildConfig.targets.filter((t) => t.platform === 'linux').map((t) => t.arch));
|
|
@@ -170,8 +173,8 @@ class PackDeb extends core_1.Command {
|
|
|
170
173
|
}
|
|
171
174
|
exports.default = PackDeb;
|
|
172
175
|
async function packForFTP(buildConfig, config, dist) {
|
|
173
|
-
const ftparchive =
|
|
174
|
-
await fsPromises.mkdir(
|
|
176
|
+
const ftparchive = node_path_1.default.join(buildConfig.tmp, 'apt', 'apt-ftparchive.conf');
|
|
177
|
+
await fsPromises.mkdir(node_path_1.default.basename(ftparchive), { recursive: true });
|
|
175
178
|
await fs.writeFile(ftparchive, scripts.ftparchive(config));
|
|
176
179
|
await exec(`apt-ftparchive -c "${ftparchive}" release . > Release`, { cwd: dist });
|
|
177
180
|
}
|
|
@@ -32,12 +32,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
const core_1 = require("@oclif/core");
|
|
37
40
|
const fs = __importStar(require("fs-extra"));
|
|
38
41
|
const node_child_process_1 = require("node:child_process");
|
|
39
42
|
const os = __importStar(require("node:os"));
|
|
40
|
-
const
|
|
43
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
41
44
|
const node_util_1 = require("node:util");
|
|
42
45
|
const Tarballs = __importStar(require("../../tarballs"));
|
|
43
46
|
const upload_util_1 = require("../../upload-util");
|
|
@@ -205,9 +208,9 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
205
208
|
pruneLockfiles: flags['prune-lockfiles'],
|
|
206
209
|
tarball: flags.tarball,
|
|
207
210
|
});
|
|
208
|
-
const scriptsDir =
|
|
211
|
+
const scriptsDir = node_path_1.default.join(buildConfig.tmp, 'macos/scripts');
|
|
209
212
|
await fs.emptyDir(buildConfig.dist('macos'));
|
|
210
|
-
const noBundleConfigurationPath =
|
|
213
|
+
const noBundleConfigurationPath = node_path_1.default.join(buildConfig.tmp, 'macos', 'no-bundle.plist');
|
|
211
214
|
const build = async (arch) => {
|
|
212
215
|
const templateKey = (0, upload_util_1.templateShortKey)('macos', {
|
|
213
216
|
arch,
|
|
@@ -218,14 +221,14 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
218
221
|
const dist = buildConfig.dist(`macos/${templateKey}`);
|
|
219
222
|
const rootDir = buildConfig.workspace({ arch, platform: 'darwin' });
|
|
220
223
|
const writeNoBundleConfiguration = async () => {
|
|
221
|
-
await fs.mkdir(
|
|
224
|
+
await fs.mkdir(node_path_1.default.dirname(noBundleConfigurationPath), { recursive: true });
|
|
222
225
|
await fs.writeFile(noBundleConfigurationPath, noBundleConfiguration, { mode: 0o755 });
|
|
223
226
|
};
|
|
224
227
|
const writeScript = async (script) => {
|
|
225
228
|
const scriptLocation = script === 'uninstall' ? [rootDir, 'bin'] : [scriptsDir];
|
|
226
229
|
scriptLocation.push(script);
|
|
227
|
-
await fs.mkdir(
|
|
228
|
-
await fs.writeFile(
|
|
230
|
+
await fs.mkdir(node_path_1.default.dirname(node_path_1.default.join(...scriptLocation)), { recursive: true });
|
|
231
|
+
await fs.writeFile(node_path_1.default.join(...scriptLocation), scripts[script](config, flags['additional-cli']), {
|
|
229
232
|
mode: 0o755,
|
|
230
233
|
});
|
|
231
234
|
};
|
package/lib/commands/pack/win.js
CHANGED
|
@@ -32,13 +32,16 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
const core_1 = require("@oclif/core");
|
|
37
40
|
const fs_extra_1 = require("fs-extra");
|
|
38
41
|
const node_child_process_1 = require("node:child_process");
|
|
39
42
|
const node_fs_1 = require("node:fs");
|
|
40
43
|
const promises_1 = require("node:fs/promises");
|
|
41
|
-
const
|
|
44
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
42
45
|
const node_util_1 = require("node:util");
|
|
43
46
|
const Tarballs = __importStar(require("../../tarballs"));
|
|
44
47
|
const upload_util_1 = require("../../upload-util");
|
|
@@ -52,7 +55,7 @@ set ${additionalCLI ? `${additionalCLI.toUpperCase()}_BINPATH` : config.scopedEn
|
|
|
52
55
|
if exist "%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${additionalCLI ?? config.bin}.cmd" (
|
|
53
56
|
"%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${additionalCLI ?? config.bin}.cmd" %*
|
|
54
57
|
) else (
|
|
55
|
-
"%~dp0\\..\\client\\bin\\node.exe" ${`${nodeOptions?.join(' ')} `}"%~dp0\\..\\client\\${additionalCLI ? `${additionalCLI}\\bin\\run` :
|
|
58
|
+
"%~dp0\\..\\client\\bin\\node.exe" ${`${nodeOptions?.join(' ')} `}"%~dp0\\..\\client\\${additionalCLI ? `${additionalCLI}\\bin\\run` : String.raw `bin\run`}" %*
|
|
56
59
|
)
|
|
57
60
|
`,
|
|
58
61
|
nsis: ({ arch, config, customization, defenderOptional, hideDefenderOption, }) => `!include MUI2.nsh
|
|
@@ -285,13 +288,13 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
285
288
|
tarball: flags.tarball,
|
|
286
289
|
});
|
|
287
290
|
await Promise.all(arches.map(async (arch) => {
|
|
288
|
-
const installerBase =
|
|
291
|
+
const installerBase = node_path_1.default.join(buildConfig.tmp, `windows-${arch}-installer`);
|
|
289
292
|
await (0, promises_1.rm)(installerBase, { force: true, recursive: true });
|
|
290
|
-
await (0, promises_1.mkdir)(
|
|
293
|
+
await (0, promises_1.mkdir)(node_path_1.default.join(installerBase, 'bin'), { recursive: true });
|
|
291
294
|
await Promise.all([
|
|
292
|
-
(0, promises_1.writeFile)(
|
|
293
|
-
(0, promises_1.writeFile)(
|
|
294
|
-
(0, promises_1.writeFile)(
|
|
295
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${config.bin}.cmd`), scripts.cmd(config, undefined, buildConfig.nodeOptions)),
|
|
296
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${config.bin}`), scripts.sh(config)),
|
|
297
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, `${config.bin}.nsi`), scripts.nsis({
|
|
295
298
|
arch,
|
|
296
299
|
config,
|
|
297
300
|
customization: nsisCustomization,
|
|
@@ -304,18 +307,18 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
304
307
|
// write duplicate files for windows aliases
|
|
305
308
|
// this avoids mklink which can require admin privileges which not everyone has
|
|
306
309
|
[
|
|
307
|
-
(0, promises_1.writeFile)(
|
|
308
|
-
(0, promises_1.writeFile)(
|
|
310
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${alias}.cmd`), scripts.cmd(config)),
|
|
311
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${alias}`), scripts.sh(config)),
|
|
309
312
|
])
|
|
310
313
|
: []),
|
|
311
314
|
...(flags['additional-cli']
|
|
312
315
|
? [
|
|
313
|
-
(0, promises_1.writeFile)(
|
|
314
|
-
(0, promises_1.writeFile)(
|
|
316
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${flags['additional-cli']}.cmd`), scripts.cmd(config, flags['additional-cli'])),
|
|
317
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${flags['additional-cli']}`), scripts.sh({ bin: flags['additional-cli'] })),
|
|
315
318
|
]
|
|
316
319
|
: []),
|
|
317
320
|
]);
|
|
318
|
-
await (0, fs_extra_1.move)(buildConfig.workspace({ arch, platform: 'win32' }),
|
|
321
|
+
await (0, fs_extra_1.move)(buildConfig.workspace({ arch, platform: 'win32' }), node_path_1.default.join(installerBase, 'client'));
|
|
319
322
|
await exec(`makensis "${installerBase}/${config.bin}.nsi" | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
|
320
323
|
const templateKey = (0, upload_util_1.templateShortKey)('win32', {
|
|
321
324
|
arch,
|
|
@@ -324,7 +327,7 @@ the CLI should already exist in a directory named after the CLI that is the root
|
|
|
324
327
|
version: config.version,
|
|
325
328
|
});
|
|
326
329
|
const o = buildConfig.dist(`win32/${templateKey}`);
|
|
327
|
-
await (0, fs_extra_1.move)(
|
|
330
|
+
await (0, fs_extra_1.move)(node_path_1.default.join(installerBase, 'installer.exe'), o);
|
|
328
331
|
const { windows } = config.pjson.oclif;
|
|
329
332
|
if (windows && windows.name && windows.keypath) {
|
|
330
333
|
await signWindows(o, arch, config, windows);
|
package/lib/commands/promote.js
CHANGED
|
@@ -38,7 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
40
40
|
const core_1 = require("@oclif/core");
|
|
41
|
-
const
|
|
41
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
42
42
|
const aws_1 = __importDefault(require("../aws"));
|
|
43
43
|
const Tarballs = __importStar(require("../tarballs"));
|
|
44
44
|
const upload_util_1 = require("../upload-util");
|
|
@@ -86,8 +86,8 @@ class Promote extends core_1.Command {
|
|
|
86
86
|
CacheControl: indexDefaults.maxAge,
|
|
87
87
|
MetadataDirective: client_s3_1.MetadataDirective.REPLACE,
|
|
88
88
|
};
|
|
89
|
-
const cloudBucketCommitKey = (shortKey) =>
|
|
90
|
-
const cloudChannelKey = (shortKey) =>
|
|
89
|
+
const cloudBucketCommitKey = (shortKey) => node_path_1.default.join(s3Config.bucket, (0, upload_util_1.commitAWSDir)(flags.version, flags.sha, s3Config), shortKey);
|
|
90
|
+
const cloudChannelKey = (shortKey) => node_path_1.default.join((0, upload_util_1.channelAWSDir)(flags.channel, s3Config), shortKey);
|
|
91
91
|
// copy tarballs manifests
|
|
92
92
|
const promoteManifest = async (target) => {
|
|
93
93
|
const manifest = (0, upload_util_1.templateShortKey)('manifest', {
|
package/lib/commands/readme.js
CHANGED
|
@@ -38,7 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const core_1 = require("@oclif/core");
|
|
40
40
|
const fs = __importStar(require("fs-extra"));
|
|
41
|
-
const
|
|
41
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
42
42
|
const readme_generator_1 = __importDefault(require("../readme-generator"));
|
|
43
43
|
class Readme extends core_1.Command {
|
|
44
44
|
static description = `The readme must have any of the following tags inside of it for it to be replaced or else it will do nothing:
|
|
@@ -98,8 +98,8 @@ Customize the code URL prefix by setting oclif.repositoryPrefix in package.json.
|
|
|
98
98
|
const { flags } = await this.parse(Readme);
|
|
99
99
|
this.flags = flags;
|
|
100
100
|
this.flags['plugin-directory'] ??= process.cwd();
|
|
101
|
-
const readmePath =
|
|
102
|
-
const tsConfigPath =
|
|
101
|
+
const readmePath = node_path_1.default.resolve(this.flags['plugin-directory'], flags['readme-path']);
|
|
102
|
+
const tsConfigPath = node_path_1.default.resolve(this.flags['plugin-directory'], flags['tsconfig-path']);
|
|
103
103
|
if (await fs.pathExists(tsConfigPath)) {
|
|
104
104
|
const { default: JSONC } = await import('tiny-jsonc');
|
|
105
105
|
const tsConfigRaw = await fs.readFile(tsConfigPath, 'utf8');
|
|
@@ -38,7 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const core_1 = require("@oclif/core");
|
|
40
40
|
const fs = __importStar(require("node:fs"));
|
|
41
|
-
const
|
|
41
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
42
42
|
const aws_1 = __importDefault(require("../../aws"));
|
|
43
43
|
const log_1 = require("../../log");
|
|
44
44
|
const Tarballs = __importStar(require("../../tarballs"));
|
|
@@ -53,7 +53,7 @@ class UploadDeb extends core_1.Command {
|
|
|
53
53
|
const { flags } = await this.parse(UploadDeb);
|
|
54
54
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
55
55
|
const { config, s3Config } = buildConfig;
|
|
56
|
-
const dist = (f) => buildConfig.dist(
|
|
56
|
+
const dist = (f) => buildConfig.dist(node_path_1.default.join('deb', f));
|
|
57
57
|
const S3Options = {
|
|
58
58
|
ACL: s3Config.acl || 'public-read',
|
|
59
59
|
Bucket: s3Config.bucket,
|
package/lib/generator.d.ts
CHANGED
|
@@ -27,15 +27,15 @@ export type GetFlagOrPromptOptions = {
|
|
|
27
27
|
*/
|
|
28
28
|
type: 'input' | 'select';
|
|
29
29
|
};
|
|
30
|
-
export declare function exec(command: string, opts?: {
|
|
30
|
+
export declare function exec(command: string, opts?: ExecOptions & {
|
|
31
31
|
silent?: boolean;
|
|
32
|
-
}
|
|
32
|
+
}): Promise<{
|
|
33
33
|
stderr: string;
|
|
34
34
|
stdout: string;
|
|
35
35
|
}>;
|
|
36
|
-
export declare function readPJSON(location: string): Promise<({
|
|
36
|
+
export declare function readPJSON(location: string): Promise<(Interfaces.PJSON & {
|
|
37
37
|
scripts: Record<string, string>;
|
|
38
|
-
}
|
|
38
|
+
}) | undefined>;
|
|
39
39
|
export declare function makeFlags<T extends Record<string, FlaggablePrompt>>(flaggablePrompts: T): FlagsOfPrompts<T>;
|
|
40
40
|
export declare abstract class GeneratorCommand<T extends typeof Command> extends Command {
|
|
41
41
|
protected args: Args<T>;
|
package/lib/generator.js
CHANGED
|
@@ -99,28 +99,28 @@ class GeneratorCommand extends core_1.Command {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
switch (type) {
|
|
102
|
-
case '
|
|
102
|
+
case 'input': {
|
|
103
103
|
return (maybeFlag() ??
|
|
104
104
|
(await checkMaybeOtherValue()) ??
|
|
105
105
|
maybeDefault() ??
|
|
106
|
-
// Dynamic import because @inquirer/
|
|
106
|
+
// Dynamic import because @inquirer/input is ESM only. Once oclif is ESM, we can make this a normal import
|
|
107
107
|
// so that we can avoid importing on every single question.
|
|
108
|
-
(await import('@inquirer/
|
|
109
|
-
choices: (this.flaggablePrompts[name].options ?? []).map((o) => ({ name: o, value: o })),
|
|
108
|
+
(await import('@inquirer/input')).default({
|
|
110
109
|
default: defaultValue,
|
|
111
110
|
message: this.flaggablePrompts[name].message,
|
|
111
|
+
validate: this.flaggablePrompts[name].validate,
|
|
112
112
|
}));
|
|
113
113
|
}
|
|
114
|
-
case '
|
|
114
|
+
case 'select': {
|
|
115
115
|
return (maybeFlag() ??
|
|
116
116
|
(await checkMaybeOtherValue()) ??
|
|
117
117
|
maybeDefault() ??
|
|
118
|
-
// Dynamic import because @inquirer/
|
|
118
|
+
// Dynamic import because @inquirer/select is ESM only. Once oclif is ESM, we can make this a normal import
|
|
119
119
|
// so that we can avoid importing on every single question.
|
|
120
|
-
(await import('@inquirer/
|
|
120
|
+
(await import('@inquirer/select')).default({
|
|
121
|
+
choices: (this.flaggablePrompts[name].options ?? []).map((o) => ({ name: o, value: o })),
|
|
121
122
|
default: defaultValue,
|
|
122
123
|
message: this.flaggablePrompts[name].message,
|
|
123
|
-
validate: this.flaggablePrompts[name].validate,
|
|
124
124
|
}));
|
|
125
125
|
}
|
|
126
126
|
default: {
|
package/lib/log.js
CHANGED
|
@@ -1,46 +1,13 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.debug = void 0;
|
|
37
4
|
exports.log = log;
|
|
38
5
|
const core_1 = require("@oclif/core");
|
|
39
|
-
const
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
40
7
|
const util_1 = require("./util");
|
|
41
8
|
exports.debug = require('debug')('oclif');
|
|
42
9
|
exports.debug.new = (name) => require('debug')(`oclif:${name}`);
|
|
43
10
|
function log(format, ...args) {
|
|
44
11
|
args = args.map((arg) => (0, util_1.prettifyPaths)(arg));
|
|
45
|
-
exports.debug.enabled ? (0, exports.debug)(format, ...args) : core_1.ux.stdout(`oclif: ${
|
|
12
|
+
return exports.debug.enabled ? (0, exports.debug)(format, ...args) : core_1.ux.stdout(`oclif: ${(0, node_util_1.format)(format, ...args)}`);
|
|
46
13
|
}
|
package/lib/readme-generator.js
CHANGED
|
@@ -227,6 +227,7 @@ USAGE
|
|
|
227
227
|
/**
|
|
228
228
|
* fetches the path to a command
|
|
229
229
|
*/
|
|
230
|
+
// eslint-disable-next-line complexity
|
|
230
231
|
commandPath(plugin, c) {
|
|
231
232
|
const strategy = typeof plugin.pjson.oclif?.commands === 'string' ? 'pattern' : plugin.pjson.oclif?.commands?.strategy;
|
|
232
233
|
// if the strategy is explicit, we can't determine the path so return undefined
|
package/lib/tarballs/bin.js
CHANGED
|
@@ -32,11 +32,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.writeBinScripts = writeBinScripts;
|
|
37
40
|
const node_child_process_1 = require("node:child_process");
|
|
38
41
|
const fs = __importStar(require("node:fs"));
|
|
39
|
-
const
|
|
42
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
40
43
|
const node_util_1 = require("node:util");
|
|
41
44
|
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
42
45
|
async function writeBinScripts({ baseWorkspace, config, nodeOptions, nodeVersion, }) {
|
|
@@ -44,7 +47,7 @@ async function writeBinScripts({ baseWorkspace, config, nodeOptions, nodeVersion
|
|
|
44
47
|
const redirectedEnvVar = config.scopedEnvVarKey('REDIRECTED');
|
|
45
48
|
const clientHomeEnvVar = config.scopedEnvVarKey('OCLIF_CLIENT_HOME');
|
|
46
49
|
const writeWin32 = async (bin) => {
|
|
47
|
-
await fs.promises.writeFile(
|
|
50
|
+
await fs.promises.writeFile(node_path_1.default.join(baseWorkspace, 'bin', `${bin}.cmd`), `@echo off
|
|
48
51
|
setlocal enableextensions
|
|
49
52
|
|
|
50
53
|
if not "%${redirectedEnvVar}%"=="1" if exist "%LOCALAPPDATA%\\${bin}\\client\\bin\\${bin}.cmd" (
|
|
@@ -65,7 +68,7 @@ if exist "%~dp0..\\bin\\node.exe" (
|
|
|
65
68
|
`);
|
|
66
69
|
};
|
|
67
70
|
const writeUnix = async () => {
|
|
68
|
-
const bin =
|
|
71
|
+
const bin = node_path_1.default.join(baseWorkspace, 'bin', config.bin);
|
|
69
72
|
await fs.promises.writeFile(bin, `#!/usr/bin/env bash
|
|
70
73
|
set -e
|
|
71
74
|
echoerr() { echo "$@" 1>&2; }
|
|
@@ -118,6 +121,6 @@ fi
|
|
|
118
121
|
writeUnix(),
|
|
119
122
|
...(config.binAliases?.map((alias) => process.platform === 'win32'
|
|
120
123
|
? writeWin32(alias)
|
|
121
|
-
: exec(`ln -sf ${config.bin} ${alias}`, { cwd:
|
|
124
|
+
: exec(`ln -sf ${config.bin} ${alias}`, { cwd: node_path_1.default.join(baseWorkspace, 'bin') })) ?? []),
|
|
122
125
|
]);
|
|
123
126
|
}
|