@cloudbase/cli 2.6.0-alpha.6 → 2.6.0-alpha.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.
Binary file
@@ -125,6 +125,10 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
125
125
  {
126
126
  flags: '--includeNodeModules',
127
127
  desc: '包含本地 node_modules 目录,默认为 false 不包含'
128
+ },
129
+ {
130
+ flags: '--functionsConfigFile <functionsConfigFile>',
131
+ desc: '多函数定义配置文件,默认为 ./cloudbase-functions.json'
128
132
  }
129
133
  ],
130
134
  requiredEnvId: false,
@@ -137,18 +141,45 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
137
141
  let { serviceName, appId, source, includeNodeModules = false } = options;
138
142
  const target = 'main';
139
143
  source = path_1.default.resolve(source || process.cwd());
140
- const loadResult = yield (0, functions_framework_1.loadUserFunction)(source, target);
141
- if (!(loadResult === null || loadResult === void 0 ? void 0 : loadResult.userFunction)) {
142
- if (loadResult.reason.includes('is not a loadable module')) {
143
- log.error(`${source} 不是一个有效的函数式托管代码目录,可以通过 --source <source> 指定代码目录路径`);
144
+ const functionsConfigFile = options.functionsConfigFile || 'cloudbase-functions.json';
145
+ let multiFunctionsConfig = null;
146
+ if (functionsConfigFile && (yield fs_extra_1.default.exists(path_1.default.resolve(source, functionsConfigFile)))) {
147
+ try {
148
+ debugger;
149
+ multiFunctionsConfig = (0, functions_framework_1.loadFunctionsConfig)(functionsConfigFile);
144
150
  }
145
- else if (loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason.includes('is not defined in the provided module')) {
146
- log.error(`主文件并未导出目标函数 ${target},请导出 ${target} 目标函数`);
151
+ catch (err) {
152
+ log.error(`多函数定义配置文件 ${functionsConfigFile} 配置文件有误,请检查`);
153
+ log.error(err);
154
+ return;
147
155
  }
148
- else {
149
- log.error(loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason);
156
+ }
157
+ const loadResult = yield (0, functions_framework_1.loadFunctions)({
158
+ target,
159
+ sourceLocation: source,
160
+ multiFunctionsConfig
161
+ });
162
+ if (Array.isArray(loadResult)) {
163
+ for (const loadItem of loadResult) {
164
+ if (!(loadItem === null || loadItem === void 0 ? void 0 : loadItem.userFunction)) {
165
+ log.error(`加载函数 ${loadItem === null || loadItem === void 0 ? void 0 : loadItem.name} 失败: "${loadItem === null || loadItem === void 0 ? void 0 : loadItem.reason}"`);
166
+ return;
167
+ }
168
+ }
169
+ }
170
+ else {
171
+ if (!(loadResult === null || loadResult === void 0 ? void 0 : loadResult.userFunction)) {
172
+ if (loadResult.reason.includes('is not a loadable module')) {
173
+ log.error(`${source} 不是一个有效的函数式托管代码目录,可以通过 --source <source> 指定代码目录路径`);
174
+ }
175
+ else if (loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason.includes('is not defined in the provided module')) {
176
+ log.error(`主文件并未导出目标函数 ${target},请导出 ${target} 目标函数`);
177
+ }
178
+ else {
179
+ log.error(loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason);
180
+ }
181
+ return;
150
182
  }
151
- return;
152
183
  }
153
184
  if (!envId) {
154
185
  envId = yield _selectEnv();
@@ -229,7 +260,7 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
229
260
  envId,
230
261
  serviceName,
231
262
  filePath: source,
232
- fileToIgnore: includeNodeModules ? [] : ['node_modules', 'node_modules/**/*']
263
+ fileToIgnore: ['logs', 'logs/**/*'].concat(includeNodeModules ? [] : ['node_modules', 'node_modules/**/*'])
233
264
  });
234
265
  packageName = PackageName;
235
266
  packageVersion = PackageVersion;
@@ -309,6 +340,10 @@ let FunRunCommand = class FunRunCommand extends common_1.Command {
309
340
  {
310
341
  flags: '--logDirname <logDirname>',
311
342
  desc: '日志文件目录,默认为 ./logs'
343
+ },
344
+ {
345
+ flags: '--functionsConfigFile <functionsConfigFile>',
346
+ desc: '多函数定义配置文件,默认为 ./cloudbase-functions.json'
312
347
  }
313
348
  ],
314
349
  requiredEnvId: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.6.0-alpha.6",
3
+ "version": "2.6.0-alpha.8",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@cloudbase/cloud-api": "^0.5.5",
35
35
  "@cloudbase/framework-core": "^1.9.7",
36
- "@cloudbase/functions-framework": "^1.0.0-beta.3",
36
+ "@cloudbase/functions-framework": "1.0.0-beta.11",
37
37
  "@cloudbase/lowcode-cli": "^0.21.1",
38
38
  "@cloudbase/manager-node": "4.2.8",
39
39
  "@cloudbase/toolbox": "^0.7.5",