create-zleap-app 0.10.0 → 0.10.2

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.
Files changed (30) hide show
  1. package/index.js +24 -2
  2. package/lib/scaffold.js +10 -0
  3. package/package.json +4 -4
  4. package/skills/zleap-cloud-app/SKILL.md +6 -6
  5. package/skills/zleap-cloud-app/references/app-runtime.md +82 -75
  6. package/skills/zleap-cloud-app/references/cloud-functions.md +230 -43
  7. package/skills/zleap-cloud-app/references/console-database.md +8 -0
  8. package/skills/zleap-cloud-app/references/console-members.md +44 -30
  9. package/skills/zleap-cloud-app/references/limits.md +57 -56
  10. package/skills/zleap-cloud-app/references/manifest.md +36 -35
  11. package/skills/zleap-cloud-app/references/permissions.md +40 -47
  12. package/skills/zleap-cloud-app/references/sdk-database-files.md +116 -49
  13. package/skills/zleap-cloud-app/references/status-codes.md +126 -94
  14. package/skills/zleap-cloud-app/references/triggers.md +24 -24
  15. package/skills/zleap-cloud-app-release/SKILL.md +5 -2
  16. package/skills/zleap-cloud-app-release/references/app-center-install.md +64 -52
  17. package/skills/zleap-cloud-app-release/references/app-center-publish.md +118 -49
  18. package/skills/zleap-cloud-app-release/references/console-functions.md +12 -4
  19. package/skills/zleap-cloud-app-release/references/console-legacy-release.md +5 -2
  20. package/skills/zleap-cloud-app-release/references/console-members.md +44 -30
  21. package/skills/zleap-cloud-app-release/references/console-release.md +39 -28
  22. package/skills/zleap-cloud-app-release/references/console-workspace.md +32 -16
  23. package/skills/zleap-cloud-app-release/references/dev-to-production.md +330 -113
  24. package/skills/zleap-cloud-app-release/references/permissions.md +40 -47
  25. package/skills/zleap-cloud-app-release/references/status-codes.md +126 -94
  26. package/templates/react-ts/AGENTS.md +2 -2
  27. package/templates/react-ts/README.md +1 -1
  28. package/templates/react-ts/package.json +3 -0
  29. package/templates/react-ts/scripts/zleap.mjs +25 -3
  30. package/templates/react-ts/src/cloud/client.ts +2 -2
@@ -2,7 +2,7 @@
2
2
  // 项目内的一键命令,封装 zleap-app CLI:
3
3
  //
4
4
  // npm run login [-- --target https://os.example.com] 浏览器授权,保存开发会话(自动续期,最长 30 天)
5
- // npm run deploy [-- --no-build] [--no-install] 构建 → 检查 → 上传 private 版本 → 安装/切换到新版本
5
+ // npm run deploy [-- --no-build] [--no-install] 构建 → 检查 → 上传开发版本 → 安装/切换到新版本
6
6
  // npm run status 查看本应用的安装、权限与可用版本
7
7
  // npm run versions 列出全部成员上传的开发版本、当前线上版本和发布记录
8
8
  // npm run release [-- --version-id <id>] [--notes 说明] [--yes]
@@ -140,7 +140,7 @@ async function login() {
140
140
  const result = cli(args, { capture: false });
141
141
  if (result.code !== 0) throw new StepError('登录未完成');
142
142
  writeJSON(configFile, { ...config, target });
143
- ok('已登录,开发会话 30 分钟内有效');
143
+ ok('已登录:访问凭据自动续期,授权最长 30 天(到期或 auth logout 后重新登录)');
144
144
  }
145
145
 
146
146
  function publishedVersions() {
@@ -160,7 +160,17 @@ function checkDist() {
160
160
  return result.json;
161
161
  }
162
162
 
163
+ /** 生成的项目用 Vite 7(Node.js 20.19+ / 22.12+);旧 Node 上构建会报难懂的语法错误,先说清楚。 */
164
+ function requireSupportedNode() {
165
+ const [major, minor] = process.versions.node.split('.').map(Number);
166
+ if (major > 22 || (major === 22 && minor >= 12) || (major === 20 && minor >= 19)) return;
167
+ throw new StepError(
168
+ `当前 Node.js ${process.versions.node} 无法构建本项目(需要 20.19+ 或 22.12+)。请升级 Node.js(例如 nvm install 22)后重试。`,
169
+ );
170
+ }
171
+
163
172
  async function deploy() {
173
+ requireSupportedNode();
164
174
  const build = () => {
165
175
  if (has('no-build')) return;
166
176
  log('构建 dist/');
@@ -183,7 +193,8 @@ async function deploy() {
183
193
  report = checkDist();
184
194
  }
185
195
 
186
- log('上传 private 版本');
196
+ // appid 应用的上传是只有应用成员可见的开发版本;旧 app_key 应用是本人 private。都不会直接给全企业用。
197
+ log('上传开发版本');
187
198
  const published = cli(['publish', 'dist']);
188
199
  if (published.code === 6) {
189
200
  const requestId = published.json?.request_id;
@@ -254,6 +265,11 @@ function finish(appId, installed, diagnosis = null) {
254
265
  // 步骤按实际出现的条目连续编号:有的步骤视情况省略,写死序号会出现「1、3」。
255
266
  const steps = [];
256
267
  if (installed) steps.push('从 zleapOS 启动台打开应用(已打开的窗口点「重新加载应用」)。');
268
+ if (hasBackgroundCapabilities(readJSON(manifestFile, {})) && diagnosis?.resource_preparation_required) {
269
+ steps.push(
270
+ `有云函数 / 后台能力:npx zleap-app prepare ${appId} --version-id ${readJSON(stateFile, {}).versionId ?? '<version_id>'} 签名并激活到开发环境(或在「云开发控制台」→ 版本管理下方「开发环境:云函数激活」操作),再在应用窗口「权限」里允许后台能力。`,
271
+ );
272
+ }
257
273
  if (!cloud || !cloud.dev || !cloud.databaseReady) {
258
274
  steps.push('开发环境或数据库还没就绪:打开「云开发控制台」选中本应用 → 概览,按提示「创建开发环境」/ 等数据库「已就绪」。');
259
275
  }
@@ -270,6 +286,12 @@ function finish(appId, installed, diagnosis = null) {
270
286
  console.log(` (app_id=${appId},状态记录在 .zleap/state.json)`);
271
287
  }
272
288
 
289
+ /** manifest 里声明了 headless 后台能力(云函数等)。 */
290
+ function hasBackgroundCapabilities(value) {
291
+ const provides = value?.runtime?.capabilities?.provides;
292
+ return Array.isArray(provides) && provides.some((item) => item?.execution === 'headless');
293
+ }
294
+
273
295
  function currentAppId() {
274
296
  const appId = option('app-id') || readJSON(stateFile, {}).appId;
275
297
  if (!appId) throw new StepError('还没有部署记录,先运行 npm run deploy(或用 --app-id 指定)');
@@ -6,11 +6,11 @@
6
6
  * - 环境由宿主决定:永远用 DYNAMIC_CURRENT_ENV,不要写死 'dev' / 'prod'。
7
7
  * - 每次读最多 100 条,用 skip 翻页;写入结果未知(COMMIT_UNKNOWN)时先重读核对,不要自动重试。
8
8
  */
9
- import { CloudError, zl, type Capabilities } from '@zleap-web/app-sdk';
9
+ import { CloudError, zl, type Capabilities } from '@zleap-ai/app-sdk';
10
10
 
11
11
  export { CloudError };
12
12
  export type { Capabilities };
13
- export type { Document } from '@zleap-web/app-sdk';
13
+ export type { Document } from '@zleap-ai/app-sdk';
14
14
 
15
15
  export type ConnectionState =
16
16
  | { status: 'connecting' }