@launchpad-kit/cli 0.0.0-bootstrap.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 +202 -0
- package/README.md +351 -0
- package/cli.mjs +1561 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# CLI
|
|
2
|
+
|
|
3
|
+
The `launchpad` command talks to a controller with an organization API key. It never
|
|
4
|
+
talks to Dokku. Keep this page current when commands change.
|
|
5
|
+
|
|
6
|
+
Packed as `@launchpad-kit/cli` (Node `>=22.12` or Bun, POSIX only; nothing is published yet):
|
|
7
|
+
`npm install @launchpad-kit/cli` installs the command and its dependencies, none of which are
|
|
8
|
+
bundled into it. From the repository, run `omni -i run build -p @launchpad-kit/cli` and
|
|
9
|
+
`bun apps/cli/dist/cli.mjs`.
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
launchpad login --controller <url> [--profile <name>] [--key-file <path> | --key-stdin]
|
|
13
|
+
launchpad logout
|
|
14
|
+
launchpad whoami
|
|
15
|
+
launchpad profile list | use <name>
|
|
16
|
+
launchpad org list | use <slug-or-id>
|
|
17
|
+
launchpad projects list
|
|
18
|
+
launchpad artifact upload <project-id> <archive-or-directory> [--directory]
|
|
19
|
+
launchpad app list | create <project-id> <slug>
|
|
20
|
+
launchpad app deploy <app-id> --artifact <id> [--spa] [--ttl <duration>]
|
|
21
|
+
launchpad app deployments <app-id> | shutdown <app-id> --confirm
|
|
22
|
+
launchpad deployment get <id> | events <id> [--after <sequence>] | delete <id> --confirm
|
|
23
|
+
launchpad alias list <app-id> | create <app-id> <slug> | operations <id>
|
|
24
|
+
launchpad alias promote <alias-id> <deployment-id> --expected-generation <generation> --idempotency-key <key> --confirm
|
|
25
|
+
launchpad alias withdraw <alias-id> --expected-generation <generation> --idempotency-key <key> --confirm
|
|
26
|
+
launchpad api <endpoint> [-X <method>] [-f|-F <key=value>]... [--input <file>] [-H <name:value>]... [-i] [--silent] [-q <jq-expression>] [--verbose] [--paginate [--slurp]] [--idempotency-key <key>] [--confirm]
|
|
27
|
+
launchpad api --session [--email <address>] [--password-file <path>] [--controller <url>] [--keep] [--secret-file <path>] <endpoint> ...
|
|
28
|
+
launchpad login --session --email <address> [--password-file <path>] [--controller <url>]
|
|
29
|
+
launchpad logout --session [--controller <url>]
|
|
30
|
+
launchpad org create --name <name> --slug <slug> --owner-email <address> --confirm
|
|
31
|
+
launchpad member list | add --user-email <address> --role <role> --confirm | remove <user-id> --confirm
|
|
32
|
+
launchpad invite create --to <address> --role <role> --confirm | list | revoke <invitation-id> --confirm
|
|
33
|
+
launchpad key list | issue --name <name> --scope <scope>... --expires-in-days <n> --secret-file <path> --confirm | revoke <key-id> --confirm
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Global options: `--json` (machine-readable output; errors become `{"error":{"code","message"}}` on stderr)
|
|
37
|
+
and `--profile <name>`.
|
|
38
|
+
|
|
39
|
+
- **The key is never an argument.** `login` reads it from `--key-file`, `--key-stdin`, or a hidden terminal
|
|
40
|
+
prompt, so it does not end up in shell history or the process list. Without a terminal and without one of
|
|
41
|
+
those options, it fails. `login` checks the key with the controller before saving it, and selects the
|
|
42
|
+
key's organization.
|
|
43
|
+
`--key-stdin` requires redirected input; with a terminal, omit it to use the hidden
|
|
44
|
+
prompt. File and stdin reads stop at 4096 bytes, even when a device reports size zero.
|
|
45
|
+
- **Credentials** live in `~/.config/launchpad/credentials.json` (mode 600; see `packages/client-core`).
|
|
46
|
+
For CI, set `LAUNCHPAD_CONTROLLER` and `LAUNCHPAD_API_KEY` (and optionally `LAUNCHPAD_ORG`) instead; the
|
|
47
|
+
file is not touched. Set both credential variables or neither; a partial pair is
|
|
48
|
+
rejected unless `--profile` explicitly chooses saved credentials. `LAUNCHPAD_ORG`
|
|
49
|
+
is an organization **ID**, not a slug. Without it, project listing discovers
|
|
50
|
+
the key's organization.
|
|
51
|
+
- **Exit codes:** 0 success, 1 other failure, 2 usage, 3 not logged in or the key is rejected (401/403),
|
|
52
|
+
4 not found, 5 controller unreachable, timed out or unexpected answer, 6 credential file or profile unusable,
|
|
53
|
+
7 and 8 are reserved. 130 is Ctrl-C at a password prompt, as for SIGINT; a signal during `--session` or
|
|
54
|
+
`--secret-file` exits 128 plus its number (SIGHUP 129, SIGINT 130, SIGTERM 143). Queuing a deployment or routing operation exits successfully; check status separately.
|
|
55
|
+
|
|
56
|
+
## `launchpad api`
|
|
57
|
+
|
|
58
|
+
`launchpad api <endpoint>` calls any `/api/v1` endpoint with the current profile (or
|
|
59
|
+
`LAUNCHPAD_CONTROLLER` and `LAUNCHPAD_API_KEY`) and prints the response. It is modeled on
|
|
60
|
+
`gh api`; the endpoints and their fields follow the controller's OpenAPI document (see the
|
|
61
|
+
[controller README](../controller/README.md#api-reference)) and may change. An API key
|
|
62
|
+
reaches only the endpoints a key may use; the session-only routes (organization, member,
|
|
63
|
+
invitation and key creation) answer 401 or 403. Use `--session` (below) for those.
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
launchpad api key
|
|
67
|
+
launchpad api organizations/{org}/projects -f name=Demo -f slug=demo --confirm
|
|
68
|
+
launchpad api -X POST organizations/{org}/projects --input body.json --confirm
|
|
69
|
+
launchpad api "organizations/{org}/deployments/${DEPLOYMENT_ID}/events" -X GET -F after=12 -F limit=500
|
|
70
|
+
launchpad api organizations/{org}/apps -X GET -F limit=50 --paginate
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- **Method and fields.** `-X` defaults to `GET`, or `POST` when `-f`/`-F` or `--input` is given.
|
|
74
|
+
`-f key=value` is a string, `-F` converts `true`, `false`, `null` and integers and reads
|
|
75
|
+
`@file` or `@-` (stdin). `a[b]=c` nests, `a[]=x` builds an array, a bare `a[]` is an empty
|
|
76
|
+
array. Fields are the JSON body; with `GET`/`HEAD`, or with `--input`, they become the query
|
|
77
|
+
string. `--input <file>|-` sends the file's bytes unchanged (1 MiB at most). Without a
|
|
78
|
+
`-H content-type:...` it must be JSON text; with one (for example `application/gzip`) any bytes
|
|
79
|
+
are sent as they are. A `-F k=@file` value must be UTF-8 text. Standard input can be read once.
|
|
80
|
+
- **Placeholders.** `{org}` (the selected organization, as other commands choose it) and
|
|
81
|
+
`{project}` (the nearest `launchpad.json`) are filled in the endpoint and in field values.
|
|
82
|
+
The endpoint value is encoded as one path segment. A placeholder with no value is a usage error.
|
|
83
|
+
One read of `launchpad.json` and one resolution of the profile serve both placeholders and the
|
|
84
|
+
request. `{project}` never makes a change allowed by itself: a non-`GET` still needs `--confirm`.
|
|
85
|
+
- **Output.** The body is printed (JSON is pretty-printed), `-i` first prints the status line
|
|
86
|
+
and headers, `--silent` prints no body, `--verbose` prints the request (before it is sent, so it also shows for a failed request) and the response headers
|
|
87
|
+
to stderr. The key and `Set-Cookie` are never shown, nor the value of a header `-H` would refuse. Terminal escape sequences and control
|
|
88
|
+
characters are stripped.
|
|
89
|
+
- **Paging.** `--paginate` (`GET` only) follows `Link: rel="next"` for a list and prints the
|
|
90
|
+
merged array; `--slurp` prints an array of the pages instead. A link is followed only if it
|
|
91
|
+
is on the controller's origin and names the same `/api/v1` path (with or without the path
|
|
92
|
+
prefix of the profile's controller URL), so the key is never sent
|
|
93
|
+
elsewhere; at most 1000 pages, 100000 items and 16 MiB are collected, within an overall deadline of 5 minutes (exit 5). Pass `-F limit=<n>` to page
|
|
94
|
+
(without it a list is returned whole). Events keep `after` and `limit`. `--paginate` cannot be
|
|
95
|
+
combined with `-i`.
|
|
96
|
+
- **Numbers.** Output is re-indented from the response text, so numbers and strings print
|
|
97
|
+
exactly as the controller sent them (for example `9007199254740993`, `1.0`), and `--paginate`
|
|
98
|
+
merges pages as text. A filter keeps them only when the system `jq` is 1.7 or newer; the
|
|
99
|
+
built-in engine and older `jq` read numbers as doubles and round integers above 2^53.
|
|
100
|
+
- **Filtering.** `-q, --jq <expression>` filters a JSON response; strings print raw and
|
|
101
|
+
other values as indented JSON. It uses the system `jq` when one is on `PATH`
|
|
102
|
+
(run without a shell and without your environment, expression as an argument, 10 s and
|
|
103
|
+
8 MiB limits; the filter is also run once on `null` to check it, so any filter that cannot finish on
|
|
104
|
+
`null` within the timeout, such as `input`, `repeat` or `[range(1e9)]`, is refused before the
|
|
105
|
+
request, and jq's own memory use is not limited), otherwise a built-in subset (`@elastic/micro-jq`), so advanced filters
|
|
106
|
+
(`map`, `select` with complex logic, `@csv` and others) may work only with the system `jq`.
|
|
107
|
+
The built-in engine returns one value, so it prints a stream such as `.[].slug` one
|
|
108
|
+
result per line only when the expression has an iterator (`[]` after a path) and does not
|
|
109
|
+
start with `[`; a stream in an expression that also builds values (`{a: .[].x}`) may differ. With
|
|
110
|
+
`--paginate` the filter sees the merged array (or the array of pages with `--slurp`).
|
|
111
|
+
An invalid or empty expression is refused before the request and before any placeholder lookup (exit 2); `--verbose` names the engine. If the filter fails after the request was sent (a runtime error
|
|
112
|
+
on the response), the request is not undone: the message says so and the exit code is 1.
|
|
113
|
+
- **Files.** `--input` and `-F k=@file` read regular files only (a FIFO is refused without
|
|
114
|
+
opening it) and refuse paths inside the credential store and, on Linux, under `/proc` and
|
|
115
|
+
`/sys` (which can expose the process environment). A hard link to the store's files
|
|
116
|
+
is not detected, and a symlink swapped between the path check and the open is not guarded
|
|
117
|
+
against (it would need write access to your own directories).
|
|
118
|
+
- **Idempotency.** `--idempotency-key <key>` sends the `Idempotency-Key` header, checked as in
|
|
119
|
+
`alias promote`.
|
|
120
|
+
|
|
121
|
+
Differences from `gh api`:
|
|
122
|
+
|
|
123
|
+
- The endpoint is a path under `/api/v1` only. Full URLs, `//host`, `..`, `#`, `\` and control
|
|
124
|
+
characters are refused (exit 2, nothing sent), so the key cannot go to another host. There is no
|
|
125
|
+
`--hostname`, `--cache`, `--preview`, `--template` or GraphQL.
|
|
126
|
+
- Anything but `GET` or `HEAD` needs `--confirm`, as the other changing commands do, including the
|
|
127
|
+
implicit `POST` when fields are given.
|
|
128
|
+
- `-H` refuses credential, framing, method-override and forwarding headers: `authorization`, `proxy-authorization`, `cookie`, `host`, `content-length`, `origin`, `transfer-encoding`, `connection`, `upgrade`, `idempotency-key`, `x-http-method-override`, `x-method-override`, `x-http-method`, `x-forwarded-host`, `x-forwarded-for`, `x-forwarded-proto`, `forwarded`, `proxy-connection`, `te`, `trailer`, `keep-alive`, `expect`
|
|
129
|
+
(use `--idempotency-key`). The list is the SDK's `FORBIDDEN_RAW_HEADERS`.
|
|
130
|
+
- Escape sequences are always stripped (`gh` has `--allow-escape-sequences`).
|
|
131
|
+
- `--paginate` always merges the pages of a list into one array (or one array of pages with
|
|
132
|
+
`--slurp`) and needs an endpoint that returns a list; `gh` prints each page separately.
|
|
133
|
+
- Errors follow this CLI: exit codes 2/3/4/5, `--json` error shape, and the controller's error
|
|
134
|
+
body is not printed (only its code and title). `-i` and `--verbose` therefore show response
|
|
135
|
+
headers of successful answers only.
|
|
136
|
+
|
|
137
|
+
## Session access (`--session`)
|
|
138
|
+
|
|
139
|
+
An API key cannot create organizations or manage members, invitations and keys. Those routes take
|
|
140
|
+
only the session cookie of a person's own account, and issuing a key also needs a sign-in from the
|
|
141
|
+
last 15 minutes. `launchpad api --session` signs in with an email and password and calls them. It is
|
|
142
|
+
for the instance operator (who creates organizations) and for organization owners and admins (who
|
|
143
|
+
issue keys and manage members). The controller's own role checks still decide what the account may do;
|
|
144
|
+
the operator has no access inside an organization without membership.
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
launchpad api --session --email ann@example.com -X POST organizations/ORG_ID/api-keys -f name=ci -f scopes[]=project:read -F expiresInDays=30 --confirm --secret-file ci.key
|
|
148
|
+
launchpad api --session --email op@example.com -X POST organizations -f name=Demo -f slug=demo -f ownerEmail=ann@example.com --confirm
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- **Default flow: an in-memory session.** With no saved session for the controller, the command asks
|
|
152
|
+
for the password (hidden prompt, or `--password-file`), signs in, makes its call (all pages of
|
|
153
|
+
`--paginate` share the session), and signs out. Nothing is written to disk and the session is always
|
|
154
|
+
new, so key issuance works. `--email` is required in this flow. **Sign-out is best effort:** a failed
|
|
155
|
+
sign-out prints a warning and does not change the exit code; a hard kill (SIGKILL, power loss) or an
|
|
156
|
+
unreachable controller leaves a server session that expires on its own at most 7 days after its last
|
|
157
|
+
use. On SIGINT, SIGTERM and SIGHUP the command aborts the request, signs out and exits with 128 plus
|
|
158
|
+
the signal number. After the first signal the sign-out is bounded by the 30 s transport timeout, and a
|
|
159
|
+
second signal exits at once without signing out. At the prompt the terminal is restored first, and
|
|
160
|
+
Ctrl-C there exits 130 with nothing sent.
|
|
161
|
+
- **Password input.** Never an argument or an environment variable. The prompt needs a terminal
|
|
162
|
+
(otherwise exit 2). `--password-file` must be a regular file owned by you with no group or other
|
|
163
|
+
permission bits (`chmod 600`), not a link or FIFO, at most 4096 bytes; one trailing newline is removed
|
|
164
|
+
and the password must be 12 to 128 characters.
|
|
165
|
+
- **`--keep` and `login --session`.** `api --session --keep` signs in, calls, and **saves the session**
|
|
166
|
+
instead of signing out; `launchpad login --session --email ...` does the same without a call and
|
|
167
|
+
prints the controller and email. Both always ask for credentials, even when a session is saved: they
|
|
168
|
+
sign the old server session out (a failure is a warning), then replace the entry, so a different
|
|
169
|
+
`--email` switches accounts. Later plain `api --session` calls use the saved session with no prompt;
|
|
170
|
+
`--email` may be omitted, the same email (any letter case) is accepted, a different one exits 2.
|
|
171
|
+
A saved session sends the warning "older than 15 minutes" before a key-issuing call, but the
|
|
172
|
+
controller's 403 stays the authority. A 401 deletes the entry. `launchpad logout --session` revokes
|
|
173
|
+
the session and deletes the entry even if sign-out failed (exit 0, with a warning); with no entry it
|
|
174
|
+
says so and exits 0. The result separates the two: `--json` gives `signedOut` (true only when the
|
|
175
|
+
controller signed the session out or said it was already over) and `localEntryRemoved`. If the
|
|
176
|
+
controller did not confirm, the message says it may still accept the old cookie until it expires, at
|
|
177
|
+
most 7 days after its last use.
|
|
178
|
+
- **Where it is saved, and the risk.** `session.json` beside `credentials.json` (mode 600, directory
|
|
179
|
+
700, no links, one entry per controller URL with the account email, the cookie and `savedAt`). It is
|
|
180
|
+
an **account-wide bearer credential**, valid until 7 days after its last use (the server expiry
|
|
181
|
+
slides): whoever can read the file can do everything that user can. The password is never stored.
|
|
182
|
+
`--keep` is opt-in; revoke with `logout --session`. If you remove this feature, delete `session.json`.
|
|
183
|
+
The key-only commands, the MCP server and older CLIs never read it.
|
|
184
|
+
- **Never with a key.** `--session` is refused (exit 2, before any prompt or request) for `api`,
|
|
185
|
+
`login` and `logout` whenever `LAUNCHPAD_API_KEY` is set. `--session` sends only `Cookie` and
|
|
186
|
+
`Origin`, never `Authorization`, and `api` without `--session` never reads `session.json`. The
|
|
187
|
+
controller comes from, in this order: `--controller`; the explicitly chosen profile (`--profile`,
|
|
188
|
+
else the `profile` of the nearest `launchpad.json`; only its controller and organization are used, its key
|
|
189
|
+
is neither read nor sent, and its organization only when its controller is the one in use);
|
|
190
|
+
`LAUNCHPAD_CONTROLLER` (a key is not needed); `LAUNCHPAD_PROFILE`; the current profile. `{org}` needs `launchpad org use`, `launchpad.json` or `LAUNCHPAD_ORG`; there is no fallback
|
|
191
|
+
to a key's organization. The controller must be https, or http to `localhost`, `127.0.0.1` or `[::1]`;
|
|
192
|
+
redirects are refused. The URL is printed before the password prompt.
|
|
193
|
+
- **Lockout, plainly.** Each default-flow call is a new sign-in, and every sign-in attempt counts toward
|
|
194
|
+
5 per 60 s per (client address, email) and 20 per 10 minutes per email; Better Auth also limits
|
|
195
|
+
`/sign-in/email` to 5 per 60 s. More than 5 `api --session` calls a minute are throttled and **also
|
|
196
|
+
block that account's dashboard sign-in** for the window. A 429 shows the wait from `retry-after` or
|
|
197
|
+
`X-Retry-After` and the command does not wait or retry. Use `--session` occasionally; for batches use
|
|
198
|
+
`--keep` (one sign-in) and then `logout --session`. A 400 `client-address-unavailable` is a plain
|
|
199
|
+
error: the controller could not tell the client address.
|
|
200
|
+
- **`forbidden-origin`.** The controller accepts a changing request with a cookie only from the exact
|
|
201
|
+
origin in its `LAUNCHPAD_BASE_URL`; an http/https or proxy-host mismatch looks like a 403
|
|
202
|
+
`forbidden-origin`, and the error says so.
|
|
203
|
+
- **Showing an issued key.** `api` hides `lp_...` text, so a created key would not be visible.
|
|
204
|
+
`--secret-file <path>` writes the response's `secret` to a new file: it is created exclusively with
|
|
205
|
+
mode 600 **before** the request (an existing file means nothing is sent), removed if the request fails
|
|
206
|
+
or returns no `secret`, and the screen shows `lp_[redacted]`. If the write fails after the key was
|
|
207
|
+
created, the error says the key exists and must be revoked in the dashboard or with `api`. It cannot be
|
|
208
|
+
combined with `--paginate`. SIGINT, SIGTERM and SIGHUP remove an empty secret file before exiting, with
|
|
209
|
+
or without `--session` (also for a kept session and while stdin is still being read); a file that
|
|
210
|
+
already holds the key is kept. The copy of the response given to `--jq` and to the screen has the key
|
|
211
|
+
replaced (built from the parsed JSON, so any escaping of the key is covered; the copy is re-serialized, so
|
|
212
|
+
number formatting may differ), so a filter cannot print part of it; only the file gets the original. **Limit:** the file is
|
|
213
|
+
removed by path after a device and inode check, and Node cannot make that atomic: someone who can
|
|
214
|
+
already write to the owner-only directory could swap the path between the check and the removal (a
|
|
215
|
+
swapped symlink is removed itself, never followed).
|
|
216
|
+
- A sign-in that was accepted (200 with a session cookie) but whose body never finished arriving still
|
|
217
|
+
has its session signed out at the end.
|
|
218
|
+
- The cookie and password are removed from errors, `--verbose` output and response headers and bodies,
|
|
219
|
+
and from the output filter (`safeOutput`) for the current run.
|
|
220
|
+
- A runner with a password file can still sign in with `--session`; that is the user's choice.
|
|
221
|
+
|
|
222
|
+
## Organization commands (session-only)
|
|
223
|
+
|
|
224
|
+
Dedicated commands for the actions a key cannot reach, so you do not hand-write
|
|
225
|
+
`launchpad api --session -X POST ...`. Each is **one API call** with your own account's session (the same
|
|
226
|
+
sign-in as `api --session`, below), follows the controller's OpenAPI document and may change with it, and
|
|
227
|
+
never prints a secret. More verbs need a new plan.
|
|
228
|
+
|
|
229
|
+
Shared by every command in this group:
|
|
230
|
+
|
|
231
|
+
- **Account and session:** `--email` (the signing-in account; optional with a saved session, a different one
|
|
232
|
+
exits 2), `--password-file`, `--keep`, `--controller` and the global `--profile` and `--json` mean what they
|
|
233
|
+
mean for `api --session`, including the lockout (each run without `--keep` or a saved session is a new
|
|
234
|
+
sign-in; more than 5 a minute also block that account's dashboard sign-in; for batches use `--keep`, then
|
|
235
|
+
`logout --session`).
|
|
236
|
+
- **Never with a key:** with `LAUNCHPAD_API_KEY` set every command exits 2 before any prompt or request, and no
|
|
237
|
+
`Authorization` header is ever sent.
|
|
238
|
+
- **`--org <id>`** (every command but `org create`) takes the organization's **ID** (a UUID), never a slug.
|
|
239
|
+
Order: `--org`, the nearest `launchpad.json` `organization`, `LAUNCHPAD_ORG`, the selected profile's
|
|
240
|
+
organization. A value that is not UUID-shaped (a slug, an empty value) exits 2 before any sign-in; find the
|
|
241
|
+
ID in the dashboard or with `launchpad api --session organizations` (`org list` needs a key you may not
|
|
242
|
+
have). Unlike `api`, which resolves a slug in `launchpad.json` with `GET /organizations`, these commands do
|
|
243
|
+
no lookup, so a slug in `launchpad.json` or the profile is refused.
|
|
244
|
+
- **`--confirm`** is required by every command that changes something (all but the `list` commands); without it
|
|
245
|
+
the command exits 2 before any prompt or request.
|
|
246
|
+
- **`Acting as <email> on <controller>, organization <id>`** goes to stderr once, after sign-in (or from a kept
|
|
247
|
+
session's stored email) and before the first request, never to stdout, so `--json` stays machine-clean. With
|
|
248
|
+
the default flow the sign-in has already happened by then, so it is an audit trail, and a real check only for
|
|
249
|
+
a kept session, where nothing is asked first. It is not an interrupt: `--confirm` is the intent check.
|
|
250
|
+
Without `--email`, a saved session of another account is used: run `launchpad logout --session` first if
|
|
251
|
+
that is not the account you mean to act as.
|
|
252
|
+
- **Output:** a table (headers first, `No <things>.` when empty) or, with `--json`, the response as JSON. Exit
|
|
253
|
+
codes are the usual ones; 409, 422 and 502 exit 1 with the controller's message.
|
|
254
|
+
|
|
255
|
+
### Organizations and members
|
|
256
|
+
|
|
257
|
+
```sh
|
|
258
|
+
launchpad org create --email op@example.com --name Demo --slug demo --owner-email ann@example.com --confirm
|
|
259
|
+
launchpad member list --org ORG_ID
|
|
260
|
+
launchpad member add --org ORG_ID --user-email bob@example.com --role deployer --confirm
|
|
261
|
+
launchpad member remove USER_ID --org ORG_ID --confirm
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
- **`org create`** (`POST /organizations`) needs the instance operator's account (anyone else gets 403, exit
|
|
265
|
+
3). The owner must be an existing user, and one whose email address is verified or that the operator provisioned (otherwise 422, exit 1: invite the address instead), a duplicate slug is 409 (exit 1), and the operator gets
|
|
266
|
+
no membership. It takes no `--org`. It prints `Created organization <slug> (<id>) with owner <email>.`
|
|
267
|
+
- **`member list`** (`GET /organizations/:org/members`; any member) prints `USER ID EMAIL NAME ROLE`. A key
|
|
268
|
+
holder can already read members with `launchpad api`; the command is here because `member remove` needs the
|
|
269
|
+
user ID it prints.
|
|
270
|
+
- **`member add`** (`POST /organizations/:org/members`) adds an **existing** user by `--user-email` with a
|
|
271
|
+
`--role` of `owner`, `admin`, `deployer` or `viewer`. Owners and admins may add; an admin may assign only
|
|
272
|
+
deployer and viewer (the controller answers 403, exit 3). Already a member is 409 (exit 1). An unknown email is 422 "No user has that email address.", and so is an account whose email is unverified and not operator-provisioned (invite it instead) (exit 1). The target is
|
|
273
|
+
`--user-email` because `--email` is always the account that signs in.
|
|
274
|
+
- **`member remove`** (`DELETE /organizations/:org/members/:userId`) takes the user ID `member list` prints.
|
|
275
|
+
Owners and admins may remove anyone; a member may remove themselves (leaving is not special-cased). Removing
|
|
276
|
+
the last owner is 409 (exit 1).
|
|
277
|
+
|
|
278
|
+
### Invitations
|
|
279
|
+
|
|
280
|
+
```sh
|
|
281
|
+
launchpad invite create --org ORG_ID --to carol@example.com --role viewer --confirm
|
|
282
|
+
launchpad invite list --org ORG_ID
|
|
283
|
+
launchpad invite revoke INVITATION_ID --org ORG_ID --confirm
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
- **`invite create`** (`POST /organizations/:org/invitations`; owner or admin) emails the invitation. The
|
|
287
|
+
controller needs invitation enrollment and SMTP: without them it answers 404 "Invitations are not enabled."
|
|
288
|
+
(exit 4); if the mail cannot be sent it answers 502 (exit 1) and has already revoked the invitation. A newer
|
|
289
|
+
invitation to the same address replaces the older one. The output is `Invited <email> as <role> (<id>). The
|
|
290
|
+
invitation was emailed.` The token is only in the email: it is never printed, and `--json` shows only `id`,
|
|
291
|
+
`email` and `role`. The target is `--to` because `--email` is always the account that signs in.
|
|
292
|
+
- **`invite list`** (`GET /organizations/:org/invitations`; owner or admin) prints the pending invitations as
|
|
293
|
+
`ID EMAIL ROLE CREATED EXPIRES`.
|
|
294
|
+
- **`invite revoke`** (`DELETE /organizations/:org/invitations/:id`; owner or admin) takes the ID `invite list`
|
|
295
|
+
prints.
|
|
296
|
+
- Not included: `invite preview` and `invite accept` (the public token flow).
|
|
297
|
+
|
|
298
|
+
### Key management
|
|
299
|
+
|
|
300
|
+
```sh
|
|
301
|
+
launchpad key list --org ORG_ID
|
|
302
|
+
launchpad key issue --org ORG_ID --name ci --scope project:read --scope app:deploy --expires-in-days 30 --secret-file ci.key --confirm
|
|
303
|
+
launchpad key revoke KEY_ID --org ORG_ID --confirm
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
- **`key list`** (`GET /organizations/:org/api-keys`; owner or admin) prints `ID NAME PREFIX STATUS SCOPES PROJECTS
|
|
307
|
+
EXPIRES LAST USED`, never a secret.
|
|
308
|
+
- **`key issue`** (`POST /organizations/:org/api-keys`; owner or admin **signed in within the last 15
|
|
309
|
+
minutes**) takes `--scope` (repeatable, from the controller's scope list), `--project <uuid>` (repeatable,
|
|
310
|
+
not with `project:create`), `--expires-in-days` (1 to 365, required) and `--secret-file` (required: an `lp_...`
|
|
311
|
+
key is hidden everywhere, so an unwritten one would be lost). The file is created exclusively with mode 600
|
|
312
|
+
before the request (an existing file means nothing is sent) and receives the secret as soon as the answer
|
|
313
|
+
arrives, before the rest of the answer is read; the screen shows only `Issued key <name> (<id>), expires
|
|
314
|
+
<date>. The secret is in <file>.` and `--json` shows the secret as `"[written to <file>]"`. At 100 active keys
|
|
315
|
+
the controller answers 409 (exit 1).
|
|
316
|
+
- **When the answer is unclear.** If the request was sent and the result is a 408, 429, any 5xx, a dropped
|
|
317
|
+
connection, a timeout, a signal or an answer without a `secret`, the key **may exist**: the file is removed and
|
|
318
|
+
the error ends with `The key may exist: run "launchpad key list" and revoke it.` A 400, 403, 404, 409 or 422
|
|
319
|
+
means the controller refused; the file is removed and no key exists. If the secret was received but the rest
|
|
320
|
+
of the answer could not be read, the file keeps the secret and a warning says the key exists. If the write
|
|
321
|
+
fails after the key was created, the error says it exists and must be revoked.
|
|
322
|
+
- **A kept session goes stale** for `key issue` after 15 minutes: the command prints a warning first and the
|
|
323
|
+
controller's 403 "Sign in again to do this." exits 3; run `launchpad login --session` again. A 401 from
|
|
324
|
+
a kept session that has expired is a refusal too: the saved session is removed, the exit code is 3 and no key
|
|
325
|
+
exists, so there is no "may exist" message.
|
|
326
|
+
- **`key revoke`** (`DELETE /organizations/:org/api-keys/:id`; owner or admin; repeating it is fine) takes the ID
|
|
327
|
+
`key list` prints.
|
|
328
|
+
|
|
329
|
+
## Workspace file
|
|
330
|
+
|
|
331
|
+
App, deployment, alias and artifact commands read the nearest `launchpad.json` for profile and
|
|
332
|
+
organization context (see [workspace resolution](../mcp/README.md#project-context)). An explicit
|
|
333
|
+
`--profile` wins. Pass exact IDs for the affected project or resource; a workspace file's `project`
|
|
334
|
+
does not select a mutation target. Other CLI commands use the saved profile or environment.
|
|
335
|
+
|
|
336
|
+
The old `deploy`, `previews` and `deployments` commands are gone. `app deploy` queues an immutable
|
|
337
|
+
deployment and does not promote it. Roll back via `alias promote` with an older retained deployment.
|
|
338
|
+
Reuse the same idempotency key and generation for a retry of the exact same routing request.
|
|
339
|
+
See the [deployment walkthrough](../../docs/deployments.md). The old `name` field of `launchpad.json`
|
|
340
|
+
is no longer accepted.
|
|
341
|
+
|
|
342
|
+
- Output and errors hide anything shaped like a key and strip terminal escape
|
|
343
|
+
sequences/control bytes. Serialized JSON stays valid.
|
|
344
|
+
- If the credential store reports `store-busy` (exit 6), wait for other commands
|
|
345
|
+
to finish and retry. After a crashed writer, remove `credentials.json.lock`
|
|
346
|
+
only after confirming no client is writing. Locks are never stolen by age.
|
|
347
|
+
|
|
348
|
+
`src/program.ts`, `src/api-command.ts` and the session files (`src/session-*.ts`, `src/password.ts`) hold the commands behind an `Io` interface (`src/io.ts`), so tests drive `run(argv, io)` with a
|
|
349
|
+
fake terminal, a temporary config directory and a fake controller. `src/index.ts` is the entry point: it starts with a node shebang, which Bun ignores when it runs the source.
|
|
350
|
+
|
|
351
|
+
Build and check commands are in [CONTRIBUTING.md](../../CONTRIBUTING.md).
|