create-astro 4.12.1 → 4.13.0
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/actions/context.d.ts +1 -1
- package/dist/actions/template.d.ts +14 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +24 -9
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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,
|
|
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";
|
|
@@ -442,7 +445,7 @@ function printHelp({
|
|
|
442
445
|
if (headline) {
|
|
443
446
|
message.push(
|
|
444
447
|
linebreak(),
|
|
445
|
-
`${title(commandName)} ${color.green(`v${"4.
|
|
448
|
+
`${title(commandName)} ${color.green(`v${"4.13.0"}`)} ${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.
|
|
541
|
+
"5.12.3"
|
|
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
|
-
|
|
971
|
-
|
|
983
|
+
const readmePath = path5.resolve(ctx.cwd, "README.md");
|
|
984
|
+
if (fs4.existsSync(readmePath)) {
|
|
972
985
|
const readme = fs4.readFileSync(readmePath, "utf8");
|
|
973
|
-
const
|
|
974
|
-
fs4.writeFileSync(readmePath,
|
|
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
|