create-kor 0.1.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/index.js +54 -0
- package/package.json +16 -0
package/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from "node:child_process";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
|
|
7
|
+
const repo = "mastoj/kor";
|
|
8
|
+
const projectName = process.argv[2];
|
|
9
|
+
|
|
10
|
+
if (!projectName) {
|
|
11
|
+
console.error("Usage: pnpm create kor <project-name>");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const dest = path.resolve(process.cwd(), projectName);
|
|
16
|
+
|
|
17
|
+
if (fs.existsSync(dest)) {
|
|
18
|
+
console.error(`Error: Directory "${projectName}" already exists.`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log(`Cloning template into ${dest}...`);
|
|
23
|
+
|
|
24
|
+
const { default: tiged } = await import("tiged");
|
|
25
|
+
const emitter = tiged(repo, { disableCache: true });
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
await emitter.clone(dest);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.error("Failed to clone template:", err.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Update root package.json name
|
|
35
|
+
const pkgPath = path.join(dest, "package.json");
|
|
36
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
37
|
+
pkg.name = path.basename(dest);
|
|
38
|
+
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
39
|
+
|
|
40
|
+
// Create apps/web/.env.local (Next.js only reads env files from its own directory)
|
|
41
|
+
const webEnvContent = "NEXT_PUBLIC_API_URL=http://localhost:3001/trpc\n";
|
|
42
|
+
fs.mkdirSync(path.join(dest, "apps/web"), { recursive: true });
|
|
43
|
+
fs.writeFileSync(path.join(dest, "apps/web/.env.local"), webEnvContent);
|
|
44
|
+
|
|
45
|
+
// Initialise a fresh git repository
|
|
46
|
+
execSync("git init && git add . && git commit -m 'Initial commit'", {
|
|
47
|
+
cwd: dest,
|
|
48
|
+
stdio: "inherit",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log("\nDone! Next steps:\n");
|
|
52
|
+
console.log(` cd ${projectName}`);
|
|
53
|
+
console.log(" pnpm install");
|
|
54
|
+
console.log(" pnpm dev");
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-kor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Create a new kor project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-kor": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": ["index.js"],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"tiged": "^2.12.7"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
}
|
|
16
|
+
}
|