create-supaslidev 0.2.0 → 0.2.1

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.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  //#region src/cli.d.ts
4
3
  declare function run(): Promise<void>;
5
4
  //#endregion
package/dist/cli.js CHANGED
@@ -1,19 +1,16 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  import { Command } from "commander";
4
3
  import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
5
4
  import { basename, dirname, join, relative } from "node:path";
6
- import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import { fileURLToPath } from "node:url";
7
6
  import { spawn } from "node:child_process";
8
7
  import * as p from "@clack/prompts";
9
8
  import ejs from "ejs";
10
9
  import pc from "picocolors";
11
10
  import { tmpdir } from "node:os";
12
-
11
+ //#endregion
13
12
  //#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;
13
+ const CLI_VERSION = "0.2.1";
17
14
  const PACKAGE_NAME = "@supaslidev/cli";
18
15
  const CACHE_DIR = join(tmpdir(), "supaslidev-cli");
19
16
  const CACHE_FILE = join(CACHE_DIR, "version-cache.json");
@@ -43,11 +40,10 @@ function readCache() {
43
40
  function writeCache(latestVersion) {
44
41
  try {
45
42
  if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
46
- const cache = {
43
+ writeFileSync(CACHE_FILE, JSON.stringify({
47
44
  latestVersion,
48
45
  checkedAt: Date.now()
49
- };
50
- writeFileSync(CACHE_FILE, JSON.stringify(cache));
46
+ }));
51
47
  } catch {}
52
48
  }
53
49
  async function fetchLatestPackageVersion(packageName) {
@@ -86,7 +82,6 @@ function checkForUpdatesCached() {
86
82
  updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
87
83
  };
88
84
  }
89
-
90
85
  //#endregion
91
86
  //#region src/create.ts
92
87
  const SUPASLIDEV_FALLBACK_VERSION = "0.1.4";
@@ -475,7 +470,6 @@ async function create(options = {}) {
475
470
  process.exit(1);
476
471
  }
477
472
  }
478
-
479
473
  //#endregion
480
474
  //#region src/state.ts
481
475
  const STATE_DIR = ".supaslidev";
@@ -535,7 +529,6 @@ function findWorkspaceRoot(startDir = process.cwd()) {
535
529
  function getImportedPresentations(workspaceDir) {
536
530
  return readState(workspaceDir)?.importedPresentations ?? [];
537
531
  }
538
-
539
532
  //#endregion
540
533
  //#region src/migrations/manifest.ts
541
534
  const MIGRATIONS_MANIFEST_FILE = "migrations.json";
@@ -588,7 +581,6 @@ function getMigrationOrder(manifest) {
588
581
  for (const migration of manifest.migrations) visit(migration.id, /* @__PURE__ */ new Set());
589
582
  return order;
590
583
  }
591
-
592
584
  //#endregion
593
585
  //#region src/commands/status.ts
594
586
  function getPendingMigrationsCount(workspaceDir) {
@@ -674,7 +666,6 @@ async function status(workspaceDir) {
674
666
  const result = await getStatus(workspaceDir);
675
667
  console.log(formatStatus(result));
676
668
  }
677
-
678
669
  //#endregion
679
670
  //#region src/migrations/backup.ts
680
671
  const BACKUP_DIR = ".supaslidev/backups";
@@ -757,7 +748,6 @@ function deleteBackup(workspaceDir, backupId) {
757
748
  force: true
758
749
  });
759
750
  }
760
-
761
751
  //#endregion
762
752
  //#region src/migrations/journal.ts
763
753
  const JOURNAL_DIR = ".supaslidev";
@@ -797,7 +787,6 @@ function createJournalEntry(migrationId, backupId, success, rolledBack = false,
797
787
  error: error?.message
798
788
  };
799
789
  }
800
-
801
790
  //#endregion
802
791
  //#region src/migrations/runner.ts
803
792
  function loadMigration(migrations, id) {
@@ -982,7 +971,6 @@ function formatRunOutput(result) {
982
971
  }
983
972
  return lines.join("\n");
984
973
  }
985
-
986
974
  //#endregion
987
975
  //#region src/migrations/loader.ts
988
976
  const MIGRATIONS = [];
@@ -1010,7 +998,6 @@ async function loadInteractiveMigration(id) {
1010
998
  getAffectedPresentations: entry.module.getAffectedPresentations
1011
999
  };
1012
1000
  }
1013
-
1014
1001
  //#endregion
1015
1002
  //#region src/prompts.ts
1016
1003
  async function promptForCatalogSelection(presentations) {
@@ -1043,7 +1030,6 @@ async function promptForCatalogSelection(presentations) {
1043
1030
  cancelled: false
1044
1031
  };
1045
1032
  }
1046
-
1047
1033
  //#endregion
1048
1034
  //#region src/commands/migrate.ts
1049
1035
  async function getMigrateResult(options = {}) {
@@ -1149,7 +1135,6 @@ async function migrate(options = {}) {
1149
1135
  console.log(formatMigrateOutput(result));
1150
1136
  if (!result.success) process.exit(1);
1151
1137
  }
1152
-
1153
1138
  //#endregion
1154
1139
  //#region src/commands/update.ts
1155
1140
  async function getUpdateResult() {
@@ -1190,7 +1175,6 @@ async function update() {
1190
1175
  console.log(formatUpdateResult(result));
1191
1176
  if (result.error) process.exit(1);
1192
1177
  }
1193
-
1194
1178
  //#endregion
1195
1179
  //#region src/background-update.ts
1196
1180
  function startBackgroundUpdateCheck() {
@@ -1216,7 +1200,6 @@ function printUpdateNotification(latestVersion) {
1216
1200
  console.log(pc.yellow(` Run ${pc.cyan(`npm install -g ${PACKAGE_NAME}`)} to update`));
1217
1201
  console.log(pc.yellow(border));
1218
1202
  }
1219
-
1220
1203
  //#endregion
1221
1204
  //#region src/cli.ts
1222
1205
  const program = new Command();
@@ -1237,11 +1220,9 @@ async function run() {
1237
1220
  startBackgroundUpdateCheck();
1238
1221
  await program.parseAsync();
1239
1222
  }
1240
- const scriptName = process.argv[1] ? basename(process.argv[1]) : "";
1241
- if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href || scriptName === "cli.js") run().catch((err) => {
1223
+ if ((process.argv[1] ? basename(process.argv[1]) : "") === "cli.js") run().catch((err) => {
1242
1224
  console.error(err);
1243
1225
  process.exit(1);
1244
1226
  });
1245
-
1246
1227
  //#endregion
1247
- export { run };
1228
+ export { run };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
3
3
  import { basename, dirname, join, relative } from "node:path";
4
- import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { fileURLToPath } from "node:url";
5
5
  import { spawn } from "node:child_process";
6
6
  import * as p from "@clack/prompts";
7
7
  import ejs from "ejs";
@@ -9,11 +9,9 @@ import pc from "picocolors";
9
9
  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
+ //#endregion
13
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;
14
+ const CLI_VERSION = "0.2.1";
17
15
  const PACKAGE_NAME = "@supaslidev/cli";
18
16
  const CACHE_DIR = join(tmpdir(), "supaslidev-cli");
19
17
  const CACHE_FILE = join(CACHE_DIR, "version-cache.json");
@@ -43,11 +41,10 @@ function readCache() {
43
41
  function writeCache(latestVersion) {
44
42
  try {
45
43
  if (!existsSync(CACHE_DIR)) mkdirSync(CACHE_DIR, { recursive: true });
46
- const cache = {
44
+ writeFileSync(CACHE_FILE, JSON.stringify({
47
45
  latestVersion,
48
46
  checkedAt: Date.now()
49
- };
50
- writeFileSync(CACHE_FILE, JSON.stringify(cache));
47
+ }));
51
48
  } catch {}
52
49
  }
53
50
  async function fetchLatestPackageVersion(packageName) {
@@ -86,7 +83,6 @@ function checkForUpdatesCached() {
86
83
  updateAvailable: latestVersion ? compareVersions(CLI_VERSION, latestVersion) : false
87
84
  };
88
85
  }
89
-
90
86
  //#endregion
91
87
  //#region src/create.ts
92
88
  const SUPASLIDEV_FALLBACK_VERSION = "0.1.4";
@@ -475,7 +471,6 @@ async function create(options = {}) {
475
471
  process.exit(1);
476
472
  }
477
473
  }
478
-
479
474
  //#endregion
480
475
  //#region src/state.ts
481
476
  const STATE_DIR = ".supaslidev";
@@ -571,7 +566,6 @@ function removeImportedPresentation(workspaceDir, name) {
571
566
  state.importedPresentations = state.importedPresentations.filter((p) => p.name !== name);
572
567
  writeState(workspaceDir, state);
573
568
  }
574
-
575
569
  //#endregion
576
570
  //#region src/migrations/manifest.ts
577
571
  const MIGRATIONS_MANIFEST_FILE = "migrations.json";
@@ -633,7 +627,6 @@ function getMigrationOrder(manifest) {
633
627
  for (const migration of manifest.migrations) visit(migration.id, /* @__PURE__ */ new Set());
634
628
  return order;
635
629
  }
636
-
637
630
  //#endregion
638
631
  //#region src/commands/status.ts
639
632
  function getPendingMigrationsCount(workspaceDir) {
@@ -719,7 +712,6 @@ async function status(workspaceDir) {
719
712
  const result = await getStatus(workspaceDir);
720
713
  console.log(formatStatus(result));
721
714
  }
722
-
723
715
  //#endregion
724
716
  //#region src/migrations/backup.ts
725
717
  const BACKUP_DIR = ".supaslidev/backups";
@@ -825,7 +817,6 @@ function getBackupMetadata(workspaceDir, backupId) {
825
817
  function backupExists(workspaceDir, backupId) {
826
818
  return existsSync(join(getBackupPath(workspaceDir, backupId), BACKUP_METADATA_FILE));
827
819
  }
828
-
829
820
  //#endregion
830
821
  //#region src/migrations/journal.ts
831
822
  const JOURNAL_DIR = ".supaslidev";
@@ -886,7 +877,6 @@ function getFailedMigrations(workspaceDir) {
886
877
  function clearJournal(workspaceDir) {
887
878
  writeJournal(workspaceDir, { entries: [] });
888
879
  }
889
-
890
880
  //#endregion
891
881
  //#region src/migrations/runner.ts
892
882
  function loadMigration(migrations, id) {
@@ -1071,7 +1061,6 @@ function formatRunOutput(result) {
1071
1061
  }
1072
1062
  return lines.join("\n");
1073
1063
  }
1074
-
1075
1064
  //#endregion
1076
1065
  //#region src/migrations/loader.ts
1077
1066
  const MIGRATIONS = [];
@@ -1103,7 +1092,6 @@ async function loadInteractiveMigration(id) {
1103
1092
  getAffectedPresentations: entry.module.getAffectedPresentations
1104
1093
  };
1105
1094
  }
1106
-
1107
1095
  //#endregion
1108
1096
  //#region src/prompts.ts
1109
1097
  async function promptForCatalogSelection(presentations) {
@@ -1136,7 +1124,6 @@ async function promptForCatalogSelection(presentations) {
1136
1124
  cancelled: false
1137
1125
  };
1138
1126
  }
1139
-
1140
1127
  //#endregion
1141
1128
  //#region src/commands/migrate.ts
1142
1129
  async function getMigrateResult(options = {}) {
@@ -1242,7 +1229,6 @@ async function migrate(options = {}) {
1242
1229
  console.log(formatMigrateOutput(result));
1243
1230
  if (!result.success) process.exit(1);
1244
1231
  }
1245
-
1246
1232
  //#endregion
1247
1233
  //#region src/commands/update.ts
1248
1234
  async function getUpdateResult() {
@@ -1283,7 +1269,6 @@ async function update() {
1283
1269
  console.log(formatUpdateResult(result));
1284
1270
  if (result.error) process.exit(1);
1285
1271
  }
1286
-
1287
1272
  //#endregion
1288
1273
  //#region src/background-update.ts
1289
1274
  function startBackgroundUpdateCheck() {
@@ -1309,7 +1294,6 @@ function printUpdateNotification(latestVersion) {
1309
1294
  console.log(pc.yellow(` Run ${pc.cyan(`npm install -g ${PACKAGE_NAME}`)} to update`));
1310
1295
  console.log(pc.yellow(border));
1311
1296
  }
1312
-
1313
1297
  //#endregion
1314
1298
  //#region src/cli.ts
1315
1299
  const program = new Command();
@@ -1330,12 +1314,10 @@ async function run$1() {
1330
1314
  startBackgroundUpdateCheck();
1331
1315
  await program.parseAsync();
1332
1316
  }
1333
- const scriptName = process.argv[1] ? basename(process.argv[1]) : "";
1334
- if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href || scriptName === "cli.js") run$1().catch((err) => {
1317
+ if ((process.argv[1] ? basename(process.argv[1]) : "") === "cli.js") run$1().catch((err) => {
1335
1318
  console.error(err);
1336
1319
  process.exit(1);
1337
1320
  });
1338
-
1339
1321
  //#endregion
1340
1322
  //#region src/transformers/json.ts
1341
1323
  function readJsonFile(filePath) {
@@ -1425,7 +1407,6 @@ function mergeJson(target, source) {
1425
1407
  }
1426
1408
  return result;
1427
1409
  }
1428
-
1429
1410
  //#endregion
1430
1411
  //#region src/transformers/yaml.ts
1431
1412
  const defaultParseOptions = { keepSourceTokens: true };
@@ -1504,7 +1485,6 @@ function mergeYaml(target, source) {
1504
1485
  }
1505
1486
  return result;
1506
1487
  }
1507
-
1508
1488
  //#endregion
1509
1489
  //#region src/transformers/typescript.ts
1510
1490
  function createTransformer(filePath) {
@@ -1637,6 +1617,5 @@ function findCallExpression(sourceFile, functionName) {
1637
1617
  if (args.length > 0 && args[0].getKind() === SyntaxKind.ObjectLiteralExpression) return args[0];
1638
1618
  }
1639
1619
  }
1640
-
1641
1620
  //#endregion
1642
- export { addArrayElement, addExport, addImport, addImportedPresentation, addJournalEntry, addMigration, backupExists, clearJournal, createBackup, createEmptyManifest, createInitialState, createJournalEntry, createTransformer, deleteBackup, deleteJsonValue, deleteYamlValue, dryRun, findArrayLiteral, findCallExpression, findDefaultExportObject, findObjectLiteral, findWorkspaceRoot, formatDryRunOutput, formatRunOutput, formatStatus, getBackupMetadata, getFailedMigrations, getImportedPresentations, getJournalEntries, getJsonValue, getLastSuccessfulEntry, getMigrationById, getMigrationHistory, getMigrationOrder, getObjectProperty, getStatus, getYamlValue, hasMigration, initializeState, listBackups, loadInteractiveMigration, loadMigrations, mergeJson, mergeYaml, readJournal, readJsonFile, readManifest, readState, readYamlDocument, readYamlFile, removeArrayElement, removeImport, removeImportedPresentation, removeObjectProperty, restoreBackup, run, run$1 as runCli, setJsonValue, setObjectProperty, setYamlValue, stateExists, status, transformJson, transformTypeScript, transformYaml, transformYamlDocument, updateCliVersion, validateManifest, wasMigrationSuccessful, writeJournal, writeJsonFile, writeManifest, writeState, writeYamlDocument, writeYamlFile };
1621
+ export { addArrayElement, addExport, addImport, addImportedPresentation, addJournalEntry, addMigration, backupExists, clearJournal, createBackup, createEmptyManifest, createInitialState, createJournalEntry, createTransformer, deleteBackup, deleteJsonValue, deleteYamlValue, dryRun, findArrayLiteral, findCallExpression, findDefaultExportObject, findObjectLiteral, findWorkspaceRoot, formatDryRunOutput, formatRunOutput, formatStatus, getBackupMetadata, getFailedMigrations, getImportedPresentations, getJournalEntries, getJsonValue, getLastSuccessfulEntry, getMigrationById, getMigrationHistory, getMigrationOrder, getObjectProperty, getStatus, getYamlValue, hasMigration, initializeState, listBackups, loadInteractiveMigration, loadMigrations, mergeJson, mergeYaml, readJournal, readJsonFile, readManifest, readState, readYamlDocument, readYamlFile, removeArrayElement, removeImport, removeImportedPresentation, removeObjectProperty, restoreBackup, run, run$1 as runCli, setJsonValue, setObjectProperty, setYamlValue, stateExists, status, transformJson, transformTypeScript, transformYaml, transformYamlDocument, updateCliVersion, validateManifest, wasMigrationSuccessful, writeJournal, writeJsonFile, writeManifest, writeState, writeYamlDocument, writeYamlFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-supaslidev",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI tool for scaffolding Supaslidev presentations",
5
5
  "keywords": [
6
6
  "slidev",
@@ -47,7 +47,7 @@
47
47
  "devDependencies": {
48
48
  "@types/ejs": "^3.1.5",
49
49
  "@types/node": "^22.10.0",
50
- "tsdown": "^0.12.5",
50
+ "tsdown": "^0.21.6",
51
51
  "tsx": "^4.19.0",
52
52
  "typescript": "^5.3.3",
53
53
  "vitest": "^4.0.0"