@appshell/cli 1.0.0-alpha.8 → 1.0.0-alpha.81
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 +170 -100
- package/dist/main.js +9 -9
- package/dist/main.js.LICENSE.txt +39 -0
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -41,51 +41,192 @@ pnpm add -D @appshell/cli
|
|
|
41
41
|
appshell [command]
|
|
42
42
|
|
|
43
43
|
Commands:
|
|
44
|
-
appshell generate [target]
|
|
45
|
-
appshell
|
|
46
|
-
appshell
|
|
44
|
+
appshell generate [target] Generates a resource
|
|
45
|
+
appshell config [target] Configures the appshell cli
|
|
46
|
+
appshell app <target> Manage appshell applications
|
|
47
|
+
appshell dev Point an application at this package running
|
|
48
|
+
locally, for this browser only
|
|
49
|
+
appshell login Authenticate with an appshell registry
|
|
50
|
+
appshell logout Discard the stored credential for a registry
|
|
51
|
+
appshell publish Publish a package to the appshell registry
|
|
52
|
+
appshell unpublish <name> <version> Remove a published package version
|
|
53
|
+
appshell outdated Analyzes shared dependencies for outdated versions
|
|
47
54
|
```
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
These global options apply to every command:
|
|
57
|
+
|
|
58
|
+
| Option | Default | Purpose |
|
|
59
|
+
| ------ | ------- | ------- |
|
|
60
|
+
| `-r, --registry` | `http://localhost:7070` | Registry to operate against |
|
|
61
|
+
| `-a, --application` | — | Application, as `name` or `scope/name` |
|
|
62
|
+
| `--scopeId` | `default` | Scope owning unqualified packages and applications |
|
|
63
|
+
| `-k, --apiKey` | `""` | Api key, when the registry expects one |
|
|
64
|
+
| `-v, --verbose` | `false` | Verbose output |
|
|
65
|
+
|
|
66
|
+
`--registry` and `--application` fall back to `APPSHELL_REGISTRY` /
|
|
67
|
+
`APPSHELL_APPLICATION`, then to `~/.appshell/config`. Set them once instead of
|
|
68
|
+
passing them every time:
|
|
50
69
|
|
|
51
70
|
```bash
|
|
52
|
-
appshell
|
|
71
|
+
appshell config set registry http://localhost:7070
|
|
72
|
+
appshell config set application storefront
|
|
73
|
+
appshell config list
|
|
74
|
+
```
|
|
53
75
|
|
|
54
|
-
|
|
76
|
+
## Vocabulary
|
|
55
77
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
78
|
+
| Term | Identity | What it is |
|
|
79
|
+
| ---- | -------- | ---------- |
|
|
80
|
+
| **Scope** | `acme` | Namespace and permission boundary |
|
|
81
|
+
| **Package** | `acme/checkout@1.5.0` | What you publish. Immutable, digest-addressed |
|
|
82
|
+
| **Application** | `acme/storefront` | The composition the registry serves |
|
|
83
|
+
| **Remote** | `PingModule/Ping` | What the browser loads, over Module Federation |
|
|
84
|
+
|
|
85
|
+
## Authenticating
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
appshell login # device flow against the configured issuer
|
|
89
|
+
appshell login --clientSecret ... # client credentials, for CI
|
|
90
|
+
appshell logout
|
|
61
91
|
```
|
|
62
92
|
|
|
63
|
-
|
|
93
|
+
The token is stored per registry. A registry running `AUTH_MODE=none` needs none —
|
|
94
|
+
commands only fail when the registry says so, and a 401 tells you to log in.
|
|
95
|
+
`APPSHELL_TOKEN` overrides the stored credential.
|
|
96
|
+
|
|
97
|
+
## Publishing a package
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
appshell publish --template dist/appshell.template.json
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Publishing is idempotent: the same content under the same version is a no-op.
|
|
104
|
+
Different content under an existing version is rejected unless the registry allows
|
|
105
|
+
forcing. When `--application` resolves, publish also **activates** the version there.
|
|
106
|
+
|
|
107
|
+
| Option | When omitted | Purpose |
|
|
108
|
+
| ------ | ------------ | ------- |
|
|
109
|
+
| `-t, --template` | `appshell.template.json` | Template to process |
|
|
110
|
+
| `--name` | the unscoped `package.json` name | Package name |
|
|
111
|
+
| `--package-version` | the `package.json` version | Version to publish as |
|
|
112
|
+
| `--visibility` | the registry defaults to `private` | Whether other scopes may activate it |
|
|
113
|
+
| `-w, --watch` | `false` | Republish whenever the template changes |
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
appshell unpublish checkout 1.5.0
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Declaring an application
|
|
120
|
+
|
|
121
|
+
`appshell app apply` reconciles an application against a declared resource, creating
|
|
122
|
+
it when absent. It is the declarative counterpart to `app create` plus `publish
|
|
123
|
+
--application`, and the same file works against any registry via `--registry`.
|
|
124
|
+
|
|
125
|
+
**appshell.app.yaml**
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
apiVersion: registry.appshell.org/v1
|
|
129
|
+
kind: Application
|
|
130
|
+
name: storefront
|
|
131
|
+
spec:
|
|
132
|
+
shell:
|
|
133
|
+
root: ContainerModule/Container
|
|
134
|
+
title: Storefront
|
|
135
|
+
packages:
|
|
136
|
+
- acme/checkout@1.5.0
|
|
137
|
+
- acme/cart@2.0.1
|
|
138
|
+
```
|
|
64
139
|
|
|
65
|
-
|
|
140
|
+
```bash
|
|
141
|
+
appshell app apply -f appshell.app.yaml
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
`spec.packages` is the **full desired set** — anything activated but absent from it is
|
|
145
|
+
deactivated, and the command prints what moved:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
Updated acme/storefront
|
|
149
|
+
activated acme/cart@2.0.1
|
|
150
|
+
deactivated acme/search
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Omit `spec.packages` entirely and package state is left alone, which is what you want
|
|
154
|
+
locally where the webpack plugin already publishes and activates on every build.
|
|
155
|
+
`${VAR}` placeholders expand from the environment exactly as they do in
|
|
156
|
+
`appshell.config.yaml`.
|
|
157
|
+
|
|
158
|
+
## Inspecting an application
|
|
66
159
|
|
|
67
160
|
```bash
|
|
68
|
-
appshell
|
|
161
|
+
appshell app list # every application in the scope
|
|
162
|
+
appshell app get storefront # packages, revision, visibility
|
|
163
|
+
appshell app composition storefront # the resolved payload the shell receives
|
|
164
|
+
appshell app revisions storefront # revision history
|
|
165
|
+
appshell app rollback storefront --to 3
|
|
166
|
+
appshell app open storefront # print the shell url
|
|
167
|
+
```
|
|
69
168
|
|
|
70
|
-
|
|
169
|
+
Every mutation produces a revision, so `revisions` is the audit trail and `rollback`
|
|
170
|
+
is how you undo one.
|
|
71
171
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
172
|
+
```bash
|
|
173
|
+
appshell app create storefront # imperative equivalent of a bare apply
|
|
174
|
+
appshell app delete storefront
|
|
175
|
+
appshell app deactivate acme/checkout
|
|
176
|
+
appshell app clone --from prod --to my-sandbox
|
|
177
|
+
appshell app sync --from prod --to staging --include packages
|
|
78
178
|
```
|
|
79
179
|
|
|
80
|
-
|
|
180
|
+
## Developing against a deployed application
|
|
181
|
+
|
|
182
|
+
`appshell dev` opens an **overlay**: a per-developer, per-browser redirect that points
|
|
183
|
+
some of an application's remotes at your machine. It is resolved per request, expires
|
|
184
|
+
on its own, and never reaches the application's composition or its revision history.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
appshell dev --port 3002 # redirect this package's remotes at localhost:3002
|
|
188
|
+
appshell dev status # what is open on the application
|
|
189
|
+
appshell dev stop --package # stop redirecting just this package
|
|
190
|
+
appshell dev stop <id> # close one, or --all
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
An overlay can only redirect remote keys the application already publishes — adding
|
|
194
|
+
one outright would be a way to run code the application was never composed with. For a
|
|
195
|
+
new package, publish and activate it first, or work in a clone.
|
|
196
|
+
|
|
197
|
+
`--shell dev` additionally serves the development shell build, which is what supports
|
|
198
|
+
hot reloading remotes in place.
|
|
199
|
+
|
|
200
|
+
## Analyzing shared dependencies
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
appshell outdated
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Compares this package's dependencies against the shared-dependency baselines the
|
|
207
|
+
application declares, and reports conflicts, missing entries and matches.
|
|
208
|
+
|
|
209
|
+
## Generate manifest
|
|
210
|
+
|
|
211
|
+
Processes a template into an appshell manifest. `appshell publish` does this for you;
|
|
212
|
+
run it directly when you want the manifest as a build artifact.
|
|
81
213
|
|
|
82
214
|
```bash
|
|
83
215
|
appshell generate manifest --template dist/appshell.template.json
|
|
84
216
|
```
|
|
85
217
|
|
|
86
|
-
|
|
218
|
+
| Option | Default | Purpose |
|
|
219
|
+
| ------ | ------- | ------- |
|
|
220
|
+
| `-t, --template` | `appshell.template.json` | Template to process |
|
|
221
|
+
| `-o, --outDir` | `dist` | Output location |
|
|
222
|
+
| `-f, --outFile` | `appshell.manifest.json` | Output filename |
|
|
87
223
|
|
|
88
|
-
|
|
224
|
+
**Where does the template come from?**
|
|
225
|
+
|
|
226
|
+
> Each micro-frontend configured with
|
|
227
|
+
> [@appshell/webpack-plugin](https://www.npmjs.com/package/@appshell/webpack-plugin)
|
|
228
|
+
> emits `appshell.template.json` at build time. `appshell publish` turns that into a
|
|
229
|
+
> manifest and publishes it as a package version.
|
|
89
230
|
|
|
90
231
|
Sample config template `appshell.template.json`:
|
|
91
232
|
|
|
@@ -121,7 +262,7 @@ Sample config template `appshell.template.json`:
|
|
|
121
262
|
}
|
|
122
263
|
}
|
|
123
264
|
},
|
|
124
|
-
"
|
|
265
|
+
"vars": {
|
|
125
266
|
"RUNTIME_ARG_1": "${RUNTIME_ARG_1}",
|
|
126
267
|
"RUNTIME_ARG_2": "${RUNTIME_ARG_2}"
|
|
127
268
|
}
|
|
@@ -132,7 +273,7 @@ Sample config template `appshell.template.json`:
|
|
|
132
273
|
|
|
133
274
|
> Note the variable expansion syntax `${CRA_MFE_URL}`. When `appshell generate manifest` is called the actual runtime environment values are injected in order to produce the remote module's appshell manifest.
|
|
134
275
|
|
|
135
|
-
> **Note** the `
|
|
276
|
+
> **Note** the `vars` section defines runtime configuration values a package reads with `getVars()` from [`@appshell/runtime/vars`](../runtime/README.md) once it is loaded. The package must share `@appshell/runtime` as a singleton to receive them. See the examples for a use case.
|
|
136
277
|
|
|
137
278
|
Sample appshell manifest produced by the `appshell generate manifest` function:
|
|
138
279
|
|
|
@@ -215,7 +356,7 @@ Sample appshell manifest produced by the `appshell generate manifest` function:
|
|
|
215
356
|
}
|
|
216
357
|
}
|
|
217
358
|
},
|
|
218
|
-
"
|
|
359
|
+
"vars": {
|
|
219
360
|
"CraModule": {
|
|
220
361
|
"RUNTIME_ARG_1": "Foo",
|
|
221
362
|
"RUNTIME_ARG_2": "Biz"
|
|
@@ -227,76 +368,5 @@ Sample appshell manifest produced by the `appshell generate manifest` function:
|
|
|
227
368
|
}
|
|
228
369
|
```
|
|
229
370
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
## Register a manifest
|
|
233
|
-
|
|
234
|
-
Register one or more appshell manifests with the global registry.
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
appshell register
|
|
238
|
-
|
|
239
|
-
Register one or more appshell manifests
|
|
240
|
-
|
|
241
|
-
Options:
|
|
242
|
-
--help Show help [boolean]
|
|
243
|
-
--version Show version number [boolean]
|
|
244
|
-
-m, --manifest One or more manifests to register [array]
|
|
245
|
-
-r, --registry Registry path for the appshell manifests
|
|
246
|
-
[string] [default: "appshell_registry"]
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
## Generate runtime env
|
|
250
|
-
|
|
251
|
-
Generates a runtime env js file that can be consumed by the application at runtime.
|
|
252
|
-
|
|
253
|
-
```bash
|
|
254
|
-
appshell generate env
|
|
255
|
-
|
|
256
|
-
Generate the runtime environment js file that reflects the current process.env
|
|
257
|
-
|
|
258
|
-
Options:
|
|
259
|
-
--help Show help [boolean]
|
|
260
|
-
--version Show version number [boolean]
|
|
261
|
-
-o, --outDir Output location for the appshell environment js [string] [default: "."]
|
|
262
|
-
-f, --outFile Output filename for the appshell environment js [string] [default: "appshell.env.js"]
|
|
263
|
-
-p, --prefix Only capture environment variables that start with prefix or regex [string] [default: ""]
|
|
264
|
-
-g, --globalName Global variable name window[globalName] used in the output js [string] [default: "__appshell_env__"]
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### Sample usage
|
|
268
|
-
|
|
269
|
-
```bash
|
|
270
|
-
appshell generate env --prefix APPSHELL_ --outDir dist
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
Sample output `appshell.env.js`
|
|
274
|
-
|
|
275
|
-
```js
|
|
276
|
-
window.__appshell_env__ = {
|
|
277
|
-
APPSHELL_VAR_1 = 'val 1',
|
|
278
|
-
APPSHELL_VAR_2 = 'val 2'
|
|
279
|
-
};
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Using regex to match prefix
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
appshell generate env --prefix '^(APPSHELL_|FOO_).*' --outDir dist
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Sample output `appshell.env.js`
|
|
289
|
-
|
|
290
|
-
```js
|
|
291
|
-
window.__appshell_env__ = {
|
|
292
|
-
APPSHELL_VAR_1 = 'val 1',
|
|
293
|
-
APPSHELL_VAR_2 = 'val 2',
|
|
294
|
-
FOO_VAR = 'some value'
|
|
295
|
-
};
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
Include in the public html
|
|
299
|
-
|
|
300
|
-
```html
|
|
301
|
-
<script src="appshell.env.js"></script>
|
|
302
|
-
```
|
|
371
|
+
`appshell publish` sends this manifest to the registry as a package version. The
|
|
372
|
+
registry composes every activated package into the payload it serves to the shell.
|