@camox/cli 0.2.0-alpha.4 → 0.3.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.
@@ -5,7 +5,7 @@ import {
5
5
  listOrganizations,
6
6
  setActiveOrganization,
7
7
  verifySession
8
- } from "./chunk-KYDY3NNE.js";
8
+ } from "./chunk-5VGGMUU6.js";
9
9
  export {
10
10
  createOrganization,
11
11
  createProject,
@@ -61,9 +61,9 @@ async function setActiveOrganization(token, organizationId) {
61
61
  throw new Error(`Failed to set active organization: ${res.status}`);
62
62
  }
63
63
  }
64
- async function createProject(token, name, organizationSlug) {
64
+ async function createProject(token, name, organizationId) {
65
65
  const client = createRpcClient(token);
66
- const result = await client.projects.create({ name, organizationSlug });
66
+ const result = await client.projects.create({ name, organizationId });
67
67
  return result;
68
68
  }
69
69
 
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createProject,
6
6
  listOrganizations,
7
7
  setActiveOrganization
8
- } from "./chunk-KYDY3NNE.js";
8
+ } from "./chunk-5VGGMUU6.js";
9
9
 
10
10
  // src/index.ts
11
11
  import { or } from "@optique/core/constructs";
@@ -20,7 +20,7 @@ __export(init_exports, {
20
20
  init: () => init,
21
21
  parser: () => parser
22
22
  });
23
- import { execSync as execSync3, spawn, spawnSync } from "child_process";
23
+ import { spawn, spawnSync } from "child_process";
24
24
  import fs3 from "fs";
25
25
  import path3 from "path";
26
26
  import { fileURLToPath } from "url";
@@ -172,7 +172,7 @@ async function authenticateUser() {
172
172
  async function getOrAuthenticate() {
173
173
  const stored = readAuthToken();
174
174
  if (stored) {
175
- const { verifySession } = await import("./api-4OWBCL7B.js");
175
+ const { verifySession } = await import("./api-C4HUA6JP.js");
176
176
  const valid = await verifySession(stored.token);
177
177
  if (valid) {
178
178
  p.log.info(`Authenticated as ${stored.name}`);
@@ -187,7 +187,6 @@ async function getOrAuthenticate() {
187
187
  }
188
188
 
189
189
  // src/lib/utils.ts
190
- import { execSync as execSync2 } from "child_process";
191
190
  import fs2 from "fs";
192
191
  import path2 from "path";
193
192
  var pmCommands = {
@@ -222,14 +221,6 @@ function detectPackageManager() {
222
221
  }
223
222
  return null;
224
223
  }
225
- function isInsideGitRepo() {
226
- try {
227
- execSync2("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
228
- return true;
229
- } catch {
230
- return false;
231
- }
232
- }
233
224
  function copyDir(src, dest, replacements) {
234
225
  fs2.mkdirSync(dest, { recursive: true });
235
226
  for (const entry of fs2.readdirSync(src, { withFileTypes: true })) {
@@ -281,7 +272,7 @@ async function selectOrCreateOrganization(token) {
281
272
  }
282
273
  const org = orgs.find((o) => o.id === selected);
283
274
  await setActiveOrganization(token, org.id);
284
- return org.slug;
275
+ return org.id;
285
276
  }
286
277
  async function promptCreateOrganization(token) {
287
278
  const orgName = await p2.text({
@@ -295,7 +286,7 @@ async function promptCreateOrganization(token) {
295
286
  const orgSlug = slugify(orgName);
296
287
  const org = await createOrganization(token, orgName, orgSlug);
297
288
  p2.log.success(`Created organization: ${org.name}`);
298
- return org.slug;
289
+ return org.id;
299
290
  }
300
291
  async function init() {
301
292
  p2.intro("camox init");
@@ -320,12 +311,12 @@ async function init() {
320
311
  );
321
312
  const targetDir = path3.resolve(result2.path);
322
313
  const auth = await getOrAuthenticate();
323
- const orgSlug = await selectOrCreateOrganization(auth.token);
314
+ const orgId = await selectOrCreateOrganization(auth.token);
324
315
  const s0 = p2.spinner();
325
316
  s0.start("Creating project...");
326
317
  let project;
327
318
  try {
328
- project = await createProject(auth.token, result2.name, orgSlug);
319
+ project = await createProject(auth.token, result2.name, orgId);
329
320
  s0.stop(`Project created with slug: ${project.slug}`);
330
321
  } catch (err) {
331
322
  s0.stop("Failed to create project.");
@@ -336,16 +327,6 @@ async function init() {
336
327
  p2.cancel(`Directory ${targetDir} is not empty.`);
337
328
  process.exit(1);
338
329
  }
339
- const alreadyInRepo = isInsideGitRepo();
340
- let initGit = false;
341
- if (!alreadyInRepo) {
342
- const answer = await p2.confirm({
343
- message: "Initialize a git repository?",
344
- initialValue: true
345
- });
346
- if (p2.isCancel(answer)) return onCancel();
347
- initGit = answer;
348
- }
349
330
  const detected = detectPackageManager();
350
331
  let pm;
351
332
  if (detected) {
@@ -380,14 +361,6 @@ async function init() {
380
361
  spawnSync(shell, [], { cwd: targetDir, stdio: "inherit" });
381
362
  process.exit(0);
382
363
  }
383
- if (initGit) {
384
- try {
385
- execSync3("git init", { cwd: targetDir, stdio: "ignore" });
386
- p2.log.success("Initialized git repository.");
387
- } catch {
388
- p2.log.warn("Could not initialize git repository.");
389
- }
390
- }
391
364
  const { install: installCmd, dev: devCmd } = pmCommands[pm];
392
365
  const [installBin, ...installArgs] = installCmd.split(" ");
393
366
  const s2 = p2.spinner();
@@ -410,18 +383,6 @@ async function init() {
410
383
  p2.log.error(`Failed to install dependencies. Run "${installCmd}" manually.`);
411
384
  dropIntoProject();
412
385
  }
413
- if (initGit) {
414
- try {
415
- execSync3("git add -A", { cwd: targetDir, stdio: "ignore" });
416
- execSync3('git commit -m "Initial commit from camox init"', {
417
- cwd: targetDir,
418
- stdio: "ignore"
419
- });
420
- p2.log.success("Created initial commit.");
421
- } catch {
422
- p2.log.warn("Could not create initial commit.");
423
- }
424
- }
425
386
  p2.outro(`Starting dev server...`);
426
387
  const [cmd, ...args] = devCmd.split(" ");
427
388
  const child = spawn(cmd, args, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camox/cli",
3
- "version": "0.2.0-alpha.4",
3
+ "version": "0.3.0",
4
4
  "bin": {
5
5
  "camox": "./dist/index.js"
6
6
  },
@@ -25,7 +25,8 @@
25
25
  "@typescript/native-preview": "^7.0.0-dev",
26
26
  "oxlint": "^0.15.0",
27
27
  "tsup": "^8.4.0",
28
- "typescript": "^5.7.2"
28
+ "typescript": "^5.7.2",
29
+ "@camox/api": "0.3.0"
29
30
  },
30
31
  "scripts": {
31
32
  "build": "tsup",
@@ -0,0 +1,29 @@
1
+ import { createFileRoute } from "@tanstack/react-router";
2
+ import { generateSitemap } from "camox/metadata";
3
+
4
+ export const Route = createFileRoute("/sitemap.xml")({
5
+ server: {
6
+ handlers: {
7
+ GET: async ({ request }) => {
8
+ const origin = new URL(request.url).origin;
9
+ const entries = await generateSitemap(origin);
10
+
11
+ const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
12
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
13
+ ${entries
14
+ .map(
15
+ (entry) => ` <url>
16
+ <loc>${entry.loc}</loc>
17
+ <lastmod>${entry.lastmod}</lastmod>
18
+ </url>`,
19
+ )
20
+ .join("\n")}
21
+ </urlset>`;
22
+
23
+ return new Response(sitemap, {
24
+ headers: { "Content-Type": "application/xml" },
25
+ });
26
+ },
27
+ },
28
+ },
29
+ });