@biuxiu/codegen 0.2.8 → 0.2.10

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/dist/code/nest.js CHANGED
@@ -30,29 +30,9 @@ class RenderNest {
30
30
  }
31
31
  constructor(name, path) {
32
32
  this.#path = path ? path.endsWith("/") ? `${this.#formatPath(path)}/${name}` : this.#formatPath(path) : name;
33
- let basePath = "";
34
33
  const apiDir = getApiDir();
35
- if (this.#path.includes("/")) {
36
- const pathArr = this.#path.split("/");
37
- for (let i = 0; i < pathArr.length; i++) {
38
- const curPath = pathArr[i];
39
- if (i === 0) {
40
- basePath = join(apiDir, curPath);
41
- } else {
42
- basePath = join(basePath, curPath);
43
- }
44
- if (!existsSync(basePath)) {
45
- mkdirSync(basePath);
46
- }
47
- }
48
- } else {
49
- basePath = join(apiDir, this.#path);
50
- if (!existsSync(basePath)) {
51
- mkdirSync(basePath);
52
- }
53
- }
54
34
  this.#name = name;
55
- this.#moduleDir = basePath;
35
+ this.#moduleDir = join(apiDir, this.#path);
56
36
  }
57
37
  async #deleteDir(path) {
58
38
  const files = await readdir(path);
@@ -65,6 +45,7 @@ class RenderNest {
65
45
  await unlink(filePath);
66
46
  }
67
47
  }
48
+ rmdir(path);
68
49
  }
69
50
  remove() {
70
51
  if (existsSync(this.#moduleDir)) {
@@ -73,6 +54,29 @@ class RenderNest {
73
54
  this.editAppModule(true);
74
55
  }
75
56
  editAppModule(isDelete = false) {
57
+ if (!isDelete) {
58
+ let basePath = "";
59
+ const apiDir = getApiDir();
60
+ if (this.#path.includes("/")) {
61
+ const pathArr = this.#path.split("/");
62
+ for (let i = 0; i < pathArr.length; i++) {
63
+ const curPath = pathArr[i];
64
+ if (i === 0) {
65
+ basePath = join(apiDir, curPath);
66
+ } else {
67
+ basePath = join(basePath, curPath);
68
+ }
69
+ if (!existsSync(basePath)) {
70
+ mkdirSync(basePath);
71
+ }
72
+ }
73
+ } else {
74
+ basePath = join(apiDir, this.#path);
75
+ if (!existsSync(basePath)) {
76
+ mkdirSync(basePath);
77
+ }
78
+ }
79
+ }
76
80
  editFileQueue.push(async () => {
77
81
  const moudleName = `${this.#name[0].toUpperCase() + this.#name.slice(1)}Module`;
78
82
  const appModuleFile = join(getApiDir(), "app.module.ts");
@@ -1,5 +1,5 @@
1
1
  import { ApiServiceField, DtoField, EntityField } from '../types';
2
- export declare function renderNestCode(config: {
2
+ export declare function renderNestCode(entity: EntityField[], dto: DtoField[], apiService: ApiServiceField[], config: {
3
3
  name: string;
4
4
  path?: string;
5
- }, dto: DtoField[], entity: EntityField[], apiService: ApiServiceField[]): void;
5
+ }): void;
@@ -1,6 +1,6 @@
1
1
  import { RenderNest } from "../code/nest";
2
2
  import { isReverse } from "../config";
3
- function renderNestCode(config, dto, entity, apiService) {
3
+ function renderNestCode(entity, dto, apiService, config) {
4
4
  const api = new RenderNest(config.name, config.path);
5
5
  if (isReverse()) {
6
6
  api.remove();
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biuxiu/codegen",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "代码生成工具",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {