pagezero 0.1.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 +27 -3
- package/package.json +1 -1
package/bin/pagezero.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
3
|
import { input } from "@inquirer/prompts"
|
|
4
|
-
import {
|
|
4
|
+
import { $, file, write } from "bun"
|
|
5
5
|
import chalk from "chalk"
|
|
6
6
|
import { program } from "commander"
|
|
7
7
|
import ora from "ora"
|
|
@@ -31,14 +31,38 @@ async function init() {
|
|
|
31
31
|
|
|
32
32
|
// Install dependencies
|
|
33
33
|
const installingDependenciesSpinner = ora(`Running: bun install`).start()
|
|
34
|
-
await $`
|
|
34
|
+
await $`bun install`.quiet().cwd(projectName)
|
|
35
35
|
installingDependenciesSpinner.succeed()
|
|
36
36
|
|
|
37
37
|
// Run setup script
|
|
38
38
|
const runningSetupScriptSpinner = ora(`Running: bun run setup`).start()
|
|
39
|
-
await $`
|
|
39
|
+
await $`bun run setup`.quiet().cwd(projectName)
|
|
40
40
|
runningSetupScriptSpinner.succeed()
|
|
41
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
|
+
|
|
42
66
|
// Done
|
|
43
67
|
console.log(chalk.green("🎉 Done! Your project is ready to go."))
|
|
44
68
|
console.log(chalk.green.bold(`cd ${projectName}`))
|
package/package.json
CHANGED