@quadient/skillshare 1.10.4 → 1.11.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/README.md +13 -1
- package/dist/help.js +5 -2
- package/dist/index.js +6 -1
- package/dist/pages-secrets.js +76 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ permissions, Microsoft session lifetime and file-tool differences in the hosted
|
|
|
117
117
|
Starting with 1.9.0:
|
|
118
118
|
|
|
119
119
|
- `agents listen` and `agents status` run Claude Code and Codex sessions from Skillshare on this computer (see [Connected agents](#connected-agents)); `--sandbox` keeps them read-only.
|
|
120
|
-
- Commands print readable text. Scripts that parsed JSON from `whoami`, `list`, `show`, `upload`, `pages list|show|runtime|upload` or `teams status|test|upload` must add `--json`; with `--json` progress goes to stderr and stdout contains only JSON.
|
|
120
|
+
- Commands print readable text. Scripts that parsed JSON from `whoami`, `list`, `show`, `upload`, `pages list|show|runtime|upload|secrets` or `teams status|test|upload` must add `--json`; with `--json` progress goes to stderr and stdout contains only JSON.
|
|
121
121
|
- `show` accepts a skill name as well as an id.
|
|
122
122
|
- `pages upload` refuses build output folder names such as `dist` or `build` without `--slug`, says whether it creates or replaces a page, refuses pages owned by someone else unless you are an admin, and prints the page URL.
|
|
123
123
|
|
|
@@ -329,6 +329,18 @@ them and build frontend assets before uploading. Inspect process status and logs
|
|
|
329
329
|
with `skillshare pages runtime <slug>`. Pages are served below `/p/<slug>/`, so use
|
|
330
330
|
that base path when building assets. Runtime data survives content replacement.
|
|
331
331
|
|
|
332
|
+
Manage the write-only secrets an application reads through `SKILLSHARE_SECRETS`
|
|
333
|
+
(page owner or admin only). `set` reads the value from piped stdin or a masked
|
|
334
|
+
prompt, so it never appears in shell history; the running app restarts to pick
|
|
335
|
+
up changes:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
skillshare pages secrets list my-app
|
|
339
|
+
skillshare pages secrets set my-app API_TOKEN
|
|
340
|
+
printf %s "$TOKEN" | skillshare pages secrets set my-app API_TOKEN
|
|
341
|
+
skillshare pages secrets delete my-app API_TOKEN
|
|
342
|
+
```
|
|
343
|
+
|
|
332
344
|
## Local Pages development (1.6.0+)
|
|
333
345
|
|
|
334
346
|
Run a celld application without a SkillShare server, repository checkout, Docker,
|
package/dist/help.js
CHANGED
|
@@ -87,11 +87,14 @@ export const COMMANDS = [
|
|
|
87
87
|
'pages show <slug> [--json]',
|
|
88
88
|
'pages runtime <slug> [--json]',
|
|
89
89
|
'pages upload <directory> [--slug <slug>] [--json]',
|
|
90
|
+
'pages secrets list <slug> [--json]',
|
|
91
|
+
'pages secrets set <slug> <name> [--json]',
|
|
92
|
+
'pages secrets delete <slug> <name> [--json]',
|
|
90
93
|
'pages dev [directory] [--slug <slug>] [--port <port>] [--build <command> --watch-dir <sources>]',
|
|
91
94
|
' [--celld <executable>] [--user-id <id>] [--user-name <name>] [--user-email <email>]',
|
|
92
95
|
],
|
|
93
|
-
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are an admin.',
|
|
94
|
-
examples: ['skillshare pages upload ./site --slug release-notes', 'skillshare pages dev . --slug my-app'],
|
|
96
|
+
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are an admin. pages secrets manages the write-only secrets an app reads through SKILLSHARE_SECRETS (owner or admin only, at most 32 per page, 16 KiB each); set reads the value from piped stdin or a masked prompt, never from the command line.',
|
|
97
|
+
examples: ['skillshare pages upload ./site --slug release-notes', 'skillshare pages dev . --slug my-app', 'skillshare pages secrets set my-app API_TOKEN', 'printf %s "$TOKEN" | skillshare pages secrets set my-app API_TOKEN'],
|
|
95
98
|
flags: ['slug', 'json'],
|
|
96
99
|
},
|
|
97
100
|
{
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { inspectInstallTarget, installFilesAtomically } from './install-files.js
|
|
|
7
7
|
import { preparePageFiles, resolvePageSlug } from './pages.js';
|
|
8
8
|
import { formatByteSize, formatDateTime, pageUrl, plural, renderPageDetail, renderPageList, renderPageRuntime, renderSkillDetail, renderSkillList, renderSkillVersion, renderUser, } from './output.js';
|
|
9
9
|
import { runPageDev } from './pages-dev.js';
|
|
10
|
+
import { runPageSecretsCommand } from './pages-secrets.js';
|
|
10
11
|
import { createServer } from 'node:http';
|
|
11
12
|
import { createHash, randomBytes } from 'node:crypto';
|
|
12
13
|
import { spawn } from 'node:child_process';
|
|
@@ -378,7 +379,11 @@ async function main() {
|
|
|
378
379
|
}
|
|
379
380
|
return;
|
|
380
381
|
}
|
|
381
|
-
|
|
382
|
+
if (action === 'secrets') {
|
|
383
|
+
await runPageSecretsCommand(client, options.positionals.slice(1), print);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
throw new Error(`Unknown pages command '${action}'. Use list, show, runtime, upload, or secrets.`);
|
|
382
387
|
}
|
|
383
388
|
}
|
|
384
389
|
return;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isCancel, password } from '@clack/prompts';
|
|
2
|
+
import { formatDateTime, formatTable } from './output.js';
|
|
3
|
+
const MAX_VALUE_BYTES = 16 * 1024;
|
|
4
|
+
export function renderPageSecrets(slug, secrets) {
|
|
5
|
+
if (secrets.length === 0)
|
|
6
|
+
return `/p/${slug}/ has no secrets.`;
|
|
7
|
+
return formatTable(['NAME', 'UPDATED', 'BY USER'], secrets.map((secret) => [
|
|
8
|
+
secret.name,
|
|
9
|
+
formatDateTime(secret.updated),
|
|
10
|
+
String(secret.updatedBy),
|
|
11
|
+
]));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Manages a Page's write-only secrets. Values are read from stdin when it is piped, or from a
|
|
15
|
+
* masked prompt, so they never land in shell history or the process list.
|
|
16
|
+
*/
|
|
17
|
+
export async function runPageSecretsCommand(client, positionals, print, readValue = readSecretValue) {
|
|
18
|
+
const [action = 'list', slug, name] = positionals;
|
|
19
|
+
if (!['list', 'set', 'delete'].includes(action)) {
|
|
20
|
+
throw new Error(`Unknown pages secrets command '${action}'. Use list, set, or delete.`);
|
|
21
|
+
}
|
|
22
|
+
if (!slug)
|
|
23
|
+
throw new Error(`pages secrets ${action} requires <slug>`);
|
|
24
|
+
const path = `/api/pages/${encodeURIComponent(slug)}/secrets`;
|
|
25
|
+
if (action === 'list') {
|
|
26
|
+
const { secrets } = await expectSecrets(slug, await client.request(path, { method: 'GET' }));
|
|
27
|
+
print(secrets, () => renderPageSecrets(slug, secrets));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!name)
|
|
31
|
+
throw new Error(`pages secrets ${action} requires <slug> <name>`);
|
|
32
|
+
if (action === 'delete') {
|
|
33
|
+
const { secrets } = await expectSecrets(slug, await client.request(`${path}?name=${encodeURIComponent(name)}`, { method: 'DELETE' }), name);
|
|
34
|
+
print(secrets, () => `Deleted ${name} from /p/${slug}/. A running app restarts to pick up the change.`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const value = await readValue();
|
|
38
|
+
if (!value)
|
|
39
|
+
throw new Error('The secret value is empty.');
|
|
40
|
+
if (Buffer.byteLength(value, 'utf8') > MAX_VALUE_BYTES)
|
|
41
|
+
throw new Error('Secret values are limited to 16384 UTF-8 bytes.');
|
|
42
|
+
const { secrets } = await expectSecrets(slug, await client.request(path, {
|
|
43
|
+
method: 'PUT',
|
|
44
|
+
headers: { 'Content-Type': 'application/json' },
|
|
45
|
+
body: JSON.stringify({ name, value }),
|
|
46
|
+
}));
|
|
47
|
+
print(secrets, () => `Saved ${name} for /p/${slug}/. A running app restarts to pick it up.`);
|
|
48
|
+
}
|
|
49
|
+
async function expectSecrets(slug, response, name) {
|
|
50
|
+
if (response.ok)
|
|
51
|
+
return await response.json();
|
|
52
|
+
if (response.status === 403)
|
|
53
|
+
throw new Error(`Only the owner of /p/${slug}/ or an administrator can manage its secrets.`);
|
|
54
|
+
if (response.status === 404) {
|
|
55
|
+
throw new Error(name ? `Page /p/${slug}/ or its secret ${name} was not found.` : `Page /p/${slug}/ was not found.`);
|
|
56
|
+
}
|
|
57
|
+
let error = {};
|
|
58
|
+
try {
|
|
59
|
+
error = await response.json();
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
throw new Error(error.error ?? `Skillshare returned HTTP ${response.status} for the Page secrets.`);
|
|
63
|
+
}
|
|
64
|
+
async function readSecretValue() {
|
|
65
|
+
if (!process.stdin.isTTY) {
|
|
66
|
+
const chunks = [];
|
|
67
|
+
for await (const chunk of process.stdin)
|
|
68
|
+
chunks.push(Buffer.from(chunk));
|
|
69
|
+
// `echo value |` adds a line ending that is not part of the secret.
|
|
70
|
+
return Buffer.concat(chunks).toString('utf8').replace(/\r?\n$/, '');
|
|
71
|
+
}
|
|
72
|
+
const value = await password({ message: 'Secret value', mask: '*' });
|
|
73
|
+
if (isCancel(value))
|
|
74
|
+
throw new Error('Cancelled.');
|
|
75
|
+
return value;
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadient/skillshare",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Skillshare CLI for installing and publishing Quadient skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
17
17
|
"start": "node ./dist/index.js",
|
|
18
18
|
"prepublishOnly": "npm run build",
|
|
19
|
-
"test": "tsx --test cli-args.test.ts install-files.test.ts output.test.ts pages.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts agents.test.ts agents-update.test.ts"
|
|
19
|
+
"test": "tsx --test cli-args.test.ts install-files.test.ts output.test.ts pages.test.ts pages-secrets.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts agents.test.ts agents-update.test.ts"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|