zion 2.5.0 → 2.5.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.
Files changed (2) hide show
  1. package/dist/cli.js +36 -16
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import os3 from "os";
5
5
  import path14 from "path";
6
6
 
7
7
  // package.json
8
- var version = "2.5.0";
8
+ var version = "2.5.1";
9
9
 
10
10
  // src/lib/theme.ts
11
11
  import chalk, { supportsColor, supportsColorStderr } from "chalk";
@@ -1573,17 +1573,19 @@ var InstallFlow = class {
1573
1573
  async run(ui, options, ctx) {
1574
1574
  const { api, lockfile } = this.deps;
1575
1575
  const lock = await lockfile.read();
1576
- const available = await ui.task(
1577
- "Fetching the list of skills",
1578
- (signal) => api.list(signal),
1579
- (names2) => ({ title: `${plural(names2.length, "skill")} available` })
1580
- );
1581
- if (available.length === 0) throw new CliError(`${api.host} has no skills right now`, "try again later");
1582
- const names = await this.chooseSkills(ui, options, ctx, available, lock);
1576
+ const names = await this.chooseSkills(ui, options, ctx, lock);
1583
1577
  const targets = await chooseTargets(ui, this.deps, options.targets, lock);
1584
1578
  const skills = await ui.task(
1585
1579
  `Downloading ${names.join(", ")}`,
1586
- (signal) => Promise.all(names.map((name) => api.get(name, signal))),
1580
+ (signal) => Promise.all(
1581
+ names.map(
1582
+ (name) => api.get(name, signal).catch((error) => {
1583
+ if (error instanceof SkillNotFoundError)
1584
+ throw new SkillNotFoundError(name, `run ${ctx.bin} skills list to see them all`);
1585
+ throw error;
1586
+ })
1587
+ )
1588
+ ),
1587
1589
  (skills2) => {
1588
1590
  const width = Math.max(...skills2.map((skill) => skill.name.length));
1589
1591
  return {
@@ -1622,15 +1624,20 @@ var InstallFlow = class {
1622
1624
  });
1623
1625
  return 0;
1624
1626
  }
1625
- async chooseSkills(ui, options, ctx, available, lock) {
1626
- if (options.all) return [...available];
1627
+ async chooseSkills(ui, options, ctx, lock) {
1627
1628
  if (options.names.length > 0) {
1628
- const missing = options.names.find((name) => !available.includes(name));
1629
- if (missing) throw new CliError(`No skill named ${missing}`, `run ${ctx.bin} skills list to see them all`);
1630
1629
  const names = [...new Set(options.names)];
1631
1630
  ui.step({ title: "Skills", lines: [names.join(", ")] });
1632
1631
  return names;
1633
1632
  }
1633
+ const { api } = this.deps;
1634
+ const available = await ui.task(
1635
+ "Fetching the list of skills",
1636
+ (signal) => api.list(signal),
1637
+ (names) => ({ title: `${plural(names.length, "skill")} available` })
1638
+ );
1639
+ if (available.length === 0) throw new CliError(`${api.host} has no skills right now`, "try again later");
1640
+ if (options.all) return [...available];
1634
1641
  return ui.multiselect({
1635
1642
  message: "Which skills?",
1636
1643
  options: available.map((name) => ({
@@ -2046,8 +2053,21 @@ function parseSkillsOptions(args, bin, targetIds) {
2046
2053
  // src/commands/skills/output.ts
2047
2054
  import path11 from "path";
2048
2055
  async function listSkills({ api, lockfile }, ctx, json) {
2049
- const [available, lock] = await Promise.all([api.list(), lockfile.read()]);
2050
- const names = [.../* @__PURE__ */ new Set([...available, ...Object.keys(lock.skills)])].sort();
2056
+ const [listed, lock] = await Promise.all([api.list(), lockfile.read()]);
2057
+ const unlisted = Object.keys(lock.skills).filter((name) => !listed.includes(name));
2058
+ const found = await Promise.all(
2059
+ unlisted.map(
2060
+ (name) => api.get(name).then(
2061
+ () => true,
2062
+ (error) => {
2063
+ if (error instanceof SkillNotFoundError) return false;
2064
+ throw error;
2065
+ }
2066
+ )
2067
+ )
2068
+ );
2069
+ const available = [...listed, ...unlisted.filter((_, i) => found[i])];
2070
+ const names = [.../* @__PURE__ */ new Set([...listed, ...unlisted])].sort();
2051
2071
  const rows = names.map((name) => {
2052
2072
  const entry = lock.skills[name];
2053
2073
  return {
@@ -2296,7 +2316,7 @@ var registry = new CommandRegistry().register(
2296
2316
  })
2297
2317
  ).register(
2298
2318
  new SkillsCommand({
2299
- api: new HttpSkillsApi("https://zzzzion.com/api/skills"),
2319
+ api: new HttpSkillsApi(process.env.ZION_SKILLS_URL || "https://zzzzion.com/api/skills"),
2300
2320
  files: new NodeSkillFiles(),
2301
2321
  lockfile: new JsonLockfile(path14.join(stateHome(process.env), "zion.json")),
2302
2322
  targets: skillTargets(os3.homedir()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zion",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",