pagezero 0.0.1 → 0.2.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/bin/pagezero.ts +68 -1
- package/package.json +11 -5
package/bin/pagezero.ts
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { input } from "@inquirer/prompts"
|
|
4
|
+
import { $, file, write } from "bun"
|
|
5
|
+
import chalk from "chalk"
|
|
6
|
+
import { program } from "commander"
|
|
7
|
+
import ora from "ora"
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.description("PageZERO CLI")
|
|
11
|
+
.option("-h, --help", "output usage information")
|
|
12
|
+
|
|
13
|
+
program.command("init").description("initialize a new project").action(init)
|
|
14
|
+
|
|
15
|
+
program.parse()
|
|
16
|
+
|
|
17
|
+
async function init() {
|
|
18
|
+
// Welcome
|
|
19
|
+
console.log(chalk.green("👋 Welcome to PageZERO CLI"))
|
|
20
|
+
console.log(chalk.green("🚀 Let's get you started with your project!"))
|
|
21
|
+
|
|
22
|
+
// Bootstrap the project
|
|
23
|
+
const projectName = await input({
|
|
24
|
+
message: "What is the name of your project?",
|
|
25
|
+
})
|
|
26
|
+
const creatingProjectSpinner = ora(
|
|
27
|
+
`Running: bun create pagezero-dev/pagezero --no-install ${projectName}`,
|
|
28
|
+
).start()
|
|
29
|
+
await $`bun create pagezero-dev/pagezero --no-install ${projectName}`.quiet()
|
|
30
|
+
creatingProjectSpinner.succeed()
|
|
31
|
+
|
|
32
|
+
// Install dependencies
|
|
33
|
+
const installingDependenciesSpinner = ora(`Running: bun install`).start()
|
|
34
|
+
await $`bun install`.quiet().cwd(projectName)
|
|
35
|
+
installingDependenciesSpinner.succeed()
|
|
36
|
+
|
|
37
|
+
// Run setup script
|
|
38
|
+
const runningSetupScriptSpinner = ora(`Running: bun run setup`).start()
|
|
39
|
+
await $`bun run setup`.quiet().cwd(projectName)
|
|
40
|
+
runningSetupScriptSpinner.succeed()
|
|
41
|
+
|
|
42
|
+
// Update wrangler.json
|
|
43
|
+
const updatingWranglerJsonSpinner = ora(`Updating wrangler.json`).start()
|
|
44
|
+
try {
|
|
45
|
+
const wranglerJson = await file(`${projectName}/wrangler.json`).json()
|
|
46
|
+
wranglerJson.name = projectName
|
|
47
|
+
wranglerJson.d1_databases[0].database_name = `${projectName}-development`
|
|
48
|
+
wranglerJson.env.production.d1_databases[0].database_name = `${projectName}-production`
|
|
49
|
+
wranglerJson.env.preview.d1_databases[0].database_name = `${projectName}-preview`
|
|
50
|
+
wranglerJson.env.test.d1_databases[0].database_name = `${projectName}-test`
|
|
51
|
+
wranglerJson.env.production.d1_databases[0].database_id = "<DATABASE_ID>"
|
|
52
|
+
wranglerJson.env.preview.d1_databases[0].database_id = "<DATABASE_ID>"
|
|
53
|
+
await write(
|
|
54
|
+
`${projectName}/wrangler.json`,
|
|
55
|
+
JSON.stringify(wranglerJson, null, 2),
|
|
56
|
+
)
|
|
57
|
+
updatingWranglerJsonSpinner.succeed()
|
|
58
|
+
} catch (error) {
|
|
59
|
+
updatingWranglerJsonSpinner.warn()
|
|
60
|
+
console.error(chalk.yellow("Issue with updating wrangler.json"))
|
|
61
|
+
if (error instanceof Error) {
|
|
62
|
+
console.error(chalk.yellow(error.message))
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Done
|
|
67
|
+
console.log(chalk.green("🎉 Done! Your project is ready to go."))
|
|
68
|
+
console.log(chalk.green.bold(`cd ${projectName}`))
|
|
69
|
+
console.log(chalk.green.bold("bun run dev"))
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pagezero",
|
|
3
|
-
"version": "0.0.1",
|
|
4
3
|
"description": "A CLI tool for PageZERO stack",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"bin": {
|
|
@@ -21,12 +20,12 @@
|
|
|
21
20
|
"license": "MIT",
|
|
22
21
|
"repository": {
|
|
23
22
|
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/pagezero-dev/
|
|
23
|
+
"url": "git+https://github.com/pagezero-dev/cli.git"
|
|
25
24
|
},
|
|
26
25
|
"bugs": {
|
|
27
|
-
"url": "https://github.com/pagezero-dev/
|
|
26
|
+
"url": "https://github.com/pagezero-dev/cli/issues"
|
|
28
27
|
},
|
|
29
|
-
"homepage": "https://github.com/pagezero-dev/
|
|
28
|
+
"homepage": "https://github.com/pagezero-dev/cli#readme",
|
|
30
29
|
"scripts": {
|
|
31
30
|
"check": "biome check",
|
|
32
31
|
"check:fix": "biome check --write",
|
|
@@ -38,5 +37,12 @@
|
|
|
38
37
|
},
|
|
39
38
|
"peerDependencies": {
|
|
40
39
|
"typescript": "^5"
|
|
41
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@inquirer/prompts": "7.8.6",
|
|
43
|
+
"chalk": "5.6.2",
|
|
44
|
+
"commander": "14.0.1",
|
|
45
|
+
"ora": "9.0.0"
|
|
46
|
+
},
|
|
47
|
+
"version": "0.2.0"
|
|
42
48
|
}
|