@swipt/cli 0.1.0-nightly.29 → 0.1.0-nightly.31
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/cli.mjs +15 -4
- 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, icon, image) {
|
|
268
|
+
function sourceCommand(files, base, output, name, localizedNames, icon, image) {
|
|
269
|
+
const names = {};
|
|
270
|
+
for (const entry of localizedNames ?? []) {
|
|
271
|
+
const [language, ...rest] = entry.split("=");
|
|
272
|
+
if (!language || rest.length === 0 || !rest.join("=")) {
|
|
273
|
+
throw new UsageError("--localized-name takes <language>=<name>, such as zh-Hans=示例");
|
|
274
|
+
}
|
|
275
|
+
names[language] = rest.join("=");
|
|
276
|
+
}
|
|
269
277
|
let shownIcon;
|
|
270
278
|
if (icon !== undefined) {
|
|
271
279
|
const [color, ...symbol] = icon.split("/");
|
|
@@ -309,6 +317,7 @@ function sourceCommand(files, base, output, name, icon, image) {
|
|
|
309
317
|
const listed = `${JSON.stringify(
|
|
310
318
|
{
|
|
311
319
|
...(name ? { name } : {}),
|
|
320
|
+
...(Object.keys(names).length > 0 ? { localizedNames: names } : {}),
|
|
312
321
|
...(shownIcon ? { icon: shownIcon } : {}),
|
|
313
322
|
...(image ? { image: prefix ? new URL(image, prefix).href : image } : {}),
|
|
314
323
|
swiplets: [...swiplets.keys()].sort().map(id => swiplets.get(id).entry),
|
|
@@ -417,7 +426,8 @@ function createCommand(directory) {
|
|
|
417
426
|
|
|
418
427
|
const usage = `usage: swiplet create <directory>
|
|
419
428
|
swiplet build
|
|
420
|
-
swiplet source [--name <name>] [--
|
|
429
|
+
swiplet source [--name <name>] [--localized-name <language>=<name>]... [--icon <color>/<symbol>] [--image <file>]
|
|
430
|
+
[--url <address>] [--output <file>] <swiplet>...
|
|
421
431
|
|
|
422
432
|
create make a swiplet project in a new or empty directory
|
|
423
433
|
build bundle the project in this directory into dist/<swiplet.id>.swiplet
|
|
@@ -433,7 +443,8 @@ try {
|
|
|
433
443
|
let parsed;
|
|
434
444
|
try {
|
|
435
445
|
parsed = parseArgs({ allowPositionals: true, options: {
|
|
436
|
-
help: { type: "boolean", short: "h" }, name: { type: "string" },
|
|
446
|
+
help: { type: "boolean", short: "h" }, name: { type: "string" }, "localized-name": { type: "string", multiple: true }, icon: { type: "string" },
|
|
447
|
+
image: { type: "string" }, url: { type: "string" }, output: { type: "string" },
|
|
437
448
|
} });
|
|
438
449
|
} catch (error) {
|
|
439
450
|
throw new UsageError(error.message);
|
|
@@ -452,7 +463,7 @@ try {
|
|
|
452
463
|
} else if (command === "create") {
|
|
453
464
|
createCommand(rest[0]);
|
|
454
465
|
} else if (command === "source") {
|
|
455
|
-
sourceCommand(rest, parsed.values.url, parsed.values.output, parsed.values.name, parsed.values.icon, parsed.values.image);
|
|
466
|
+
sourceCommand(rest, parsed.values.url, parsed.values.output, parsed.values.name, parsed.values["localized-name"], parsed.values.icon, parsed.values.image);
|
|
456
467
|
} else {
|
|
457
468
|
await buildCommand(process.cwd());
|
|
458
469
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swipt/cli",
|
|
3
|
-
"version": "0.1.0-nightly.
|
|
3
|
+
"version": "0.1.0-nightly.31",
|
|
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.
|
|
24
|
+
"@swipt/api": "0.1.0-nightly.31"
|
|
25
25
|
}
|
|
26
26
|
}
|