create-kide-app 0.1.8 → 0.1.10

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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +42 -42
  3. package/package.json +4 -1
package/README.md CHANGED
@@ -5,7 +5,7 @@ Scaffold a new [Kide CMS](https://github.com/mhernesniemi/kide-cms) project.
5
5
  ## Usage
6
6
 
7
7
  ```bash
8
- pnpx create-kide-app my-project
8
+ pnpm create kide-app my-project
9
9
  ```
10
10
 
11
11
  The CLI asks for:
package/index.js CHANGED
@@ -5,7 +5,6 @@ import { execFileSync, execSync, spawn } from "node:child_process";
5
5
  import {
6
6
  cpSync,
7
7
  existsSync,
8
- mkdirSync,
9
8
  readFileSync,
10
9
  rmSync,
11
10
  writeFileSync,
@@ -169,9 +168,13 @@ async function main() {
169
168
  const branchArgs = templateRef ? ["--branch", templateRef] : [];
170
169
  // execFileSync, not execSync: no shell, so projectDir is passed as one argv entry
171
170
  // and can never be reinterpreted as a command regardless of what it contains.
172
- execFileSync("git", ["clone", "--depth", "1", ...branchArgs, REPO, projectDir], {
173
- stdio: "pipe",
174
- });
171
+ execFileSync(
172
+ "git",
173
+ ["clone", "--depth", "1", ...branchArgs, REPO, projectDir],
174
+ {
175
+ stdio: "pipe",
176
+ },
177
+ );
175
178
  try {
176
179
  templateCommit = execSync("git rev-parse HEAD", {
177
180
  cwd: projectDir,
@@ -208,31 +211,24 @@ async function main() {
208
211
  const targetDir = path.join(adaptersDir, target);
209
212
 
210
213
  if (target === "cloudflare") {
214
+ // The Cloudflare adapter/storage/env implementations live in the tree at
215
+ // src/cms/platform/cloudflare. We only copy the target's Astro/Drizzle/wrangler config and
216
+ // flip the two platform selectors to point at that profile — no source files are overwritten.
211
217
  cpSync(
212
218
  path.join(targetDir, "astro.config.mjs"),
213
219
  path.join(projectDir, "astro.config.mjs"),
214
220
  );
215
- cpSync(
216
- path.join(targetDir, "src/cms/adapters/db.ts"),
217
- path.join(projectDir, "src/cms/adapters/db.ts"),
218
- );
219
221
  cpSync(
220
222
  path.join(targetDir, "drizzle.config.ts"),
221
223
  path.join(projectDir, "drizzle.config.ts"),
222
224
  );
223
- cpSync(
224
- path.join(targetDir, "src/cms/adapters/storage.ts"),
225
- path.join(projectDir, "src/cms/adapters/storage.ts"),
226
- );
227
- cpSync(
228
- path.join(targetDir, "src/cms/adapters/cf-env.ts"),
229
- path.join(projectDir, "src/cms/adapters/cf-env.ts"),
225
+ writeFileSync(
226
+ path.join(projectDir, "src/cms/adapters/db.ts"),
227
+ 'export * from "../platform/cloudflare/database";\n',
230
228
  );
231
- const uploadsRouteDir = path.join(projectDir, "src/pages/uploads");
232
- mkdirSync(uploadsRouteDir, { recursive: true });
233
- cpSync(
234
- path.join(targetDir, "src/pages/uploads/[...path].ts"),
235
- path.join(uploadsRouteDir, "[...path].ts"),
229
+ writeFileSync(
230
+ path.join(projectDir, "src/cms/adapters/storage.ts"),
231
+ 'export * from "../platform/cloudflare/storage";\n',
236
232
  );
237
233
  }
238
234
 
@@ -243,7 +239,7 @@ async function main() {
243
239
 
244
240
  if (target === "cloudflare") {
245
241
  delete pkg.dependencies["@astrojs/node"];
246
- pkg.dependencies["@astrojs/cloudflare"] = "^13.0.0";
242
+ pkg.dependencies["@astrojs/cloudflare"] = "~14.1.7";
247
243
 
248
244
  // Move better-sqlite3 to devDependencies — drizzle-kit needs it to push schema to local D1
249
245
  if (pkg.dependencies["better-sqlite3"]) {
@@ -272,7 +268,7 @@ async function main() {
272
268
  );
273
269
  writeFileSync(path.join(projectDir, "wrangler.toml"), wranglerContent);
274
270
 
275
- pkg.devDependencies.wrangler = "^4.0.0";
271
+ pkg.devDependencies.wrangler = "^4.83.0";
276
272
 
277
273
  pkg.scripts.dev = "astro dev";
278
274
  pkg.scripts.build = "astro build";
@@ -483,22 +479,13 @@ async function main() {
483
479
 
484
480
  if (seedDemo && target === "local") {
485
481
  s.start("Pushing schema to database");
486
- // Ensure data/ directory exists drizzle-kit push silently exits 0 if it can't open the file
487
- mkdirSync(path.join(projectDir, "data"), { recursive: true });
488
- let pushOk = false;
482
+ // The guarded sync script (exits non-zero on failure, creates data/ itself)
483
+ // same path the dev server and deploys use.
489
484
  try {
490
- const out = execSync(`${pm.exec} drizzle-kit push --force`, {
491
- cwd: projectDir,
492
- stdio: "pipe",
493
- }).toString();
494
- pushOk = !out.includes("Error:") && out.includes("Changes applied");
495
- s.stop(
496
- pushOk
497
- ? "Schema pushed"
498
- : "Schema push failed — run `pnpm exec drizzle-kit push` manually",
499
- );
485
+ execSync(`${pm.run} cms:push`, { cwd: projectDir, stdio: "pipe" });
486
+ s.stop("Schema pushed");
500
487
  } catch {
501
- s.stop("Schema will be set up on first dev start");
488
+ s.stop("Schema push failed run `pnpm cms:push` manually");
502
489
  }
503
490
  s.start("Seeding demo content");
504
491
  try {
@@ -713,12 +700,25 @@ async function main() {
713
700
  // --- Done ---
714
701
 
715
702
  if (target === "local") {
716
- p.outro("Starting dev server...");
717
- try {
718
- execSync(`${pm.run} dev`, { cwd: projectDir, stdio: "inherit" });
719
- } catch {
720
- console.log(`\n Project directory: ${projectDir}`);
721
- console.log(` To start again: cd ${projectName} && pnpm dev\n`);
703
+ const startDev = await p.confirm({
704
+ message: "Start the dev server now?",
705
+ initialValue: true,
706
+ });
707
+
708
+ if (!p.isCancel(startDev) && startDev) {
709
+ p.outro("Starting dev server...");
710
+ try {
711
+ execSync(`${pm.run} dev`, { cwd: projectDir, stdio: "inherit" });
712
+ } catch {
713
+ console.log(`\n Project directory: ${projectDir}`);
714
+ console.log(` To start again: cd ${projectName} && pnpm dev\n`);
715
+ }
716
+ } else {
717
+ p.note(
718
+ [`cd ${projectName}`, "", `${pm.run} dev`].join("\n"),
719
+ "Next steps",
720
+ );
721
+ p.outro("Project created!");
722
722
  }
723
723
  } else {
724
724
  if (cf.deployed && cf.url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kide-app",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Scaffold a new Kide CMS project",
5
5
  "author": "Matti Hernesniemi",
6
6
  "license": "MIT",
@@ -8,6 +8,9 @@
8
8
  "bin": {
9
9
  "create-kide-app": "./index.js"
10
10
  },
11
+ "scripts": {
12
+ "release": "npm version patch && git push --follow-tags && npm publish"
13
+ },
11
14
  "files": [
12
15
  "index.js"
13
16
  ],