extension-create 4.3.0 → 4.3.1-canary.476.00e7626
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.
|
@@ -34,8 +34,9 @@ export interface RunInstallOptions {
|
|
|
34
34
|
export type SignalGroup = (pid: number, signal: NodeJS.Signals) => void;
|
|
35
35
|
export declare const signalProcessGroup: SignalGroup;
|
|
36
36
|
export declare const KILL_GRACE_MS = 2000;
|
|
37
|
+
export declare const TREE_END_WAIT_MS = 5000;
|
|
37
38
|
export type InstallRunner = (command: string, args: string[], opts: RunInstallOptions) => Promise<InstallResult>;
|
|
38
39
|
export declare function windowsTaskkillPath(env?: Record<string, string | undefined>): string;
|
|
39
|
-
export declare function endProcessTree(child: ChildProcess, spawnProcess: SpawnProcess, platform: NodeJS.Platform, signalGroup?: SignalGroup): void;
|
|
40
|
+
export declare function endProcessTree(child: ChildProcess, spawnProcess: SpawnProcess, platform: NodeJS.Platform, signalGroup?: SignalGroup, onAsked?: () => void): void;
|
|
40
41
|
export declare function forwardEndingSignals(pid: number, signalGroup: SignalGroup): () => void;
|
|
41
42
|
export declare function runInstall(command: string, args: string[], opts: RunInstallOptions): Promise<InstallResult>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface JsonParseFailure {
|
|
2
|
+
line: number;
|
|
3
|
+
column: number;
|
|
4
|
+
atEnd: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function jsonParseFailure(text: string): JsonParseFailure | undefined;
|
|
7
|
+
export declare function describeJsonParseFailure(text: string): string;
|
|
8
|
+
export declare function describeJsonReadFailure(error: unknown, text?: string): string;
|
|
9
|
+
export {};
|
package/dist/lib/messages.d.ts
CHANGED
|
@@ -41,9 +41,9 @@ export declare function installingDependenciesFailed(pmCommand: string, pmArgs:
|
|
|
41
41
|
export declare function installingDependenciesProcessError(projectName: string, error: unknown, retry?: ScaffoldRetry): string;
|
|
42
42
|
export declare function packageManagerNotInstalled(projectName: string, pmCommand: string, pmArgs: string[], retry?: ScaffoldRetry): string;
|
|
43
43
|
export declare function manifestNotFound(projectPath: string, searchDepth: number): string;
|
|
44
|
-
export declare function manifestNotParseable(manifestPath: string,
|
|
45
|
-
export declare function templateFileNotReadable(filePath: string,
|
|
46
|
-
export declare function templatePackageJsonNotParseable(packageJsonPath: string,
|
|
44
|
+
export declare function manifestNotParseable(manifestPath: string, reason: string): string;
|
|
45
|
+
export declare function templateFileNotReadable(filePath: string, reason: string): string;
|
|
46
|
+
export declare function templatePackageJsonNotParseable(packageJsonPath: string, reason: string): string;
|
|
47
47
|
export declare function writingPackageJsonMetadata(): string;
|
|
48
48
|
export declare function writingPackageJsonMetadataError(error: unknown): string;
|
|
49
49
|
export declare function packageManagerAskedAgain(manager: Exclude<ScaffoldPackageManager, 'deno'>, waitedSeconds: number, limitSeconds: number): string;
|
package/dist/module.cjs
CHANGED
|
@@ -475,6 +475,7 @@ const signalProcessGroup = (pid, signal)=>{
|
|
|
475
475
|
process.kill(-pid, signal);
|
|
476
476
|
};
|
|
477
477
|
const KILL_GRACE_MS = 2000;
|
|
478
|
+
const TREE_END_WAIT_MS = 5000;
|
|
478
479
|
function stillRunning(child) {
|
|
479
480
|
return null === child.exitCode && null === child.signalCode;
|
|
480
481
|
}
|
|
@@ -482,8 +483,16 @@ function windowsTaskkillPath(env = process.env) {
|
|
|
482
483
|
const root = env.SystemRoot || env.windir || 'C:\\Windows';
|
|
483
484
|
return external_node_path_namespaceObject.win32.join(root, 'System32', 'taskkill.exe');
|
|
484
485
|
}
|
|
485
|
-
function endProcessTree(child, spawnProcess, platform, signalGroup) {
|
|
486
|
+
function endProcessTree(child, spawnProcess, platform, signalGroup, onAsked) {
|
|
486
487
|
if ('win32' === platform && void 0 !== child.pid) {
|
|
488
|
+
let told = false;
|
|
489
|
+
const tell = ()=>{
|
|
490
|
+
if (told) return;
|
|
491
|
+
told = true;
|
|
492
|
+
clearTimeout(bound);
|
|
493
|
+
onAsked?.();
|
|
494
|
+
};
|
|
495
|
+
const bound = onAsked ? setTimeout(tell, TREE_END_WAIT_MS) : void 0;
|
|
487
496
|
const killShim = ()=>{
|
|
488
497
|
try {
|
|
489
498
|
child.kill('SIGKILL');
|
|
@@ -497,11 +506,16 @@ function endProcessTree(child, spawnProcess, platform, signalGroup) {
|
|
|
497
506
|
'/F'
|
|
498
507
|
], {
|
|
499
508
|
stdio: 'ignore'
|
|
500
|
-
}).on('error',
|
|
509
|
+
}).on('error', ()=>{
|
|
510
|
+
killShim();
|
|
511
|
+
tell();
|
|
512
|
+
}).on('close', (code)=>{
|
|
501
513
|
if (0 !== code) killShim();
|
|
514
|
+
tell();
|
|
502
515
|
});
|
|
503
516
|
} catch {
|
|
504
517
|
killShim();
|
|
518
|
+
tell();
|
|
505
519
|
}
|
|
506
520
|
return;
|
|
507
521
|
}
|
|
@@ -516,6 +530,7 @@ function endProcessTree(child, spawnProcess, platform, signalGroup) {
|
|
|
516
530
|
if (signalGroup || stillRunning(child)) send('SIGKILL');
|
|
517
531
|
}, KILL_GRACE_MS);
|
|
518
532
|
escalate.unref?.();
|
|
533
|
+
onAsked?.();
|
|
519
534
|
}
|
|
520
535
|
function forwardEndingSignals(pid, signalGroup) {
|
|
521
536
|
const forwarded = [
|
|
@@ -583,20 +598,24 @@ async function install_runner_runInstall(command, args, opts) {
|
|
|
583
598
|
if (tee) process.stderr.write(chunk);
|
|
584
599
|
});
|
|
585
600
|
return new Promise((resolve, reject)=>{
|
|
601
|
+
let timedOut = false;
|
|
586
602
|
const timer = setTimeout(()=>{
|
|
603
|
+
timedOut = true;
|
|
587
604
|
release();
|
|
588
|
-
endProcessTree(child, spawnProcess, platform, signalGroup)
|
|
605
|
+
endProcessTree(child, spawnProcess, platform, signalGroup, ()=>{
|
|
606
|
+
resolve({
|
|
607
|
+
code: null,
|
|
608
|
+
stderr,
|
|
609
|
+
stdout,
|
|
610
|
+
reason: installTimedOutReason(timeoutMs)
|
|
611
|
+
});
|
|
612
|
+
});
|
|
589
613
|
child.stdout?.destroy();
|
|
590
614
|
child.stderr?.destroy();
|
|
591
615
|
child.unref();
|
|
592
|
-
resolve({
|
|
593
|
-
code: null,
|
|
594
|
-
stderr,
|
|
595
|
-
stdout,
|
|
596
|
-
reason: installTimedOutReason(timeoutMs)
|
|
597
|
-
});
|
|
598
616
|
}, timeoutMs);
|
|
599
617
|
child.on('close', (code, signal)=>{
|
|
618
|
+
if (timedOut) return;
|
|
600
619
|
clearTimeout(timer);
|
|
601
620
|
release();
|
|
602
621
|
resolve({
|
|
@@ -609,6 +628,7 @@ async function install_runner_runInstall(command, args, opts) {
|
|
|
609
628
|
});
|
|
610
629
|
});
|
|
611
630
|
child.on('error', (error)=>{
|
|
631
|
+
if (timedOut) return;
|
|
612
632
|
clearTimeout(timer);
|
|
613
633
|
release();
|
|
614
634
|
reject(error);
|
|
@@ -1182,14 +1202,14 @@ function packageManagerNotInstalled(projectName, pmCommand, pmArgs, retry) {
|
|
|
1182
1202
|
function manifestNotFound(projectPath, searchDepth) {
|
|
1183
1203
|
return `${prefix('error')} Couldn't read a manifest.json for this scaffold.\n${fmt.label('PATH')} ${fmt.val(projectPath)}\n${fmt.label('SEARCHED')} ${fmt.val(`the common locations, then every directory up to depth ${searchDepth}`)}\n${external_pintor_default().red('Add a manifest.json, or scaffold from a template that ships one.')}`;
|
|
1184
1204
|
}
|
|
1185
|
-
function manifestNotParseable(manifestPath,
|
|
1186
|
-
return `${prefix('error')} Couldn't read a manifest.json for this scaffold.\n${fmt.label('PATH')} ${fmt.val(manifestPath)}\n${fmt.label('REASON')} ${fmt.val(
|
|
1205
|
+
function manifestNotParseable(manifestPath, reason) {
|
|
1206
|
+
return `${prefix('error')} Couldn't read a manifest.json for this scaffold.\n${fmt.label('PATH')} ${fmt.val(manifestPath)}\n${fmt.label('REASON')} ${fmt.val(reason)}\n${external_pintor_default().red('Fix that file, then create again.')}`;
|
|
1187
1207
|
}
|
|
1188
|
-
function templateFileNotReadable(filePath,
|
|
1189
|
-
return `${prefix('error')} Couldn't read the template's ${external_pintor_default().blue(external_node_path_namespaceObject.basename(filePath))}.\n${fmt.label('PATH')} ${fmt.val(filePath)}\n${fmt.label('REASON')} ${fmt.val(
|
|
1208
|
+
function templateFileNotReadable(filePath, reason) {
|
|
1209
|
+
return `${prefix('error')} Couldn't read the template's ${external_pintor_default().blue(external_node_path_namespaceObject.basename(filePath))}.\n${fmt.label('PATH')} ${fmt.val(filePath)}\n${fmt.label('REASON')} ${fmt.val(reason)}\n${external_pintor_default().red('Fix that file in the template, then create again.')}`;
|
|
1190
1210
|
}
|
|
1191
|
-
function templatePackageJsonNotParseable(packageJsonPath,
|
|
1192
|
-
return `${prefix('error')} Couldn't read the template's ${external_pintor_default().blue('package.json')}.\n${fmt.label('PATH')} ${fmt.val(packageJsonPath)}\n${fmt.label('REASON')} ${fmt.val(
|
|
1211
|
+
function templatePackageJsonNotParseable(packageJsonPath, reason) {
|
|
1212
|
+
return `${prefix('error')} Couldn't read the template's ${external_pintor_default().blue('package.json')}.\n${fmt.label('PATH')} ${fmt.val(packageJsonPath)}\n${fmt.label('REASON')} ${fmt.val(reason)}\n${external_pintor_default().red('Fix that file in the template, then create again.')}`;
|
|
1193
1213
|
}
|
|
1194
1214
|
function writingPackageJsonMetadata() {
|
|
1195
1215
|
return `${prefix('debug')} create write file=package.json`;
|
|
@@ -1666,7 +1686,7 @@ function networkTimeoutMs() {
|
|
|
1666
1686
|
return Number.isFinite(raw) && raw > 0 ? raw : 60000;
|
|
1667
1687
|
}
|
|
1668
1688
|
const CODELOAD_BASE = 'https://codeload.github.com/extension-js/templates/zip';
|
|
1669
|
-
const DEFAULT_TEMPLATES_REF = '
|
|
1689
|
+
const DEFAULT_TEMPLATES_REF = 'fcfc7eb4e92d1dadfa5ec59f0ce455ae035aca7c';
|
|
1670
1690
|
const BUNDLED_TEMPLATES = [
|
|
1671
1691
|
"javascript"
|
|
1672
1692
|
];
|
|
@@ -2102,7 +2122,9 @@ async function getZipSourcePath(tempPath, templateUrl) {
|
|
|
2102
2122
|
}
|
|
2103
2123
|
const removeRecursively = (target)=>promises_namespaceObject.rm(target, {
|
|
2104
2124
|
recursive: true,
|
|
2105
|
-
force: true
|
|
2125
|
+
force: true,
|
|
2126
|
+
maxRetries: 5,
|
|
2127
|
+
retryDelay: 100
|
|
2106
2128
|
});
|
|
2107
2129
|
async function cleanupFailedImport(projectPath, ownsProjectDir, preExistingEntries, remove = removeRecursively) {
|
|
2108
2130
|
const leftBehind = [];
|
|
@@ -2476,6 +2498,136 @@ async function initializeGitRepository(projectPath, projectName, templateName, l
|
|
|
2476
2498
|
]);
|
|
2477
2499
|
if (!committed.ok) logger.log(firstCommitSkipped(projectName, committed.reason || ''));
|
|
2478
2500
|
}
|
|
2501
|
+
const WHITESPACE = ' \t\n\r';
|
|
2502
|
+
const ESCAPES = '"\\/bfnrt';
|
|
2503
|
+
const HEX = /^[0-9a-fA-F]$/;
|
|
2504
|
+
const DIGIT = /^[0-9]$/;
|
|
2505
|
+
function jsonParseFailure(text) {
|
|
2506
|
+
const n = text.length;
|
|
2507
|
+
const stack = [];
|
|
2508
|
+
let i = 0;
|
|
2509
|
+
const at = (offset)=>{
|
|
2510
|
+
const before = text.slice(0, offset).split('\n');
|
|
2511
|
+
return {
|
|
2512
|
+
line: before.length,
|
|
2513
|
+
column: before[before.length - 1].length + 1,
|
|
2514
|
+
atEnd: offset >= n
|
|
2515
|
+
};
|
|
2516
|
+
};
|
|
2517
|
+
const skipWhitespace = ()=>{
|
|
2518
|
+
while(i < n && WHITESPACE.includes(text[i]))i++;
|
|
2519
|
+
};
|
|
2520
|
+
const digits = ()=>{
|
|
2521
|
+
const start = i;
|
|
2522
|
+
while(i < n && DIGIT.test(text[i]))i++;
|
|
2523
|
+
return i > start;
|
|
2524
|
+
};
|
|
2525
|
+
const readString = ()=>{
|
|
2526
|
+
i++;
|
|
2527
|
+
while(i < n){
|
|
2528
|
+
const char = text[i];
|
|
2529
|
+
if ('"' === char) {
|
|
2530
|
+
i++;
|
|
2531
|
+
return true;
|
|
2532
|
+
}
|
|
2533
|
+
if (char.charCodeAt(0) < 0x20) break;
|
|
2534
|
+
if ('\\' !== char) {
|
|
2535
|
+
i++;
|
|
2536
|
+
continue;
|
|
2537
|
+
}
|
|
2538
|
+
i++;
|
|
2539
|
+
if (i >= n) break;
|
|
2540
|
+
if (ESCAPES.includes(text[i])) {
|
|
2541
|
+
i++;
|
|
2542
|
+
continue;
|
|
2543
|
+
}
|
|
2544
|
+
if ('u' !== text[i]) break;
|
|
2545
|
+
i++;
|
|
2546
|
+
for(let k = 0; k < 4; k++, i++)if (i >= n || !HEX.test(text[i])) return false;
|
|
2547
|
+
}
|
|
2548
|
+
return false;
|
|
2549
|
+
};
|
|
2550
|
+
const readNumber = ()=>{
|
|
2551
|
+
if ('-' === text[i]) i++;
|
|
2552
|
+
if ('0' === text[i]) i++;
|
|
2553
|
+
else if (!digits()) return false;
|
|
2554
|
+
if ('.' === text[i]) {
|
|
2555
|
+
i++;
|
|
2556
|
+
if (!digits()) return false;
|
|
2557
|
+
}
|
|
2558
|
+
if ('e' === text[i] || 'E' === text[i]) {
|
|
2559
|
+
i++;
|
|
2560
|
+
if ('+' === text[i] || '-' === text[i]) i++;
|
|
2561
|
+
if (!digits()) return false;
|
|
2562
|
+
}
|
|
2563
|
+
return true;
|
|
2564
|
+
};
|
|
2565
|
+
const readWord = (word)=>{
|
|
2566
|
+
for (const char of word){
|
|
2567
|
+
if (text[i] !== char) return false;
|
|
2568
|
+
i++;
|
|
2569
|
+
}
|
|
2570
|
+
return true;
|
|
2571
|
+
};
|
|
2572
|
+
const readKey = ()=>{
|
|
2573
|
+
skipWhitespace();
|
|
2574
|
+
if ('"' !== text[i] || !readString()) return false;
|
|
2575
|
+
skipWhitespace();
|
|
2576
|
+
if (':' !== text[i]) return false;
|
|
2577
|
+
i++;
|
|
2578
|
+
return true;
|
|
2579
|
+
};
|
|
2580
|
+
for(;;){
|
|
2581
|
+
skipWhitespace();
|
|
2582
|
+
const char = text[i];
|
|
2583
|
+
let complete = true;
|
|
2584
|
+
if ('{' === char || '[' === char) {
|
|
2585
|
+
i++;
|
|
2586
|
+
skipWhitespace();
|
|
2587
|
+
if (text[i] === ('{' === char ? '}' : ']')) i++;
|
|
2588
|
+
else {
|
|
2589
|
+
stack.push(char);
|
|
2590
|
+
if ('{' === char && !readKey()) return at(i);
|
|
2591
|
+
complete = false;
|
|
2592
|
+
}
|
|
2593
|
+
} else if ('"' === char) {
|
|
2594
|
+
if (!readString()) return at(i);
|
|
2595
|
+
} else if ('-' === char || void 0 !== char && DIGIT.test(char)) {
|
|
2596
|
+
if (!readNumber()) return at(i);
|
|
2597
|
+
} else {
|
|
2598
|
+
if ('t' !== char && 'f' !== char && 'n' !== char) return at(i);
|
|
2599
|
+
const word = 't' === char ? 'true' : 'f' === char ? 'false' : 'null';
|
|
2600
|
+
if (!readWord(word)) return at(i);
|
|
2601
|
+
}
|
|
2602
|
+
if (complete) for(;;){
|
|
2603
|
+
skipWhitespace();
|
|
2604
|
+
if (0 === stack.length) return i < n ? at(i) : void 0;
|
|
2605
|
+
const open = stack[stack.length - 1];
|
|
2606
|
+
if (',' === text[i]) {
|
|
2607
|
+
i++;
|
|
2608
|
+
if ('{' === open && !readKey()) return at(i);
|
|
2609
|
+
break;
|
|
2610
|
+
}
|
|
2611
|
+
if (text[i] !== ('{' === open ? '}' : ']')) return at(i);
|
|
2612
|
+
i++;
|
|
2613
|
+
stack.pop();
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
function describeJsonParseFailure(text) {
|
|
2618
|
+
const failure = jsonParseFailure(text);
|
|
2619
|
+
if (!failure) return 'not valid JSON';
|
|
2620
|
+
const where = `line ${failure.line} column ${failure.column}`;
|
|
2621
|
+
return failure.atEnd ? `unexpected end of the file at ${where}` : `unexpected character at ${where}`;
|
|
2622
|
+
}
|
|
2623
|
+
function describeJsonReadFailure(error, text) {
|
|
2624
|
+
const code = error?.code;
|
|
2625
|
+
if ('string' == typeof code && /^E[A-Z0-9_]+$/.test(code)) return code;
|
|
2626
|
+
return void 0 === text ? 'not valid JSON' : describeJsonParseFailure(text);
|
|
2627
|
+
}
|
|
2628
|
+
function blank(text) {
|
|
2629
|
+
return text.replace(/[^\r\n]/g, ' ');
|
|
2630
|
+
}
|
|
2479
2631
|
function stripJsoncExtensions(text) {
|
|
2480
2632
|
let out = '';
|
|
2481
2633
|
let i = 0;
|
|
@@ -2500,13 +2652,17 @@ function stripJsoncExtensions(text) {
|
|
|
2500
2652
|
continue;
|
|
2501
2653
|
}
|
|
2502
2654
|
if ('/' === char && '/' === text[i + 1]) {
|
|
2655
|
+
const start = i;
|
|
2503
2656
|
while(i < text.length && '\n' !== text[i])i++;
|
|
2657
|
+
out += blank(text.slice(start, i));
|
|
2504
2658
|
continue;
|
|
2505
2659
|
}
|
|
2506
2660
|
if ('/' === char && '*' === text[i + 1]) {
|
|
2661
|
+
const start = i;
|
|
2507
2662
|
i += 2;
|
|
2508
2663
|
while(i < text.length && !('*' === text[i] && '/' === text[i + 1]))i++;
|
|
2509
2664
|
i += 2;
|
|
2665
|
+
out += blank(text.slice(start, i));
|
|
2510
2666
|
continue;
|
|
2511
2667
|
}
|
|
2512
2668
|
if (',' === char) {
|
|
@@ -2520,19 +2676,23 @@ function stripJsoncExtensions(text) {
|
|
|
2520
2676
|
continue;
|
|
2521
2677
|
}
|
|
2522
2678
|
if ('/' === c && '/' === text[j + 1]) {
|
|
2679
|
+
const start = j;
|
|
2523
2680
|
while(j < text.length && '\n' !== text[j])j++;
|
|
2681
|
+
buffered += blank(text.slice(start, j));
|
|
2524
2682
|
continue;
|
|
2525
2683
|
}
|
|
2526
2684
|
if ('/' === c && '*' === text[j + 1]) {
|
|
2685
|
+
const start = j;
|
|
2527
2686
|
j += 2;
|
|
2528
2687
|
while(j < text.length && !('*' === text[j] && '/' === text[j + 1]))j++;
|
|
2529
2688
|
j += 2;
|
|
2689
|
+
buffered += blank(text.slice(start, j));
|
|
2530
2690
|
continue;
|
|
2531
2691
|
}
|
|
2532
2692
|
break;
|
|
2533
2693
|
}
|
|
2534
2694
|
const nextChar = text[j] ?? '';
|
|
2535
|
-
out += '}' === nextChar || ']' === nextChar ? buffered.slice(1) : buffered;
|
|
2695
|
+
out += '}' === nextChar || ']' === nextChar ? ` ${buffered.slice(1)}` : buffered;
|
|
2536
2696
|
i = j;
|
|
2537
2697
|
continue;
|
|
2538
2698
|
}
|
|
@@ -2544,7 +2704,12 @@ function stripJsoncExtensions(text) {
|
|
|
2544
2704
|
function parseJsoncSafe(text) {
|
|
2545
2705
|
const withoutBom = 0xfeff === text.charCodeAt(0) ? text.slice(1) : text;
|
|
2546
2706
|
const stripped = stripJsoncExtensions(withoutBom);
|
|
2547
|
-
|
|
2707
|
+
const json = stripped.trim() ? stripped : '{}';
|
|
2708
|
+
try {
|
|
2709
|
+
return JSON.parse(json);
|
|
2710
|
+
} catch {
|
|
2711
|
+
throw new SyntaxError(describeJsonParseFailure(json));
|
|
2712
|
+
}
|
|
2548
2713
|
}
|
|
2549
2714
|
function parseNpmSpecifier(specifier) {
|
|
2550
2715
|
if ('string' != typeof specifier || !specifier.startsWith('npm:')) return;
|
|
@@ -2635,26 +2800,38 @@ async function findManifestJsonPath(projectPath) {
|
|
|
2635
2800
|
}
|
|
2636
2801
|
async function readManifestJson(projectPath) {
|
|
2637
2802
|
const manifestJsonPath = await findManifestJsonPath(projectPath);
|
|
2803
|
+
let raw;
|
|
2638
2804
|
try {
|
|
2639
|
-
|
|
2805
|
+
raw = await external_node_fs_namespaceObject.promises.readFile(manifestJsonPath, 'utf-8');
|
|
2640
2806
|
return {
|
|
2641
2807
|
manifestJsonPath,
|
|
2642
2808
|
manifestJson: JSON.parse(raw)
|
|
2643
2809
|
};
|
|
2644
2810
|
} catch (error) {
|
|
2645
|
-
|
|
2811
|
+
const reason = describeJsonReadFailure(error, raw);
|
|
2812
|
+
throw failStep(manifestNotParseable(manifestJsonPath, reason), contentFreeCause(error, raw, reason), CODES.E_TEMPLATE_NOT_FOUND);
|
|
2646
2813
|
}
|
|
2647
2814
|
}
|
|
2815
|
+
function contentFreeCause(error, text, reason) {
|
|
2816
|
+
return void 0 === text ? error : new SyntaxError(reason);
|
|
2817
|
+
}
|
|
2648
2818
|
function readTemplatePackageJson(projectPath) {
|
|
2649
2819
|
const packageJsonPath = external_node_path_namespaceObject.join(projectPath, 'package.json');
|
|
2820
|
+
let raw;
|
|
2821
|
+
let parsed;
|
|
2650
2822
|
try {
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
return parsed;
|
|
2823
|
+
raw = external_node_fs_namespaceObject.readFileSync(packageJsonPath, 'utf8');
|
|
2824
|
+
parsed = JSON.parse(raw);
|
|
2654
2825
|
} catch (error) {
|
|
2655
2826
|
if (error?.code === 'ENOENT') return;
|
|
2656
|
-
|
|
2827
|
+
const reason = describeJsonReadFailure(error, raw);
|
|
2828
|
+
throw failStep(templatePackageJsonNotParseable(packageJsonPath, reason), contentFreeCause(error, raw, reason), CODES.E_TEMPLATE_NOT_FOUND);
|
|
2829
|
+
}
|
|
2830
|
+
if (!parsed || 'object' != typeof parsed || Array.isArray(parsed)) {
|
|
2831
|
+
const reason = 'it does not hold a JSON object';
|
|
2832
|
+
throw failStep(templatePackageJsonNotParseable(packageJsonPath, reason), new TypeError(reason), CODES.E_TEMPLATE_NOT_FOUND);
|
|
2657
2833
|
}
|
|
2834
|
+
return parsed;
|
|
2658
2835
|
}
|
|
2659
2836
|
function failureOutput(run) {
|
|
2660
2837
|
return [
|
|
@@ -3219,13 +3396,24 @@ async function collectTemplateImports(projectPath, cliVersion) {
|
|
|
3219
3396
|
return imports;
|
|
3220
3397
|
}
|
|
3221
3398
|
async function readTemplateDenoConfig(configPath) {
|
|
3399
|
+
const refuse = (reason, cause)=>new CreateError(templateFileNotReadable(configPath, reason), CODES.E_TEMPLATE_NOT_FOUND, cause);
|
|
3400
|
+
let text;
|
|
3401
|
+
let parsed;
|
|
3222
3402
|
try {
|
|
3223
|
-
|
|
3224
|
-
if (!parsed || 'object' != typeof parsed || Array.isArray(parsed)) throw new TypeError('The file does not hold a JSON object');
|
|
3225
|
-
return parsed;
|
|
3403
|
+
text = await promises_namespaceObject.readFile(configPath, 'utf8');
|
|
3226
3404
|
} catch (error) {
|
|
3227
|
-
throw
|
|
3405
|
+
throw refuse(describeJsonReadFailure(error), error);
|
|
3406
|
+
}
|
|
3407
|
+
try {
|
|
3408
|
+
parsed = parseJsoncSafe(text);
|
|
3409
|
+
} catch (error) {
|
|
3410
|
+
throw refuse(error.message, error);
|
|
3411
|
+
}
|
|
3412
|
+
if (!parsed || 'object' != typeof parsed || Array.isArray(parsed)) {
|
|
3413
|
+
const reason = 'it does not hold a JSON object';
|
|
3414
|
+
throw refuse(reason, new TypeError(reason));
|
|
3228
3415
|
}
|
|
3416
|
+
return parsed;
|
|
3229
3417
|
}
|
|
3230
3418
|
async function writeDenoJsonc(projectPath, { template = "javascript", cliVersion, primary = false }, logger) {
|
|
3231
3419
|
if (!isDenoRuntime()) return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AxiosRequestConfig, type AxiosResponse } from 'axios';
|
|
2
|
-
export declare const DEFAULT_TEMPLATES_REF = "
|
|
2
|
+
export declare const DEFAULT_TEMPLATES_REF = "fcfc7eb4e92d1dadfa5ec59f0ce455ae035aca7c";
|
|
3
3
|
export declare const BUNDLED_TEMPLATES: readonly string[];
|
|
4
4
|
export declare const DEFAULT_TEMPLATE_NAME = "typescript";
|
|
5
5
|
export declare const OFFLINE_FALLBACK_TEMPLATE = "javascript";
|
package/package.json
CHANGED