gooseworks 0.2.4 → 0.2.5
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/dist/auth/oauth-server.d.ts.map +1 -1
- package/dist/auth/oauth-server.js +27 -19
- package/dist/auth/oauth-server.js.map +1 -1
- package/dist/commands/formats.d.ts +3 -0
- package/dist/commands/formats.d.ts.map +1 -0
- package/dist/commands/formats.js +155 -0
- package/dist/commands/formats.js.map +1 -0
- package/dist/commands/graphics/get-flow.d.ts +30 -0
- package/dist/commands/graphics/get-flow.d.ts.map +1 -0
- package/dist/commands/graphics/get-flow.js +212 -0
- package/dist/commands/graphics/get-flow.js.map +1 -0
- package/dist/commands/graphics/publish-flow.d.ts +28 -0
- package/dist/commands/graphics/publish-flow.d.ts.map +1 -0
- package/dist/commands/graphics/publish-flow.js +178 -0
- package/dist/commands/graphics/publish-flow.js.map +1 -0
- package/dist/commands/graphics/shared.d.ts +48 -0
- package/dist/commands/graphics/shared.d.ts.map +1 -0
- package/dist/commands/graphics/shared.js +181 -0
- package/dist/commands/graphics/shared.js.map +1 -0
- package/dist/commands/styles.d.ts +3 -0
- package/dist/commands/styles.d.ts.map +1 -0
- package/dist/commands/styles.js +157 -0
- package/dist/commands/styles.js.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/graphics-api.d.ts +106 -0
- package/dist/lib/graphics-api.d.ts.map +1 -0
- package/dist/lib/graphics-api.js +289 -0
- package/dist/lib/graphics-api.js.map +1 -0
- package/dist/lib/graphics-cache.d.ts +31 -0
- package/dist/lib/graphics-cache.d.ts.map +1 -0
- package/dist/lib/graphics-cache.js +126 -0
- package/dist/lib/graphics-cache.js.map +1 -0
- package/dist/lib/graphics-manifest.d.ts +96 -0
- package/dist/lib/graphics-manifest.d.ts.map +1 -0
- package/dist/lib/graphics-manifest.js +289 -0
- package/dist/lib/graphics-manifest.js.map +1 -0
- package/dist/skills/fetcher.d.ts +18 -0
- package/dist/skills/fetcher.d.ts.map +1 -0
- package/dist/skills/fetcher.js +118 -0
- package/dist/skills/fetcher.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-server.d.ts","sourceRoot":"","sources":["../../src/auth/oauth-server.ts"],"names":[],"mappings":"AAUA,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"oauth-server.d.ts","sourceRoot":"","sources":["../../src/auth/oauth-server.ts"],"names":[],"mappings":"AAUA,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA6HxE"}
|
|
@@ -70,12 +70,6 @@ async function runOAuthFlow(apiBase) {
|
|
|
70
70
|
res.end('<html><body><h2>Authentication failed: missing parameters</h2><p>You can close this window.</p></body></html>');
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
// Send response with Connection: close so browser doesn't keep-alive
|
|
74
|
-
res.writeHead(200, {
|
|
75
|
-
'Content-Type': 'text/html',
|
|
76
|
-
'Connection': 'close',
|
|
77
|
-
});
|
|
78
|
-
res.end('<html><body><h2>GooseWorks CLI authenticated!</h2><p>You can close this window and return to your terminal.</p></body></html>');
|
|
79
73
|
const creds = {
|
|
80
74
|
api_key: token,
|
|
81
75
|
email,
|
|
@@ -89,20 +83,34 @@ async function runOAuthFlow(apiBase) {
|
|
|
89
83
|
clearTimeout(timeout);
|
|
90
84
|
process.removeListener('SIGINT', cleanup);
|
|
91
85
|
process.removeListener('SIGTERM', cleanup);
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
// Plain 200 + HTML — no Connection: close, no synchronous socket
|
|
87
|
+
// teardown. The previous code closed the server and destroyed
|
|
88
|
+
// sockets in the same tick as `res.end()`, racing the response
|
|
89
|
+
// flush; the browser ended up rendering ERR_CONNECTION_REFUSED
|
|
90
|
+
// instead of the success page.
|
|
91
|
+
//
|
|
92
|
+
// Now we resolve the OAuth promise immediately so the CLI can
|
|
93
|
+
// continue with the rest of `install`, and schedule a delayed
|
|
94
|
+
// teardown that gives the browser a few seconds to render and
|
|
95
|
+
// ignore favicon failures. The CLI process exits naturally once
|
|
96
|
+
// its remaining steps complete (server.close + socket.destroy
|
|
97
|
+
// make sure the listening port is released before that).
|
|
98
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
99
|
+
res.end('<html><body><h2>GooseWorks CLI authenticated!</h2><p>You can close this window and return to your terminal.</p></body></html>');
|
|
100
|
+
resolve({
|
|
101
|
+
api_key: token,
|
|
102
|
+
email,
|
|
103
|
+
agent_id: agentId,
|
|
104
|
+
...(scopeType ? { scope_type: scopeType } : {}),
|
|
105
|
+
...(defaultAgentId ? { default_agent_id: defaultAgentId } : {}),
|
|
106
|
+
...(mcpServerUrl ? { mcp_server_url: mcpServerUrl } : {}),
|
|
102
107
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
server.close();
|
|
110
|
+
for (const socket of sockets) {
|
|
111
|
+
socket.destroy();
|
|
112
|
+
}
|
|
113
|
+
}, 5000);
|
|
106
114
|
}
|
|
107
115
|
else {
|
|
108
116
|
res.writeHead(404);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-server.js","sourceRoot":"","sources":["../../src/auth/oauth-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,
|
|
1
|
+
{"version":3,"file":"oauth-server.js","sourceRoot":"","sources":["../../src/auth/oauth-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,oCA6HC;AAhJD,2CAA6B;AAE7B,+CAAiC;AACjC,gDAAwB;AACxB,+CAAkE;AAClE,wDAA0C;AAC1C,sCAAyC;AAEzC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAW1B,KAAK,UAAU,YAAY,CAAC,OAAe;IAChD,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,YAAY,GAAG,qBAAY,CAAC;IAElC,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAClD,2DAA2D;QAC3D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAc,CAAC;QAEtC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC5C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,kBAAkB,CAAC,CAAC;YAExD,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;gBACjC,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,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AAI,KAAK,CAAC,+DAA+D,CAAC,CAAC,CAAC;QACrF,CAAC,EAAE,gBAAgB,CAAC,CAAC;QAErB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACH,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../src/commands/formats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+LpC,eAAO,MAAM,cAAc,SAOH,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatsCommand = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
const graphics_manifest_1 = require("../lib/graphics-manifest");
|
|
7
|
+
const graphics_api_1 = require("../lib/graphics-api");
|
|
8
|
+
const shared_1 = require("./graphics/shared");
|
|
9
|
+
const publish_flow_1 = require("./graphics/publish-flow");
|
|
10
|
+
const get_flow_1 = require("./graphics/get-flow");
|
|
11
|
+
function renderListTable(rows) {
|
|
12
|
+
return (0, shared_1.renderTable)(rows, [
|
|
13
|
+
{ header: 'NAME', get: (r) => (0, shared_1.truncate)(r.name, 40) },
|
|
14
|
+
{ header: 'SLUG', get: (r) => r.slug },
|
|
15
|
+
{
|
|
16
|
+
header: 'SIZE',
|
|
17
|
+
get: (r) => r.width != null && r.height != null ? `${r.width}×${r.height}` : '',
|
|
18
|
+
},
|
|
19
|
+
{ header: 'FEATURED', get: (r) => (r.featured ? '★' : '') },
|
|
20
|
+
{ header: 'AUTHOR', get: (r) => r.authorHandle ?? '' },
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
const listCmd = new commander_1.Command('list')
|
|
24
|
+
.description('List published graphic formats')
|
|
25
|
+
.option('--featured', 'Only featured formats')
|
|
26
|
+
.option('--q <query>', 'Free-text query')
|
|
27
|
+
.option('--limit <n>', 'Max rows to return')
|
|
28
|
+
.option('--offset <n>', 'Skip the first N rows')
|
|
29
|
+
.option('--json', 'Print full JSON instead of a table')
|
|
30
|
+
.action(async (opts) => {
|
|
31
|
+
try {
|
|
32
|
+
const env = await (0, graphics_api_1.listFormats)((0, shared_1.clientOpts)(), {
|
|
33
|
+
q: opts.q,
|
|
34
|
+
featured: !!opts.featured,
|
|
35
|
+
limit: (0, shared_1.parseIntOpt)(opts.limit, 'limit'),
|
|
36
|
+
offset: (0, shared_1.parseIntOpt)(opts.offset, 'offset'),
|
|
37
|
+
});
|
|
38
|
+
if (opts.json) {
|
|
39
|
+
process.stdout.write(JSON.stringify(env.data, null, 2) + '\n');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (env.data.length === 0) {
|
|
43
|
+
process.stderr.write('No formats match.\n');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
process.stdout.write(renderListTable(env.data) + '\n');
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
(0, shared_1.reportApiErrorAndExit)(err);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const searchCmd = new commander_1.Command('search')
|
|
53
|
+
.description('Search graphic formats (alias for `list --q <query>`)')
|
|
54
|
+
.argument('<query>', 'Search query')
|
|
55
|
+
.option('--json', 'Print full JSON instead of a table')
|
|
56
|
+
.option('--limit <n>', 'Max rows to return')
|
|
57
|
+
.option('--offset <n>', 'Skip the first N rows')
|
|
58
|
+
.action(async (query, opts) => {
|
|
59
|
+
try {
|
|
60
|
+
const env = await (0, graphics_api_1.listFormats)((0, shared_1.clientOpts)(), {
|
|
61
|
+
q: query,
|
|
62
|
+
limit: (0, shared_1.parseIntOpt)(opts.limit, 'limit'),
|
|
63
|
+
offset: (0, shared_1.parseIntOpt)(opts.offset, 'offset'),
|
|
64
|
+
});
|
|
65
|
+
if (opts.json) {
|
|
66
|
+
process.stdout.write(JSON.stringify(env.data, null, 2) + '\n');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (env.data.length === 0) {
|
|
70
|
+
process.stderr.write(`No formats match "${query}".\n`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
process.stdout.write(renderListTable(env.data) + '\n');
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
(0, shared_1.reportApiErrorAndExit)(err);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const getCmd = new commander_1.Command('get')
|
|
80
|
+
.description('Print a format\'s spec.md (default) or full JSON record')
|
|
81
|
+
.argument('<slug>', 'Format slug')
|
|
82
|
+
.option('--json', 'Print full JSON record instead of spec.md')
|
|
83
|
+
.option('--include-examples', 'Also download example PNGs into ./<slug>/')
|
|
84
|
+
.option('--no-cache', 'Bypass local ETag cache')
|
|
85
|
+
.action(async (slug, opts) => {
|
|
86
|
+
const opt = (0, shared_1.clientOpts)();
|
|
87
|
+
await (0, get_flow_1.runGetFlow)({
|
|
88
|
+
resource: 'formats',
|
|
89
|
+
fetchMarkdown: (s, etag) => (0, graphics_api_1.getFormatSpecMd)(opt, s, etag),
|
|
90
|
+
fetchRecord: (s, etag) => (0, graphics_api_1.getFormatRecord)(opt, s, etag),
|
|
91
|
+
}, slug, {
|
|
92
|
+
json: opts.json,
|
|
93
|
+
includeExamples: opts.includeExamples,
|
|
94
|
+
noCache: opts.cache === false,
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
const publishCmd = new commander_1.Command('publish')
|
|
98
|
+
.description('Publish a format from a directory containing gooseworks-format.json')
|
|
99
|
+
.argument('[path]', 'Directory containing the manifest', '.')
|
|
100
|
+
.option('--slug <slug>', 'Override the manifest slug')
|
|
101
|
+
.option('--yes', 'Skip the slug-collision prompt and accept the suggestion')
|
|
102
|
+
.action(async (dir, opts) => {
|
|
103
|
+
const auth = (0, shared_1.authedClientOpts)();
|
|
104
|
+
await (0, publish_flow_1.runPublishFlow)({
|
|
105
|
+
manifestFilename: graphics_manifest_1.FORMAT_MANIFEST_FILENAME,
|
|
106
|
+
validate: graphics_manifest_1.validateFormatManifest,
|
|
107
|
+
hubUrl: (slug) => `${config_1.FRONTEND_URL}/formats/${slug}`,
|
|
108
|
+
label: 'format',
|
|
109
|
+
upload: (manifest, files) => (0, graphics_api_1.publishFormat)(auth, manifest, files),
|
|
110
|
+
}, { dir, slug: opts.slug, yes: opts.yes });
|
|
111
|
+
});
|
|
112
|
+
const updateCmd = new commander_1.Command('update')
|
|
113
|
+
.description('Update a format by slug')
|
|
114
|
+
.argument('<slug>', 'Format slug to update')
|
|
115
|
+
.argument('[path]', 'Directory containing the manifest', '.')
|
|
116
|
+
.action(async (slug, dir) => {
|
|
117
|
+
const auth = (0, shared_1.authedClientOpts)();
|
|
118
|
+
await (0, publish_flow_1.runUpdateFlow)({
|
|
119
|
+
manifestFilename: graphics_manifest_1.FORMAT_MANIFEST_FILENAME,
|
|
120
|
+
validate: graphics_manifest_1.validateFormatManifest,
|
|
121
|
+
hubUrl: (s) => `${config_1.FRONTEND_URL}/formats/${s}`,
|
|
122
|
+
label: 'format',
|
|
123
|
+
upload: (manifest, files) => (0, graphics_api_1.updateFormat)(auth, slug, manifest, files),
|
|
124
|
+
}, { dir, slug, yes: true });
|
|
125
|
+
});
|
|
126
|
+
const deleteCmd = new commander_1.Command('delete')
|
|
127
|
+
.description('Delete a format by slug (owner only)')
|
|
128
|
+
.argument('<slug>', 'Format slug to delete')
|
|
129
|
+
.option('--yes', 'Skip the confirmation prompt')
|
|
130
|
+
.action(async (slug, opts) => {
|
|
131
|
+
const auth = (0, shared_1.authedClientOpts)();
|
|
132
|
+
if (!opts.yes) {
|
|
133
|
+
const ok = await (0, shared_1.promptYesNo)(`Delete format '${slug}'?`, false);
|
|
134
|
+
if (!ok) {
|
|
135
|
+
process.stderr.write('Aborted.\n');
|
|
136
|
+
process.exit(shared_1.EXIT_USER_ERROR);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
await (0, graphics_api_1.deleteFormat)(auth, slug);
|
|
141
|
+
process.stdout.write(`Deleted format '${slug}'.\n`);
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
(0, shared_1.reportApiErrorAndExit)(err);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
exports.formatsCommand = new commander_1.Command('formats')
|
|
148
|
+
.description('Browse and publish graphic formats')
|
|
149
|
+
.addCommand(listCmd)
|
|
150
|
+
.addCommand(searchCmd)
|
|
151
|
+
.addCommand(getCmd)
|
|
152
|
+
.addCommand(publishCmd)
|
|
153
|
+
.addCommand(updateCmd)
|
|
154
|
+
.addCommand(deleteCmd);
|
|
155
|
+
//# sourceMappingURL=formats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.js","sourceRoot":"","sources":["../../src/commands/formats.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,sCAAyC;AACzC,gEAGkC;AAClC,sDAS6B;AAC7B,8CAS2B;AAC3B,0DAAwE;AACxE,kDAAiD;AAUjD,SAAS,eAAe,CAAC,IAAgD;IACvE,OAAO,IAAA,oBAAW,EAAC,IAAI,EAAE;QACvB,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,iBAAQ,EAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE;QACpD,EAAE,MAAM,EAAE,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AAI,CAAC,CAAC;QAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,IAAI,MAAM,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAA,8BAAqB,EAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC,CAAC,CAAC;AAEQ,QAAA,cAAc,GAAG,IAAI,mBAAO,CAAC,SAAS,CAAC;KACjD,WAAW,CAAC,oCAAoC,CAAC;KACjD,UAAU,CAAC,OAAO,CAAC;KACnB,UAAU,CAAC,SAAS,CAAC;KACrB,UAAU,CAAC,MAAM,CAAC;KAClB,UAAU,CAAC,UAAU,CAAC;KACtB,UAAU,CAAC,SAAS,CAAC;KACrB,UAAU,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic `get <slug>` flow shared by styles + formats.
|
|
3
|
+
*
|
|
4
|
+
* Default output: hits the markdown endpoint (design.md or spec.md), prints
|
|
5
|
+
* the body to stdout, with ETag-keyed disk cache and offline fallback.
|
|
6
|
+
*
|
|
7
|
+
* --json: hits the JSON record endpoint and prints it to stdout.
|
|
8
|
+
*
|
|
9
|
+
* --include-examples: also downloads example PNGs from the JSON record into
|
|
10
|
+
* ./<slug>/<format>.png (current working directory).
|
|
11
|
+
*/
|
|
12
|
+
import { type MarkdownResponse, type RecordResponse } from '../../lib/graphics-api';
|
|
13
|
+
import { type Resource } from '../../lib/graphics-cache';
|
|
14
|
+
export interface GetConfig<T> {
|
|
15
|
+
resource: Resource;
|
|
16
|
+
/** Hits `:slug/design.md` or `:slug/spec.md`. */
|
|
17
|
+
fetchMarkdown: (slug: string, etag: string | null) => Promise<MarkdownResponse>;
|
|
18
|
+
/** Hits `:slug` for the full JSON record, with ETag round-trip. */
|
|
19
|
+
fetchRecord: (slug: string, etag: string | null) => Promise<RecordResponse<T>>;
|
|
20
|
+
}
|
|
21
|
+
export interface GetOptions {
|
|
22
|
+
json?: boolean;
|
|
23
|
+
includeExamples?: boolean;
|
|
24
|
+
noCache?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function runGetFlow<T extends {
|
|
27
|
+
examples?: unknown[];
|
|
28
|
+
slug?: string;
|
|
29
|
+
}>(cfg: GetConfig<T>, slug: string, opts: GetOptions): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=get-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-flow.d.ts","sourceRoot":"","sources":["../../../src/commands/graphics/get-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAIlC,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,iDAAiD;IACjD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChF,mEAAmE;IACnE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;CAChF;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAChF,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generic `get <slug>` flow shared by styles + formats.
|
|
4
|
+
*
|
|
5
|
+
* Default output: hits the markdown endpoint (design.md or spec.md), prints
|
|
6
|
+
* the body to stdout, with ETag-keyed disk cache and offline fallback.
|
|
7
|
+
*
|
|
8
|
+
* --json: hits the JSON record endpoint and prints it to stdout.
|
|
9
|
+
*
|
|
10
|
+
* --include-examples: also downloads example PNGs from the JSON record into
|
|
11
|
+
* ./<slug>/<format>.png (current working directory).
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.runGetFlow = runGetFlow;
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const graphics_api_1 = require("../../lib/graphics-api");
|
|
51
|
+
const graphics_api_2 = require("../../lib/graphics-api");
|
|
52
|
+
const graphics_cache_1 = require("../../lib/graphics-cache");
|
|
53
|
+
const graphics_manifest_1 = require("../../lib/graphics-manifest");
|
|
54
|
+
const shared_1 = require("./shared");
|
|
55
|
+
async function runGetFlow(cfg, slug, opts) {
|
|
56
|
+
if (opts.json) {
|
|
57
|
+
await emitJson(cfg, slug, !!opts.includeExamples, !!opts.noCache);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
await emitMarkdown(cfg, slug, !!opts.noCache);
|
|
61
|
+
if (opts.includeExamples) {
|
|
62
|
+
await downloadExamples(cfg, slug);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function emitMarkdown(cfg, slug, noCache) {
|
|
66
|
+
const cached = noCache ? null : (0, graphics_cache_1.readCache)(cfg.resource, slug, 'md');
|
|
67
|
+
const etag = cached?.etag ?? null;
|
|
68
|
+
try {
|
|
69
|
+
const res = await cfg.fetchMarkdown(slug, etag);
|
|
70
|
+
if (res.status === 304 && cached) {
|
|
71
|
+
process.stdout.write(cached.body);
|
|
72
|
+
if (!cached.body.endsWith('\n'))
|
|
73
|
+
process.stdout.write('\n');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (res.status === 200 && res.body !== null) {
|
|
77
|
+
if (!noCache)
|
|
78
|
+
(0, graphics_cache_1.writeCache)(cfg.resource, slug, 'md', res.body, res.etag);
|
|
79
|
+
process.stdout.write(res.body);
|
|
80
|
+
if (!res.body.endsWith('\n'))
|
|
81
|
+
process.stdout.write('\n');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// 304 with no cached body shouldn't happen in practice — fall through.
|
|
85
|
+
process.stderr.write('Unexpected 304 with no cached body.\n');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
if (cached && (err instanceof graphics_api_1.NetworkError || isTransientApiError(err))) {
|
|
90
|
+
process.stderr.write(`Warning: ${describeFetchError(err)} — serving cached copy.\n`);
|
|
91
|
+
process.stdout.write(cached.body);
|
|
92
|
+
if (!cached.body.endsWith('\n'))
|
|
93
|
+
process.stdout.write('\n');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
(0, shared_1.reportApiErrorAndExit)(err);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function emitJson(cfg, slug, includeExamples, noCache) {
|
|
100
|
+
const cached = noCache ? null : (0, graphics_cache_1.readCache)(cfg.resource, slug, 'json');
|
|
101
|
+
const cachedEtag = cached?.etag ?? null;
|
|
102
|
+
let recordData;
|
|
103
|
+
try {
|
|
104
|
+
const res = await cfg.fetchRecord(slug, cachedEtag);
|
|
105
|
+
if (res.status === 304 && cached) {
|
|
106
|
+
recordData = JSON.parse(cached.body).data;
|
|
107
|
+
}
|
|
108
|
+
else if (res.status === 200 && res.envelope) {
|
|
109
|
+
recordData = res.envelope.data;
|
|
110
|
+
if (!noCache) {
|
|
111
|
+
(0, graphics_cache_1.writeCache)(cfg.resource, slug, 'json', JSON.stringify(res.envelope, null, 2), res.etag);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
process.stderr.write('Unexpected 304 with no cached body.\n');
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
if (cached && (err instanceof graphics_api_1.NetworkError || isTransientApiError(err))) {
|
|
121
|
+
process.stderr.write(`Warning: ${describeFetchError(err)} — serving cached copy.\n`);
|
|
122
|
+
// The cached body is the full envelope; print just `.data` to match
|
|
123
|
+
// the freshly-fetched output shape.
|
|
124
|
+
try {
|
|
125
|
+
const parsed = JSON.parse(cached.body);
|
|
126
|
+
process.stdout.write(JSON.stringify(parsed.data, null, 2));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
process.stdout.write(cached.body);
|
|
130
|
+
}
|
|
131
|
+
process.stdout.write('\n');
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
(0, shared_1.reportApiErrorAndExit)(err);
|
|
135
|
+
}
|
|
136
|
+
process.stdout.write(JSON.stringify(recordData, null, 2));
|
|
137
|
+
process.stdout.write('\n');
|
|
138
|
+
if (includeExamples) {
|
|
139
|
+
await downloadExamplesFromRecord(recordData, slug);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function downloadExamples(cfg, slug) {
|
|
143
|
+
let recordData;
|
|
144
|
+
try {
|
|
145
|
+
const res = await cfg.fetchRecord(slug, null);
|
|
146
|
+
if (res.status !== 200 || !res.envelope) {
|
|
147
|
+
process.stderr.write('Could not download examples: empty record response.\n');
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
recordData = res.envelope.data;
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
process.stderr.write(`Could not download examples: ${describeFetchError(err)}\n`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
await downloadExamplesFromRecord(recordData, slug);
|
|
157
|
+
}
|
|
158
|
+
async function downloadExamplesFromRecord(record, slug) {
|
|
159
|
+
const examples = (record.examples ?? []);
|
|
160
|
+
if (examples.length === 0) {
|
|
161
|
+
process.stderr.write('No examples to download.\n');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// The directory name comes from the user-supplied CLI slug, not record.slug,
|
|
165
|
+
// and we re-validate before using it as a path component.
|
|
166
|
+
if (!graphics_manifest_1.SLUG_RE.test(slug)) {
|
|
167
|
+
process.stderr.write(`Refusing to write examples: slug '${slug}' is not a valid slug.\n`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const targetDir = path.resolve(process.cwd(), slug);
|
|
171
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
172
|
+
for (const ex of examples) {
|
|
173
|
+
const url = ex.url || ex.imageUrl;
|
|
174
|
+
if (!url)
|
|
175
|
+
continue;
|
|
176
|
+
if (!isSafeDownloadUrl(url)) {
|
|
177
|
+
process.stderr.write(` skipped ${url}: only http(s) URLs are downloaded\n`);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const format = typeof ex.format === 'string' && graphics_manifest_1.SLUG_RE.test(ex.format) ? ex.format : 'example';
|
|
181
|
+
const fileName = `${format}.png`;
|
|
182
|
+
try {
|
|
183
|
+
const bytes = await (0, graphics_api_2.downloadBytes)(url);
|
|
184
|
+
const dest = path.join(targetDir, fileName);
|
|
185
|
+
fs.writeFileSync(dest, bytes);
|
|
186
|
+
process.stderr.write(` saved ${path.relative(process.cwd(), dest)}\n`);
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
process.stderr.write(` failed to download ${url}: ${describeFetchError(err)}\n`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function isSafeDownloadUrl(url) {
|
|
194
|
+
try {
|
|
195
|
+
const parsed = new URL(url);
|
|
196
|
+
return parsed.protocol === 'https:' || parsed.protocol === 'http:';
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function isTransientApiError(err) {
|
|
203
|
+
return err instanceof graphics_api_1.ApiError && err.status >= 500;
|
|
204
|
+
}
|
|
205
|
+
function describeFetchError(err) {
|
|
206
|
+
if (err instanceof graphics_api_1.NetworkError)
|
|
207
|
+
return `network unreachable (${err.message})`;
|
|
208
|
+
if (err instanceof graphics_api_1.ApiError)
|
|
209
|
+
return `server error ${err.status}`;
|
|
210
|
+
return err instanceof Error ? err.message : String(err);
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=get-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-flow.js","sourceRoot":"","sources":["../../../src/commands/graphics/get-flow.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCH,gCAaC;AA5CD,uCAAyB;AACzB,2CAA6B;AAC7B,yDAKgC;AAChC,yDAAuD;AACvD,6DAIkC;AAClC,mEAAsD;AACtD,qCAAiD;AAgB1C,KAAK,UAAU,UAAU,CAC9B,GAAiB,EACjB,IAAY,EACZ,IAAgB;IAEhB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClE,OAAO;IACT,CAAC;IACD,MAAM,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,MAAM,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,GAAiB,EACjB,IAAY,EACZ,OAAgB;IAEhB,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,0BAAS,EAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,MAAM,EAAE,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AC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAY;IACvC,OAAO,GAAG,YAAY,uBAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;AACtD,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAY;IACtC,IAAI,GAAG,YAAY,2BAAY;QAAE,OAAO,wBAAwB,GAAG,CAAC,OAAO,GAAG,CAAC;IAC/E,IAAI,GAAG,YAAY,uBAAQ;QAAE,OAAO,gBAAgB,GAAG,CAAC,MAAM,EAAE,CAAC;IACjE,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic publish/update orchestration shared by the styles and formats
|
|
3
|
+
* commands. Handles manifest read + validate + slug overlay, multipart
|
|
4
|
+
* upload, and the 409 slug-collision retry loop.
|
|
5
|
+
*/
|
|
6
|
+
import { type ValidationResult, type ResolvedExampleFile } from '../../lib/graphics-manifest';
|
|
7
|
+
import { type WriteResult } from '../../lib/graphics-api';
|
|
8
|
+
export interface PublishConfig {
|
|
9
|
+
manifestFilename: string;
|
|
10
|
+
validate: (manifest: unknown) => ValidationResult;
|
|
11
|
+
/** Hub URL to print on success, e.g. `https://app.gooseworks.ai/styles/<slug>`. */
|
|
12
|
+
hubUrl: (slug: string) => string;
|
|
13
|
+
/** Resource label used in user-facing messages: 'style' or 'format'. */
|
|
14
|
+
label: 'style' | 'format';
|
|
15
|
+
/** Performs the create/update upload. Returns the new slug + id. */
|
|
16
|
+
upload: (manifest: Record<string, unknown>, files: ResolvedExampleFile[]) => Promise<WriteResult>;
|
|
17
|
+
}
|
|
18
|
+
export interface PublishOptions {
|
|
19
|
+
/** Defaults to process.cwd(). */
|
|
20
|
+
dir?: string;
|
|
21
|
+
/** Override the manifest's slug at publish time. */
|
|
22
|
+
slug?: string;
|
|
23
|
+
/** Skip interactive prompts. */
|
|
24
|
+
yes?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function runPublishFlow(cfg: PublishConfig, opts: PublishOptions): Promise<void>;
|
|
27
|
+
export declare function runUpdateFlow(cfg: PublishConfig, opts: PublishOptions): Promise<void>;
|
|
28
|
+
//# sourceMappingURL=publish-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-flow.d.ts","sourceRoot":"","sources":["../../../src/commands/graphics/publish-flow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAOpE,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,gBAAgB,CAAC;IAClD,mFAAmF;IACnF,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACjC,wEAAwE;IACxE,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,oEAAoE;IACpE,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACnG;AAED,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAyBD,wBAAsB,cAAc,CAClC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CAGf"}
|