@livespace/plugin-cli 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +69 -2
- package/dist/cli.js +182 -0
- package/dist/commands/client-id.js +12 -0
- package/dist/commands/context.js +7 -0
- package/dist/commands/keys.js +152 -0
- package/dist/commands/load.js +25 -0
- package/dist/commands/manifest.js +378 -0
- package/dist/keys/files.js +48 -0
- package/dist/keys/generate.js +50 -0
- package/dist/keys/keyset.js +48 -0
- package/dist/manifest/check.js +258 -0
- package/dist/manifest/file.js +59 -0
- package/dist/manifest/package-json.js +49 -0
- package/dist/manifest/schema.js +77 -0
- package/dist/ui/clack.js +50 -0
- package/dist/ui/output.js +45 -0
- package/dist/ui/prompter.js +140 -0
- package/dist/ui/validators.js +45 -0
- package/package.json +39 -5
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks for one typed value, so a prompt can say what's wrong as it's entered. The whole manifest
|
|
3
|
+
* is still checked by `checkManifest` before anything is written; these only fail faster.
|
|
4
|
+
*/
|
|
5
|
+
import { ID_PATTERN } from "../manifest/schema.js";
|
|
6
|
+
const parse = (value) => {
|
|
7
|
+
try {
|
|
8
|
+
return new URL(value);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const isId = (v) => ID_PATTERN.test(v)
|
|
15
|
+
? undefined
|
|
16
|
+
: 'lowercase letters, digits, ".", "_" or "-", starting with a letter or digit';
|
|
17
|
+
export const isSemver = (v) => /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(v)
|
|
18
|
+
? undefined
|
|
19
|
+
: "semver, e.g. 0.1.0";
|
|
20
|
+
export const isHttpsOrigin = (v) => {
|
|
21
|
+
const url = parse(v);
|
|
22
|
+
if (url === null || url.protocol !== "https:") {
|
|
23
|
+
return "an https origin, e.g. https://plugin.example.com";
|
|
24
|
+
}
|
|
25
|
+
return url.origin === v
|
|
26
|
+
? undefined
|
|
27
|
+
: `the origin alone, no path or trailing slash: ${url.origin}`;
|
|
28
|
+
};
|
|
29
|
+
export const isHttpsUrl = (v) => parse(v)?.protocol === "https:" ? undefined : "an https URL";
|
|
30
|
+
export const isSvgUrl = (v) => isHttpsUrl(v) ??
|
|
31
|
+
(/\.svg(?:[?#].*)?$/i.test(parse(v)?.pathname ?? "") ? undefined : "an .svg");
|
|
32
|
+
export const isHexColor = (v) => /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(v)
|
|
33
|
+
? undefined
|
|
34
|
+
: "a hex colour, e.g. #5546b8";
|
|
35
|
+
export const isKeyList = (v) => {
|
|
36
|
+
const keys = splitList(v);
|
|
37
|
+
if (keys.length === 0) {
|
|
38
|
+
return "at least one key, e.g. apiToken";
|
|
39
|
+
}
|
|
40
|
+
return new Set(keys).size === keys.length ? undefined : "each key once";
|
|
41
|
+
};
|
|
42
|
+
export const splitList = (v) => v
|
|
43
|
+
.split(",")
|
|
44
|
+
.map((item) => item.trim())
|
|
45
|
+
.filter((item) => item !== "");
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@livespace/plugin-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Sets up a Livespace plugin's catalog manifest, its key pairs included.",
|
|
5
|
+
"author": "LS FE team",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"livespace-plugin": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": ["dist"],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20.12"
|
|
14
|
+
},
|
|
15
|
+
"keywords": ["livespace", "plugin", "manifest", "cli"],
|
|
16
|
+
"homepage": "https://www.npmjs.com/package/@livespace/plugin-cli",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://gitlab.com/livespace-it/plugin-platform/sdk-client.git",
|
|
20
|
+
"directory": "packages/cli"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
27
|
+
"lint:types": "tsc --noEmit",
|
|
28
|
+
"prepublishOnly": "yarn test",
|
|
29
|
+
"test": "yarn build && vitest run --watch false",
|
|
30
|
+
"test:watch": "vitest"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@clack/prompts": "1.8.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "22.15.21",
|
|
37
|
+
"typescript": "5.2.2",
|
|
38
|
+
"vitest": "3.2.4"
|
|
39
|
+
}
|
|
40
|
+
}
|