extension-create 3.3.3-next.8 → 3.4.0-next.1
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/dist/{module.js → module.cjs} +109 -15
- package/package.json +12 -8
|
@@ -463,6 +463,102 @@ function getInstallArgs() {
|
|
|
463
463
|
'--silent'
|
|
464
464
|
];
|
|
465
465
|
}
|
|
466
|
+
function resolveWindowsCmdExe() {
|
|
467
|
+
const comspec = process.env.ComSpec;
|
|
468
|
+
if (comspec) return comspec;
|
|
469
|
+
const systemRoot = process.env.SystemRoot || 'C:\\Windows';
|
|
470
|
+
return external_path_namespaceObject.join(systemRoot, 'System32', 'cmd.exe');
|
|
471
|
+
}
|
|
472
|
+
function formatCmdArgs(command, args) {
|
|
473
|
+
const quotedCommand = command.includes(' ') ? `"${command}"` : command;
|
|
474
|
+
const quotedArgs = args.map((arg)=>arg.includes(' ') ? `"${arg}"` : arg);
|
|
475
|
+
return `${quotedCommand} ${quotedArgs.join(' ')}`.trim();
|
|
476
|
+
}
|
|
477
|
+
function resolveInstallInvocation(command, args) {
|
|
478
|
+
if ('win32' !== process.platform) return {
|
|
479
|
+
command,
|
|
480
|
+
args
|
|
481
|
+
};
|
|
482
|
+
return {
|
|
483
|
+
command: resolveWindowsCmdExe(),
|
|
484
|
+
args: [
|
|
485
|
+
'/d',
|
|
486
|
+
'/s',
|
|
487
|
+
'/c',
|
|
488
|
+
formatCmdArgs(command, args)
|
|
489
|
+
]
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function buildExecEnv() {
|
|
493
|
+
if ('win32' !== process.platform) return;
|
|
494
|
+
const nodeDir = external_path_namespaceObject.dirname(process.execPath);
|
|
495
|
+
const pathSep = external_path_namespaceObject.delimiter;
|
|
496
|
+
const existing = process.env.PATH || process.env.Path || '';
|
|
497
|
+
if (existing.includes(nodeDir)) return;
|
|
498
|
+
return {
|
|
499
|
+
...process.env,
|
|
500
|
+
PATH: `${nodeDir}${pathSep}${existing}`.trim(),
|
|
501
|
+
Path: `${nodeDir}${pathSep}${existing}`.trim()
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
function getTagFallback(version) {
|
|
505
|
+
if ('*' === version || 'latest' === version || 'next' === version) return null;
|
|
506
|
+
const cleaned = version.replace(/^[~^]/, '');
|
|
507
|
+
return cleaned.includes('-') ? 'next' : 'latest';
|
|
508
|
+
}
|
|
509
|
+
async function updateExtensionDependencyTag(projectPath, projectName) {
|
|
510
|
+
const packageJsonPath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
511
|
+
try {
|
|
512
|
+
const raw = await external_fs_namespaceObject.promises.readFile(packageJsonPath, 'utf8');
|
|
513
|
+
const packageJson = JSON.parse(raw);
|
|
514
|
+
const currentVersion = packageJson?.devDependencies?.extension;
|
|
515
|
+
if ('string' != typeof currentVersion) return false;
|
|
516
|
+
const tag = getTagFallback(currentVersion);
|
|
517
|
+
if (!tag || currentVersion === tag) return false;
|
|
518
|
+
packageJson.devDependencies = {
|
|
519
|
+
...packageJson.devDependencies || {},
|
|
520
|
+
extension: tag
|
|
521
|
+
};
|
|
522
|
+
await external_fs_namespaceObject.promises.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
523
|
+
return true;
|
|
524
|
+
} catch (error) {
|
|
525
|
+
console.error(cantInstallDependencies(projectName, error));
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function shouldRetryWithTagFallback(output) {
|
|
530
|
+
const text = output.toLowerCase();
|
|
531
|
+
return text.includes('no matching version found for extension@') || text.includes('notarget') || text.includes('etarget');
|
|
532
|
+
}
|
|
533
|
+
async function runInstall(command, args, cwd, stdio) {
|
|
534
|
+
const invocation = resolveInstallInvocation(command, args);
|
|
535
|
+
const env = buildExecEnv();
|
|
536
|
+
const child = (0, external_cross_spawn_namespaceObject.spawn)(invocation.command, invocation.args, {
|
|
537
|
+
stdio,
|
|
538
|
+
cwd,
|
|
539
|
+
env: env || process.env
|
|
540
|
+
});
|
|
541
|
+
let stdout = '';
|
|
542
|
+
let stderr = '';
|
|
543
|
+
if (child.stdout) child.stdout.on('data', (chunk)=>{
|
|
544
|
+
stdout += chunk.toString();
|
|
545
|
+
});
|
|
546
|
+
if (child.stderr) child.stderr.on('data', (chunk)=>{
|
|
547
|
+
stderr += chunk.toString();
|
|
548
|
+
});
|
|
549
|
+
return new Promise((resolve, reject)=>{
|
|
550
|
+
child.on('close', (code)=>{
|
|
551
|
+
resolve({
|
|
552
|
+
code,
|
|
553
|
+
stderr,
|
|
554
|
+
stdout
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
child.on('error', (error)=>{
|
|
558
|
+
reject(error);
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
}
|
|
466
562
|
async function installDependencies(projectPath, projectName) {
|
|
467
563
|
const nodeModulesPath = external_path_namespaceObject.join(projectPath, 'node_modules');
|
|
468
564
|
const command = await getInstallCommand();
|
|
@@ -472,22 +568,20 @@ async function installDependencies(projectPath, projectName) {
|
|
|
472
568
|
await external_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
|
|
473
569
|
recursive: true
|
|
474
570
|
});
|
|
475
|
-
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : '
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
reject(error);
|
|
488
|
-
});
|
|
489
|
-
});
|
|
571
|
+
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'pipe';
|
|
572
|
+
const firstRun = await runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
573
|
+
if (0 !== firstRun.code) {
|
|
574
|
+
const output = `${firstRun.stdout}\n${firstRun.stderr}`;
|
|
575
|
+
const shouldRetry = shouldRetryWithTagFallback(output);
|
|
576
|
+
const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName) : false;
|
|
577
|
+
if (didUpdate) {
|
|
578
|
+
const retryRun = await runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
579
|
+
if (0 === retryRun.code) return;
|
|
580
|
+
}
|
|
581
|
+
throw new Error(installingDependenciesFailed(command, dependenciesArgs, firstRun.code));
|
|
582
|
+
}
|
|
490
583
|
} catch (error) {
|
|
584
|
+
console.error(installingDependenciesProcessError(projectName, error));
|
|
491
585
|
console.error(cantInstallDependencies(projectName, error));
|
|
492
586
|
throw error;
|
|
493
587
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"type": "module",
|
|
2
3
|
"license": "MIT",
|
|
3
|
-
"packageManager": "pnpm@10.28.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
|
-
"url": "https://github.com/extension-js/extension.js.git"
|
|
6
|
+
"url": "git+https://github.com/extension-js/extension.js.git",
|
|
7
|
+
"directory": "programs/create"
|
|
7
8
|
},
|
|
8
9
|
"engines": {
|
|
9
10
|
"node": ">=18"
|
|
@@ -12,27 +13,30 @@
|
|
|
12
13
|
".": {
|
|
13
14
|
"development": "./module.ts",
|
|
14
15
|
"types": "./dist/module.d.ts",
|
|
15
|
-
"import": "./dist/module.
|
|
16
|
-
"require": "./dist/module.
|
|
16
|
+
"import": "./dist/module.cjs",
|
|
17
|
+
"require": "./dist/module.cjs"
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
|
-
"main": "./dist/module.
|
|
20
|
+
"main": "./dist/module.cjs",
|
|
20
21
|
"types": "./dist/module.d.ts",
|
|
21
22
|
"files": [
|
|
22
23
|
"dist"
|
|
23
24
|
],
|
|
24
25
|
"name": "extension-create",
|
|
25
|
-
"version": "3.
|
|
26
|
+
"version": "3.4.0-next.1",
|
|
26
27
|
"description": "The standalone extension creation engine for Extension.js",
|
|
27
28
|
"author": {
|
|
28
29
|
"name": "Cezar Augusto",
|
|
29
30
|
"email": "boss@cezaraugusto.net",
|
|
30
31
|
"url": "https://cezaraugusto.com"
|
|
31
32
|
},
|
|
33
|
+
"homepage": "https://github.com/extension-js/extension.js/tree/main/programs/create#readme",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/extension-js/extension.js/issues"
|
|
36
|
+
},
|
|
32
37
|
"publishConfig": {
|
|
33
38
|
"access": "public",
|
|
34
|
-
"registry": "https://registry.npmjs.org"
|
|
35
|
-
"tag": "latest"
|
|
39
|
+
"registry": "https://registry.npmjs.org"
|
|
36
40
|
},
|
|
37
41
|
"scripts": {
|
|
38
42
|
"clean": "rm -rf dist",
|