@ appshell/ cli (英语)
与 Appshell 和 Webpack 模块 Federation 一起建设微前端的功能.
工作实例可见于此 这里。 。 。 .
开始
开始,你需要安装 @appshell/cli数字 :
npm install @appshell/cli --save-dev
或者说
yarn add -D @appshell/cli
或者说
pnpm add -D @appshell/cli
使用量
appshell [command]
Commands:
appshell generate [target] Generates a resource
appshell config [target] Configures the appshell cli
appshell app <target> Manage appshell applications
appshell dev Point an application at this package running
locally, for this browser only
appshell login Authenticate with an appshell registry
appshell logout Discard the stored credential for a registry
appshell publish Publish a package to the appshell registry
appshell unpublish <name> <version> Remove a published package version, restorable for
the registry's window (30 days by default)
appshell restore <name> <version> Bring back an unpublished version inside its window
appshell purge <name> <version> Drop an unpublished version's content for good
(needs --yes)
appshell trust Trust CI workflows to publish into a scope, or
workloads to apply its applications, without a
stored secret
appshell outdated Analyzes shared dependencies for outdated versions
这些全局选项适用于每个命令:
| 选项 | 默认 | 目的 |
|---|---|---|
-r, --registry | http://localhost:7070 | 书记官处 |
-a, --application | —— 说 | 应用程序, 如 name 或者说 scope/name |
--scopeId | default | 拥有不合格软件包和应用程序的范围 |
-k, --apiKey | "" | Api 密钥, 当登记册需要时 |
-v, --verbose | false | Verbose 输出 |
--registry 财务报告和审定财务报表 --application 倒计时 APPSHELL_REGISTRY 编号 :
APPSHELL_APPLICATION,然后改为 ~/.appshell/config设置它们一次而不是
每次都会通过他们:
appshell config set registry http://localhost:7070
appshell config set application storefront
appshell config list
词汇
| 任期 | 身份 | 这是什么 |
|---|---|---|
| 范围 | acme | 命名空间和权限边界 |
| 软件包 | acme/[email protected] | 你所发表的。 不可改变、处理摘要 |
| 应用 | acme/storefront | 登记册服务的组成 |
| 远程 | PingModule/Ping | 浏览器装入什么,超过模块联盟 |
认证
appshell login # device flow against the configured issuer
appshell login --clientSecret ... # client credentials, for CI
appshell logout
代币按登记簿存储. 正在运行的注册 AUTH_MODE=none 不需要钱..
命令只当注册员说失败时才会失败,一个401命令您登录.
APPSHELL_TOKEN 覆盖存储的证书。 一个 GitHub 动作任务可以发布
也没有,看 受托出版。 。 。 .
发布软件包
appshell publish --template dist/appshell.template.json
出版为一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一作一.
拒绝现有版本下的不同内容,除非登记处允许
强迫 何时 --application 解决, 也发布 激活 那边的版本.
| 选项 | 省略时 | 目的 |
|---|---|---|
-t, --template | appshell.template.json | 要处理的模板 |
--name | 未扫描 package.json 名称 | 软件包名称 |
--package-version | 页:1 package.json 版本 | 要公布的版本为 |
--visibility | 注册默认为 private | 其他范围是否可以激活它 |
-w, --watch | false | 当模板被更改时, 重新组合 |
appshell unpublish checkout 1.5.0
不出版则从每个读取的版本中取出,但登记处保留其内容为: 窗口中,30天,除非它另作配置。 它拒绝应用程序的版本 启动。 输出说到版本可以恢复为止,以及如何:
appshell packages unpublished checkout # what can still be restored, and until when
appshell restore checkout 1.5.0 # back exactly as it was, same digest
appshell purge checkout 1.5.0 --yes # gone for good; only after an unpublish
该版本的坐标停留无论用哪一种方式:同一版本无法再被发布 和其他内容.
受托出版
一个 GitHub 动作工作流程可以发布到具有自身 OIDC 特性的范围,所以没有 秘密存放在任何地方。 范围所有人——或一个组织的管理人员,范围 组织拥有——可能用于下列工作流程的记录:
appshell trust add acme --github acme/widgets --workflow pipeline.yml --environment production
appshell trust list acme
appshell trust remove acme 1b2c3d4e # the id as `list` shows it
trust add 在 GitHub 上查找存储器, 并用其不可改变的 ID 记录它,所以
重新命名或转移寄存器,或采用旧名的新寄存器不会继承
信任。 信赖。 设定 GITHUB_TOKEN (或 GH_TOKEN寻找一个私人仓库; --github-api https://<host>/api/v3 财务报告和审定财务报表 --issuer 覆盖 GitHub 企业服务器。 命名为
--environment 建议:其保护规则随后决定哪些分支和
审查人员可以发布.
工作流程需要 id-token: write 和登记地址,没有别的:
permissions: { id-token: write, contents: read }
env: { APPSHELL_REGISTRY: https://registry.appshell.org }
jobs:
publish:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
# ...build...
- run: npx appshell publish
没有 APPSHELL_TOKEN 并且没有存储的登记簿, appshell publish 询问
运行一个标志,其受众为所配置的登记器 url,没有线索
斜线——登记处 TRUSTED_PUBLISHING_AUDIENCE 必须是准确的,并呈现
为了那个请求 每一个发布薄荷本身,没有被存储. 明确
APPSHELL_TOKEN 或存储的登录胜出,所以将一个发布作为账户的工作.
包必须命名其范围, 如 @acme/widgets: 工作流程中没有其命名空间
拥有的。 拒绝说要检查什么.. appshell trust list <scope> 和这份工作
环境,或登记处未启用可信任的出版,在这种情况下
发布一次无符号的重试,用于不需要的注册(AUTH_MODE=none) (中文(简体) ).
宣布申请
appshell app apply 以已宣布的资源对应用程序进行调节,创建
当它缺席。 它是声明的对应物 app create 加号 publish --application,而同一文件通过 --registry。 。 。 .
appshell.app.yaml (英语)
apiVersion: registry.appshell.org/v1
kind: Application
name: storefront
spec:
shell:
root: ContainerModule/Container
title: Storefront
packages:
- acme/[email protected]
- acme/[email protected]
appshell app apply -f appshell.app.yaml
spec.packages 这是 完整想要的一组 - 任何激活但缺失的东西
已关闭, 命令打印移动的内容 :
Updated acme/storefront
activated acme/[email protected]
deactivated acme/search
奥米 spec.packages 完全和软件包状态单独存在,这是你想要的
本地的 webpack 插件已经发布并激活了每个架构.
${VAR} 占地者在环境中的扩张 与他们在
appshell.config.yaml。 。 。 .
受托部署
工作量可以用自己的OIDC身份应用应用程序,所以任务或控制器 即GitHub动作工作流程,或 a Kubernetes服务账户。 申请的范围拥有者或管理机构, (b) 记录哪些工作量——申请必须先存在:
# A GitHub Actions workflow, by repository ids as for publishing
appshell trust add acme --application storefront \
--github acme/deploy --workflow deploy.yml --environment production
# A Kubernetes service account, under its cluster's OIDC issuer
appshell trust add acme --application storefront \
--kubernetes https://oidc.eks.us-east-1.amazonaws.com/id/EXAMPLE \
--namespace appshell --service-account deployer
appshell trust list acme --application storefront
appshell trust remove acme 1b2c3d4e --application storefront
分组发行商被完全照搬,必须是分组的服务
账户代号所携带的(kubectl get --raw /.well-known/openid-configuration 打印出来。 这个
注册处从那里取出其密钥,所以发行者的发现文件必须公开:
EKS,GKE和AKS服务于一个,一个自我管理的集群必须发布自己的发现
公开https地址的文档和密钥.
从 GitHub 动作,与 id-token: write 没有 APPSHELL_TOKEN 或存储登录,
appshell app apply 向跑者询问登记员的部署对象的标志
注册 url 与 /deploy,或 APPSHELL_DEPLOY_AUDIENCE 当登记册的操作员设置时
TRUSTED_DEPLOYMENT_AUDIENCE 适用于其他事物——并适用于:
permissions: { id-token: write, contents: read }
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- run: npx appshell app apply -f appshell.app.yaml --registry https://registry.appshell.org
从库伯内特给观众投出一个符号 进入舱内,像运行 信任的服务账户,并提交同一登记册:
spec:
serviceAccountName: deployer
containers:
- name: apply
# ...
volumeMounts:
- name: appshell-token
mountPath: /var/run/appshell
readOnly: true
volumes:
- name: appshell-token
projected:
sources:
- serviceAccountToken:
audience: https://registry.appshell.org/deploy
expirationSeconds: 3600 # at most an hour is accepted
path: token
APPSHELL_TOKEN=$(cat /var/run/appshell/token) \
appshell app apply -f appshell.app.yaml --registry https://registry.appshell.org
工作量只可适用,只适用已经存在的应用程序,而且只适用以下列名称命名的应用程序:
scope/name 在资源,因为它没有自己的范围。 拒绝会说什么
检查 : appshell trust list <scope> --application <name> 工作或账户,或
观众设置。 在没有可信部署的情况下使用登记册
(单位:千美元)AUTH_MODE=none每一个当地人,一次重复一次,没有符号.
检查应用程序
appshell app list # every application in the scope
appshell app get storefront # packages, revision, visibility
appshell app composition storefront # the resolved payload the shell receives
appshell app revisions storefront # revision history
appshell app rollback storefront --to 3
appshell app open storefront # print the shell url
每次变异都会产生修正 所以 revisions 是审计线索 rollback
这就是你如何取消一个.
appshell app create storefront # imperative equivalent of a bare apply
appshell app delete storefront
appshell app deactivate acme/checkout
appshell app clone --from prod --to my-sandbox
appshell app sync --from prod --to staging --include packages
克隆人从不继承其源代码的权限来接取重叠. 问它与
--allow-overlays,而副本是你的 指向你的机器与 appshell dev数字 :
appshell app clone --from appshell/appshell-example --to <scope>/example --allow-overlays
对照已部署的应用程序开发
appshell dev 打开一个 覆盖:每个开发者,每个浏览器重定向点数
一些应用程序的远程 在你的机器。 按要求解决,期满
并且从未达到申请的构成或修订历史.
appshell dev --port 3002 # redirect this package's remotes at localhost:3002
appshell dev status # what is open on the application
appshell dev stop --package # stop redirecting just this package
appshell dev stop <id> # close one, or --all
覆盖只能重定向应用程序已发布的远程密钥 – 添加 一个直接的就是运行代码的方法 应用程序从来没有编配。 对a 新软件包,先发布并激活,或者在克隆中工作.
--shell dev 支持开发的外壳构建
热重装遥控器到位 .
分析共享依赖
appshell outdated
将这个软件包的依赖性与共享依赖性基线相比较 应用程序宣布并报告冲突、缺少条目和匹配.
生成显示
将模板处理成一个appshell 运算表 . appshell publish 这样做是为了你;
直接运行它,当你想要的 清单作为建筑文物.
appshell generate manifest --template dist/appshell.template.json
| 选项 | 默认 | 目的 |
|---|---|---|
-t, --template | appshell.template.json | 要处理的模板 |
-o, --outDir | dist | 产出地点 |
-f, --outFile | appshell.manifest.json | 输出文件名 |
模板从何而来?
每个微前端配置 @appshell/webpack-plugin (英语) 发射
appshell.template.json在建设时间.appshell publish把它变成一个 显示并出版为包版.
样本配置模板 appshell.template.json数字 :
{
"remotes": {
"CraModule/App": {
"url": "${CRA_MFE_URL}",
"metadata": {
"route": "/cra",
"displayName": "Example App",
"displayGroup": "${CRA_MFE_DISPLAY_GROUP}",
"order": 10,
"icon": "ViewList"
},
"id": "3eb81a0c"
}
},
"module": {
"exposes": {
"./App": "./src/App"
},
"filename": "remoteEntry.js",
"name": "CraModule",
"shared": {
"react": {
"singleton": true,
"requiredVersion": "^18.2.0"
},
"react-dom": {
"singleton": true,
"requiredVersion": "^18.2.0"
}
}
},
"vars": {
"RUNTIME_ARG_1": "${RUNTIME_ARG_1}",
"RUNTIME_ARG_2": "${RUNTIME_ARG_2}"
}
}
我的运行时间环境如何在应用软件显示中反映出来?
注意变量扩展语法
${CRA_MFE_URL}时appshell generate manifest被称作实际运行时环境值被注入,以生成远程模块的appshell显示.
说明 页:1
vars定义运行时配置值getVars()从@appshell/runtime/vars一旦装入。 软件包必须共享@appshell/runtime作为接收他们的单子 见一用例.
应用壳样品清单 appshell generate manifest 函数 :
{
"remotes": {
"CraModule/App": {
"id": "3eb81a0c",
"url": "http://localhost:3001/remoteEntry.js",
"scope": "CraModule",
"module": "./App",
"metadata": {
"route": "/cra",
"displayName": "Example App",
"displayGroup": "primary",
"order": 10,
"icon": "ViewList"
}
},
"VanillaModule/Vanilla": {
"id": "8232ce86",
"url": "http://localhost:3002/remoteEntry.js",
"scope": "VanillaModule",
"module": "./Vanilla",
"metadata": {
"route": "/vanilla",
"displayName": "Example React App",
"displayGroup": "primary",
"order": 10,
"icon": "ViewList"
}
}
},
"modules": {
"Appshell": {
"name": "Appshell",
"shared": {
"react": {
"singleton": true,
"requiredVersion": "^18.2.0"
},
"react-dom": {
"singleton": true,
"requiredVersion": "^18.2.0"
}
}
},
"CraModule": {
"exposes": {
"./App": "./src/App"
},
"filename": "remoteEntry.js",
"name": "CraModule",
"shared": {
"react": {
"singleton": true,
"requiredVersion": "^18.2.0"
},
"react-dom": {
"singleton": true,
"requiredVersion": "^18.2.0"
}
}
},
"VanillaModule": {
"exposes": {
"./Vanilla": "./src/App"
},
"filename": "remoteEntry.js",
"name": "VanillaModule",
"shared": {
"react": {
"singleton": true,
"requiredVersion": "^18.2.0"
},
"react-dom": {
"singleton": true,
"requiredVersion": "^18.2.0"
}
}
}
},
"vars": {
"CraModule": {
"RUNTIME_ARG_1": "Foo",
"RUNTIME_ARG_2": "Biz"
},
"VanillaModule": {
"RUNTIME_ARG_1": "Bar"
}
}
}
appshell publish 将此列表作为软件包版本发送给注册处。 这个
登记册将每个活化包装入其供壳使用的有效载荷.