create-base-stack 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/bin/index.ts +64 -20
  2. package/package.json +15 -4
package/bin/index.ts CHANGED
@@ -1,26 +1,70 @@
1
1
  #!/usr/bin/env bun
2
- import { mkdir, copyFile, readdir } from "node:fs/promises";
2
+ import { cp, rename } from "node:fs/promises";
3
+ import { spawnSync } from "node:child_process";
3
4
  import path from "node:path";
4
5
 
5
- const projectName = process.argv[2] || "base-stack";
6
- const templateDir = path.join(import.meta.dir, "../template");
7
- const targetDir = path.join(process.cwd(), projectName);
8
-
9
- console.log(`šŸš€ Creating ${projectName}...`);
10
-
11
- // Simple recursive copy function
12
- async function copy(src: string, dest: string) {
13
- await mkdir(dest, { recursive: true });
14
- const entries = await readdir(src, { withFileTypes: true });
15
- for (const entry of entries) {
16
- const srcPath = path.join(src, entry.name);
17
- const destPath = path.join(dest, entry.name);
18
- entry.isDirectory()
19
- ? await copy(srcPath, destPath)
20
- : await copyFile(srcPath, destPath);
21
- }
6
+ const projectName = process.argv[2];
7
+
8
+ if (!projectName) {
9
+ console.error("āŒ Please provide a project name:");
10
+ console.log(" bun create base-stack my-app");
11
+ process.exit(1);
22
12
  }
23
13
 
24
- await copy(templateDir, targetDir);
25
- console.log("āœ… Project ready! Now run: bun install");
14
+ const templateDir = path.resolve(import.meta.dir, "../template");
15
+ const targetDir = path.resolve(process.cwd(), projectName);
16
+
17
+ async function main() {
18
+ console.log(`\nšŸš€ Creating "${projectName}" from monorepo template...`);
19
+
20
+ try {
21
+ // 1. Copy the template
22
+ await cp(templateDir, targetDir, { recursive: true });
23
+ console.log("šŸ“‚ Files scaffolded.");
24
+
25
+ // 2. Fix the .gitignore (NPM renames .gitignore to .npmignore on publish)
26
+ // We look for 'gitignore.template' and rename it to '.gitignore'
27
+ const gitignorePath = path.join(targetDir, "gitignore.template");
28
+ const destGitignore = path.join(targetDir, ".gitignore");
29
+
30
+ try {
31
+ await rename(gitignorePath, destGitignore);
32
+ } catch (e) {
33
+ // If gitignore.template doesn't exist, we check if it's currently named .npmignore
34
+ const npmignorePath = path.join(targetDir, ".npmignore");
35
+ try {
36
+ await rename(npmignorePath, destGitignore);
37
+ } catch (e) {
38
+ // No ignore file found, skip
39
+ }
40
+ }
41
+
42
+ // 3. Run bun install
43
+ console.log("šŸ“¦ Installing dependencies (this may take a moment)...");
44
+ const installResult = spawnSync("bun", ["install"], {
45
+ cwd: targetDir,
46
+ stdio: "inherit",
47
+ });
48
+
49
+ if (installResult.status !== 0) {
50
+ throw new Error("Failed to install dependencies");
51
+ }
52
+
53
+ // 4. Run the initial build
54
+ console.log("šŸ—ļø Performing initial build...");
55
+ spawnSync("bun", ["run", "build"], {
56
+ cwd: targetDir,
57
+ stdio: "inherit",
58
+ });
59
+
60
+ console.log(`\nāœ… Success! Project created in ${targetDir}`);
61
+ console.log(`\nNext steps:`);
62
+ console.log(` 1. cd ${projectName}`);
63
+ console.log(` 2. bun dev\n`);
64
+ } catch (err) {
65
+ console.error("āŒ Critical Error:", err);
66
+ process.exit(1);
67
+ }
68
+ }
26
69
 
70
+ main();
package/package.json CHANGED
@@ -1,12 +1,23 @@
1
1
  {
2
2
  "name": "create-base-stack",
3
- "version": "1.0.1",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
+ "description": "Full-stack monorepo template with Hono, React, and Vite, powered by Bun and Turborepo.",
5
6
  "bin": {
6
- "create-base-stack": "./bin/index.ts"
7
+ "create-base-stack": "bin/index.ts"
7
8
  },
8
9
  "files": [
9
10
  "bin",
10
- "template"
11
- ]
11
+ "template",
12
+ "README.md"
13
+ ],
14
+ "keywords": [
15
+ "bun",
16
+ "create",
17
+ "hono",
18
+ "react",
19
+ "monorepo",
20
+ "turbo"
21
+ ],
22
+ "author": "decimo"
12
23
  }