@oclif/core 1.0.6 → 1.0.10
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/CHANGELOG.md +23 -0
- package/lib/config/plugin.js +33 -11
- package/lib/config/util.d.ts +3 -0
- package/lib/config/util.js +5 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.10](https://github.com/oclif/core/compare/v1.0.9...v1.0.10) (2021-12-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* bump deps ([#317](https://github.com/oclif/core/issues/317)) ([3e656e0](https://github.com/oclif/core/commit/3e656e0b6909bedb879a267bf341cfb992f4d208))
|
|
11
|
+
|
|
12
|
+
### [1.0.9](https://github.com/oclif/core/compare/v1.0.8...v1.0.9) (2021-12-08)
|
|
13
|
+
|
|
14
|
+
### [1.0.8](https://github.com/oclif/core/compare/v1.0.7...v1.0.8) (2021-12-07)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* bump deps ([#314](https://github.com/oclif/core/issues/314)) ([e989d1c](https://github.com/oclif/core/commit/e989d1c078d24df3023f2abf61dd454435f08956))
|
|
20
|
+
|
|
21
|
+
### [1.0.7](https://github.com/oclif/core/compare/v1.0.6...v1.0.7) (2021-12-02)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* bump cli-ux ([2334c7d](https://github.com/oclif/core/commit/2334c7d05d003a167b41375d55cc67e28403863e))
|
|
27
|
+
|
|
5
28
|
### [1.0.6](https://github.com/oclif/core/compare/v1.0.5...v1.0.6) (2021-12-01)
|
|
6
29
|
|
|
7
30
|
|
package/lib/config/plugin.js
CHANGED
|
@@ -23,23 +23,34 @@ function topicsToArray(input, base) {
|
|
|
23
23
|
return [{ ...input[k], name: `${base}${k}` }].concat(topicsToArray(input[k].subtopics, `${base}${input[k].name}`));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
//
|
|
26
|
+
// essentially just "cd .."
|
|
27
|
+
function* up(from) {
|
|
28
|
+
while (path.dirname(from) !== from) {
|
|
29
|
+
yield from;
|
|
30
|
+
from = path.dirname(from);
|
|
31
|
+
}
|
|
32
|
+
yield from;
|
|
33
|
+
}
|
|
34
|
+
async function findSourcesRoot(root) {
|
|
35
|
+
for (const next of up(root)) {
|
|
36
|
+
const cur = path.join(next, 'package.json');
|
|
37
|
+
// eslint-disable-next-line no-await-in-loop
|
|
38
|
+
if (await (0, util_3.exists)(cur))
|
|
39
|
+
return path.dirname(cur);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
/**
|
|
43
|
+
* @returns string
|
|
44
|
+
* @param name string
|
|
45
|
+
* @param root string
|
|
28
46
|
* find package root
|
|
29
47
|
* for packages installed into node_modules this will go up directories until
|
|
30
48
|
* it finds a node_modules directory with the plugin installed into it
|
|
31
49
|
*
|
|
32
|
-
* This is needed because
|
|
50
|
+
* This is needed because some oclif plugins do not declare the `main` field in their package.json
|
|
51
|
+
* https://github.com/oclif/config/pull/289#issuecomment-983904051
|
|
33
52
|
*/
|
|
34
|
-
async function
|
|
35
|
-
// essentially just "cd .."
|
|
36
|
-
function* up(from) {
|
|
37
|
-
while (path.dirname(from) !== from) {
|
|
38
|
-
yield from;
|
|
39
|
-
from = path.dirname(from);
|
|
40
|
-
}
|
|
41
|
-
yield from;
|
|
42
|
-
}
|
|
53
|
+
async function findRootLegacy(name, root) {
|
|
43
54
|
for (const next of up(root)) {
|
|
44
55
|
let cur;
|
|
45
56
|
if (name) {
|
|
@@ -63,6 +74,17 @@ async function findRoot(name, root) {
|
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
}
|
|
77
|
+
async function findRoot(name, root) {
|
|
78
|
+
if (name) {
|
|
79
|
+
let pkgPath;
|
|
80
|
+
try {
|
|
81
|
+
pkgPath = (0, util_3.resolvePackage)(name, { paths: [__dirname, root] });
|
|
82
|
+
}
|
|
83
|
+
catch { }
|
|
84
|
+
return pkgPath ? findSourcesRoot(path.dirname(pkgPath)) : findRootLegacy(name, root);
|
|
85
|
+
}
|
|
86
|
+
return findSourcesRoot(root);
|
|
87
|
+
}
|
|
66
88
|
class Plugin {
|
|
67
89
|
// eslint-disable-next-line no-useless-constructor
|
|
68
90
|
constructor(options) {
|
package/lib/config/util.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export declare function mapValues<T extends Record<string, any>, TResult>(obj: {
|
|
|
5
5
|
[P in keyof T]: TResult;
|
|
6
6
|
};
|
|
7
7
|
export declare function exists(path: string): Promise<boolean>;
|
|
8
|
+
export declare function resolvePackage(id: string, paths: {
|
|
9
|
+
paths: string[];
|
|
10
|
+
}): string;
|
|
8
11
|
export declare function loadJSON(path: string): Promise<any>;
|
|
9
12
|
export declare function compact<T>(a: (T | undefined)[]): T[];
|
|
10
13
|
export declare function uniq<T>(arr: T[]): T[];
|
package/lib/config/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Debug = exports.uniq = exports.compact = exports.loadJSON = exports.exists = exports.mapValues = exports.flatMap = void 0;
|
|
3
|
+
exports.Debug = exports.uniq = exports.compact = exports.loadJSON = exports.resolvePackage = exports.exists = exports.mapValues = exports.flatMap = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const debug = require('debug');
|
|
6
6
|
function flatMap(arr, fn) {
|
|
@@ -20,6 +20,10 @@ function exists(path) {
|
|
|
20
20
|
return new Promise(resolve => resolve(fs.existsSync(path)));
|
|
21
21
|
}
|
|
22
22
|
exports.exists = exists;
|
|
23
|
+
function resolvePackage(id, paths) {
|
|
24
|
+
return require.resolve(id, paths);
|
|
25
|
+
}
|
|
26
|
+
exports.resolvePackage = resolvePackage;
|
|
23
27
|
function loadJSON(path) {
|
|
24
28
|
debug('config')('loadJSON %s', path);
|
|
25
29
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/core",
|
|
3
3
|
"description": "base library for oclif CLIs",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.10",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@oclif/linewrap": "^1.0.0",
|
|
9
9
|
"chalk": "^4.1.2",
|
|
10
10
|
"clean-stack": "^3.0.1",
|
|
11
|
-
"cli-ux": "
|
|
11
|
+
"cli-ux": "6.0.5",
|
|
12
12
|
"debug": "^4.3.3",
|
|
13
13
|
"fs-extra": "^9.1.0",
|
|
14
14
|
"get-package-type": "^0.1.0",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@commitlint/config-conventional": "^12.1.4",
|
|
28
|
-
"@oclif/plugin-help": "^5.1.
|
|
29
|
-
"@oclif/plugin-plugins": "^2.0.
|
|
28
|
+
"@oclif/plugin-help": "^5.1.7",
|
|
29
|
+
"@oclif/plugin-plugins": "^2.0.8",
|
|
30
30
|
"@oclif/test": "^1.2.8",
|
|
31
31
|
"@types/chai": "^4.2.22",
|
|
32
32
|
"@types/chai-as-promised": "^7.1.4",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"typescript": "4.5.2"
|
|
63
63
|
},
|
|
64
64
|
"resolutions": {
|
|
65
|
-
"@oclif/command": "1.8.
|
|
65
|
+
"@oclif/command": "1.8.9",
|
|
66
66
|
"@oclif/parser": "3.8.6"
|
|
67
67
|
},
|
|
68
68
|
"engines": {
|