@ncukondo/slide-generation 0.2.4 → 0.2.5

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/cli/index.js CHANGED
@@ -1515,7 +1515,7 @@ var Pipeline = class {
1515
1515
  };
1516
1516
 
1517
1517
  // src/index.ts
1518
- var VERSION = "0.2.4";
1518
+ var VERSION = "0.2.5";
1519
1519
 
1520
1520
  // src/cli/commands/convert.ts
1521
1521
  import { Command } from "commander";
@@ -4810,7 +4810,7 @@ import { mkdir as mkdir7, writeFile as writeFile7, access as access10, readdir a
4810
4810
  import { existsSync as existsSync2 } from "fs";
4811
4811
  import { execSync, spawnSync } from "child_process";
4812
4812
  import { createInterface } from "readline";
4813
- import { dirname as dirname6, join as join16, resolve as resolve5, sep } from "path";
4813
+ import { basename as basename7, dirname as dirname6, join as join16, resolve as resolve5, sep } from "path";
4814
4814
  import { fileURLToPath } from "url";
4815
4815
  import chalk6 from "chalk";
4816
4816
  import ora3 from "ora";
@@ -6230,32 +6230,67 @@ function getMarpInstallCommand(pm) {
6230
6230
  return "npm install -D @marp-team/marp-cli";
6231
6231
  }
6232
6232
  }
6233
- async function promptYesNo(question, defaultYes = true) {
6233
+ async function promptMarpInstallChoice() {
6234
6234
  if (!process.stdin.isTTY) {
6235
- return defaultYes;
6235
+ return "skip";
6236
6236
  }
6237
6237
  const rl = createInterface({
6238
6238
  input: process.stdin,
6239
6239
  output: process.stdout
6240
6240
  });
6241
- const hint = defaultYes ? "(Y/n)" : "(y/N)";
6242
- const prompt = `${question} ${hint} `;
6241
+ console.log("How would you like to install Marp CLI?");
6242
+ console.log(` ${chalk6.cyan("1)")} Global install ${chalk6.dim("(recommended - works everywhere)")}`);
6243
+ console.log(` ${chalk6.cyan("2)")} Local install ${chalk6.dim("(creates package.json)")}`);
6244
+ console.log(` ${chalk6.cyan("3)")} Skip ${chalk6.dim("(I'll install it later)")}`);
6245
+ console.log("");
6243
6246
  return new Promise((resolve7) => {
6244
- rl.question(prompt, (answer) => {
6247
+ rl.question("Choice [1]: ", (answer) => {
6245
6248
  rl.close();
6246
- const normalized = answer.trim().toLowerCase();
6247
- if (normalized === "") {
6248
- resolve7(defaultYes);
6249
+ const normalized = answer.trim();
6250
+ if (normalized === "" || normalized === "1") {
6251
+ resolve7("global");
6252
+ } else if (normalized === "2") {
6253
+ resolve7("local");
6249
6254
  } else {
6250
- resolve7(normalized === "y" || normalized === "yes");
6255
+ resolve7("skip");
6251
6256
  }
6252
6257
  });
6253
6258
  });
6254
6259
  }
6255
- function installMarpCli(targetDir) {
6260
+ function installMarpCliGlobally() {
6261
+ const spinner = ora3("Installing Marp CLI globally...").start();
6262
+ try {
6263
+ const result = spawnSync("npm", ["install", "-g", "@marp-team/marp-cli"], {
6264
+ stdio: "pipe",
6265
+ shell: true,
6266
+ timeout: 12e4
6267
+ // 2 minutes timeout
6268
+ });
6269
+ if (result.status === 0) {
6270
+ spinner.succeed("Marp CLI installed globally");
6271
+ return true;
6272
+ } else {
6273
+ const stderr = result.stderr?.toString() || "Unknown error";
6274
+ spinner.fail(`Failed to install Marp CLI: ${stderr}`);
6275
+ console.log(chalk6.dim("You can install it manually with: npm install -g @marp-team/marp-cli"));
6276
+ return false;
6277
+ }
6278
+ } catch (error) {
6279
+ const message = error instanceof Error ? error.message : "Unknown error";
6280
+ spinner.fail(`Failed to install Marp CLI: ${message}`);
6281
+ console.log(chalk6.dim("You can install it manually with: npm install -g @marp-team/marp-cli"));
6282
+ return false;
6283
+ }
6284
+ }
6285
+ async function installMarpCliLocally(targetDir) {
6256
6286
  const pm = detectPackageManager(targetDir);
6257
6287
  const installCmd = getMarpInstallCommand(pm);
6258
- const spinner = ora3(`Installing Marp CLI with ${pm}...`).start();
6288
+ const packageJsonPath = join16(targetDir, "package.json");
6289
+ if (!existsSync2(packageJsonPath)) {
6290
+ const packageJsonContent = generatePackageJsonContent(targetDir);
6291
+ await writeFile7(packageJsonPath, packageJsonContent, "utf-8");
6292
+ }
6293
+ const spinner = ora3(`Installing Marp CLI locally with ${pm}...`).start();
6259
6294
  try {
6260
6295
  const result = spawnSync(pm, ["add", "-D", "@marp-team/marp-cli"], {
6261
6296
  cwd: targetDir,
@@ -6265,7 +6300,7 @@ function installMarpCli(targetDir) {
6265
6300
  // 2 minutes timeout
6266
6301
  });
6267
6302
  if (result.status === 0) {
6268
- spinner.succeed("Marp CLI installed successfully");
6303
+ spinner.succeed("Marp CLI installed locally");
6269
6304
  return true;
6270
6305
  } else {
6271
6306
  const stderr = result.stderr?.toString() || "Unknown error";
@@ -6280,14 +6315,29 @@ function installMarpCli(targetDir) {
6280
6315
  return false;
6281
6316
  }
6282
6317
  }
6318
+ function generatePackageJsonContent(targetDir) {
6319
+ const projectName = basename7(targetDir) || "my-presentation";
6320
+ return JSON.stringify(
6321
+ {
6322
+ name: projectName,
6323
+ version: "1.0.0",
6324
+ private: true,
6325
+ description: "Presentation project created with slide-gen",
6326
+ scripts: {
6327
+ preview: "slide-gen preview presentation.yaml",
6328
+ build: "slide-gen convert presentation.yaml"
6329
+ }
6330
+ },
6331
+ null,
6332
+ 2
6333
+ );
6334
+ }
6283
6335
  async function showMarpCliInfo(targetDir) {
6284
6336
  if (isMarpCliInstalledGlobally() || isMarpCliInstalledLocally(targetDir)) {
6285
6337
  console.log("");
6286
6338
  console.log(chalk6.green("\u2713") + " Marp CLI is available");
6287
6339
  return true;
6288
6340
  }
6289
- const pm = detectPackageManager(targetDir);
6290
- const installCmd = getMarpInstallCommand(pm);
6291
6341
  console.log("");
6292
6342
  console.log(chalk6.dim("\u2500".repeat(45)));
6293
6343
  console.log(chalk6.yellow("Marp CLI is recommended for full features:"));
@@ -6298,22 +6348,19 @@ async function showMarpCliInfo(targetDir) {
6298
6348
  console.log(chalk6.dim("Marp CLI is not currently installed."));
6299
6349
  console.log(chalk6.dim("\u2500".repeat(45)));
6300
6350
  console.log("");
6301
- const packageJsonPath = join16(targetDir, "package.json");
6302
- const hasPackageJson = existsSync2(packageJsonPath);
6303
- if (!hasPackageJson) {
6304
- console.log(chalk6.dim("No package.json found. You can install Marp CLI globally:"));
6305
- console.log(` ${chalk6.cyan("npm install -g @marp-team/marp-cli")}`);
6306
- return false;
6307
- }
6308
- const shouldInstall = await promptYesNo("Install Marp CLI now?", true);
6309
- if (shouldInstall) {
6310
- const success = installMarpCli(targetDir);
6311
- return success;
6312
- } else {
6313
- console.log("");
6314
- console.log(chalk6.dim("You can install it later with:"));
6315
- console.log(` ${chalk6.cyan(installCmd)}`);
6316
- return false;
6351
+ const choice = await promptMarpInstallChoice();
6352
+ switch (choice) {
6353
+ case "global":
6354
+ return installMarpCliGlobally();
6355
+ case "local":
6356
+ return await installMarpCliLocally(targetDir);
6357
+ case "skip":
6358
+ default:
6359
+ console.log("");
6360
+ console.log(chalk6.dim("You can install Marp CLI later with:"));
6361
+ console.log(` ${chalk6.cyan("npm install -g @marp-team/marp-cli")} ${chalk6.dim("(global)")}`);
6362
+ console.log(` ${chalk6.cyan("npm install -D @marp-team/marp-cli")} ${chalk6.dim("(local)")}`);
6363
+ return false;
6317
6364
  }
6318
6365
  }
6319
6366
  async function generateAiConfig(targetDir) {
@@ -6450,7 +6497,7 @@ slides:
6450
6497
  // src/cli/commands/watch.ts
6451
6498
  import { Command as Command7 } from "commander";
6452
6499
  import { access as access11 } from "fs/promises";
6453
- import { basename as basename7, dirname as dirname7, join as join17 } from "path";
6500
+ import { basename as basename8, dirname as dirname7, join as join17 } from "path";
6454
6501
  import chalk7 from "chalk";
6455
6502
  import { watch as chokidarWatch2 } from "chokidar";
6456
6503
  var WatchState = class {
@@ -6484,7 +6531,7 @@ var WatchState = class {
6484
6531
  };
6485
6532
  function getDefaultOutputPath2(inputPath) {
6486
6533
  const dir = dirname7(inputPath);
6487
- const base = basename7(inputPath, ".yaml");
6534
+ const base = basename8(inputPath, ".yaml");
6488
6535
  return join17(dir, `${base}.md`);
6489
6536
  }
6490
6537
  function formatTime() {
@@ -6629,7 +6676,7 @@ async function executeWatch(inputPath, options) {
6629
6676
  // src/cli/commands/images.ts
6630
6677
  import { Command as Command8 } from "commander";
6631
6678
  import { readFile as readFile15, stat as stat2, mkdir as mkdir8 } from "fs/promises";
6632
- import { dirname as dirname8, basename as basename8, join as join18 } from "path";
6679
+ import { dirname as dirname8, basename as basename9, join as join18 } from "path";
6633
6680
  import chalk8 from "chalk";
6634
6681
  import { stringify as stringifyYaml3 } from "yaml";
6635
6682
  function createImagesCommand() {
@@ -6953,7 +7000,7 @@ async function processSingleFile(filePath, options) {
6953
7000
  }
6954
7001
  const processor = new ImageProcessor();
6955
7002
  const dir = dirname8(filePath);
6956
- const filename = basename8(filePath);
7003
+ const filename = basename9(filePath);
6957
7004
  const outputDir = join18(dir, options.output);
6958
7005
  await mkdir8(outputDir, { recursive: true });
6959
7006
  const outputPath = join18(outputDir, filename);
@@ -7051,7 +7098,7 @@ function parseBlurSpec(spec) {
7051
7098
  // src/cli/commands/screenshot.ts
7052
7099
  import { Command as Command9 } from "commander";
7053
7100
  import { access as access12, mkdir as mkdir9, readdir as readdir7, unlink as unlink3 } from "fs/promises";
7054
- import { basename as basename9, dirname as dirname9, join as join19 } from "path";
7101
+ import { basename as basename10, dirname as dirname9, join as join19 } from "path";
7055
7102
  import chalk9 from "chalk";
7056
7103
  import ora4 from "ora";
7057
7104
  async function filterToSpecificSlide(outputDir, baseName, slideNumber, format) {
@@ -7201,7 +7248,7 @@ async function executeScreenshot(inputPath, options) {
7201
7248
  }
7202
7249
  if (options.slide !== void 0) {
7203
7250
  spinner?.start(`Filtering to slide ${options.slide}...`);
7204
- const mdBaseName = basename9(tempMdPath, ".md");
7251
+ const mdBaseName = basename10(tempMdPath, ".md");
7205
7252
  const format = options.format || "png";
7206
7253
  const filterResult = await filterToSpecificSlide(
7207
7254
  outputDir,