@oclif/core 4.0.0-beta.13 → 4.0.0-beta.15
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/config/ts-path.js +29 -6
- package/lib/ux/theme.js +8 -3
- package/package.json +4 -3
package/lib/config/ts-path.js
CHANGED
|
@@ -78,6 +78,24 @@ async function loadTSConfig(root) {
|
|
|
78
78
|
(0, warn_1.memoizedWarn)(`Could not parse tsconfig.json for ${root}. Falling back to compiled source.`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
async function registerTsx(root, moduleType) {
|
|
82
|
+
if (REGISTERED.has(root))
|
|
83
|
+
return;
|
|
84
|
+
try {
|
|
85
|
+
const apiPath = moduleType === 'module' ? 'tsx/esm/api' : 'tsx/cjs/api';
|
|
86
|
+
const tsxPath = require.resolve(apiPath, { paths: [root] });
|
|
87
|
+
if (!tsxPath)
|
|
88
|
+
return;
|
|
89
|
+
debug('registering tsx at', root);
|
|
90
|
+
debug('tsx path:', tsxPath);
|
|
91
|
+
const { register } = await import(tsxPath);
|
|
92
|
+
register();
|
|
93
|
+
REGISTERED.add(root);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
debug(`Could not find tsx. Skipping tsx registration for ${root}.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
81
99
|
async function registerTSNode(root, tsconfig) {
|
|
82
100
|
if (REGISTERED.has(root))
|
|
83
101
|
return;
|
|
@@ -135,18 +153,20 @@ async function registerTSNode(root, tsconfig) {
|
|
|
135
153
|
}
|
|
136
154
|
/**
|
|
137
155
|
* Skip ts-node registration for ESM plugins in production.
|
|
138
|
-
* The node ecosystem is not mature enough to support auto-transpiling ESM modules at this time.
|
|
156
|
+
* The node/ts-node ecosystem is not mature enough to support auto-transpiling ESM modules at this time.
|
|
139
157
|
* See the following:
|
|
140
158
|
* - https://github.com/TypeStrong/ts-node/issues/1791#issuecomment-1149754228
|
|
141
159
|
* - https://github.com/nodejs/node/issues/49432
|
|
142
160
|
* - https://github.com/nodejs/node/pull/49407
|
|
143
161
|
* - https://github.com/nodejs/node/issues/34049
|
|
144
162
|
*
|
|
145
|
-
* We still register ts-node for ESM plugins when NODE_ENV is "test" or "development" and root plugin is also ESM
|
|
163
|
+
* We still register tsx/ts-node for ESM plugins when NODE_ENV is "test" or "development" and root plugin is also ESM
|
|
146
164
|
* since that allows plugins to be auto-transpiled when developing locally using `bin/dev.js`.
|
|
147
165
|
*/
|
|
148
166
|
function cannotTranspileEsm(rootPlugin, plugin, isProduction) {
|
|
149
|
-
return (isProduction || rootPlugin?.moduleType === 'commonjs') &&
|
|
167
|
+
return ((isProduction || rootPlugin?.moduleType === 'commonjs') &&
|
|
168
|
+
plugin?.moduleType === 'module' &&
|
|
169
|
+
!plugin?.pjson.devDependencies?.tsx);
|
|
150
170
|
}
|
|
151
171
|
/**
|
|
152
172
|
* If the dev script is run with ts-node for an ESM plugin, skip ts-node registration
|
|
@@ -166,15 +186,18 @@ function cannotUseTsNode(root, plugin, isProduction) {
|
|
|
166
186
|
/**
|
|
167
187
|
* Determine the path to the source file from the compiled ./lib files
|
|
168
188
|
*/
|
|
169
|
-
async function determinePath(root, orig) {
|
|
189
|
+
async function determinePath(root, orig, plugin) {
|
|
170
190
|
const tsconfig = await loadTSConfig(root);
|
|
171
191
|
if (!tsconfig)
|
|
172
192
|
return orig;
|
|
173
193
|
debug(`Determining path for ${orig}`);
|
|
174
|
-
if (RUN_TIME === '
|
|
194
|
+
if (RUN_TIME === 'bun') {
|
|
175
195
|
debug(`Skipping ts-node registration for ${root} because the runtime is: ${RUN_TIME}`);
|
|
176
196
|
}
|
|
177
197
|
else {
|
|
198
|
+
// attempt to register tsx first. If it fails to register, we will fall back to ts-node
|
|
199
|
+
await registerTsx(root, plugin?.moduleType);
|
|
200
|
+
// if tsx registration succeeded, then this will exit early since the path will be in REGISTERED already
|
|
178
201
|
await registerTSNode(root, tsconfig);
|
|
179
202
|
}
|
|
180
203
|
const { baseUrl, outDir, rootDir, rootDirs } = tsconfig.compilerOptions;
|
|
@@ -251,7 +274,7 @@ async function tsPath(root, orig, plugin) {
|
|
|
251
274
|
return orig;
|
|
252
275
|
}
|
|
253
276
|
try {
|
|
254
|
-
return await determinePath(root, orig);
|
|
277
|
+
return await determinePath(root, orig, plugin);
|
|
255
278
|
}
|
|
256
279
|
catch (error) {
|
|
257
280
|
debug(error);
|
package/lib/ux/theme.js
CHANGED
|
@@ -5,8 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseTheme = exports.colorize = void 0;
|
|
7
7
|
const ansis_1 = __importDefault(require("ansis"));
|
|
8
|
+
const supports_color_1 = require("supports-color");
|
|
8
9
|
const theme_1 = require("../interfaces/theme");
|
|
9
|
-
function
|
|
10
|
+
function isStandardAnsi(color) {
|
|
10
11
|
return theme_1.STANDARD_ANSI.includes(color);
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
@@ -18,7 +19,11 @@ function isStandardChalk(color) {
|
|
|
18
19
|
function colorize(color, text) {
|
|
19
20
|
if (!color)
|
|
20
21
|
return text;
|
|
21
|
-
if (
|
|
22
|
+
if (!supports_color_1.stdout)
|
|
23
|
+
return text;
|
|
24
|
+
if (!supports_color_1.stderr)
|
|
25
|
+
return text;
|
|
26
|
+
if (isStandardAnsi(color))
|
|
22
27
|
return ansis_1.default[color](text);
|
|
23
28
|
if (color.startsWith('#'))
|
|
24
29
|
return ansis_1.default.hex(color)(text);
|
|
@@ -39,5 +44,5 @@ function parseTheme(theme) {
|
|
|
39
44
|
}
|
|
40
45
|
exports.parseTheme = parseTheme;
|
|
41
46
|
function isValid(color) {
|
|
42
|
-
return color.startsWith('#') || color.startsWith('rgb') ||
|
|
47
|
+
return color.startsWith('#') || color.startsWith('rgb') || isStandardAnsi(color) ? color : undefined;
|
|
43
48
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/core",
|
|
3
3
|
"description": "base library for oclif CLIs",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.15",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"ansi-escapes": "^4.3.2",
|
|
9
|
-
"ansis": "^3.
|
|
9
|
+
"ansis": "^3.1.1",
|
|
10
10
|
"clean-stack": "^3.0.1",
|
|
11
11
|
"cli-spinners": "^2.9.2",
|
|
12
12
|
"cosmiconfig": "^9.0.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"is-wsl": "^2.2.0",
|
|
19
19
|
"minimatch": "^9.0.4",
|
|
20
20
|
"string-width": "^4.2.3",
|
|
21
|
-
"supports-color": "^
|
|
21
|
+
"supports-color": "^8",
|
|
22
22
|
"widest-line": "^3.1.0",
|
|
23
23
|
"wordwrap": "^1.0.0",
|
|
24
24
|
"wrap-ansi": "^7.0.0"
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@types/node": "^18",
|
|
41
41
|
"@types/pnpapi": "^0.0.5",
|
|
42
42
|
"@types/sinon": "^17.0.3",
|
|
43
|
+
"@types/supports-color": "^8.1.3",
|
|
43
44
|
"@types/wordwrap": "^1.0.3",
|
|
44
45
|
"@types/wrap-ansi": "^3.0.0",
|
|
45
46
|
"benchmark": "^2.1.4",
|