@appshell/cli

中文文档
1.0.0-alpha.148发布于 2026/10/30MITCommonJS构建来源已验证近 30 天下载 6117

cli 用于为模块 federation 微前端生成全球应用软件的工具

中文使用文档
文档目录12 节
  1. 开始
  2. 使用量
  3. 词汇
  4. 认证
  5. 发布软件包
  6. 受托出版
  7. 宣布申请
  8. 受托部署
  9. 检查应用程序
  10. 对照已部署的应用程序开发
  11. 分析共享依赖
  12. 生成显示

Appshell CI

@ 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, --registryhttp://localhost:7070书记官处
-a, --application—— 说应用程序, 如 name 或者说 scope/name
--scopeIddefault拥有不合格软件包和应用程序的范围
-k, --apiKey""Api 密钥, 当登记册需要时
-v, --verbosefalseVerbose 输出

--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, --templateappshell.template.json要处理的模板
--name未扫描 package.json 名称软件包名称
--package-version页:1 package.json 版本要公布的版本为
--visibility注册默认为 private其他范围是否可以激活它
-w, --watchfalse当模板被更改时, 重新组合
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, --templateappshell.template.json要处理的模板
-o, --outDirdist产出地点
-f, --outFileappshell.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 将此列表作为软件包版本发送给注册处。 这个 登记册将每个活化包装入其供壳使用的有效载荷.

版本与发布记录

@appshell/cli 共发布 220 个版本,首次发布于 2023/03/04;过去 12 个月发布了 142 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0-alpha.148latest2026/10/309 天前
1.0.0-alpha.1472026/10/2910 天前
1.0.0-alpha.1462026/10/2810 天前
1.0.0-alpha.1452026/10/2810 天前
1.0.0-alpha.1442026/10/2712 天前
1.0.0-alpha.1432026/10/2613 天前

关于 @appshell/cli 的常见问题

@appshell/cli 是什么?

cli 用于为模块 federation 微前端生成全球应用软件的工具

如何安装 @appshell/cli?

在项目目录运行 npm install @appshell/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 appshell,可以用 npx appshell 直接运行。

@appshell/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/appshell__cli 是否存在。

@appshell/cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@appshell/cli 可以商用吗?

@appshell/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@appshell/cli 的下载量有多少?

根据 npm 官方下载统计,@appshell/cli 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,117 次,日均约 204 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appshell/cli 还在维护吗?

最新版本 1.0.0-alpha.148 发布于 2026/10/30(9 天前);至今共发布 220 个版本,其中过去 12 个月发布了 142 个;首次发布于 2023/03/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。