@livespace/plugin-cli 0.1.1 → 0.2.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.
|
@@ -3,7 +3,7 @@ import { checkManifest } from "../manifest/check.js";
|
|
|
3
3
|
import { readManifestText, readPackageJson, serializeManifest, writeManifest, } from "../manifest/file.js";
|
|
4
4
|
import { prefillFrom } from "../manifest/package-json.js";
|
|
5
5
|
import { CATEGORIES, EXPECTED_LOCALES, LOCALES, MANIFEST_FILE, OBJECT_TYPES, REQUIRED_LOCALE, clientIdOf, } from "../manifest/schema.js";
|
|
6
|
-
import { isHexColor, isHttpsOrigin, isHttpsUrl, isId, isKeyList, isSemver,
|
|
6
|
+
import { isHexColor, isHttpsOrigin, isHttpsUrl, isId, isImageUrl, isKeyList, isSemver, splitList, } from "../ui/validators.js";
|
|
7
7
|
import { UsageError } from "./context.js";
|
|
8
8
|
import { createKeys, saveKeys } from "./keys.js";
|
|
9
9
|
import { loadManifest } from "./load.js";
|
|
@@ -161,15 +161,15 @@ export async function manifestInit(ctx) {
|
|
|
161
161
|
const categories = await askCategories(p);
|
|
162
162
|
const iconUrl = await p.text({
|
|
163
163
|
name: "icon-url",
|
|
164
|
-
message: "Icon URL (.svg, optional)?",
|
|
164
|
+
message: "Icon URL (.svg or .png, optional)?",
|
|
165
165
|
optional: true,
|
|
166
|
-
validate:
|
|
166
|
+
validate: isImageUrl,
|
|
167
167
|
});
|
|
168
168
|
const illustrationUrl = await p.text({
|
|
169
169
|
name: "illustration-url",
|
|
170
|
-
message: "Illustration URL (.svg, optional)?",
|
|
170
|
+
message: "Illustration URL (.svg or .png, optional)?",
|
|
171
171
|
optional: true,
|
|
172
|
-
validate:
|
|
172
|
+
validate: isImageUrl,
|
|
173
173
|
});
|
|
174
174
|
const accentColor = await p.text({
|
|
175
175
|
name: "accent-color",
|
|
@@ -268,7 +268,7 @@ const SETTERS = {
|
|
|
268
268
|
message: "Icon URL?",
|
|
269
269
|
initial: m.iconUrl,
|
|
270
270
|
optional: true,
|
|
271
|
-
validate:
|
|
271
|
+
validate: isImageUrl,
|
|
272
272
|
});
|
|
273
273
|
},
|
|
274
274
|
"illustration-url": async (p, m) => {
|
|
@@ -277,7 +277,7 @@ const SETTERS = {
|
|
|
277
277
|
message: "Illustration URL?",
|
|
278
278
|
initial: m.illustrationUrl,
|
|
279
279
|
optional: true,
|
|
280
|
-
validate:
|
|
280
|
+
validate: isImageUrl,
|
|
281
281
|
});
|
|
282
282
|
},
|
|
283
283
|
"accent-color": async (p, m) => {
|
package/dist/manifest/check.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { CATEGORIES, EXPECTED_LOCALES, FIELDS, ID_PATTERN, KEY_ALG, KEY_USES, MAX_KEYS_PER_USE, MIN_RSA_BITS, OBJECT_TYPES, REQUIRED_LOCALE, } from "./schema.js";
|
|
10
10
|
const SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
11
11
|
const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
12
|
-
const
|
|
12
|
+
const IMAGE = /\.(?:svg|png)(?:[?#].*)?$/i;
|
|
13
13
|
const RAW_HTML = /<\/?[a-zA-Z][^>]*>/;
|
|
14
14
|
const LINK = /\[[^\]]*\]\([^)]*\)|<https?:\/\/[^>]*>|https?:\/\/\S+/;
|
|
15
15
|
/** JWK members that only a private key has. One in a manifest is a leaked key. */
|
|
@@ -185,8 +185,8 @@ function checkAssets(m, failures, warnings) {
|
|
|
185
185
|
continue;
|
|
186
186
|
}
|
|
187
187
|
if ((key === "iconUrl" || key === "illustrationUrl") &&
|
|
188
|
-
!
|
|
189
|
-
failures.push(`"${key}" must be an .svg`);
|
|
188
|
+
!IMAGE.test(url.pathname)) {
|
|
189
|
+
failures.push(`"${key}" must be an .svg or .png`);
|
|
190
190
|
}
|
|
191
191
|
if (origin !== undefined && url.origin !== origin) {
|
|
192
192
|
warnings.push(`"${key}" is served from another origin than the plugin (${url.origin}) — fine if intended`);
|
package/dist/ui/validators.js
CHANGED
|
@@ -27,8 +27,10 @@ export const isHttpsOrigin = (v) => {
|
|
|
27
27
|
: `the origin alone, no path or trailing slash: ${url.origin}`;
|
|
28
28
|
};
|
|
29
29
|
export const isHttpsUrl = (v) => parse(v)?.protocol === "https:" ? undefined : "an https URL";
|
|
30
|
-
export const
|
|
31
|
-
(/\.svg(?:[?#].*)?$/i.test(parse(v)?.pathname ?? "")
|
|
30
|
+
export const isImageUrl = (v) => isHttpsUrl(v) ??
|
|
31
|
+
(/\.(?:svg|png)(?:[?#].*)?$/i.test(parse(v)?.pathname ?? "")
|
|
32
|
+
? undefined
|
|
33
|
+
: "an .svg or .png");
|
|
32
34
|
export const isHexColor = (v) => /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(v)
|
|
33
35
|
? undefined
|
|
34
36
|
: "a hex colour, e.g. #5546b8";
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livespace/plugin-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Sets up a Livespace plugin's catalog manifest, its key pairs included.",
|
|
5
5
|
"author": "LS FE team",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"livespace-plugin": "
|
|
9
|
+
"livespace-plugin": "dist/cli.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|