@camox/cli 0.3.1 → 0.4.1

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 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,50 @@ async function init() {
327
304
  p2.cancel(`Directory ${targetDir} is not empty.`);
328
305
  process.exit(1);
329
306
  }
330
- const detected = detectPackageManager();
331
- let pm;
332
- if (detected) {
333
- pm = detected;
334
- p2.log.info(`Detected package manager: ${detected}`);
335
- } else {
336
- const selected = await p2.select({
337
- message: "Which package manager?",
338
- options: [
339
- { value: "pnpm", label: "pnpm" },
340
- { value: "bun", label: "bun" },
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
+ `);
328
+ fs3.writeFileSync(
329
+ path3.join(targetDir, ".gitignore"),
330
+ `node_modules
331
+ .DS_Store
332
+ dist
333
+ dist-ssr
334
+ *.local
335
+ count.txt
336
+ .env
337
+ .nitro
338
+ .tanstack
339
+ .output
340
+ .vinxi
341
+
342
+ # Auto generated by Camox
343
+ src/camox/app.ts
344
+ src/routes/_camox.tsx
345
+ src/routes/_camox/
346
+
347
+ # Auto generated by Tanstack Router
348
+ src/routeTree.gen.ts
349
+ `
350
+ );
357
351
  s.stop("Project scaffolded!");
358
352
  function dropIntoProject() {
359
353
  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.1",
3
+ "version": "0.4.1",
4
4
  "bin": {
5
5
  "camox": "./dist/index.js"
6
6
  },
@@ -25,7 +25,7 @@
25
25
  "@typescript/native-preview": "7.0.0-dev.20260412.1",
26
26
  "oxlint": "^0.15.0",
27
27
  "tsup": "^8.4.0",
28
- "@camox/api": "0.3.1"
28
+ "@camox/api": "0.4.1"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "tsup",
@@ -0,0 +1,2 @@
1
+ # Required — retrieve from https://camox.ai/dashboard
2
+ CAMOX_SYNC_SECRET=
@@ -3,7 +3,7 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "scripts": {
6
- "dev": "vite dev --port 3000",
6
+ "dev": "vite dev --port 7400",
7
7
  "start": "node .output/server/index.mjs",
8
8
  "build": "vite build",
9
9
  "serve": "vite preview",
@@ -13,7 +13,9 @@
13
13
  "dependencies": {
14
14
  "@radix-ui/react-slot": "^1.2.4",
15
15
  "@tailwindcss/vite": "^4.2.2",
16
+ "@tanstack/react-query": "^5.99.0",
16
17
  "@tanstack/react-router": "^1.168.18",
18
+ "@tanstack/react-router-ssr-query": "^1.166.11",
17
19
  "@tanstack/react-start": "^1.167.32",
18
20
  "@tanstack/router-plugin": "^1.167.18",
19
21
  "camox": "{{camoxVersion}}",
@@ -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>;
@@ -3,15 +3,18 @@ import tailwindcss from "@tailwindcss/vite";
3
3
  import { tanstackStart } from "@tanstack/react-start/plugin/vite";
4
4
  import react, { reactCompilerPreset } from "@vitejs/plugin-react";
5
5
  import { camox } from "camox/vite";
6
- import { defineConfig } from "vite";
6
+ import { defineConfig, loadEnv } from "vite";
7
7
 
8
- export default defineConfig({
9
- resolve: { tsconfigPaths: true },
10
- plugins: [
11
- tailwindcss(),
12
- camox({ projectSlug: "{{projectSlug}}", syncSecret: "{{syncSecret}}" }),
13
- tanstackStart(),
14
- react(),
15
- babelPlugin({ presets: [reactCompilerPreset()] }),
16
- ],
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
+ };
17
20
  });