create-astro 4.12.1 → 4.13.1

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.
@@ -1,4 +1,4 @@
1
- import { type Task, prompt } from '@astrojs/cli-kit';
1
+ import { prompt, type Task } from '@astrojs/cli-kit';
2
2
  export interface Context {
3
3
  help: boolean;
4
4
  prompt: typeof prompt;
@@ -1,3 +1,17 @@
1
1
  import type { Context } from './context.js';
2
+ /**
3
+ * Removes sections from README content that are marked with HTML template markers.
4
+ *
5
+ * Template marker format:
6
+ * <!-- ASTRO:REMOVE:START -->
7
+ * Content to remove
8
+ * <!-- ASTRO:REMOVE:END -->
9
+ */
10
+ export declare function removeTemplateMarkerSections(content: string): string;
11
+ /**
12
+ * Processes a template README file by removing template marker sections and
13
+ * replacing package manager references.
14
+ */
15
+ export declare function processTemplateReadme(content: string, packageManager: string): string;
2
16
  export declare function template(ctx: Pick<Context, 'template' | 'prompt' | 'yes' | 'dryRun' | 'exit' | 'tasks'>): Promise<void>;
3
17
  export declare function getTemplateTarget(tmpl: string, ref?: string): string;
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { next } from './actions/next-steps.js';
6
6
  import { projectName } from './actions/project-name.js';
7
7
  import { template } from './actions/template.js';
8
8
  import { verify } from './actions/verify.js';
9
- import { setStdout } from './messages.js';
9
+ export { processTemplateReadme, removeTemplateMarkerSections } from './actions/template.js';
10
+ export { setStdout } from './messages.js';
10
11
  export declare function main(): Promise<void>;
11
- export { dependencies, getContext, git, intro, next, projectName, setStdout, template, verify };
12
+ export { dependencies, getContext, git, intro, next, projectName, template, verify };
package/dist/index.js CHANGED
@@ -168,6 +168,9 @@ var require_arg = __commonJS({
168
168
  }
169
169
  });
170
170
 
171
+ // src/index.ts
172
+ import { tasks } from "@astrojs/cli-kit";
173
+
171
174
  // src/actions/context.ts
172
175
  var import_arg = __toESM(require_arg(), 1);
173
176
  import os from "node:os";
@@ -292,7 +295,7 @@ async function shell(command, flags, opts = {}) {
292
295
  let stdout2 = "";
293
296
  let stderr = "";
294
297
  try {
295
- child = spawn(command, flags, {
298
+ child = spawn(`${command} ${flags.join(" ")}`, {
296
299
  cwd: opts.cwd,
297
300
  shell: true,
298
301
  stdio: opts.stdio,
@@ -442,7 +445,7 @@ function printHelp({
442
445
  if (headline) {
443
446
  message.push(
444
447
  linebreak(),
445
- `${title(commandName)} ${color.green(`v${"4.12.1"}`)} ${headline}`
448
+ `${title(commandName)} ${color.green(`v${"4.13.1"}`)} ${headline}`
446
449
  );
447
450
  }
448
451
  if (usage) {
@@ -535,7 +538,7 @@ async function getContext(argv) {
535
538
  packageManager,
536
539
  "astro",
537
540
  getPackageTag(packageSpecifier),
538
- "5.8.1"
541
+ "5.12.6"
539
542
  ),
540
543
  skipHouston,
541
544
  fancy,
@@ -565,9 +568,6 @@ function detectPackageManager() {
565
568
  return name === "npminstall" ? "cnpm" : name;
566
569
  }
567
570
 
568
- // src/index.ts
569
- import { tasks } from "@astrojs/cli-kit";
570
-
571
571
  // src/actions/dependencies.ts
572
572
  import fs from "node:fs";
573
573
  import path from "node:path";
@@ -889,6 +889,19 @@ import fs4 from "node:fs";
889
889
  import path5 from "node:path";
890
890
  import { color as color6 } from "@astrojs/cli-kit";
891
891
  import { downloadTemplate } from "@bluwy/giget-core";
892
+ function removeTemplateMarkerSections(content) {
893
+ const pattern = /<!--\s*ASTRO:REMOVE:START\s*-->[\s\S]*?<!--\s*ASTRO:REMOVE:END\s*-->/gi;
894
+ let result = content.replace(pattern, "");
895
+ result = result.replace(/\n{3,}/g, "\n\n");
896
+ return result;
897
+ }
898
+ function processTemplateReadme(content, packageManager) {
899
+ let processed = removeTemplateMarkerSections(content);
900
+ if (packageManager !== "npm") {
901
+ processed = processed.replace(/\bnpm run\b/g, packageManager).replace(/\bnpm\b/g, packageManager);
902
+ }
903
+ return processed;
904
+ }
892
905
  async function template(ctx) {
893
906
  if (!ctx.template && ctx.yes) ctx.template = "basics";
894
907
  if (ctx.template) {
@@ -967,11 +980,11 @@ async function copyTemplate(tmpl, ctx) {
967
980
  cwd: ctx.cwd,
968
981
  dir: "."
969
982
  });
970
- if (ctx.packageManager !== "npm") {
971
- const readmePath = path5.resolve(ctx.cwd, "README.md");
983
+ const readmePath = path5.resolve(ctx.cwd, "README.md");
984
+ if (fs4.existsSync(readmePath)) {
972
985
  const readme = fs4.readFileSync(readmePath, "utf8");
973
- const updatedReadme = readme.replace(/\bnpm run\b/g, ctx.packageManager).replace(/\bnpm\b/g, ctx.packageManager);
974
- fs4.writeFileSync(readmePath, updatedReadme);
986
+ const processedReadme = processTemplateReadme(readme, ctx.packageManager);
987
+ fs4.writeFileSync(readmePath, processedReadme);
975
988
  }
976
989
  } catch (err) {
977
990
  if (ctx.cwd !== "." && ctx.cwd !== "./" && !ctx.cwd.startsWith("../")) {
@@ -1086,7 +1099,9 @@ export {
1086
1099
  intro,
1087
1100
  main,
1088
1101
  next,
1102
+ processTemplateReadme,
1089
1103
  projectName,
1104
+ removeTemplateMarkerSections,
1090
1105
  setStdout,
1091
1106
  template,
1092
1107
  verify
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "4.12.1",
3
+ "version": "4.13.1",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",