extension-create 3.12.0 → 3.12.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/dist/lib/messages.d.ts +0 -1
- package/dist/lib/utils.d.ts +4 -1
- package/dist/module.cjs +64 -120
- package/dist/module.d.ts +12 -1
- package/dist/steps/create-directory.d.ts +4 -1
- package/dist/steps/generate-extension-types.d.ts +4 -1
- package/dist/steps/import-external-template.d.ts +4 -1
- package/dist/steps/initialize-git-repository.d.ts +4 -1
- package/dist/steps/install-dependencies.d.ts +4 -1
- package/dist/steps/install-internal-deps.d.ts +4 -7
- package/dist/steps/setup-built-in-tests.d.ts +4 -1
- package/dist/steps/write-gitignore.d.ts +4 -1
- package/dist/steps/write-manifest-json.d.ts +4 -1
- package/dist/steps/write-package-json.d.ts +4 -1
- package/dist/steps/write-readme-file.d.ts +4 -1
- package/package.json +3 -4
package/dist/lib/messages.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ 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
19
|
export declare function foundSpecializedDependencies(count: number): string;
|
|
21
20
|
export declare function installingProjectIntegrations(integrations: string[]): string;
|
|
22
21
|
export declare function installingDependenciesFailed(gitCommand: string, gitArgs: string[], code: number | null): string;
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare function copyDirectoryWithSymlinks(source: string, destination: string): Promise<void>;
|
|
2
2
|
export declare function moveDirectoryContents(source: string, destination: string): Promise<void>;
|
|
3
3
|
export declare function getInstallCommand(): Promise<"pnpm" | "yarn" | "npm">;
|
|
4
|
-
export declare function isDirectoryWriteable(directory: string, projectName: string
|
|
4
|
+
export declare function isDirectoryWriteable(directory: string, projectName: string, logger: {
|
|
5
|
+
log(...args: any[]): void;
|
|
6
|
+
error(...args: any[]): void;
|
|
7
|
+
}): Promise<boolean>;
|
|
5
8
|
export declare function isTypeScriptTemplate(templateName: string): boolean;
|
package/dist/module.cjs
CHANGED
|
@@ -146,9 +146,6 @@ function initializingGitForRepositoryError(projectName, error) {
|
|
|
146
146
|
function installingDependencies() {
|
|
147
147
|
return `${statusPrefix} Installing project-specific dependencies... ${external_pintor_default().gray('(This may take a moment)')}`;
|
|
148
148
|
}
|
|
149
|
-
function installingBuildDependencies(dependencies) {
|
|
150
|
-
return `${statusPrefix} Installing general build dependencies... ${external_pintor_default().gray('(This may take a moment)')}`;
|
|
151
|
-
}
|
|
152
149
|
function foundSpecializedDependencies(count) {
|
|
153
150
|
return `${statusPrefix} Found ${external_pintor_default().yellow(String(count))} specialized integration${1 === count ? '' : 's'} needing installation...`;
|
|
154
151
|
}
|
|
@@ -243,15 +240,15 @@ async function moveDirectoryContents(source, destination) {
|
|
|
243
240
|
async function getInstallCommand() {
|
|
244
241
|
return detectPackageManagerFromEnv();
|
|
245
242
|
}
|
|
246
|
-
async function isDirectoryWriteable(directory, projectName) {
|
|
243
|
+
async function isDirectoryWriteable(directory, projectName, logger) {
|
|
247
244
|
try {
|
|
248
|
-
|
|
245
|
+
logger.log(folderExists(projectName));
|
|
249
246
|
await promises_namespaceObject.mkdir(directory, {
|
|
250
247
|
recursive: true
|
|
251
248
|
});
|
|
252
249
|
return true;
|
|
253
250
|
} catch (err) {
|
|
254
|
-
|
|
251
|
+
logger.log(writingDirectoryError(err));
|
|
255
252
|
return false;
|
|
256
253
|
}
|
|
257
254
|
}
|
|
@@ -262,17 +259,17 @@ const allowlist = [
|
|
|
262
259
|
'LICENSE',
|
|
263
260
|
'node_modules'
|
|
264
261
|
];
|
|
265
|
-
async function createDirectory(projectPath, projectName) {
|
|
266
|
-
|
|
262
|
+
async function createDirectory(projectPath, projectName, logger) {
|
|
263
|
+
logger.log(startingNewExtension(projectName));
|
|
267
264
|
try {
|
|
268
|
-
const isCurrentDirWriteable = await isDirectoryWriteable(projectPath, projectName);
|
|
269
|
-
|
|
265
|
+
const isCurrentDirWriteable = await isDirectoryWriteable(projectPath, projectName, logger);
|
|
266
|
+
logger.log(checkingIfPathIsWriteable());
|
|
270
267
|
if (!isCurrentDirWriteable) {
|
|
271
|
-
|
|
268
|
+
logger.error(destinationNotWriteable(projectPath));
|
|
272
269
|
throw new Error(destinationNotWriteable(projectPath));
|
|
273
270
|
}
|
|
274
271
|
const currentDir = await promises_namespaceObject.readdir(projectPath);
|
|
275
|
-
|
|
272
|
+
logger.log(scanningPossiblyConflictingFiles());
|
|
276
273
|
const conflictingFiles = await Promise.all(currentDir.filter((file)=>!file.startsWith('.')).filter((file)=>!file.endsWith('.log')).filter((file)=>!allowlist.includes(file)).map(async (file)=>{
|
|
277
274
|
const stats = await promises_namespaceObject.lstat(external_path_namespaceObject.join(projectPath, file));
|
|
278
275
|
return stats.isDirectory() ? `${file}/` : `${file}`;
|
|
@@ -326,7 +323,7 @@ async function getZipSourcePath(tempPath, templateUrl) {
|
|
|
326
323
|
if (onlyDir.name === archiveBase) return external_path_namespaceObject.join(tempPath, onlyDir.name);
|
|
327
324
|
return tempPath;
|
|
328
325
|
}
|
|
329
|
-
async function importExternalTemplate(projectPath, projectName, template) {
|
|
326
|
+
async function importExternalTemplate(projectPath, projectName, template, logger) {
|
|
330
327
|
const templateName = external_path_namespaceObject.basename(template);
|
|
331
328
|
const examplesUrl = 'https://github.com/extension-js/examples/tree/main/examples';
|
|
332
329
|
const resolvedTemplate = 'init' === templateName ? "javascript" : template;
|
|
@@ -376,7 +373,7 @@ async function importExternalTemplate(projectPath, projectName, template) {
|
|
|
376
373
|
force: true
|
|
377
374
|
});
|
|
378
375
|
} catch (error) {
|
|
379
|
-
|
|
376
|
+
logger.error(installingFromTemplateError(projectName, templateName, error));
|
|
380
377
|
throw error;
|
|
381
378
|
}
|
|
382
379
|
}
|
|
@@ -422,7 +419,7 @@ function resolveExtensionDevDependencyVersion(cliVersion) {
|
|
|
422
419
|
if (!cliVersion) return 'latest';
|
|
423
420
|
return cliVersion.includes('-') ? cliVersion : `^${cliVersion}`;
|
|
424
421
|
}
|
|
425
|
-
async function overridePackageJson(projectPath, projectName, { template = "javascript", cliVersion }) {
|
|
422
|
+
async function overridePackageJson(projectPath, projectName, { template = "javascript", cliVersion }, logger) {
|
|
426
423
|
const extensionBinary = await resolveExtensionBinary();
|
|
427
424
|
const candidatePath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
428
425
|
let packageJson = {};
|
|
@@ -465,10 +462,10 @@ async function overridePackageJson(projectPath, projectName, { template = "javas
|
|
|
465
462
|
}
|
|
466
463
|
};
|
|
467
464
|
try {
|
|
468
|
-
|
|
465
|
+
logger.log(writingPackageJsonMetadata());
|
|
469
466
|
await promises_namespaceObject.writeFile(external_path_namespaceObject.join(projectPath, 'package.json'), JSON.stringify(packageMetadata, null, 2));
|
|
470
467
|
} catch (error) {
|
|
471
|
-
|
|
468
|
+
logger.error(writingPackageJsonMetadataError(projectName, error));
|
|
472
469
|
throw error;
|
|
473
470
|
}
|
|
474
471
|
}
|
|
@@ -524,7 +521,7 @@ function getTagFallback(version) {
|
|
|
524
521
|
const cleaned = version.replace(/^[~^]/, '');
|
|
525
522
|
return cleaned.includes('-') ? 'next' : 'latest';
|
|
526
523
|
}
|
|
527
|
-
async function updateExtensionDependencyTag(projectPath, projectName) {
|
|
524
|
+
async function updateExtensionDependencyTag(projectPath, projectName, logger) {
|
|
528
525
|
const packageJsonPath = external_path_namespaceObject.join(projectPath, 'package.json');
|
|
529
526
|
try {
|
|
530
527
|
const raw = await external_fs_namespaceObject.promises.readFile(packageJsonPath, 'utf8');
|
|
@@ -540,7 +537,7 @@ async function updateExtensionDependencyTag(projectPath, projectName) {
|
|
|
540
537
|
await external_fs_namespaceObject.promises.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
541
538
|
return true;
|
|
542
539
|
} catch (error) {
|
|
543
|
-
|
|
540
|
+
logger.error(cantInstallDependencies(projectName, error));
|
|
544
541
|
return false;
|
|
545
542
|
}
|
|
546
543
|
}
|
|
@@ -565,14 +562,14 @@ async function hasDependenciesToInstall(projectPath) {
|
|
|
565
562
|
return true;
|
|
566
563
|
}
|
|
567
564
|
}
|
|
568
|
-
async function installDependencies(projectPath, projectName) {
|
|
565
|
+
async function installDependencies(projectPath, projectName, logger) {
|
|
569
566
|
const nodeModulesPath = external_path_namespaceObject.join(projectPath, 'node_modules');
|
|
570
567
|
const shouldInstall = await hasDependenciesToInstall(projectPath);
|
|
571
568
|
if (!shouldInstall) return;
|
|
572
569
|
const command = await getInstallCommand();
|
|
573
570
|
const dependenciesArgs = getInstallArgs();
|
|
574
571
|
const installMessage = installingDependencies();
|
|
575
|
-
|
|
572
|
+
logger.log(installMessage);
|
|
576
573
|
try {
|
|
577
574
|
await external_fs_namespaceObject.promises.mkdir(nodeModulesPath, {
|
|
578
575
|
recursive: true
|
|
@@ -582,7 +579,7 @@ async function installDependencies(projectPath, projectName) {
|
|
|
582
579
|
if (0 !== firstRun.code) {
|
|
583
580
|
const output = `${firstRun.stdout}\n${firstRun.stderr}`;
|
|
584
581
|
const shouldRetry = shouldRetryWithTagFallback(output);
|
|
585
|
-
const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName) : false;
|
|
582
|
+
const didUpdate = shouldRetry ? await updateExtensionDependencyTag(projectPath, projectName, logger) : false;
|
|
586
583
|
if (didUpdate) {
|
|
587
584
|
const retryRun = await install_dependencies_runInstall(command, dependenciesArgs, projectPath, stdio);
|
|
588
585
|
if (0 === retryRun.code) return;
|
|
@@ -590,8 +587,8 @@ async function installDependencies(projectPath, projectName) {
|
|
|
590
587
|
throw new Error(installingDependenciesFailed(command, dependenciesArgs, firstRun.code));
|
|
591
588
|
}
|
|
592
589
|
} catch (error) {
|
|
593
|
-
|
|
594
|
-
|
|
590
|
+
logger.error(installingDependenciesProcessError(projectName, error));
|
|
591
|
+
logger.error(cantInstallDependencies(projectName, error));
|
|
595
592
|
throw error;
|
|
596
593
|
}
|
|
597
594
|
}
|
|
@@ -638,7 +635,7 @@ async function findManifestJsonPath(projectPath) {
|
|
|
638
635
|
}
|
|
639
636
|
throw new Error(`Could not locate manifest.json under ${projectPath}. Checked common paths and searched up to depth ${manifestSearchMaxDepth}.`);
|
|
640
637
|
}
|
|
641
|
-
async function writeReadmeFile(projectPath, projectName) {
|
|
638
|
+
async function writeReadmeFile(projectPath, projectName, logger) {
|
|
642
639
|
try {
|
|
643
640
|
await promises_namespaceObject.access(external_path_namespaceObject.join(projectPath, 'README.md'));
|
|
644
641
|
return;
|
|
@@ -705,17 +702,17 @@ Learn more in the [Extension.js docs](https://extension.js.org).
|
|
|
705
702
|
const manifestJson = JSON.parse(await promises_namespaceObject.readFile(manifestJsonPath, 'utf-8'));
|
|
706
703
|
const readmeFileEdited = initTemplateReadme.replaceAll('[projectName]', projectName).replaceAll("[templateDescription]", manifestJson.description).replaceAll('[runCommand]', installCommand);
|
|
707
704
|
try {
|
|
708
|
-
|
|
705
|
+
logger.log(writingReadmeMetaData());
|
|
709
706
|
await promises_namespaceObject.mkdir(projectPath, {
|
|
710
707
|
recursive: true
|
|
711
708
|
});
|
|
712
709
|
await promises_namespaceObject.writeFile(external_path_namespaceObject.join(projectPath, 'README.md'), readmeFileEdited);
|
|
713
710
|
} catch (error) {
|
|
714
|
-
|
|
711
|
+
logger.error(writingReadmeMetaDataEError(projectName, error));
|
|
715
712
|
throw error;
|
|
716
713
|
}
|
|
717
714
|
}
|
|
718
|
-
async function writeManifestJson(projectPath, projectName) {
|
|
715
|
+
async function writeManifestJson(projectPath, projectName, logger) {
|
|
719
716
|
const manifestJsonPath = await findManifestJsonPath(projectPath);
|
|
720
717
|
const manifestJsonContent = await promises_namespaceObject.readFile(manifestJsonPath);
|
|
721
718
|
const manifestJson = JSON.parse(manifestJsonContent.toString());
|
|
@@ -725,14 +722,14 @@ async function writeManifestJson(projectPath, projectName) {
|
|
|
725
722
|
author: 'Your Name'
|
|
726
723
|
};
|
|
727
724
|
try {
|
|
728
|
-
|
|
725
|
+
logger.log(writingManifestJsonMetadata());
|
|
729
726
|
await promises_namespaceObject.writeFile(manifestJsonPath, JSON.stringify(manifestMetadata, null, 2));
|
|
730
727
|
} catch (error) {
|
|
731
|
-
|
|
728
|
+
logger.error(writingManifestJsonMetadataError(projectName, error));
|
|
732
729
|
throw error;
|
|
733
730
|
}
|
|
734
731
|
}
|
|
735
|
-
async function generateExtensionTypes(projectPath, projectName) {
|
|
732
|
+
async function generateExtensionTypes(projectPath, projectName, logger) {
|
|
736
733
|
const extensionEnvFile = external_path_namespaceObject.join(projectPath, 'extension-env.d.ts');
|
|
737
734
|
const typePath = 'extension';
|
|
738
735
|
const fileContent = `\
|
|
@@ -750,10 +747,10 @@ async function generateExtensionTypes(projectPath, projectName) {
|
|
|
750
747
|
await promises_namespaceObject.mkdir(projectPath, {
|
|
751
748
|
recursive: true
|
|
752
749
|
});
|
|
753
|
-
|
|
750
|
+
logger.log(writingTypeDefinitions(projectName));
|
|
754
751
|
await promises_namespaceObject.writeFile(extensionEnvFile, fileContent);
|
|
755
752
|
} catch (error) {
|
|
756
|
-
|
|
753
|
+
logger.error(writingTypeDefinitionsError(error));
|
|
757
754
|
throw error;
|
|
758
755
|
}
|
|
759
756
|
}
|
|
@@ -801,13 +798,13 @@ const globalLines = [
|
|
|
801
798
|
...envFiles,
|
|
802
799
|
...debugFiles
|
|
803
800
|
];
|
|
804
|
-
async function writeGitignore(projectPath) {
|
|
801
|
+
async function writeGitignore(projectPath, logger) {
|
|
805
802
|
const gitIgnorePath = external_path_namespaceObject.join(projectPath, '.gitignore');
|
|
806
803
|
const paths = new Set();
|
|
807
804
|
let currentContents = '';
|
|
808
805
|
currentContents = await promises_namespaceObject.readFile(gitIgnorePath, 'utf8').catch((err)=>{
|
|
809
806
|
if ('ENOENT' === err.code) return '';
|
|
810
|
-
|
|
807
|
+
logger.error(err);
|
|
811
808
|
throw err;
|
|
812
809
|
});
|
|
813
810
|
for (const rawLine of currentContents.split(/\r?\n/)){
|
|
@@ -817,21 +814,21 @@ async function writeGitignore(projectPath) {
|
|
|
817
814
|
const linesToAdd = globalLines.filter((line)=>!paths.has(line));
|
|
818
815
|
while('' === linesToAdd[linesToAdd.length - 1])linesToAdd.pop();
|
|
819
816
|
if (0 === linesToAdd.length) return;
|
|
820
|
-
|
|
817
|
+
logger.log(writingGitIgnore());
|
|
821
818
|
const shouldPrefixWithNewline = currentContents.length > 0 && !currentContents.endsWith('\n');
|
|
822
819
|
const contentToAppend = `${shouldPrefixWithNewline ? '\n' : ''}${linesToAdd.join('\n')}`;
|
|
823
820
|
await promises_namespaceObject.appendFile(gitIgnorePath, contentToAppend).catch((err)=>{
|
|
824
|
-
|
|
821
|
+
logger.error(err);
|
|
825
822
|
throw err;
|
|
826
823
|
});
|
|
827
824
|
}
|
|
828
|
-
async function initializeGitRepository(projectPath, projectName) {
|
|
825
|
+
async function initializeGitRepository(projectPath, projectName, logger) {
|
|
829
826
|
const gitCommand = 'git';
|
|
830
827
|
const gitArgs = [
|
|
831
828
|
'init',
|
|
832
829
|
'--quiet'
|
|
833
830
|
];
|
|
834
|
-
|
|
831
|
+
logger.log(initializingGitForRepository(projectName));
|
|
835
832
|
try {
|
|
836
833
|
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
|
|
837
834
|
const child = (0, external_cross_spawn_namespaceObject.spawn)(gitCommand, gitArgs, {
|
|
@@ -844,21 +841,21 @@ async function initializeGitRepository(projectPath, projectName) {
|
|
|
844
841
|
else resolve();
|
|
845
842
|
});
|
|
846
843
|
child.on('error', (error)=>{
|
|
847
|
-
|
|
844
|
+
logger.error(initializingGitForRepositoryProcessError(projectName, error));
|
|
848
845
|
reject(error);
|
|
849
846
|
});
|
|
850
847
|
});
|
|
851
848
|
} catch (error) {
|
|
852
|
-
|
|
849
|
+
logger.error(initializingGitForRepositoryError(projectName, error));
|
|
853
850
|
throw error;
|
|
854
851
|
}
|
|
855
852
|
}
|
|
856
|
-
async function setupBuiltInTests(projectPath, projectName) {
|
|
853
|
+
async function setupBuiltInTests(projectPath, projectName, logger) {
|
|
857
854
|
try {
|
|
858
855
|
const testSpecPath = external_path_namespaceObject.join(projectPath, 'tests', 'templates.spec.ts');
|
|
859
856
|
if (external_fs_namespaceObject.existsSync(testSpecPath)) external_fs_namespaceObject.unlinkSync(testSpecPath);
|
|
860
857
|
} catch (error) {
|
|
861
|
-
|
|
858
|
+
logger.error(cantSetupBuiltInTests(projectName, error));
|
|
862
859
|
throw error;
|
|
863
860
|
}
|
|
864
861
|
}
|
|
@@ -884,17 +881,6 @@ function resolveDevelopRoot(projectPath) {
|
|
|
884
881
|
return null;
|
|
885
882
|
}
|
|
886
883
|
}
|
|
887
|
-
function resolveBuildDepsPath(developRoot) {
|
|
888
|
-
return external_path_namespaceObject.join(developRoot, 'webpack', 'webpack-lib', 'build-dependencies.json');
|
|
889
|
-
}
|
|
890
|
-
function loadBuildDependencies(developRoot) {
|
|
891
|
-
const metadataPath = resolveBuildDepsPath(developRoot);
|
|
892
|
-
if (!external_fs_namespaceObject.existsSync(metadataPath)) {
|
|
893
|
-
console.warn(`${installingBuildDependencies([])} (build-dependencies.json missing; skipping build deps install)`);
|
|
894
|
-
return {};
|
|
895
|
-
}
|
|
896
|
-
return JSON.parse(external_fs_namespaceObject.readFileSync(metadataPath, 'utf8'));
|
|
897
|
-
}
|
|
898
884
|
function readPackageJson(projectPath) {
|
|
899
885
|
try {
|
|
900
886
|
const raw = external_fs_namespaceObject.readFileSync(external_path_namespaceObject.join(projectPath, 'package.json'), 'utf8');
|
|
@@ -1029,39 +1015,6 @@ function buildOptionalInstallArgs(pm, dependencies, installDir) {
|
|
|
1029
1015
|
'--legacy-peer-deps'
|
|
1030
1016
|
];
|
|
1031
1017
|
}
|
|
1032
|
-
function buildBuildInstallArgs(pm, dependencies, dependencyMap) {
|
|
1033
|
-
const depsWithVersions = dependencies.map((dep)=>`${dep}@${dependencyMap[dep]}`);
|
|
1034
|
-
if ('yarn' === pm) return [
|
|
1035
|
-
'add',
|
|
1036
|
-
...depsWithVersions
|
|
1037
|
-
];
|
|
1038
|
-
if ('pnpm' === pm) return [
|
|
1039
|
-
'add',
|
|
1040
|
-
'--save',
|
|
1041
|
-
...depsWithVersions
|
|
1042
|
-
];
|
|
1043
|
-
if ('bun' === pm) return [
|
|
1044
|
-
'add',
|
|
1045
|
-
...depsWithVersions
|
|
1046
|
-
];
|
|
1047
|
-
return [
|
|
1048
|
-
'install',
|
|
1049
|
-
'--save',
|
|
1050
|
-
...depsWithVersions
|
|
1051
|
-
];
|
|
1052
|
-
}
|
|
1053
|
-
function resolveMissingBuildDeps(developRoot) {
|
|
1054
|
-
const dependencyMap = loadBuildDependencies(developRoot);
|
|
1055
|
-
const candidates = Object.keys(dependencyMap);
|
|
1056
|
-
const missing = candidates.filter((dep)=>!canResolve(dep, [
|
|
1057
|
-
developRoot,
|
|
1058
|
-
process.cwd()
|
|
1059
|
-
]));
|
|
1060
|
-
return {
|
|
1061
|
-
dependencies: missing,
|
|
1062
|
-
dependencyMap
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
1018
|
function resolveMissingOptionalDeps(developRoot, projectPath) {
|
|
1066
1019
|
const plan = detectOptionalDependencies(projectPath);
|
|
1067
1020
|
const dependenciesByIntegration = {};
|
|
@@ -1086,31 +1039,18 @@ function resolveMissingOptionalDeps(developRoot, projectPath) {
|
|
|
1086
1039
|
dependenciesByIntegration
|
|
1087
1040
|
};
|
|
1088
1041
|
}
|
|
1089
|
-
async function
|
|
1042
|
+
async function installOptionalDependencies(developRoot, projectPath, plan, logger) {
|
|
1090
1043
|
if (0 === plan.dependencies.length) return;
|
|
1091
1044
|
const pm = detectPackageManagerFromEnv();
|
|
1092
|
-
const installMessage = installingBuildDependencies(plan.dependencies);
|
|
1093
|
-
console.log(installMessage);
|
|
1094
|
-
const args = buildBuildInstallArgs(pm, plan.dependencies, plan.dependencyMap);
|
|
1095
1045
|
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
|
|
1096
|
-
|
|
1097
|
-
cwd: developRoot,
|
|
1098
|
-
stdio
|
|
1099
|
-
});
|
|
1100
|
-
if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
|
|
1101
|
-
}
|
|
1102
|
-
async function installOptionalDependencies(developRoot, projectPath, plan) {
|
|
1103
|
-
if (0 === plan.dependencies.length) return;
|
|
1104
|
-
const pm = detectPackageManagerFromEnv();
|
|
1105
|
-
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
|
|
1106
|
-
console.log(foundSpecializedDependencies(plan.integrations.length));
|
|
1046
|
+
logger.log(foundSpecializedDependencies(plan.integrations.length));
|
|
1107
1047
|
for (const [index, integration] of plan.integrations.entries()){
|
|
1108
1048
|
const missingDeps = plan.dependenciesByIntegration[integration] || [];
|
|
1109
1049
|
const baseMessage = installingProjectIntegrations([
|
|
1110
1050
|
integration
|
|
1111
1051
|
]);
|
|
1112
1052
|
const installMessage = baseMessage.replace('⏵⏵⏵ ', `⏵⏵⏵ [${index + 1}/${plan.integrations.length}] `);
|
|
1113
|
-
|
|
1053
|
+
logger.log(installMessage);
|
|
1114
1054
|
if (0 === missingDeps.length) continue;
|
|
1115
1055
|
const args = buildOptionalInstallArgs(pm, missingDeps, developRoot);
|
|
1116
1056
|
const result = await runInstall(pm, args, {
|
|
@@ -1120,39 +1060,43 @@ async function installOptionalDependencies(developRoot, projectPath, plan) {
|
|
|
1120
1060
|
if (0 !== result.code) throw new Error(installingDependenciesFailed(pm, args, result.code));
|
|
1121
1061
|
}
|
|
1122
1062
|
}
|
|
1123
|
-
async function installInternalDependencies(projectPath) {
|
|
1063
|
+
async function installInternalDependencies(projectPath, logger) {
|
|
1124
1064
|
if ('test' === process.env.EXTENSION_ENV || 'true' === process.env.EXTENSION_SKIP_INTERNAL_INSTALL) return;
|
|
1125
1065
|
const developRoot = resolveDevelopRoot(projectPath);
|
|
1126
1066
|
if (!developRoot) return;
|
|
1127
|
-
const buildPlan = resolveMissingBuildDeps(developRoot);
|
|
1128
|
-
if (buildPlan.dependencies.length > 0) await installBuildDependencies(developRoot, buildPlan);
|
|
1129
1067
|
const optionalPlan = resolveMissingOptionalDeps(developRoot, projectPath);
|
|
1130
|
-
if (optionalPlan.dependencies.length > 0) await installOptionalDependencies(developRoot, projectPath, optionalPlan);
|
|
1068
|
+
if (optionalPlan.dependencies.length > 0) await installOptionalDependencies(developRoot, projectPath, optionalPlan, logger);
|
|
1131
1069
|
}
|
|
1132
|
-
async function extensionCreate(projectNameInput, { cliVersion, template = "javascript", install = false }) {
|
|
1070
|
+
async function extensionCreate(projectNameInput, { cliVersion, template = "javascript", install = false, logger = console }) {
|
|
1133
1071
|
if (!projectNameInput) throw new Error(noProjectName());
|
|
1134
1072
|
if (projectNameInput.startsWith('http')) throw new Error(noUrlAllowed());
|
|
1135
1073
|
const projectPath = external_path_namespaceObject.isAbsolute(projectNameInput) ? projectNameInput : external_path_namespaceObject.join(process.cwd(), projectNameInput);
|
|
1136
1074
|
const projectName = external_path_namespaceObject.basename(projectPath);
|
|
1137
1075
|
try {
|
|
1138
|
-
await createDirectory(projectPath, projectName);
|
|
1139
|
-
await importExternalTemplate(projectPath, projectName, template);
|
|
1076
|
+
await createDirectory(projectPath, projectName, logger);
|
|
1077
|
+
await importExternalTemplate(projectPath, projectName, template, logger);
|
|
1140
1078
|
await overridePackageJson(projectPath, projectName, {
|
|
1141
1079
|
template,
|
|
1142
1080
|
cliVersion
|
|
1143
|
-
});
|
|
1081
|
+
}, logger);
|
|
1144
1082
|
if (install) {
|
|
1145
|
-
await installDependencies(projectPath, projectName);
|
|
1146
|
-
await installInternalDependencies(projectPath);
|
|
1083
|
+
await installDependencies(projectPath, projectName, logger);
|
|
1084
|
+
await installInternalDependencies(projectPath, logger);
|
|
1147
1085
|
}
|
|
1148
|
-
await writeReadmeFile(projectPath, projectName);
|
|
1149
|
-
await writeManifestJson(projectPath, projectName);
|
|
1150
|
-
await initializeGitRepository(projectPath, projectName);
|
|
1151
|
-
await writeGitignore(projectPath);
|
|
1152
|
-
await setupBuiltInTests(projectPath, projectName);
|
|
1153
|
-
if (isTypeScriptTemplate(template)) await generateExtensionTypes(projectPath, projectName);
|
|
1086
|
+
await writeReadmeFile(projectPath, projectName, logger);
|
|
1087
|
+
await writeManifestJson(projectPath, projectName, logger);
|
|
1088
|
+
await initializeGitRepository(projectPath, projectName, logger);
|
|
1089
|
+
await writeGitignore(projectPath, logger);
|
|
1090
|
+
await setupBuiltInTests(projectPath, projectName, logger);
|
|
1091
|
+
if (isTypeScriptTemplate(template)) await generateExtensionTypes(projectPath, projectName, logger);
|
|
1154
1092
|
const successfulInstall = await successfullInstall(projectPath, projectName, Boolean(install));
|
|
1155
|
-
|
|
1093
|
+
logger.log(successfulInstall);
|
|
1094
|
+
return {
|
|
1095
|
+
projectPath,
|
|
1096
|
+
projectName,
|
|
1097
|
+
template,
|
|
1098
|
+
depsInstalled: install
|
|
1099
|
+
};
|
|
1156
1100
|
} catch (error) {
|
|
1157
1101
|
throw error;
|
|
1158
1102
|
}
|
package/dist/module.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
export interface CreateLogger {
|
|
2
|
+
log: (...args: any[]) => void;
|
|
3
|
+
error: (...args: any[]) => void;
|
|
4
|
+
}
|
|
1
5
|
export interface CreateOptions {
|
|
2
6
|
template?: string;
|
|
3
7
|
install?: boolean;
|
|
4
8
|
cliVersion?: string;
|
|
9
|
+
logger?: CreateLogger;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateResult {
|
|
12
|
+
projectPath: string;
|
|
13
|
+
projectName: string;
|
|
14
|
+
template: string;
|
|
15
|
+
depsInstalled: boolean;
|
|
5
16
|
}
|
|
6
|
-
export declare function extensionCreate(projectNameInput: string | undefined, { cliVersion, template, install }: CreateOptions): Promise<
|
|
17
|
+
export declare function extensionCreate(projectNameInput: string | undefined, { cliVersion, template, install, logger }: CreateOptions): Promise<CreateResult>;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function generateExtensionTypes(projectPath: string, projectName: string
|
|
1
|
+
export declare function generateExtensionTypes(projectPath: string, projectName: string, logger: {
|
|
2
|
+
log(...args: any[]): void;
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
}): Promise<void>;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function importExternalTemplate(projectPath: string, projectName: string, template: string
|
|
1
|
+
export declare function importExternalTemplate(projectPath: string, projectName: string, template: string, logger: {
|
|
2
|
+
log(...args: any[]): void;
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
}): Promise<void>;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function initializeGitRepository(projectPath: string, projectName: string
|
|
1
|
+
export declare function initializeGitRepository(projectPath: string, projectName: string, logger: {
|
|
2
|
+
log(...args: any[]): void;
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
}): Promise<void>;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function installDependencies(projectPath: string, projectName: string
|
|
1
|
+
export declare function installDependencies(projectPath: string, projectName: string, logger: {
|
|
2
|
+
log(...args: any[]): void;
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
}): Promise<void>;
|
|
@@ -3,18 +3,15 @@ type OptionalDepsPlan = {
|
|
|
3
3
|
dependencies: string[];
|
|
4
4
|
dependenciesByIntegration: Record<string, string[]>;
|
|
5
5
|
};
|
|
6
|
-
type BuildDepsPlan = {
|
|
7
|
-
dependencies: string[];
|
|
8
|
-
dependencyMap: Record<string, string>;
|
|
9
|
-
};
|
|
10
6
|
declare function resolveDevelopRoot(projectPath: string): string | null;
|
|
11
7
|
declare function detectOptionalDependencies(projectPath: string): OptionalDepsPlan;
|
|
12
|
-
declare function resolveMissingBuildDeps(developRoot: string): BuildDepsPlan;
|
|
13
8
|
declare function resolveMissingOptionalDeps(developRoot: string, projectPath: string): OptionalDepsPlan;
|
|
14
|
-
export declare function installInternalDependencies(projectPath: string
|
|
9
|
+
export declare function installInternalDependencies(projectPath: string, logger: {
|
|
10
|
+
log(...args: any[]): void;
|
|
11
|
+
error(...args: any[]): void;
|
|
12
|
+
}): Promise<void>;
|
|
15
13
|
export declare const __testing__: {
|
|
16
14
|
resolveDevelopRoot: typeof resolveDevelopRoot;
|
|
17
|
-
resolveMissingBuildDeps: typeof resolveMissingBuildDeps;
|
|
18
15
|
resolveMissingOptionalDeps: typeof resolveMissingOptionalDeps;
|
|
19
16
|
detectOptionalDependencies: typeof detectOptionalDependencies;
|
|
20
17
|
};
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function setupBuiltInTests(projectPath: string, projectName: string
|
|
1
|
+
export declare function setupBuiltInTests(projectPath: string, projectName: string, logger: {
|
|
2
|
+
log(...args: any[]): void;
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
}): Promise<void>;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export declare function writeManifestJson(projectPath: string, projectName: string
|
|
1
|
+
export declare function writeManifestJson(projectPath: string, projectName: string, logger: {
|
|
2
|
+
log(...args: any[]): void;
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
}): Promise<void>;
|
|
@@ -3,5 +3,8 @@ interface OverridePackageJsonOptions {
|
|
|
3
3
|
template?: string;
|
|
4
4
|
cliVersion?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function overridePackageJson(projectPath: string, projectName: string, { template, cliVersion }: OverridePackageJsonOptions
|
|
6
|
+
export declare function overridePackageJson(projectPath: string, projectName: string, { template, cliVersion }: OverridePackageJsonOptions, logger: {
|
|
7
|
+
log(...args: any[]): void;
|
|
8
|
+
error(...args: any[]): void;
|
|
9
|
+
}): Promise<void>;
|
|
7
10
|
export {};
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"name": "extension-create",
|
|
27
|
-
"version": "3.12.
|
|
27
|
+
"version": "3.12.2",
|
|
28
28
|
"description": "The standalone extension creation engine for Extension.js",
|
|
29
29
|
"author": {
|
|
30
30
|
"name": "Cezar Augusto",
|
|
@@ -73,11 +73,10 @@
|
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"adm-zip": "^0.5.16",
|
|
76
|
-
"axios": "^1.
|
|
76
|
+
"axios": "^1.15.0",
|
|
77
77
|
"cross-spawn": "^7.0.6",
|
|
78
78
|
"go-git-it": "^5.1.5",
|
|
79
|
-
"pintor": "0.3.0"
|
|
80
|
-
"tiny-glob": "^0.2.9"
|
|
79
|
+
"pintor": "0.3.0"
|
|
81
80
|
},
|
|
82
81
|
"devDependencies": {
|
|
83
82
|
"@biomejs/biome": "^2.2.4",
|