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