@oclif/core 4.0.0-beta.6 → 4.0.0-beta.7
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 +5 -5
- package/lib/errors/warn.d.ts +2 -8
- package/lib/errors/warn.js +9 -8
- package/lib/util/read-tsconfig.js +2 -4
- package/package.json +1 -1
package/lib/config/ts-path.js
CHANGED
|
@@ -75,7 +75,7 @@ async function loadTSConfig(root) {
|
|
|
75
75
|
if (isErrno(error))
|
|
76
76
|
return;
|
|
77
77
|
debug(`Could not parse tsconfig.json. Skipping typescript path lookup for ${root}.`);
|
|
78
|
-
(0, warn_1.
|
|
78
|
+
(0, warn_1.memoizedWarn)(`Could not parse tsconfig.json for ${root}. Falling back to compiled source.`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
async function registerTSNode(root, tsconfig) {
|
|
@@ -90,7 +90,7 @@ async function registerTSNode(root, tsconfig) {
|
|
|
90
90
|
}
|
|
91
91
|
catch {
|
|
92
92
|
debug(`Could not find ts-node at ${tsNodePath}. Skipping ts-node registration for ${root}.`);
|
|
93
|
-
(0, warn_1.
|
|
93
|
+
(0, warn_1.memoizedWarn)(`Could not find ts-node at ${tsNodePath}. Please ensure that ts-node is a devDependency. Falling back to compiled source.`);
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const typeRoots = [(0, node_path_1.join)(root, 'node_modules', '@types')];
|
|
@@ -219,7 +219,7 @@ async function determinePath(root, orig) {
|
|
|
219
219
|
}
|
|
220
220
|
debug(`No source file found. Returning default path ${orig}`);
|
|
221
221
|
if (!(0, util_1.isProd)())
|
|
222
|
-
(0, warn_1.
|
|
222
|
+
(0, warn_1.memoizedWarn)(`Could not find source for ${orig} based on tsconfig. Defaulting to compiled source.`);
|
|
223
223
|
return orig;
|
|
224
224
|
}
|
|
225
225
|
async function tsPath(root, orig, plugin) {
|
|
@@ -242,12 +242,12 @@ async function tsPath(root, orig, plugin) {
|
|
|
242
242
|
if (cannotTranspileEsm(rootPlugin, plugin, isProduction)) {
|
|
243
243
|
debug(`Skipping typescript path lookup for ${root} because it's an ESM module (NODE_ENV: ${process.env.NODE_ENV}, root plugin module type: ${rootPlugin?.moduleType})`);
|
|
244
244
|
if (plugin?.type === 'link')
|
|
245
|
-
(0, warn_1.
|
|
245
|
+
(0, warn_1.memoizedWarn)(`${plugin?.name} is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.`);
|
|
246
246
|
return orig;
|
|
247
247
|
}
|
|
248
248
|
if (cannotUseTsNode(root, plugin, isProduction)) {
|
|
249
249
|
debug(`Skipping typescript path lookup for ${root} because ts-node is run in node version ${process.version}"`);
|
|
250
|
-
(0, warn_1.
|
|
250
|
+
(0, warn_1.memoizedWarn)(`ts-node executable cannot transpile ESM in Node 20. Existing compiled source will be used instead. See https://github.com/oclif/core/issues/817.`);
|
|
251
251
|
return orig;
|
|
252
252
|
}
|
|
253
253
|
try {
|
package/lib/errors/warn.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
type Options = {
|
|
2
|
-
/**
|
|
3
|
-
* If true, will only print the same warning once.
|
|
4
|
-
*/
|
|
5
|
-
ignoreDuplicates?: boolean;
|
|
6
|
-
};
|
|
7
1
|
/**
|
|
8
2
|
* Prints a pretty warning message to stderr.
|
|
9
3
|
*
|
|
10
4
|
* @param input The error or string to print.
|
|
11
|
-
* @param options.ignoreDuplicates If true, will only print the same warning once.
|
|
12
5
|
*/
|
|
13
|
-
export declare function warn(input: Error | string
|
|
6
|
+
export declare function warn(input: Error | string): void;
|
|
7
|
+
export declare function memoizedWarn(input: Error | string): void;
|
|
14
8
|
export default warn;
|
package/lib/errors/warn.js
CHANGED
|
@@ -3,23 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.warn = void 0;
|
|
6
|
+
exports.memoizedWarn = exports.warn = void 0;
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const write_1 = require("../ux/write");
|
|
9
9
|
const cli_1 = require("./errors/cli");
|
|
10
10
|
const pretty_print_1 = __importDefault(require("./errors/pretty-print"));
|
|
11
|
-
const WARNINGS = new Set();
|
|
12
11
|
/**
|
|
13
12
|
* Prints a pretty warning message to stderr.
|
|
14
13
|
*
|
|
15
14
|
* @param input The error or string to print.
|
|
16
|
-
* @param options.ignoreDuplicates If true, will only print the same warning once.
|
|
17
15
|
*/
|
|
18
|
-
function warn(input
|
|
19
|
-
const ignoreDuplicates = options?.ignoreDuplicates ?? true;
|
|
20
|
-
if (ignoreDuplicates && WARNINGS.has(input))
|
|
21
|
-
return;
|
|
22
|
-
WARNINGS.add(input);
|
|
16
|
+
function warn(input) {
|
|
23
17
|
let err;
|
|
24
18
|
if (typeof input === 'string') {
|
|
25
19
|
err = new cli_1.CLIError.Warn(input);
|
|
@@ -37,4 +31,11 @@ function warn(input, options) {
|
|
|
37
31
|
(0, logger_1.getLogger)().error(err.stack);
|
|
38
32
|
}
|
|
39
33
|
exports.warn = warn;
|
|
34
|
+
const WARNINGS = new Set();
|
|
35
|
+
function memoizedWarn(input) {
|
|
36
|
+
if (!WARNINGS.has(input))
|
|
37
|
+
warn(input);
|
|
38
|
+
WARNINGS.add(input);
|
|
39
|
+
}
|
|
40
|
+
exports.memoizedWarn = memoizedWarn;
|
|
40
41
|
exports.default = warn;
|
|
@@ -43,13 +43,11 @@ async function readTSConfig(root, tsconfigName = 'tsconfig.json') {
|
|
|
43
43
|
catch { }
|
|
44
44
|
}
|
|
45
45
|
if (!typescript) {
|
|
46
|
-
(0, warn_1.
|
|
46
|
+
(0, warn_1.memoizedWarn)('Could not find typescript. Please ensure that typescript is a devDependency. Falling back to compiled source.');
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
const read = async (path) => {
|
|
50
|
-
const localRoot = await upUntil(path, async (p) =>
|
|
51
|
-
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
52
|
-
(await (0, promises_1.readdir)(p)).includes('package.json'));
|
|
50
|
+
const localRoot = await upUntil(path, async (p) => (await (0, promises_1.readdir)(p)).includes('package.json'));
|
|
53
51
|
if (!localRoot)
|
|
54
52
|
return;
|
|
55
53
|
try {
|