@drupal-canvas/cli 0.7.0 → 0.7.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/README.md +4 -0
- package/dist/index.js +163 -92
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -57,6 +57,10 @@ properties:
|
|
|
57
57
|
If `canvas.config.json` is not present, the CLI will use the default values
|
|
58
58
|
shown above.
|
|
59
59
|
|
|
60
|
+
If you still have `CANVAS_COMPONENT_DIR` set in your shell, `.env`, or
|
|
61
|
+
`.canvasrc`, the CLI will warn you and offer to create or update
|
|
62
|
+
`canvas.config.json` with `componentDir`.
|
|
63
|
+
|
|
60
64
|
#### .env
|
|
61
65
|
|
|
62
66
|
This file contains environmental configuration that varies between environments
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import chalk3 from 'chalk';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
4
|
+
import * as fs5 from 'fs';
|
|
5
|
+
import fs5__default, { realpathSync, promises, readlinkSync, readdirSync, readdir as readdir$1, lstatSync, existsSync, statSync } from 'fs';
|
|
6
6
|
import * as p10 from '@clack/prompts';
|
|
7
7
|
import { createHash } from 'crypto';
|
|
8
8
|
import path7, { win32, posix, isAbsolute, resolve } from 'path';
|
|
@@ -23,7 +23,7 @@ import axios from 'axios';
|
|
|
23
23
|
import os2 from 'os';
|
|
24
24
|
import { basename } from 'path/win32';
|
|
25
25
|
import { ESLint } from 'eslint';
|
|
26
|
-
import {
|
|
26
|
+
import { requiredDeprecated, required } from '@drupal-canvas/eslint-config';
|
|
27
27
|
import { table } from 'table';
|
|
28
28
|
|
|
29
29
|
var __create = Object.create;
|
|
@@ -9248,10 +9248,10 @@ var require_typescript = __commonJS({
|
|
|
9248
9248
|
Debug2.loggingHost.log(level, s);
|
|
9249
9249
|
}
|
|
9250
9250
|
}
|
|
9251
|
-
function
|
|
9251
|
+
function log10(s) {
|
|
9252
9252
|
logMessage(3, s);
|
|
9253
9253
|
}
|
|
9254
|
-
Debug2.log =
|
|
9254
|
+
Debug2.log = log10;
|
|
9255
9255
|
((_log) => {
|
|
9256
9256
|
function error2(s) {
|
|
9257
9257
|
logMessage(1, s);
|
|
@@ -9269,7 +9269,7 @@ var require_typescript = __commonJS({
|
|
|
9269
9269
|
logMessage(4, s);
|
|
9270
9270
|
}
|
|
9271
9271
|
_log.trace = trace2;
|
|
9272
|
-
})(
|
|
9272
|
+
})(log10 = Debug2.log || (Debug2.log = {}));
|
|
9273
9273
|
const assertionCache = {};
|
|
9274
9274
|
function getAssertionLevel() {
|
|
9275
9275
|
return currentAssertionLevel;
|
|
@@ -140467,8 +140467,8 @@ ${lanes.join("\n")}
|
|
|
140467
140467
|
WatchLogLevel2[WatchLogLevel2["Verbose"] = 2] = "Verbose";
|
|
140468
140468
|
return WatchLogLevel2;
|
|
140469
140469
|
})(WatchLogLevel || {});
|
|
140470
|
-
function getWatchFactory(host, watchLogLevel,
|
|
140471
|
-
setSysLog(watchLogLevel === 2 ?
|
|
140470
|
+
function getWatchFactory(host, watchLogLevel, log10, getDetailWatchInfo2) {
|
|
140471
|
+
setSysLog(watchLogLevel === 2 ? log10 : noop);
|
|
140472
140472
|
const plainInvokeFactory = {
|
|
140473
140473
|
watchFile: (file, callback, pollingInterval, options) => host.watchFile(file, callback, pollingInterval, options),
|
|
140474
140474
|
watchDirectory: (directory, callback, flags, options) => host.watchDirectory(directory, callback, (flags & 1) !== 0, options)
|
|
@@ -140505,36 +140505,36 @@ ${lanes.join("\n")}
|
|
|
140505
140505
|
return typeof host.useCaseSensitiveFileNames === "boolean" ? host.useCaseSensitiveFileNames : host.useCaseSensitiveFileNames();
|
|
140506
140506
|
}
|
|
140507
140507
|
function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) {
|
|
140508
|
-
|
|
140508
|
+
log10(`ExcludeWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
|
|
140509
140509
|
return {
|
|
140510
|
-
close: () =>
|
|
140510
|
+
close: () => log10(`ExcludeWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`)
|
|
140511
140511
|
};
|
|
140512
140512
|
}
|
|
140513
140513
|
function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
|
|
140514
|
-
|
|
140514
|
+
log10(`FileWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
|
|
140515
140515
|
const watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2);
|
|
140516
140516
|
return {
|
|
140517
140517
|
close: () => {
|
|
140518
|
-
|
|
140518
|
+
log10(`FileWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`);
|
|
140519
140519
|
watcher.close();
|
|
140520
140520
|
}
|
|
140521
140521
|
};
|
|
140522
140522
|
}
|
|
140523
140523
|
function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
|
|
140524
140524
|
const watchInfo = `DirectoryWatcher:: Added:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
|
|
140525
|
-
|
|
140525
|
+
log10(watchInfo);
|
|
140526
140526
|
const start = timestamp();
|
|
140527
140527
|
const watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2);
|
|
140528
140528
|
const elapsed = timestamp() - start;
|
|
140529
|
-
|
|
140529
|
+
log10(`Elapsed:: ${elapsed}ms ${watchInfo}`);
|
|
140530
140530
|
return {
|
|
140531
140531
|
close: () => {
|
|
140532
140532
|
const watchInfo2 = `DirectoryWatcher:: Close:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
|
|
140533
|
-
|
|
140533
|
+
log10(watchInfo2);
|
|
140534
140534
|
const start2 = timestamp();
|
|
140535
140535
|
watcher.close();
|
|
140536
140536
|
const elapsed2 = timestamp() - start2;
|
|
140537
|
-
|
|
140537
|
+
log10(`Elapsed:: ${elapsed2}ms ${watchInfo2}`);
|
|
140538
140538
|
}
|
|
140539
140539
|
};
|
|
140540
140540
|
}
|
|
@@ -140545,7 +140545,7 @@ ${lanes.join("\n")}
|
|
|
140545
140545
|
file,
|
|
140546
140546
|
(...args) => {
|
|
140547
140547
|
const triggerredInfo = `${key2 === "watchFile" ? "FileWatcher" : "DirectoryWatcher"}:: Triggered with ${args[0]} ${args[1] !== void 0 ? args[1] : ""}:: ${getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo2)}`;
|
|
140548
|
-
|
|
140548
|
+
log10(triggerredInfo);
|
|
140549
140549
|
const start = timestamp();
|
|
140550
140550
|
cb.call(
|
|
140551
140551
|
/*thisArg*/
|
|
@@ -140553,7 +140553,7 @@ ${lanes.join("\n")}
|
|
|
140553
140553
|
...args
|
|
140554
140554
|
);
|
|
140555
140555
|
const elapsed = timestamp() - start;
|
|
140556
|
-
|
|
140556
|
+
log10(`Elapsed:: ${elapsed}ms ${triggerredInfo}`);
|
|
140557
140557
|
},
|
|
140558
140558
|
flags,
|
|
140559
140559
|
options,
|
|
@@ -153613,7 +153613,7 @@ ${lanes.join("\n")}
|
|
|
153613
153613
|
}
|
|
153614
153614
|
return void 0;
|
|
153615
153615
|
}
|
|
153616
|
-
function discoverTypings(host,
|
|
153616
|
+
function discoverTypings(host, log10, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
|
|
153617
153617
|
if (!typeAcquisition || !typeAcquisition.enable) {
|
|
153618
153618
|
return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
|
|
153619
153619
|
}
|
|
@@ -153648,7 +153648,7 @@ ${lanes.join("\n")}
|
|
|
153648
153648
|
}
|
|
153649
153649
|
for (const excludeTypingName of exclude) {
|
|
153650
153650
|
const didDelete = inferredTypings.delete(excludeTypingName);
|
|
153651
|
-
if (didDelete &&
|
|
153651
|
+
if (didDelete && log10) log10(`Typing for ${excludeTypingName} is in exclude list, will be ignored.`);
|
|
153652
153652
|
}
|
|
153653
153653
|
packageNameToTypingLocation.forEach((typing, name) => {
|
|
153654
153654
|
const registryEntry = typesRegistry.get(name);
|
|
@@ -153666,7 +153666,7 @@ ${lanes.join("\n")}
|
|
|
153666
153666
|
}
|
|
153667
153667
|
});
|
|
153668
153668
|
const result = { cachedTypingPaths, newTypingNames, filesToWatch };
|
|
153669
|
-
if (
|
|
153669
|
+
if (log10) log10(`Finished typings discovery:${stringifyIndented(result)}`);
|
|
153670
153670
|
return result;
|
|
153671
153671
|
function addInferredTyping(typingName) {
|
|
153672
153672
|
if (!inferredTypings.has(typingName)) {
|
|
@@ -153674,7 +153674,7 @@ ${lanes.join("\n")}
|
|
|
153674
153674
|
}
|
|
153675
153675
|
}
|
|
153676
153676
|
function addInferredTypings(typingNames, message) {
|
|
153677
|
-
if (
|
|
153677
|
+
if (log10) log10(`${message}: ${JSON.stringify(typingNames)}`);
|
|
153678
153678
|
forEach(typingNames, addInferredTyping);
|
|
153679
153679
|
}
|
|
153680
153680
|
function getTypingNames(projectRootPath2, manifestName, modulesDirName, filesToWatch2) {
|
|
@@ -153714,7 +153714,7 @@ ${lanes.join("\n")}
|
|
|
153714
153714
|
return isScoped && toFileNameLowerCase(pathComponents2[pathComponents2.length - 4]) === modulesDirName || // `node_modules/@foo/bar`
|
|
153715
153715
|
!isScoped && toFileNameLowerCase(pathComponents2[pathComponents2.length - 3]) === modulesDirName;
|
|
153716
153716
|
});
|
|
153717
|
-
if (
|
|
153717
|
+
if (log10) log10(`Searching for typing names in ${packagesFolderPath}; all files: ${JSON.stringify(dependencyManifestNames)}`);
|
|
153718
153718
|
for (const manifestPath2 of dependencyManifestNames) {
|
|
153719
153719
|
const normalizedFileName = normalizePath4(manifestPath2);
|
|
153720
153720
|
const result2 = readConfigFile(normalizedFileName, (path21) => host.readFile(path21));
|
|
@@ -153726,10 +153726,10 @@ ${lanes.join("\n")}
|
|
|
153726
153726
|
if (ownTypes) {
|
|
153727
153727
|
const absolutePath = getNormalizedAbsolutePath(ownTypes, getDirectoryPath(normalizedFileName));
|
|
153728
153728
|
if (host.fileExists(absolutePath)) {
|
|
153729
|
-
if (
|
|
153729
|
+
if (log10) log10(` Package '${manifest2.name}' provides its own types.`);
|
|
153730
153730
|
inferredTypings.set(manifest2.name, absolutePath);
|
|
153731
153731
|
} else {
|
|
153732
|
-
if (
|
|
153732
|
+
if (log10) log10(` Package '${manifest2.name}' provides its own types but they are missing.`);
|
|
153733
153733
|
}
|
|
153734
153734
|
} else {
|
|
153735
153735
|
packageNames.push(manifest2.name);
|
|
@@ -153753,7 +153753,7 @@ ${lanes.join("\n")}
|
|
|
153753
153753
|
/* Jsx */
|
|
153754
153754
|
));
|
|
153755
153755
|
if (hasJsxFile) {
|
|
153756
|
-
if (
|
|
153756
|
+
if (log10) log10(`Inferred 'react' typings due to presence of '.jsx' extension`);
|
|
153757
153757
|
addInferredTyping("react");
|
|
153758
153758
|
}
|
|
153759
153759
|
}
|
|
@@ -168130,7 +168130,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
168130
168130
|
const cancellationToken = host.getCancellationToken ? new CancellationTokenObject(host.getCancellationToken()) : NoopCancellationToken;
|
|
168131
168131
|
const currentDirectory = host.getCurrentDirectory();
|
|
168132
168132
|
maybeSetLocalizedDiagnosticMessages((_a2 = host.getLocalizedDiagnosticMessages) == null ? void 0 : _a2.bind(host));
|
|
168133
|
-
function
|
|
168133
|
+
function log10(message) {
|
|
168134
168134
|
if (host.log) {
|
|
168135
168135
|
host.log(message);
|
|
168136
168136
|
}
|
|
@@ -168145,7 +168145,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
168145
168145
|
readFile: maybeBind(host, host.readFile),
|
|
168146
168146
|
getDocumentPositionMapper: maybeBind(host, host.getDocumentPositionMapper),
|
|
168147
168147
|
getSourceFileLike: maybeBind(host, host.getSourceFileLike),
|
|
168148
|
-
log:
|
|
168148
|
+
log: log10
|
|
168149
168149
|
});
|
|
168150
168150
|
function getValidSourceFile(fileName) {
|
|
168151
168151
|
const sourceFile = program2.getSourceFile(fileName);
|
|
@@ -168180,7 +168180,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
168180
168180
|
}
|
|
168181
168181
|
const typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0;
|
|
168182
168182
|
if (lastTypesRootVersion !== typeRootsVersion) {
|
|
168183
|
-
|
|
168183
|
+
log10("TypeRoots version has changed; provide new program");
|
|
168184
168184
|
program2 = void 0;
|
|
168185
168185
|
lastTypesRootVersion = typeRootsVersion;
|
|
168186
168186
|
}
|
|
@@ -168550,7 +168550,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
168550
168550
|
return ts_Completions_exports.getCompletionsAtPosition(
|
|
168551
168551
|
host,
|
|
168552
168552
|
program2,
|
|
168553
|
-
|
|
168553
|
+
log10,
|
|
168554
168554
|
getValidSourceFile(fileName),
|
|
168555
168555
|
position,
|
|
168556
168556
|
fullPreferences,
|
|
@@ -168565,7 +168565,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
168565
168565
|
synchronizeHostData();
|
|
168566
168566
|
return ts_Completions_exports.getCompletionEntryDetails(
|
|
168567
168567
|
program2,
|
|
168568
|
-
|
|
168568
|
+
log10,
|
|
168569
168569
|
getValidSourceFile(fileName),
|
|
168570
168570
|
position,
|
|
168571
168571
|
{ name, source: source2, data },
|
|
@@ -168578,7 +168578,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
168578
168578
|
}
|
|
168579
168579
|
function getCompletionEntrySymbol2(fileName, position, name, source2, preferences = emptyOptions) {
|
|
168580
168580
|
synchronizeHostData();
|
|
168581
|
-
return ts_Completions_exports.getCompletionEntrySymbol(program2,
|
|
168581
|
+
return ts_Completions_exports.getCompletionEntrySymbol(program2, log10, getValidSourceFile(fileName), position, { name, source: source2 }, host, preferences);
|
|
168582
168582
|
}
|
|
168583
168583
|
function getQuickInfoAtPosition(fileName, position, maximumLength, verbosityLevel) {
|
|
168584
168584
|
synchronizeHostData();
|
|
@@ -168883,10 +168883,10 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
168883
168883
|
let start = timestamp();
|
|
168884
168884
|
const settings = toEditorSettings(editorOptions);
|
|
168885
168885
|
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
|
168886
|
-
|
|
168886
|
+
log10("getIndentationAtPosition: getCurrentSourceFile: " + (timestamp() - start));
|
|
168887
168887
|
start = timestamp();
|
|
168888
168888
|
const result = ts_formatting_exports.SmartIndenter.getIndentation(position, sourceFile, settings);
|
|
168889
|
-
|
|
168889
|
+
log10("getIndentationAtPosition: computeIndentation : " + (timestamp() - start));
|
|
168890
168890
|
return result;
|
|
168891
168891
|
}
|
|
168892
168892
|
function getFormattingEditsForRange(fileName, start, end, options) {
|
|
@@ -182621,7 +182621,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
182621
182621
|
}
|
|
182622
182622
|
return allCommitCharacters;
|
|
182623
182623
|
}
|
|
182624
|
-
function getCompletionsAtPosition(host, program2,
|
|
182624
|
+
function getCompletionsAtPosition(host, program2, log10, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol = false) {
|
|
182625
182625
|
var _a2;
|
|
182626
182626
|
const { previousToken } = getRelevantTokens(position, sourceFile);
|
|
182627
182627
|
if (triggerCharacter && !isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) {
|
|
@@ -182654,7 +182654,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
182654
182654
|
} else {
|
|
182655
182655
|
incompleteCompletionsCache == null ? void 0 : incompleteCompletionsCache.clear();
|
|
182656
182656
|
}
|
|
182657
|
-
const stringCompletions = ts_Completions_StringCompletions_exports.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program2,
|
|
182657
|
+
const stringCompletions = ts_Completions_StringCompletions_exports.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program2, log10, preferences, includeSymbol);
|
|
182658
182658
|
if (stringCompletions) {
|
|
182659
182659
|
return stringCompletions;
|
|
182660
182660
|
}
|
|
@@ -182663,7 +182663,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
182663
182663
|
}
|
|
182664
182664
|
const completionData = getCompletionData(
|
|
182665
182665
|
program2,
|
|
182666
|
-
|
|
182666
|
+
log10,
|
|
182667
182667
|
sourceFile,
|
|
182668
182668
|
compilerOptions,
|
|
182669
182669
|
position,
|
|
@@ -182679,7 +182679,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
182679
182679
|
}
|
|
182680
182680
|
switch (completionData.kind) {
|
|
182681
182681
|
case 0:
|
|
182682
|
-
const response = completionInfoFromData(sourceFile, host, program2, compilerOptions,
|
|
182682
|
+
const response = completionInfoFromData(sourceFile, host, program2, compilerOptions, log10, completionData, preferences, formatContext, position, includeSymbol);
|
|
182683
182683
|
if (response == null ? void 0 : response.isIncomplete) {
|
|
182684
182684
|
incompleteCompletionsCache == null ? void 0 : incompleteCompletionsCache.set(response);
|
|
182685
182685
|
}
|
|
@@ -183101,7 +183101,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
183101
183101
|
function getOptionalReplacementSpan(location) {
|
|
183102
183102
|
return (location == null ? void 0 : location.kind) === 80 ? createTextSpanFromNode(location) : void 0;
|
|
183103
183103
|
}
|
|
183104
|
-
function completionInfoFromData(sourceFile, host, program2, compilerOptions,
|
|
183104
|
+
function completionInfoFromData(sourceFile, host, program2, compilerOptions, log10, completionData, preferences, formatContext, position, includeSymbol) {
|
|
183105
183105
|
const {
|
|
183106
183106
|
symbols,
|
|
183107
183107
|
contextToken,
|
|
@@ -183165,7 +183165,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
183165
183165
|
host,
|
|
183166
183166
|
program2,
|
|
183167
183167
|
getEmitScriptTarget(compilerOptions),
|
|
183168
|
-
|
|
183168
|
+
log10,
|
|
183169
183169
|
completionKind,
|
|
183170
183170
|
preferences,
|
|
183171
183171
|
compilerOptions,
|
|
@@ -184177,7 +184177,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184177
184177
|
return "TypeOnlyAlias/";
|
|
184178
184178
|
}
|
|
184179
184179
|
}
|
|
184180
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program2, target,
|
|
184180
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, position, sourceFile, host, program2, target, log10, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importStatementCompletion, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag, includeSymbol = false) {
|
|
184181
184181
|
const start = timestamp();
|
|
184182
184182
|
const closestSymbolDeclaration = getClosestSymbolDeclaration(contextToken, location);
|
|
184183
184183
|
const useSemicolons = probablyUsesSemicolons(sourceFile);
|
|
@@ -184237,7 +184237,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184237
184237
|
true
|
|
184238
184238
|
);
|
|
184239
184239
|
}
|
|
184240
|
-
|
|
184240
|
+
log10("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (timestamp() - start));
|
|
184241
184241
|
return {
|
|
184242
184242
|
has: (name) => uniques.has(name),
|
|
184243
184243
|
add: (name) => uniques.set(name, true)
|
|
@@ -184333,7 +184333,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184333
184333
|
}
|
|
184334
184334
|
return entries;
|
|
184335
184335
|
}
|
|
184336
|
-
function getSymbolCompletionFromEntryId(program2,
|
|
184336
|
+
function getSymbolCompletionFromEntryId(program2, log10, sourceFile, position, entryId, host, preferences) {
|
|
184337
184337
|
if (entryId.source === "SwitchCases/") {
|
|
184338
184338
|
return { type: "cases" };
|
|
184339
184339
|
}
|
|
@@ -184356,7 +184356,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184356
184356
|
const compilerOptions = program2.getCompilerOptions();
|
|
184357
184357
|
const completionData = getCompletionData(
|
|
184358
184358
|
program2,
|
|
184359
|
-
|
|
184359
|
+
log10,
|
|
184360
184360
|
sourceFile,
|
|
184361
184361
|
compilerOptions,
|
|
184362
184362
|
position,
|
|
@@ -184381,7 +184381,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184381
184381
|
return info && info.name === entryId.name && (entryId.source === "ClassMemberSnippet/" && symbol.flags & 106500 || entryId.source === "ObjectLiteralMethodSnippet/" && symbol.flags & (4 | 8192) || getSourceFromOrigin(origin) === entryId.source || entryId.source === "ObjectLiteralMemberWithComma/") ? { type: "symbol", symbol, location, origin, contextToken, previousToken, isJsxInitializer, isTypeOnlyLocation } : void 0;
|
|
184382
184382
|
}) || { type: "none" };
|
|
184383
184383
|
}
|
|
184384
|
-
function getCompletionEntryDetails(program2,
|
|
184384
|
+
function getCompletionEntryDetails(program2, log10, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
|
|
184385
184385
|
const typeChecker = program2.getTypeChecker();
|
|
184386
184386
|
const compilerOptions = program2.getCompilerOptions();
|
|
184387
184387
|
const { name, source: source2, data } = entryId;
|
|
@@ -184389,7 +184389,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184389
184389
|
if (isInString(sourceFile, position, previousToken)) {
|
|
184390
184390
|
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, program2, host, cancellationToken, preferences);
|
|
184391
184391
|
}
|
|
184392
|
-
const symbolCompletion = getSymbolCompletionFromEntryId(program2,
|
|
184392
|
+
const symbolCompletion = getSymbolCompletionFromEntryId(program2, log10, sourceFile, position, entryId, host, preferences);
|
|
184393
184393
|
switch (symbolCompletion.type) {
|
|
184394
184394
|
case "request": {
|
|
184395
184395
|
const { request } = symbolCompletion;
|
|
@@ -184583,8 +184583,8 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184583
184583
|
Debug.assert(!(data == null ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
|
|
184584
184584
|
return { sourceDisplay: [textPart(moduleSpecifier)], codeActions: [codeAction] };
|
|
184585
184585
|
}
|
|
184586
|
-
function getCompletionEntrySymbol(program2,
|
|
184587
|
-
const completion = getSymbolCompletionFromEntryId(program2,
|
|
184586
|
+
function getCompletionEntrySymbol(program2, log10, sourceFile, position, entryId, host, preferences) {
|
|
184587
|
+
const completion = getSymbolCompletionFromEntryId(program2, log10, sourceFile, position, entryId, host, preferences);
|
|
184588
184588
|
return completion.type === "symbol" ? completion.symbol : void 0;
|
|
184589
184589
|
}
|
|
184590
184590
|
var CompletionKind = /* @__PURE__ */ ((CompletionKind2) => {
|
|
@@ -184657,15 +184657,15 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184657
184657
|
/* SourceFile */
|
|
184658
184658
|
));
|
|
184659
184659
|
}
|
|
184660
|
-
function getCompletionData(program2,
|
|
184660
|
+
function getCompletionData(program2, log10, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
|
|
184661
184661
|
const typeChecker = program2.getTypeChecker();
|
|
184662
184662
|
const inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
|
|
184663
184663
|
let start = timestamp();
|
|
184664
184664
|
let currentToken = getTokenAtPosition(sourceFile, position);
|
|
184665
|
-
|
|
184665
|
+
log10("getCompletionData: Get current token: " + (timestamp() - start));
|
|
184666
184666
|
start = timestamp();
|
|
184667
184667
|
const insideComment = isInComment(sourceFile, position, currentToken);
|
|
184668
|
-
|
|
184668
|
+
log10("getCompletionData: Is inside comment: " + (timestamp() - start));
|
|
184669
184669
|
let insideJsDocTagTypeExpression = false;
|
|
184670
184670
|
let insideJsDocImportTag = false;
|
|
184671
184671
|
let isInSnippetScope = false;
|
|
@@ -184710,7 +184710,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184710
184710
|
}
|
|
184711
184711
|
}
|
|
184712
184712
|
if (!insideJsDocTagTypeExpression && !insideJsDocImportTag) {
|
|
184713
|
-
|
|
184713
|
+
log10("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment.");
|
|
184714
184714
|
return void 0;
|
|
184715
184715
|
}
|
|
184716
184716
|
}
|
|
@@ -184719,7 +184719,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184719
184719
|
const tokens = getRelevantTokens(position, sourceFile);
|
|
184720
184720
|
const previousToken = tokens.previousToken;
|
|
184721
184721
|
let contextToken = tokens.contextToken;
|
|
184722
|
-
|
|
184722
|
+
log10("getCompletionData: Get previous token: " + (timestamp() - start));
|
|
184723
184723
|
let node = currentToken;
|
|
184724
184724
|
let propertyAccessToConvert;
|
|
184725
184725
|
let isRightOfDot = false;
|
|
@@ -184752,7 +184752,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184752
184752
|
isNewIdentifierLocation = importStatementCompletionInfo.isNewIdentifierLocation;
|
|
184753
184753
|
}
|
|
184754
184754
|
if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
|
|
184755
|
-
|
|
184755
|
+
log10("Returning an empty list because completion was requested in an invalid position.");
|
|
184756
184756
|
return keywordFilters ? keywordCompletionData(keywordFilters, isJsOnlyLocation, computeCommitCharactersAndIsNewIdentifier().isNewIdentifierLocation) : void 0;
|
|
184757
184757
|
}
|
|
184758
184758
|
let parent2 = contextToken.parent;
|
|
@@ -184885,7 +184885,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
184885
184885
|
return keywordFilters ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierLocation) : void 0;
|
|
184886
184886
|
}
|
|
184887
184887
|
}
|
|
184888
|
-
|
|
184888
|
+
log10("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
|
|
184889
184889
|
const contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker);
|
|
184890
184890
|
const isLiteralExpected = !tryCast(previousToken, isStringLiteralLike) && !isJsxIdentifierExpected;
|
|
184891
184891
|
const literals = !isLiteralExpected ? [] : mapDefined(
|
|
@@ -185432,7 +185432,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
185432
185432
|
function isCompletionListBlocker(contextToken2) {
|
|
185433
185433
|
const start2 = timestamp();
|
|
185434
185434
|
const result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken2) || isSolelyIdentifierDefinitionLocation(contextToken2) || isDotOfNumericLiteral(contextToken2) || isInJsxText(contextToken2) || isBigIntLiteral(contextToken2);
|
|
185435
|
-
|
|
185435
|
+
log10("getCompletionsAtPosition: isCompletionListBlocker: " + (timestamp() - start2));
|
|
185436
185436
|
return result;
|
|
185437
185437
|
}
|
|
185438
185438
|
function isInJsxText(contextToken2) {
|
|
@@ -186755,7 +186755,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
186755
186755
|
values: map2.values.bind(map2)
|
|
186756
186756
|
};
|
|
186757
186757
|
}
|
|
186758
|
-
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program2,
|
|
186758
|
+
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program2, log10, preferences, includeSymbol) {
|
|
186759
186759
|
if (isInReferenceComment(sourceFile, position)) {
|
|
186760
186760
|
const entries = getTripleSlashReferenceCompletion(sourceFile, position, program2, host, createModuleSpecifierResolutionHost(program2, host));
|
|
186761
186761
|
return entries && convertPathCompletions(entries);
|
|
@@ -186763,10 +186763,10 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
186763
186763
|
if (isInString(sourceFile, position, contextToken)) {
|
|
186764
186764
|
if (!contextToken || !isStringLiteralLike(contextToken)) return void 0;
|
|
186765
186765
|
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program2, host, preferences);
|
|
186766
|
-
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program2,
|
|
186766
|
+
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program2, log10, options, preferences, position, includeSymbol);
|
|
186767
186767
|
}
|
|
186768
186768
|
}
|
|
186769
|
-
function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program2,
|
|
186769
|
+
function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program2, log10, options, preferences, position, includeSymbol) {
|
|
186770
186770
|
if (completion === void 0) {
|
|
186771
186771
|
return void 0;
|
|
186772
186772
|
}
|
|
@@ -186787,7 +186787,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
|
|
|
186787
186787
|
host,
|
|
186788
186788
|
program2,
|
|
186789
186789
|
99,
|
|
186790
|
-
|
|
186790
|
+
log10,
|
|
186791
186791
|
4,
|
|
186792
186792
|
preferences,
|
|
186793
186793
|
options,
|
|
@@ -203287,7 +203287,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
203287
203287
|
isEnabled: () => false,
|
|
203288
203288
|
writeLine: noop
|
|
203289
203289
|
};
|
|
203290
|
-
function typingToFileName(cachePath, packageName, installTypingHost,
|
|
203290
|
+
function typingToFileName(cachePath, packageName, installTypingHost, log10) {
|
|
203291
203291
|
try {
|
|
203292
203292
|
const result = resolveModuleName(packageName, combinePaths(cachePath, "index.d.ts"), {
|
|
203293
203293
|
moduleResolution: 2
|
|
@@ -203295,8 +203295,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
203295
203295
|
}, installTypingHost);
|
|
203296
203296
|
return result.resolvedModule && result.resolvedModule.resolvedFileName;
|
|
203297
203297
|
} catch (e) {
|
|
203298
|
-
if (
|
|
203299
|
-
|
|
203298
|
+
if (log10.isEnabled()) {
|
|
203299
|
+
log10.writeLine(`Failed to resolve ${packageName} in folder '${cachePath}': ${e.message}`);
|
|
203300
203300
|
}
|
|
203301
203301
|
return void 0;
|
|
203302
203302
|
}
|
|
@@ -203323,13 +203323,13 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
203323
203323
|
return { command, remaining: remaining - toSlice };
|
|
203324
203324
|
}
|
|
203325
203325
|
var TypingsInstaller = class {
|
|
203326
|
-
constructor(installTypingHost, globalCachePath, safeListPath, typesMapLocation, throttleLimit,
|
|
203326
|
+
constructor(installTypingHost, globalCachePath, safeListPath, typesMapLocation, throttleLimit, log10 = nullLog) {
|
|
203327
203327
|
this.installTypingHost = installTypingHost;
|
|
203328
203328
|
this.globalCachePath = globalCachePath;
|
|
203329
203329
|
this.safeListPath = safeListPath;
|
|
203330
203330
|
this.typesMapLocation = typesMapLocation;
|
|
203331
203331
|
this.throttleLimit = throttleLimit;
|
|
203332
|
-
this.log =
|
|
203332
|
+
this.log = log10;
|
|
203333
203333
|
this.packageNameToTypingLocation = /* @__PURE__ */ new Map();
|
|
203334
203334
|
this.missingTypingsSet = /* @__PURE__ */ new Set();
|
|
203335
203335
|
this.knownCachesSet = /* @__PURE__ */ new Set();
|
|
@@ -203827,13 +203827,13 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
203827
203827
|
}
|
|
203828
203828
|
static run(self2) {
|
|
203829
203829
|
self2.timerId = void 0;
|
|
203830
|
-
const
|
|
203830
|
+
const log10 = self2.logger.hasLevel(
|
|
203831
203831
|
2
|
|
203832
203832
|
/* requestTime */
|
|
203833
203833
|
);
|
|
203834
|
-
const before =
|
|
203834
|
+
const before = log10 && self2.host.getMemoryUsage();
|
|
203835
203835
|
self2.host.gc();
|
|
203836
|
-
if (
|
|
203836
|
+
if (log10) {
|
|
203837
203837
|
const after = self2.host.getMemoryUsage();
|
|
203838
203838
|
self2.logger.perftrc(`GC::before ${before}, after ${after}`);
|
|
203839
203839
|
}
|
|
@@ -204759,17 +204759,17 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
204759
204759
|
updateProjectIfDirty(this);
|
|
204760
204760
|
return hasOneOrMoreJsAndNoTsFiles(this);
|
|
204761
204761
|
}
|
|
204762
|
-
static resolveModule(moduleName, initialDir, host,
|
|
204763
|
-
return _Project.importServicePluginSync({ name: moduleName }, [initialDir], host,
|
|
204762
|
+
static resolveModule(moduleName, initialDir, host, log10) {
|
|
204763
|
+
return _Project.importServicePluginSync({ name: moduleName }, [initialDir], host, log10).resolvedModule;
|
|
204764
204764
|
}
|
|
204765
204765
|
/** @internal */
|
|
204766
|
-
static importServicePluginSync(pluginConfigEntry, searchPaths, host,
|
|
204766
|
+
static importServicePluginSync(pluginConfigEntry, searchPaths, host, log10) {
|
|
204767
204767
|
Debug.assertIsDefined(host.require);
|
|
204768
204768
|
let errorLogs;
|
|
204769
204769
|
let resolvedModule;
|
|
204770
204770
|
for (const initialDir of searchPaths) {
|
|
204771
204771
|
const resolvedPath = normalizeSlashes(host.resolvePath(combinePaths(initialDir, "node_modules")));
|
|
204772
|
-
|
|
204772
|
+
log10(`Loading ${pluginConfigEntry.name} from ${initialDir} (resolved to ${resolvedPath})`);
|
|
204773
204773
|
const result = host.require(resolvedPath, pluginConfigEntry.name);
|
|
204774
204774
|
if (!result.error) {
|
|
204775
204775
|
resolvedModule = result.module;
|
|
@@ -204781,13 +204781,13 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
204781
204781
|
return { pluginConfigEntry, resolvedModule, errorLogs };
|
|
204782
204782
|
}
|
|
204783
204783
|
/** @internal */
|
|
204784
|
-
static async importServicePluginAsync(pluginConfigEntry, searchPaths, host,
|
|
204784
|
+
static async importServicePluginAsync(pluginConfigEntry, searchPaths, host, log10) {
|
|
204785
204785
|
Debug.assertIsDefined(host.importPlugin);
|
|
204786
204786
|
let errorLogs;
|
|
204787
204787
|
let resolvedModule;
|
|
204788
204788
|
for (const initialDir of searchPaths) {
|
|
204789
204789
|
const resolvedPath = combinePaths(initialDir, "node_modules");
|
|
204790
|
-
|
|
204790
|
+
log10(`Dynamically importing ${pluginConfigEntry.name} from ${initialDir} (resolved to ${resolvedPath})`);
|
|
204791
204791
|
let result;
|
|
204792
204792
|
try {
|
|
204793
204793
|
result = await host.importPlugin(resolvedPath, pluginConfigEntry.name);
|
|
@@ -207594,7 +207594,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
207594
207594
|
3
|
|
207595
207595
|
/* verbose */
|
|
207596
207596
|
) ? 2 : this.logger.loggingEnabled() ? 1 : 0;
|
|
207597
|
-
const
|
|
207597
|
+
const log10 = watchLogLevel !== 0 ? (s) => this.logger.info(s) : noop;
|
|
207598
207598
|
this.packageJsonCache = createPackageJsonCache(this);
|
|
207599
207599
|
this.watchFactory = this.serverMode !== 0 ? {
|
|
207600
207600
|
watchFile: returnNoopFileWatcher,
|
|
@@ -207602,7 +207602,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
207602
207602
|
} : getWatchFactory(
|
|
207603
207603
|
createWatchFactoryHostUsingWatchEvents(this, opts.canUseWatchEvents) || this.host,
|
|
207604
207604
|
watchLogLevel,
|
|
207605
|
-
|
|
207605
|
+
log10,
|
|
207606
207606
|
getDetailWatchInfo
|
|
207607
207607
|
);
|
|
207608
207608
|
this.canUseWatchEvents = getCanUseWatchEvents(this, opts.canUseWatchEvents);
|
|
@@ -235178,7 +235178,7 @@ var require_node = __commonJS({
|
|
|
235178
235178
|
var tty = __require("tty");
|
|
235179
235179
|
var util2 = __require("util");
|
|
235180
235180
|
exports$1.init = init;
|
|
235181
|
-
exports$1.log =
|
|
235181
|
+
exports$1.log = log10;
|
|
235182
235182
|
exports$1.formatArgs = formatArgs;
|
|
235183
235183
|
exports$1.save = save;
|
|
235184
235184
|
exports$1.load = load3;
|
|
@@ -235313,7 +235313,7 @@ var require_node = __commonJS({
|
|
|
235313
235313
|
}
|
|
235314
235314
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
235315
235315
|
}
|
|
235316
|
-
function
|
|
235316
|
+
function log10(...args) {
|
|
235317
235317
|
return process.stderr.write(util2.formatWithOptions(exports$1.inspectOpts, ...args) + "\n");
|
|
235318
235318
|
}
|
|
235319
235319
|
function save(namespaces) {
|
|
@@ -274614,7 +274614,7 @@ var V = class extends EventEmitter {
|
|
|
274614
274614
|
};
|
|
274615
274615
|
var vi = realpathSync.native;
|
|
274616
274616
|
var wt = { lstatSync: lstatSync, readdir: readdir$1, readdirSync: readdirSync, readlinkSync: readlinkSync, realpathSync: vi, promises: { lstat: lstat, readdir: readdir, readlink: readlink, realpath: realpath } };
|
|
274617
|
-
var Ue = (n9) => !n9 || n9 === wt || n9 ===
|
|
274617
|
+
var Ue = (n9) => !n9 || n9 === wt || n9 === fs5 ? wt : { ...wt, ...n9, promises: { ...wt.promises, ...n9.promises || {} } };
|
|
274618
274618
|
var $e = /^\\\\\?\\([a-z]:)\\?$/i;
|
|
274619
274619
|
var Ri = (n9) => n9.replace(/\//g, "\\").replace($e, "$1\\");
|
|
274620
274620
|
var Oi = /[\\\/]/;
|
|
@@ -276241,11 +276241,11 @@ var DEFAULT_CANVAS_CONFIG = {
|
|
|
276241
276241
|
};
|
|
276242
276242
|
function loadCanvasConfig() {
|
|
276243
276243
|
const configPath = path7.resolve(process.cwd(), "canvas.config.json");
|
|
276244
|
-
if (!
|
|
276244
|
+
if (!fs5__default.existsSync(configPath)) {
|
|
276245
276245
|
return { ...DEFAULT_CANVAS_CONFIG };
|
|
276246
276246
|
}
|
|
276247
276247
|
try {
|
|
276248
|
-
const raw =
|
|
276248
|
+
const raw = fs5__default.readFileSync(configPath, "utf-8");
|
|
276249
276249
|
const parsed = JSON.parse(raw);
|
|
276250
276250
|
return {
|
|
276251
276251
|
aliasBaseDir: parsed.aliasBaseDir ?? DEFAULT_CANVAS_CONFIG.aliasBaseDir,
|
|
@@ -276266,12 +276266,12 @@ function loadEnvFiles() {
|
|
|
276266
276266
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
276267
276267
|
if (homeDir) {
|
|
276268
276268
|
const homeEnvPath = path7.resolve(homeDir, ".canvasrc");
|
|
276269
|
-
if (
|
|
276269
|
+
if (fs5__default.existsSync(homeEnvPath)) {
|
|
276270
276270
|
dotenv.config({ path: homeEnvPath });
|
|
276271
276271
|
}
|
|
276272
276272
|
}
|
|
276273
276273
|
const localEnvPath = path7.resolve(process.cwd(), ".env");
|
|
276274
|
-
if (
|
|
276274
|
+
if (fs5__default.existsSync(localEnvPath)) {
|
|
276275
276275
|
dotenv.config({ path: localEnvPath });
|
|
276276
276276
|
}
|
|
276277
276277
|
}
|
|
@@ -276296,6 +276296,75 @@ function getConfig() {
|
|
|
276296
276296
|
function setConfig(newConfig) {
|
|
276297
276297
|
config = { ...config, ...newConfig };
|
|
276298
276298
|
}
|
|
276299
|
+
var legacyComponentDirMigrationHandled = false;
|
|
276300
|
+
async function handleLegacyComponentDirMigration(options = {}) {
|
|
276301
|
+
if (legacyComponentDirMigrationHandled) {
|
|
276302
|
+
return;
|
|
276303
|
+
}
|
|
276304
|
+
legacyComponentDirMigrationHandled = true;
|
|
276305
|
+
const legacyComponentDir = process.env.CANVAS_COMPONENT_DIR?.trim();
|
|
276306
|
+
if (!legacyComponentDir) {
|
|
276307
|
+
return;
|
|
276308
|
+
}
|
|
276309
|
+
const configPath = path7.resolve(process.cwd(), "canvas.config.json");
|
|
276310
|
+
const hasConfigFile = fs5__default.existsSync(configPath);
|
|
276311
|
+
let parsedConfig = null;
|
|
276312
|
+
let configParseError = false;
|
|
276313
|
+
if (hasConfigFile) {
|
|
276314
|
+
try {
|
|
276315
|
+
const raw = fs5__default.readFileSync(configPath, "utf-8");
|
|
276316
|
+
const parsed = JSON.parse(raw);
|
|
276317
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
276318
|
+
parsedConfig = parsed;
|
|
276319
|
+
} else {
|
|
276320
|
+
configParseError = true;
|
|
276321
|
+
}
|
|
276322
|
+
} catch {
|
|
276323
|
+
configParseError = true;
|
|
276324
|
+
}
|
|
276325
|
+
}
|
|
276326
|
+
const hasComponentDirConfig = typeof parsedConfig?.componentDir === "string" && parsedConfig.componentDir.trim().length > 0;
|
|
276327
|
+
if (hasComponentDirConfig) {
|
|
276328
|
+
return;
|
|
276329
|
+
}
|
|
276330
|
+
p10.log.warn(
|
|
276331
|
+
"CANVAS_COMPONENT_DIR is deprecated for component directory configuration. Use componentDir in canvas.config.json instead."
|
|
276332
|
+
);
|
|
276333
|
+
setConfig({
|
|
276334
|
+
componentDir: legacyComponentDir,
|
|
276335
|
+
deprecatedComponentDir: legacyComponentDir
|
|
276336
|
+
});
|
|
276337
|
+
if (configParseError) {
|
|
276338
|
+
p10.log.warn(
|
|
276339
|
+
"canvas.config.json exists but is invalid. Update it manually by adding a componentDir key."
|
|
276340
|
+
);
|
|
276341
|
+
return;
|
|
276342
|
+
}
|
|
276343
|
+
if (options.skipPrompt) {
|
|
276344
|
+
p10.log.info(
|
|
276345
|
+
`Add "componentDir": "${legacyComponentDir}" to canvas.config.json to persist this setting.`
|
|
276346
|
+
);
|
|
276347
|
+
return;
|
|
276348
|
+
}
|
|
276349
|
+
const shouldWriteConfig = await p10.confirm({
|
|
276350
|
+
message: hasConfigFile ? `Add "componentDir": "${legacyComponentDir}" to canvas.config.json?` : `Create canvas.config.json with "componentDir": "${legacyComponentDir}"?`,
|
|
276351
|
+
initialValue: true
|
|
276352
|
+
});
|
|
276353
|
+
if (p10.isCancel(shouldWriteConfig) || !shouldWriteConfig) {
|
|
276354
|
+
p10.log.info(
|
|
276355
|
+
`Skipped config update. You can set "componentDir": "${legacyComponentDir}" in canvas.config.json later.`
|
|
276356
|
+
);
|
|
276357
|
+
return;
|
|
276358
|
+
}
|
|
276359
|
+
const nextConfig = hasConfigFile ? { ...parsedConfig ?? {}, componentDir: legacyComponentDir } : { componentDir: legacyComponentDir };
|
|
276360
|
+
fs5__default.writeFileSync(
|
|
276361
|
+
configPath,
|
|
276362
|
+
`${JSON.stringify(nextConfig, null, 2)}
|
|
276363
|
+
`,
|
|
276364
|
+
"utf-8"
|
|
276365
|
+
);
|
|
276366
|
+
p10.log.info("Updated canvas.config.json with componentDir.");
|
|
276367
|
+
}
|
|
276299
276368
|
async function ensureConfig(requiredKeys) {
|
|
276300
276369
|
const config2 = getConfig();
|
|
276301
276370
|
const missingKeys = requiredKeys.filter((key2) => !config2[key2]);
|
|
@@ -276484,7 +276553,7 @@ function vitePluginSvgr({ svgrOptions, esbuildOptions, include = "**/*.svg?react
|
|
|
276484
276553
|
const { transform } = await Promise.resolve().then(() => __toESM(require_dist2(), 1));
|
|
276485
276554
|
const { default: jsx } = await Promise.resolve().then(() => __toESM(require_dist14(), 1));
|
|
276486
276555
|
const filePath = id.replace(postfixRE, "");
|
|
276487
|
-
const svgCode = await
|
|
276556
|
+
const svgCode = await fs5__default.promises.readFile(filePath, "utf8");
|
|
276488
276557
|
const componentCode = await transform(svgCode, svgrOptions, {
|
|
276489
276558
|
filePath,
|
|
276490
276559
|
caller: {
|
|
@@ -288075,10 +288144,10 @@ async function buildTailwindForComponents(selectedComponents, useLocalGlobalCss
|
|
|
288075
288144
|
success: true
|
|
288076
288145
|
};
|
|
288077
288146
|
}
|
|
288078
|
-
async function validateComponent(componentDir2, fix = false,
|
|
288147
|
+
async function validateComponent(componentDir2, fix = false, deprecated) {
|
|
288079
288148
|
const eslint = new ESLint({
|
|
288080
288149
|
overrideConfigFile: true,
|
|
288081
|
-
overrideConfig:
|
|
288150
|
+
overrideConfig: deprecated ? requiredDeprecated : required,
|
|
288082
288151
|
fix
|
|
288083
288152
|
});
|
|
288084
288153
|
const eslintResults = await eslint.lintFiles(componentDir2 + "/**/*");
|
|
@@ -288113,11 +288182,7 @@ async function buildComponent(component, useLocalGlobalCss = true, outputDir2 =
|
|
|
288113
288182
|
details: []
|
|
288114
288183
|
};
|
|
288115
288184
|
const componentAbsoluteDir = path7.dirname(component.metadataPath);
|
|
288116
|
-
const validationResult = await validateComponent(
|
|
288117
|
-
componentAbsoluteDir,
|
|
288118
|
-
false,
|
|
288119
|
-
true
|
|
288120
|
-
);
|
|
288185
|
+
const validationResult = await validateComponent(componentAbsoluteDir);
|
|
288121
288186
|
if (!validationResult.success) {
|
|
288122
288187
|
result.success = false;
|
|
288123
288188
|
result.details = validationResult.details;
|
|
@@ -288638,7 +288703,7 @@ async function buildComponent2(componentDir2, useLocalGlobalCss = true) {
|
|
|
288638
288703
|
success: true,
|
|
288639
288704
|
details: []
|
|
288640
288705
|
};
|
|
288641
|
-
const validationResult = await validateComponent(componentDir2);
|
|
288706
|
+
const validationResult = await validateComponent(componentDir2, false, true);
|
|
288642
288707
|
if (!validationResult.success) {
|
|
288643
288708
|
result.success = false;
|
|
288644
288709
|
result.details = validationResult.details;
|
|
@@ -289978,6 +290043,12 @@ uploadCommand(program);
|
|
|
289978
290043
|
buildDeprecatedCommand(program);
|
|
289979
290044
|
validateCommand(program);
|
|
289980
290045
|
buildCommand(program);
|
|
290046
|
+
program.hook("preAction", async (command) => {
|
|
290047
|
+
const commandOptions = command.opts?.();
|
|
290048
|
+
await handleLegacyComponentDirMigration({
|
|
290049
|
+
skipPrompt: Boolean(commandOptions?.yes)
|
|
290050
|
+
});
|
|
290051
|
+
});
|
|
289981
290052
|
program.showHelpAfterError();
|
|
289982
290053
|
program.showSuggestionAfterError(true);
|
|
289983
290054
|
try {
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drupal-canvas/cli",
|
|
3
3
|
"description": "CLI tool for managing Drupal Canvas code components",
|
|
4
|
-
"version": "0.7.0",
|
|
5
4
|
"license": "GPL-2.0-or-later",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
@@ -39,12 +38,14 @@
|
|
|
39
38
|
"prettier": "^3.2.1",
|
|
40
39
|
"tsup": "^8.5.1",
|
|
41
40
|
"typescript": "^5.8.3",
|
|
42
|
-
"vitest": "^3.2.3"
|
|
41
|
+
"vitest": "^3.2.3",
|
|
42
|
+
"@drupal-canvas/discovery": "*",
|
|
43
|
+
"@drupal-canvas/vite-compat": "*"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@babel/parser": "^7.26.9",
|
|
46
47
|
"@clack/prompts": "^0.11.0",
|
|
47
|
-
"@drupal-canvas/eslint-config": "^0.1.
|
|
48
|
+
"@drupal-canvas/eslint-config": "^0.1.3",
|
|
48
49
|
"@swc/wasm": "^1.12.1",
|
|
49
50
|
"axios": "^1.9.0",
|
|
50
51
|
"chalk": "^5.4.1",
|
|
@@ -55,8 +56,7 @@
|
|
|
55
56
|
"lightningcss": "^1.30.1",
|
|
56
57
|
"table": "^6.9.0",
|
|
57
58
|
"tailwindcss-in-browser": "^0.6.0",
|
|
58
|
-
"vite": "^6.3.5"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
59
|
+
"vite": "^6.3.5"
|
|
60
|
+
},
|
|
61
|
+
"version": "0.7.2"
|
|
62
62
|
}
|