create-contentisland 0.4.1 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.js +287 -256
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { cac as pe } from "cac";
2
- import m from "prompts";
3
- import l from "node:fs/promises";
1
+ import { cac as fe } from "cac";
2
+ import u from "prompts";
3
+ import c from "node:fs/promises";
4
4
  import r from "node:path";
5
- import Q from "node:child_process";
6
- import { existsSync as S } from "node:fs";
7
- import { createClient as me } from "@content-island/api-client";
8
- const R = ".content-island", ee = "config.json", G = ".gitignore", b = ".env", J = {
5
+ import te from "node:child_process";
6
+ import { existsSync as v } from "node:fs";
7
+ import { createClient as we } from "@content-island/api-client";
8
+ const D = ".content-island", ne = "config.json", J = ".gitignore", T = ".env", V = {
9
9
  aa: "Afaraf",
10
10
  ab: "Аҧсуа",
11
11
  ae: "Avesta",
@@ -190,7 +190,7 @@ const R = ".content-island", ee = "config.json", G = ".gitignore", b = ".env", J
190
190
  za: "Zhuang",
191
191
  zh: "中文",
192
192
  zu: "isiZulu"
193
- }, p = {
193
+ }, m = {
194
194
  reset: "\x1B[0m",
195
195
  green: "\x1B[32m",
196
196
  red: "\x1B[31m",
@@ -198,16 +198,16 @@ const R = ".content-island", ee = "config.json", G = ".gitignore", b = ".env", J
198
198
  bold: "\x1B[1m",
199
199
  cyan: "\x1B[36m",
200
200
  magenta: "\x1B[35m"
201
- }, j = (e) => {
201
+ }, I = (e) => {
202
202
  let n = "";
203
- return e?.bold && (n += p.bold), n;
203
+ return e?.bold && (n += m.bold), n;
204
204
  }, g = {
205
- green: (e, n) => `${p.green}${j(n)}${e}${p.reset}`,
206
- red: (e, n) => `${p.red}${j(n)}${e}${p.reset}`,
207
- yellow: (e, n) => `${p.yellow}${j(n)}${e}${p.reset}`,
208
- bold: (e) => `${p.bold}${e}${p.reset}`,
209
- cyan: (e, n) => `${p.cyan}${j(n)}${e}${p.reset}`,
210
- magenta: (e, n) => `${p.magenta}${j(n)}${e}${p.reset}`
205
+ green: (e, n) => `${m.green}${I(n)}${e}${m.reset}`,
206
+ red: (e, n) => `${m.red}${I(n)}${e}${m.reset}`,
207
+ yellow: (e, n) => `${m.yellow}${I(n)}${e}${m.reset}`,
208
+ bold: (e) => `${m.bold}${e}${m.reset}`,
209
+ cyan: (e, n) => `${m.cyan}${I(n)}${e}${m.reset}`,
210
+ magenta: (e, n) => `${m.magenta}${I(n)}${e}${m.reset}`
211
211
  }, t = {
212
212
  info: (e) => console.log(g.cyan("ℹ️ " + e)),
213
213
  success: (e) => console.log(g.green("✅ " + e)),
@@ -233,61 +233,61 @@ const R = ".content-island", ee = "config.json", G = ".gitignore", b = ".env", J
233
233
  updating: (e) => console.log(g.green("🔄 " + e)),
234
234
  run: (e) => console.log(g.green("🚀 " + e)),
235
235
  command: (e) => console.log(" " + g.magenta(e, { bold: !0 }))
236
- }, D = () => r.join(process.cwd(), R), fe = async () => {
237
- const e = process.cwd(), n = r.join(e, G), a = `${R}/`;
236
+ }, M = () => r.join(process.cwd(), D), ye = async () => {
237
+ const e = process.cwd(), n = r.join(e, J), a = `${D}/`;
238
238
  let o = "";
239
- S(n) && (o = await l.readFile(n, "utf-8"), o.includes(a)) || (o = o + `${o.endsWith(`
239
+ v(n) && (o = await c.readFile(n, "utf-8"), o.includes(a)) || (o = o + `${o.endsWith(`
240
240
  `) ? "" : `
241
241
  `}${a}
242
- `, await l.writeFile(n, o, "utf-8"), t.saved(`Added ${a} to ${G}`));
243
- }, we = async () => {
244
- const e = D();
242
+ `, await c.writeFile(n, o, "utf-8"), t.saved(`Added ${a} to ${J}`));
243
+ }, he = async () => {
244
+ const e = M();
245
245
  try {
246
- S(e) || (await l.mkdir(e, { recursive: !0 }), t.created(`Created: ${R}/`)), await fe();
246
+ v(e) || (await c.mkdir(e, { recursive: !0 }), t.created(`Created: ${D}/`)), await ye();
247
247
  } catch (n) {
248
248
  t.error(`Failed to create config directory: ${n.message}`);
249
249
  }
250
- }, te = async () => r.join(D(), ee), M = async () => {
251
- const e = await te();
252
- if (!S(e))
250
+ }, ae = async () => r.join(M(), ne), O = async () => {
251
+ const e = await ae();
252
+ if (!v(e))
253
253
  return null;
254
254
  try {
255
- const n = await l.readFile(e, "utf-8");
255
+ const n = await c.readFile(e, "utf-8");
256
256
  return JSON.parse(n);
257
257
  } catch (n) {
258
- return t.warning(`Could not parse ${ee}: ${n.message}`), null;
258
+ return t.warning(`Could not parse ${ne}: ${n.message}`), null;
259
259
  }
260
- }, T = async (e) => {
260
+ }, $ = async (e) => {
261
261
  let n = {
262
262
  ...e
263
263
  };
264
- await we();
265
- const a = await te();
266
- if (S(a)) {
267
- const o = await M();
264
+ await he();
265
+ const a = await ae();
266
+ if (v(a)) {
267
+ const o = await O();
268
268
  o && (n = { ...o, ...e });
269
269
  }
270
270
  try {
271
271
  const o = JSON.stringify(n, null, 2);
272
- await l.writeFile(a, o, "utf-8"), t.saved(`Saved configuration to ${a}`);
272
+ await c.writeFile(a, o, "utf-8"), t.saved(`Saved configuration to ${a}`);
273
273
  } catch (o) {
274
274
  t.error(`Failed to save configuration: ${o.message}`);
275
275
  }
276
- }, ye = (e, n, a, o) => {
277
- let s = 0, i = n, c = !1, f = "", u = !1;
276
+ }, Ee = (e, n, a, o) => {
277
+ let s = 0, i = n, l = !1, f = "", p = !1;
278
278
  const C = ['"', "'", "`"].includes(a);
279
279
  for (let w = n; w < e.length; w++) {
280
280
  const d = e[w];
281
- if (u) {
282
- u = !1;
281
+ if (p) {
282
+ p = !1;
283
283
  continue;
284
284
  }
285
- if (d === "\\" && c) {
286
- u = !0;
285
+ if (d === "\\" && l) {
286
+ p = !0;
287
287
  continue;
288
288
  }
289
289
  if (C) {
290
- if (d === a && !c) {
290
+ if (d === a && !l) {
291
291
  if (s++, s === 1)
292
292
  continue;
293
293
  if (s === 2) {
@@ -295,11 +295,11 @@ const R = ".content-island", ee = "config.json", G = ".gitignore", b = ".env", J
295
295
  break;
296
296
  }
297
297
  }
298
- } else if (!c && (d === '"' || d === "'" || d === "`"))
299
- c = !0, f = d;
300
- else if (c && d === f)
301
- c = !1;
302
- else if (!c) {
298
+ } else if (!l && (d === '"' || d === "'" || d === "`"))
299
+ l = !0, f = d;
300
+ else if (l && d === f)
301
+ l = !1;
302
+ else if (!l) {
303
303
  if (d === a)
304
304
  s++;
305
305
  else if (d === o && (s--, s === 0)) {
@@ -309,37 +309,37 @@ const R = ".content-island", ee = "config.json", G = ".gitignore", b = ".env", J
309
309
  }
310
310
  }
311
311
  return i;
312
- }, P = async (e) => {
313
- const { filePath: n, property: a, startSymbol: o, endSymbol: s } = e, i = await l.readFile(n, "utf-8");
314
- let c = o;
315
- o === "[" && (c = "\\["), o === "{" && (c = "\\{"), o === "(" && (c = "\\(");
316
- const f = new RegExp(`${a}\\s*:\\s*(${c})`), u = i.match(f);
317
- if (!u)
312
+ }, x = async (e) => {
313
+ const { filePath: n, property: a, startSymbol: o, endSymbol: s } = e, i = await c.readFile(n, "utf-8");
314
+ let l = o;
315
+ o === "[" && (l = "\\["), o === "{" && (l = "\\{"), o === "(" && (l = "\\(");
316
+ const f = new RegExp(`${a}\\s*:\\s*(${l})`), p = i.match(f);
317
+ if (!p)
318
318
  return null;
319
- const C = i.indexOf(u[0]) + u[0].length - 1, w = ye(i, C, o, s);
319
+ const C = i.indexOf(p[0]) + p[0].length - 1, w = Ee(i, C, o, s);
320
320
  return i.substring(C, w);
321
- }, he = (e) => JSON.parse(
321
+ }, Se = (e) => JSON.parse(
322
322
  e.replace(/'/g, '"').replace(/(\w+):/g, '"$1":').replace(/,\s*}/g, "}").replace(/,\s*]/g, "]")
323
- ), ne = (e) => e.replace(/"/g, "'").replace(/'(\w+)':/g, "$1:"), Ee = async (e, n, a, o) => {
324
- let s = await P(a);
325
- if (s || (s = await P(o)), !s)
323
+ ), oe = (e) => e.replace(/"/g, "'").replace(/'(\w+)':/g, "$1:"), ke = async (e, n, a, o) => {
324
+ let s = await x(a);
325
+ if (s || (s = await x(o)), !s)
326
326
  throw new Error(
327
327
  `Could not find property '${a.property}' or fallback property '${o.property}' in file ${a.filePath}`
328
328
  );
329
- const i = ne(JSON.stringify(n, null, 2));
330
- return (await l.readFile(a.filePath, "utf-8")).replace(s, (f) => `${f},
329
+ const i = oe(JSON.stringify(n, null, 2));
330
+ return (await c.readFile(a.filePath, "utf-8")).replace(s, (f) => `${f},
331
331
  ${e}: ${i}`);
332
- }, ke = ".git", A = (e, n) => {
333
- const a = Q.spawn("git", ["clone", "--depth=1", e, n], { stdio: "inherit" });
332
+ }, ve = ".git", b = (e, n) => {
333
+ const a = te.spawn("git", ["clone", "--depth=1", e, n], { stdio: "inherit" });
334
334
  return new Promise((o, s) => {
335
335
  a.on("close", (i) => {
336
- l.rm(r.join(n, ke), { recursive: !0, force: !0 }).finally(() => {
336
+ c.rm(r.join(n, ve), { recursive: !0, force: !0 }).finally(() => {
337
337
  i === 0 ? o() : s(new Error("Failed to clone repository. Please make sure the target folder is empty and try again."));
338
338
  });
339
339
  });
340
340
  });
341
- }, F = (e) => {
342
- const n = Q.spawn("npm install", {
341
+ }, P = (e) => {
342
+ const n = te.spawn("npm install", {
343
343
  cwd: e,
344
344
  stdio: "inherit",
345
345
  shell: !0
@@ -351,157 +351,187 @@ const R = ".content-island", ee = "config.json", G = ".gitignore", b = ".env", J
351
351
  s === 0 || t.error("Failed to install dependencies. Please try running 'npm install' manually."), a();
352
352
  });
353
353
  });
354
- }, L = async (e) => {
355
- const n = r.join(e, "package.json"), a = await l.readFile(n, "utf-8"), o = JSON.parse(a);
354
+ }, A = async (e) => {
355
+ const n = r.join(e, "package.json"), a = await c.readFile(n, "utf-8"), o = JSON.parse(a);
356
356
  if (o.scripts) {
357
357
  const { predev: s, ...i } = o.scripts;
358
358
  o.scripts = i;
359
359
  }
360
- await l.writeFile(n, JSON.stringify(o, null, 2), "utf-8");
361
- }, x = async (e, n) => {
360
+ await c.writeFile(n, JSON.stringify(o, null, 2), "utf-8");
361
+ }, L = async (e, n) => {
362
362
  const a = 'CONTENT_ISLAND_ACCESS_TOKEN=YOUR_TOKEN_HERE # You can find the access token in your project’s "General tab" (https://docs.contentisland.net/ui/project/general/)', o = r.join(e, n);
363
- await l.writeFile(o, a, "utf-8");
364
- }, Se = "https://github.com/content-island/template-new-bussines-landing-one-page.git", Ce = "create-dev-env.js", V = ".env-sample";
363
+ await c.writeFile(o, a, "utf-8");
364
+ }, Ce = "https://github.com/content-island/template-new-bussines-landing-one-page.git", je = "create-dev-env.js", K = ".env-sample";
365
365
  let y = process.cwd();
366
- const ve = () => ({
366
+ const Te = () => ({
367
367
  id: "business-landing",
368
368
  hasToSaveConfig: !1,
369
- getEnvFilePath: () => r.join(y, b),
369
+ getEnvFilePath: () => r.join(y, T),
370
370
  onInit: async () => {
371
- const { projectPath: e } = await m({
371
+ const { projectPath: e } = await u({
372
372
  type: "text",
373
373
  name: "projectPath",
374
374
  message: "Where should we create your new business landing project?",
375
375
  initial: "./"
376
376
  });
377
- e && (y = r.join(process.cwd(), e), t.loading("Cloning Business Landing template repository..."), await A(Se, y), t.success("Business Landing template repository cloned."));
378
- const { installDeps: n } = await m({
377
+ e && (y = r.join(process.cwd(), e), t.loading("Cloning Business Landing template repository..."), await b(Ce, y), t.success("Business Landing template repository cloned."));
378
+ const { installDeps: n } = await u({
379
379
  type: "confirm",
380
380
  name: "installDeps",
381
381
  message: "Do you want to install the dependencies now?",
382
382
  initial: !0
383
383
  });
384
- n && (t.loading("Installing dependencies..."), await F(y), t.success("Dependencies installed."));
384
+ n && (t.loading("Installing dependencies..."), await P(y), t.success("Dependencies installed."));
385
385
  },
386
386
  syncProject: async () => {
387
- t.info("Syncing Business Landing project..."), await l.unlink(r.join(y, Ce)), await l.unlink(r.join(y, V)), await x(y, V), await L(y), t.success("Business Landing project synchronized.");
387
+ t.info("Syncing Business Landing project..."), await c.unlink(r.join(y, je)), await c.unlink(r.join(y, K)), await L(y, K), await A(y), t.success("Business Landing project synchronized.");
388
388
  },
389
389
  onFinish: async () => {
390
390
  t.run("Now you can start your project by running:"), t.newLine();
391
391
  const e = r.relative(process.cwd(), y);
392
392
  e && t.command(`cd ${e}`), t.command("npm run dev"), t.newLine();
393
393
  }
394
- }), je = "https://github.com/content-island/template-minimal-astro.git", Te = "create-dev-env.js", K = ".env-sample";
394
+ }), Ie = "https://github.com/content-island/template-it-event.git", $e = "create-dev-env.js", U = ".env-sample";
395
395
  let h = process.cwd();
396
396
  const be = () => ({
397
- id: "minimal-astro",
397
+ id: "it-event",
398
398
  hasToSaveConfig: !1,
399
- getEnvFilePath: () => r.join(h, b),
399
+ getEnvFilePath: () => r.join(h, T),
400
400
  onInit: async () => {
401
- const { projectPath: e } = await m({
401
+ const { projectPath: e } = await u({
402
402
  type: "text",
403
403
  name: "projectPath",
404
- message: "Where should we create your new minimal astro project?",
404
+ message: "Where should we create your new IT Event landing project?",
405
405
  initial: "./"
406
406
  });
407
- e && (h = r.join(process.cwd(), e), t.loading("Cloning Minimal Astro template repository..."), await A(je, h), t.success("Minimal Astro template repository cloned."));
408
- const { installDeps: n } = await m({
407
+ e && (h = r.join(process.cwd(), e), t.loading("Cloning IT Event Landing template repository..."), await b(Ie, h), t.success("IT Event Landing template repository cloned."));
408
+ const { installDeps: n } = await u({
409
409
  type: "confirm",
410
410
  name: "installDeps",
411
411
  message: "Do you want to install the dependencies now?",
412
412
  initial: !0
413
413
  });
414
- n && (t.loading("Installing dependencies..."), await F(h), t.success("Dependencies installed."));
414
+ n && (t.loading("Installing dependencies..."), await P(h), t.success("Dependencies installed."));
415
415
  },
416
416
  syncProject: async () => {
417
- t.info("Syncing Minimal Astro project..."), await l.unlink(r.join(h, Te)), await l.unlink(r.join(h, K)), await x(h, K), await L(h), t.success("Minimal Astro project synchronized.");
417
+ t.info("Syncing IT Event Landing project..."), await c.unlink(r.join(h, $e)), await c.unlink(r.join(h, U)), await L(h, U), await A(h), t.success("IT Event Landing project synchronized.");
418
418
  },
419
419
  onFinish: async () => {
420
420
  t.run("Now you can start your project by running:"), t.newLine();
421
421
  const e = r.relative(process.cwd(), h);
422
422
  e && t.command(`cd ${e}`), t.command("npm run dev"), t.newLine();
423
423
  }
424
- }), Ie = "https://github.com/content-island/template-personal-static-site.git", $e = "create-dev-env.js", U = ".env-sample";
424
+ }), Pe = "https://github.com/content-island/template-minimal-astro.git", Ae = "create-dev-env.js", Y = ".env-sample";
425
425
  let E = process.cwd();
426
- const Pe = () => ({
426
+ const Le = () => ({
427
+ id: "minimal-astro",
428
+ hasToSaveConfig: !1,
429
+ getEnvFilePath: () => r.join(E, T),
430
+ onInit: async () => {
431
+ const { projectPath: e } = await u({
432
+ type: "text",
433
+ name: "projectPath",
434
+ message: "Where should we create your new minimal astro project?",
435
+ initial: "./"
436
+ });
437
+ e && (E = r.join(process.cwd(), e), t.loading("Cloning Minimal Astro template repository..."), await b(Pe, E), t.success("Minimal Astro template repository cloned."));
438
+ const { installDeps: n } = await u({
439
+ type: "confirm",
440
+ name: "installDeps",
441
+ message: "Do you want to install the dependencies now?",
442
+ initial: !0
443
+ });
444
+ n && (t.loading("Installing dependencies..."), await P(E), t.success("Dependencies installed."));
445
+ },
446
+ syncProject: async () => {
447
+ t.info("Syncing Minimal Astro project..."), await c.unlink(r.join(E, Ae)), await c.unlink(r.join(E, Y)), await L(E, Y), await A(E), t.success("Minimal Astro project synchronized.");
448
+ },
449
+ onFinish: async () => {
450
+ t.run("Now you can start your project by running:"), t.newLine();
451
+ const e = r.relative(process.cwd(), E);
452
+ e && t.command(`cd ${e}`), t.command("npm run dev"), t.newLine();
453
+ }
454
+ }), Fe = "https://github.com/content-island/template-personal-static-site.git", Ne = "create-dev-env.js", W = ".env-sample";
455
+ let S = process.cwd();
456
+ const xe = () => ({
427
457
  id: "personal-static-site",
428
458
  hasToSaveConfig: !1,
429
- getEnvFilePath: () => r.join(E, b),
459
+ getEnvFilePath: () => r.join(S, T),
430
460
  onInit: async () => {
431
- const { projectPath: e } = await m({
461
+ const { projectPath: e } = await u({
432
462
  type: "text",
433
463
  name: "projectPath",
434
464
  message: "Where should we create your new personal static site project?",
435
465
  initial: "./"
436
466
  });
437
- e && (E = r.join(process.cwd(), e), t.loading("Cloning Personal Static Site template repository..."), await A(Ie, E), t.success("Personal Static Site template repository cloned."));
438
- const { installDeps: n } = await m({
467
+ e && (S = r.join(process.cwd(), e), t.loading("Cloning Personal Static Site template repository..."), await b(Fe, S), t.success("Personal Static Site template repository cloned."));
468
+ const { installDeps: n } = await u({
439
469
  type: "confirm",
440
470
  name: "installDeps",
441
471
  message: "Do you want to install the dependencies now?",
442
472
  initial: !0
443
473
  });
444
- n && (t.loading("Installing dependencies..."), await F(E), t.success("Dependencies installed."));
474
+ n && (t.loading("Installing dependencies..."), await P(S), t.success("Dependencies installed."));
445
475
  },
446
476
  syncProject: async () => {
447
- t.info("Syncing Personal Static Site project..."), await l.unlink(r.join(E, $e)), await l.unlink(r.join(E, U)), await x(E, U), await L(E), t.success("Personal Static Site project synchronized.");
477
+ t.info("Syncing Personal Static Site project..."), await c.unlink(r.join(S, Ne)), await c.unlink(r.join(S, W)), await L(S, W), await A(S), t.success("Personal Static Site project synchronized.");
448
478
  },
449
479
  onFinish: async () => {
450
480
  t.run("Now you can start your project by running:"), t.newLine();
451
- const e = r.relative(process.cwd(), E);
481
+ const e = r.relative(process.cwd(), S);
452
482
  e && t.command(`cd ${e}`), t.command("npm run dev"), t.newLine();
453
483
  }
454
- }), Ae = "https://github.com/content-island/template-restaurant.git", Fe = "create-dev-env.js", Y = ".env-sample";
484
+ }), _e = "https://github.com/content-island/template-restaurant.git", Re = "create-dev-env.js", H = ".env-sample";
455
485
  let k = process.cwd();
456
- const Le = () => ({
486
+ const De = () => ({
457
487
  id: "restaurant-site",
458
488
  hasToSaveConfig: !1,
459
- getEnvFilePath: () => r.join(k, b),
489
+ getEnvFilePath: () => r.join(k, T),
460
490
  onInit: async () => {
461
- const { projectPath: e } = await m({
491
+ const { projectPath: e } = await u({
462
492
  type: "text",
463
493
  name: "projectPath",
464
494
  message: "Where should we create your new restaurant site project?",
465
495
  initial: "./"
466
496
  });
467
- e && (k = r.join(process.cwd(), e), t.loading("Cloning Restaurant Site template repository..."), await A(Ae, k), t.success("Restaurant Site template repository cloned."));
468
- const { installDeps: n } = await m({
497
+ e && (k = r.join(process.cwd(), e), t.loading("Cloning Restaurant Site template repository..."), await b(_e, k), t.success("Restaurant Site template repository cloned."));
498
+ const { installDeps: n } = await u({
469
499
  type: "confirm",
470
500
  name: "installDeps",
471
501
  message: "Do you want to install the dependencies now?",
472
502
  initial: !0
473
503
  });
474
- n && (t.loading("Installing dependencies..."), await F(k), t.success("Dependencies installed."));
504
+ n && (t.loading("Installing dependencies..."), await P(k), t.success("Dependencies installed."));
475
505
  },
476
506
  syncProject: async () => {
477
- t.info("Syncing Restaurant Site project..."), await l.unlink(r.join(k, Fe)), await l.unlink(r.join(k, Y)), await x(k, Y), await L(k), t.success("Restaurant Site project synchronized.");
507
+ t.info("Syncing Restaurant Site project..."), await c.unlink(r.join(k, Re)), await c.unlink(r.join(k, H)), await L(k, H), await A(k), t.success("Restaurant Site project synchronized.");
478
508
  },
479
509
  onFinish: async () => {
480
510
  t.run("Now you can start your project by running:"), t.newLine();
481
511
  const e = r.relative(process.cwd(), k);
482
512
  e && t.command(`cd ${e}`), t.command("npm run dev"), t.newLine();
483
513
  }
484
- }), N = (e, n) => Array.isArray(e) ? e.map(n) : [], xe = (e, n) => ({
514
+ }), _ = (e, n) => Array.isArray(e) ? e.map(n) : [], Me = (e, n) => ({
485
515
  id: e.id,
486
516
  language: e.language,
487
517
  name: e.name,
488
518
  label: e.label,
489
- pages: N(e.pages, (a) => n.find((o) => o.id === a))
490
- }), Ne = (e, n) => ({
519
+ pages: _(e.pages, (a) => n.find((o) => o.id === a))
520
+ }), Oe = (e, n) => ({
491
521
  id: e.id,
492
522
  language: e.language,
493
523
  index: e.index,
494
- folders: N(e.folders, (a) => xe(a, n))
524
+ folders: _(e.folders, (a) => Me(a, n))
495
525
  });
496
- let _ = null;
497
- const _e = (e) => {
498
- _ = me({ accessToken: e });
499
- }, O = () => {
500
- if (!_)
526
+ let R = null;
527
+ const ze = (e) => {
528
+ R = we({ accessToken: e });
529
+ }, z = () => {
530
+ if (!R)
501
531
  throw new Error("API client not initialized. Call initializeClient first.");
502
- return _;
503
- }, Re = async () => await O().getProject(), W = async (e) => {
504
- const n = O(), a = await n.getContent({
532
+ return R;
533
+ }, Ge = async () => await z().getProject(), q = async (e) => {
534
+ const n = z(), a = await n.getContent({
505
535
  contentType: "Root",
506
536
  includeRelatedContent: !0,
507
537
  language: e
@@ -517,10 +547,10 @@ const _e = (e) => {
517
547
  });
518
548
  if (!s)
519
549
  throw new Error(`Pages not found for IDs: ${o.join(", ")}`);
520
- return Ne(a, s);
521
- }, De = async () => {
550
+ return Oe(a, s);
551
+ }, Be = async () => {
522
552
  try {
523
- return await O().getContent({
553
+ return await z().getContent({
524
554
  contentType: "Meta"
525
555
  });
526
556
  } catch (e) {
@@ -528,150 +558,150 @@ const _e = (e) => {
528
558
  "The Content Island API token is missing or malformed. Verify that you've copied the complete token and that you have sufficient permissions."
529
559
  ) : t.error("The requested template is not of type StarLight, so the meta field could not be found."), process.exit(1);
530
560
  }
531
- }, ae = "astro.config.mjs", z = () => r.join(process.cwd(), "src", "content", "docs"), B = () => r.join(process.cwd(), ae), Me = () => {
561
+ }, se = "astro.config.mjs", G = () => r.join(process.cwd(), "src", "content", "docs"), B = () => r.join(process.cwd(), se), Je = () => {
532
562
  const e = [], n = B();
533
- S(n) || e.push(ae);
534
- const a = z();
535
- return S(a) || e.push("src/content/docs directory"), {
563
+ v(n) || e.push(se);
564
+ const a = G();
565
+ return v(a) || e.push("src/content/docs directory"), {
536
566
  valid: e.length === 0,
537
567
  missingItems: e
538
568
  };
539
- }, Oe = async () => {
540
- const e = z();
541
- if (!S(e)) {
542
- t.info("Content docs directory not found, creating it..."), await l.mkdir(e, { recursive: !0 });
569
+ }, Ve = async () => {
570
+ const e = G();
571
+ if (!v(e)) {
572
+ t.info("Content docs directory not found, creating it..."), await c.mkdir(e, { recursive: !0 });
543
573
  return;
544
574
  }
545
- const n = await l.readdir(e);
575
+ const n = await c.readdir(e);
546
576
  for (const a of n) {
547
577
  const o = r.join(e, a);
548
- await l.rm(o, { recursive: !0, force: !0 });
578
+ await c.rm(o, { recursive: !0, force: !0 });
549
579
  }
550
- }, v = {
580
+ }, j = {
551
581
  sidebar: { start: "[", end: "]" },
552
582
  locales: { start: "{", end: "}" },
553
583
  title: { start: "'", end: "'" }
554
- }, oe = (e, n) => {
584
+ }, ie = (e, n) => {
555
585
  const a = [], o = [];
556
586
  for (const s of n) {
557
- const i = e.findIndex((c) => c.label === s.label);
587
+ const i = e.findIndex((l) => l.label === s.label);
558
588
  if (i >= 0) {
559
- const c = s.items && e[i].items ? oe(e[i].items || [], s.items) : s.items;
589
+ const l = s.items && e[i].items ? ie(e[i].items || [], s.items) : s.items;
560
590
  a[i] = {
561
591
  ...e[i],
562
592
  ...s,
563
- items: c
593
+ items: l
564
594
  };
565
595
  } else
566
596
  o.push(s);
567
597
  }
568
598
  return a.push(...o), a.sort((s, i) => {
569
- const c = n.findIndex((u) => u.label === s.label), f = n.findIndex((u) => u.label === i.label);
570
- return c - f;
599
+ const l = n.findIndex((p) => p.label === s.label), f = n.findIndex((p) => p.label === i.label);
600
+ return l - f;
571
601
  });
572
- }, ze = (e, n) => {
602
+ }, Ke = (e, n) => {
573
603
  const a = {
574
- root: { lang: e, label: J[e] }
604
+ root: { lang: e, label: V[e] }
575
605
  };
576
606
  return Array.isArray(n) ? n.reduce(
577
607
  (o, s) => ({
578
608
  ...o,
579
- [s]: { lang: s, label: J[s] }
609
+ [s]: { lang: s, label: V[s] }
580
610
  }),
581
611
  a
582
612
  ) : a;
583
- }, q = async (e, n, a) => {
584
- const o = B(), s = await P({
613
+ }, Z = async (e, n, a) => {
614
+ const o = B(), s = await x({
585
615
  filePath: o,
586
616
  property: n,
587
- startSymbol: v[n]?.start,
588
- endSymbol: v[n]?.end
617
+ startSymbol: j[n]?.start,
618
+ endSymbol: j[n]?.end
589
619
  });
590
620
  let i;
591
621
  if (s) {
592
- const c = ne(JSON.stringify(e, null, 2));
593
- i = (await l.readFile(o, "utf-8")).replace(s, c);
622
+ const l = oe(JSON.stringify(e, null, 2));
623
+ i = (await c.readFile(o, "utf-8")).replace(s, l);
594
624
  } else
595
- i = await Ee(
625
+ i = await ke(
596
626
  n,
597
627
  e,
598
628
  {
599
629
  filePath: o,
600
630
  property: a,
601
- startSymbol: v[a]?.start,
602
- endSymbol: v[a]?.end
631
+ startSymbol: j[a]?.start,
632
+ endSymbol: j[a]?.end
603
633
  },
604
634
  {
605
635
  filePath: o,
606
636
  property: "title",
607
- startSymbol: v.title.start,
608
- endSymbol: v.title.end
637
+ startSymbol: j.title.start,
638
+ endSymbol: j.title.end
609
639
  }
610
640
  );
611
- await l.writeFile(o, i, "utf-8");
612
- }, Be = async (e, n, a) => {
641
+ await c.writeFile(o, i, "utf-8");
642
+ }, Ue = async (e, n, a) => {
613
643
  try {
614
- let o = await P({
644
+ let o = await x({
615
645
  filePath: B(),
616
646
  property: "sidebar",
617
- startSymbol: v.sidebar.start,
618
- endSymbol: v.sidebar.end
647
+ startSymbol: j.sidebar.start,
648
+ endSymbol: j.sidebar.end
619
649
  }), s = [];
620
650
  try {
621
- s = o ? he(o) : null;
651
+ s = o ? Se(o) : null;
622
652
  } catch {
623
653
  t.warning("Could not parse existing sidebar in astro.config.mjs. A new sidebar will be created."), s = [];
624
654
  }
625
655
  s || (t.warning("No existing sidebar found in astro.config.mjs. A new sidebar will be created."), s = []);
626
- const i = oe(s, e);
627
- await q(i, "sidebar", "locales");
628
- const c = ze(n, a);
629
- await q(c, "locales", "sidebar");
656
+ const i = ie(s, e);
657
+ await Z(i, "sidebar", "locales");
658
+ const l = Ke(n, a);
659
+ await Z(l, "locales", "sidebar");
630
660
  } catch (o) {
631
661
  t.error(`Error reading astro.config.mjs: ${o.message}`), process.exit(1);
632
662
  }
633
- }, Ge = (e) => /^---\s*\n([\s\S]*?)\n---\s*\n/.test(e), Je = (e) => r.parse(e).name.replace(/[-_]/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").filter((o) => o.length > 0).map((o) => o.charAt(0).toUpperCase() + o.slice(1).toLowerCase()).join(" ");
634
- function Ve(e, n, a) {
635
- if (Ge(e))
663
+ }, Ye = (e) => /^---\s*\n([\s\S]*?)\n---\s*\n/.test(e), We = (e) => r.parse(e).name.replace(/[-_]/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").filter((o) => o.length > 0).map((o) => o.charAt(0).toUpperCase() + o.slice(1).toLowerCase()).join(" ");
664
+ function He(e, n, a) {
665
+ if (Ye(e))
636
666
  return e;
637
- const o = Je(n), s = `---
667
+ const o = We(n), s = `---
638
668
  title: "${o}"
639
669
  ---
640
670
 
641
671
  `;
642
672
  return t.warning(`Missing frontmatter in ${a}`), t.info(`Added default title: "${o}"`), t.warning("Please update the content in Content Island 🏝️ to include proper frontmatter"), t.newLine(), s + e;
643
673
  }
644
- const $ = async (e, n) => {
645
- const a = z(), o = r.join(a, e), s = Ve(n, e, r.relative(process.cwd(), o)), i = r.dirname(o);
646
- S(i) || await l.mkdir(i, { recursive: !0 }), await l.writeFile(o, s, "utf-8");
647
- }, Ke = async (e, n) => {
674
+ const N = async (e, n) => {
675
+ const a = G(), o = r.join(a, e), s = He(n, e, r.relative(process.cwd(), o)), i = r.dirname(o);
676
+ v(i) || await c.mkdir(i, { recursive: !0 }), await c.writeFile(o, s, "utf-8");
677
+ }, qe = async (e, n) => {
648
678
  try {
649
- await $(e.index.filename, e.index.content);
679
+ await N(e.index.filename, e.index.content);
650
680
  for (const a of e.folders)
651
681
  for (const o of a.pages)
652
- await $(r.join(a.name, o.filename), o.content);
682
+ await N(r.join(a.name, o.filename), o.content);
653
683
  for (const a of n) {
654
- await $(r.join(a.language, a.index.filename), a.index.content);
684
+ await N(r.join(a.language, a.index.filename), a.index.content);
655
685
  for (const o of a.folders)
656
686
  for (const s of o.pages)
657
- await $(r.join(a.language, o.name, s.filename), s.content);
687
+ await N(r.join(a.language, o.name, s.filename), s.content);
658
688
  }
659
689
  } catch (a) {
660
690
  t.error(`Error updating docs content: ${a.message}`), process.exit(1);
661
691
  }
662
- }, Ue = async (e, n) => {
692
+ }, Ze = async (e, n) => {
663
693
  if (e.length === 1) {
664
694
  const s = e[0];
665
- return t.success(`Single language found: ${s}. Continuing...`), await T({ languageCode: s }), s;
695
+ return t.success(`Single language found: ${s}. Continuing...`), await $({ languageCode: s }), s;
666
696
  }
667
- const a = (await M())?.languageCode;
697
+ const a = (await O())?.languageCode;
668
698
  if (a && !n) {
669
699
  if (e.includes(a))
670
700
  return t.info(`Using saved default language: ${a}`), a;
671
701
  t.warning(`Saved language '${a}' not found in project languages`), t.step("Will ask for new default language and save it");
672
702
  }
673
703
  t.step("Multiple languages found. Please select the default language:");
674
- const o = await m({
704
+ const o = await u({
675
705
  type: "select",
676
706
  name: "language",
677
707
  message: "Select the default language:",
@@ -681,8 +711,8 @@ const $ = async (e, n) => {
681
711
  })),
682
712
  initial: 0
683
713
  });
684
- return o.language || (t.error("Language selection is required to continue."), process.exit(1)), a !== o.language && (await T({ languageCode: o.language }), t.config(`Saving default language '${o.language}' to config`)), o.language;
685
- }, Ye = () => {
714
+ return o.language || (t.error("Language selection is required to continue."), process.exit(1)), a !== o.language && (await $({ languageCode: o.language }), t.config(`Saving default language '${o.language}' to config`)), o.language;
715
+ }, Xe = () => {
686
716
  t.detected(`
687
717
  ⭐ ✨ STARLIGHT PROJECT DETECTED ✨ ⭐
688
718
 
@@ -694,128 +724,129 @@ const $ = async (e, n) => {
694
724
  ✨ ⭐ ✨ ⭐ ✨
695
725
  ⭐ ✨ ⭐ ✨
696
726
  `), t.success("All good! Starlight ⭐ project detected successfully."), t.loading("Launching process..."), t.newLine();
697
- }, We = (e) => {
727
+ }, Qe = (e) => {
698
728
  t.newLine(), t.error("Starlight ⭐ project not found!"), t.newLine(), t.error("Missing required items:"), e.forEach((n) => {
699
729
  t.error(` • ${n}`);
700
730
  }), t.newLine(), t.error("Please make sure you are in the root directory of a Starlight ⭐ project."), t.warning("A Starlight ⭐ project should have:"), t.warning(" • astro.config.mjs file"), t.warning(" • src/content/docs directory"), t.newLine();
701
- }, se = (e) => {
731
+ }, re = (e) => {
702
732
  const n = e.reduce(
703
733
  (a, o) => ({ ...a, ...o }),
704
734
  {}
705
735
  );
706
736
  return Object.keys(n).length > 0 ? n : void 0;
707
- }, ie = (e) => e.filename.replace(/\.(mdx?|md)$/, ""), H = (e) => e.label ? e.label.trim() : ie(e), qe = (e, n) => {
708
- const a = ie(e), o = n.trim().toLowerCase();
737
+ }, ce = (e) => e.filename.replace(/\.(mdx?|md)$/, ""), X = (e) => e.label ? e.label.trim() : ce(e), et = (e, n) => {
738
+ const a = ce(e), o = n.trim().toLowerCase();
709
739
  return a.toLocaleLowerCase() === "index" ? o : `${o}/${a}`;
710
- }, He = (e, n, a) => {
740
+ }, tt = (e, n, a) => {
711
741
  e.filename.replace(/\.(mdx?|md)$/, "");
712
- const o = a.filter((s) => s.id === e.id).map((s) => ({ [s.language]: H(s) }));
742
+ const o = a.filter((s) => s.id === e.id).map((s) => ({ [s.language]: X(s) }));
713
743
  return {
714
- label: H(e),
715
- slug: qe(e, n),
716
- translations: se(o)
744
+ label: X(e),
745
+ slug: et(e, n),
746
+ translations: re(o)
717
747
  };
718
- }, Z = (e) => e.label ? e.label.trim() : e.name, Ze = (e, n) => {
719
- const a = n.flatMap((i) => i.folders ?? []).filter((i) => i.id === e.id), o = a.flatMap((i) => i.pages ?? []).filter((i) => e.pages.some((c) => c.id === i.id)), s = a.map((i) => ({ [i.language]: Z(i) }));
748
+ }, Q = (e) => e.label ? e.label.trim() : e.name, nt = (e, n) => {
749
+ const a = n.flatMap((i) => i.folders ?? []).filter((i) => i.id === e.id), o = a.flatMap((i) => i.pages ?? []).filter((i) => e.pages.some((l) => l.id === i.id)), s = a.map((i) => ({ [i.language]: Q(i) }));
720
750
  return {
721
- label: Z(e),
722
- translations: se(s),
723
- items: N(e.pages, (i) => He(i, e.name, o))
751
+ label: Q(e),
752
+ translations: re(s),
753
+ items: _(e.pages, (i) => tt(i, e.name, o))
724
754
  };
725
- }, Xe = (e, n) => N(e.folders, (a) => Ze(a, n)), Qe = () => ({
755
+ }, at = (e, n) => _(e.folders, (a) => nt(a, n)), ot = () => ({
726
756
  id: "starlight",
727
757
  hasToSaveConfig: !0,
728
- getEnvFilePath: () => r.join(D(), b),
758
+ getEnvFilePath: () => r.join(M(), T),
729
759
  onInit: async (e) => {
730
760
  t.step("Checking for Starlight ⭐ project...");
731
- const { valid: n, missingItems: a } = Me();
732
- if (n || (We(a), process.exit(1)), Ye(), e.command === "init") {
733
- const o = r.join(process.cwd(), "package.json"), s = await l.readFile(o, "utf-8"), i = JSON.parse(s), c = i.scripts || {};
734
- i.scripts = { ...c, "content-update": "npm create contentisland@latest update" }, await l.writeFile(o, JSON.stringify(i, null, 2), "utf-8");
761
+ const { valid: n, missingItems: a } = Je();
762
+ if (n || (Qe(a), process.exit(1)), Xe(), e.command === "init") {
763
+ const o = r.join(process.cwd(), "package.json"), s = await c.readFile(o, "utf-8"), i = JSON.parse(s), l = i.scripts || {};
764
+ i.scripts = { ...l, "content-update": "npm create contentisland@latest update" }, await c.writeFile(o, JSON.stringify(i, null, 2), "utf-8");
735
765
  }
736
766
  },
737
767
  syncProject: async (e) => {
738
768
  const { accessToken: n, askIfMultipleLanguages: a } = e;
739
- t.connecting("Initializing Content Island 🏝️ client..."), _e(n);
740
- const o = await De();
769
+ t.connecting("Initializing Content Island 🏝️ client..."), ze(n);
770
+ const o = await Be();
741
771
  t.success(`Connected to project using template: ${o.template} (version: ${o.version})`), o.template !== "starlight" && (t.warning(
742
772
  "The project you are trying to sync is not using the Starlight ⭐ template. Please make sure you are using the correct template."
743
- ), process.exit(1)), await T({
773
+ ), process.exit(1)), await $({
744
774
  version: o.version
745
775
  }), t.fetching("Fetching project information from Content Island 🏝️ ...");
746
- const s = await Re();
776
+ const s = await Ge();
747
777
  t.success(`Project fetched: ${s.name}`);
748
778
  const i = s.languages.map((d) => d);
749
779
  t.info(`Languages found (${i.length}): ${i.join(", ")}`);
750
- const c = await Ue(i, a);
751
- t.language(c);
752
- const f = i.filter((d) => d !== c), u = await W(c);
780
+ const l = await Ze(i, a);
781
+ t.language(l);
782
+ const f = i.filter((d) => d !== l), p = await q(l);
753
783
  let C = [];
754
784
  for (const d of f) {
755
- const ue = await W(d);
756
- C.push(ue);
785
+ const me = await q(d);
786
+ C.push(me);
757
787
  }
758
- t.clearing("Clearing existing docs content..."), await Oe(), t.docs("Existing docs content cleared"), t.updating("Updating docs content with fetched data..."), await Ke(u, C), t.docs("Docs content updated"), t.config("Generating sidebar configuration...");
759
- const w = Xe(u, C);
760
- await Be(w, c, f), t.config("Sidebar configuration updated in astro.config.mjs");
788
+ t.clearing("Clearing existing docs content..."), await Ve(), t.docs("Existing docs content cleared"), t.updating("Updating docs content with fetched data..."), await qe(p, C), t.docs("Docs content updated"), t.config("Generating sidebar configuration...");
789
+ const w = at(p, C);
790
+ await Ue(w, l, f), t.config("Sidebar configuration updated in astro.config.mjs");
761
791
  },
762
792
  onFinish: async () => {
763
793
  t.run("Now you can start your project by running:"), t.newLine(), t.command("npm run dev"), t.newLine();
764
794
  }
765
- }), re = {
766
- starlight: Qe,
767
- "personal-static-site": Pe,
768
- "minimal-astro": be,
769
- "business-landing": ve,
770
- "restaurant-site": Le
771
- }, et = (e) => {
772
- const n = re[e];
795
+ }), le = {
796
+ starlight: ot,
797
+ "personal-static-site": xe,
798
+ "minimal-astro": Le,
799
+ "business-landing": Te,
800
+ "restaurant-site": De,
801
+ "it-event": be
802
+ }, st = (e) => {
803
+ const n = le[e];
773
804
  if (!n)
774
805
  throw new Error(`Template "${e}" not found`);
775
806
  return n();
776
- }, tt = () => Object.keys(re), nt = async (e, n) => {
807
+ }, it = () => Object.keys(le), rt = async (e, n) => {
777
808
  let a;
778
- return a || (a = (await M())?.templateID), a && n && (t.info(`Existing template found: ${a}`), (await m({
809
+ return a || (a = (await O())?.templateID), a && n && (t.info(`Existing template found: ${a}`), (await u({
779
810
  type: "confirm",
780
811
  name: "useExisting",
781
812
  message: `An existing template (${a}) was found. Do you want to use it?`,
782
813
  initial: !0
783
- }))?.useExisting ? t.success(`Using existing template: ${a}`) : (a = null, t.step("Selecting new template..."))), a || (t.step("Please select a template:"), a = (await m({
814
+ }))?.useExisting ? t.success(`Using existing template: ${a}`) : (a = null, t.step("Selecting new template..."))), a || (t.step("Please select a template:"), a = (await u({
784
815
  type: "select",
785
816
  name: "templateID",
786
817
  message: "Select a template:",
787
818
  choices: e.map((s) => ({ title: s, value: s }))
788
819
  }))?.templateID), a || (t.error("Template is required to continue"), process.exit(1)), a;
789
- }, ce = async (e) => {
820
+ }, ge = async (e) => {
790
821
  try {
791
- const { selectedTemplateId: n, askIfExists: a } = e, o = tt();
822
+ const { selectedTemplateId: n, askIfExists: a } = e, o = it();
792
823
  let s = o.find((i) => i === n);
793
- return s || (s = await nt(o, a)), t.detected(`Template selected: ${s}`), et(s);
824
+ return s || (s = await rt(o, a)), t.detected(`Template selected: ${s}`), st(s);
794
825
  } catch (n) {
795
826
  t.error(`Error configuring template: ${n.message}`), process.exit(1);
796
827
  }
797
- }, le = "CONTENT_ISLAND_ACCESS_TOKEN", at = async (e) => {
798
- if (!S(e))
828
+ }, de = "CONTENT_ISLAND_ACCESS_TOKEN", ct = async (e) => {
829
+ if (!v(e))
799
830
  return null;
800
831
  try {
801
- const a = (await l.readFile(e, "utf-8")).match(new RegExp(`${le}=(.+)`));
832
+ const a = (await c.readFile(e, "utf-8")).match(new RegExp(`${de}=(.+)`));
802
833
  return a ? a[1].trim() : null;
803
834
  } catch {
804
835
  return null;
805
836
  }
806
- }, ge = async (e, n) => {
837
+ }, ue = async (e, n) => {
807
838
  try {
808
- const a = `${le}=${e}
839
+ const a = `${de}=${e}
809
840
  `, o = r.dirname(n);
810
- await l.mkdir(o, { recursive: !0 }), await l.writeFile(n, a, "utf-8"), t.token(`Access token saved to ${n}`);
841
+ await c.mkdir(o, { recursive: !0 }), await c.writeFile(n, a, "utf-8"), t.token(`Access token saved to ${n}`);
811
842
  } catch (a) {
812
843
  t.error(`Failed to save the access token: ${a.message}`);
813
844
  }
814
- }, X = (e) => {
845
+ }, ee = (e) => {
815
846
  e || (t.error("Token is required to continue"), process.exit(1));
816
- }, ot = async (e, n) => {
817
- let a = e ? await at(e) : null;
818
- if (a && n && (t.info("Found existing Content Island 🏝️ token"), (await m({
847
+ }, lt = async (e, n) => {
848
+ let a = e ? await ct(e) : null;
849
+ if (a && n && (t.info("Found existing Content Island 🏝️ token"), (await u({
819
850
  type: "confirm",
820
851
  name: "useExisting",
821
852
  message: "An existing token was found. Do you want to use it?",
@@ -824,30 +855,30 @@ const $ = async (e, n) => {
824
855
  t.success("Using existing Content Island 🏝️ token");
825
856
  else {
826
857
  n || t.warning("No existing token found");
827
- const o = await m({
858
+ const o = await u({
828
859
  type: "password",
829
860
  name: "token",
830
861
  message: "Enter your Content Island 🏝️ API token:",
831
862
  validate: (s) => s.length > 0 ? !0 : "Token is required"
832
863
  });
833
- X(o?.token), a = o?.token, e && await ge(a, e);
864
+ ee(o?.token), a = o?.token, e && await ue(a, e);
834
865
  }
835
- return X(a), a;
836
- }, de = async (e) => {
866
+ return ee(a), a;
867
+ }, pe = async (e) => {
837
868
  const { accessToken: n, envFilePath: a, askIfExists: o } = e;
838
869
  let s = n;
839
- return s ? (t.success("Using provided Content Island 🏝️ token"), await ge(s, a)) : s = await ot(a, o), s;
840
- }, st = async (e) => {
870
+ return s ? (t.success("Using provided Content Island 🏝️ token"), await ue(s, a)) : s = await lt(a, o), s;
871
+ }, gt = async (e) => {
841
872
  try {
842
873
  t.title("Content Island Integration"), t.step("Configuring template...");
843
- const n = await ce({
874
+ const n = await ge({
844
875
  selectedTemplateId: e.template,
845
876
  askIfExists: !0
846
877
  });
847
878
  n.onInit && (t.step("Running template initialization..."), await n.onInit({
848
879
  command: "init"
849
- })), n.hasToSaveConfig && (t.step("Saving configuration..."), await T({ templateID: n.id }), t.config("Template configuration saved")), t.step("Configuring access token...");
850
- const a = n.getEnvFilePath ? n.getEnvFilePath() : null, o = await de({
880
+ })), n.hasToSaveConfig && (t.step("Saving configuration..."), await $({ templateID: n.id }), t.config("Template configuration saved")), t.step("Configuring access token...");
881
+ const a = n.getEnvFilePath ? n.getEnvFilePath() : null, o = await pe({
851
882
  accessToken: e.token,
852
883
  envFilePath: a,
853
884
  askIfExists: !0
@@ -856,14 +887,14 @@ const $ = async (e, n) => {
856
887
  } catch (n) {
857
888
  t.newLine(), t.error("Error during Content Island integration:"), t.error(n instanceof Error ? n.message : String(n)), process.exit(1);
858
889
  }
859
- }, it = async () => {
890
+ }, dt = async () => {
860
891
  try {
861
892
  t.title("Content Island Integration"), t.step("Configuring template...");
862
- const e = await ce({ askIfExists: !1 });
893
+ const e = await ge({ askIfExists: !1 });
863
894
  e.onInit && (t.step("Running template initialization..."), await e.onInit({
864
895
  command: "update"
865
- })), e.hasToSaveConfig && (t.step("Saving configuration..."), await T({ templateID: e.id }), t.config("Template configuration saved")), t.step("Configuring access token...");
866
- const n = e.getEnvFilePath ? e.getEnvFilePath() : null, a = await de({
896
+ })), e.hasToSaveConfig && (t.step("Saving configuration..."), await $({ templateID: e.id }), t.config("Template configuration saved")), t.step("Configuring access token...");
897
+ const n = e.getEnvFilePath ? e.getEnvFilePath() : null, a = await pe({
867
898
  envFilePath: n,
868
899
  askIfExists: !1
869
900
  });
@@ -871,21 +902,21 @@ const $ = async (e, n) => {
871
902
  } catch (e) {
872
903
  t.newLine(), t.error("Error during Content Island integration:"), t.error(e instanceof Error ? e.message : String(e)), process.exit(1);
873
904
  }
874
- }, rt = "0.4.1", ct = {
875
- version: rt
876
- }, I = pe("create-contentisland");
877
- I.command("", "Initialize and validate a project").example("npm create contentisland").example("npm create contentisland --token <token>").example("npm create contentisland --token <token> --template starlight").option(
905
+ }, ut = "0.5.0", pt = {
906
+ version: ut
907
+ }, F = fe("create-contentisland");
908
+ F.command("", "Initialize and validate a project").example("npm create contentisland").example("npm create contentisland --token <token>").example("npm create contentisland --token <token> --template starlight").option(
878
909
  "--token <token>",
879
910
  "Your Content Island token (you can also set the CONTENT_ISLAND_ACCESS_TOKEN environment variable)",
880
911
  {
881
912
  default: process.env.CONTENT_ISLAND_ACCESS_TOKEN || void 0
882
913
  }
883
914
  ).option("--template <template>", "The template to use: starlight.").action(async (e) => {
884
- await st(e);
915
+ await gt(e);
885
916
  });
886
- I.command("update", "Update content from Content Island 🏝️ (preserves existing token)").example("npm create contentisland update").action(async () => {
887
- await it();
917
+ F.command("update", "Update content from Content Island 🏝️ (preserves existing token)").example("npm create contentisland update").action(async () => {
918
+ await dt();
888
919
  });
889
- I.help();
890
- I.version(ct.version);
891
- I.parse();
920
+ F.help();
921
+ F.version(pt.version);
922
+ F.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-contentisland",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Content Island - Starlight CLI",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -27,7 +27,7 @@
27
27
  "test:watch": "vitest -c ./config/test/config.ts"
28
28
  },
29
29
  "dependencies": {
30
- "@content-island/api-client": "0.17.0",
30
+ "@content-island/api-client": "0.18.0",
31
31
  "cac": "6.7.14",
32
32
  "prompts": "2.4.2"
33
33
  },