jsrepo 1.7.1 → 1.9.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 CHANGED
@@ -6,8 +6,8 @@ import path12 from "pathe";
6
6
 
7
7
  // src/commands/add.ts
8
8
  import fs6 from "node:fs";
9
- import { cancel, confirm, isCancel, multiselect, outro, spinner as spinner2 } from "@clack/prompts";
10
- import color7 from "chalk";
9
+ import { cancel, confirm, isCancel, multiselect, outro, spinner as spinner2, text } from "@clack/prompts";
10
+ import color8 from "chalk";
11
11
  import { Command, program as program2 } from "commander";
12
12
  import { resolveCommand as resolveCommand2 } from "package-manager-detector/commands";
13
13
  import { detect } from "package-manager-detector/detect";
@@ -29,7 +29,7 @@ var JSREPO = color.hex("#f7df1e")("jsrepo");
29
29
 
30
30
  // src/utils/blocks.ts
31
31
  import fs4 from "node:fs";
32
- import color4 from "chalk";
32
+ import color5 from "chalk";
33
33
  import path4 from "pathe";
34
34
 
35
35
  // src/utils/blocks/types/result.ts
@@ -680,6 +680,7 @@ var mapToArray = (map, fn) => {
680
680
  };
681
681
 
682
682
  // src/utils/git-providers.ts
683
+ import color4 from "chalk";
683
684
  import { Octokit } from "octokit";
684
685
  import * as v3 from "valibot";
685
686
 
@@ -1158,13 +1159,84 @@ var github = {
1158
1159
  },
1159
1160
  matches: (repoPath) => repoPath.toLowerCase().startsWith("https://github.com") || repoPath.toLowerCase().startsWith("github")
1160
1161
  };
1161
- var providers = [github];
1162
+ var gitlab = {
1163
+ name: () => "gitlab",
1164
+ resolveRaw: async (repoPath, resourcePath) => {
1165
+ const info = await gitlab.info(repoPath);
1166
+ return new URL(
1167
+ `${encodeURIComponent(resourcePath)}/raw?ref=${info.ref}`,
1168
+ `https://gitlab.com/api/v4/projects/${encodeURIComponent(`${info.owner}/${info.repoName}`)}/repository/files/`
1169
+ );
1170
+ },
1171
+ fetchRaw: async (repoPath, resourcePath) => {
1172
+ const url = await gitlab.resolveRaw(repoPath, resourcePath);
1173
+ const errorMessage = (err) => {
1174
+ return Err(
1175
+ `There was an error fetching the \`${OUTPUT_FILE}\` from the repository \`${url.href}\` make sure the target repository has a \`${OUTPUT_FILE}\` in its root.
1176
+ Error: ${err}`
1177
+ );
1178
+ };
1179
+ try {
1180
+ const token = get().get(`${gitlab.name()}-token`);
1181
+ const headers = new Headers();
1182
+ if (token !== void 0) {
1183
+ headers.append("PRIVATE-TOKEN", `${token}`);
1184
+ }
1185
+ const response = await fetch(url, { headers });
1186
+ if (!response.ok) {
1187
+ return errorMessage(`${response.status} ${response.text}`);
1188
+ }
1189
+ return Ok(await response.text());
1190
+ } catch (err) {
1191
+ return errorMessage(`${err}`);
1192
+ }
1193
+ },
1194
+ fetchManifest: async (repoPath) => {
1195
+ const manifest = await gitlab.fetchRaw(repoPath, OUTPUT_FILE);
1196
+ if (manifest.isErr()) return Err(manifest.unwrapErr());
1197
+ const categories = v3.parse(v3.array(categorySchema), JSON.parse(manifest.unwrap()));
1198
+ return Ok(categories);
1199
+ },
1200
+ info: async (repoPath) => {
1201
+ if (typeof repoPath !== "string") return repoPath;
1202
+ const repo = repoPath.replaceAll(/(https:\/\/gitlab.com\/)|(gitlab\/)/g, "");
1203
+ const [owner, repoName, ...rest] = repo.split("/");
1204
+ let ref = "main";
1205
+ let refs = "heads";
1206
+ if (rest[0] === "-" && rest[1] === "tree") {
1207
+ if (rest[2].includes("?")) {
1208
+ const [tempRef, last] = rest[2].split("?");
1209
+ ref = tempRef;
1210
+ if (last.startsWith("ref_type=")) {
1211
+ if (last.slice(10) === "tags") {
1212
+ refs = "tags";
1213
+ }
1214
+ }
1215
+ } else {
1216
+ ref = rest[2];
1217
+ }
1218
+ }
1219
+ return {
1220
+ refs,
1221
+ url: repoPath,
1222
+ name: gitlab.name(),
1223
+ repoName,
1224
+ owner,
1225
+ ref,
1226
+ provider: gitlab
1227
+ };
1228
+ },
1229
+ matches: (repoPath) => repoPath.toLowerCase().startsWith("https://gitlab.com") || repoPath.toLowerCase().startsWith("gitlab")
1230
+ };
1231
+ var providers = [github, gitlab];
1162
1232
  var getProviderInfo = async (repo) => {
1163
1233
  const provider = providers.find((provider2) => provider2.matches(repo));
1164
1234
  if (provider) {
1165
1235
  return Ok(await provider.info(repo));
1166
1236
  }
1167
- return Err("Only GitHub repositories are supported at this time!");
1237
+ return Err(
1238
+ `Only ${providers.map((p, i) => `${i === providers.length - 1 ? "and" : ""}${color4.cyan(p.name())}`).join(", ")} repositories are supported at this time!`
1239
+ );
1168
1240
  };
1169
1241
  var fetchBlocks = async (...repos) => {
1170
1242
  const blocksMap = /* @__PURE__ */ new Map();
@@ -1195,11 +1267,11 @@ var resolveTree = async (blockSpecifiers, blocksMap, repoPaths) => {
1195
1267
  const blocks = /* @__PURE__ */ new Map();
1196
1268
  for (const blockSpecifier of blockSpecifiers) {
1197
1269
  let block = void 0;
1198
- if (!blockSpecifier.startsWith("github")) {
1270
+ if (!providers.find((p) => blockSpecifier.startsWith(p.name()))) {
1199
1271
  if (repoPaths.length === 0) {
1200
1272
  return Err(
1201
- color4.red(
1202
- `If your config doesn't repos then you must provide the repo in the block specifier ex: \`${color4.bold(
1273
+ color5.red(
1274
+ `If your config doesn't repos then you must provide the repo in the block specifier ex: \`${color5.bold(
1203
1275
  `github/<owner>/<name>/${blockSpecifier}`
1204
1276
  )}\`!`
1205
1277
  )
@@ -1218,7 +1290,7 @@ var resolveTree = async (blockSpecifiers, blocksMap, repoPaths) => {
1218
1290
  block = blocksMap.get(blockSpecifier);
1219
1291
  }
1220
1292
  if (!block) {
1221
- return Err(`Invalid block! ${color4.bold(blockSpecifier)} does not exist!`);
1293
+ return Err(`Invalid block! ${color5.bold(blockSpecifier)} does not exist!`);
1222
1294
  }
1223
1295
  const fullSpecifier = `${block.sourceRepo.url}/${block.category}/${block.name}`;
1224
1296
  blocks.set(fullSpecifier, { name: fullSpecifier, subDependency: false, block });
@@ -1281,7 +1353,7 @@ var getConfig = (cwd) => {
1281
1353
  };
1282
1354
 
1283
1355
  // src/utils/dependencies.ts
1284
- import color5 from "chalk";
1356
+ import color6 from "chalk";
1285
1357
  import { execa } from "execa";
1286
1358
  import { resolveCommand } from "package-manager-detector";
1287
1359
  var installDependencies = async ({
@@ -1296,14 +1368,14 @@ var installDependencies = async ({
1296
1368
  } else {
1297
1369
  add2 = resolveCommand(pm, "install", [...deps]);
1298
1370
  }
1299
- if (add2 == null) return Err(color5.red(`Could not resolve add command for '${pm}'.`));
1371
+ if (add2 == null) return Err(color6.red(`Could not resolve add command for '${pm}'.`));
1300
1372
  try {
1301
1373
  await execa(add2.command, [...add2.args], { cwd });
1302
1374
  return Ok(deps);
1303
1375
  } catch {
1304
1376
  return Err(
1305
- color5.red(
1306
- `Failed to install ${color5.bold(deps.join(", "))}! Failed while running '${color5.bold(
1377
+ color6.red(
1378
+ `Failed to install ${color6.bold(deps.join(", "))}! Failed while running '${color6.bold(
1307
1379
  `${add2.command} ${add2.args.join(" ")}`
1308
1380
  )}'`
1309
1381
  )
@@ -1320,7 +1392,7 @@ var getWatermark = (version2, repoUrl) => {
1320
1392
 
1321
1393
  // src/utils/prompts.ts
1322
1394
  import { intro, spinner } from "@clack/prompts";
1323
- import color6 from "chalk";
1395
+ import color7 from "chalk";
1324
1396
 
1325
1397
  // src/utils/blocks/utils/strip-ansi.ts
1326
1398
  import ansiRegex from "ansi-regex";
@@ -1388,7 +1460,7 @@ var nextSteps = (steps) => {
1388
1460
  `;
1389
1461
  return result;
1390
1462
  };
1391
- var _intro = (version2) => intro(`${color6.bgHex("#f7df1e").black(" jsrepo ")}${color6.gray(` v${version2} `)}`);
1463
+ var _intro = (version2) => intro(`${color7.bgHex("#f7df1e").black(" jsrepo ")}${color7.gray(` v${version2} `)}`);
1392
1464
 
1393
1465
  // src/commands/add.ts
1394
1466
  var schema2 = v5.object({
@@ -1405,7 +1477,7 @@ var add = new Command("add").argument(
1405
1477
  const options = v5.parse(schema2, opts);
1406
1478
  _intro(context.package.version);
1407
1479
  await _add(blockNames, options);
1408
- outro(color7.green("All done!"));
1480
+ outro(color8.green("All done!"));
1409
1481
  });
1410
1482
  var _add = async (blockNames, options) => {
1411
1483
  const verbose = (msg) => {
@@ -1415,14 +1487,32 @@ var _add = async (blockNames, options) => {
1415
1487
  };
1416
1488
  verbose(`Attempting to add ${JSON.stringify(blockNames)}`);
1417
1489
  const loading = spinner2();
1418
- const config = getConfig(options.cwd).match(
1419
- (val) => val,
1420
- (err) => program2.error(color7.red(err))
1421
- );
1490
+ const configResult = getConfig(options.cwd);
1491
+ const noConfig = configResult.isErr();
1492
+ let config;
1493
+ if (configResult.isErr()) {
1494
+ const response = await confirm({
1495
+ message: `You don't have ${JSREPO} initialized in your project. Do you want to continue?`,
1496
+ initialValue: false
1497
+ });
1498
+ if (isCancel(response) || !response) {
1499
+ cancel("Canceled!");
1500
+ process.exit(0);
1501
+ }
1502
+ config = {
1503
+ $schema: "",
1504
+ includeTests: false,
1505
+ watermark: true,
1506
+ path: "./src/blocks",
1507
+ repos: []
1508
+ };
1509
+ } else {
1510
+ config = configResult.unwrap();
1511
+ }
1422
1512
  let repoPaths = config.repos;
1423
1513
  if (options.repo) repoPaths = [options.repo];
1424
1514
  for (const blockSpecifier of blockNames) {
1425
- if (!blockSpecifier.startsWith("github")) continue;
1515
+ if (!providers.find((p) => blockSpecifier.startsWith(p.name()))) continue;
1426
1516
  const [providerName, owner, repoName, ...rest] = blockSpecifier.split("/");
1427
1517
  let repo;
1428
1518
  if (rest.length > 2) {
@@ -1433,7 +1523,7 @@ var _add = async (blockNames, options) => {
1433
1523
  if (!repoPaths.find((repoPath) => repoPath === repo)) {
1434
1524
  if (!options.allow) {
1435
1525
  const result = await confirm({
1436
- message: `Allow ${color7.cyan("jsrepo")} to download and run code from ${color7.cyan(repo)}?`,
1526
+ message: `Allow ${JSREPO} to download and run code from ${color8.cyan(repo)}?`,
1437
1527
  initialValue: true
1438
1528
  });
1439
1529
  if (isCancel(result) || !result) {
@@ -1446,7 +1536,7 @@ var _add = async (blockNames, options) => {
1446
1536
  }
1447
1537
  if (!options.allow && options.repo) {
1448
1538
  const result = await confirm({
1449
- message: `Allow ${color7.cyan("jsrepo")} to download and run code from ${color7.cyan(options.repo)}?`,
1539
+ message: `Allow ${JSREPO} to download and run code from ${color8.cyan(options.repo)}?`,
1450
1540
  initialValue: true
1451
1541
  });
1452
1542
  if (isCancel(result) || !result) {
@@ -1455,23 +1545,30 @@ var _add = async (blockNames, options) => {
1455
1545
  }
1456
1546
  }
1457
1547
  if (repoPaths.length === 0) {
1548
+ if (noConfig) {
1549
+ program2.error(
1550
+ color8.red(
1551
+ `Fully quality blocks ex: (github/ieedan/std/utils/math) or provide the \`${color8.bold("--repo")}\` flag to specify a registry.`
1552
+ )
1553
+ );
1554
+ }
1458
1555
  program2.error(
1459
- color7.red(
1460
- `There were no repos present in your config and you didn't provide the \`${color7.bold("--repo")}\` flag with a repo.`
1556
+ color8.red(
1557
+ `There were no repos present in your config and you didn't provide the \`${color8.bold("--repo")}\` flag with a repo.`
1461
1558
  )
1462
1559
  );
1463
1560
  }
1464
- verbose(`Fetching blocks from ${color7.cyan(repoPaths.join(", "))}`);
1465
- if (!options.verbose) loading.start(`Fetching blocks from ${color7.cyan(repoPaths.join(", "))}`);
1561
+ verbose(`Fetching blocks from ${color8.cyan(repoPaths.join(", "))}`);
1562
+ if (!options.verbose) loading.start(`Fetching blocks from ${color8.cyan(repoPaths.join(", "))}`);
1466
1563
  const blocksMap = (await fetchBlocks(...repoPaths)).match(
1467
1564
  (val) => val,
1468
1565
  ({ repo, message }) => {
1469
- loading.stop(`Failed fetching blocks from ${color7.cyan(repo)}`);
1470
- program2.error(color7.red(message));
1566
+ loading.stop(`Failed fetching blocks from ${color8.cyan(repo)}`);
1567
+ program2.error(color8.red(message));
1471
1568
  }
1472
1569
  );
1473
- if (!options.verbose) loading.stop(`Retrieved blocks from ${color7.cyan(repoPaths.join(", "))}`);
1474
- verbose(`Retrieved blocks from ${color7.cyan(repoPaths.join(", "))}`);
1570
+ if (!options.verbose) loading.stop(`Retrieved blocks from ${color8.cyan(repoPaths.join(", "))}`);
1571
+ verbose(`Retrieved blocks from ${color8.cyan(repoPaths.join(", "))}`);
1475
1572
  const installedBlocks = getInstalled(blocksMap, config, options.cwd).map(
1476
1573
  (val) => val.specifier
1477
1574
  );
@@ -1484,14 +1581,14 @@ var _add = async (blockNames, options) => {
1484
1581
  const blockExists = installedBlocks.findIndex((block) => block === shortName) !== -1;
1485
1582
  let label;
1486
1583
  if (repoPaths.length > 1) {
1487
- label = `${color7.cyan(
1584
+ label = `${color8.cyan(
1488
1585
  `${value.sourceRepo.name}/${value.sourceRepo.owner}/${value.sourceRepo.repoName}/${value.category}`
1489
1586
  )}/${value.name}`;
1490
1587
  } else {
1491
- label = `${color7.cyan(value.category)}/${value.name}`;
1588
+ label = `${color8.cyan(value.category)}/${value.name}`;
1492
1589
  }
1493
1590
  return {
1494
- label: blockExists ? color7.gray(label) : label,
1591
+ label: blockExists ? color8.gray(label) : label,
1495
1592
  value: key,
1496
1593
  // show hint for `Installed` if block is already installed
1497
1594
  hint: blockExists ? "Installed" : void 0
@@ -1505,11 +1602,11 @@ var _add = async (blockNames, options) => {
1505
1602
  }
1506
1603
  installingBlockNames = promptResult;
1507
1604
  }
1508
- verbose(`Installing blocks ${color7.cyan(installingBlockNames.join(", "))}`);
1605
+ verbose(`Installing blocks ${color8.cyan(installingBlockNames.join(", "))}`);
1509
1606
  if (options.verbose) console.log("Blocks map: ", blocksMap);
1510
1607
  const installingBlocks = (await resolveTree(installingBlockNames, blocksMap, repoPaths)).match(
1511
1608
  (val) => val,
1512
- program2.error
1609
+ (err) => program2.error(err)
1513
1610
  );
1514
1611
  const pm = (await detect({ cwd: options.cwd }))?.agent ?? "npm";
1515
1612
  const tasks = [];
@@ -1520,11 +1617,48 @@ var _add = async (blockNames, options) => {
1520
1617
  const watermark = getWatermark(context.package.version, block.sourceRepo.url);
1521
1618
  const providerInfo = block.sourceRepo;
1522
1619
  verbose(`Setting up ${fullSpecifier}`);
1620
+ if (noConfig) {
1621
+ const partialSpecifier = `${color8.cyan(`${block.category}/${block.name}`)}`;
1622
+ const blocksPath = await text({
1623
+ message: `Where would you like to add ${partialSpecifier}?`,
1624
+ initialValue: config.path,
1625
+ defaultValue: config.path,
1626
+ placeholder: config.path,
1627
+ validate(value) {
1628
+ if (value.trim() === "") return "Please provide a value";
1629
+ }
1630
+ });
1631
+ if (isCancel(blocksPath)) {
1632
+ cancel("Canceled!");
1633
+ process.exit(0);
1634
+ }
1635
+ config.path = blocksPath;
1636
+ if (!options.yes) {
1637
+ const includeTests = await confirm({
1638
+ message: `Include tests for ${partialSpecifier}?`,
1639
+ initialValue: config.includeTests
1640
+ });
1641
+ if (isCancel(includeTests)) {
1642
+ cancel("Canceled!");
1643
+ process.exit(0);
1644
+ }
1645
+ config.includeTests = includeTests;
1646
+ const addWatermark = await confirm({
1647
+ message: `Add watermark to ${partialSpecifier}?`,
1648
+ initialValue: config.watermark
1649
+ });
1650
+ if (isCancel(addWatermark)) {
1651
+ cancel("Canceled!");
1652
+ process.exit(0);
1653
+ }
1654
+ config.watermark = addWatermark;
1655
+ }
1656
+ }
1523
1657
  const directory = path6.join(options.cwd, config.path, block.category);
1524
1658
  const blockExists = !block.subdirectory && fs6.existsSync(path6.join(directory, block.files[0])) || block.subdirectory && fs6.existsSync(path6.join(directory, block.name));
1525
1659
  if (blockExists && !options.yes) {
1526
1660
  const result = await confirm({
1527
- message: `${color7.bold(block.name)} already exists in your project would you like to overwrite it?`,
1661
+ message: `${color8.bold(block.name)} already exists in your project would you like to overwrite it?`,
1528
1662
  initialValue: false
1529
1663
  });
1530
1664
  if (isCancel(result) || !result) {
@@ -1536,15 +1670,15 @@ var _add = async (blockNames, options) => {
1536
1670
  loadingMessage: `Adding ${fullSpecifier}`,
1537
1671
  completedMessage: `Added ${fullSpecifier}`,
1538
1672
  run: async () => {
1539
- verbose(`Creating directory ${color7.bold(directory)}`);
1673
+ verbose(`Creating directory ${color8.bold(directory)}`);
1540
1674
  fs6.mkdirSync(directory, { recursive: true });
1541
1675
  const files = [];
1542
1676
  const getSourceFile = async (filePath) => {
1543
1677
  const content = await providerInfo.provider.fetchRaw(providerInfo, filePath);
1544
1678
  if (content.isErr()) {
1545
- loading.stop(color7.red(`Error fetching ${color7.bold(filePath)}`));
1679
+ loading.stop(color8.red(`Error fetching ${color8.bold(filePath)}`));
1546
1680
  program2.error(
1547
- color7.red(`There was an error trying to get ${fullSpecifier}`)
1681
+ color8.red(`There was an error trying to get ${fullSpecifier}`)
1548
1682
  );
1549
1683
  }
1550
1684
  return content.unwrap();
@@ -1613,7 +1747,7 @@ ${content}`;
1613
1747
  if (install) {
1614
1748
  if (deps.size > 0) {
1615
1749
  if (!options.verbose)
1616
- loading.start(`Installing dependencies with ${color7.cyan(pm)}`);
1750
+ loading.start(`Installing dependencies with ${color8.cyan(pm)}`);
1617
1751
  (await installDependencies({
1618
1752
  pm,
1619
1753
  deps: Array.from(deps),
@@ -1622,7 +1756,7 @@ ${content}`;
1622
1756
  })).match(
1623
1757
  (installed) => {
1624
1758
  if (!options.verbose)
1625
- loading.stop(`Installed ${color7.cyan(installed.join(", "))}`);
1759
+ loading.stop(`Installed ${color8.cyan(installed.join(", "))}`);
1626
1760
  },
1627
1761
  (err) => {
1628
1762
  if (!options.verbose) loading.stop("Failed to install dependencies");
@@ -1632,7 +1766,7 @@ ${content}`;
1632
1766
  }
1633
1767
  if (devDeps.size > 0) {
1634
1768
  if (!options.verbose)
1635
- loading.start(`Installing dependencies with ${color7.cyan(pm)}`);
1769
+ loading.start(`Installing dependencies with ${color8.cyan(pm)}`);
1636
1770
  (await installDependencies({
1637
1771
  pm,
1638
1772
  deps: Array.from(devDeps),
@@ -1641,7 +1775,7 @@ ${content}`;
1641
1775
  })).match(
1642
1776
  (installed) => {
1643
1777
  if (!options.verbose)
1644
- loading.stop(`Installed ${color7.cyan(installed.join(", "))}`);
1778
+ loading.stop(`Installed ${color8.cyan(installed.join(", "))}`);
1645
1779
  },
1646
1780
  (err) => {
1647
1781
  if (!options.verbose) loading.stop("Failed to install dev dependencies");
@@ -1655,13 +1789,13 @@ ${content}`;
1655
1789
  if (deps.size > 0) {
1656
1790
  const cmd = resolveCommand2(pm, "install", [...deps]);
1657
1791
  steps.push(
1658
- `Install dependencies \`${color7.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
1792
+ `Install dependencies \`${color8.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
1659
1793
  );
1660
1794
  }
1661
1795
  if (devDeps.size > 0) {
1662
1796
  const cmd = resolveCommand2(pm, "install", [...devDeps, "-D"]);
1663
1797
  steps.push(
1664
- `Install dev dependencies \`${color7.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
1798
+ `Install dev dependencies \`${color8.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
1665
1799
  );
1666
1800
  }
1667
1801
  }
@@ -1669,7 +1803,7 @@ ${content}`;
1669
1803
  if (!install) {
1670
1804
  steps.push("");
1671
1805
  }
1672
- steps.push(`Import the blocks from \`${color7.cyan(config.path)}\``);
1806
+ steps.push(`Import the blocks from \`${color8.cyan(config.path)}\``);
1673
1807
  const next = nextSteps(steps);
1674
1808
  process.stdout.write(next);
1675
1809
  }
@@ -1677,7 +1811,7 @@ ${content}`;
1677
1811
 
1678
1812
  // src/commands/auth.ts
1679
1813
  import { cancel as cancel2, confirm as confirm2, isCancel as isCancel2, outro as outro2, password, select } from "@clack/prompts";
1680
- import color8 from "chalk";
1814
+ import color9 from "chalk";
1681
1815
  import { Command as Command2, Option } from "commander";
1682
1816
  import * as v6 from "valibot";
1683
1817
  var schema3 = v6.object({
@@ -1694,12 +1828,24 @@ var auth = new Command2("auth").description("Provide a token for access to priva
1694
1828
  const options = v6.parse(schema3, opts);
1695
1829
  _intro(context.package.version);
1696
1830
  await _auth(options);
1697
- outro2(color8.green("All done!"));
1831
+ outro2(color9.green("All done!"));
1698
1832
  });
1699
1833
  var _auth = async (options) => {
1700
1834
  const storage = get();
1701
1835
  if (options.logout) {
1702
1836
  for (const provider of providers) {
1837
+ const tokenKey = `${provider.name()}-token`;
1838
+ if (storage.get(tokenKey) === void 0) {
1839
+ process.stdout.write(`${VERTICAL_LINE}
1840
+ `);
1841
+ process.stdout.write(
1842
+ color9.gray(
1843
+ `${VERTICAL_LINE} Already logged out of ${provider.name()}.
1844
+ `
1845
+ )
1846
+ );
1847
+ continue;
1848
+ }
1703
1849
  const response = await confirm2({
1704
1850
  message: `Remove ${provider.name()} token?`,
1705
1851
  initialValue: true
@@ -1709,7 +1855,7 @@ var _auth = async (options) => {
1709
1855
  process.exit(0);
1710
1856
  }
1711
1857
  if (!response) continue;
1712
- storage.delete(`${provider.name()}-token`);
1858
+ storage.delete(tokenKey);
1713
1859
  }
1714
1860
  return;
1715
1861
  }
@@ -1749,7 +1895,7 @@ var _auth = async (options) => {
1749
1895
  // src/commands/build.ts
1750
1896
  import fs7 from "node:fs";
1751
1897
  import { outro as outro3, spinner as spinner3 } from "@clack/prompts";
1752
- import color9 from "chalk";
1898
+ import color10 from "chalk";
1753
1899
  import { Command as Command3, program as program3 } from "commander";
1754
1900
  import path7 from "pathe";
1755
1901
  import * as v7 from "valibot";
@@ -1775,7 +1921,7 @@ var build = new Command3("build").description(`Builds the provided --dirs in the
1775
1921
  const options = v7.parse(schema4, opts);
1776
1922
  _intro(context.package.version);
1777
1923
  await _build(options);
1778
- outro3(color9.green("All done!"));
1924
+ outro3(color10.green("All done!"));
1779
1925
  });
1780
1926
  var _build = async (options) => {
1781
1927
  const loading = spinner3();
@@ -1783,7 +1929,7 @@ var _build = async (options) => {
1783
1929
  const outFile = path7.join(options.cwd, OUTPUT_FILE);
1784
1930
  for (const dir of options.dirs) {
1785
1931
  const dirPath = path7.join(options.cwd, dir);
1786
- loading.start(`Building ${color9.cyan(dirPath)}`);
1932
+ loading.start(`Building ${color10.cyan(dirPath)}`);
1787
1933
  if (options.output && fs7.existsSync(outFile)) fs7.rmSync(outFile);
1788
1934
  const builtCategories = buildBlocksDirectory(dirPath, { ...options });
1789
1935
  for (const category of builtCategories) {
@@ -1791,20 +1937,20 @@ var _build = async (options) => {
1791
1937
  const error = "a category with the same name already exists!";
1792
1938
  if (options.errorOnWarn) {
1793
1939
  program3.error(
1794
- color9.red(
1795
- `\`${color9.bold(`${dir}/${category.name}`)}\` could not be added because ${error}`
1940
+ color10.red(
1941
+ `\`${color10.bold(`${dir}/${category.name}`)}\` could not be added because ${error}`
1796
1942
  )
1797
1943
  );
1798
1944
  } else {
1799
1945
  console.warn(
1800
- `${VERTICAL_LINE} ${WARN} Skipped adding \`${color9.cyan(`${dir}/${category.name}`)}\` because ${error}`
1946
+ `${VERTICAL_LINE} ${WARN} Skipped adding \`${color10.cyan(`${dir}/${category.name}`)}\` because ${error}`
1801
1947
  );
1802
1948
  }
1803
1949
  continue;
1804
1950
  }
1805
1951
  categories.push(category);
1806
1952
  }
1807
- loading.stop(`Built ${color9.cyan(dirPath)}`);
1953
+ loading.stop(`Built ${color10.cyan(dirPath)}`);
1808
1954
  }
1809
1955
  loading.start("Checking manifest");
1810
1956
  const warnings = [];
@@ -1816,14 +1962,14 @@ var _build = async (options) => {
1816
1962
  (cat) => cat.name.trim() === depCategoryName.trim()
1817
1963
  );
1818
1964
  const invalidDependencyError = () => {
1819
- const error = `depends on ${color9.bold(dep)} which doesn't exist!`;
1965
+ const error = `depends on ${color10.bold(dep)} which doesn't exist!`;
1820
1966
  if (options.errorOnWarn) {
1821
1967
  warnings.push(
1822
- color9.red(`${color9.bold(`${category.name}/${block.name}`)} ${error}`)
1968
+ color10.red(`${color10.bold(`${category.name}/${block.name}`)} ${error}`)
1823
1969
  );
1824
1970
  } else {
1825
1971
  warnings.push(
1826
- `${VERTICAL_LINE} ${WARN} ${color9.bold(`${category.name}/${block.name}`)} ${error}`
1972
+ `${VERTICAL_LINE} ${WARN} ${color10.bold(`${category.name}/${block.name}`)} ${error}`
1827
1973
  );
1828
1974
  }
1829
1975
  };
@@ -1837,9 +1983,9 @@ var _build = async (options) => {
1837
1983
  }
1838
1984
  for (const dep of [...block.dependencies, ...block.devDependencies]) {
1839
1985
  if (!dep.includes("@")) {
1840
- const error = `You haven't installed ${color9.bold(dep)} as a dependency so your users could get any version of it when they install your block!`;
1986
+ const error = `You haven't installed ${color10.bold(dep)} as a dependency so your users could get any version of it when they install your block!`;
1841
1987
  if (options.errorOnWarn) {
1842
- warnings.push(color9.red(error));
1988
+ warnings.push(color10.red(error));
1843
1989
  } else {
1844
1990
  warnings.push(`${VERTICAL_LINE} ${WARN} ${error}`);
1845
1991
  }
@@ -1857,23 +2003,23 @@ var _build = async (options) => {
1857
2003
  }
1858
2004
  }
1859
2005
  if (options.output) {
1860
- loading.start(`Writing output to \`${color9.cyan(outFile)}\``);
2006
+ loading.start(`Writing output to \`${color10.cyan(outFile)}\``);
1861
2007
  fs7.writeFileSync(outFile, JSON.stringify(categories, null, " "));
1862
- loading.stop(`Wrote output to \`${color9.cyan(outFile)}\``);
2008
+ loading.stop(`Wrote output to \`${color10.cyan(outFile)}\``);
1863
2009
  }
1864
2010
  };
1865
2011
 
1866
2012
  // src/commands/diff.ts
1867
2013
  import fs8 from "node:fs";
1868
2014
  import { cancel as cancel3, confirm as confirm3, isCancel as isCancel3, outro as outro4, spinner as spinner4 } from "@clack/prompts";
1869
- import color11 from "chalk";
2015
+ import color12 from "chalk";
1870
2016
  import { Command as Command4, program as program4 } from "commander";
1871
2017
  import { diffLines } from "diff";
1872
2018
  import path8 from "pathe";
1873
2019
  import * as v8 from "valibot";
1874
2020
 
1875
2021
  // src/utils/diff.ts
1876
- import color10 from "chalk";
2022
+ import color11 from "chalk";
1877
2023
  import { diffChars } from "diff";
1878
2024
 
1879
2025
  // src/utils/blocks/utils/array-sum.ts
@@ -1922,10 +2068,10 @@ var formatDiff = ({
1922
2068
  changes,
1923
2069
  expand = false,
1924
2070
  maxUnchanged = 5,
1925
- colorRemoved = color10.red,
1926
- colorAdded = color10.green,
1927
- colorCharsRemoved = color10.bgRed,
1928
- colorCharsAdded = color10.bgGreen,
2071
+ colorRemoved = color11.red,
2072
+ colorAdded = color11.green,
2073
+ colorCharsRemoved = color11.bgRed,
2074
+ colorCharsAdded = color11.bgGreen,
1929
2075
  prefix,
1930
2076
  onUnchanged,
1931
2077
  intro: intro2
@@ -1959,7 +2105,7 @@ var formatDiff = ({
1959
2105
  onUnchanged,
1960
2106
  intro: intro2
1961
2107
  });
1962
- const linePrefix = (line) => color10.gray(`${prefix?.() ?? ""}${leftPadMin(`${line + 1 + lineOffset} `, length)} `);
2108
+ const linePrefix = (line) => color11.gray(`${prefix?.() ?? ""}${leftPadMin(`${line + 1 + lineOffset} `, length)} `);
1963
2109
  for (let i = 0; i < changes.length; i++) {
1964
2110
  const change = changes[i];
1965
2111
  const hasPreviousChange = changes[i - 1]?.added || changes[i - 1]?.removed;
@@ -1989,8 +2135,8 @@ var formatDiff = ({
1989
2135
  const count = ls.length - shownLines;
1990
2136
  result += `${join(
1991
2137
  get2(
1992
- color10.gray(
1993
- `+ ${count} more unchanged (${color10.italic("-E to expand")})`
2138
+ color11.gray(
2139
+ `+ ${count} more unchanged (${color11.italic("-E to expand")})`
1994
2140
  )
1995
2141
  ),
1996
2142
  {
@@ -2081,19 +2227,19 @@ var diff = new Command4("diff").description("Compares local blocks to the blocks
2081
2227
  const options = v8.parse(schema5, opts);
2082
2228
  _intro(context.package.version);
2083
2229
  await _diff(options);
2084
- outro4(color11.green("All done!"));
2230
+ outro4(color12.green("All done!"));
2085
2231
  });
2086
2232
  var _diff = async (options) => {
2087
2233
  const loading = spinner4();
2088
2234
  const config = getConfig(options.cwd).match(
2089
2235
  (val) => val,
2090
- (err) => program4.error(color11.red(err))
2236
+ (err) => program4.error(color12.red(err))
2091
2237
  );
2092
2238
  let repoPaths = config.repos;
2093
2239
  if (options.repo) repoPaths = [options.repo];
2094
2240
  if (!options.allow && options.repo) {
2095
2241
  const result = await confirm3({
2096
- message: `Allow ${color11.cyan("jsrepo")} to download and run code from ${color11.cyan(options.repo)}?`,
2242
+ message: `Allow ${color12.cyan("jsrepo")} to download and run code from ${color12.cyan(options.repo)}?`,
2097
2243
  initialValue: true
2098
2244
  });
2099
2245
  if (isCancel3(result) || !result) {
@@ -2101,15 +2247,15 @@ var _diff = async (options) => {
2101
2247
  process.exit(0);
2102
2248
  }
2103
2249
  }
2104
- loading.start(`Fetching blocks from ${color11.cyan(repoPaths.join(", "))}`);
2250
+ loading.start(`Fetching blocks from ${color12.cyan(repoPaths.join(", "))}`);
2105
2251
  const blocksMap = (await fetchBlocks(...repoPaths)).match(
2106
2252
  (val) => val,
2107
2253
  ({ repo, message }) => {
2108
- loading.stop(`Failed fetching blocks from ${color11.cyan(repo)}`);
2109
- program4.error(color11.red(message));
2254
+ loading.stop(`Failed fetching blocks from ${color12.cyan(repo)}`);
2255
+ program4.error(color12.red(message));
2110
2256
  }
2111
2257
  );
2112
- loading.stop(`Retrieved blocks from ${color11.cyan(repoPaths.join(", "))}`);
2258
+ loading.stop(`Retrieved blocks from ${color12.cyan(repoPaths.join(", "))}`);
2113
2259
  const installedBlocks = getInstalled(blocksMap, config, options.cwd);
2114
2260
  for (const blockSpecifier of installedBlocks) {
2115
2261
  let found = false;
@@ -2131,7 +2277,7 @@ var _diff = async (options) => {
2131
2277
  const sourcePath = path8.join(block.directory, file);
2132
2278
  const response = await providerInfo.provider.fetchRaw(providerInfo, sourcePath);
2133
2279
  if (response.isErr()) {
2134
- program4.error(color11.red(`There was an error trying to get ${fullSpecifier}`));
2280
+ program4.error(color12.red(`There was an error trying to get ${fullSpecifier}`));
2135
2281
  }
2136
2282
  let remoteContent = response.unwrap();
2137
2283
  const directory = path8.join(options.cwd, config.path, block.category);
@@ -2165,16 +2311,16 @@ ${remoteContent}`;
2165
2311
  changes,
2166
2312
  expand: options.expand,
2167
2313
  maxUnchanged: options.maxUnchanged,
2168
- colorAdded: color11.greenBright,
2169
- colorRemoved: color11.redBright,
2170
- colorCharsAdded: color11.bgGreenBright,
2171
- colorCharsRemoved: color11.bgRedBright,
2314
+ colorAdded: color12.greenBright,
2315
+ colorRemoved: color12.redBright,
2316
+ colorCharsAdded: color12.bgGreenBright,
2317
+ colorCharsRemoved: color12.bgRedBright,
2172
2318
  prefix: () => `${VERTICAL_LINE} `,
2173
- onUnchanged: ({ from: from2, to, prefix }) => `${prefix?.() ?? ""}${color11.cyan(from2)} \u2192 ${color11.gray(to)} ${color11.gray("(unchanged)")}
2319
+ onUnchanged: ({ from: from2, to, prefix }) => `${prefix?.() ?? ""}${color12.cyan(from2)} \u2192 ${color12.gray(to)} ${color12.gray("(unchanged)")}
2174
2320
  `,
2175
2321
  intro: ({ from: from2, to, changes: changes2, prefix }) => {
2176
2322
  const totalChanges = changes2.filter((a) => a.added).length;
2177
- return `${prefix?.() ?? ""}${color11.cyan(from2)} \u2192 ${color11.gray(to)} (${totalChanges} change${totalChanges === 1 ? "" : "s"})
2323
+ return `${prefix?.() ?? ""}${color12.cyan(from2)} \u2192 ${color12.gray(to)} (${totalChanges} change${totalChanges === 1 ? "" : "s"})
2178
2324
  ${prefix?.() ?? ""}
2179
2325
  `;
2180
2326
  }
@@ -2185,7 +2331,7 @@ ${prefix?.() ?? ""}
2185
2331
  }
2186
2332
  if (!found) {
2187
2333
  program4.error(
2188
- color11.red(`Invalid block! ${color11.bold(blockSpecifier)} does not exist!`)
2334
+ color12.red(`Invalid block! ${color12.bold(blockSpecifier)} does not exist!`)
2189
2335
  );
2190
2336
  }
2191
2337
  }
@@ -2193,8 +2339,8 @@ ${prefix?.() ?? ""}
2193
2339
 
2194
2340
  // src/commands/init.ts
2195
2341
  import fs9 from "node:fs";
2196
- import { cancel as cancel4, confirm as confirm4, isCancel as isCancel4, outro as outro5, password as password2, select as select2, spinner as spinner5, text } from "@clack/prompts";
2197
- import color12 from "chalk";
2342
+ import { cancel as cancel4, confirm as confirm4, isCancel as isCancel4, outro as outro5, password as password2, select as select2, spinner as spinner5, text as text2 } from "@clack/prompts";
2343
+ import color13 from "chalk";
2198
2344
  import { Command as Command5, program as program5 } from "commander";
2199
2345
  import { detect as detect2, resolveCommand as resolveCommand3 } from "package-manager-detector";
2200
2346
  import path9 from "pathe";
@@ -2218,8 +2364,8 @@ var init = new Command5("init").description("Initializes your project with a con
2218
2364
  _intro(context.package.version);
2219
2365
  if (options.registry !== void 0 && options.project !== void 0) {
2220
2366
  program5.error(
2221
- color12.red(
2222
- `You cannot provide both ${color12.bold("--project")} and ${color12.bold("--registry")} at the same time.`
2367
+ color13.red(
2368
+ `You cannot provide both ${color13.bold("--project")} and ${color13.bold("--registry")} at the same time.`
2223
2369
  )
2224
2370
  );
2225
2371
  }
@@ -2243,14 +2389,14 @@ var init = new Command5("init").description("Initializes your project with a con
2243
2389
  } else {
2244
2390
  await _initProject(options);
2245
2391
  }
2246
- outro5(color12.green("All done!"));
2392
+ outro5(color13.green("All done!"));
2247
2393
  });
2248
2394
  var _initProject = async (options) => {
2249
2395
  const storage = get();
2250
2396
  const initialConfig = getConfig(options.cwd);
2251
2397
  const loading = spinner5();
2252
2398
  if (!options.path) {
2253
- const result = await text({
2399
+ const result = await text2({
2254
2400
  message: "Where should we add the blocks?",
2255
2401
  validate(value) {
2256
2402
  if (value.trim() === "") return "Please provide a value";
@@ -2276,7 +2422,7 @@ var _initProject = async (options) => {
2276
2422
  process.exit(0);
2277
2423
  }
2278
2424
  if (!confirmResult) break;
2279
- const result = await text({
2425
+ const result = await text2({
2280
2426
  message: "Where should we download the blocks from?",
2281
2427
  placeholder: "github/ieedan/std",
2282
2428
  validate: (val) => {
@@ -2292,7 +2438,7 @@ var _initProject = async (options) => {
2292
2438
  }
2293
2439
  const provider = providers.find((p) => p.matches(result));
2294
2440
  if (!provider) {
2295
- program5.error(color12.red("Invalid provider!"));
2441
+ program5.error(color13.red("Invalid provider!"));
2296
2442
  }
2297
2443
  const tokenKey = `${provider.name()}-token`;
2298
2444
  const token = storage.get(tokenKey);
@@ -2342,10 +2488,10 @@ var _initRegistry = async (options) => {
2342
2488
  const loading = spinner5();
2343
2489
  const packagePath = path9.join(options.cwd, "package.json");
2344
2490
  if (!fs9.existsSync(packagePath)) {
2345
- program5.error(color12.red(`Couldn't find your ${color12.bold("package.json")}!`));
2491
+ program5.error(color13.red(`Couldn't find your ${color13.bold("package.json")}!`));
2346
2492
  }
2347
2493
  if (!options.path) {
2348
- const response = await text({
2494
+ const response = await text2({
2349
2495
  message: "Where are your blocks located?",
2350
2496
  defaultValue: "./blocks",
2351
2497
  initialValue: "./blocks",
@@ -2361,7 +2507,7 @@ var _initRegistry = async (options) => {
2361
2507
  const scriptAlreadyExists = pkg.scripts !== void 0 && pkg.scripts[options.script] !== void 0;
2362
2508
  if (!options.yes && scriptAlreadyExists) {
2363
2509
  const response = await confirm4({
2364
- message: `The \`${color12.cyan(options.script)}\` already exists overwrite?`,
2510
+ message: `The \`${color13.cyan(options.script)}\` already exists overwrite?`,
2365
2511
  initialValue: false
2366
2512
  });
2367
2513
  if (isCancel4(response)) {
@@ -2369,7 +2515,7 @@ var _initRegistry = async (options) => {
2369
2515
  process.exit(0);
2370
2516
  }
2371
2517
  if (!response) {
2372
- const response2 = await text({
2518
+ const response2 = await text2({
2373
2519
  message: "What would you like to call the script?",
2374
2520
  defaultValue: "build:registry",
2375
2521
  placeholder: "build:registry",
@@ -2404,7 +2550,7 @@ var _initRegistry = async (options) => {
2404
2550
  buildScript += "jsrepo build ";
2405
2551
  } else {
2406
2552
  const command = resolveCommand3(pm, "execute", ["jsrepo", "build"]);
2407
- if (!command) program5.error(color12.red(`Error resolving execute command for ${pm}`));
2553
+ if (!command) program5.error(color13.red(`Error resolving execute command for ${pm}`));
2408
2554
  buildScript += `${command.command} ${command.args.join(" ")} `;
2409
2555
  }
2410
2556
  if (options.path !== "./build") {
@@ -2414,13 +2560,13 @@ var _initRegistry = async (options) => {
2414
2560
  pkg.scripts = {};
2415
2561
  }
2416
2562
  pkg.scripts[options.script] = buildScript;
2417
- loading.start(`Adding \`${color12.cyan(options.script)}\` to scripts in package.json`);
2563
+ loading.start(`Adding \`${color13.cyan(options.script)}\` to scripts in package.json`);
2418
2564
  try {
2419
2565
  fs9.writeFileSync(packagePath, JSON.stringify(pkg, null, " "));
2420
2566
  } catch (err) {
2421
- program5.error(color12.red(`Error writing to \`${color12.bold(packagePath)}\`. Error: ${err}`));
2567
+ program5.error(color13.red(`Error writing to \`${color13.bold(packagePath)}\`. Error: ${err}`));
2422
2568
  }
2423
- loading.stop(`Added \`${color12.cyan(options.script)}\` to scripts in package.json`);
2569
+ loading.stop(`Added \`${color13.cyan(options.script)}\` to scripts in package.json`);
2424
2570
  let installed = alreadyInstalled;
2425
2571
  if (installAsDevDependency && !alreadyInstalled) {
2426
2572
  let shouldInstall = options.yes;
@@ -2457,13 +2603,13 @@ var _initRegistry = async (options) => {
2457
2603
  if (!installed && installAsDevDependency) {
2458
2604
  const cmd = resolveCommand3(pm, "install", ["jsrepo", "-D"]);
2459
2605
  steps.push(
2460
- `Install ${JSREPO} as a dev dependency \`${color12.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
2606
+ `Install ${JSREPO} as a dev dependency \`${color13.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
2461
2607
  );
2462
2608
  }
2463
- steps.push(`Add blocks to \`${color12.cyan(options.path)}\`.`);
2609
+ steps.push(`Add blocks to \`${color13.cyan(options.path)}\`.`);
2464
2610
  const runScript = resolveCommand3(pm, "run", [options.script]);
2465
2611
  steps.push(
2466
- `Run \`${color12.cyan(`${runScript?.command} ${runScript?.args.join(" ")}`)}\` to build the registry.`
2612
+ `Run \`${color13.cyan(`${runScript?.command} ${runScript?.args.join(" ")}`)}\` to build the registry.`
2467
2613
  );
2468
2614
  steps = steps.map((step, i) => `${i + 1}. ${step}`);
2469
2615
  const next = nextSteps(steps);
@@ -2473,7 +2619,7 @@ var _initRegistry = async (options) => {
2473
2619
  // src/commands/test.ts
2474
2620
  import fs10 from "node:fs";
2475
2621
  import { cancel as cancel5, confirm as confirm5, isCancel as isCancel5, outro as outro6, spinner as spinner6 } from "@clack/prompts";
2476
- import color13 from "chalk";
2622
+ import color14 from "chalk";
2477
2623
  import { Argument, Command as Command6, program as program6 } from "commander";
2478
2624
  import { execa as execa2 } from "execa";
2479
2625
  import { resolveCommand as resolveCommand4 } from "package-manager-detector/commands";
@@ -2492,7 +2638,7 @@ var test = new Command6("test").description("Tests local blocks against most rec
2492
2638
  const options = v10.parse(schema7, opts);
2493
2639
  _intro(context.package.version);
2494
2640
  await _test(blockNames, options);
2495
- outro6(color13.green("All done!"));
2641
+ outro6(color14.green("All done!"));
2496
2642
  });
2497
2643
  var _test = async (blockNames, options) => {
2498
2644
  const verbose = (msg) => {
@@ -2503,7 +2649,7 @@ var _test = async (blockNames, options) => {
2503
2649
  verbose(`Attempting to test ${JSON.stringify(blockNames)}`);
2504
2650
  const config = getConfig(options.cwd).match(
2505
2651
  (val) => val,
2506
- (err) => program6.error(color13.red(err))
2652
+ (err) => program6.error(color14.red(err))
2507
2653
  );
2508
2654
  const loading = spinner6();
2509
2655
  const blocksMap = /* @__PURE__ */ new Map();
@@ -2511,7 +2657,7 @@ var _test = async (blockNames, options) => {
2511
2657
  if (options.repo) repoPaths = [options.repo];
2512
2658
  if (!options.allow && options.repo) {
2513
2659
  const result = await confirm5({
2514
- message: `Allow ${color13.cyan("jsrepo")} to download and run code from ${color13.cyan(options.repo)}?`,
2660
+ message: `Allow ${color14.cyan("jsrepo")} to download and run code from ${color14.cyan(options.repo)}?`,
2515
2661
  initialValue: true
2516
2662
  });
2517
2663
  if (isCancel5(result) || !result) {
@@ -2519,20 +2665,20 @@ var _test = async (blockNames, options) => {
2519
2665
  process.exit(0);
2520
2666
  }
2521
2667
  }
2522
- verbose(`Fetching blocks from ${color13.cyan(repoPaths.join(", "))}`);
2523
- if (!options.verbose) loading.start(`Fetching blocks from ${color13.cyan(repoPaths.join(", "))}`);
2668
+ verbose(`Fetching blocks from ${color14.cyan(repoPaths.join(", "))}`);
2669
+ if (!options.verbose) loading.start(`Fetching blocks from ${color14.cyan(repoPaths.join(", "))}`);
2524
2670
  for (const repo of repoPaths) {
2525
2671
  const providerInfo = (await getProviderInfo(repo)).match(
2526
2672
  (info) => info,
2527
- (err) => program6.error(color13.red(err))
2673
+ (err) => program6.error(color14.red(err))
2528
2674
  );
2529
2675
  const manifest = await providerInfo.provider.fetchManifest(providerInfo);
2530
- verbose(`Got info for provider ${color13.cyan(providerInfo.name)}`);
2676
+ verbose(`Got info for provider ${color14.cyan(providerInfo.name)}`);
2531
2677
  if (manifest.isErr()) {
2532
- if (!options.verbose) loading.stop(`Error fetching ${color13.cyan(repo)}`);
2678
+ if (!options.verbose) loading.stop(`Error fetching ${color14.cyan(repo)}`);
2533
2679
  program6.error(
2534
- color13.red(
2535
- `There was an error fetching the \`${OUTPUT_FILE}\` from the repository ${color13.cyan(
2680
+ color14.red(
2681
+ `There was an error fetching the \`${OUTPUT_FILE}\` from the repository ${color14.cyan(
2536
2682
  repo
2537
2683
  )} make sure the target repository has a \`${OUTPUT_FILE}\` in its root?`
2538
2684
  )
@@ -2551,12 +2697,12 @@ var _test = async (blockNames, options) => {
2551
2697
  }
2552
2698
  }
2553
2699
  }
2554
- verbose(`Retrieved blocks from ${color13.cyan(repoPaths.join(", "))}`);
2555
- if (!options.verbose) loading.stop(`Retrieved blocks from ${color13.cyan(repoPaths.join(", "))}`);
2700
+ verbose(`Retrieved blocks from ${color14.cyan(repoPaths.join(", "))}`);
2701
+ if (!options.verbose) loading.stop(`Retrieved blocks from ${color14.cyan(repoPaths.join(", "))}`);
2556
2702
  const tempTestDirectory = path10.resolve(
2557
2703
  path10.join(options.cwd, `blocks-tests-temp-${Date.now()}`)
2558
2704
  );
2559
- verbose(`Trying to create the temp directory ${color13.bold(tempTestDirectory)}.`);
2705
+ verbose(`Trying to create the temp directory ${color14.bold(tempTestDirectory)}.`);
2560
2706
  fs10.mkdirSync(tempTestDirectory, { recursive: true });
2561
2707
  const cleanUp = () => {
2562
2708
  fs10.rmSync(tempTestDirectory, { recursive: true, force: true });
@@ -2570,12 +2716,12 @@ var _test = async (blockNames, options) => {
2570
2716
  }
2571
2717
  if (testingBlocks.length === 0) {
2572
2718
  cleanUp();
2573
- program6.error(color13.red("There were no blocks found in your project!"));
2719
+ program6.error(color14.red("There were no blocks found in your project!"));
2574
2720
  }
2575
2721
  const testingBlocksMapped = [];
2576
2722
  for (const blockSpecifier of testingBlocks) {
2577
2723
  let block = void 0;
2578
- if (!blockSpecifier.startsWith("github")) {
2724
+ if (!providers.find((p) => blockSpecifier.startsWith(p.name()))) {
2579
2725
  for (const repo of repoPaths) {
2580
2726
  const providerInfo = (await getProviderInfo(repo)).unwrap();
2581
2727
  const tempBlock = blocksMap.get(
@@ -2596,11 +2742,11 @@ var _test = async (blockNames, options) => {
2596
2742
  }
2597
2743
  const providerInfo = (await getProviderInfo(repo)).match(
2598
2744
  (val) => val,
2599
- (err) => program6.error(color13.red(err))
2745
+ (err) => program6.error(color14.red(err))
2600
2746
  );
2601
2747
  const categories = (await providerInfo.provider.fetchManifest(providerInfo)).match(
2602
2748
  (val) => val,
2603
- (err) => program6.error(color13.red(err))
2749
+ (err) => program6.error(color14.red(err))
2604
2750
  );
2605
2751
  for (const category of categories) {
2606
2752
  for (const block2 of category.blocks) {
@@ -2618,7 +2764,7 @@ var _test = async (blockNames, options) => {
2618
2764
  }
2619
2765
  if (!block) {
2620
2766
  program6.error(
2621
- color13.red(`Invalid block! ${color13.bold(blockSpecifier)} does not exist!`)
2767
+ color14.red(`Invalid block! ${color14.bold(blockSpecifier)} does not exist!`)
2622
2768
  );
2623
2769
  }
2624
2770
  testingBlocksMapped.push({ name: blockSpecifier, block });
@@ -2627,17 +2773,17 @@ var _test = async (blockNames, options) => {
2627
2773
  const providerInfo = block.sourceRepo;
2628
2774
  const fullSpecifier = `${block.sourceRepo.url}/${block.category}/${block.name}`;
2629
2775
  if (!options.verbose) {
2630
- loading.start(`Setting up test file for ${color13.cyan(fullSpecifier)}`);
2776
+ loading.start(`Setting up test file for ${color14.cyan(fullSpecifier)}`);
2631
2777
  }
2632
2778
  if (!block.tests) {
2633
- loading.stop(`No tests found for ${color13.cyan(fullSpecifier)}`);
2779
+ loading.stop(`No tests found for ${color14.cyan(fullSpecifier)}`);
2634
2780
  continue;
2635
2781
  }
2636
2782
  const getSourceFile = async (filePath) => {
2637
2783
  const content = await providerInfo.provider.fetchRaw(providerInfo, filePath);
2638
2784
  if (content.isErr()) {
2639
- loading.stop(color13.red(`Error fetching ${color13.bold(filePath)}`));
2640
- program6.error(color13.red(`There was an error trying to get ${fullSpecifier}`));
2785
+ loading.stop(color14.red(`Error fetching ${color14.bold(filePath)}`));
2786
+ program6.error(color14.red(`There was an error trying to get ${fullSpecifier}`));
2641
2787
  }
2642
2788
  return content.unwrap();
2643
2789
  };
@@ -2680,19 +2826,19 @@ var _test = async (blockNames, options) => {
2680
2826
  }
2681
2827
  }
2682
2828
  project.saveSync();
2683
- verbose(`Completed ${color13.cyan.bold(fullSpecifier)} test file`);
2829
+ verbose(`Completed ${color14.cyan.bold(fullSpecifier)} test file`);
2684
2830
  if (!options.verbose) {
2685
- loading.stop(`Completed setup for ${color13.bold(fullSpecifier)}`);
2831
+ loading.stop(`Completed setup for ${color14.bold(fullSpecifier)}`);
2686
2832
  }
2687
2833
  }
2688
2834
  verbose("Beginning testing");
2689
2835
  const pm = await detect3({ cwd: options.cwd });
2690
2836
  if (pm == null) {
2691
- program6.error(color13.red("Could not detect package manager"));
2837
+ program6.error(color14.red("Could not detect package manager"));
2692
2838
  }
2693
2839
  const resolved = resolveCommand4(pm.agent, "execute", ["vitest", "run", tempTestDirectory]);
2694
2840
  if (resolved == null) {
2695
- program6.error(color13.red(`Could not resolve add command for '${pm.agent}'.`));
2841
+ program6.error(color14.red(`Could not resolve add command for '${pm.agent}'.`));
2696
2842
  }
2697
2843
  const { command, args } = resolved;
2698
2844
  const testCommand = `${command} ${args.join(" ")}`;
@@ -2709,7 +2855,7 @@ var _test = async (blockNames, options) => {
2709
2855
  } catch (err) {
2710
2856
  if (options.debug) {
2711
2857
  console.info(
2712
- `${color13.bold("--debug")} flag provided. Skipping cleanup. Run '${color13.bold(
2858
+ `${color14.bold("--debug")} flag provided. Skipping cleanup. Run '${color14.bold(
2713
2859
  testCommand
2714
2860
  )}' to retry tests.
2715
2861
  `
@@ -2717,14 +2863,14 @@ var _test = async (blockNames, options) => {
2717
2863
  } else {
2718
2864
  cleanUp();
2719
2865
  }
2720
- program6.error(color13.red(`Tests failed! Error ${err}`));
2866
+ program6.error(color14.red(`Tests failed! Error ${err}`));
2721
2867
  }
2722
2868
  };
2723
2869
 
2724
2870
  // src/commands/update.ts
2725
2871
  import fs11 from "node:fs";
2726
2872
  import { cancel as cancel6, confirm as confirm6, isCancel as isCancel6, multiselect as multiselect2, outro as outro7, spinner as spinner7 } from "@clack/prompts";
2727
- import color14 from "chalk";
2873
+ import color15 from "chalk";
2728
2874
  import { Command as Command7, program as program7 } from "commander";
2729
2875
  import { diffLines as diffLines2 } from "diff";
2730
2876
  import { resolveCommand as resolveCommand5 } from "package-manager-detector/commands";
@@ -2751,7 +2897,7 @@ var update = new Command7("update").argument("[blocks...]", "Names of the blocks
2751
2897
  const options = v11.parse(schema8, opts);
2752
2898
  _intro(context.package.version);
2753
2899
  await _update(blockNames, options);
2754
- outro7(color14.green("All done!"));
2900
+ outro7(color15.green("All done!"));
2755
2901
  });
2756
2902
  var _update = async (blockNames, options) => {
2757
2903
  const verbose = (msg) => {
@@ -2763,22 +2909,22 @@ var _update = async (blockNames, options) => {
2763
2909
  const loading = spinner7();
2764
2910
  const config = getConfig(options.cwd).match(
2765
2911
  (val) => val,
2766
- (err) => program7.error(color14.red(err))
2912
+ (err) => program7.error(color15.red(err))
2767
2913
  );
2768
2914
  let repoPaths = config.repos;
2769
2915
  if (options.repo) repoPaths = [options.repo];
2770
2916
  for (const blockSpecifier of blockNames) {
2771
- if (blockSpecifier.startsWith("github")) {
2917
+ if (providers.find((p) => blockSpecifier.startsWith(p.name()))) {
2772
2918
  program7.error(
2773
- color14.red(
2774
- `Invalid value provided for block names \`${color14.bold(blockSpecifier)}\`. Block names are expected to be provided in the format of \`${color14.bold("<category>/<name>")}\``
2919
+ color15.red(
2920
+ `Invalid value provided for block names \`${color15.bold(blockSpecifier)}\`. Block names are expected to be provided in the format of \`${color15.bold("<category>/<name>")}\``
2775
2921
  )
2776
2922
  );
2777
2923
  }
2778
2924
  }
2779
2925
  if (!options.allow && options.repo) {
2780
2926
  const result = await confirm6({
2781
- message: `Allow ${color14.cyan("jsrepo")} to download and run code from ${color14.cyan(options.repo)}?`,
2927
+ message: `Allow ${color15.cyan("jsrepo")} to download and run code from ${color15.cyan(options.repo)}?`,
2782
2928
  initialValue: true
2783
2929
  });
2784
2930
  if (isCancel6(result) || !result) {
@@ -2786,17 +2932,17 @@ var _update = async (blockNames, options) => {
2786
2932
  process.exit(0);
2787
2933
  }
2788
2934
  }
2789
- verbose(`Fetching blocks from ${color14.cyan(repoPaths.join(", "))}`);
2790
- if (!options.verbose) loading.start(`Fetching blocks from ${color14.cyan(repoPaths.join(", "))}`);
2935
+ verbose(`Fetching blocks from ${color15.cyan(repoPaths.join(", "))}`);
2936
+ if (!options.verbose) loading.start(`Fetching blocks from ${color15.cyan(repoPaths.join(", "))}`);
2791
2937
  const blocksMap = (await fetchBlocks(...repoPaths)).match(
2792
2938
  (val) => val,
2793
2939
  ({ repo, message }) => {
2794
- loading.stop(`Failed fetching blocks from ${color14.cyan(repo)}`);
2795
- program7.error(color14.red(message));
2940
+ loading.stop(`Failed fetching blocks from ${color15.cyan(repo)}`);
2941
+ program7.error(color15.red(message));
2796
2942
  }
2797
2943
  );
2798
- if (!options.verbose) loading.stop(`Retrieved blocks from ${color14.cyan(repoPaths.join(", "))}`);
2799
- verbose(`Retrieved blocks from ${color14.cyan(repoPaths.join(", "))}`);
2944
+ if (!options.verbose) loading.stop(`Retrieved blocks from ${color15.cyan(repoPaths.join(", "))}`);
2945
+ verbose(`Retrieved blocks from ${color15.cyan(repoPaths.join(", "))}`);
2800
2946
  const installedBlocks = getInstalled(blocksMap, config, options.cwd);
2801
2947
  let updatingBlockNames = blockNames;
2802
2948
  if (options.all) {
@@ -2807,7 +2953,7 @@ var _update = async (blockNames, options) => {
2807
2953
  message: "Which blocks would you like to update?",
2808
2954
  options: installedBlocks.map((block) => {
2809
2955
  return {
2810
- label: `${color14.cyan(block.block.category)}/${block.block.name}`,
2956
+ label: `${color15.cyan(block.block.category)}/${block.block.name}`,
2811
2957
  value: block.specifier
2812
2958
  };
2813
2959
  }),
@@ -2819,7 +2965,7 @@ var _update = async (blockNames, options) => {
2819
2965
  }
2820
2966
  updatingBlockNames = promptResult;
2821
2967
  }
2822
- verbose(`Preparing to update ${color14.cyan(updatingBlockNames.join(", "))}`);
2968
+ verbose(`Preparing to update ${color15.cyan(updatingBlockNames.join(", "))}`);
2823
2969
  const updatingBlocks = (await resolveTree(updatingBlockNames, blocksMap, repoPaths)).match(
2824
2970
  (val) => val,
2825
2971
  program7.error
@@ -2838,8 +2984,8 @@ var _update = async (blockNames, options) => {
2838
2984
  const getSourceFile = async (filePath) => {
2839
2985
  const content = await providerInfo.provider.fetchRaw(providerInfo, filePath);
2840
2986
  if (content.isErr()) {
2841
- loading.stop(color14.red(`Error fetching ${color14.bold(filePath)}`));
2842
- program7.error(color14.red(`There was an error trying to get ${fullSpecifier}`));
2987
+ loading.stop(color15.red(`Error fetching ${color15.bold(filePath)}`));
2988
+ program7.error(color15.red(`There was an error trying to get ${fullSpecifier}`));
2843
2989
  }
2844
2990
  return content.unwrap();
2845
2991
  };
@@ -2893,16 +3039,16 @@ ${remoteContent}`;
2893
3039
  changes,
2894
3040
  expand: options.expand,
2895
3041
  maxUnchanged: options.maxUnchanged,
2896
- colorAdded: color14.greenBright,
2897
- colorRemoved: color14.redBright,
2898
- colorCharsAdded: color14.bgGreenBright,
2899
- colorCharsRemoved: color14.bgRedBright,
3042
+ colorAdded: color15.greenBright,
3043
+ colorRemoved: color15.redBright,
3044
+ colorCharsAdded: color15.bgGreenBright,
3045
+ colorCharsRemoved: color15.bgRedBright,
2900
3046
  prefix: () => `${VERTICAL_LINE} `,
2901
- onUnchanged: ({ from: from2, to: to2, prefix }) => `${prefix?.() ?? ""}${color14.cyan(from2)} \u2192 ${color14.gray(to2)} ${color14.gray("(unchanged)")}
3047
+ onUnchanged: ({ from: from2, to: to2, prefix }) => `${prefix?.() ?? ""}${color15.cyan(from2)} \u2192 ${color15.gray(to2)} ${color15.gray("(unchanged)")}
2902
3048
  `,
2903
3049
  intro: ({ from: from2, to: to2, changes: changes2, prefix }) => {
2904
3050
  const totalChanges = changes2.filter((a) => a.added).length;
2905
- return `${prefix?.() ?? ""}${color14.cyan(from2)} \u2192 ${color14.gray(to2)} (${totalChanges} change${totalChanges === 1 ? "" : "s"})
3051
+ return `${prefix?.() ?? ""}${color15.cyan(from2)} \u2192 ${color15.gray(to2)} (${totalChanges} change${totalChanges === 1 ? "" : "s"})
2906
3052
  ${prefix?.() ?? ""}
2907
3053
  `;
2908
3054
  }
@@ -2924,8 +3070,8 @@ ${prefix?.() ?? ""}
2924
3070
  await runTasks(
2925
3071
  [
2926
3072
  {
2927
- loadingMessage: `Writing changes to ${color14.cyan(file.destPath)}`,
2928
- completedMessage: `Wrote changes to ${color14.cyan(file.destPath)}.`,
3073
+ loadingMessage: `Writing changes to ${color15.cyan(file.destPath)}`,
3074
+ completedMessage: `Wrote changes to ${color15.cyan(file.destPath)}.`,
2929
3075
  run: async () => fs11.writeFileSync(file.destPath, remoteContent)
2930
3076
  }
2931
3077
  ],
@@ -2969,7 +3115,7 @@ ${prefix?.() ?? ""}
2969
3115
  if (install) {
2970
3116
  if (deps.size > 0) {
2971
3117
  if (!options.verbose)
2972
- loading.start(`Installing dependencies with ${color14.cyan(pm)}`);
3118
+ loading.start(`Installing dependencies with ${color15.cyan(pm)}`);
2973
3119
  (await installDependencies({
2974
3120
  pm,
2975
3121
  deps: Array.from(deps),
@@ -2978,7 +3124,7 @@ ${prefix?.() ?? ""}
2978
3124
  })).match(
2979
3125
  (installed) => {
2980
3126
  if (!options.verbose)
2981
- loading.stop(`Installed ${color14.cyan(installed.join(", "))}`);
3127
+ loading.stop(`Installed ${color15.cyan(installed.join(", "))}`);
2982
3128
  },
2983
3129
  (err) => {
2984
3130
  if (!options.verbose) loading.stop("Failed to install dependencies");
@@ -2988,7 +3134,7 @@ ${prefix?.() ?? ""}
2988
3134
  }
2989
3135
  if (devDeps.size > 0) {
2990
3136
  if (!options.verbose)
2991
- loading.start(`Installing dependencies with ${color14.cyan(pm)}`);
3137
+ loading.start(`Installing dependencies with ${color15.cyan(pm)}`);
2992
3138
  (await installDependencies({
2993
3139
  pm,
2994
3140
  deps: Array.from(devDeps),
@@ -2997,7 +3143,7 @@ ${prefix?.() ?? ""}
2997
3143
  })).match(
2998
3144
  (installed) => {
2999
3145
  if (!options.verbose)
3000
- loading.stop(`Installed ${color14.cyan(installed.join(", "))}`);
3146
+ loading.stop(`Installed ${color15.cyan(installed.join(", "))}`);
3001
3147
  },
3002
3148
  (err) => {
3003
3149
  if (!options.verbose) loading.stop("Failed to install dev dependencies");
@@ -3011,13 +3157,13 @@ ${prefix?.() ?? ""}
3011
3157
  if (deps.size > 0) {
3012
3158
  const cmd = resolveCommand5(pm, "install", [...deps]);
3013
3159
  steps.push(
3014
- `Install dependencies \`${color14.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
3160
+ `Install dependencies \`${color15.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
3015
3161
  );
3016
3162
  }
3017
3163
  if (devDeps.size > 0) {
3018
3164
  const cmd = resolveCommand5(pm, "install", [...devDeps, "-D"]);
3019
3165
  steps.push(
3020
- `Install dev dependencies \`${color14.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
3166
+ `Install dev dependencies \`${color15.cyan(`${cmd?.command} ${cmd?.args.join(" ")}`)}\``
3021
3167
  );
3022
3168
  }
3023
3169
  }
@@ -3025,7 +3171,7 @@ ${prefix?.() ?? ""}
3025
3171
  if (!install) {
3026
3172
  steps.push("");
3027
3173
  }
3028
- steps.push(`Import the blocks from \`${color14.cyan(config.path)}\``);
3174
+ steps.push(`Import the blocks from \`${color15.cyan(config.path)}\``);
3029
3175
  const next = nextSteps(steps);
3030
3176
  process.stdout.write(next);
3031
3177
  }