create-secra 0.1.3 → 0.1.5
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/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/bin/index.mjs +30 -2
- package/package.json +4 -1
- package/template/apps/core/src/pages/index.tsx +1 -0
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ npm create secra@latest my-app
|
|
|
27
27
|
- `dist`
|
|
28
28
|
- `.turbo`
|
|
29
29
|
- `.git`
|
|
30
|
+
- The generated project's root `package.json` `name` is automatically updated from your target directory name.
|
|
30
31
|
- After scaffolding, dependencies are installed automatically with your detected package manager (`pnpm`/`yarn`/`bun`/`npm`).
|
|
31
32
|
|
|
32
33
|
## Override Template Source
|
package/README.zh-CN.md
CHANGED
package/bin/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
|
-
import { cpSync, existsSync, readdirSync } from "node:fs";
|
|
4
|
+
import { cpSync, existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import process from "node:process";
|
|
@@ -18,6 +18,30 @@ function fail(message) {
|
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function toPackageName(input) {
|
|
22
|
+
const normalized = input
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replace(/[^a-z0-9-]+/g, "-")
|
|
25
|
+
.replace(/-+/g, "-")
|
|
26
|
+
.replace(/^-|-$/g, "");
|
|
27
|
+
|
|
28
|
+
return normalized || "secra-app";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function updatePackageName(cwd, name) {
|
|
32
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
33
|
+
if (!existsSync(packageJsonPath)) return;
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const content = readFileSync(packageJsonPath, "utf8");
|
|
37
|
+
const json = JSON.parse(content);
|
|
38
|
+
json.name = toPackageName(name);
|
|
39
|
+
writeFileSync(packageJsonPath, `${JSON.stringify(json, null, 2)}\n`, "utf8");
|
|
40
|
+
} catch (error) {
|
|
41
|
+
fail(`Failed to update package name. ${error instanceof Error ? error.message : String(error)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
21
45
|
function detectPackageManager() {
|
|
22
46
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
23
47
|
if (userAgent.startsWith("pnpm")) return "pnpm";
|
|
@@ -76,6 +100,8 @@ async function main() {
|
|
|
76
100
|
fail(`Failed to copy template. ${error instanceof Error ? error.message : String(error)}`);
|
|
77
101
|
}
|
|
78
102
|
|
|
103
|
+
updatePackageName(targetPath, path.basename(targetPath));
|
|
104
|
+
|
|
79
105
|
console.log(`[create-secra] Installing dependencies with ${manager} ...`);
|
|
80
106
|
try {
|
|
81
107
|
await runInstall(targetPath, manager);
|
|
@@ -85,7 +111,9 @@ async function main() {
|
|
|
85
111
|
|
|
86
112
|
console.log(`[create-secra] Done. Next steps:`);
|
|
87
113
|
console.log(` cd ${targetDir}`);
|
|
88
|
-
console.log(`
|
|
114
|
+
console.log(` pnpm install`);
|
|
115
|
+
console.log(` pnpm -r --filter "./packages/*" build`);
|
|
116
|
+
console.log(` pnpm dev`);
|
|
89
117
|
}
|
|
90
118
|
|
|
91
119
|
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-secra",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Create a Secra project from the official template.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,5 +15,8 @@
|
|
|
15
15
|
"secra",
|
|
16
16
|
"scaffold"
|
|
17
17
|
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prepublishOnly": "npm version patch"
|
|
20
|
+
},
|
|
18
21
|
"license": "MIT"
|
|
19
22
|
}
|