create-sense-app 1.0.0 → 1.0.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.
- package/bin/cli.ts +25 -13
- package/package.json +1 -1
package/bin/cli.ts
CHANGED
|
@@ -1,40 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
-
import { join, resolve } from "node:path";
|
|
1
|
+
import { cp, mkdir, readFile, writeFile, rm } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
5
3
|
import { spawn } from "bun";
|
|
4
|
+
import fs from "node:fs";
|
|
6
5
|
|
|
7
6
|
const projectName = process.argv[2] || "sense-app";
|
|
8
|
-
const
|
|
9
|
-
const projectDir = join(currentDir, projectName);
|
|
10
|
-
|
|
11
|
-
console.log(`\n ⚙︎ Creating a new Sense app in ${projectName}...\n`);
|
|
7
|
+
const projectDir = join(process.cwd(), projectName);
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
console.log(`\n Creating a new Sense app in ${projectName}...\n`);
|
|
14
10
|
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
if (fs.existsSync(projectDir)) {
|
|
13
|
+
console.error(`Error: Directory ${projectName} already exists.`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
await mkdir(projectDir, { recursive: true });
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
const repo = "github:ommishra/sense-template";
|
|
19
20
|
const degit = spawn(["npx", "degit", repo, projectName], {
|
|
20
21
|
stdio: ["ignore", "inherit", "inherit"],
|
|
21
22
|
});
|
|
22
|
-
|
|
23
23
|
await degit.exited;
|
|
24
24
|
|
|
25
25
|
if (degit.exitCode !== 0) {
|
|
26
|
-
console.error("Failed to download template.");
|
|
27
26
|
process.exit(1);
|
|
28
27
|
}
|
|
29
28
|
|
|
29
|
+
const lockfilePath = join(projectDir, "bun.lockb");
|
|
30
|
+
if (fs.existsSync(lockfilePath)) {
|
|
31
|
+
await rm(lockfilePath);
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
|
|
31
35
|
const pkgPath = join(projectDir, "package.json");
|
|
32
36
|
const pkgStr = await readFile(pkgPath, "utf-8");
|
|
33
37
|
const pkg = JSON.parse(pkgStr);
|
|
34
38
|
|
|
39
|
+
|
|
35
40
|
pkg.name = projectName;
|
|
41
|
+
|
|
42
|
+
|
|
36
43
|
pkg.dependencies["@ommishra/sense"] = "latest";
|
|
37
44
|
|
|
45
|
+
|
|
38
46
|
await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
|
|
49
|
+
console.log(`\nDone! Now run:\n`);
|
|
50
|
+
console.log(` cd ${projectName}`);
|
|
51
|
+
console.log(` bun install`);
|
|
52
|
+
console.log(` bun dev`);
|