@kelviq/cli 0.4.2 → 0.5.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 +147 -5
- package/dist/cli-ui/secret-prompt.d.ts +53 -0
- package/dist/cli-ui/secret-prompt.js +119 -0
- package/dist/cli-ui/secret-prompt.js.map +1 -0
- package/dist/cli.js +6 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/env.js +2 -2
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/import/index.d.ts +15 -0
- package/dist/commands/import/index.js +120 -0
- package/dist/commands/import/index.js.map +1 -0
- package/dist/commands/import/lemon-squeezy.d.ts +2 -0
- package/dist/commands/import/lemon-squeezy.js +90 -0
- package/dist/commands/import/lemon-squeezy.js.map +1 -0
- package/dist/commands/import/redact.d.ts +10 -0
- package/dist/commands/import/redact.js +73 -0
- package/dist/commands/import/redact.js.map +1 -0
- package/dist/commands/import/runner.d.ts +40 -0
- package/dist/commands/import/runner.js +510 -0
- package/dist/commands/import/runner.js.map +1 -0
- package/dist/commands/import/source.d.ts +122 -0
- package/dist/commands/import/source.js +29 -0
- package/dist/commands/import/source.js.map +1 -0
- package/dist/commands/login.js +6 -104
- package/dist/commands/login.js.map +1 -1
- package/dist/core/config.d.ts +2 -0
- package/dist/core/config.js +4 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/env-file.d.ts +7 -2
- package/dist/core/env-file.js +22 -7
- package/dist/core/env-file.js.map +1 -1
- package/dist/core/errors.d.ts +23 -1
- package/dist/core/errors.js +83 -31
- package/dist/core/errors.js.map +1 -1
- package/dist/core/http.d.ts +4 -0
- package/dist/core/http.js +6 -3
- package/dist/core/http.js.map +1 -1
- package/dist/core/import-env.d.ts +8 -0
- package/dist/core/import-env.js +18 -0
- package/dist/core/import-env.js.map +1 -0
- package/dist/generated/openapi.json +1359 -109
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ Browser-handoff login is not built yet — see "What's not here yet" below.
|
|
|
34
34
|
| `kelviq status` | Shows the live catalog: products, features, and each plan's latest version with price and entitlement counts. `--json` for scripting. |
|
|
35
35
|
| `kelviq webhook add` / `list` | Registers the app's webhook endpoint and writes its signing secret into an env file without printing it. |
|
|
36
36
|
| `kelviq discount create` / `list` | Creates a discount code (product by identifier) after restating it for confirmation. |
|
|
37
|
+
| `kelviq import lemon-squeezy` | Starts a server-side import of a Lemon Squeezy store (profile, products, plans, customers, files, orders, renewals, discounts, license keys) and emails a report. `--dry-run` saves nothing. |
|
|
37
38
|
|
|
38
39
|
```bash
|
|
39
40
|
kelviq init # write kelviq.config.ts in the current directory
|
|
@@ -53,11 +54,17 @@ kelviq webhook add https://app.example.com/api/kelviq/webhooks \
|
|
|
53
54
|
--events checkout.completed,subscription.created --write-secret .env.local
|
|
54
55
|
kelviq discount create --name "Launch" --code LAUNCH20 --percent 20 \
|
|
55
56
|
--duration repeating --months 3 --product my-app --plans pro
|
|
57
|
+
kelviq import # list the platforms a store can be imported from
|
|
58
|
+
kelviq import lemon-squeezy --store 12345 --dry-run # save nothing; the emailed report shows what a real run would do
|
|
59
|
+
kelviq import lemon-squeezy --store 12345 # shows what it will do, asks, then starts it in sandbox
|
|
60
|
+
kelviq import lemon-squeezy --store 12345 --only orders,renewals --prod --yes # later: pick up new sales and refunds
|
|
56
61
|
```
|
|
57
62
|
|
|
58
|
-
Every command reads `KELVIQ_*` variables
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
Every command reads `KELVIQ_*` variables, plus the two `kelviq import
|
|
64
|
+
lemon-squeezy` uses (`LEMONSQUEEZY_API_KEY` and `LEMONSQUEEZY_STORE_ID`), from
|
|
65
|
+
`.env.local` then `.env` in the working directory (the shell always wins), or
|
|
66
|
+
from `--env-file <path>` when given; `--no-env-file` turns that off. No other
|
|
67
|
+
variable is taken from an env file.
|
|
61
68
|
|
|
62
69
|
Run `kelviq push --help` / `kelviq promote --help` for the full flag set:
|
|
63
70
|
`--publish`, `--migrate-features`, `--migrate-pricing`, `--prune`,
|
|
@@ -67,11 +74,146 @@ Run `kelviq push --help` / `kelviq promote --help` for the full flag set:
|
|
|
67
74
|
environment mode matching the target (sandbox by default, production with
|
|
68
75
|
`--prod`), and tries to open it in your default browser, then prompts for
|
|
69
76
|
the key on stdin (an interactive terminal masks each character as `*` while
|
|
70
|
-
you type or paste, then reports how many characters it received).
|
|
71
|
-
|
|
77
|
+
you type or paste, then reports how many characters it received). Ctrl-C or
|
|
78
|
+
Ctrl-D at that prompt prints `Cancelled; no key was stored.` and exits
|
|
79
|
+
non-zero. Kelviq has no key-introspection endpoint, so `login` cannot show which org a key belongs
|
|
72
80
|
to; `kelviq env --check` confirms a key is accepted by making one
|
|
73
81
|
authenticated read against its environment.
|
|
74
82
|
|
|
83
|
+
## Importing a store
|
|
84
|
+
|
|
85
|
+
`kelviq import lemon-squeezy` starts an import of a Lemon Squeezy store into
|
|
86
|
+
the Kelviq organization your Server API key belongs to. The import runs on
|
|
87
|
+
Kelviq's servers, so the command returns as soon as it is queued; a report is
|
|
88
|
+
emailed to the organization owner (or `--report-email`) when it finishes.
|
|
89
|
+
There is no status to poll. Running it again is safe: records already
|
|
90
|
+
imported are skipped and what is new is added.
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
$ kelviq import lemon-squeezy
|
|
94
|
+
Create a key in Lemon Squeezy under Settings → API.
|
|
95
|
+
Paste your Lemon Squeezy API key: ********************************
|
|
96
|
+
Lemon Squeezy store id (the number beside your store under Settings → Stores): 12345
|
|
97
|
+
Import from Lemon Squeezy:
|
|
98
|
+
environment: sandbox (your test environment; add --prod to import into production)
|
|
99
|
+
source: Lemon Squeezy
|
|
100
|
+
api key: typed
|
|
101
|
+
store: 12345
|
|
102
|
+
steps: all (store, products, customers, files, orders, renewals, discounts, licenses)
|
|
103
|
+
order type: all (every order and every subscription renewal)
|
|
104
|
+
plans: published on import, so they can be sold straight away (--no-publish-plans imports them as drafts)
|
|
105
|
+
discounts: usable at checkout on import (--no-publish-discounts leaves them switched off)
|
|
106
|
+
report to: the organization owner's email
|
|
107
|
+
|
|
108
|
+
customers: not emailed; no webhooks fire for imported records
|
|
109
|
+
subscriptions: imported as history; they keep billing on Lemon Squeezy
|
|
110
|
+
the import runs on Kelviq's servers; records already imported are skipped, so it is safe to run again
|
|
111
|
+
Start the import into sandbox? [y/N] y
|
|
112
|
+
Import started for Acme Apps into sandbox.
|
|
113
|
+
steps: store, products, customers, files, orders, renewals, discounts, licenses
|
|
114
|
+
report: emailed to owner@example.com when the import finishes
|
|
115
|
+
task id: 6f1c2f0e-8d3a-4a57-9b1e-2c1d5e7a9f10 (a reference for support; it cannot be queried)
|
|
116
|
+
There is nothing to poll: the report email is the only completion signal. A large store can take over an hour.
|
|
117
|
+
When the report arrives: review the imported plans (kelviq status), then point your app at Kelviq.
|
|
118
|
+
Add --prod to import into production.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Key and store**
|
|
122
|
+
|
|
123
|
+
- The Lemon Squeezy API key is read from `LEMONSQUEEZY_API_KEY`, or from a
|
|
124
|
+
masked prompt in an interactive terminal, which first says where to create
|
|
125
|
+
one (`Create a key in Lemon Squeezy under Settings → API.`). There is no
|
|
126
|
+
flag for it, so it never lands in shell history. Ctrl-C or Ctrl-D at the
|
|
127
|
+
prompt prints `Cancelled; no import was started.` and exits 130.
|
|
128
|
+
- The key is never printed. The summary shows only where it came from:
|
|
129
|
+
`api key: from LEMONSQUEEZY_API_KEY (.env.local)`, `(shell)`, or
|
|
130
|
+
`typed`. It is hidden in every message and in `--json`, however an error
|
|
131
|
+
quotes it back (as typed, JSON-escaped, URL-encoded or HTML-escaped, in any
|
|
132
|
+
letter case). A value shorter than 20 characters or containing whitespace is
|
|
133
|
+
turned away before anything is sent: `That does not look like a Lemon
|
|
134
|
+
Squeezy API key; nothing was started.`
|
|
135
|
+
- The store comes from `--store <id>` or `LEMONSQUEEZY_STORE_ID`; an
|
|
136
|
+
interactive terminal asks for it, and asks again (up to three times) when
|
|
137
|
+
the entry is not a number. A rejected store is never quoted back, and a
|
|
138
|
+
rejected step or order type only when it is a short lower-case word, since
|
|
139
|
+
a flag or variable set to the wrong thing can hold a key: `--store must be
|
|
140
|
+
the numeric Lemon Squeezy store id (digits only).`
|
|
141
|
+
- In a non-interactive session a missing key and a missing store are reported
|
|
142
|
+
together.
|
|
143
|
+
- The Kelviq Server API key must have been created by the organization owner.
|
|
144
|
+
|
|
145
|
+
**What is shown, and where**
|
|
146
|
+
|
|
147
|
+
- The summary above is printed before every import, including with `--yes`
|
|
148
|
+
and for a dry run. Production reads `environment: PRODUCTION (live data)`
|
|
149
|
+
and is asked for as `Start the import into PRODUCTION? [y/N]`.
|
|
150
|
+
- The prompts, the summary, the progress line (`Checking the store with Lemon
|
|
151
|
+
Squeezy and queueing the import…`) and errors go to stderr. stdout carries
|
|
152
|
+
only the closing report, or the one `--json` document, so redirecting
|
|
153
|
+
stdout never hides a question.
|
|
154
|
+
- A dry run ends with `When the report looks right, run the same command
|
|
155
|
+
without --dry-run.` A real run ends with the next steps shown above; the
|
|
156
|
+
`Add --prod` line appears only after a sandbox import, and with
|
|
157
|
+
`--no-publish-plans` the steps include `publish the drafts in the
|
|
158
|
+
dashboard`.
|
|
159
|
+
|
|
160
|
+
**Confirmation**
|
|
161
|
+
|
|
162
|
+
- A real run asks first; in a non-interactive session it needs `--yes`.
|
|
163
|
+
- `--dry-run` runs the whole import, saves nothing and emails the report a
|
|
164
|
+
real run would produce. It needs no confirmation.
|
|
165
|
+
- The exception is an API host that is not Kelviq's own. A
|
|
166
|
+
`KELVIQ_*_BASE_URL` variable, which an env file in the working directory
|
|
167
|
+
can set, sends both keys to that host, so the summary then shows
|
|
168
|
+
`api host: <url> (not the default)` and even a dry run asks first (`--yes`
|
|
169
|
+
in a non-interactive session).
|
|
170
|
+
|
|
171
|
+
**Flags**
|
|
172
|
+
|
|
173
|
+
- `--only` / `--skip` take comma-separated steps with no spaces: `store`,
|
|
174
|
+
`products`, `customers`, `files`, `orders`, `renewals`, `discounts`,
|
|
175
|
+
`licenses`. Repeating either flag adds to its list. A stray argument is
|
|
176
|
+
refused rather than dropped: `unexpected argument "renewals". Lists are
|
|
177
|
+
comma-separated with no spaces, for example --only orders,renewals`.
|
|
178
|
+
- `--orders all|one-time|subscription` chooses which sales come across
|
|
179
|
+
(`one_time` and `subscriptions` are accepted too).
|
|
180
|
+
- Plans are published and discount codes usable at checkout on import.
|
|
181
|
+
`--no-publish-plans` imports plans as drafts to review and publish
|
|
182
|
+
yourself (the summary then reads `plans: imported as drafts to
|
|
183
|
+
review and publish in the dashboard`), and `--no-publish-discounts` leaves
|
|
184
|
+
imported discount codes switched off (`discounts: imported switched
|
|
185
|
+
off`).
|
|
186
|
+
- Running the import again without those flags publishes plans an earlier
|
|
187
|
+
run left as drafts and switches on imported discount codes that are still
|
|
188
|
+
off. It leaves alone archived plans, plans that already have a published
|
|
189
|
+
version, and codes limited to plans that are not published. A plan the
|
|
190
|
+
import cannot publish stays a draft and is named in the report's warnings.
|
|
191
|
+
A dry run publishes nothing.
|
|
192
|
+
- `--json` prints one document on stdout: `{ "environment", "source",
|
|
193
|
+
"import" }`, where `import` is the API's response (`status`, `taskId`,
|
|
194
|
+
`storeName`, `steps`, `reportEmail`, ...), or `{ "error": "..." }` for any
|
|
195
|
+
failure, a declined confirmation included (`not confirmed; no import was
|
|
196
|
+
started.`).
|
|
197
|
+
|
|
198
|
+
**When it does not start**
|
|
199
|
+
|
|
200
|
+
The command reports an import as started only when the API confirms it was
|
|
201
|
+
queued. Otherwise it exits 1 and says what happened:
|
|
202
|
+
|
|
203
|
+
| Situation | Message |
|
|
204
|
+
|---|---|
|
|
205
|
+
| A 2xx answer that is not the API's confirmation | `the server answered HTTP <n> but did not confirm the import was queued; nothing may have started. Run "kelviq env" to check the API host.` |
|
|
206
|
+
| HTTP 404 | `this Kelviq environment does not offer store imports yet (HTTP 404). Run "kelviq env" to check the API host.` |
|
|
207
|
+
| A 5xx error page | `Kelviq could not start the import (HTTP <n>). Nothing was started; try again in a few minutes.` |
|
|
208
|
+
| The host cannot be reached | `could not reach <host> (<cause>). Nothing was started.` |
|
|
209
|
+
| No answer within 60 seconds, a dropped connection, or HTTP 504 | The import may have been queued. No second one will start while it runs, so running the command again later is safe. |
|
|
210
|
+
| An import is already running (HTTP 409) | Its report is on the way by email. `If no report arrives within a day, contact hi@kelviq.com.` |
|
|
211
|
+
| Lemon Squeezy rejects the key or the store | The API's message, then `Check the Lemon Squeezy API key (LEMONSQUEEZY_API_KEY) and --store.` |
|
|
212
|
+
| A rejected field | The flag or variable to fix (`--store`, `--only, item 1`, `LEMONSQUEEZY_API_KEY`) with the API's message. |
|
|
213
|
+
| A mistyped source, as in `kelviq import lemonsqueezy --store 1` | `Unknown import source "lemonsqueezy". Did you mean "lemon-squeezy"?` and the list of sources. |
|
|
214
|
+
|
|
215
|
+
Run `kelviq import lemon-squeezy --help` for the full flag set.
|
|
216
|
+
|
|
75
217
|
## `kelviq.config.ts`
|
|
76
218
|
|
|
77
219
|
`kelviq init` writes this starter file:
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
export interface SecretPromptIO {
|
|
3
|
+
stdin: NodeJS.ReadableStream;
|
|
4
|
+
stdout: NodeJS.WritableStream;
|
|
5
|
+
/** Whether stdin is an interactive terminal (masks input) vs piped (plain read). */
|
|
6
|
+
isTTY: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* What a prompt ended with: the line that was entered (possibly empty), or
|
|
10
|
+
* `cancelled` when the user backed out of the masked prompt with Ctrl-C or
|
|
11
|
+
* Ctrl-D instead of answering it. A piped stdin that ends without a line is
|
|
12
|
+
* an empty answer, not a cancellation.
|
|
13
|
+
*/
|
|
14
|
+
export type SecretPromptResult = {
|
|
15
|
+
cancelled: false;
|
|
16
|
+
value: string;
|
|
17
|
+
} | {
|
|
18
|
+
cancelled: true;
|
|
19
|
+
};
|
|
20
|
+
export declare function promptForKey(promptText: string, io: SecretPromptIO): Promise<SecretPromptResult>;
|
|
21
|
+
/** Non-TTY (piped) path: read one line as-is. This is the path exercised by tests. */
|
|
22
|
+
export declare function readLinePlain(promptText: string, io: SecretPromptIO): Promise<SecretPromptResult>;
|
|
23
|
+
/**
|
|
24
|
+
* TTY path: reads a line while masking echo. `readline`'s own rendering
|
|
25
|
+
* (which would include the real characters, e.g. on a backspace-triggered
|
|
26
|
+
* line refresh) is fully suppressed via a muted output stream. In its place
|
|
27
|
+
* one `*` is shown per character of the line being edited, driven by
|
|
28
|
+
* `readline`'s public `keypress` event — not a hand-rolled raw-mode reader;
|
|
29
|
+
* `readline` still owns all line editing and remains the sole source of
|
|
30
|
+
* truth for the captured value, this only decides what gets echoed.
|
|
31
|
+
*
|
|
32
|
+
* `readline`'s own `keypress` listener is registered first (inside
|
|
33
|
+
* `createInterface`), so by the time the listener below runs the key has
|
|
34
|
+
* already been applied and `rl.line` is the line as it now stands. The row
|
|
35
|
+
* of asterisks is brought to that length after every key: a typed or pasted
|
|
36
|
+
* character adds one (a paste arrives as one keypress per character, so an
|
|
37
|
+
* 80-character paste renders as 80 `*`), Backspace removes one (`\b \b`),
|
|
38
|
+
* Ctrl-U removes them all, and a key that does not change the line (Ctrl-C,
|
|
39
|
+
* Ctrl-D, an arrow) echoes nothing. No character is ever revealed.
|
|
40
|
+
*
|
|
41
|
+
* Ctrl-C (readline's `SIGINT`: the terminal is in raw mode, so no signal is
|
|
42
|
+
* raised) and Ctrl-D on an empty line (readline's `close`) cancel the prompt:
|
|
43
|
+
* the terminal is restored, a newline is written, and the promise resolves
|
|
44
|
+
* as cancelled. Without those handlers readline only pauses the stream, the
|
|
45
|
+
* promise never settles, and the process exits 0 having said nothing.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readLineMasked(promptText: string, io: SecretPromptIO): Promise<SecretPromptResult>;
|
|
48
|
+
export declare class MutedWritable extends Writable {
|
|
49
|
+
private readonly target;
|
|
50
|
+
muted: boolean;
|
|
51
|
+
constructor(target: NodeJS.WritableStream);
|
|
52
|
+
_write(chunk: Buffer | string, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Reads one secret line from stdin: masked with asterisk feedback on an
|
|
2
|
+
// interactive terminal, read as-is when piped. Shared by `kelviq login` (the
|
|
3
|
+
// Kelviq Server API key) and `kelviq import <source>` (the source platform's
|
|
4
|
+
// API key). Nothing here ever echoes or logs the characters that were typed.
|
|
5
|
+
//
|
|
6
|
+
// Each call opens its own readline interface on `io.stdin` and closes it
|
|
7
|
+
// before resolving. The y/N prompts in src/commands/push-shared.ts keep a
|
|
8
|
+
// different, shared interface on the same stream, so a command that needs
|
|
9
|
+
// both must read the secret FIRST and confirm afterwards: two interfaces
|
|
10
|
+
// listening at once would each receive the same line.
|
|
11
|
+
import { createInterface } from 'node:readline';
|
|
12
|
+
import { Writable } from 'node:stream';
|
|
13
|
+
export async function promptForKey(promptText, io) {
|
|
14
|
+
return io.isTTY ? readLineMasked(promptText, io) : readLinePlain(promptText, io);
|
|
15
|
+
}
|
|
16
|
+
/** Non-TTY (piped) path: read one line as-is. This is the path exercised by tests. */
|
|
17
|
+
export function readLinePlain(promptText, io) {
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
io.stdout.write(promptText);
|
|
20
|
+
const rl = createInterface({ input: io.stdin, terminal: false });
|
|
21
|
+
let resolved = false;
|
|
22
|
+
const finish = (line) => {
|
|
23
|
+
if (resolved)
|
|
24
|
+
return;
|
|
25
|
+
resolved = true;
|
|
26
|
+
rl.close();
|
|
27
|
+
resolve({ cancelled: false, value: line });
|
|
28
|
+
};
|
|
29
|
+
rl.once('line', finish);
|
|
30
|
+
rl.once('close', () => finish(''));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* TTY path: reads a line while masking echo. `readline`'s own rendering
|
|
35
|
+
* (which would include the real characters, e.g. on a backspace-triggered
|
|
36
|
+
* line refresh) is fully suppressed via a muted output stream. In its place
|
|
37
|
+
* one `*` is shown per character of the line being edited, driven by
|
|
38
|
+
* `readline`'s public `keypress` event — not a hand-rolled raw-mode reader;
|
|
39
|
+
* `readline` still owns all line editing and remains the sole source of
|
|
40
|
+
* truth for the captured value, this only decides what gets echoed.
|
|
41
|
+
*
|
|
42
|
+
* `readline`'s own `keypress` listener is registered first (inside
|
|
43
|
+
* `createInterface`), so by the time the listener below runs the key has
|
|
44
|
+
* already been applied and `rl.line` is the line as it now stands. The row
|
|
45
|
+
* of asterisks is brought to that length after every key: a typed or pasted
|
|
46
|
+
* character adds one (a paste arrives as one keypress per character, so an
|
|
47
|
+
* 80-character paste renders as 80 `*`), Backspace removes one (`\b \b`),
|
|
48
|
+
* Ctrl-U removes them all, and a key that does not change the line (Ctrl-C,
|
|
49
|
+
* Ctrl-D, an arrow) echoes nothing. No character is ever revealed.
|
|
50
|
+
*
|
|
51
|
+
* Ctrl-C (readline's `SIGINT`: the terminal is in raw mode, so no signal is
|
|
52
|
+
* raised) and Ctrl-D on an empty line (readline's `close`) cancel the prompt:
|
|
53
|
+
* the terminal is restored, a newline is written, and the promise resolves
|
|
54
|
+
* as cancelled. Without those handlers readline only pauses the stream, the
|
|
55
|
+
* promise never settles, and the process exits 0 having said nothing.
|
|
56
|
+
*/
|
|
57
|
+
export function readLineMasked(promptText, io) {
|
|
58
|
+
return new Promise((resolve) => {
|
|
59
|
+
const muted = new MutedWritable(io.stdout);
|
|
60
|
+
const rl = createInterface({ input: io.stdin, output: muted, terminal: true });
|
|
61
|
+
io.stdout.write(promptText);
|
|
62
|
+
muted.muted = true;
|
|
63
|
+
let echoed = 0;
|
|
64
|
+
// `done` guards against a real EventEmitter quirk: the Enter keystroke's
|
|
65
|
+
// own `keypress` event (str: '\n'/'\r', key.name: 'enter'/'return') is
|
|
66
|
+
// delivered to listeners in registration order, and `readline`'s own
|
|
67
|
+
// internal listener (registered first, inside createInterface above)
|
|
68
|
+
// synchronously finishes the line and invokes the `question` callback
|
|
69
|
+
// below — including our `removeListener` call — *before* this listener
|
|
70
|
+
// (registered second) gets its turn for that same emit() cycle. Node
|
|
71
|
+
// still calls already-snapshotted listeners for an in-flight emit even
|
|
72
|
+
// if one of them removed a later listener mid-cycle, so without this
|
|
73
|
+
// flag the row of asterisks would be erased as the line is submitted.
|
|
74
|
+
let done = false;
|
|
75
|
+
const onKeypress = (_str, key) => {
|
|
76
|
+
if (done)
|
|
77
|
+
return;
|
|
78
|
+
if (key?.name === 'return' || key?.name === 'enter')
|
|
79
|
+
return;
|
|
80
|
+
const length = rl.line.length;
|
|
81
|
+
if (length > echoed)
|
|
82
|
+
io.stdout.write('*'.repeat(length - echoed));
|
|
83
|
+
else if (length < echoed)
|
|
84
|
+
io.stdout.write('\b \b'.repeat(echoed - length));
|
|
85
|
+
echoed = length;
|
|
86
|
+
};
|
|
87
|
+
io.stdin.on('keypress', onKeypress);
|
|
88
|
+
// Runs once, for an answer or a cancellation: stops echoing, closes the
|
|
89
|
+
// interface (which takes the terminal out of raw mode) and ends the line
|
|
90
|
+
// the prompt was on.
|
|
91
|
+
const settle = (result) => {
|
|
92
|
+
if (done)
|
|
93
|
+
return;
|
|
94
|
+
done = true;
|
|
95
|
+
io.stdin.removeListener('keypress', onKeypress);
|
|
96
|
+
muted.muted = false;
|
|
97
|
+
rl.close();
|
|
98
|
+
io.stdout.write('\n');
|
|
99
|
+
resolve(result);
|
|
100
|
+
};
|
|
101
|
+
rl.on('SIGINT', () => settle({ cancelled: true }));
|
|
102
|
+
rl.on('close', () => settle({ cancelled: true }));
|
|
103
|
+
rl.question('', (answer) => settle({ cancelled: false, value: answer }));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export class MutedWritable extends Writable {
|
|
107
|
+
target;
|
|
108
|
+
muted = false;
|
|
109
|
+
constructor(target) {
|
|
110
|
+
super();
|
|
111
|
+
this.target = target;
|
|
112
|
+
}
|
|
113
|
+
_write(chunk, _encoding, callback) {
|
|
114
|
+
if (!this.muted)
|
|
115
|
+
this.target.write(chunk);
|
|
116
|
+
callback();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=secret-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-prompt.js","sourceRoot":"","sources":["../../src/cli-ui/secret-prompt.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,0EAA0E;AAC1E,yEAAyE;AACzE,sDAAsD;AACtD,OAAO,EAAE,eAAe,EAAY,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAiBvC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,UAAkB,EAAE,EAAkB;IACvE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACnF,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,aAAa,CAAC,UAAkB,EAAE,EAAkB;IAClE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC5B,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACjE,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE;YAC9B,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,EAA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c,SAAQ,QAAQ;IAEZ;IAD7B,KAAK,GAAG,KAAK,CAAC;IACd,YAA6B,MAA6B;QACxD,KAAK,EAAE,CAAC;QADmB,WAAM,GAAN,MAAM,CAAuB;IAE1D,CAAC;IACQ,MAAM,CAAC,KAAsB,EAAE,SAAyB,EAAE,QAAwC;QACzG,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,QAAQ,EAAE,CAAC;IACb,CAAC;CACF"}
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { initStyle } from './cli-ui/style.js';
|
|
4
4
|
import { registerDiscountCommand } from './commands/discount.js';
|
|
5
5
|
import { registerEnvCommand } from './commands/env.js';
|
|
6
|
+
import { registerImportCommand } from './commands/import/index.js';
|
|
6
7
|
import { registerInitCommand } from './commands/init.js';
|
|
7
8
|
import { registerLoginCommand } from './commands/login.js';
|
|
8
9
|
import { registerLogoutCommand } from './commands/logout.js';
|
|
@@ -24,9 +25,10 @@ program
|
|
|
24
25
|
// CLI plan 014: must be typed before the subcommand name (e.g. `kelviq
|
|
25
26
|
// --no-color push`) — a root-level option, same as `--version`/`--help`.
|
|
26
27
|
.option('--no-color', 'Disable colored output')
|
|
27
|
-
// KELVIQ_* variables
|
|
28
|
-
//
|
|
29
|
-
|
|
28
|
+
// KELVIQ_* variables, and the ones `kelviq import` sources declare, are
|
|
29
|
+
// read from `.env.local` then `.env` in the working directory (never
|
|
30
|
+
// overriding the shell), or from `--env-file` paths only.
|
|
31
|
+
.option('--env-file <path>', 'Load KELVIQ_* variables, and the ones "kelviq import" sources read, from this dotenv file instead of .env.local/.env (repeatable)', collect, [])
|
|
30
32
|
.option('--no-env-file', 'Do not read .env.local or .env from the working directory');
|
|
31
33
|
// CLI plan 014: the ONE place style.ts's singleton is initialized — after
|
|
32
34
|
// commander has parsed `--no-color` but before any command's action runs.
|
|
@@ -71,5 +73,6 @@ registerPromoteCommand(program);
|
|
|
71
73
|
registerStatusCommand(program);
|
|
72
74
|
registerWebhookCommand(program);
|
|
73
75
|
registerDiscountCommand(program);
|
|
76
|
+
registerImportCommand(program);
|
|
74
77
|
program.parseAsync(process.argv);
|
|
75
78
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,SAAS,OAAO,CAAC,KAAa,EAAE,QAAkB;IAChD,OAAO,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,OAAO;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AAC,IAAI,EAAE,CAAC;QACd,SAAS,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC;SAAM,CAAC;QACN,SAAS,CAAC;YACR,WAAW,EAAE,IAAI,CAAC,KAAK,KAAK,KAAK;YACjC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC5B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AACjC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAE/B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/commands/env.js
CHANGED
|
@@ -51,12 +51,12 @@ export function runEnvReport(io, options = {}) {
|
|
|
51
51
|
io.stdout.write(report);
|
|
52
52
|
return report;
|
|
53
53
|
}
|
|
54
|
-
/** Where the CLI read
|
|
54
|
+
/** Where the CLI read its variables from — appended to the text report so an agent can see which env file was picked up. */
|
|
55
55
|
function envFilesLine() {
|
|
56
56
|
const load = lastEnvFileLoad();
|
|
57
57
|
if (load.loaded.length === 0)
|
|
58
58
|
return 'Env files : none read';
|
|
59
|
-
const applied = load.applied.length > 0 ? ` (${load.applied.join(', ')})` : ' (no
|
|
59
|
+
const applied = load.applied.length > 0 ? ` (${load.applied.join(', ')})` : ' (no variables taken)';
|
|
60
60
|
return `Env files : ${load.loaded.join(', ')}${applied}`;
|
|
61
61
|
}
|
|
62
62
|
/** One lightweight authenticated read against `envName`'s host, reporting only whether the key was accepted. */
|
package/dist/commands/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/commands/env.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAgC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAmCnD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,EAAS,EAAE,UAAsB,EAAE;IAC9D,MAAM,MAAM,GAAG,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;IAElE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,GAAG,GAAoB;YAC3B,WAAW,EAAE,SAAS;YACtB,UAAU,EAAE,MAAM,CAAC,cAAc;YACjC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,UAAU,EAAE,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YAC1D,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACrD,CAAC;QACF,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;QAC1C,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED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E,KAAK,CAAC;SACtH,MAAM,CAAC,KAAK,EAAE,IAAgB,EAAE,EAAE;QACjC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,QAAQ,GAAG,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QACD,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { ImportSource } from './source.js';
|
|
3
|
+
export declare const IMPORT_SOURCES: readonly ImportSource[];
|
|
4
|
+
/** What bare `kelviq import` prints. */
|
|
5
|
+
export declare function renderSourceList(sources?: readonly ImportSource[]): string;
|
|
6
|
+
/**
|
|
7
|
+
* The registered source a mistyped name most likely meant, if any: the same
|
|
8
|
+
* letters with different punctuation or case (`lemonsqueezy`), a typo or two
|
|
9
|
+
* (`lemon-squeezi`), or the start of the name (`lemon`). The name itself is
|
|
10
|
+
* never accepted in its place: there is one spelling per source.
|
|
11
|
+
*/
|
|
12
|
+
export declare function suggestSource(name: string, sources?: readonly ImportSource[]): string | undefined;
|
|
13
|
+
/** What `kelviq import <something that is not a source>` prints. */
|
|
14
|
+
export declare function renderUnknownSource(args: readonly string[], sources?: readonly ImportSource[]): string;
|
|
15
|
+
export declare function registerImportCommand(program: Command, sources?: readonly ImportSource[]): void;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { lastEnvFileOrigins } from '../../core/env-file.js';
|
|
2
|
+
import { lemonSqueezy } from './lemon-squeezy.js';
|
|
3
|
+
import { runImport } from './runner.js';
|
|
4
|
+
export const IMPORT_SOURCES = [lemonSqueezy];
|
|
5
|
+
/** What bare `kelviq import` prints. */
|
|
6
|
+
export function renderSourceList(sources = IMPORT_SOURCES) {
|
|
7
|
+
const width = Math.max(...sources.map((s) => s.id.length));
|
|
8
|
+
return [
|
|
9
|
+
'Available import sources:',
|
|
10
|
+
...sources.map((s) => ` ${s.id.padEnd(width)} ${s.label}`),
|
|
11
|
+
'',
|
|
12
|
+
'Run `kelviq import <source> --help` for its flags. Start with --dry-run: nothing is saved, and the emailed report shows what a real run would do.',
|
|
13
|
+
'',
|
|
14
|
+
].join('\n');
|
|
15
|
+
}
|
|
16
|
+
function editDistance(a, b) {
|
|
17
|
+
let previous = Array.from({ length: b.length + 1 }, (_unused, i) => i);
|
|
18
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
19
|
+
const current = [i];
|
|
20
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
21
|
+
const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1);
|
|
22
|
+
current[j] = Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, substitution);
|
|
23
|
+
}
|
|
24
|
+
previous = current;
|
|
25
|
+
}
|
|
26
|
+
return previous[b.length] ?? 0;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The registered source a mistyped name most likely meant, if any: the same
|
|
30
|
+
* letters with different punctuation or case (`lemonsqueezy`), a typo or two
|
|
31
|
+
* (`lemon-squeezi`), or the start of the name (`lemon`). The name itself is
|
|
32
|
+
* never accepted in its place: there is one spelling per source.
|
|
33
|
+
*/
|
|
34
|
+
export function suggestSource(name, sources = IMPORT_SOURCES) {
|
|
35
|
+
const letters = (text) => text.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
36
|
+
const typed = letters(name);
|
|
37
|
+
if (typed === '')
|
|
38
|
+
return undefined;
|
|
39
|
+
let best;
|
|
40
|
+
for (const source of sources) {
|
|
41
|
+
const id = letters(source.id);
|
|
42
|
+
const distance = id.startsWith(typed) && typed.length >= 3 ? 0 : editDistance(typed, id);
|
|
43
|
+
if (distance <= 2 && (best === undefined || distance < best.distance))
|
|
44
|
+
best = { id: source.id, distance };
|
|
45
|
+
}
|
|
46
|
+
return best?.id;
|
|
47
|
+
}
|
|
48
|
+
/** What `kelviq import <something that is not a source>` prints. */
|
|
49
|
+
export function renderUnknownSource(args, sources = IMPORT_SOURCES) {
|
|
50
|
+
// With flags around it (`import lemonsqueezy --store 1`) the mistyped name
|
|
51
|
+
// is still the thing to report, not the flag. A flag's value is not a
|
|
52
|
+
// name, so past the first argument only a near miss counts as one.
|
|
53
|
+
const first = args[0];
|
|
54
|
+
const name = args.find((arg) => !arg.startsWith('-') && suggestSource(arg, sources) !== undefined) ?? (first?.startsWith('-') ? undefined : first);
|
|
55
|
+
if (name === undefined) {
|
|
56
|
+
return `Unknown option "${args[0] ?? ''}". Name an import source before its flags.\n${renderSourceList(sources)}`;
|
|
57
|
+
}
|
|
58
|
+
const suggestion = suggestSource(name, sources);
|
|
59
|
+
return `Unknown import source "${name}".${suggestion ? ` Did you mean "${suggestion}"?` : ''}\n${renderSourceList(sources)}`;
|
|
60
|
+
}
|
|
61
|
+
/** `--only a --only b` reads as `--only a,b`: a repeated list flag adds to the list. */
|
|
62
|
+
function joinLists(value, previous) {
|
|
63
|
+
return previous === undefined ? value : `${previous},${value}`;
|
|
64
|
+
}
|
|
65
|
+
function registerSource(group, source, io) {
|
|
66
|
+
const { credentials, locator } = source;
|
|
67
|
+
const steps = source.steps.join(', ');
|
|
68
|
+
const command = group
|
|
69
|
+
.command(source.id)
|
|
70
|
+
.description(`Start a server-side import${locator ? ` of a ${source.label} ${locator.noun}` : ` from ${source.label}`} and email a report when it finishes. ` +
|
|
71
|
+
`The ${credentials.label} is read from ${credentials.envVar} or a masked prompt, never from a flag.`);
|
|
72
|
+
if (locator)
|
|
73
|
+
command.option(locator.flag, locator.description);
|
|
74
|
+
command.option('--dry-run', 'Run the whole import without saving anything; the emailed report shows what a real run would do', false);
|
|
75
|
+
for (const extra of source.extraFlags)
|
|
76
|
+
command.option(extra.flag, extra.description);
|
|
77
|
+
command
|
|
78
|
+
.option('--only <steps>', `Run only these steps, comma-separated with no spaces: ${steps}`, joinLists)
|
|
79
|
+
.option('--skip <steps>', 'Leave these steps out, comma-separated with no spaces', joinLists)
|
|
80
|
+
// Negatable options: `publishPlans` / `publishDiscounts` are true unless the flag is passed.
|
|
81
|
+
.option('--no-publish-plans', 'Import plans as drafts to review and publish yourself; by default each imported plan is published and can be sold straight away')
|
|
82
|
+
.option('--no-publish-discounts', 'Leave imported discount codes switched off; by default they work at checkout straight away')
|
|
83
|
+
.option('--report-email <address>', "Send the report here instead of to the organization owner's email")
|
|
84
|
+
.option('--prod', 'Target the production environment instead of sandbox', false)
|
|
85
|
+
.option('--yes', 'Skip the confirmation prompt (required in non-interactive sessions, except for a dry run)', false)
|
|
86
|
+
.option('--json', 'Machine-readable output', false)
|
|
87
|
+
// The command takes no positional arguments. Commander would drop a
|
|
88
|
+
// stray one silently (`--only orders, renewals` would import only
|
|
89
|
+
// orders), so they are handed to the runner, which refuses to start.
|
|
90
|
+
.action(async (opts, self) => {
|
|
91
|
+
process.exitCode = await runImport(source, opts, io(), self.args);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export function registerImportCommand(program, sources = IMPORT_SOURCES) {
|
|
95
|
+
const io = () => ({
|
|
96
|
+
stdin: process.stdin,
|
|
97
|
+
stdout: process.stdout,
|
|
98
|
+
stderr: process.stderr,
|
|
99
|
+
isTTY: Boolean(process.stdin.isTTY),
|
|
100
|
+
envFileVars: lastEnvFileOrigins(),
|
|
101
|
+
});
|
|
102
|
+
const group = program
|
|
103
|
+
.command('import')
|
|
104
|
+
.description("Import a store from another platform. The import runs on Kelviq's servers and emails a report when it finishes.")
|
|
105
|
+
// A mistyped source leaves its flags with the group. Letting them
|
|
106
|
+
// through is what makes "unknown import source" the error, instead of
|
|
107
|
+
// "unknown option '--store'" about a flag that does exist.
|
|
108
|
+
.allowUnknownOption()
|
|
109
|
+
.action((_opts, command) => {
|
|
110
|
+
if (command.args.length > 0) {
|
|
111
|
+
process.stderr.write(renderUnknownSource(command.args, sources));
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
process.stdout.write(renderSourceList(sources));
|
|
116
|
+
});
|
|
117
|
+
for (const source of sources)
|
|
118
|
+
registerSource(group, source, io);
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/import/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,CAAC,MAAM,cAAc,GAA4B,CAAC,YAAY,CAAC,CAAC;AAEtE,wCAAwC;AACxC,MAAM,UAAU,gBAAgB,CAAC,UAAmC,cAAc;IAChF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,OAAO;QACL,2BAA2B;QAC3B,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QAC5D,EAAE;QACF,mJAAmJ;QACnJ,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,IAAI,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,EA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