seedyn 0.2.0 → 0.2.1

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 CHANGED
@@ -33,6 +33,19 @@ owner-only config file. API URL precedence is `--api-url`, then
33
33
  Passing a secret on the command line can expose it to shell history and process
34
34
  inspection; prefer the environment or `seedyn auth set`.
35
35
 
36
+ ## Self-hosted Seedyn
37
+
38
+ Save the application origin once, then use the normal login flow:
39
+
40
+ ```sh
41
+ npx seedyn config set api-url https://seedyn.example.com
42
+ npx seedyn config get api-url
43
+ npx seedyn auth login
44
+ ```
45
+
46
+ The origin must use HTTPS. HTTP is accepted for `localhost` during development.
47
+ For a one-off command, pass `--api-url`. In CI, set `SEEDYN_API_URL`.
48
+
36
49
  ## Upload
37
50
 
38
51
  The shortest form treats the first argument as a file:
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "seedyn",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Upload any file to Seedyn and receive its durable URL.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/DavidIlie/seedyn.git",
10
+ "directory": "packages/cli"
11
+ },
7
12
  "files": [
8
13
  "bin/",
9
14
  "src/",
@@ -12,7 +17,7 @@
12
17
  "THIRD_PARTY_NOTICES.md"
13
18
  ],
14
19
  "bin": {
15
- "seedyn": "./bin/seedyn.mjs"
20
+ "seedyn": "bin/seedyn.mjs"
16
21
  },
17
22
  "engines": {
18
23
  "node": ">=22.12.0"
package/src/cli.mjs CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  readConfig,
8
8
  removeAuthentication,
9
9
  resolveAuthentication,
10
+ saveApiUrl,
10
11
  saveAuthentication,
11
12
  validateApiKey,
12
13
  validateApiUrl,
@@ -32,6 +33,10 @@ export async function run(arguments_) {
32
33
  await authCommand(args.slice(1));
33
34
  return;
34
35
  }
36
+ if (first === "config") {
37
+ await configCommand(args.slice(1));
38
+ return;
39
+ }
35
40
  await uploadCommand(first === "upload" ? args.slice(1) : args);
36
41
  }
37
42
 
@@ -135,6 +140,35 @@ async function authCommand(args) {
135
140
  throw new CliError(`Unknown auth command: ${action}`);
136
141
  }
137
142
 
143
+ async function configCommand(args) {
144
+ const action = args[0] || "help";
145
+ if (action === "help" || action === "--help" || action === "-h") {
146
+ console.log(CONFIG_HELP);
147
+ return;
148
+ }
149
+
150
+ if (action === "set" && args[1] === "api-url") {
151
+ if (args.length !== 3) {
152
+ throw new CliError("Usage: seedyn config set api-url <origin>");
153
+ }
154
+ const result = await saveApiUrl(args[2]);
155
+ console.log(`API URL saved to ${result.file}`);
156
+ console.log(`API URL: ${result.value.apiUrl}`);
157
+ return;
158
+ }
159
+
160
+ if (action === "get" && args[1] === "api-url") {
161
+ if (args.length !== 2) {
162
+ throw new CliError("Usage: seedyn config get api-url");
163
+ }
164
+ const config = await readConfig();
165
+ console.log(config.apiUrl || "https://seedyn.dave.tips");
166
+ return;
167
+ }
168
+
169
+ throw new CliError(`Unknown config command: ${args.join(" ")}`);
170
+ }
171
+
138
172
  async function uploadCommand(args) {
139
173
  const { values, positionals } = parseArgs({
140
174
  args,
@@ -287,6 +321,7 @@ Usage:
287
321
  seedyn <file> [options]
288
322
  seedyn upload <file> [options]
289
323
  seedyn auth <login|set|status|remove>
324
+ seedyn config <set|get> api-url
290
325
 
291
326
  Examples:
292
327
  seedyn ./image.png --copy
@@ -323,6 +358,12 @@ Commands:
323
358
 
324
359
  Run "seedyn auth login" for the guided browser flow.`;
325
360
 
361
+ const CONFIG_HELP = `Usage: seedyn config <command>
362
+
363
+ Commands:
364
+ set api-url <origin> Save a self-hosted Seedyn application origin
365
+ get api-url Print the configured application origin`;
366
+
326
367
  const AUTH_LOGIN_HELP = `Usage: seedyn auth login [options]
327
368
 
328
369
  Options:
package/src/config.mjs CHANGED
@@ -133,6 +133,17 @@ export async function saveAuthentication(
133
133
  return { file: configPath(environment), value: next };
134
134
  }
135
135
 
136
+ export async function saveApiUrl(apiUrl, environment = process.env) {
137
+ const existing = await readConfig(environment);
138
+ const next = {
139
+ ...existing,
140
+ apiUrl: validateApiUrl(apiUrl),
141
+ updatedAt: new Date().toISOString(),
142
+ };
143
+ await writeConfig(next, environment);
144
+ return { file: configPath(environment), value: next };
145
+ }
146
+
136
147
  export async function removeAuthentication(environment = process.env) {
137
148
  const existing = await readConfig(environment);
138
149
  const { apiKey: _removed, ...next } = existing;