@swipt/cli 0.1.0-nightly.27 → 0.1.0-nightly.29

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/cli.mjs +25 -6
  2. package/package.json +2 -2
package/cli.mjs CHANGED
@@ -265,7 +265,15 @@ async function buildCommand(root) {
265
265
 
266
266
  const manifestEntry = /^(?:[^/]+\/)?manifest\.json$/;
267
267
 
268
- function sourceCommand(files, base, output, name) {
268
+ function sourceCommand(files, base, output, name, icon, image) {
269
+ let shownIcon;
270
+ if (icon !== undefined) {
271
+ const [color, ...symbol] = icon.split("/");
272
+ if (!color || !symbol.join("/")) {
273
+ throw new UsageError("--icon takes <color>/<symbol>, such as blue/sparkles");
274
+ }
275
+ shownIcon = { color, symbol: symbol.join("/") };
276
+ }
269
277
  let prefix;
270
278
  if (base !== undefined) {
271
279
  try {
@@ -298,7 +306,16 @@ function sourceCommand(files, base, output, name) {
298
306
  },
299
307
  });
300
308
  }
301
- const listed = `${JSON.stringify({ ...(name ? { name } : {}), swiplets: [...swiplets.keys()].sort().map(id => swiplets.get(id).entry) }, null, 2)}\n`;
309
+ const listed = `${JSON.stringify(
310
+ {
311
+ ...(name ? { name } : {}),
312
+ ...(shownIcon ? { icon: shownIcon } : {}),
313
+ ...(image ? { image: prefix ? new URL(image, prefix).href : image } : {}),
314
+ swiplets: [...swiplets.keys()].sort().map(id => swiplets.get(id).entry),
315
+ },
316
+ null,
317
+ 2,
318
+ )}\n`;
302
319
  if (output) {
303
320
  fs.writeFileSync(output, listed);
304
321
  } else {
@@ -400,11 +417,11 @@ function createCommand(directory) {
400
417
 
401
418
  const usage = `usage: swiplet create <directory>
402
419
  swiplet build
403
- swiplet source [--name <name>] [--url <address>] [--output <file>] <swiplet>...
420
+ swiplet source [--name <name>] [--icon <color>/<symbol>] [--image <file>] [--url <address>] [--output <file>] <swiplet>...
404
421
 
405
422
  create make a swiplet project in a new or empty directory
406
423
  build bundle the project in this directory into dist/<swiplet.id>.swiplet
407
- source list built swiplets in a source; without --url they are expected next to it
424
+ source list built swiplets in a source; files are expected next to it unless --url says where they are
408
425
 
409
426
  Type-check a project with its "check" script.`;
410
427
 
@@ -415,7 +432,9 @@ class UsageError extends Error {}
415
432
  try {
416
433
  let parsed;
417
434
  try {
418
- parsed = parseArgs({ allowPositionals: true, options: { help: { type: "boolean", short: "h" }, name: { type: "string" }, url: { type: "string" }, output: { type: "string" } } });
435
+ parsed = parseArgs({ allowPositionals: true, options: {
436
+ help: { type: "boolean", short: "h" }, name: { type: "string" }, icon: { type: "string" }, image: { type: "string" }, url: { type: "string" }, output: { type: "string" },
437
+ } });
419
438
  } catch (error) {
420
439
  throw new UsageError(error.message);
421
440
  }
@@ -433,7 +452,7 @@ try {
433
452
  } else if (command === "create") {
434
453
  createCommand(rest[0]);
435
454
  } else if (command === "source") {
436
- sourceCommand(rest, parsed.values.url, parsed.values.output, parsed.values.name);
455
+ sourceCommand(rest, parsed.values.url, parsed.values.output, parsed.values.name, parsed.values.icon, parsed.values.image);
437
456
  } else {
438
457
  await buildCommand(process.cwd());
439
458
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swipt/cli",
3
- "version": "0.1.0-nightly.27",
3
+ "version": "0.1.0-nightly.29",
4
4
  "license": "GPL-3.0-or-later",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,6 +21,6 @@
21
21
  "esbuild": "^0.28.2"
22
22
  },
23
23
  "peerDependencies": {
24
- "@swipt/api": "0.1.0-nightly.27"
24
+ "@swipt/api": "0.1.0-nightly.29"
25
25
  }
26
26
  }