@bams-app/work-cli 0.0.7 → 0.0.8

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 CHANGED
@@ -4,7 +4,8 @@ BAMS-Work 全局开发工具(类似 vue-cli 模式),提供**项目初始
4
4
 
5
5
  ## 设计思路
6
6
 
7
- `work-cli` 是**薄壳**,不内嵌任何模板/服务/能力包代码,全部复用 work 仓库发布到 npm 的包:
7
+ `work-cli` 是**薄壳**,不内嵌任何服务/能力包代码(仅内嵌脚手架项目模板 `templates/project/`),
8
+ 全部复用 work 仓库发布到 npm 的包:
8
9
 
9
10
  | 能力 | 来源包 |
10
11
  | --- | --- |
@@ -34,14 +35,14 @@ BAMS-Work 全局开发工具(类似 vue-cli 模式),提供**项目初始
34
35
 
35
36
  ```mermaid
36
37
  flowchart LR
37
- subgraph WORK["work 仓库(52 个可发布包)"]
38
+ subgraph WORK["work 仓库(全部可发布包)"]
38
39
  A["能力包<br/>packages/ · ui/ · configs/"]
39
- B["开发工具<br/>cli/(ui-dev-server · create-* · template)"]
40
+ B["开发工具与模板<br/>tooling/ · templates/"]
40
41
  end
41
42
  subgraph REG["私有 registry<br/>npm.hedpy.cn"]
42
43
  C["@bams-app/*"]
43
44
  end
44
- subgraph CLI["@bams-app/work-cli(薄壳)"]
45
+ subgraph CLI["@bams-app/work-cli(全局 CLI)"]
45
46
  D["create / add / dev<br/>env / pages-entry / pages-from-components"]
46
47
  end
47
48
  subgraph PROJ["用户项目(Monorepo)"]
@@ -127,8 +128,8 @@ bams-work update
127
128
 
128
129
  所有 work 包统一发布到 npm registry,**默认官方 npm(registry.npmjs.org)**,通过环境变量
129
130
  `NPM_REGISTRY` 可随时切换到私有 registry(如 `https://npm.hedpy.cn/`)。work 下所有含
130
- `package.json` 的目录(`packages/`、`cli/`、`ui/`、`configs/` 等)都会被打包发布,
131
- `private` 包自动跳过:
131
+ `package.json` 的目录(`packages/`、`ui/`、`tooling/`、`templates/`、`cli/`、`configs/` 等)
132
+ 都会被打包发布,`private` 包自动跳过:
132
133
 
133
134
  ```bash
134
135
  # 0. 登录对应 registry(每次切换目标后需重新登录)
@@ -136,11 +137,9 @@ npm login --registry=https://registry.npmjs.org/ # 发布官方
136
137
  npm login --registry=https://npm.hedpy.cn/ # 切到私服时
137
138
 
138
139
  # 1. 在仓库根目录一键发布全部 work 包(交互式选择版本,只升不降)
140
+ # 包含 work-cli 本体(work/cli),无需单独发布
139
141
  yarn publish-all # 默认发布官方 npm
140
142
  NPM_REGISTRY=https://npm.hedpy.cn/ yarn publish-all # 发布到私服
141
-
142
- # 2. 发布 work-cli 本体(dependencies 改为 registry 版本号后)
143
- cd work-cli && npm publish
144
143
  ```
145
144
 
146
145
  ### 单包发布
@@ -151,7 +150,7 @@ cd work-cli && npm publish
151
150
  ```bash
152
151
  cd work/packages/utils && npm publish --registry=https://registry.npmjs.org/
153
152
  cd work/ui/ui-header-component && npm publish --registry=https://registry.npmjs.org/
154
- cd work/cli/create-ui-component && npm publish --registry=https://registry.npmjs.org/
153
+ cd work/tooling/create-ui-component && npm publish --registry=https://registry.npmjs.org/
155
154
  cd work/configs && npm publish --registry=https://registry.npmjs.org/
156
155
  ```
157
156
 
@@ -161,8 +160,8 @@ cd work/configs && npm publish --registry=https://registry.npmjs.org/
161
160
  能力包(`@bams-app/*`,含 `work/ui` 下的 ui 组件包)由 `ui-dev-server` 的 dependencies
162
161
  统一声明,发布后随 `npm install` 自动安装到用户项目,无需逐包注入。
163
162
 
164
- 发布后 work-cli `dependencies` 应从 `file:../work/cli/...` 改为对应 registry 版本号
165
- (`^0.0.1` 等),`create` 生成的项目则声明 `"@bams-app/ui-dev-server": "^0.0.1"`。
163
+ `work-cli` `create` 生成的项目均以 `"*"` 声明 `@bams-app/*` 依赖:仓库内经 yarn
164
+ workspaces 链接到本地包,发布后自动解析为 registry 上最新的已发布版本,无需手动改版本号。
166
165
 
167
166
  ## 用户项目升级
168
167
 
@@ -217,8 +216,8 @@ bams-work update
217
216
  复制方式安装并解析其全部传递依赖;修改 work 包源码后需重新执行 `npm install` 才会生效:
218
217
 
219
218
  ```bash
220
- cd work-cli && npm install # 安装 file: 依赖(链接 work/cli 下的包)
221
- npm link # 全局链接 bams-work
219
+ yarn install # 在仓库根安装(yarn workspaces 链接 work/ 下的本地包)
220
+ cd work/cli && npm link # 全局链接 bams-work
222
221
 
223
222
  cd /tmp && rm -rf demo-app
224
223
  bams-work create demo-app # 自动以 file: 引用本地 ui-dev-server 与能力包
package/commands/build.js CHANGED
@@ -43,7 +43,7 @@ async function main(args) {
43
43
  buildAppBin = require.resolve('@bams-app/ui-dev-server/bin/build-app.js');
44
44
  sharedEnvBin = require.resolve('@bams-app/shared-env/bin/shared-env.js');
45
45
  } catch (err) {
46
- error('未安装 work 依赖包,请先在 work-cli 目录执行 npm install');
46
+ error('未安装 work 依赖包,请先在 work/cli 目录执行 npm install');
47
47
  process.exit(1);
48
48
  }
49
49
 
@@ -10,7 +10,7 @@ const PROJECT_TEMPLATE_DIR = path.join(TEMPLATES_DIR, 'project');
10
10
  /**
11
11
  * 探测 work 仓库根目录(本地验证模式定位 file: 引用来源)
12
12
  * 1. WORK_PROJECT_ROOT 环境变量优先
13
- * 2. 通过 file: 安装的 @bams-app/ui-dev-server 包真实路径上溯(ui-dev-server -> cli -> work -> 仓库根)
13
+ * 2. 通过 file: 安装的 @bams-app/ui-dev-server 包真实路径上溯(ui-dev-server -> tooling -> work -> 仓库根)
14
14
  * 3. 均不可用(registry 安装)时返回空,走发布模式
15
15
  * @returns {string} work 仓库根目录或空字符串
16
16
  */
@@ -38,7 +38,7 @@ function detectWorkRoot() {
38
38
  function buildUiDevServerDep() {
39
39
  const workRoot = detectWorkRoot();
40
40
  if (workRoot) {
41
- const pkgDir = path.join(workRoot, 'work', 'cli', 'ui-dev-server');
41
+ const pkgDir = path.join(workRoot, 'work', 'tooling', 'ui-dev-server');
42
42
  if (isDirectory(pkgDir)) {
43
43
  return `"@bams-app/ui-dev-server": "file:${pkgDir}"`;
44
44
  }
@@ -62,13 +62,13 @@ function buildCapabilityDeps() {
62
62
  return `,\n "${name}": "${range}"`;
63
63
  }
64
64
  const short = name.replace('@bams-app/', '');
65
- // 在 work/configs、work/packages、work/ui、work/cli 多个位置依次查找包目录
65
+ // 在 work/configs、work/packages、work/ui、work/tooling 多个位置依次查找包目录
66
66
  const pkgDir = short === 'configs' && isDirectory(path.join(workRoot, 'work', 'configs'))
67
67
  ? path.join(workRoot, 'work', 'configs')
68
68
  : [
69
69
  path.join(workRoot, 'work', 'packages', short),
70
70
  path.join(workRoot, 'work', 'ui', short),
71
- path.join(workRoot, 'work', 'cli', short)
71
+ path.join(workRoot, 'work', 'tooling', short)
72
72
  ].find(dir => isDirectory(dir));
73
73
  return `,\n "${name}": "file:${pkgDir}"`;
74
74
  })
package/commands/dev.js CHANGED
@@ -62,7 +62,7 @@ async function main(args) {
62
62
  sharedEnvBin = require.resolve('@bams-app/shared-env/bin/shared-env.js');
63
63
  uiDevServerBin = require.resolve('@bams-app/ui-dev-server/bin/ui-dev-server.js');
64
64
  } catch (err) {
65
- error('未安装 work 依赖包,请先在 work-cli 目录执行 npm install');
65
+ error('未安装 work 依赖包,请先在 work/cli 目录执行 npm install');
66
66
  process.exit(1);
67
67
  }
68
68
 
package/commands/umd.js CHANGED
@@ -142,7 +142,7 @@ async function main(args) {
142
142
  try {
143
143
  buildUmdBin = require.resolve('@bams-app/ui-dev-server/bin/build-umd.js');
144
144
  } catch (err) {
145
- error('未安装 work 依赖包,请先在 work-cli 目录执行 npm install');
145
+ error('未安装 work 依赖包,请先在 work/cli 目录执行 npm install');
146
146
  process.exit(1);
147
147
  }
148
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bams-app/work-cli",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "BAMS-Work 全局开发工具:复用 work 已发布的包(ui-dev-server / shared-env / create-ui-*)提供项目初始化与组件开发能力(类似 vue-cli)",
5
5
  "main": "index.js",
6
6
  "bin": {