create-supaslidev 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -43,6 +43,7 @@ pnpm create supaslidev --name my-slides --presentation intro-deck
43
43
  | `--install` / `--no-install` | Run pnpm install | `true` |
44
44
 
45
45
  The wizard creates a pnpm workspace with:
46
+
46
47
  - A `presentations/` directory for your decks
47
48
  - A `packages/shared/` directory with reusable components, layouts, and styles (configured as a Slidev addon)
48
49
  - Shared dependency management via pnpm catalog
package/dist/cli.js CHANGED
@@ -10,8 +10,86 @@ import ejs from "ejs";
10
10
  import pc from "picocolors";
11
11
  import { tmpdir } from "node:os";
12
12
 
13
+ //#region src/version.ts
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
16
+ const CLI_VERSION = pkg.version;
17
+ const PACKAGE_NAME = "@supaslidev/cli";
18
+ const CACHE_DIR = join(tmpdir(), "supaslidev-cli");
19
+ const CACHE_FILE = join(CACHE_DIR, "version-cache.json");
20
+ const CACHE_TTL_MS = 1440 * 60 * 1e3;
21
+ function compareVersions(current, latest) {
22
+ const parseVersion = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
23
+ const currentParts = parseVersion(current);
24
+ const latestParts = parseVersion(latest);
25
+ for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
26
+ const curr = currentParts[i] ?? 0;
27
+ const lat = latestParts[i] ?? 0;
28
+ if (lat > curr) return true;
29
+ if (lat < curr) return false;
30
+ }
31
+ return false;
32
+ }
33
+ function readCache() {
34
+ try {
35
+ if (!existsSync(CACHE_FILE)) return null;
36
+ const data = JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
37
+ if (Date.now() - data.checkedAt > CACHE_TTL_MS) return null;
38
+ return data;
39
+ } catch {
40
+ return null;
41
+ }
42
+ }
43
+ function writeCache(latestVersion) {
44
+ try {
45
+ if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
46
+ const cache = {
47
+ latestVersion,
48
+ checkedAt: Date.now()
49
+ };
50
+ writeFileSync(CACHE_FILE, JSON.stringify(cache));
51
+ } catch {}
52
+ }
53
+ async function fetchLatestPackageVersion(packageName) {
54
+ try {
55
+ const controller = new AbortController();
56
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
57
+ const response = await fetch(`https://registry.npmjs.org/${packageName}`, { signal: controller.signal });
58
+ clearTimeout(timeoutId);
59
+ if (!response.ok) return null;
60
+ return (await response.json())["dist-tags"].latest;
61
+ } catch {
62
+ return null;
63
+ }
64
+ }
65
+ async function fetchLatestVersion() {
66
+ const version = await fetchLatestPackageVersion(PACKAGE_NAME);
67
+ if (version) writeCache(version);
68
+ return version;
69
+ }
70
+ function getCachedLatestVersion() {
71
+ return readCache()?.latestVersion ?? null;
72
+ }
73
+ async function checkForUpdates() {
74
+ const latestVersion = await fetchLatestVersion();
75
+ return {
76
+ currentVersion: CLI_VERSION,
77
+ latestVersion,
78
+ updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
79
+ };
80
+ }
81
+ function checkForUpdatesCached() {
82
+ const latestVersion = getCachedLatestVersion();
83
+ return {
84
+ currentVersion: CLI_VERSION,
85
+ latestVersion,
86
+ updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
87
+ };
88
+ }
89
+
90
+ //#endregion
13
91
  //#region src/create.ts
14
- const CLI_VERSION$1 = "0.1.0";
92
+ const SUPASLIDEV_FALLBACK_VERSION = "0.1.4";
15
93
  function createSafeSpinner() {
16
94
  if (process.stdout.isTTY && process.stdin.isTTY) {
17
95
  const spinner = p.spinner();
@@ -379,12 +457,14 @@ async function create(options = {}) {
379
457
  trackPath(targetDir);
380
458
  spinner.start("Creating workspace structure...");
381
459
  createDirectoryStructure(targetDir);
460
+ const supaslidevVersion = `^${await fetchLatestPackageVersion("supaslidev") ?? SUPASLIDEV_FALLBACK_VERSION}`;
382
461
  const templateData = {
383
462
  projectName,
384
463
  presentationName,
385
464
  description: `${projectName} - Slidev presentations monorepo`,
386
- cliVersion: CLI_VERSION$1,
387
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
465
+ cliVersion: CLI_VERSION,
466
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
467
+ supaslidevVersion
388
468
  };
389
469
  await renderWorkspaceTemplates(targetDir, options.template ?? "default", templateData);
390
470
  spinner.message("Creating presentation...");
@@ -548,79 +628,6 @@ function getMigrationOrder(manifest) {
548
628
  return order;
549
629
  }
550
630
 
551
- //#endregion
552
- //#region src/version.ts
553
- const CLI_VERSION = "0.1.0";
554
- const PACKAGE_NAME = "@supaslidev/cli";
555
- const CACHE_DIR = join(tmpdir(), "supaslidev-cli");
556
- const CACHE_FILE = join(CACHE_DIR, "version-cache.json");
557
- const CACHE_TTL_MS = 1440 * 60 * 1e3;
558
- function compareVersions(current, latest) {
559
- const parseVersion = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
560
- const currentParts = parseVersion(current);
561
- const latestParts = parseVersion(latest);
562
- for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
563
- const curr = currentParts[i] ?? 0;
564
- const lat = latestParts[i] ?? 0;
565
- if (lat > curr) return true;
566
- if (lat < curr) return false;
567
- }
568
- return false;
569
- }
570
- function readCache() {
571
- try {
572
- if (!existsSync(CACHE_FILE)) return null;
573
- const data = JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
574
- if (Date.now() - data.checkedAt > CACHE_TTL_MS) return null;
575
- return data;
576
- } catch {
577
- return null;
578
- }
579
- }
580
- function writeCache(latestVersion) {
581
- try {
582
- if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
583
- const cache = {
584
- latestVersion,
585
- checkedAt: Date.now()
586
- };
587
- writeFileSync(CACHE_FILE, JSON.stringify(cache));
588
- } catch {}
589
- }
590
- async function fetchLatestVersion() {
591
- try {
592
- const controller = new AbortController();
593
- const timeoutId = setTimeout(() => controller.abort(), 5e3);
594
- const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`, { signal: controller.signal });
595
- clearTimeout(timeoutId);
596
- if (!response.ok) return null;
597
- const version = (await response.json())["dist-tags"].latest;
598
- writeCache(version);
599
- return version;
600
- } catch {
601
- return null;
602
- }
603
- }
604
- function getCachedLatestVersion() {
605
- return readCache()?.latestVersion ?? null;
606
- }
607
- async function checkForUpdates() {
608
- const latestVersion = await fetchLatestVersion();
609
- return {
610
- currentVersion: CLI_VERSION,
611
- latestVersion,
612
- updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
613
- };
614
- }
615
- function checkForUpdatesCached() {
616
- const latestVersion = getCachedLatestVersion();
617
- return {
618
- currentVersion: CLI_VERSION,
619
- latestVersion,
620
- updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
621
- };
622
- }
623
-
624
631
  //#endregion
625
632
  //#region src/commands/status.ts
626
633
  function getPendingMigrationsCount(workspaceDir) {
@@ -1252,7 +1259,7 @@ function printUpdateNotification(latestVersion) {
1252
1259
  //#endregion
1253
1260
  //#region src/cli.ts
1254
1261
  const program = new Command();
1255
- program.name("create-supaslidev").description("CLI tool for scaffolding Supaslidev presentations").version("0.1.0");
1262
+ program.name("create-supaslidev").description("CLI tool for scaffolding Supaslidev presentations").version(CLI_VERSION);
1256
1263
  program.command("create", { isDefault: true }).description("Create a new Supaslidev workspace").option("-n, --name <name>", "Name of the workspace").option("-p, --presentation <name>", "Name of the first presentation").option("-t, --template <template>", "Template to use", "default").option("--git", "Initialize a git repository").option("--no-git", "Skip git initialization").option("--install", "Run pnpm install after scaffolding").option("--no-install", "Skip pnpm install").action(async (options) => {
1257
1264
  await create(options);
1258
1265
  });
package/dist/index.js CHANGED
@@ -10,8 +10,86 @@ import { tmpdir } from "node:os";
10
10
  import { parse, parseDocument, stringify } from "yaml";
11
11
  import { IndentationText, Node, Project, SyntaxKind } from "ts-morph";
12
12
 
13
+ //#region src/version.ts
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
16
+ const CLI_VERSION = pkg.version;
17
+ const PACKAGE_NAME = "@supaslidev/cli";
18
+ const CACHE_DIR = join(tmpdir(), "supaslidev-cli");
19
+ const CACHE_FILE = join(CACHE_DIR, "version-cache.json");
20
+ const CACHE_TTL_MS = 1440 * 60 * 1e3;
21
+ function compareVersions(current, latest) {
22
+ const parseVersion = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
23
+ const currentParts = parseVersion(current);
24
+ const latestParts = parseVersion(latest);
25
+ for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
26
+ const curr = currentParts[i] ?? 0;
27
+ const lat = latestParts[i] ?? 0;
28
+ if (lat > curr) return true;
29
+ if (lat < curr) return false;
30
+ }
31
+ return false;
32
+ }
33
+ function readCache() {
34
+ try {
35
+ if (!existsSync(CACHE_FILE)) return null;
36
+ const data = JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
37
+ if (Date.now() - data.checkedAt > CACHE_TTL_MS) return null;
38
+ return data;
39
+ } catch {
40
+ return null;
41
+ }
42
+ }
43
+ function writeCache(latestVersion) {
44
+ try {
45
+ if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
46
+ const cache = {
47
+ latestVersion,
48
+ checkedAt: Date.now()
49
+ };
50
+ writeFileSync(CACHE_FILE, JSON.stringify(cache));
51
+ } catch {}
52
+ }
53
+ async function fetchLatestPackageVersion(packageName) {
54
+ try {
55
+ const controller = new AbortController();
56
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
57
+ const response = await fetch(`https://registry.npmjs.org/${packageName}`, { signal: controller.signal });
58
+ clearTimeout(timeoutId);
59
+ if (!response.ok) return null;
60
+ return (await response.json())["dist-tags"].latest;
61
+ } catch {
62
+ return null;
63
+ }
64
+ }
65
+ async function fetchLatestVersion() {
66
+ const version = await fetchLatestPackageVersion(PACKAGE_NAME);
67
+ if (version) writeCache(version);
68
+ return version;
69
+ }
70
+ function getCachedLatestVersion() {
71
+ return readCache()?.latestVersion ?? null;
72
+ }
73
+ async function checkForUpdates() {
74
+ const latestVersion = await fetchLatestVersion();
75
+ return {
76
+ currentVersion: CLI_VERSION,
77
+ latestVersion,
78
+ updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
79
+ };
80
+ }
81
+ function checkForUpdatesCached() {
82
+ const latestVersion = getCachedLatestVersion();
83
+ return {
84
+ currentVersion: CLI_VERSION,
85
+ latestVersion,
86
+ updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
87
+ };
88
+ }
89
+
90
+ //#endregion
13
91
  //#region src/create.ts
14
- const CLI_VERSION$2 = "0.1.0";
92
+ const SUPASLIDEV_FALLBACK_VERSION = "0.1.4";
15
93
  function createSafeSpinner() {
16
94
  if (process.stdout.isTTY && process.stdin.isTTY) {
17
95
  const spinner = p.spinner();
@@ -379,12 +457,14 @@ async function create(options = {}) {
379
457
  trackPath(targetDir);
380
458
  spinner.start("Creating workspace structure...");
381
459
  createDirectoryStructure(targetDir);
460
+ const supaslidevVersion = `^${await fetchLatestPackageVersion("supaslidev") ?? SUPASLIDEV_FALLBACK_VERSION}`;
382
461
  const templateData = {
383
462
  projectName,
384
463
  presentationName,
385
464
  description: `${projectName} - Slidev presentations monorepo`,
386
- cliVersion: CLI_VERSION$2,
387
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
465
+ cliVersion: CLI_VERSION,
466
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
467
+ supaslidevVersion
388
468
  };
389
469
  await renderWorkspaceTemplates(targetDir, options.template ?? "default", templateData);
390
470
  spinner.message("Creating presentation...");
@@ -437,7 +517,6 @@ async function create(options = {}) {
437
517
 
438
518
  //#endregion
439
519
  //#region src/state.ts
440
- const CLI_VERSION$1 = "0.1.0";
441
520
  const STATE_DIR = ".supaslidev";
442
521
  const STATE_FILE = "state.json";
443
522
  function getStatePath(workspaceDir) {
@@ -449,7 +528,7 @@ function getStateDir(workspaceDir) {
449
528
  function createInitialState() {
450
529
  const now = (/* @__PURE__ */ new Date()).toISOString();
451
530
  return {
452
- cliVersion: CLI_VERSION$1,
531
+ cliVersion: CLI_VERSION,
453
532
  createdAt: now,
454
533
  lastUpdatedAt: now,
455
534
  appliedMigrations: []
@@ -501,7 +580,7 @@ function hasMigration(workspaceDir, migrationId) {
501
580
  function updateCliVersion(workspaceDir) {
502
581
  const state = readState(workspaceDir);
503
582
  if (!state) throw new Error("State file not found. Is this a Supaslidev workspace?");
504
- state.cliVersion = CLI_VERSION$1;
583
+ state.cliVersion = CLI_VERSION;
505
584
  writeState(workspaceDir, state);
506
585
  }
507
586
  function findWorkspaceRoot(startDir = process.cwd()) {
@@ -594,79 +673,6 @@ function getMigrationOrder(manifest) {
594
673
  return order;
595
674
  }
596
675
 
597
- //#endregion
598
- //#region src/version.ts
599
- const CLI_VERSION = "0.1.0";
600
- const PACKAGE_NAME = "@supaslidev/cli";
601
- const CACHE_DIR = join(tmpdir(), "supaslidev-cli");
602
- const CACHE_FILE = join(CACHE_DIR, "version-cache.json");
603
- const CACHE_TTL_MS = 1440 * 60 * 1e3;
604
- function compareVersions(current, latest) {
605
- const parseVersion = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
606
- const currentParts = parseVersion(current);
607
- const latestParts = parseVersion(latest);
608
- for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
609
- const curr = currentParts[i] ?? 0;
610
- const lat = latestParts[i] ?? 0;
611
- if (lat > curr) return true;
612
- if (lat < curr) return false;
613
- }
614
- return false;
615
- }
616
- function readCache() {
617
- try {
618
- if (!existsSync(CACHE_FILE)) return null;
619
- const data = JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
620
- if (Date.now() - data.checkedAt > CACHE_TTL_MS) return null;
621
- return data;
622
- } catch {
623
- return null;
624
- }
625
- }
626
- function writeCache(latestVersion) {
627
- try {
628
- if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
629
- const cache = {
630
- latestVersion,
631
- checkedAt: Date.now()
632
- };
633
- writeFileSync(CACHE_FILE, JSON.stringify(cache));
634
- } catch {}
635
- }
636
- async function fetchLatestVersion() {
637
- try {
638
- const controller = new AbortController();
639
- const timeoutId = setTimeout(() => controller.abort(), 5e3);
640
- const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}`, { signal: controller.signal });
641
- clearTimeout(timeoutId);
642
- if (!response.ok) return null;
643
- const version = (await response.json())["dist-tags"].latest;
644
- writeCache(version);
645
- return version;
646
- } catch {
647
- return null;
648
- }
649
- }
650
- function getCachedLatestVersion() {
651
- return readCache()?.latestVersion ?? null;
652
- }
653
- async function checkForUpdates() {
654
- const latestVersion = await fetchLatestVersion();
655
- return {
656
- currentVersion: CLI_VERSION,
657
- latestVersion,
658
- updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
659
- };
660
- }
661
- function checkForUpdatesCached() {
662
- const latestVersion = getCachedLatestVersion();
663
- return {
664
- currentVersion: CLI_VERSION,
665
- latestVersion,
666
- updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
667
- };
668
- }
669
-
670
676
  //#endregion
671
677
  //#region src/commands/status.ts
672
678
  function getPendingMigrationsCount(workspaceDir) {
@@ -1346,7 +1352,7 @@ function printUpdateNotification(latestVersion) {
1346
1352
  //#endregion
1347
1353
  //#region src/cli.ts
1348
1354
  const program = new Command();
1349
- program.name("create-supaslidev").description("CLI tool for scaffolding Supaslidev presentations").version("0.1.0");
1355
+ program.name("create-supaslidev").description("CLI tool for scaffolding Supaslidev presentations").version(CLI_VERSION);
1350
1356
  program.command("create", { isDefault: true }).description("Create a new Supaslidev workspace").option("-n, --name <name>", "Name of the workspace").option("-p, --presentation <name>", "Name of the first presentation").option("-t, --template <template>", "Template to use", "default").option("--git", "Initialize a git repository").option("--no-git", "Skip git initialization").option("--install", "Run pnpm install after scaffolding").option("--no-install", "Skip pnpm install").action(async (options) => {
1351
1357
  await create(options);
1352
1358
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-supaslidev",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI tool for scaffolding Supaslidev presentations",
5
5
  "keywords": [
6
6
  "slidev",
@@ -12,7 +12,8 @@
12
12
  "deploy": "supaslidev deploy"
13
13
  },
14
14
  "devDependencies": {
15
- "supaslidev": "^0.1.3"
15
+ "playwright-chromium": "catalog:",
16
+ "supaslidev": "<%= supaslidevVersion %>"
16
17
  },
17
18
  "engines": {
18
19
  "node": ">=18.0.0"
@@ -11,3 +11,4 @@ catalog:
11
11
  '@vue/compiler-sfc': ^3.5.27
12
12
  typescript: ^5.3.3
13
13
  vue-tsc: ^2.0.0
14
+ playwright-chromium: ^1.58.2