@camox/cli 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.
- package/dist/index.js +13 -42
- package/package.json +6 -7
- package/template/.env.example +2 -0
- package/template/package.json +15 -11
- package/template/src/router.tsx +15 -0
- package/template/vite.config.ts +15 -10
package/dist/index.js
CHANGED
|
@@ -198,29 +198,6 @@ var pmCommands = {
|
|
|
198
198
|
function slugify(name) {
|
|
199
199
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
200
200
|
}
|
|
201
|
-
function detectPackageManager() {
|
|
202
|
-
const userAgent = process.env.npm_config_user_agent;
|
|
203
|
-
if (userAgent) {
|
|
204
|
-
const name = userAgent.split("/")[0];
|
|
205
|
-
if (name === "pnpm") return "pnpm";
|
|
206
|
-
if (name === "bun") return "bun";
|
|
207
|
-
if (name === "npm" || name === "npx") return "npm";
|
|
208
|
-
if (name === "yarn") return "yarn";
|
|
209
|
-
}
|
|
210
|
-
let dir = process.cwd();
|
|
211
|
-
const root = path2.parse(dir).root;
|
|
212
|
-
while (true) {
|
|
213
|
-
if (fs2.existsSync(path2.join(dir, "pnpm-lock.yaml")) || fs2.existsSync(path2.join(dir, "pnpm-workspace.yaml")))
|
|
214
|
-
return "pnpm";
|
|
215
|
-
if (fs2.existsSync(path2.join(dir, "bun.lockb")) || fs2.existsSync(path2.join(dir, "bun.lock")))
|
|
216
|
-
return "bun";
|
|
217
|
-
if (fs2.existsSync(path2.join(dir, "package-lock.json"))) return "npm";
|
|
218
|
-
if (fs2.existsSync(path2.join(dir, "yarn.lock"))) return "yarn";
|
|
219
|
-
if (dir === root) break;
|
|
220
|
-
dir = path2.dirname(dir);
|
|
221
|
-
}
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
201
|
function copyDir(src, dest, replacements) {
|
|
225
202
|
fs2.mkdirSync(dest, { recursive: true });
|
|
226
203
|
for (const entry of fs2.readdirSync(src, { withFileTypes: true })) {
|
|
@@ -327,33 +304,27 @@ async function init() {
|
|
|
327
304
|
p2.cancel(`Directory ${targetDir} is not empty.`);
|
|
328
305
|
process.exit(1);
|
|
329
306
|
}
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
{ value: "npm", label: "npm" },
|
|
342
|
-
{ value: "yarn", label: "yarn" }
|
|
343
|
-
]
|
|
344
|
-
});
|
|
345
|
-
if (p2.isCancel(selected)) return onCancel();
|
|
346
|
-
pm = selected;
|
|
347
|
-
}
|
|
307
|
+
const selected = await p2.select({
|
|
308
|
+
message: "Which package manager?",
|
|
309
|
+
options: [
|
|
310
|
+
{ value: "pnpm", label: "pnpm (recommended)" },
|
|
311
|
+
{ value: "bun", label: "bun" },
|
|
312
|
+
{ value: "npm", label: "npm" },
|
|
313
|
+
{ value: "yarn", label: "yarn" }
|
|
314
|
+
]
|
|
315
|
+
});
|
|
316
|
+
if (p2.isCancel(selected)) return onCancel();
|
|
317
|
+
const pm = selected;
|
|
348
318
|
const s = p2.spinner();
|
|
349
319
|
s.start("Scaffolding project...");
|
|
350
320
|
const templateDir = path3.resolve(__dirname, "..", "template");
|
|
351
321
|
copyDir(templateDir, targetDir, {
|
|
352
322
|
"{{projectName}}": result2.name,
|
|
353
323
|
"{{projectSlug}}": project.slug,
|
|
354
|
-
"{{syncSecret}}": project.syncSecret,
|
|
355
324
|
"{{camoxVersion}}": ownPkg.version
|
|
356
325
|
});
|
|
326
|
+
fs3.writeFileSync(path3.join(targetDir, ".env"), `CAMOX_SYNC_SECRET=${project.syncSecret}
|
|
327
|
+
`);
|
|
357
328
|
s.stop("Project scaffolded!");
|
|
358
329
|
function dropIntoProject() {
|
|
359
330
|
const shell = process.env.SHELL || "/bin/bash";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camox/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"camox": "./dist/index.js"
|
|
6
6
|
},
|
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
"@clack/prompts": "^0.10.0",
|
|
18
18
|
"@optique/core": "*",
|
|
19
19
|
"@optique/run": "*",
|
|
20
|
-
"@orpc/client": "^1.13.
|
|
21
|
-
"@orpc/server": "^1.13.
|
|
20
|
+
"@orpc/client": "^1.13.14",
|
|
21
|
+
"@orpc/server": "^1.13.14"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/node": "^24.
|
|
25
|
-
"@typescript/native-preview": "
|
|
24
|
+
"@types/node": "^24.12.2",
|
|
25
|
+
"@typescript/native-preview": "7.0.0-dev.20260412.1",
|
|
26
26
|
"oxlint": "^0.15.0",
|
|
27
27
|
"tsup": "^8.4.0",
|
|
28
|
-
"
|
|
29
|
-
"@camox/api": "0.3.0"
|
|
28
|
+
"@camox/api": "0.4.0"
|
|
30
29
|
},
|
|
31
30
|
"scripts": {
|
|
32
31
|
"build": "tsup",
|
package/template/package.json
CHANGED
|
@@ -11,29 +11,33 @@
|
|
|
11
11
|
"check": "tsgo --noEmit && oxlint --fix"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@radix-ui/react-slot": "^1.2.
|
|
14
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
15
15
|
"@tailwindcss/vite": "^4.2.2",
|
|
16
|
-
"@tanstack/react-
|
|
17
|
-
"@tanstack/react-
|
|
18
|
-
"@tanstack/router-
|
|
16
|
+
"@tanstack/react-query": "^5.99.0",
|
|
17
|
+
"@tanstack/react-router": "^1.168.18",
|
|
18
|
+
"@tanstack/react-router-ssr-query": "^1.166.11",
|
|
19
|
+
"@tanstack/react-start": "^1.167.32",
|
|
20
|
+
"@tanstack/router-plugin": "^1.167.18",
|
|
19
21
|
"camox": "{{camoxVersion}}",
|
|
20
22
|
"class-variance-authority": "^0.7.1",
|
|
21
23
|
"clsx": "^2.1.1",
|
|
22
24
|
"lucide-react": "^0.476.0",
|
|
23
|
-
"react": "^19.
|
|
24
|
-
"react-dom": "^19.
|
|
25
|
-
"tailwind-merge": "^3.0
|
|
25
|
+
"react": "^19.2.5",
|
|
26
|
+
"react-dom": "^19.2.5",
|
|
27
|
+
"tailwind-merge": "^3.5.0",
|
|
26
28
|
"tailwindcss": "^4.0.6"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
31
|
+
"@babel/core": "^7.29.0",
|
|
32
|
+
"@rolldown/plugin-babel": "^0.2.2",
|
|
33
|
+
"@types/babel__core": "^7.20.5",
|
|
29
34
|
"@types/react": "^19.0.8",
|
|
30
|
-
"@types/react-dom": "^19.
|
|
35
|
+
"@types/react-dom": "^19.2.3",
|
|
31
36
|
"@typescript/native-preview": "^7.0.0-dev",
|
|
32
37
|
"@vitejs/plugin-react": "^6.0.1",
|
|
33
|
-
"babel-plugin-react-compiler": "
|
|
38
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
34
39
|
"oxlint": "^0.15.15",
|
|
35
|
-
"tw-animate-css": "^1.
|
|
36
|
-
"typescript": "^5.7.2",
|
|
40
|
+
"tw-animate-css": "^1.4.0",
|
|
37
41
|
"vite": "8.0.1"
|
|
38
42
|
}
|
|
39
43
|
}
|
package/template/src/router.tsx
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
1
2
|
import { createRouter as createTanstackRouter } from "@tanstack/react-router";
|
|
3
|
+
import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
|
|
2
4
|
|
|
3
5
|
import { routeTree } from "./routeTree.gen";
|
|
4
6
|
|
|
5
7
|
export function getRouter() {
|
|
8
|
+
const queryClient = new QueryClient();
|
|
9
|
+
|
|
6
10
|
const router = createTanstackRouter({
|
|
7
11
|
routeTree,
|
|
8
12
|
defaultPreload: "intent",
|
|
13
|
+
// Providing queryClient to the router context is required by Camox.
|
|
14
|
+
// All Camox queries start with a "camox" prefix in the query key array,
|
|
15
|
+
// so you can share the same client without risking conflicting keys.
|
|
16
|
+
context: { queryClient },
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
setupRouterSsrQueryIntegration({
|
|
20
|
+
router,
|
|
21
|
+
queryClient,
|
|
22
|
+
wrapQueryClient: true,
|
|
9
23
|
});
|
|
10
24
|
|
|
11
25
|
return router;
|
|
12
26
|
}
|
|
13
27
|
|
|
28
|
+
// Register the router instance for type safety
|
|
14
29
|
declare module "@tanstack/react-router" {
|
|
15
30
|
interface Register {
|
|
16
31
|
router: ReturnType<typeof getRouter>;
|
package/template/vite.config.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import babelPlugin from "@rolldown/plugin-babel";
|
|
1
2
|
import tailwindcss from "@tailwindcss/vite";
|
|
2
3
|
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
3
|
-
import
|
|
4
|
+
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
4
5
|
import { camox } from "camox/vite";
|
|
5
|
-
import { defineConfig } from "vite";
|
|
6
|
+
import { defineConfig, loadEnv } from "vite";
|
|
6
7
|
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export default defineConfig(({ mode }) => {
|
|
9
|
+
const env = loadEnv(mode, process.cwd(), "CAMOX_");
|
|
10
|
+
return {
|
|
11
|
+
resolve: { tsconfigPaths: true },
|
|
12
|
+
plugins: [
|
|
13
|
+
tailwindcss(),
|
|
14
|
+
camox({ projectSlug: "{{projectSlug}}", syncSecret: env.CAMOX_SYNC_SECRET }),
|
|
15
|
+
tanstackStart(),
|
|
16
|
+
react(),
|
|
17
|
+
babelPlugin({ presets: [reactCompilerPreset()] }),
|
|
18
|
+
],
|
|
19
|
+
};
|
|
15
20
|
});
|