create-stardrive 1.2.3 → 1.3.4
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/bin/index.js +124 -4
- package/package.json +2 -2
package/bin/index.js
CHANGED
|
@@ -175,12 +175,33 @@ function removeBlog(targetDir2) {
|
|
|
175
175
|
const withoutComment = removeLines(withoutSection, /^\s*\/\/ content\/article settings\s*$/);
|
|
176
176
|
return removeLines(withoutComment, /^\s*addArticles:/);
|
|
177
177
|
});
|
|
178
|
+
const packageJsonPath = path.join(targetDir2, "package.json");
|
|
179
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
180
|
+
const pkg = JSON.parse(
|
|
181
|
+
fs.readFileSync(packageJsonPath, "utf8")
|
|
182
|
+
);
|
|
183
|
+
if (pkg.dependencies) delete pkg.dependencies["reading-time"];
|
|
184
|
+
if (pkg.devDependencies) delete pkg.devDependencies["reading-time"];
|
|
185
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2));
|
|
186
|
+
}
|
|
187
|
+
editFile(
|
|
188
|
+
targetDir2,
|
|
189
|
+
"astro.config.ts",
|
|
190
|
+
(content) => content.replace(
|
|
191
|
+
/(\binclude:\s*\[)([^\]]*)\]/,
|
|
192
|
+
(_full, prefix, body) => {
|
|
193
|
+
const items = body.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0 && entry !== "'reading-time'");
|
|
194
|
+
return `${prefix}${items.join(", ")}]`;
|
|
195
|
+
}
|
|
196
|
+
).replace(/,\s*\]/, "]")
|
|
197
|
+
);
|
|
178
198
|
}
|
|
179
199
|
function removeFaq(targetDir2) {
|
|
180
200
|
removePaths(targetDir2, [
|
|
181
201
|
"src/content/faq-answers",
|
|
182
202
|
"src/pages/faq.astro",
|
|
183
|
-
"src/pages/[lang]/faq.astro"
|
|
203
|
+
"src/pages/[lang]/faq.astro",
|
|
204
|
+
"src/components/faq"
|
|
184
205
|
]);
|
|
185
206
|
editFile(targetDir2, "src/content.config.ts", (content) => {
|
|
186
207
|
const withoutDecl = removeBraceBlock(content, /const faq_answers = defineCollection\(/);
|
|
@@ -198,7 +219,7 @@ function removeIntegration(targetDir2) {
|
|
|
198
219
|
"src/content/integration-options",
|
|
199
220
|
"src/pages/integration",
|
|
200
221
|
"src/pages/[lang]/integration",
|
|
201
|
-
"src/components/integration
|
|
222
|
+
"src/components/integration"
|
|
202
223
|
]);
|
|
203
224
|
editFile(targetDir2, "src/content.config.ts", (content) => {
|
|
204
225
|
const withoutDecl = removeBraceBlock(
|
|
@@ -207,12 +228,60 @@ function removeIntegration(targetDir2) {
|
|
|
207
228
|
);
|
|
208
229
|
return removeCollectionFromExport(withoutDecl, "integration_options");
|
|
209
230
|
});
|
|
231
|
+
editFile(
|
|
232
|
+
targetDir2,
|
|
233
|
+
"theme.config.ts",
|
|
234
|
+
(content) => content.replace(
|
|
235
|
+
/onDemandRenderedCollections:\s*\[[^\]]*\]/,
|
|
236
|
+
"onDemandRenderedCollections: []"
|
|
237
|
+
).replace(
|
|
238
|
+
/excludePagesPattern:\s*\[[^\]]*\]/,
|
|
239
|
+
"excludePagesPattern: []"
|
|
240
|
+
)
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
function removeEvents(targetDir2) {
|
|
244
|
+
removePaths(targetDir2, [
|
|
245
|
+
"src/styles/events.css",
|
|
246
|
+
"src/pages/events",
|
|
247
|
+
"src/pages/[lang]/events",
|
|
248
|
+
"src/pages/dynamic-events-sitemap.xml.ts",
|
|
249
|
+
"src/components/events",
|
|
250
|
+
"src/content/events",
|
|
251
|
+
"src/images/content/events",
|
|
252
|
+
"src/utils/event-bridge.ts"
|
|
253
|
+
]);
|
|
254
|
+
editFile(targetDir2, "src/content.config.ts", (content) => {
|
|
255
|
+
const withoutDecl = removeBraceBlock(content, /const events = defineCollection\(/);
|
|
256
|
+
return removeCollectionFromExport(withoutDecl, "events");
|
|
257
|
+
});
|
|
258
|
+
editFile(targetDir2, "theme.config.ts", (content) => {
|
|
259
|
+
const withoutSection = removeBraceBlock(content, /^[ \t]*dynamicEvents:\s*\{/m);
|
|
260
|
+
const withoutComment = removeLines(withoutSection, /^\s*\/\/ you can also dynamically integrate events.*$/m);
|
|
261
|
+
return removeLines(withoutComment, /^\s*addEvents:/);
|
|
262
|
+
});
|
|
263
|
+
editFile(targetDir2, "astro.config.ts", (content) => {
|
|
264
|
+
return removeLines(content, /^\s*customSitemaps:\s.*$/m);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function cleanupContentConfig(targetDir2) {
|
|
268
|
+
const contentConfigPath = path.join(targetDir2, "src/content.config.ts");
|
|
269
|
+
if (!fs.existsSync(contentConfigPath)) return;
|
|
270
|
+
const content = fs.readFileSync(contentConfigPath, "utf8");
|
|
271
|
+
const match = content.match(
|
|
272
|
+
/export const collections\s*=\s*\{([^}]*)\}\s*;?/
|
|
273
|
+
);
|
|
274
|
+
if (match && match[1].trim() === "") {
|
|
275
|
+
fs.writeFileSync(contentConfigPath, "export const collections = {};\n");
|
|
276
|
+
ok("No content collections left; cleaned up content.config.ts");
|
|
277
|
+
}
|
|
210
278
|
}
|
|
211
279
|
function cleanupNav(targetDir2, removed) {
|
|
212
280
|
const routes = [
|
|
213
281
|
removed.blog ? "blog" : null,
|
|
214
282
|
removed.faq ? "faq" : null,
|
|
215
|
-
removed.integration ? "integration" : null
|
|
283
|
+
removed.integration ? "integration" : null,
|
|
284
|
+
removed.events ? "events" : null
|
|
216
285
|
].filter((route) => route !== null);
|
|
217
286
|
if (routes.length === 0) return;
|
|
218
287
|
const pattern = new RegExp(
|
|
@@ -285,11 +354,18 @@ async function configureFeatures(targetDir2) {
|
|
|
285
354
|
removeIntegration(targetDir2);
|
|
286
355
|
ok("Removed the integration catalog");
|
|
287
356
|
}
|
|
357
|
+
const keepEvents = await confirm(rl, "Keep the events feature?");
|
|
358
|
+
if (!keepEvents) {
|
|
359
|
+
removeEvents(targetDir2);
|
|
360
|
+
ok("Removed the events feature");
|
|
361
|
+
}
|
|
288
362
|
cleanupNav(targetDir2, {
|
|
289
363
|
blog: !keepBlog,
|
|
290
364
|
faq: !keepFaq,
|
|
291
|
-
integration: !keepIntegration
|
|
365
|
+
integration: !keepIntegration,
|
|
366
|
+
events: !keepEvents
|
|
292
367
|
});
|
|
368
|
+
cleanupContentConfig(targetDir2);
|
|
293
369
|
const useCloudflare = await confirm(
|
|
294
370
|
rl,
|
|
295
371
|
"Will you host on Cloudflare Workers?"
|
|
@@ -465,6 +541,48 @@ function calibratePackageJson(targetDir2, projectName2, pm2) {
|
|
|
465
541
|
fs3.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2));
|
|
466
542
|
ok(`Named your ship ${c.bold(projectName2)}`);
|
|
467
543
|
}
|
|
544
|
+
var LOCKFILE_RULES = {
|
|
545
|
+
npm: "package-lock.json",
|
|
546
|
+
pnpm: "pnpm-lock.yaml",
|
|
547
|
+
yarn: "yarn.lock",
|
|
548
|
+
bun: "bun.lockb"
|
|
549
|
+
};
|
|
550
|
+
function calibrateGitignore(targetDir2, pm2) {
|
|
551
|
+
step("Calibrating .gitignore lockfile rules");
|
|
552
|
+
const gitignorePath = path3.join(targetDir2, ".gitignore");
|
|
553
|
+
if (!fs3.existsSync(gitignorePath)) {
|
|
554
|
+
info("No .gitignore found, skipping lockfile calibration");
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const lines = fs3.readFileSync(gitignorePath, "utf8").split(/\r?\n/);
|
|
558
|
+
const activeRule = LOCKFILE_RULES[pm2];
|
|
559
|
+
const inactiveRules = Object.values(LOCKFILE_RULES).filter(
|
|
560
|
+
(rule) => rule !== activeRule
|
|
561
|
+
);
|
|
562
|
+
const rewritten = lines.map((line) => {
|
|
563
|
+
const trimmed = line.trim();
|
|
564
|
+
const match = trimmed.match(/^#?\s*(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb)$/);
|
|
565
|
+
if (!match) return line;
|
|
566
|
+
const rule = match[1];
|
|
567
|
+
if (rule === activeRule) {
|
|
568
|
+
return `#${rule}`;
|
|
569
|
+
}
|
|
570
|
+
if (inactiveRules.includes(rule)) {
|
|
571
|
+
return rule;
|
|
572
|
+
}
|
|
573
|
+
return line;
|
|
574
|
+
});
|
|
575
|
+
fs3.writeFileSync(gitignorePath, rewritten.join("\n"));
|
|
576
|
+
ok(`Enabled ${activeRule} for ${pm2}, ignored others`);
|
|
577
|
+
}
|
|
578
|
+
function setAgentMode(targetDir2) {
|
|
579
|
+
step("Specifying AI agent mode in the project");
|
|
580
|
+
fs3.writeFileSync(
|
|
581
|
+
path3.join(targetDir2, "STARDRIVE_AGENT_MODE.md"),
|
|
582
|
+
"project\n"
|
|
583
|
+
);
|
|
584
|
+
ok("Created STARDRIVE_AGENT_MODE.md");
|
|
585
|
+
}
|
|
468
586
|
function installDependencies(targetDir2, projectName2, pm2, skipInstall2) {
|
|
469
587
|
if (skipInstall2) {
|
|
470
588
|
step("Skipping dependency install");
|
|
@@ -495,8 +613,10 @@ ok(`Selected ${c.bold(tag)}`);
|
|
|
495
613
|
cloneRepo(tag, targetDir, projectName);
|
|
496
614
|
trimProject(targetDir);
|
|
497
615
|
calibratePackageJson(targetDir, projectName, pm);
|
|
616
|
+
calibrateGitignore(targetDir, pm);
|
|
498
617
|
await configureFeatures(targetDir);
|
|
499
618
|
installDependencies(targetDir, projectName, pm, skipInstall);
|
|
619
|
+
setAgentMode(targetDir);
|
|
500
620
|
console.log(`
|
|
501
621
|
${c.green("All systems go.")} ${c.dim("Pre-flight checklist complete.")}
|
|
502
622
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-stardrive",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "This is the launchpad application to create the Astro Stardrive boilerplate.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-stardrive": "bin/index.js"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"typecheck": "tsc --noEmit"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@types/node": "^26.
|
|
54
|
+
"@types/node": "^26.1.0",
|
|
55
55
|
"esbuild": "^0.28.1",
|
|
56
56
|
"typescript": "^6.0.3"
|
|
57
57
|
}
|