create-apexjs 0.1.2 → 0.1.3

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/dist/index.js +58 -8
  2. package/package.json +7 -7
  3. package/LICENSE +0 -21
package/dist/index.js CHANGED
@@ -4,15 +4,40 @@
4
4
  import { cpSync, existsSync, readdirSync, readFileSync, renameSync, writeFileSync } from "fs";
5
5
  import { basename, join, resolve } from "path";
6
6
  import { fileURLToPath } from "url";
7
+ import { spawnSync } from "child_process";
7
8
  import { defineCommand, runMain } from "citty";
8
9
  var TEMPLATE_DIR = fileURLToPath(new URL("../templates/default", import.meta.url));
10
+ function detectPackageManager() {
11
+ const ua = process.env.npm_config_user_agent || "";
12
+ if (ua.startsWith("pnpm")) return "pnpm";
13
+ if (ua.startsWith("yarn")) return "yarn";
14
+ if (ua.startsWith("bun")) return "bun";
15
+ return "npm";
16
+ }
17
+ function run(cmd, cmdArgs, cwd, quiet = false) {
18
+ const res = spawnSync(cmd, cmdArgs, {
19
+ cwd,
20
+ stdio: quiet ? "ignore" : "inherit",
21
+ // On Windows, npm/pnpm/yarn are .cmd shims that need a shell.
22
+ shell: process.platform === "win32"
23
+ });
24
+ return res.status === 0;
25
+ }
26
+ var c = {
27
+ cyan: (s) => `\x1B[36m${s}\x1B[0m`,
28
+ dim: (s) => `\x1B[2m${s}\x1B[0m`,
29
+ green: (s) => `\x1B[32m${s}\x1B[0m`,
30
+ yellow: (s) => `\x1B[33m${s}\x1B[0m`
31
+ };
9
32
  var main = defineCommand({
10
33
  meta: {
11
34
  name: "create-apexjs",
12
35
  description: "Scaffold a new Apex JS app"
13
36
  },
14
37
  args: {
15
- dir: { type: "positional", required: false, description: "Target directory", default: "apex-app" }
38
+ dir: { type: "positional", required: false, description: "Target directory", default: "apex-app" },
39
+ install: { type: "boolean", default: true, description: "Install dependencies (use --no-install to skip)" },
40
+ git: { type: "boolean", default: true, description: "Initialize a git repository (use --no-git to skip)" }
16
41
  },
17
42
  run({ args }) {
18
43
  const target = resolve(process.cwd(), args.dir);
@@ -33,14 +58,39 @@ var main = defineCommand({
33
58
  }
34
59
  }
35
60
  console.log(`
36
- \x1B[36mApex JS\x1B[0m app created in ${args.dir}
37
-
38
- Next steps:
39
- cd ${args.dir}
40
- npm install
41
- npm run dev # http://localhost:3000
42
- npm run dev:islands # static-first islands mode
61
+ ${c.cyan("Apex JS")} app created in ${args.dir}`);
62
+ const pm = detectPackageManager();
63
+ let gitOk = false;
64
+ if (args.git) {
65
+ const hasGit = spawnSync("git", ["--version"], { stdio: "ignore", shell: process.platform === "win32" }).status === 0;
66
+ if (hasGit && run("git", ["init", "-q"], target, true)) {
67
+ run("git", ["add", "-A"], target, true);
68
+ run("git", ["commit", "-m", "Initial commit from Apex JS", "--no-gpg-sign"], target, true);
69
+ gitOk = true;
70
+ }
71
+ }
72
+ let installed = false;
73
+ if (args.install) {
74
+ console.log(`
75
+ Installing dependencies with ${c.cyan(pm)}\u2026
76
+ `);
77
+ installed = run(pm, ["install"], target);
78
+ if (!installed) {
79
+ console.log(`
80
+ ${c.yellow("\u26A0")} Dependency install failed \u2014 run it yourself after cd'ing in.
81
+ `);
82
+ }
83
+ }
84
+ const runPrefix = pm === "npm" ? "npm run" : pm;
85
+ const steps = [`cd ${args.dir}`];
86
+ if (!installed) steps.push(pm === "yarn" ? "yarn" : `${pm} install`);
87
+ steps.push(`${runPrefix} dev ${c.dim("# http://localhost:3000")}`);
88
+ steps.push(`${runPrefix} dev:islands ${c.dim("# static-first islands mode")}`);
89
+ console.log(`
90
+ ${installed ? c.green("Ready.") : "Next steps:"}
91
+ ${steps.map((s) => ` ${s}`).join("\n")}
43
92
 
93
+ ${gitOk ? c.dim("Git repository initialized.") : ""}
44
94
  Your server/api/*.ts routes are also MCP tools at /mcp.
45
95
  `);
46
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-apexjs",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Scaffold a new Apex JS app",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,15 +28,15 @@
28
28
  "dist",
29
29
  "templates"
30
30
  ],
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "dev": "tsup --watch",
34
+ "typecheck": "tsc --noEmit"
35
+ },
31
36
  "dependencies": {
32
37
  "citty": "^0.1.6"
33
38
  },
34
39
  "engines": {
35
40
  "node": ">=20.19"
36
- },
37
- "scripts": {
38
- "build": "tsup",
39
- "dev": "tsup --watch",
40
- "typecheck": "tsc --noEmit"
41
41
  }
42
- }
42
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Andre Corugda
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.