pagezero 0.2.0 → 0.3.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 +61 -1
  2. package/package.json +3 -1
package/bin/pagezero.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { input } from "@inquirer/prompts"
3
+ import { confirm, input } from "@inquirer/prompts"
4
+ import boxen from "boxen"
4
5
  import { $, file, write } from "bun"
5
6
  import chalk from "chalk"
6
7
  import { program } from "commander"
8
+ import logSymbols from "log-symbols"
7
9
  import ora from "ora"
8
10
 
9
11
  program
@@ -12,6 +14,8 @@ program
12
14
 
13
15
  program.command("init").description("initialize a new project").action(init)
14
16
 
17
+ program.command("upgrade").description("upgrade pagezero stack").action(upgrade)
18
+
15
19
  program.parse()
16
20
 
17
21
  async function init() {
@@ -68,3 +72,59 @@ async function init() {
68
72
  console.log(chalk.green.bold(`cd ${projectName}`))
69
73
  console.log(chalk.green.bold("bun run dev"))
70
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
@@ -40,9 +40,11 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@inquirer/prompts": "7.8.6",
43
+ "boxen": "8.0.1",
43
44
  "chalk": "5.6.2",
44
45
  "commander": "14.0.1",
46
+ "log-symbols": "7.0.1",
45
47
  "ora": "9.0.0"
46
48
  },
47
- "version": "0.2.0"
49
+ "version": "0.3.0"
48
50
  }