@artis-lab/cli 0.15.0 → 0.17.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.
@@ -1,3 +1,8 @@
1
+ import {
2
+ VerifyUnavailableError,
3
+ formatVerifyReport,
4
+ verifyFiles
5
+ } from "./chunk-I5P3FLKO.js";
1
6
  import {
2
7
  artifactShortId,
3
8
  batchDocuments,
@@ -38,18 +43,13 @@ import {
38
43
  uploadAsset,
39
44
  watchArtifact,
40
45
  whoami
41
- } from "./chunk-JPCT7RRK.js";
46
+ } from "./chunk-XTAKEL34.js";
42
47
  import {
43
48
  installSkill,
44
49
  listSkillHarnesses,
45
50
  printHarnessTable,
46
51
  printInstallResults
47
52
  } from "./chunk-2LRPXCLL.js";
48
- import {
49
- VerifyUnavailableError,
50
- formatVerifyReport,
51
- verifyFiles
52
- } from "./chunk-QZFIUZXT.js";
53
53
  import {
54
54
  artisCliVersion
55
55
  } from "./chunk-IZYFOV2K.js";
@@ -247,7 +247,7 @@ function command(spec) {
247
247
  ...Object.fromEntries(
248
248
  [...spec.flags, ...removedFlags].map((name) => [
249
249
  name,
250
- flagCatalog[name]
250
+ spec.removed?.includes(name) ? refused(name) : flagCatalog[name]
251
251
  ])
252
252
  )
253
253
  },
@@ -282,7 +282,7 @@ function command(spec) {
282
282
  route,
283
283
  usage: spec.usage,
284
284
  brief: spec.brief,
285
- flags: spec.flags,
285
+ flags: spec.flags.filter((name) => !spec.removed?.includes(name)),
286
286
  hidden: spec.hidden ?? false,
287
287
  command: command2
288
288
  };
@@ -477,8 +477,14 @@ ${type.references.map((path) => ` ${path}`).join("\n")}`
477
477
  "capabilities",
478
478
  "reload-pages"
479
479
  ],
480
+ removed: ["capabilities"],
480
481
  args: [artifactArg, optionalArg("file", "Edited HTML file.")],
481
482
  async run(flags, artifact, file) {
483
+ if (flags.capabilities !== void 0) {
484
+ throw usageError(
485
+ '--capabilities was removed from revise: a revision changes only content. Set them with "artis capabilities set <artifact> <json|file>": before revising to add one the new content uses, after to drop one.'
486
+ );
487
+ }
482
488
  const result = await onConflict(
483
489
  () => reviseArtifact({
484
490
  artifact,
@@ -488,7 +494,6 @@ ${type.references.map((path) => ` ${path}`).join("\n")}`
488
494
  base: flags.base,
489
495
  type: flags.type,
490
496
  author: flags.author,
491
- capabilities: flags.capabilities,
492
497
  reloadPages: flags["reload-pages"]
493
498
  }),
494
499
  () => reviseConflictActions(artifact)
@@ -545,7 +550,7 @@ ${type.references.map((path) => ` ${path}`).join("\n")}`
545
550
  type: flags.type,
546
551
  revision: flags.revision
547
552
  });
548
- const title = `Verified ${job.label}${job.type ? ` (type ${job.type})` : ""}`;
553
+ const title = `Verified ${job.label}${job.type ? ` (type ${job.type.name})` : ""}`;
549
554
  let report;
550
555
  try {
551
556
  report = await verifyFiles(job.files, {
@@ -554,16 +559,7 @@ ${type.references.map((path) => ` ${path}`).join("\n")}`
554
559
  });
555
560
  } catch (error) {
556
561
  if (error instanceof VerifyUnavailableError) {
557
- if (error.partial && !flags.json) {
558
- console.log(title);
559
- for (const line of formatVerifyReport(error.partial)) {
560
- console.log(line);
561
- }
562
- }
563
- throw new CliError(
564
- error.partial ? `Rendering checks did not run: ${error.message}` : error.message,
565
- exitCodes.error
566
- );
562
+ throw new CliError(error.message, exitCodes.error);
567
563
  }
568
564
  throw error;
569
565
  }
@@ -3,7 +3,7 @@ import {
3
3
  commandTree,
4
4
  getCliHelp,
5
5
  valueFlags
6
- } from "./chunk-VBJGJXYL.js";
6
+ } from "./chunk-P4O6TXMP.js";
7
7
  import {
8
8
  recoveryActions,
9
9
  renderNextActions
@@ -9,9 +9,6 @@ import {
9
9
  getRememberedBase,
10
10
  rememberBase
11
11
  } from "./chunk-JYMG2Y6C.js";
12
- import {
13
- verifyTypes
14
- } from "./chunk-QZFIUZXT.js";
15
12
  import {
16
13
  ARTIS_DEFAULT_HOST,
17
14
  findProfileForHost,
@@ -27,7 +24,10 @@ import {
27
24
  changedFiles,
28
25
  readFilesDir,
29
26
  writeFilesDir
30
- } from "./chunk-43EXTJSU.js";
27
+ } from "./chunk-FSJVBXCW.js";
28
+ import {
29
+ isTypePackageName
30
+ } from "./chunk-4O5BCFCD.js";
31
31
  import {
32
32
  CliError,
33
33
  exitCodeForResponse,
@@ -909,13 +909,52 @@ function parseVerifyType(value) {
909
909
  if (type === void 0 || type === "html") {
910
910
  return void 0;
911
911
  }
912
- if (!verifyTypes.includes(type)) {
912
+ if (!isTypePackageName(type)) {
913
913
  throw usageError(
914
- `Unknown type "${type}". Expected one of: ${verifyTypes.join(", ")}.`
914
+ `"${type}" is not a type name: 1-40 lower-case letters, digits and -, starting with a letter.`
915
915
  );
916
916
  }
917
917
  return type;
918
918
  }
919
+ async function readVerifyTypePackage(input, name) {
920
+ let files;
921
+ try {
922
+ ({
923
+ type: { package: files }
924
+ } = await publicCall(input, "GET /api/types/{name}", {
925
+ params: { name }
926
+ }));
927
+ } catch (error) {
928
+ if (error instanceof CliError && error.exitCode === exitCodes.notFound) {
929
+ throw new CliError(
930
+ `The type ${name} is not installed on ${resolveBaseUrl(input, await readCliConfig())}. List the installed types with: artis types`,
931
+ exitCodes.notFound
932
+ );
933
+ }
934
+ throw error;
935
+ }
936
+ const read = async (path) => (await readTypeReference({ ...input, name, path })).content;
937
+ if (!files || typeof files.entry !== "string") {
938
+ throw new CliError(
939
+ `${resolveBaseUrl(input, await readCliConfig())} does not serve the ${name} package to artis verify: the server needs updating.`,
940
+ exitCodes.error
941
+ );
942
+ }
943
+ const { entry, runtime, check, googleFonts, layout } = files;
944
+ const [entryText, runtimeText, checkText] = await Promise.all([
945
+ read(entry),
946
+ read(runtime),
947
+ check ? read(check) : void 0
948
+ ]);
949
+ return {
950
+ name,
951
+ entry: entryText,
952
+ runtime: runtimeText,
953
+ ...checkText === void 0 ? {} : { check: checkText },
954
+ googleFonts,
955
+ ...layout ? { layout } : {}
956
+ };
957
+ }
919
958
  async function prepareVerify(input) {
920
959
  const { target, root } = input;
921
960
  if (!target && !root) {
@@ -924,7 +963,12 @@ async function prepareVerify(input) {
924
963
  );
925
964
  }
926
965
  if (root) {
927
- return prepareFilesDirVerify(input, root);
966
+ const job = await prepareFilesDirVerify(input, root);
967
+ return job.typeName ? {
968
+ files: job.files,
969
+ label: job.label,
970
+ type: await readVerifyTypePackage(input, job.typeName)
971
+ } : { files: job.files, label: job.label };
928
972
  }
929
973
  const reference = target;
930
974
  let type = parseVerifyType(input.type);
@@ -978,17 +1022,16 @@ async function prepareVerify(input) {
978
1022
  (revision) => revision.id === read.listed.revisionId
979
1023
  )?.type;
980
1024
  if (declared !== void 0 && declared !== "html") {
981
- if (!verifyTypes.includes(declared)) {
982
- throw new CliError(
983
- `${label} is of type ${declared}, which this CLI cannot verify. Update the CLI.`,
984
- exitCodes.error
985
- );
986
- }
987
1025
  type = declared;
988
1026
  }
989
1027
  }
990
1028
  }
991
- return { files, label, type, loadAsset };
1029
+ return {
1030
+ files,
1031
+ label,
1032
+ ...type ? { type: await readVerifyTypePackage(input, type) } : {},
1033
+ loadAsset
1034
+ };
992
1035
  }
993
1036
  async function prepareFilesDirVerify(input, root) {
994
1037
  if (input.target) {
@@ -1004,7 +1047,7 @@ async function prepareFilesDirVerify(input, root) {
1004
1047
  `${root} has no index.html: an html artifact is that one file. For a deck, add --type slides.`
1005
1048
  );
1006
1049
  }
1007
- return { files, label: root, type };
1050
+ return { files, label: root, ...type ? { typeName: type } : {} };
1008
1051
  }
1009
1052
  async function listArtifacts(input) {
1010
1053
  const credentials = await resolveCredentials(input);
@@ -1140,7 +1183,6 @@ async function reviseArtifact(input) {
1140
1183
  if (!summary) {
1141
1184
  throw usageError("Missing --summary for revision.");
1142
1185
  }
1143
- const capabilities = await parseCapabilitiesFlag(input.capabilities);
1144
1186
  const type = parseTypeFlag(input.type);
1145
1187
  const credentials = await resolveCredentials(input);
1146
1188
  const explicitBase = input.base;
@@ -1150,7 +1192,6 @@ async function reviseArtifact(input) {
1150
1192
  baseRevisionId,
1151
1193
  source: "cli",
1152
1194
  summary,
1153
- capabilities,
1154
1195
  reloadPages: input.reloadPages || void 0,
1155
1196
  type
1156
1197
  };
package/src/lib/cli.js CHANGED
@@ -40,19 +40,19 @@ import {
40
40
  uploadAsset,
41
41
  watchArtifact,
42
42
  whoami
43
- } from "./chunk-JPCT7RRK.js";
43
+ } from "./chunk-XTAKEL34.js";
44
44
  import "./chunk-43WVFZLO.js";
45
45
  import "./chunk-JYMG2Y6C.js";
46
46
  import {
47
47
  installSkill,
48
48
  listSkillHarnesses
49
49
  } from "./chunk-2LRPXCLL.js";
50
- import "./chunk-QZFIUZXT.js";
51
50
  import {
52
51
  artisCliVersion
53
52
  } from "./chunk-IZYFOV2K.js";
54
53
  import "./chunk-46DMRA3V.js";
55
- import "./chunk-43EXTJSU.js";
54
+ import "./chunk-FSJVBXCW.js";
55
+ import "./chunk-4O5BCFCD.js";
56
56
  import "./chunk-HUWOFEEU.js";
57
57
  export {
58
58
  artifactIdArg,
@@ -4,15 +4,16 @@ import {
4
4
  commandTree,
5
5
  getCliHelp,
6
6
  valueFlags
7
- } from "./chunk-VBJGJXYL.js";
8
- import "./chunk-JPCT7RRK.js";
7
+ } from "./chunk-P4O6TXMP.js";
8
+ import "./chunk-I5P3FLKO.js";
9
+ import "./chunk-XTAKEL34.js";
9
10
  import "./chunk-43WVFZLO.js";
10
11
  import "./chunk-JYMG2Y6C.js";
11
12
  import "./chunk-2LRPXCLL.js";
12
- import "./chunk-QZFIUZXT.js";
13
13
  import "./chunk-IZYFOV2K.js";
14
14
  import "./chunk-46DMRA3V.js";
15
- import "./chunk-43EXTJSU.js";
15
+ import "./chunk-FSJVBXCW.js";
16
+ import "./chunk-4O5BCFCD.js";
16
17
  import "./chunk-IKQ5U3DH.js";
17
18
  import "./chunk-HUWOFEEU.js";
18
19
  export {
package/src/lib/files.js CHANGED
@@ -3,7 +3,8 @@ import {
3
3
  readFilesDir,
4
4
  sha256Hex,
5
5
  writeFilesDir
6
- } from "./chunk-43EXTJSU.js";
6
+ } from "./chunk-FSJVBXCW.js";
7
+ import "./chunk-4O5BCFCD.js";
7
8
  import "./chunk-HUWOFEEU.js";
8
9
  export {
9
10
  changedFiles,
package/src/lib/verify.js CHANGED
@@ -11,9 +11,9 @@ import {
11
11
  verifyFiles,
12
12
  verifyHtml,
13
13
  verifyThemes,
14
- verifyTypes,
15
14
  verifyWidths
16
- } from "./chunk-QZFIUZXT.js";
15
+ } from "./chunk-I5P3FLKO.js";
16
+ import "./chunk-4O5BCFCD.js";
17
17
  export {
18
18
  GOOGLE_FONTS_FONT_ORIGIN,
19
19
  GOOGLE_FONTS_STYLE_ORIGIN,
@@ -27,6 +27,5 @@ export {
27
27
  verifyFiles,
28
28
  verifyHtml,
29
29
  verifyThemes,
30
- verifyTypes,
31
30
  verifyWidths
32
31
  };