extension-create 3.5.0-next.2 → 3.5.0-next.20

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.
@@ -0,0 +1,10 @@
1
+ type InstallResult = {
2
+ code: number | null;
3
+ stderr: string;
4
+ stdout: string;
5
+ };
6
+ export declare function runInstall(command: string, args: string[], opts: {
7
+ cwd: string;
8
+ stdio: 'inherit' | 'ignore' | 'pipe';
9
+ }): Promise<InstallResult>;
10
+ export {};
@@ -16,6 +16,9 @@ export declare function initializingGitForRepositoryFailed(gitCommand: string, g
16
16
  export declare function initializingGitForRepositoryProcessError(projectName: string, error: any): string;
17
17
  export declare function initializingGitForRepositoryError(projectName: string, error: any): string;
18
18
  export declare function installingDependencies(): string;
19
+ export declare function installingBuildDependencies(dependencies: string[]): string;
20
+ export declare function foundSpecializedDependencies(count: number): string;
21
+ export declare function installingProjectIntegrations(integrations: string[]): string[];
19
22
  export declare function installingDependenciesFailed(gitCommand: string, gitArgs: string[], code: number | null): string;
20
23
  export declare function installingDependenciesProcessError(projectName: string, error: any): string;
21
24
  export declare function cantInstallDependencies(projectName: string, error: any): string;
@@ -2,6 +2,7 @@ type ProgressOptions = {
2
2
  enabled?: boolean;
3
3
  intervalMs?: number;
4
4
  width?: number;
5
+ persistLabel?: boolean;
5
6
  };
6
7
  type ProgressHandle = {
7
8
  stop: () => void;
package/dist/module.cjs CHANGED
@@ -143,6 +143,30 @@ function initializingGitForRepositoryProcessError(projectName, error) {
143
143
  function initializingGitForRepositoryError(projectName, error) {
144
144
  return `${external_pintor_default().red('Error')} Couldn't initialize ${external_pintor_default().yellow('git')} for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error?.message || error))}\n${external_pintor_default().red('Next step: retry initialization or create the repository manually.')}`;
145
145
  }
146
+ function installingDependencies() {
147
+ return `${statusPrefix} Installing project-specific dependencies...`;
148
+ }
149
+ function installingBuildDependencies(dependencies) {
150
+ return `${statusPrefix} Installing general build dependencies...`;
151
+ }
152
+ function foundSpecializedDependencies(count) {
153
+ return `${statusPrefix} Found ${external_pintor_default().yellow(String(count))} specialized dependencies needing installation...`;
154
+ }
155
+ function installingProjectIntegrations(integrations) {
156
+ if (0 === integrations.length) return [
157
+ `${statusPrefix} Installing specialized dependencies for ${external_pintor_default().gray('project tooling')}...`
158
+ ];
159
+ return integrations.map((integration)=>`${statusPrefix} Installing specialized dependencies for ${external_pintor_default().yellow(integration)}...`);
160
+ }
161
+ function installingDependenciesFailed(gitCommand, gitArgs, code) {
162
+ return `${external_pintor_default().red('Error')} Command ${external_pintor_default().yellow(gitCommand)} ${external_pintor_default().yellow(gitArgs.join(' '))} failed.\n${external_pintor_default().red(`Exit code: ${external_pintor_default().yellow(String(code))}`)}\n${external_pintor_default().red('Next step: run the command manually to inspect the error.')}`;
163
+ }
164
+ function installingDependenciesProcessError(projectName, error) {
165
+ return `${external_pintor_default().red('Error')} Child process failed while installing dependencies for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error))}\n${external_pintor_default().red('Next step: run the install command manually to inspect the error.')}`;
166
+ }
167
+ function cantInstallDependencies(projectName, error) {
168
+ return `${external_pintor_default().red('Error')} Couldn't install dependencies for ${external_pintor_default().blue(projectName)}.\n${external_pintor_default().red(String(error?.message || error))}\n${external_pintor_default().red('Next step: check your package manager settings, then try again.')}`;
169
+ }
146
170
  function writingPackageJsonMetadata() {
147
171
  return `${statusPrefix} Writing ${external_pintor_default().yellow('package.json')}...`;
148
172
  }
@@ -330,7 +354,7 @@ async function importExternalTemplate(projectPath, projectName, template) {
330
354
  if (!line) return false;
331
355
  const trimmed = line.trim();
332
356
  if (!trimmed) return false;
333
- if (/Using git version/i.test(line) || /GitHub API rate limit reached, continuing without connectivity check/i.test(line) || /\[go-git-it\] An error occurred: Error: Failed to download release asset: HTTP 404/i.test(line) || /^Downloading extension\b/i.test(trimmed) || /^URL https?:\/\/codeload\.github\.com\/extension-js\/examples\/zip\/refs\/heads\/main\b/i.test(trimmed) || /^\[[=\s]+\]\s*\d+%/i.test(trimmed)) {
357
+ if (/Using git version/i.test(line) || /GitHub API rate limit reached, continuing without connectivity check/i.test(line) || /^Downloading extension\b/i.test(trimmed) || /^URL https?:\/\/codeload\.github\.com\/extension-js\/examples\/zip\/refs\/heads\/main\b/i.test(trimmed) || /^\[[=\s]+\]\s*\d+%/i.test(trimmed)) {
334
358
  suppressGoGitItStack = true;
335
359
  return true;
336
360
  }
@@ -478,6 +502,198 @@ async function overridePackageJson(projectPath, projectName, { template: _templa
478
502
  throw error;
479
503
  }
480
504
  }
505
+ function stripAnsi(input) {
506
+ return input.replace(/\x1b\[[0-9;]*m/g, '');
507
+ }
508
+ function shouldShowProgress() {
509
+ return Boolean(process.stdout.isTTY) && !process.env.CI;
510
+ }
511
+ function startProgressBar(label, options) {
512
+ const enabled = (options?.enabled ?? true) && shouldShowProgress();
513
+ if (!enabled) return {
514
+ stop: ()=>void 0
515
+ };
516
+ const width = Math.max(10, options?.width ?? 24);
517
+ const intervalMs = Math.max(50, options?.intervalMs ?? 90);
518
+ let tick = 0;
519
+ let lastVisibleLength = 0;
520
+ const render = ()=>{
521
+ const filled = tick % (width + 1);
522
+ const empty = width - filled;
523
+ const bar = `[${'='.repeat(filled)}${' '.repeat(empty)}]`;
524
+ const line = `${label} ${bar}`;
525
+ lastVisibleLength = stripAnsi(line).length;
526
+ process.stdout.write(`\r${line}`);
527
+ tick = (tick + 1) % (width + 1);
528
+ };
529
+ render();
530
+ const timer = setInterval(render, intervalMs);
531
+ return {
532
+ stop: ()=>{
533
+ clearInterval(timer);
534
+ if (process.stdout.isTTY) {
535
+ process.stdout.write(`\r${' '.repeat(lastVisibleLength)}\r`);
536
+ if (options?.persistLabel) process.stdout.write(`${label}\n`);
537
+ }
538
+ }
539
+ };
540
+ }
541
+ const external_cross_spawn_namespaceObject = require("cross-spawn");
542
+ function resolveWindowsCmdExe() {
543
+ const comspec = process.env.ComSpec;
544
+ if (comspec) return comspec;
545
+ const systemRoot = process.env.SystemRoot || 'C:\\Windows';
546
+ return external_path_namespaceObject.join(systemRoot, 'System32', 'cmd.exe');
547
+ }
548
+ function formatCmdArgs(command, args) {
549
+ const quotedCommand = command.includes(' ') ? `"${command}"` : command;
550
+ const quotedArgs = args.map((arg)=>arg.includes(' ') ? `"${arg}"` : arg);
551
+ return `${quotedCommand} ${quotedArgs.join(' ')}`.trim();
552
+ }
553
+ function resolveInstallInvocation(command, args) {
554
+ if ('win32' !== process.platform) return {
555
+ command,
556
+ args
557
+ };
558
+ return {
559
+ command: resolveWindowsCmdExe(),
560
+ args: [
561
+ '/d',
562
+ '/s',
563
+ '/c',
564
+ formatCmdArgs(command, args)
565
+ ]
566
+ };
567
+ }
568
+ function buildExecEnv() {
569
+ if ('win32' !== process.platform) return;
570
+ const nodeDir = external_path_namespaceObject.dirname(process.execPath);
571
+ const pathSep = external_path_namespaceObject.delimiter;
572
+ const existing = process.env.PATH || process.env.Path || '';
573
+ if (existing.includes(nodeDir)) return;
574
+ return {
575
+ ...process.env,
576
+ PATH: `${nodeDir}${pathSep}${existing}`.trim(),
577
+ Path: `${nodeDir}${pathSep}${existing}`.trim()
578
+ };
579
+ }
580
+ async function runInstall(command, args, opts) {
581
+ const invocation = resolveInstallInvocation(command, args);
582
+ const env = buildExecEnv();
583
+ const child = (0, external_cross_spawn_namespaceObject.spawn)(invocation.command, invocation.args, {
584
+ stdio: opts.stdio,
585
+ cwd: opts.cwd,
586
+ env: env || process.env
587
+ });
588
+ let stdout = '';
589
+ let stderr = '';
590
+ if (child.stdout) child.stdout.on('data', (chunk)=>{
591
+ stdout += chunk.toString();
592
+ });
593
+ if (child.stderr) child.stderr.on('data', (chunk)=>{
594
+ stderr += chunk.toString();
595
+ });
596
+ return new Promise((resolve, reject)=>{
597
+ child.on('close', (code)=>{
598
+ resolve({
599
+ code,
600
+ stderr,
601
+ stdout
602
+ });
603
+ });
604
+ child.on('error', (error)=>{
605
+ reject(error);
606
+ });
607
+ });
608
+ }
609
+ function getInstallArgs() {
610
+ return [
611
+ 'install',
612
+ '--silent'
613
+ ];
614
+ }
615
+ function getTagFallback(version) {
616
+ if ('*' === version || 'latest' === version || 'next' === version) return null;
617
+ const cleaned = version.replace(/^[~^]/, '');
618
+ return cleaned.includes('-') ? 'next' : 'latest';
619
+ }
620
+ async function updateExtensionDependencyTag(projectPath, projectName) {
621
+ const packageJsonPath = external_path_namespaceObject.join(projectPath, 'package.json');
622
+ try {
623
+ const raw = await external_fs_namespaceObject.promises.readFile(packageJsonPath, 'utf8');
624
+ const packageJson = JSON.parse(raw);
625
+ const currentVersion = packageJson?.devDependencies?.extension;
626
+ if ('string' != typeof currentVersion) return false;
627
+ const tag = getTagFallback(currentVersion);
628
+ if (!tag || currentVersion === tag) return false;
629
+ packageJson.devDependencies = {
630
+ ...packageJson.devDependencies || {},
631
+ extension: tag
632
+ };
633
+ await external_fs_namespaceObject.promises.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
634
+ return true;
635
+ } catch (error) {
636
+ console.error(cantInstallDependencies(projectName, error));
637
+ return false;
638
+ }
639
+ }
640
+ function shouldRetryWithTagFallback(output) {
641
+ const text = output.toLowerCase();
642
+ return text.includes('no matching version found for extension@') || text.includes('notarget') || text.includes('etarget');
643
+ }
644
+ async function install_dependencies_runInstall(command, args, cwd, stdio) {
645
+ return runInstall(command, args, {
646
+ cwd,
647
+ stdio
648
+ });
649
+ }
650
+ async function installDependencies(projectPath, projectName) {
651
+ const nodeModulesPath = external_path_namespaceObject.join(projectPath, 'node_modules');
652
+ const command = await getInstallCommand();
653
+ const dependenciesArgs = getInstallArgs();
654
+ const installMessage = installingDependencies();
655
+ const progressEnabled = shouldShowProgress();
656
+ const progress = startProgressBar(installMessage, {
657
+ enabled: progressEnabled,
658
+ persistLabel: true
659
+ });
660
+ if (!progressEnabled) console.log(installMessage);
661
+ try {
662
+ await external_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
663
+ recursive: true
664
+ });
665
+ const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'pipe';
666
+ let firstRun;
667
+ try {
668
+ firstRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
669
+ } finally{
670
+ progress.stop();
671
+ }
672
+ if (0 !== firstRun.code) {
673
+ const output = `${firstRun.stdout}\n${firstRun.stderr}`;
674
+ const shouldRetry = shouldRetryWithTagFallback(output);
675
+ const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName) : false;
676
+ if (didUpdate) {
677
+ const retryProgress = startProgressBar(installMessage, {
678
+ enabled: progressEnabled,
679
+ persistLabel: true
680
+ });
681
+ let retryRun;
682
+ try {
683
+ retryRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
684
+ } finally{
685
+ retryProgress.stop();
686
+ }
687
+ if (0 === retryRun.code) return;
688
+ }
689
+ throw new Error(installingDependenciesFailed(command, dependenciesArgs, firstRun.code));
690
+ }
691
+ } catch (error) {
692
+ console.error(installingDependenciesProcessError(projectName, error));
693
+ console.error(cantInstallDependencies(projectName, error));
694
+ throw error;
695
+ }
696
+ }
481
697
  const manifestSearchMaxDepth = 3;
482
698
  const ignoredManifestDirs = new Set([
483
699
  'node_modules',
@@ -703,7 +919,6 @@ async function writeGitignore(projectPath) {
703
919
  throw err;
704
920
  });
705
921
  }
706
- const external_cross_spawn_namespaceObject = require("cross-spawn");
707
922
  async function initializeGitRepository(projectPath, projectName) {
708
923
  const gitCommand = 'git';
709
924
  const gitArgs = [
@@ -741,7 +956,298 @@ async function setupBuiltInTests(projectPath, projectName) {
741
956
  throw error;
742
957
  }
743
958
  }
744
- async function extensionCreate(projectNameInput, { cliVersion, template = 'init', install: _install = false }) {
959
+ const external_module_namespaceObject = require("module");
960
+ const requireFromCreate = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
961
+ function resolveDevelopRoot(projectPath) {
962
+ const override = process.env.EXTENSION_CREATE_DEVELOP_ROOT;
963
+ if (override) return override;
964
+ try {
965
+ const localPkgPath = external_path_namespaceObject.join(projectPath, 'node_modules', 'extension-develop', 'package.json');
966
+ if (external_fs_namespaceObject.existsSync(localPkgPath)) return external_path_namespaceObject.dirname(localPkgPath);
967
+ const pkgPath = requireFromCreate.resolve('extension-develop/package.json', {
968
+ paths: [
969
+ projectPath,
970
+ process.cwd(),
971
+ __dirname
972
+ ]
973
+ });
974
+ return external_path_namespaceObject.dirname(pkgPath);
975
+ } catch {
976
+ return null;
977
+ }
978
+ }
979
+ function resolveBuildDepsPath(developRoot) {
980
+ return external_path_namespaceObject.join(developRoot, 'webpack', 'webpack-lib', 'build-dependencies.json');
981
+ }
982
+ function loadBuildDependencies(developRoot) {
983
+ const metadataPath = resolveBuildDepsPath(developRoot);
984
+ if (!external_fs_namespaceObject.existsSync(metadataPath)) {
985
+ console.warn(`${installingBuildDependencies([])} (build-dependencies.json missing; skipping build deps install)`);
986
+ return {};
987
+ }
988
+ return JSON.parse(external_fs_namespaceObject.readFileSync(metadataPath, 'utf8'));
989
+ }
990
+ function readPackageJson(projectPath) {
991
+ try {
992
+ const raw = external_fs_namespaceObject.readFileSync(external_path_namespaceObject.join(projectPath, 'package.json'), 'utf8');
993
+ return JSON.parse(raw);
994
+ } catch {
995
+ return {};
996
+ }
997
+ }
998
+ function hasDependency(pkg, name) {
999
+ return Boolean(pkg.dependencies?.[name] || pkg.devDependencies?.[name]);
1000
+ }
1001
+ function canResolve(dependency, paths) {
1002
+ try {
1003
+ requireFromCreate.resolve(dependency, {
1004
+ paths
1005
+ });
1006
+ return true;
1007
+ } catch {
1008
+ return false;
1009
+ }
1010
+ }
1011
+ function findConfigFile(projectPath, candidates) {
1012
+ return candidates.some((file)=>external_fs_namespaceObject.existsSync(external_path_namespaceObject.join(projectPath, file)));
1013
+ }
1014
+ function detectOptionalDependencies(projectPath) {
1015
+ const pkg = readPackageJson(projectPath);
1016
+ const usesReact = hasDependency(pkg, 'react') || hasDependency(pkg, 'react-dom');
1017
+ const usesPreact = hasDependency(pkg, 'preact');
1018
+ const usesVue = hasDependency(pkg, 'vue');
1019
+ const usesSvelte = hasDependency(pkg, 'svelte');
1020
+ const hasTsConfig = external_fs_namespaceObject.existsSync(external_path_namespaceObject.join(projectPath, 'tsconfig.json'));
1021
+ const usesTypeScript = hasDependency(pkg, "typescript") || hasTsConfig;
1022
+ const usesSass = hasDependency(pkg, 'sass') || hasDependency(pkg, 'sass-loader');
1023
+ const usesLess = hasDependency(pkg, 'less') || hasDependency(pkg, 'less-loader');
1024
+ const postCssConfigFiles = [
1025
+ '.postcssrc',
1026
+ '.postcssrc.json',
1027
+ '.postcssrc.yaml',
1028
+ '.postcssrc.yml',
1029
+ 'postcss.config.mjs',
1030
+ '.postcssrc.js',
1031
+ '.postcssrc.cjs',
1032
+ 'postcss.config.js',
1033
+ 'postcss.config.cjs'
1034
+ ];
1035
+ const tailwindConfigFiles = [
1036
+ 'tailwind.config.mjs',
1037
+ 'tailwind.config.cjs',
1038
+ 'tailwind.config.js'
1039
+ ];
1040
+ const usesPostCss = hasDependency(pkg, 'postcss') || hasDependency(pkg, 'postcss-loader') || findConfigFile(projectPath, postCssConfigFiles) || hasDependency(pkg, 'tailwindcss') || hasDependency(pkg, '@tailwindcss/postcss') || findConfigFile(projectPath, tailwindConfigFiles);
1041
+ const integrations = [];
1042
+ const dependenciesByIntegration = {};
1043
+ const deps = new Set();
1044
+ const addIntegration = (name, depsForIntegration)=>{
1045
+ if (!integrations.includes(name)) integrations.push(name);
1046
+ if (!dependenciesByIntegration[name]) dependenciesByIntegration[name] = [];
1047
+ for (const dep of depsForIntegration){
1048
+ if (!dependenciesByIntegration[name].includes(dep)) dependenciesByIntegration[name].push(dep);
1049
+ deps.add(dep);
1050
+ }
1051
+ };
1052
+ if (usesTypeScript) addIntegration('TypeScript', [
1053
+ "typescript"
1054
+ ]);
1055
+ if (usesReact) addIntegration('React', [
1056
+ 'react-refresh',
1057
+ '@rspack/plugin-react-refresh'
1058
+ ]);
1059
+ if (usesPreact) addIntegration('Preact', [
1060
+ '@prefresh/core',
1061
+ '@prefresh/utils',
1062
+ '@rspack/plugin-preact-refresh',
1063
+ 'preact'
1064
+ ]);
1065
+ if (usesVue) addIntegration('Vue', [
1066
+ 'vue-loader',
1067
+ '@vue/compiler-sfc'
1068
+ ]);
1069
+ if (usesSvelte) addIntegration('Svelte', [
1070
+ 'svelte-loader',
1071
+ "typescript"
1072
+ ]);
1073
+ if (usesSass) addIntegration('Sass', [
1074
+ 'sass-loader',
1075
+ 'postcss-loader',
1076
+ 'postcss-scss',
1077
+ 'postcss-preset-env'
1078
+ ]);
1079
+ if (usesLess) addIntegration('Less', [
1080
+ 'less',
1081
+ 'less-loader'
1082
+ ]);
1083
+ if (!usesPostCss || usesSass || usesLess) {
1084
+ if (usesPostCss) addIntegration('PostCSS', []);
1085
+ } else addIntegration('PostCSS', [
1086
+ 'postcss',
1087
+ 'postcss-loader'
1088
+ ]);
1089
+ return {
1090
+ integrations,
1091
+ dependencies: Array.from(deps),
1092
+ dependenciesByIntegration
1093
+ };
1094
+ }
1095
+ function buildOptionalInstallArgs(pm, dependencies, installDir) {
1096
+ if ('yarn' === pm) return [
1097
+ 'add',
1098
+ ...dependencies,
1099
+ '--cwd',
1100
+ installDir,
1101
+ '--optional'
1102
+ ];
1103
+ if ('pnpm' === pm) return [
1104
+ 'add',
1105
+ ...dependencies,
1106
+ '--dir',
1107
+ installDir,
1108
+ '--save-optional'
1109
+ ];
1110
+ if ('bun' === pm) return [
1111
+ 'add',
1112
+ ...dependencies,
1113
+ '--cwd',
1114
+ installDir,
1115
+ '--optional'
1116
+ ];
1117
+ return [
1118
+ 'install',
1119
+ ...dependencies,
1120
+ '--prefix',
1121
+ installDir,
1122
+ '--save-optional'
1123
+ ];
1124
+ }
1125
+ function buildBuildInstallArgs(pm, dependencies, dependencyMap) {
1126
+ const depsWithVersions = dependencies.map((dep)=>`${dep}@${dependencyMap[dep]}`);
1127
+ if ('yarn' === pm) return [
1128
+ 'add',
1129
+ ...depsWithVersions
1130
+ ];
1131
+ if ('pnpm' === pm) return [
1132
+ 'add',
1133
+ '--save',
1134
+ ...depsWithVersions
1135
+ ];
1136
+ if ('bun' === pm) return [
1137
+ 'add',
1138
+ ...depsWithVersions
1139
+ ];
1140
+ return [
1141
+ 'install',
1142
+ '--save',
1143
+ ...depsWithVersions
1144
+ ];
1145
+ }
1146
+ function resolveMissingBuildDeps(developRoot) {
1147
+ const dependencyMap = loadBuildDependencies(developRoot);
1148
+ const candidates = Object.keys(dependencyMap);
1149
+ const missing = candidates.filter((dep)=>!canResolve(dep, [
1150
+ developRoot,
1151
+ process.cwd()
1152
+ ]));
1153
+ return {
1154
+ dependencies: missing,
1155
+ dependencyMap
1156
+ };
1157
+ }
1158
+ function resolveMissingOptionalDeps(developRoot, projectPath) {
1159
+ const plan = detectOptionalDependencies(projectPath);
1160
+ const dependenciesByIntegration = {};
1161
+ const integrations = [];
1162
+ const missing = new Set();
1163
+ for (const integration of plan.integrations){
1164
+ const depsForIntegration = plan.dependenciesByIntegration[integration] || [];
1165
+ const missingForIntegration = depsForIntegration.filter((dep)=>!canResolve(dep, [
1166
+ developRoot,
1167
+ projectPath,
1168
+ process.cwd()
1169
+ ]));
1170
+ if (0 !== missingForIntegration.length) {
1171
+ integrations.push(integration);
1172
+ dependenciesByIntegration[integration] = missingForIntegration;
1173
+ missingForIntegration.forEach((dep)=>missing.add(dep));
1174
+ }
1175
+ }
1176
+ return {
1177
+ integrations,
1178
+ dependencies: Array.from(missing),
1179
+ dependenciesByIntegration
1180
+ };
1181
+ }
1182
+ async function installBuildDependencies(developRoot, plan) {
1183
+ if (0 === plan.dependencies.length) return;
1184
+ const pm = detectPackageManagerFromEnv();
1185
+ const installMessage = installingBuildDependencies(plan.dependencies);
1186
+ const progressEnabled = shouldShowProgress();
1187
+ const progress = startProgressBar(installMessage, {
1188
+ enabled: progressEnabled,
1189
+ persistLabel: true
1190
+ });
1191
+ if (!progressEnabled) console.log(installMessage);
1192
+ try {
1193
+ const args = buildBuildInstallArgs(pm, plan.dependencies, plan.dependencyMap);
1194
+ const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
1195
+ const result = await runInstall(pm, args, {
1196
+ cwd: developRoot,
1197
+ stdio
1198
+ });
1199
+ if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
1200
+ } finally{
1201
+ progress.stop();
1202
+ }
1203
+ }
1204
+ async function installOptionalDependencies(developRoot, projectPath, plan) {
1205
+ if (0 === plan.dependencies.length) return;
1206
+ const pm = detectPackageManagerFromEnv();
1207
+ const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
1208
+ const progressEnabled = shouldShowProgress();
1209
+ console.log(foundSpecializedDependencies(plan.dependencies.length));
1210
+ for (const [index, integration] of plan.integrations.entries()){
1211
+ const missingDeps = plan.dependenciesByIntegration[integration] || [];
1212
+ const [baseMessage] = installingProjectIntegrations([
1213
+ integration
1214
+ ]);
1215
+ const installMessage = baseMessage.replace('►►► ', `►►► [${index + 1}/${plan.integrations.length}] `);
1216
+ const progress = startProgressBar(installMessage, {
1217
+ enabled: progressEnabled,
1218
+ persistLabel: true
1219
+ });
1220
+ if (!progressEnabled) console.log(installMessage);
1221
+ try {
1222
+ if (0 === missingDeps.length) continue;
1223
+ for (const dep of missingDeps){
1224
+ const args = buildOptionalInstallArgs(pm, [
1225
+ dep
1226
+ ], developRoot);
1227
+ const result = await runInstall(pm, args, {
1228
+ cwd: developRoot,
1229
+ stdio
1230
+ });
1231
+ if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
1232
+ }
1233
+ } finally{
1234
+ progress.stop();
1235
+ }
1236
+ }
1237
+ }
1238
+ async function installInternalDependencies(projectPath) {
1239
+ if ('test' === process.env.EXTENSION_ENV || 'true' === process.env.EXTENSION_SKIP_INTERNAL_INSTALL) return;
1240
+ const developRoot = resolveDevelopRoot(projectPath);
1241
+ if (!developRoot) return;
1242
+ const buildPlan = resolveMissingBuildDeps(developRoot);
1243
+ if (0 === buildPlan.dependencies.length) console.log(installingBuildDependencies(buildPlan.dependencies));
1244
+ else await installBuildDependencies(developRoot, buildPlan);
1245
+ const optionalPlan = resolveMissingOptionalDeps(developRoot, projectPath);
1246
+ if (0 === optionalPlan.dependencies.length) {
1247
+ if (optionalPlan.integrations.length > 0) installingProjectIntegrations(optionalPlan.integrations).forEach((message)=>console.log(message));
1248
+ } else await installOptionalDependencies(developRoot, projectPath, optionalPlan);
1249
+ }
1250
+ async function extensionCreate(projectNameInput, { cliVersion, template = 'init', install = false }) {
745
1251
  if (!projectNameInput) throw new Error(noProjectName());
746
1252
  if (projectNameInput.startsWith('http')) throw new Error(noUrlAllowed());
747
1253
  const projectPath = external_path_namespaceObject.isAbsolute(projectNameInput) ? projectNameInput : external_path_namespaceObject.join(process.cwd(), projectNameInput);
@@ -753,13 +1259,17 @@ async function extensionCreate(projectNameInput, { cliVersion, template = 'init'
753
1259
  template,
754
1260
  cliVersion
755
1261
  });
1262
+ if (install) {
1263
+ await installDependencies(projectPath, projectName);
1264
+ await installInternalDependencies(projectPath);
1265
+ }
756
1266
  await writeReadmeFile(projectPath, projectName);
757
1267
  await writeManifestJson(projectPath, projectName);
758
1268
  await initializeGitRepository(projectPath, projectName);
759
1269
  await writeGitignore(projectPath);
760
1270
  await setupBuiltInTests(projectPath, projectName);
761
1271
  if (isTypeScriptTemplate(template)) await generateExtensionTypes(projectPath, projectName);
762
- const successfulInstall = await successfullInstall(projectPath, projectName, false);
1272
+ const successfulInstall = await successfullInstall(projectPath, projectName, Boolean(install));
763
1273
  console.log(successfulInstall);
764
1274
  } catch (error) {
765
1275
  throw error;
package/dist/module.d.ts CHANGED
@@ -3,4 +3,4 @@ export interface CreateOptions {
3
3
  install?: boolean;
4
4
  cliVersion?: string;
5
5
  }
6
- export declare function extensionCreate(projectNameInput: string | undefined, { cliVersion, template, install: _install }: CreateOptions): Promise<void>;
6
+ export declare function extensionCreate(projectNameInput: string | undefined, { cliVersion, template, install }: CreateOptions): Promise<void>;
@@ -0,0 +1,21 @@
1
+ type OptionalDepsPlan = {
2
+ integrations: string[];
3
+ dependencies: string[];
4
+ dependenciesByIntegration: Record<string, string[]>;
5
+ };
6
+ type BuildDepsPlan = {
7
+ dependencies: string[];
8
+ dependencyMap: Record<string, string>;
9
+ };
10
+ declare function resolveDevelopRoot(projectPath: string): string | null;
11
+ declare function detectOptionalDependencies(projectPath: string): OptionalDepsPlan;
12
+ declare function resolveMissingBuildDeps(developRoot: string): BuildDepsPlan;
13
+ declare function resolveMissingOptionalDeps(developRoot: string, projectPath: string): OptionalDepsPlan;
14
+ export declare function installInternalDependencies(projectPath: string): Promise<void>;
15
+ export declare const __testing__: {
16
+ resolveDevelopRoot: typeof resolveDevelopRoot;
17
+ resolveMissingBuildDeps: typeof resolveMissingBuildDeps;
18
+ resolveMissingOptionalDeps: typeof resolveMissingOptionalDeps;
19
+ detectOptionalDependencies: typeof detectOptionalDependencies;
20
+ };
21
+ export {};
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "name": "extension-create",
26
- "version": "3.5.0-next.2",
26
+ "version": "3.5.0-next.20",
27
27
  "description": "The standalone extension creation engine for Extension.js",
28
28
  "author": {
29
29
  "name": "Cezar Augusto",
@@ -81,15 +81,15 @@
81
81
  "devDependencies": {
82
82
  "@changesets/cli": "^2.29.8",
83
83
  "@eslint/js": "^9.39.2",
84
- "@rslib/core": "^0.19.2",
84
+ "@rslib/core": "^0.19.4",
85
85
  "@types/adm-zip": "^0.5.7",
86
86
  "@types/chrome": "^0.1.33",
87
87
  "@types/cross-spawn": "^6.0.6",
88
- "@types/node": "^25.0.9",
88
+ "@types/node": "^25.2.0",
89
89
  "@types/webextension-polyfill": "0.12.4",
90
90
  "@vitest/coverage-v8": "^4.0.17",
91
91
  "eslint": "^9.39.2",
92
- "globals": "^17.0.0",
92
+ "globals": "^17.3.0",
93
93
  "prettier": "^3.8.0",
94
94
  "tsconfig": "*",
95
95
  "typescript": "5.9.3",