extension-create 4.0.30 → 4.0.33
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.cjs
CHANGED
|
@@ -439,10 +439,9 @@ async function generateExtensionTypes(projectPath, projectName, logger) {
|
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
const external_node_os_namespaceObject = require("node:os");
|
|
442
|
-
const external_adm_zip_namespaceObject = require("adm-zip");
|
|
443
|
-
var external_adm_zip_default = /*#__PURE__*/ __webpack_require__.n(external_adm_zip_namespaceObject);
|
|
444
442
|
const external_axios_namespaceObject = require("axios");
|
|
445
443
|
var external_axios_default = /*#__PURE__*/ __webpack_require__.n(external_axios_namespaceObject);
|
|
444
|
+
const external_fflate_namespaceObject = require("fflate");
|
|
446
445
|
const external_go_git_it_namespaceObject = require("go-git-it");
|
|
447
446
|
var external_go_git_it_default = /*#__PURE__*/ __webpack_require__.n(external_go_git_it_namespaceObject);
|
|
448
447
|
function _define_property(obj, key, value) {
|
|
@@ -455,12 +454,38 @@ function _define_property(obj, key, value) {
|
|
|
455
454
|
else obj[key] = value;
|
|
456
455
|
return obj;
|
|
457
456
|
}
|
|
457
|
+
async function extractZipBufferTo(zipBuffer, destinationDir) {
|
|
458
|
+
const root = external_node_path_namespaceObject.resolve(destinationDir);
|
|
459
|
+
const entries = (0, external_fflate_namespaceObject.unzipSync)(new Uint8Array(zipBuffer));
|
|
460
|
+
await promises_namespaceObject.mkdir(root, {
|
|
461
|
+
recursive: true
|
|
462
|
+
});
|
|
463
|
+
for (const [name, data] of Object.entries(entries)){
|
|
464
|
+
const normalized = name.replace(/\\/g, '/');
|
|
465
|
+
const target = external_node_path_namespaceObject.resolve(root, normalized);
|
|
466
|
+
const relative = external_node_path_namespaceObject.relative(root, target);
|
|
467
|
+
if (!relative || relative.startsWith('..') || external_node_path_namespaceObject.isAbsolute(relative)) throw new Error(`Refusing to extract zip entry outside the destination: ${name}`);
|
|
468
|
+
if (normalized.endsWith('/')) {
|
|
469
|
+
await promises_namespaceObject.mkdir(target, {
|
|
470
|
+
recursive: true
|
|
471
|
+
});
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
await promises_namespaceObject.mkdir(external_node_path_namespaceObject.dirname(target), {
|
|
475
|
+
recursive: true
|
|
476
|
+
});
|
|
477
|
+
await promises_namespaceObject.writeFile(target, data);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
458
480
|
const NETWORK_TIMEOUT_MS = (()=>{
|
|
459
481
|
const raw = parseInt(String(process.env.EXTENSION_CREATE_TIMEOUT_MS || ''), 10);
|
|
460
482
|
return Number.isFinite(raw) && raw > 0 ? raw : 60000;
|
|
461
483
|
})();
|
|
462
484
|
const CODELOAD_BASE = 'https://codeload.github.com/extension-js/examples/zip';
|
|
463
|
-
const DEFAULT_TEMPLATES_REF = '
|
|
485
|
+
const DEFAULT_TEMPLATES_REF = 'f7f4e6efb56a7e5ae08d58dbff3972d94af7d021';
|
|
486
|
+
const BUNDLED_TEMPLATES = [
|
|
487
|
+
"javascript"
|
|
488
|
+
];
|
|
464
489
|
function resolveCatalogUrls(ref, overrideUrl) {
|
|
465
490
|
if (overrideUrl) return [
|
|
466
491
|
overrideUrl
|
|
@@ -516,22 +541,24 @@ async function downloadArchive(url, timeoutMs, attempts = 2) {
|
|
|
516
541
|
throw lastError;
|
|
517
542
|
}
|
|
518
543
|
async function extractExamplesTemplateFromZip(zipBuffer, templateName, projectPath) {
|
|
519
|
-
const
|
|
520
|
-
const entries = zip.getEntries();
|
|
544
|
+
const entries = Object.entries((0, external_fflate_namespaceObject.unzipSync)(new Uint8Array(zipBuffer)));
|
|
521
545
|
if (!entries.length) throw new TemplateNotFoundError(templateName, new Error('empty archive'));
|
|
522
|
-
const archiveRoot = entries[0].
|
|
546
|
+
const archiveRoot = entries[0][0].split('/')[0];
|
|
523
547
|
const wanted = `${archiveRoot}/examples/${templateName}/`;
|
|
524
|
-
const files = entries.filter((
|
|
548
|
+
const files = entries.filter(([name])=>!name.endsWith('/') && name.startsWith(wanted));
|
|
525
549
|
if (!files.length) throw new TemplateNotFoundError(templateName);
|
|
550
|
+
const root = external_node_path_namespaceObject.resolve(projectPath);
|
|
526
551
|
let written = 0;
|
|
527
|
-
for (const
|
|
528
|
-
const rel =
|
|
552
|
+
for (const [name, data] of files){
|
|
553
|
+
const rel = name.slice(wanted.length);
|
|
529
554
|
if (!rel) continue;
|
|
530
|
-
const dest = external_node_path_namespaceObject.
|
|
555
|
+
const dest = external_node_path_namespaceObject.resolve(root, rel);
|
|
556
|
+
const relative = external_node_path_namespaceObject.relative(root, dest);
|
|
557
|
+
if (!relative || relative.startsWith('..') || external_node_path_namespaceObject.isAbsolute(relative)) throw new Error(`Refusing to extract zip entry outside the destination: ${name}`);
|
|
531
558
|
await promises_namespaceObject.mkdir(external_node_path_namespaceObject.dirname(dest), {
|
|
532
559
|
recursive: true
|
|
533
560
|
});
|
|
534
|
-
await promises_namespaceObject.writeFile(dest,
|
|
561
|
+
await promises_namespaceObject.writeFile(dest, data);
|
|
535
562
|
written++;
|
|
536
563
|
}
|
|
537
564
|
return written;
|
|
@@ -677,8 +704,8 @@ async function importExternalTemplate(projectPath, projectName, template, logger
|
|
|
677
704
|
await promises_namespaceObject.mkdir(projectPath, {
|
|
678
705
|
recursive: true
|
|
679
706
|
});
|
|
680
|
-
if (!isHttp && !isGithub &&
|
|
681
|
-
const localTemplate = bundledTemplateDir(
|
|
707
|
+
if (!isHttp && !isGithub && BUNDLED_TEMPLATES.includes(resolvedTemplate)) {
|
|
708
|
+
const localTemplate = bundledTemplateDir(resolvedTemplate);
|
|
682
709
|
if ((0, external_node_fs_namespaceObject.existsSync)(localTemplate)) {
|
|
683
710
|
await copyDirectoryWithSymlinks(localTemplate, projectPath);
|
|
684
711
|
await removeTemplateScaffoldingFiles(projectPath);
|
|
@@ -735,8 +762,7 @@ async function importExternalTemplate(projectPath, projectName, template, logger
|
|
|
735
762
|
const contentType = String(headers?.['content-type'] || '');
|
|
736
763
|
const looksZip = /zip|octet-stream/i.test(contentType) || template.toLowerCase().endsWith('.zip');
|
|
737
764
|
if (!looksZip) throw new Error(`Remote template does not appear to be a ZIP archive: ${template}`);
|
|
738
|
-
|
|
739
|
-
zip.extractAllTo(tempPath, true);
|
|
765
|
+
await extractZipBufferTo(Buffer.from(data), tempPath);
|
|
740
766
|
const sourcePath = await getZipSourcePath(tempPath, template);
|
|
741
767
|
await moveDirectoryContents(sourcePath, projectPath);
|
|
742
768
|
provenance = {
|
|
@@ -862,134 +888,6 @@ async function initializeGitRepository(projectPath, projectName, templateName, l
|
|
|
862
888
|
], projectPath);
|
|
863
889
|
if (!committed.ok) logger.log(firstCommitSkipped(projectName, committed.reason || ''));
|
|
864
890
|
}
|
|
865
|
-
function buildExecEnv() {
|
|
866
|
-
if ('win32' !== process.platform) return;
|
|
867
|
-
const nodeDir = external_node_path_namespaceObject.dirname(process.execPath);
|
|
868
|
-
const pathSep = external_node_path_namespaceObject.delimiter;
|
|
869
|
-
const existing = process.env.PATH || process.env.Path || '';
|
|
870
|
-
if (existing.includes(nodeDir)) return;
|
|
871
|
-
return {
|
|
872
|
-
...process.env,
|
|
873
|
-
PATH: `${nodeDir}${pathSep}${existing}`.trim(),
|
|
874
|
-
Path: `${nodeDir}${pathSep}${existing}`.trim()
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
async function runInstall(command, args, opts) {
|
|
878
|
-
const env = buildExecEnv();
|
|
879
|
-
const child = (0, external_cross_spawn_namespaceObject.spawn)(command, args, {
|
|
880
|
-
stdio: opts.stdio,
|
|
881
|
-
cwd: opts.cwd,
|
|
882
|
-
env: env || process.env
|
|
883
|
-
});
|
|
884
|
-
let stdout = '';
|
|
885
|
-
let stderr = '';
|
|
886
|
-
if (child.stdout) child.stdout.on('data', (chunk)=>{
|
|
887
|
-
stdout += chunk.toString();
|
|
888
|
-
});
|
|
889
|
-
if (child.stderr) child.stderr.on('data', (chunk)=>{
|
|
890
|
-
stderr += chunk.toString();
|
|
891
|
-
});
|
|
892
|
-
return new Promise((resolve, reject)=>{
|
|
893
|
-
child.on('close', (code)=>{
|
|
894
|
-
resolve({
|
|
895
|
-
code,
|
|
896
|
-
stderr,
|
|
897
|
-
stdout
|
|
898
|
-
});
|
|
899
|
-
});
|
|
900
|
-
child.on('error', (error)=>{
|
|
901
|
-
reject(error);
|
|
902
|
-
});
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
function getInstallArgs(packageManager) {
|
|
906
|
-
if ('bun' === packageManager) return [
|
|
907
|
-
'install'
|
|
908
|
-
];
|
|
909
|
-
return [
|
|
910
|
-
'install',
|
|
911
|
-
'--silent'
|
|
912
|
-
];
|
|
913
|
-
}
|
|
914
|
-
function getTagFallback(version) {
|
|
915
|
-
if ('*' === version || 'latest' === version || 'next' === version) return null;
|
|
916
|
-
const cleaned = version.replace(/^[~^]/, '');
|
|
917
|
-
return cleaned.includes('-') ? 'next' : 'latest';
|
|
918
|
-
}
|
|
919
|
-
async function updateExtensionDependencyTag(projectPath, projectName, logger) {
|
|
920
|
-
const packageJsonPath = external_node_path_namespaceObject.join(projectPath, 'package.json');
|
|
921
|
-
try {
|
|
922
|
-
const raw = await external_node_fs_namespaceObject.promises.readFile(packageJsonPath, 'utf8');
|
|
923
|
-
const packageJson = JSON.parse(raw);
|
|
924
|
-
const currentVersion = packageJson?.devDependencies?.extension;
|
|
925
|
-
if ('string' != typeof currentVersion) return false;
|
|
926
|
-
const tag = getTagFallback(currentVersion);
|
|
927
|
-
if (!tag || currentVersion === tag) return false;
|
|
928
|
-
packageJson.devDependencies = {
|
|
929
|
-
...packageJson.devDependencies || {},
|
|
930
|
-
extension: tag
|
|
931
|
-
};
|
|
932
|
-
await external_node_fs_namespaceObject.promises.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
933
|
-
return true;
|
|
934
|
-
} catch (error) {
|
|
935
|
-
logger.error(cantInstallDependencies(projectName, error));
|
|
936
|
-
return false;
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
function shouldRetryWithTagFallback(output) {
|
|
940
|
-
const text = output.toLowerCase();
|
|
941
|
-
return text.includes('no matching version found for extension@') || text.includes('notarget') || text.includes('etarget');
|
|
942
|
-
}
|
|
943
|
-
async function install_dependencies_runInstall(command, args, cwd, stdio) {
|
|
944
|
-
return runInstall(command, args, {
|
|
945
|
-
cwd,
|
|
946
|
-
stdio
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
async function hasDependenciesToInstall(projectPath) {
|
|
950
|
-
try {
|
|
951
|
-
const raw = await external_node_fs_namespaceObject.promises.readFile(external_node_path_namespaceObject.join(projectPath, 'package.json'), 'utf8');
|
|
952
|
-
const packageJson = JSON.parse(raw);
|
|
953
|
-
const depsCount = Object.keys(packageJson?.dependencies || {}).length;
|
|
954
|
-
const devDepsCount = Object.keys(packageJson?.devDependencies || {}).length;
|
|
955
|
-
return depsCount + devDepsCount > 0;
|
|
956
|
-
} catch (error) {
|
|
957
|
-
return true;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
async function installDependencies(projectPath, projectName, logger) {
|
|
961
|
-
const nodeModulesPath = external_node_path_namespaceObject.join(projectPath, 'node_modules');
|
|
962
|
-
const shouldInstall = await hasDependenciesToInstall(projectPath);
|
|
963
|
-
if (!shouldInstall) return;
|
|
964
|
-
const command = isDenoRuntime() ? 'deno' : await getInstallCommand();
|
|
965
|
-
const dependenciesArgs = 'deno' === command ? [
|
|
966
|
-
'install'
|
|
967
|
-
] : getInstallArgs(command);
|
|
968
|
-
const installMessage = installingDependencies();
|
|
969
|
-
logger.log(installMessage);
|
|
970
|
-
try {
|
|
971
|
-
await external_node_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
|
|
972
|
-
recursive: true
|
|
973
|
-
});
|
|
974
|
-
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'pipe';
|
|
975
|
-
const firstRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
976
|
-
if (0 !== firstRun.code) {
|
|
977
|
-
const output = `${firstRun.stdout}\n${firstRun.stderr}`;
|
|
978
|
-
const shouldRetry = shouldRetryWithTagFallback(output);
|
|
979
|
-
const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName, logger) : false;
|
|
980
|
-
if (didUpdate) {
|
|
981
|
-
const retryRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
982
|
-
if (0 === retryRun.code) return;
|
|
983
|
-
}
|
|
984
|
-
throw new Error(installingDependenciesFailed(command, dependenciesArgs, firstRun.code));
|
|
985
|
-
}
|
|
986
|
-
} catch (error) {
|
|
987
|
-
logger.error(installingDependenciesProcessError(projectName, error));
|
|
988
|
-
logger.error(cantInstallDependencies(projectName, error));
|
|
989
|
-
throw error;
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
const external_node_module_namespaceObject = require("node:module");
|
|
993
891
|
function stripJsoncExtensions(text) {
|
|
994
892
|
let out = '';
|
|
995
893
|
let i = 0;
|
|
@@ -1104,6 +1002,200 @@ function readDenoConfigDependencies(projectPath) {
|
|
|
1104
1002
|
}
|
|
1105
1003
|
return dependencies;
|
|
1106
1004
|
}
|
|
1005
|
+
function buildExecEnv() {
|
|
1006
|
+
if ('win32' !== process.platform) return;
|
|
1007
|
+
const nodeDir = external_node_path_namespaceObject.dirname(process.execPath);
|
|
1008
|
+
const pathSep = external_node_path_namespaceObject.delimiter;
|
|
1009
|
+
const existing = process.env.PATH || process.env.Path || '';
|
|
1010
|
+
if (existing.includes(nodeDir)) return;
|
|
1011
|
+
return {
|
|
1012
|
+
...process.env,
|
|
1013
|
+
PATH: `${nodeDir}${pathSep}${existing}`.trim(),
|
|
1014
|
+
Path: `${nodeDir}${pathSep}${existing}`.trim()
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
async function runInstall(command, args, opts) {
|
|
1018
|
+
const env = buildExecEnv();
|
|
1019
|
+
const child = (0, external_cross_spawn_namespaceObject.spawn)(command, args, {
|
|
1020
|
+
stdio: opts.stdio,
|
|
1021
|
+
cwd: opts.cwd,
|
|
1022
|
+
env: env || process.env
|
|
1023
|
+
});
|
|
1024
|
+
let stdout = '';
|
|
1025
|
+
let stderr = '';
|
|
1026
|
+
if (child.stdout) child.stdout.on('data', (chunk)=>{
|
|
1027
|
+
stdout += chunk.toString();
|
|
1028
|
+
});
|
|
1029
|
+
if (child.stderr) child.stderr.on('data', (chunk)=>{
|
|
1030
|
+
stderr += chunk.toString();
|
|
1031
|
+
});
|
|
1032
|
+
return new Promise((resolve, reject)=>{
|
|
1033
|
+
child.on('close', (code)=>{
|
|
1034
|
+
resolve({
|
|
1035
|
+
code,
|
|
1036
|
+
stderr,
|
|
1037
|
+
stdout
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
child.on('error', (error)=>{
|
|
1041
|
+
reject(error);
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
function getInstallArgs(packageManager) {
|
|
1046
|
+
if ('bun' === packageManager) return [
|
|
1047
|
+
'install'
|
|
1048
|
+
];
|
|
1049
|
+
return [
|
|
1050
|
+
'install',
|
|
1051
|
+
'--silent'
|
|
1052
|
+
];
|
|
1053
|
+
}
|
|
1054
|
+
function getTagFallback(version) {
|
|
1055
|
+
if ('*' === version || 'latest' === version || 'next' === version) return null;
|
|
1056
|
+
const cleaned = version.replace(/^[~^]/, '');
|
|
1057
|
+
return cleaned.includes('-') ? 'next' : 'latest';
|
|
1058
|
+
}
|
|
1059
|
+
async function pathExists(target) {
|
|
1060
|
+
try {
|
|
1061
|
+
await external_node_fs_namespaceObject.promises.access(target);
|
|
1062
|
+
return true;
|
|
1063
|
+
} catch {
|
|
1064
|
+
return false;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
async function resolveDenoConfigPath(projectPath) {
|
|
1068
|
+
for (const candidate of [
|
|
1069
|
+
'deno.json',
|
|
1070
|
+
'deno.jsonc'
|
|
1071
|
+
]){
|
|
1072
|
+
const full = external_node_path_namespaceObject.join(projectPath, candidate);
|
|
1073
|
+
if (await pathExists(full)) return full;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
async function updatePackageJsonExtensionTag(projectPath) {
|
|
1077
|
+
const packageJsonPath = external_node_path_namespaceObject.join(projectPath, 'package.json');
|
|
1078
|
+
if (!await pathExists(packageJsonPath)) return false;
|
|
1079
|
+
const packageJson = JSON.parse(await external_node_fs_namespaceObject.promises.readFile(packageJsonPath, 'utf8'));
|
|
1080
|
+
const currentVersion = packageJson?.devDependencies?.extension;
|
|
1081
|
+
if ('string' != typeof currentVersion) return false;
|
|
1082
|
+
const tag = getTagFallback(currentVersion);
|
|
1083
|
+
if (!tag || currentVersion === tag) return false;
|
|
1084
|
+
packageJson.devDependencies = {
|
|
1085
|
+
...packageJson.devDependencies || {},
|
|
1086
|
+
extension: tag
|
|
1087
|
+
};
|
|
1088
|
+
await external_node_fs_namespaceObject.promises.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
1089
|
+
return true;
|
|
1090
|
+
}
|
|
1091
|
+
function replaceExtensionSpecifierInDenoConfig(raw, currentSpecifier, nextSpecifier) {
|
|
1092
|
+
if (currentSpecifier === nextSpecifier) return;
|
|
1093
|
+
const quoted = `"${currentSpecifier}"`;
|
|
1094
|
+
let from = 0;
|
|
1095
|
+
while(from < raw.length){
|
|
1096
|
+
const at = raw.indexOf(quoted, from);
|
|
1097
|
+
if (-1 === at) break;
|
|
1098
|
+
const lineStart = raw.lastIndexOf('\n', at) + 1;
|
|
1099
|
+
const lineBefore = raw.slice(lineStart, at);
|
|
1100
|
+
if (/:\s*$/.test(lineBefore) && !lineBefore.includes('//')) {
|
|
1101
|
+
const index = at + 1;
|
|
1102
|
+
return raw.slice(0, index) + nextSpecifier + raw.slice(index + currentSpecifier.length);
|
|
1103
|
+
}
|
|
1104
|
+
from = at + quoted.length;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
async function updateDenoConfigExtensionTag(projectPath) {
|
|
1108
|
+
const configPath = await resolveDenoConfigPath(projectPath);
|
|
1109
|
+
if (!configPath) return false;
|
|
1110
|
+
const raw = await external_node_fs_namespaceObject.promises.readFile(configPath, 'utf8');
|
|
1111
|
+
const config = parseJsoncSafe(raw);
|
|
1112
|
+
const imports = config?.imports;
|
|
1113
|
+
if (!imports || 'object' != typeof imports) return false;
|
|
1114
|
+
let next = raw;
|
|
1115
|
+
let updated = false;
|
|
1116
|
+
for (const specifier of Object.values(imports)){
|
|
1117
|
+
if ('string' != typeof specifier) continue;
|
|
1118
|
+
const parsed = parseNpmSpecifier(specifier);
|
|
1119
|
+
if (!parsed || 'extension' !== parsed.name) continue;
|
|
1120
|
+
const tag = getTagFallback(parsed.version);
|
|
1121
|
+
if (!tag || parsed.version === tag) continue;
|
|
1122
|
+
const rewritten = replaceExtensionSpecifierInDenoConfig(next, specifier, `npm:extension@${tag}`);
|
|
1123
|
+
if (void 0 !== rewritten) {
|
|
1124
|
+
next = rewritten;
|
|
1125
|
+
updated = true;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
if (!updated) return false;
|
|
1129
|
+
await external_node_fs_namespaceObject.promises.writeFile(configPath, next);
|
|
1130
|
+
return true;
|
|
1131
|
+
}
|
|
1132
|
+
async function updateExtensionDependencyTag(projectPath, projectName, logger) {
|
|
1133
|
+
try {
|
|
1134
|
+
const updatedPackageJson = await updatePackageJsonExtensionTag(projectPath);
|
|
1135
|
+
const updatedDenoConfig = await updateDenoConfigExtensionTag(projectPath);
|
|
1136
|
+
return updatedPackageJson || updatedDenoConfig;
|
|
1137
|
+
} catch (error) {
|
|
1138
|
+
logger.error(cantInstallDependencies(projectName, error));
|
|
1139
|
+
return false;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function shouldRetryWithTagFallback(output) {
|
|
1143
|
+
const text = output.toLowerCase();
|
|
1144
|
+
return text.includes('no matching version found for extension@') || text.includes('notarget') && text.includes('extension@') || text.includes('etarget') && text.includes('extension@') || /could not find version of npm package ['"]?extension['"]?/.test(text);
|
|
1145
|
+
}
|
|
1146
|
+
async function install_dependencies_runInstall(command, args, cwd, stdio) {
|
|
1147
|
+
return runInstall(command, args, {
|
|
1148
|
+
cwd,
|
|
1149
|
+
stdio
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
async function hasDependenciesToInstall(projectPath) {
|
|
1153
|
+
const packageJsonPath = external_node_path_namespaceObject.join(projectPath, 'package.json');
|
|
1154
|
+
let raw;
|
|
1155
|
+
try {
|
|
1156
|
+
raw = await external_node_fs_namespaceObject.promises.readFile(packageJsonPath, 'utf8');
|
|
1157
|
+
} catch (error) {
|
|
1158
|
+
if (error?.code === 'ENOENT') return Object.keys(readDenoConfigDependencies(projectPath)).length > 0;
|
|
1159
|
+
throw error;
|
|
1160
|
+
}
|
|
1161
|
+
const packageJson = JSON.parse(raw);
|
|
1162
|
+
const depsCount = Object.keys(packageJson?.dependencies || {}).length;
|
|
1163
|
+
const devDepsCount = Object.keys(packageJson?.devDependencies || {}).length;
|
|
1164
|
+
return depsCount + devDepsCount > 0;
|
|
1165
|
+
}
|
|
1166
|
+
async function installDependencies(projectPath, projectName, logger) {
|
|
1167
|
+
const nodeModulesPath = external_node_path_namespaceObject.join(projectPath, 'node_modules');
|
|
1168
|
+
const shouldInstall = await hasDependenciesToInstall(projectPath);
|
|
1169
|
+
if (!shouldInstall) return;
|
|
1170
|
+
const command = isDenoRuntime() ? 'deno' : await getInstallCommand();
|
|
1171
|
+
const dependenciesArgs = 'deno' === command ? [
|
|
1172
|
+
'install'
|
|
1173
|
+
] : getInstallArgs(command);
|
|
1174
|
+
const installMessage = installingDependencies();
|
|
1175
|
+
logger.log(installMessage);
|
|
1176
|
+
try {
|
|
1177
|
+
await external_node_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
|
|
1178
|
+
recursive: true
|
|
1179
|
+
});
|
|
1180
|
+
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'pipe';
|
|
1181
|
+
const firstRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
1182
|
+
if (0 !== firstRun.code) {
|
|
1183
|
+
const output = `${firstRun.stdout}\n${firstRun.stderr}`;
|
|
1184
|
+
const shouldRetry = shouldRetryWithTagFallback(output);
|
|
1185
|
+
const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName, logger) : false;
|
|
1186
|
+
if (didUpdate) {
|
|
1187
|
+
const retryRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
1188
|
+
if (0 === retryRun.code) return;
|
|
1189
|
+
}
|
|
1190
|
+
throw new Error(installingDependenciesFailed(command, dependenciesArgs, firstRun.code));
|
|
1191
|
+
}
|
|
1192
|
+
} catch (error) {
|
|
1193
|
+
logger.error(installingDependenciesProcessError(projectName, error));
|
|
1194
|
+
logger.error(cantInstallDependencies(projectName, error));
|
|
1195
|
+
throw error;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
1107
1199
|
const requireFromCreate = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
1108
1200
|
function resolveDevelopRoot(projectPath) {
|
|
1109
1201
|
try {
|
|
@@ -1485,7 +1577,7 @@ async function overridePackageJson(projectPath, { template = "javascript", cliVe
|
|
|
1485
1577
|
throw error;
|
|
1486
1578
|
}
|
|
1487
1579
|
}
|
|
1488
|
-
async function
|
|
1580
|
+
async function write_deno_jsonc_pathExists(target) {
|
|
1489
1581
|
try {
|
|
1490
1582
|
await promises_namespaceObject.access(target);
|
|
1491
1583
|
return true;
|
|
@@ -1531,7 +1623,7 @@ async function writeDenoJsonc(projectPath, { template = "javascript", cliVersion
|
|
|
1531
1623
|
for (const candidate of [
|
|
1532
1624
|
'deno.json',
|
|
1533
1625
|
'deno.jsonc'
|
|
1534
|
-
])if (await
|
|
1626
|
+
])if (await write_deno_jsonc_pathExists(external_node_path_namespaceObject.join(projectPath, candidate))) {
|
|
1535
1627
|
existingConfig = candidate;
|
|
1536
1628
|
break;
|
|
1537
1629
|
}
|
|
@@ -1548,8 +1640,12 @@ async function writeDenoJsonc(projectPath, { template = "javascript", cliVersion
|
|
|
1548
1640
|
...imports || {},
|
|
1549
1641
|
...config.imports || {}
|
|
1550
1642
|
};
|
|
1551
|
-
if (
|
|
1552
|
-
|
|
1643
|
+
if (imports?.extension) config.imports.extension = imports.extension;
|
|
1644
|
+
config.nodeModulesDir = 'auto';
|
|
1645
|
+
config.tasks = {
|
|
1646
|
+
...tasks,
|
|
1647
|
+
...config.tasks || {}
|
|
1648
|
+
};
|
|
1553
1649
|
await promises_namespaceObject.writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
1554
1650
|
} else await promises_namespaceObject.writeFile(external_node_path_namespaceObject.join(projectPath, 'deno.jsonc'), renderDenoJsonc(tasks, imports));
|
|
1555
1651
|
if (primary) await promises_namespaceObject.rm(external_node_path_namespaceObject.join(projectPath, 'package.json'), {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare const DEFAULT_TEMPLATES_REF = "
|
|
1
|
+
export declare const DEFAULT_TEMPLATES_REF = "f7f4e6efb56a7e5ae08d58dbff3972d94af7d021";
|
|
2
|
+
export declare const BUNDLED_TEMPLATES: readonly string[];
|
|
2
3
|
export declare function resolveCatalogUrls(ref: string, overrideUrl?: string): string[];
|
|
3
4
|
export interface TemplateProvenance {
|
|
4
5
|
template: string;
|
|
@@ -9,7 +9,7 @@ Packaging your extension is local and free. Submitting the result to a
|
|
|
9
9
|
store is what [extension.dev](https://docs.extension.dev/publish/overview?utm_source=store-md)
|
|
10
10
|
does, and it sponsors Extension.js.
|
|
11
11
|
|
|
12
|
-
Last updated: 2026-08-
|
|
12
|
+
Last updated: 2026-08-17
|
|
13
13
|
|
|
14
14
|
## Listing
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"templates"
|
|
26
26
|
],
|
|
27
27
|
"name": "extension-create",
|
|
28
|
-
"version": "4.0.
|
|
28
|
+
"version": "4.0.33",
|
|
29
29
|
"description": "The standalone extension creation engine for Extension.js",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Cezar Augusto",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"edge-extension"
|
|
76
76
|
],
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"adm-zip": "^0.6.0",
|
|
79
78
|
"axios": "^1.18.0",
|
|
80
79
|
"cross-spawn": "^7.0.6",
|
|
80
|
+
"fflate": "^0.8.3",
|
|
81
81
|
"go-git-it": "^5.1.5",
|
|
82
82
|
"pintor": "0.3.0",
|
|
83
83
|
"prefers-yarn": "2.0.1"
|
|
@@ -86,7 +86,6 @@
|
|
|
86
86
|
"@biomejs/biome": "^2.2.4",
|
|
87
87
|
"@changesets/cli": "^2.29.8",
|
|
88
88
|
"@rslib/core": "^0.23.1",
|
|
89
|
-
"@types/adm-zip": "^0.5.7",
|
|
90
89
|
"@types/chrome": "^0.1.33",
|
|
91
90
|
"@types/cross-spawn": "^6.0.6",
|
|
92
91
|
"@types/node": "^26",
|