oclif 3.17.0 → 3.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oclif.manifest.json +1 -1
- package/lib/commands/manifest.js +1 -1
- package/lib/commands/readme.js +16 -8
- package/package.json +1 -1
package/.oclif.manifest.json
CHANGED
package/lib/commands/manifest.js
CHANGED
|
@@ -50,7 +50,7 @@ class Manifest extends core_1.Command {
|
|
|
50
50
|
(0, shelljs_1.exec)(`7z x -bd -y "${tarball}"`, { cwd: fullPath });
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
|
-
(0, shelljs_1.exec)(`tar -
|
|
53
|
+
(0, shelljs_1.exec)(`tar -xzf "${tarball}"`, { cwd: fullPath });
|
|
54
54
|
}
|
|
55
55
|
const manifest = await fs.readJSON(path.join(fullPath, 'package', 'oclif.manifest.json'));
|
|
56
56
|
for (const command of Object.values(manifest.commands)) {
|
package/lib/commands/readme.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// tslint:disable no-implicit-dependencies
|
|
4
3
|
const core_1 = require("@oclif/core");
|
|
5
4
|
const fs = require("fs-extra");
|
|
6
5
|
const _ = require("lodash");
|
|
@@ -13,9 +12,16 @@ const columns = Number.parseInt(process.env.COLUMNS, 10) || 120;
|
|
|
13
12
|
const slugify = new (require('github-slugger'))();
|
|
14
13
|
class Readme extends core_1.Command {
|
|
15
14
|
async run() {
|
|
15
|
+
var _a, _b;
|
|
16
16
|
this.flags = (await this.parse(Readme)).flags;
|
|
17
17
|
const cwd = process.cwd();
|
|
18
18
|
const readmePath = path.resolve(cwd, 'README.md');
|
|
19
|
+
const tsConfigPath = path.resolve(cwd, 'tsconfig.json');
|
|
20
|
+
const tsConfig = await fs.readJSON(tsConfigPath).catch(() => ({}));
|
|
21
|
+
const outDir = (_b = (_a = tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.outDir) !== null && _b !== void 0 ? _b : 'lib';
|
|
22
|
+
if (!await fs.pathExists(outDir)) {
|
|
23
|
+
this.warn(`No compiled source found at ${outDir}. Some commands may be missing.`);
|
|
24
|
+
}
|
|
19
25
|
const config = await core_1.Config.load({ root: cwd, devPlugins: false, userPlugins: false });
|
|
20
26
|
try {
|
|
21
27
|
const p = require.resolve('@oclif/plugin-legacy', { paths: [cwd] });
|
|
@@ -23,7 +29,7 @@ class Readme extends core_1.Command {
|
|
|
23
29
|
await plugin.load();
|
|
24
30
|
config.plugins.push(plugin);
|
|
25
31
|
}
|
|
26
|
-
catch (
|
|
32
|
+
catch (_c) { }
|
|
27
33
|
await config.runHook('init', { id: 'readme', argv: this.argv });
|
|
28
34
|
this.HelpClass = await (0, core_1.loadHelpClass)(config);
|
|
29
35
|
let readme = await fs.readFile(readmePath, 'utf8');
|
|
@@ -177,21 +183,24 @@ USAGE
|
|
|
177
183
|
* fetches the path to a command
|
|
178
184
|
*/
|
|
179
185
|
commandPath(plugin, c) {
|
|
186
|
+
var _a, _b;
|
|
180
187
|
const commandsDir = plugin.pjson.oclif.commands;
|
|
181
188
|
if (!commandsDir)
|
|
182
189
|
return;
|
|
190
|
+
const hasTypescript = ((_a = plugin.pjson.devDependencies) === null || _a === void 0 ? void 0 : _a.typescript) || ((_b = plugin.pjson.dependencies) === null || _b === void 0 ? void 0 : _b.typescript);
|
|
183
191
|
let p = path.join(plugin.root, commandsDir, ...c.id.split(':'));
|
|
184
|
-
const
|
|
192
|
+
const outDir = path.dirname(commandsDir.replace(`.${path.sep}`, ''));
|
|
193
|
+
const outDirRegex = new RegExp('^' + outDir + (path.sep === '\\' ? '\\\\' : path.sep));
|
|
185
194
|
if (fs.pathExistsSync(path.join(p, 'index.js'))) {
|
|
186
195
|
p = path.join(p, 'index.js');
|
|
187
196
|
}
|
|
188
197
|
else if (fs.pathExistsSync(p + '.js')) {
|
|
189
198
|
p += '.js';
|
|
190
199
|
}
|
|
191
|
-
else if (
|
|
200
|
+
else if (hasTypescript) {
|
|
192
201
|
// check if non-compiled scripts are available
|
|
193
202
|
const base = p.replace(plugin.root + path.sep, '');
|
|
194
|
-
p = path.join(plugin.root, base.replace(
|
|
203
|
+
p = path.join(plugin.root, base.replace(outDirRegex, 'src' + path.sep));
|
|
195
204
|
if (fs.pathExistsSync(path.join(p, 'index.ts'))) {
|
|
196
205
|
p = path.join(p, 'index.ts');
|
|
197
206
|
}
|
|
@@ -204,9 +213,8 @@ USAGE
|
|
|
204
213
|
else
|
|
205
214
|
return;
|
|
206
215
|
p = p.replace(plugin.root + path.sep, '');
|
|
207
|
-
if (
|
|
208
|
-
p = p.replace(
|
|
209
|
-
p = p.replace(/\.js$/, '.ts');
|
|
216
|
+
if (hasTypescript) {
|
|
217
|
+
p = p.replace(outDirRegex, 'src' + path.sep).replace(/\.js$/, '.ts');
|
|
210
218
|
}
|
|
211
219
|
p = p.replace(/\\/g, '/'); // Replace windows '\' by '/'
|
|
212
220
|
return p;
|