pagezero 0.3.0 → 0.4.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.
Files changed (2) hide show
  1. package/bin/pagezero.ts +2 -117
  2. package/package.json +7 -7
package/bin/pagezero.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { confirm, input } from "@inquirer/prompts"
4
- import boxen from "boxen"
5
- import { $, file, write } from "bun"
6
- import chalk from "chalk"
7
3
  import { program } from "commander"
8
- import logSymbols from "log-symbols"
9
- import ora from "ora"
4
+ import { init } from "../src/commands/init"
5
+ import { upgrade } from "../src/commands/upgrade"
10
6
 
11
7
  program
12
8
  .description("PageZERO CLI")
@@ -17,114 +13,3 @@ program.command("init").description("initialize a new project").action(init)
17
13
  program.command("upgrade").description("upgrade pagezero stack").action(upgrade)
18
14
 
19
15
  program.parse()
20
-
21
- async function init() {
22
- // Welcome
23
- console.log(chalk.green("👋 Welcome to PageZERO CLI"))
24
- console.log(chalk.green("🚀 Let's get you started with your project!"))
25
-
26
- // Bootstrap the project
27
- const projectName = await input({
28
- message: "What is the name of your project?",
29
- })
30
- const creatingProjectSpinner = ora(
31
- `Running: bun create pagezero-dev/pagezero --no-install ${projectName}`,
32
- ).start()
33
- await $`bun create pagezero-dev/pagezero --no-install ${projectName}`.quiet()
34
- creatingProjectSpinner.succeed()
35
-
36
- // Install dependencies
37
- const installingDependenciesSpinner = ora(`Running: bun install`).start()
38
- await $`bun install`.quiet().cwd(projectName)
39
- installingDependenciesSpinner.succeed()
40
-
41
- // Run setup script
42
- const runningSetupScriptSpinner = ora(`Running: bun run setup`).start()
43
- await $`bun run setup`.quiet().cwd(projectName)
44
- runningSetupScriptSpinner.succeed()
45
-
46
- // Update wrangler.json
47
- const updatingWranglerJsonSpinner = ora(`Updating wrangler.json`).start()
48
- try {
49
- const wranglerJson = await file(`${projectName}/wrangler.json`).json()
50
- wranglerJson.name = projectName
51
- wranglerJson.d1_databases[0].database_name = `${projectName}-development`
52
- wranglerJson.env.production.d1_databases[0].database_name = `${projectName}-production`
53
- wranglerJson.env.preview.d1_databases[0].database_name = `${projectName}-preview`
54
- wranglerJson.env.test.d1_databases[0].database_name = `${projectName}-test`
55
- wranglerJson.env.production.d1_databases[0].database_id = "<DATABASE_ID>"
56
- wranglerJson.env.preview.d1_databases[0].database_id = "<DATABASE_ID>"
57
- await write(
58
- `${projectName}/wrangler.json`,
59
- JSON.stringify(wranglerJson, null, 2),
60
- )
61
- updatingWranglerJsonSpinner.succeed()
62
- } catch (error) {
63
- updatingWranglerJsonSpinner.warn()
64
- console.error(chalk.yellow("Issue with updating wrangler.json"))
65
- if (error instanceof Error) {
66
- console.error(chalk.yellow(error.message))
67
- }
68
- }
69
-
70
- // Done
71
- console.log(chalk.green("🎉 Done! Your project is ready to go."))
72
- console.log(chalk.green.bold(`cd ${projectName}`))
73
- console.log(chalk.green.bold("bun run dev"))
74
- }
75
-
76
- async function upgrade() {
77
- console.log(
78
- chalk.yellow(
79
- boxen(
80
- "Ugrade command is primitive. It will overwrite your existing \nproject files with the latest version of the PageZERO stack. \nAfterwards please review the changes through a git diff.",
81
- { padding: 1, title: "WARNING", titleAlignment: "center" },
82
- ),
83
- ),
84
- )
85
-
86
- const shouldProceed = await confirm({
87
- message: "Do you want to proceed?",
88
- })
89
-
90
- if (!shouldProceed) {
91
- return
92
- }
93
-
94
- const rsync = await $`command -v rsync`.quiet()
95
- if (rsync.stdout) {
96
- console.log(`${logSymbols.success} rsync is installed`)
97
- } else {
98
- console.log(
99
- `${logSymbols.error} rsync is not installed and is required for the upgrade command: please install it and try again`,
100
- )
101
- return
102
- }
103
-
104
- const wranglerFile = file(`wrangler.json`)
105
- if (await wranglerFile.exists()) {
106
- console.log(`${logSymbols.success} wrangler.json file found`)
107
- } else {
108
- console.log(
109
- `${logSymbols.error} wrangler.json file not found: please run command within PageZERO project directory`,
110
- )
111
- return
112
- }
113
-
114
- const clonePagezeroSpinner = ora(`downloading latest PageZERO stack`).start()
115
- await $`git clone --depth 1 https://github.com/pagezero-dev/pagezero.git pagezero-latest`.quiet()
116
- clonePagezeroSpinner.succeed()
117
-
118
- const copyPagezeroSpinner = ora(
119
- `copying PageZERO stack to project directory`,
120
- ).start()
121
- await $`rsync -a --exclude=".git" ./pagezero-latest/ ./`.quiet()
122
- copyPagezeroSpinner.succeed()
123
-
124
- const cleanupSpinner = ora(`cleaning up`).start()
125
- await $`rm -rf pagezero-latest`.quiet()
126
- cleanupSpinner.succeed()
127
-
128
- console.log(chalk.green("PageZERO stack upgraded successfully"))
129
- console.log(chalk.green.bold("Please review the changes through a git diff"))
130
- }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bin/"
10
10
  ],
11
11
  "engines": {
12
- "bun": ">=1.2.20"
12
+ "bun": ">=1.3.1"
13
13
  },
14
14
  "keywords": [
15
15
  "cli",
@@ -32,19 +32,19 @@
32
32
  "check:types": "tsc"
33
33
  },
34
34
  "devDependencies": {
35
- "@biomejs/biome": "2.2.4",
36
- "@types/bun": "1.2.20"
35
+ "@biomejs/biome": "2.3.3",
36
+ "@types/bun": "1.3.1"
37
37
  },
38
38
  "peerDependencies": {
39
- "typescript": "^5"
39
+ "typescript": "^5.9.3"
40
40
  },
41
41
  "dependencies": {
42
- "@inquirer/prompts": "7.8.6",
42
+ "@inquirer/prompts": "7.9.0",
43
43
  "boxen": "8.0.1",
44
44
  "chalk": "5.6.2",
45
- "commander": "14.0.1",
45
+ "commander": "14.0.2",
46
46
  "log-symbols": "7.0.1",
47
47
  "ora": "9.0.0"
48
48
  },
49
- "version": "0.3.0"
49
+ "version": "0.4.0"
50
50
  }