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