extension-create 4.0.24 → 4.0.25
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/git-identity.d.ts +6 -0
- package/dist/lib/messages.d.ts +4 -0
- package/dist/lib/package-manager.d.ts +4 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/module.cjs +181 -37
- package/dist/steps/initialize-git-repository.d.ts +2 -1
- package/dist/steps/write-manifest-json.d.ts +1 -1
- package/dist/steps/write-store-metadata.d.ts +6 -0
- package/dist/test-template-javascript/.extension-create.json +1 -1
- package/dist/test-template-javascript/README.md +1 -1
- package/dist/test-template-javascript/STORE.md +3 -3
- package/dist/test-template-javascript/package.json +2 -7
- package/dist/test-template-javascript/src/manifest.json +2 -3
- package/package.json +1 -1
- package/templates/javascript/README.md +1 -1
- package/templates/javascript/STORE.md +2 -2
- package/templates/javascript/package.json +1 -1
- package/templates/javascript/src/manifest.json +1 -1
package/dist/lib/messages.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ export declare function createDirectoryError(projectName: string, error: unknown
|
|
|
8
8
|
export declare function writingTypeDefinitions(projectName: string): string;
|
|
9
9
|
export declare function writingTypeDefinitionsError(error: unknown): string;
|
|
10
10
|
export declare function installingFromTemplate(projectName: string, templateName: string): string;
|
|
11
|
+
export declare function usingTemplate(templateName: string, source: string): string;
|
|
11
12
|
export declare function installingFromTemplateError(template: string, error: unknown): string;
|
|
12
13
|
export declare function templateFetchTimedOut(templateName: string, ms: number): string;
|
|
13
14
|
export declare function templateNotFoundInCatalog(templateName: string, error?: unknown): string;
|
|
14
15
|
export declare function templateDownloadFailed(templateName: string, error: unknown): string;
|
|
15
16
|
export declare function initializingGitForRepository(projectName: string): string;
|
|
16
17
|
export declare function initializingGitSkipped(projectName: string, reason: string): string;
|
|
18
|
+
export declare function firstCommitSkipped(projectName: string, reason: string): string;
|
|
17
19
|
export declare function installingDependencies(): string;
|
|
18
20
|
export declare function foundSpecializedDependencies(count: number): string;
|
|
19
21
|
export declare function installingProjectIntegrations(integrations: string[]): string;
|
|
@@ -28,6 +30,8 @@ export declare function writingTemplateProvenance(): string;
|
|
|
28
30
|
export declare function writingTemplateProvenanceError(error: unknown): string;
|
|
29
31
|
export declare function writingManifestJsonMetadata(): string;
|
|
30
32
|
export declare function writingManifestJsonMetadataError(error: unknown): string;
|
|
33
|
+
export declare function writingStoreMetadata(projectName: string): string;
|
|
34
|
+
export declare function writingStoreMetadataError(error: unknown): string;
|
|
31
35
|
export declare function writingReadmeMetaData(): string;
|
|
32
36
|
export declare function writingGitIgnore(): string;
|
|
33
37
|
export declare function writingReadmeMetaDataError(error: unknown): string;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getPackageManagerSpec as getPackageManagerSpecFromEnv } from 'prefers-yarn';
|
|
2
|
+
declare const NODE_PACKAGE_MANAGERS: readonly ['pnpm', 'yarn', 'bun', 'npm'];
|
|
3
|
+
type NodePackageManager = (typeof NODE_PACKAGE_MANAGERS)[number];
|
|
4
|
+
export declare function detectPackageManagerFromEnv(): NodePackageManager;
|
|
2
5
|
export declare function isDenoRuntime(): boolean;
|
|
3
6
|
export type ScaffoldPackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'deno';
|
|
4
7
|
export declare function resolveScaffoldPackageManager(): ScaffoldPackageManager;
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
-
export declare function getInstallCommand(): Promise<
|
|
3
|
+
export declare function getInstallCommand(): Promise<"bun" | "npm" | "pnpm" | "yarn">;
|
|
4
4
|
export declare function isDirectoryWriteable(directory: string, logger: {
|
|
5
5
|
log(...args: unknown[]): void;
|
|
6
6
|
error(...args: unknown[]): void;
|
package/dist/module.cjs
CHANGED
|
@@ -115,12 +115,25 @@ new Set([
|
|
|
115
115
|
'waterfox'
|
|
116
116
|
]);
|
|
117
117
|
const external_prefers_yarn_namespaceObject = require("prefers-yarn");
|
|
118
|
+
const NODE_PACKAGE_MANAGERS = [
|
|
119
|
+
'pnpm',
|
|
120
|
+
'yarn',
|
|
121
|
+
'bun',
|
|
122
|
+
'npm'
|
|
123
|
+
];
|
|
124
|
+
function detectPackageManagerFromEnv() {
|
|
125
|
+
const userAgent = (process.env.npm_config_user_agent || '').toLowerCase();
|
|
126
|
+
for (const manager of NODE_PACKAGE_MANAGERS)if (userAgent.includes(`${manager}/`)) return manager;
|
|
127
|
+
const execPath = (process.env.npm_execpath || process.env.NPM_EXEC_PATH || '').toLowerCase();
|
|
128
|
+
for (const manager of NODE_PACKAGE_MANAGERS)if (execPath.includes(manager)) return manager;
|
|
129
|
+
return 'npm';
|
|
130
|
+
}
|
|
118
131
|
function isDenoRuntime() {
|
|
119
132
|
return void 0 !== globalThis.Deno || Boolean(process.versions?.deno);
|
|
120
133
|
}
|
|
121
134
|
function resolveScaffoldPackageManager() {
|
|
122
135
|
if (isDenoRuntime()) return 'deno';
|
|
123
|
-
return
|
|
136
|
+
return detectPackageManagerFromEnv();
|
|
124
137
|
}
|
|
125
138
|
function destinationNotWriteable(workingDir) {
|
|
126
139
|
const workingDirFolder = external_node_path_namespaceObject.basename(workingDir);
|
|
@@ -185,6 +198,10 @@ function installingFromTemplate(projectName, templateName) {
|
|
|
185
198
|
if ('init' === templateName || "javascript" === templateName) return `${prefix('info')} Copying the template files…`;
|
|
186
199
|
return `${prefix('info')} Copying the template ${external_pintor_default().blue(templateName)}…`;
|
|
187
200
|
}
|
|
201
|
+
function usingTemplate(templateName, source) {
|
|
202
|
+
const origin = 'bundled' === source ? 'bundled with this CLI' : `from ${fmt.val(fmt.truncate(source, 120))}`;
|
|
203
|
+
return `${prefix('info')} Using the ${external_pintor_default().blue(templateName)} template, ${origin}.`;
|
|
204
|
+
}
|
|
188
205
|
function installingFromTemplateError(template, error) {
|
|
189
206
|
return `${prefix('error')} Couldn't find the template ${external_pintor_default().blue(template)}.\n${fmt.label('REASON')} ${fmt.val(fmt.truncate(String(error)))}\n${external_pintor_default().red('Choose a template name from')} ${external_pintor_default().blue('extension create --help')}${external_pintor_default().red(', or pass a GitHub URL.')}`;
|
|
190
207
|
}
|
|
@@ -203,6 +220,9 @@ function initializingGitForRepository(projectName) {
|
|
|
203
220
|
function initializingGitSkipped(projectName, reason) {
|
|
204
221
|
return `${prefix('warn')} Skipping the git init for ${external_pintor_default().blue(projectName)}.\n${fmt.label('REASON')} ${fmt.val(reason)}\nRun ${external_pintor_default().blue('git init')} yourself if you want version control.`;
|
|
205
222
|
}
|
|
223
|
+
function firstCommitSkipped(projectName, reason) {
|
|
224
|
+
return `${prefix('warn')} Left ${external_pintor_default().blue(projectName)} uncommitted.\n${fmt.label('REASON')} ${fmt.val(reason)}\nRun ${external_pintor_default().blue('git add -A && git commit')} to record the scaffold.`;
|
|
225
|
+
}
|
|
206
226
|
function installingDependencies() {
|
|
207
227
|
return `${prefix('info')} Installing the dependencies…\n${external_pintor_default().gray('This can take a moment.')}`;
|
|
208
228
|
}
|
|
@@ -252,6 +272,12 @@ function writingManifestJsonMetadata() {
|
|
|
252
272
|
function writingManifestJsonMetadataError(error) {
|
|
253
273
|
return `${prefix('error')} Couldn't write ${external_pintor_default().blue('manifest.json')}.\n${fmt.label('REASON')} ${fmt.val(fmt.truncate(String(error)))}\n${external_pintor_default().red('Check the file permissions, then try again.')}`;
|
|
254
274
|
}
|
|
275
|
+
function writingStoreMetadata(projectName) {
|
|
276
|
+
return `${prefix('debug')} create write file=STORE.md name=${projectName}`;
|
|
277
|
+
}
|
|
278
|
+
function writingStoreMetadataError(error) {
|
|
279
|
+
return `${prefix('warn')} Couldn't update ${external_pintor_default().blue('STORE.md')}.\n${fmt.label('REASON')} ${fmt.val(fmt.truncate(String(error)))}\nEdit the listing name in ${external_pintor_default().blue('STORE.md')} before you submit.`;
|
|
280
|
+
}
|
|
255
281
|
function writingReadmeMetaData() {
|
|
256
282
|
return `${prefix('debug')} create write file=README.md`;
|
|
257
283
|
}
|
|
@@ -335,7 +361,7 @@ async function moveDirectoryContents(source, destination) {
|
|
|
335
361
|
});
|
|
336
362
|
}
|
|
337
363
|
async function getInstallCommand() {
|
|
338
|
-
return
|
|
364
|
+
return detectPackageManagerFromEnv();
|
|
339
365
|
}
|
|
340
366
|
async function isDirectoryWriteable(directory, logger) {
|
|
341
367
|
try {
|
|
@@ -687,30 +713,98 @@ async function importExternalTemplate(projectPath, projectName, template, logger
|
|
|
687
713
|
}
|
|
688
714
|
}
|
|
689
715
|
const external_cross_spawn_namespaceObject = require("cross-spawn");
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
716
|
+
function readGitConfig(key, cwd) {
|
|
717
|
+
try {
|
|
718
|
+
const result = (0, external_cross_spawn_namespaceObject.sync)('git', [
|
|
719
|
+
'config',
|
|
720
|
+
'--get',
|
|
721
|
+
key
|
|
722
|
+
], {
|
|
723
|
+
cwd,
|
|
724
|
+
encoding: 'utf8',
|
|
725
|
+
stdio: [
|
|
726
|
+
'ignore',
|
|
727
|
+
'pipe',
|
|
728
|
+
'ignore'
|
|
729
|
+
]
|
|
730
|
+
});
|
|
731
|
+
if (0 !== result.status) return;
|
|
732
|
+
const value = String(result.stdout || '').trim();
|
|
733
|
+
return value || void 0;
|
|
734
|
+
} catch {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function readGitIdentity(cwd = process.cwd()) {
|
|
739
|
+
return {
|
|
740
|
+
name: readGitConfig('user.name', cwd),
|
|
741
|
+
email: readGitConfig('user.email', cwd)
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function hasGitIdentity(identity) {
|
|
745
|
+
return Boolean(identity.name && identity.email);
|
|
746
|
+
}
|
|
747
|
+
const COMMIT_SUBJECT_LIMIT = 72;
|
|
748
|
+
function firstCommitSubject(projectName, templateName) {
|
|
749
|
+
const withTemplate = templateName ? `Create ${projectName} from the ${templateName} template` : '';
|
|
750
|
+
if (withTemplate && withTemplate.length <= COMMIT_SUBJECT_LIMIT) return withTemplate;
|
|
751
|
+
const bare = `Create ${projectName}`;
|
|
752
|
+
return bare.length <= COMMIT_SUBJECT_LIMIT ? bare : 'Initial commit';
|
|
753
|
+
}
|
|
754
|
+
async function runGit(args, projectPath) {
|
|
697
755
|
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
|
|
698
|
-
const child = (0, external_cross_spawn_namespaceObject.spawn)(
|
|
756
|
+
const child = (0, external_cross_spawn_namespaceObject.spawn)('git', args, {
|
|
699
757
|
stdio,
|
|
700
|
-
cwd: projectPath
|
|
758
|
+
cwd: projectPath,
|
|
759
|
+
env: {
|
|
760
|
+
...process.env,
|
|
761
|
+
GIT_TERMINAL_PROMPT: '0'
|
|
762
|
+
}
|
|
701
763
|
});
|
|
702
|
-
await new Promise((resolve)=>{
|
|
764
|
+
return await new Promise((resolve)=>{
|
|
703
765
|
child.on('close', (code)=>{
|
|
704
|
-
if (0
|
|
705
|
-
|
|
766
|
+
if (0 === code) return resolve({
|
|
767
|
+
ok: true
|
|
768
|
+
});
|
|
769
|
+
resolve({
|
|
770
|
+
ok: false,
|
|
771
|
+
reason: `git ${args[0]} exited with ${code}`
|
|
772
|
+
});
|
|
706
773
|
});
|
|
707
774
|
child.on('error', (error)=>{
|
|
708
775
|
const reason = error?.code === 'ENOENT' ? 'git not found' : String(error?.message || error);
|
|
709
|
-
|
|
710
|
-
|
|
776
|
+
resolve({
|
|
777
|
+
ok: false,
|
|
778
|
+
reason
|
|
779
|
+
});
|
|
711
780
|
});
|
|
712
781
|
});
|
|
713
782
|
}
|
|
783
|
+
async function initializeGitRepository(projectPath, projectName, templateName, logger) {
|
|
784
|
+
if (isDebug()) logger.log(initializingGitForRepository(projectName));
|
|
785
|
+
const init = await runGit([
|
|
786
|
+
'init',
|
|
787
|
+
'--quiet'
|
|
788
|
+
], projectPath);
|
|
789
|
+
if (!init.ok) return void logger.log(initializingGitSkipped(projectName, init.reason || ''));
|
|
790
|
+
const identity = readGitIdentity(projectPath);
|
|
791
|
+
if (!hasGitIdentity(identity)) return void logger.log(firstCommitSkipped(projectName, 'no git user identity'));
|
|
792
|
+
const staged = await runGit([
|
|
793
|
+
'add',
|
|
794
|
+
'--all'
|
|
795
|
+
], projectPath);
|
|
796
|
+
if (!staged.ok) return void logger.log(firstCommitSkipped(projectName, staged.reason || ''));
|
|
797
|
+
const committed = await runGit([
|
|
798
|
+
'-c',
|
|
799
|
+
'commit.gpgsign=false',
|
|
800
|
+
'commit',
|
|
801
|
+
'--quiet',
|
|
802
|
+
'--no-verify',
|
|
803
|
+
'--message',
|
|
804
|
+
firstCommitSubject(projectName, templateName)
|
|
805
|
+
], projectPath);
|
|
806
|
+
if (!committed.ok) logger.log(firstCommitSkipped(projectName, committed.reason || ''));
|
|
807
|
+
}
|
|
714
808
|
function buildExecEnv() {
|
|
715
809
|
if ('win32' !== process.platform) return;
|
|
716
810
|
const nodeDir = external_node_path_namespaceObject.dirname(process.execPath);
|
|
@@ -1142,7 +1236,7 @@ function resolveMissingOptionalDeps(developRoot, projectPath) {
|
|
|
1142
1236
|
}
|
|
1143
1237
|
async function installOptionalDependencies(developRoot, projectPath, plan, logger) {
|
|
1144
1238
|
if (0 === plan.dependencies.length) return;
|
|
1145
|
-
const pm =
|
|
1239
|
+
const pm = detectPackageManagerFromEnv();
|
|
1146
1240
|
const stdio = 'development' === process.env.EXTENSION_ENV ? 'inherit' : 'ignore';
|
|
1147
1241
|
if (isDebug()) logger.log(foundSpecializedDependencies(plan.integrations.length));
|
|
1148
1242
|
const infoPrefix = prefix('info');
|
|
@@ -1276,9 +1370,10 @@ async function overridePackageJson(projectPath, { template = "javascript", cliVe
|
|
|
1276
1370
|
const usesMlNativeDeps = ML_DEP_TRIGGERS.some((dep)=>declaredDeps[dep]);
|
|
1277
1371
|
const nativeBuildDeps = usesMlNativeDeps ? ML_NATIVE_BUILD_DEPENDENCIES : [];
|
|
1278
1372
|
const existingPnpm = packageJson.pnpm && 'object' == typeof packageJson.pnpm ? packageJson.pnpm : {};
|
|
1373
|
+
const installsWithPnpm = String(packageManagerSpec || '').startsWith('pnpm@') || 'pnpm' === resolveScaffoldPackageManager();
|
|
1279
1374
|
const ignoredBuilt = uniq([
|
|
1280
1375
|
...existingPnpm.ignoredBuiltDependencies || [],
|
|
1281
|
-
...BUILD_NOOP_DEPENDENCIES
|
|
1376
|
+
...installsWithPnpm ? BUILD_NOOP_DEPENDENCIES : []
|
|
1282
1377
|
]);
|
|
1283
1378
|
const onlyBuilt = uniq([
|
|
1284
1379
|
...existingPnpm.onlyBuiltDependencies || [],
|
|
@@ -1288,8 +1383,28 @@ async function overridePackageJson(projectPath, { template = "javascript", cliVe
|
|
|
1288
1383
|
...packageJson.trustedDependencies || [],
|
|
1289
1384
|
...nativeBuildDeps
|
|
1290
1385
|
]);
|
|
1386
|
+
const pnpmSettings = {
|
|
1387
|
+
...existingPnpm,
|
|
1388
|
+
...ignoredBuilt.length ? {
|
|
1389
|
+
ignoredBuiltDependencies: ignoredBuilt
|
|
1390
|
+
} : {},
|
|
1391
|
+
...onlyBuilt.length ? {
|
|
1392
|
+
onlyBuiltDependencies: onlyBuilt
|
|
1393
|
+
} : {}
|
|
1394
|
+
};
|
|
1395
|
+
const identity = readGitIdentity(projectPath);
|
|
1396
|
+
const author = identity.name ? {
|
|
1397
|
+
name: identity.name,
|
|
1398
|
+
...identity.email ? {
|
|
1399
|
+
email: identity.email
|
|
1400
|
+
} : {}
|
|
1401
|
+
} : void 0;
|
|
1402
|
+
const templateFields = {
|
|
1403
|
+
...packageJson
|
|
1404
|
+
};
|
|
1405
|
+
delete templateFields.author;
|
|
1291
1406
|
const packageMetadata = {
|
|
1292
|
-
...
|
|
1407
|
+
...templateFields,
|
|
1293
1408
|
name: external_node_path_namespaceObject.basename(projectPath),
|
|
1294
1409
|
private: true,
|
|
1295
1410
|
...packageManagerSpec ? {
|
|
@@ -1301,23 +1416,15 @@ async function overridePackageJson(projectPath, { template = "javascript", cliVe
|
|
|
1301
1416
|
},
|
|
1302
1417
|
dependencies: packageJson.dependencies,
|
|
1303
1418
|
devDependencies: packageJson.devDependencies,
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
ignoredBuiltDependencies: ignoredBuilt
|
|
1308
|
-
} : {},
|
|
1309
|
-
...onlyBuilt.length ? {
|
|
1310
|
-
onlyBuiltDependencies: onlyBuilt
|
|
1311
|
-
} : {}
|
|
1312
|
-
},
|
|
1419
|
+
...Object.keys(pnpmSettings).length ? {
|
|
1420
|
+
pnpm: pnpmSettings
|
|
1421
|
+
} : {},
|
|
1313
1422
|
...trustedDeps.length ? {
|
|
1314
1423
|
trustedDependencies: trustedDeps
|
|
1315
1424
|
} : {},
|
|
1316
|
-
author
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
url: 'https://yourwebsite.com'
|
|
1320
|
-
}
|
|
1425
|
+
...author ? {
|
|
1426
|
+
author
|
|
1427
|
+
} : {}
|
|
1321
1428
|
};
|
|
1322
1429
|
try {
|
|
1323
1430
|
if (isDebug()) logger.log(writingPackageJsonMetadata());
|
|
@@ -1508,11 +1615,12 @@ async function writeManifestJson(projectPath, logger) {
|
|
|
1508
1615
|
const manifestJsonPath = await findManifestJsonPath(projectPath);
|
|
1509
1616
|
const manifestJsonContent = await promises_namespaceObject.readFile(manifestJsonPath);
|
|
1510
1617
|
const manifestJson = JSON.parse(manifestJsonContent.toString());
|
|
1618
|
+
const templateName = String(manifestJson.name || '').trim();
|
|
1511
1619
|
const manifestMetadata = {
|
|
1512
1620
|
...manifestJson,
|
|
1513
|
-
name: external_node_path_namespaceObject.basename(projectPath)
|
|
1514
|
-
author: 'Your Name'
|
|
1621
|
+
name: external_node_path_namespaceObject.basename(projectPath)
|
|
1515
1622
|
};
|
|
1623
|
+
delete manifestMetadata.author;
|
|
1516
1624
|
try {
|
|
1517
1625
|
if (isDebug()) logger.log(writingManifestJsonMetadata());
|
|
1518
1626
|
await promises_namespaceObject.writeFile(manifestJsonPath, JSON.stringify(manifestMetadata, null, 2));
|
|
@@ -1520,6 +1628,7 @@ async function writeManifestJson(projectPath, logger) {
|
|
|
1520
1628
|
logger.error(writingManifestJsonMetadataError(error));
|
|
1521
1629
|
throw error;
|
|
1522
1630
|
}
|
|
1631
|
+
return templateName;
|
|
1523
1632
|
}
|
|
1524
1633
|
async function write_readme_file_pathExists(target) {
|
|
1525
1634
|
try {
|
|
@@ -1553,6 +1662,34 @@ async function writeReadmeFile(projectPath, projectName, logger) {
|
|
|
1553
1662
|
throw error;
|
|
1554
1663
|
}
|
|
1555
1664
|
}
|
|
1665
|
+
const STORE_METADATA_FILE = 'STORE.md';
|
|
1666
|
+
function escapeForRegExp(value) {
|
|
1667
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1668
|
+
}
|
|
1669
|
+
function rewriteStoreMetadata(content, projectName, templateName, today) {
|
|
1670
|
+
let next = content.replace(/^(\s*-\s*Name:).*$/m, (_match, label)=>`${label} ${projectName}`);
|
|
1671
|
+
if (templateName && templateName !== projectName) next = next.replace(new RegExp(escapeForRegExp(templateName), 'g'), projectName);
|
|
1672
|
+
next = next.replace(/^(Last updated:).*$/m, (_match, label)=>`${label} ${today}`);
|
|
1673
|
+
return next;
|
|
1674
|
+
}
|
|
1675
|
+
async function writeStoreMetadata(projectPath, projectName, templateName, logger) {
|
|
1676
|
+
const storePath = external_node_path_namespaceObject.join(projectPath, STORE_METADATA_FILE);
|
|
1677
|
+
let content;
|
|
1678
|
+
try {
|
|
1679
|
+
content = await promises_namespaceObject.readFile(storePath, 'utf8');
|
|
1680
|
+
} catch {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
1684
|
+
const rewritten = rewriteStoreMetadata(content, projectName, templateName, today);
|
|
1685
|
+
if (rewritten === content) return;
|
|
1686
|
+
try {
|
|
1687
|
+
if (isDebug()) logger.log(writingStoreMetadata(projectName));
|
|
1688
|
+
await promises_namespaceObject.writeFile(storePath, rewritten);
|
|
1689
|
+
} catch (error) {
|
|
1690
|
+
logger.error(writingStoreMetadataError(error));
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1556
1693
|
const TEMPLATE_PROVENANCE_FILE = '.extension-create.json';
|
|
1557
1694
|
function ownCreateVersion() {
|
|
1558
1695
|
try {
|
|
@@ -1591,6 +1728,7 @@ async function extensionCreate(projectNameInput, { cliVersion, template = "javas
|
|
|
1591
1728
|
const projectName = external_node_path_namespaceObject.basename(projectPath);
|
|
1592
1729
|
const updateSuffix = process.env.EXTENSION_CLI_UPDATE_SUFFIX || '';
|
|
1593
1730
|
if (updateSuffix) delete process.env.EXTENSION_CLI_UPDATE_SUFFIX;
|
|
1731
|
+
const requestedTemplate = 'init' === external_node_path_namespaceObject.basename(String(template)) ? "javascript" : String(template);
|
|
1594
1732
|
logger.log(' ');
|
|
1595
1733
|
logger.log(card({
|
|
1596
1734
|
version: cliVersion || process.env.EXTENSION_CLI_VERSION,
|
|
@@ -1600,6 +1738,10 @@ async function extensionCreate(projectNameInput, { cliVersion, template = "javas
|
|
|
1600
1738
|
label: 'Extension',
|
|
1601
1739
|
value: projectName
|
|
1602
1740
|
},
|
|
1741
|
+
{
|
|
1742
|
+
label: 'Template',
|
|
1743
|
+
value: requestedTemplate
|
|
1744
|
+
},
|
|
1603
1745
|
{
|
|
1604
1746
|
label: 'Output',
|
|
1605
1747
|
value: projectPath
|
|
@@ -1610,6 +1752,7 @@ async function extensionCreate(projectNameInput, { cliVersion, template = "javas
|
|
|
1610
1752
|
process.env.EXTENSION_CLI_BANNER_PRINTED = 'true';
|
|
1611
1753
|
await createDirectory(projectPath, projectName, logger);
|
|
1612
1754
|
const templateProvenance = await importExternalTemplate(projectPath, projectName, template, logger);
|
|
1755
|
+
if (templateProvenance?.template) logger.log(usingTemplate(templateProvenance.template, templateProvenance.source));
|
|
1613
1756
|
const isMonorepoTemplate = String(template).toLowerCase().includes('monorepo');
|
|
1614
1757
|
if (isDenoRuntime() && !isMonorepoTemplate) await writeDenoJsonc(projectPath, {
|
|
1615
1758
|
template,
|
|
@@ -1631,11 +1774,12 @@ async function extensionCreate(projectNameInput, { cliVersion, template = "javas
|
|
|
1631
1774
|
await installInternalDependencies(projectPath, logger);
|
|
1632
1775
|
}
|
|
1633
1776
|
await writeReadmeFile(projectPath, projectName, logger);
|
|
1634
|
-
await writeManifestJson(projectPath, logger);
|
|
1635
|
-
await
|
|
1777
|
+
const templateManifestName = await writeManifestJson(projectPath, logger);
|
|
1778
|
+
await writeStoreMetadata(projectPath, projectName, templateManifestName, logger);
|
|
1636
1779
|
await writeGitignore(projectPath, logger);
|
|
1637
1780
|
await setupBuiltInTests(projectPath, logger);
|
|
1638
1781
|
if (isTypeScriptTemplate(template)) await generateExtensionTypes(projectPath, projectName, logger);
|
|
1782
|
+
await initializeGitRepository(projectPath, projectName, templateProvenance?.template, logger);
|
|
1639
1783
|
const readyMessage = await scaffoldReady(projectPath, projectName, Boolean(install));
|
|
1640
1784
|
logger.log(readyMessage);
|
|
1641
1785
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function firstCommitSubject(projectName: string, templateName?: string): string;
|
|
2
|
+
export declare function initializeGitRepository(projectPath: string, projectName: string, templateName: string | undefined, logger: {
|
|
2
3
|
log(...args: unknown[]): void;
|
|
3
4
|
error(...args: unknown[]): void;
|
|
4
5
|
}): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const STORE_METADATA_FILE = "STORE.md";
|
|
2
|
+
export declare function rewriteStoreMetadata(content: string, projectName: string, templateName: string, today: string): string;
|
|
3
|
+
export declare function writeStoreMetadata(projectPath: string, projectName: string, templateName: string, logger: {
|
|
4
|
+
log(...args: unknown[]): void;
|
|
5
|
+
error(...args: unknown[]): void;
|
|
6
|
+
}): Promise<void>;
|
|
@@ -13,8 +13,8 @@ Last updated: 2026-07-30
|
|
|
13
13
|
|
|
14
14
|
## Listing
|
|
15
15
|
|
|
16
|
-
- Name:
|
|
17
|
-
- Summary:
|
|
16
|
+
- Name: test-template-javascript
|
|
17
|
+
- Summary: Adds a sidebar panel to the browser.
|
|
18
18
|
- Description: TODO write two or three short paragraphs of user
|
|
19
19
|
benefits. Describe what the user sees and gains, not how the code
|
|
20
20
|
works.
|
|
@@ -35,7 +35,7 @@ Last updated: 2026-07-30
|
|
|
35
35
|
|
|
36
36
|
### Single purpose
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Adds a sidebar panel to the browser.
|
|
39
39
|
|
|
40
40
|
### Permissions justification
|
|
41
41
|
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "test-template-javascript",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Adds a sidebar panel to the browser with a simple page.",
|
|
5
5
|
"version": "1.0.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"author": {
|
|
9
|
-
"name": "Your Name",
|
|
10
|
-
"email": "your@email.com",
|
|
11
|
-
"url": "https://yourwebsite.com"
|
|
12
|
-
},
|
|
13
8
|
"scripts": {
|
|
14
9
|
"dev": "extension dev",
|
|
15
10
|
"start": "extension start",
|
|
@@ -21,7 +16,7 @@
|
|
|
21
16
|
},
|
|
22
17
|
"dependencies": {},
|
|
23
18
|
"devDependencies": {
|
|
24
|
-
"extension": "^4.0.
|
|
19
|
+
"extension": "^4.0.24"
|
|
25
20
|
},
|
|
26
21
|
"packageManager": "pnpm@10.28.0",
|
|
27
22
|
"pnpm": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"name": "test-template-javascript",
|
|
16
|
-
"description": "
|
|
16
|
+
"description": "Adds a sidebar panel to the browser with a simple page.",
|
|
17
17
|
"icons": {
|
|
18
18
|
"16": "images/icon.png",
|
|
19
19
|
"32": "images/icon.png",
|
|
@@ -67,6 +67,5 @@
|
|
|
67
67
|
"content/scripts.js"
|
|
68
68
|
]
|
|
69
69
|
}
|
|
70
|
-
]
|
|
71
|
-
"author": "Your Name"
|
|
70
|
+
]
|
|
72
71
|
}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ Last updated: 2026-07-30
|
|
|
14
14
|
## Listing
|
|
15
15
|
|
|
16
16
|
- Name: JavaScript Sidebar Example
|
|
17
|
-
- Summary:
|
|
17
|
+
- Summary: Adds a sidebar panel to the browser.
|
|
18
18
|
- Description: TODO write two or three short paragraphs of user
|
|
19
19
|
benefits. Describe what the user sees and gains, not how the code
|
|
20
20
|
works.
|
|
@@ -35,7 +35,7 @@ Last updated: 2026-07-30
|
|
|
35
35
|
|
|
36
36
|
### Single purpose
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Adds a sidebar panel to the browser.
|
|
39
39
|
|
|
40
40
|
### Permissions justification
|
|
41
41
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "javascript",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Adds a sidebar panel to the browser with a simple page.",
|
|
5
5
|
"version": "1.0.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"name": "JavaScript Sidebar Example",
|
|
14
|
-
"description": "
|
|
14
|
+
"description": "Adds a sidebar panel to the browser with a simple page.",
|
|
15
15
|
"icons": {
|
|
16
16
|
"16": "images/icon.png",
|
|
17
17
|
"32": "images/icon.png",
|