@gct-paas/cli 0.1.4-dev.1 → 0.1.4-dev.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.
@@ -33,7 +33,7 @@ class ApiManage {
33
33
  add(pathStr, cfg) {
34
34
  const splits = pathStr.split("/");
35
35
  const entityName = splits[3];
36
- const method = splits[4];
36
+ const method = splits.slice(4).join("_");
37
37
  const requestPath = splits.slice(4).join("/");
38
38
  if (!this.cache.has(entityName)) {
39
39
  this.cache.set(entityName, new EntityApiManage(entityName));
@@ -35,15 +35,19 @@ class GenApiAction {
35
35
  * @param {boolean} clean 是否清理输出目录后再生成
36
36
  */
37
37
  async run(baseUrl, tag, template, output, clean) {
38
- const cwd = process.cwd();
39
- const tempPath = _path.default.resolve(cwd, template);
40
- const outPath = _path.default.resolve(cwd, output);
41
- if (clean === true && _fsExtra.default.existsSync(outPath)) {
42
- rm.sync(outPath);
38
+ try {
39
+ const cwd = process.cwd();
40
+ const tempPath = _path.default.resolve(cwd, template);
41
+ const outPath = _path.default.resolve(cwd, output);
42
+ if (clean === true && _fsExtra.default.existsSync(outPath)) {
43
+ rm.sync(outPath);
44
+ }
45
+ await this.registerMacros(tempPath, this.engine);
46
+ await this.registerTempFiles(tempPath, this.engine);
47
+ await this.write(tag, _path.default.join(baseUrl, this.configs[tag]), outPath, this.engine);
48
+ } catch (error) {
49
+ console.error(error);
43
50
  }
44
- await this.registerMacros(tempPath, this.engine);
45
- await this.registerTempFiles(tempPath, this.engine);
46
- await this.write(tag, _path.default.join(baseUrl, this.configs[tag]), outPath, this.engine);
47
51
  }
48
52
  /**
49
53
  * 基于模型编译输出文件
@@ -26,7 +26,7 @@ export class ApiManage {
26
26
  add(pathStr, cfg) {
27
27
  const splits = pathStr.split("/");
28
28
  const entityName = splits[3];
29
- const method = splits[4];
29
+ const method = splits.slice(4).join("_");
30
30
  const requestPath = splits.slice(4).join("/");
31
31
  if (!this.cache.has(entityName)) {
32
32
  this.cache.set(entityName, new EntityApiManage(entityName));
@@ -26,20 +26,24 @@ export class GenApiAction {
26
26
  * @param {boolean} clean 是否清理输出目录后再生成
27
27
  */
28
28
  async run(baseUrl, tag, template, output, clean) {
29
- const cwd = process.cwd();
30
- const tempPath = path.resolve(cwd, template);
31
- const outPath = path.resolve(cwd, output);
32
- if (clean === true && fse.existsSync(outPath)) {
33
- rm.sync(outPath);
29
+ try {
30
+ const cwd = process.cwd();
31
+ const tempPath = path.resolve(cwd, template);
32
+ const outPath = path.resolve(cwd, output);
33
+ if (clean === true && fse.existsSync(outPath)) {
34
+ rm.sync(outPath);
35
+ }
36
+ await this.registerMacros(tempPath, this.engine);
37
+ await this.registerTempFiles(tempPath, this.engine);
38
+ await this.write(
39
+ tag,
40
+ path.join(baseUrl, this.configs[tag]),
41
+ outPath,
42
+ this.engine
43
+ );
44
+ } catch (error) {
45
+ console.error(error);
34
46
  }
35
- await this.registerMacros(tempPath, this.engine);
36
- await this.registerTempFiles(tempPath, this.engine);
37
- await this.write(
38
- tag,
39
- path.join(baseUrl, this.configs[tag]),
40
- outPath,
41
- this.engine
42
- );
43
47
  }
44
48
  /**
45
49
  * 基于模型编译输出文件
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/cli",
3
- "version": "0.1.4-dev.1",
3
+ "version": "0.1.4-dev.2",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "bin": {
@@ -34,6 +34,7 @@
34
34
  "license": "MIT",
35
35
  "author": "gct",
36
36
  "scripts": {
37
+ "run": "tsx src/bin.ts",
37
38
  "build": "npm run lint && unbuild",
38
39
  "lint": "eslint src/",
39
40
  "publish:next": "npm run build && npm publish --access public --tag=next --registry=https://registry.npmjs.org/",