create-sense-app 1.0.2 → 1.0.3
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/cli.js +17 -12
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
1
|
// @bun
|
|
3
|
-
|
|
4
2
|
// bin/cli.ts
|
|
5
|
-
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
3
|
+
import { mkdir, readFile, writeFile, rm } from "fs/promises";
|
|
6
4
|
import { join } from "path";
|
|
7
5
|
var {spawn } = globalThis.Bun;
|
|
6
|
+
import fs from "fs";
|
|
8
7
|
var projectName = process.argv[2] || "sense-app";
|
|
9
|
-
var
|
|
10
|
-
var projectDir = join(currentDir, projectName);
|
|
8
|
+
var projectDir = join(process.cwd(), projectName);
|
|
11
9
|
console.log(`
|
|
12
|
-
|
|
10
|
+
Creating a new Sense app in ${projectName}...
|
|
13
11
|
`);
|
|
12
|
+
if (fs.existsSync(projectDir)) {
|
|
13
|
+
console.error(`Error: Directory ${projectName} already exists.`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
14
16
|
await mkdir(projectDir, { recursive: true });
|
|
15
|
-
var repo = "github:
|
|
17
|
+
var repo = "github:ommishra/sense/packages/sense-template";
|
|
16
18
|
var degit = spawn(["npx", "degit", repo, projectName], {
|
|
17
19
|
stdio: ["ignore", "inherit", "inherit"]
|
|
18
20
|
});
|
|
19
21
|
await degit.exited;
|
|
20
22
|
if (degit.exitCode !== 0) {
|
|
21
|
-
console.error("Failed to download template.");
|
|
22
23
|
process.exit(1);
|
|
23
24
|
}
|
|
25
|
+
var lockfilePath = join(projectDir, "bun.lockb");
|
|
26
|
+
if (fs.existsSync(lockfilePath)) {
|
|
27
|
+
await rm(lockfilePath);
|
|
28
|
+
}
|
|
24
29
|
var pkgPath = join(projectDir, "package.json");
|
|
25
30
|
var pkgStr = await readFile(pkgPath, "utf-8");
|
|
26
31
|
var pkg = JSON.parse(pkgStr);
|
|
@@ -28,8 +33,8 @@ pkg.name = projectName;
|
|
|
28
33
|
pkg.dependencies["@ommishra/sense"] = "latest";
|
|
29
34
|
await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
30
35
|
console.log(`
|
|
31
|
-
Done!
|
|
32
|
-
cd ${projectName}
|
|
33
|
-
bun install
|
|
34
|
-
bun dev
|
|
36
|
+
Done! Now run:
|
|
35
37
|
`);
|
|
38
|
+
console.log(` cd ${projectName}`);
|
|
39
|
+
console.log(` bun install`);
|
|
40
|
+
console.log(` bun dev`);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-sense-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"bin": "./dist/cli.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "bun build ./bin/cli.ts --outfile ./dist/cli.js --target
|
|
6
|
+
"build": "bun build ./bin/cli.ts --outfile ./dist/cli.js --target bun"
|
|
7
7
|
},
|
|
8
8
|
"module": "index.ts",
|
|
9
9
|
"type": "module",
|