@baeta/generator-sdk 0.0.4 → 0.0.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @baeta/generator-sdk
2
2
 
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#47](https://github.com/andreisergiu98/baeta/pull/47) [`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
8
+
9
+ - [#43](https://github.com/andreisergiu98/baeta/pull/43) [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - bump dependencies
10
+
11
+ - Updated dependencies [[`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9), [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2)]:
12
+ - @baeta/plugin@0.0.18
13
+
14
+ ## 0.0.5
15
+
16
+ ### Patch Changes
17
+
18
+ - [#40](https://github.com/andreisergiu98/baeta/pull/40) [`9f937f4`](https://github.com/andreisergiu98/baeta/commit/9f937f47d3464a082680047414ee13a76cf6c056) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - avoid rewriting persisted files
19
+
20
+ - [#40](https://github.com/andreisergiu98/baeta/pull/40) [`9f937f4`](https://github.com/andreisergiu98/baeta/commit/9f937f47d3464a082680047414ee13a76cf6c056) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - normalize config
21
+
3
22
  ## 0.0.4
4
23
 
5
24
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -67,11 +67,13 @@ var FileManager = (_class2 = class {constructor() { _class2.prototype.__init4.ca
67
67
  this.files = this.files.filter((file) => file.tag !== tag);
68
68
  }
69
69
  writeAll() {
70
- return Promise.all(this.files.map((file) => file.write()));
70
+ const toWrite = this.files.filter((file) => !file.persisted);
71
+ return Promise.all(toWrite.map((file) => file.write()));
71
72
  }
72
73
  writeByTag(tag) {
73
74
  const files = this.getByTag(tag);
74
- return Promise.all(files.map((file) => file.write()));
75
+ const toWrite = files.filter((file) => !file.persisted);
76
+ return Promise.all(toWrite.map((file) => file.write()));
75
77
  }
76
78
  unlinkAll() {
77
79
  return Promise.all(this.files.map((file) => file.unlink())).then(() => {
@@ -79,10 +81,22 @@ var FileManager = (_class2 = class {constructor() { _class2.prototype.__init4.ca
79
81
  }
80
82
  }, _class2);
81
83
 
84
+ // lib/module.ts
85
+ var _changecaseall = require('change-case-all');
86
+ function getModuleGetName(name) {
87
+ return `get${_changecaseall.pascalCase.call(void 0, name)}Module`;
88
+ }
89
+ function getModuleCreateName(name) {
90
+ return `create${_changecaseall.pascalCase.call(void 0, name)}Module`;
91
+ }
92
+ function getModuleVariableName(name) {
93
+ return _changecaseall.camelCase.call(void 0, `${name}Module`);
94
+ }
95
+
82
96
  // lib/plugin.ts
83
97
  var _plugin = require('@baeta/plugin');
84
98
  var GeneratorPluginVersion = /* @__PURE__ */ ((GeneratorPluginVersion2) => {
85
- GeneratorPluginVersion2[GeneratorPluginVersion2["V1"] = 0] = "V1";
99
+ GeneratorPluginVersion2["V1"] = "v1";
86
100
  return GeneratorPluginVersion2;
87
101
  })(GeneratorPluginVersion || {});
88
102
  var defaultPluginFn = async (ctx, next) => {
@@ -93,7 +107,7 @@ function createPluginV1(options) {
93
107
  return {
94
108
  name: options.name,
95
109
  actionName: options.actionName,
96
- version: 0 /* V1 */,
110
+ version: "v1" /* V1 */,
97
111
  type: _plugin.PluginType.Generator,
98
112
  end: _nullishCoalesce(options.end, () => ( defaultPluginFn)),
99
113
  generate: _nullishCoalesce(options.generate, () => ( defaultPluginFn)),
@@ -117,4 +131,7 @@ function getGeneratorPlugins(plugins) {
117
131
 
118
132
 
119
133
 
120
- exports.File = File; exports.FileManager = FileManager; exports.GeneratorPluginVersion = GeneratorPluginVersion; exports.createPluginV1 = createPluginV1; exports.getGeneratorPlugins = getGeneratorPlugins; exports.isGeneratorPlugin = isGeneratorPlugin;
134
+
135
+
136
+
137
+ exports.File = File; exports.FileManager = FileManager; exports.GeneratorPluginVersion = GeneratorPluginVersion; exports.createPluginV1 = createPluginV1; exports.getGeneratorPlugins = getGeneratorPlugins; exports.getModuleCreateName = getModuleCreateName; exports.getModuleGetName = getModuleGetName; exports.getModuleVariableName = getModuleVariableName; exports.isGeneratorPlugin = isGeneratorPlugin;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PluginType } from '@baeta/plugin';
2
2
 
3
3
  interface GeneratorOptions {
4
+ cwd?: string;
4
5
  schemas: string[];
5
6
  modulesDir?: string;
6
7
  moduleDefinitionName?: string;
@@ -9,6 +10,16 @@ interface GeneratorOptions {
9
10
  extensions?: string;
10
11
  scalars?: Record<string, string>;
11
12
  }
13
+ interface NormalizedGeneratorOptions {
14
+ cwd: string;
15
+ schemas: string[];
16
+ modulesDir: string;
17
+ moduleDefinitionName: string;
18
+ baseTypesPath: string;
19
+ contextType?: string;
20
+ extensions?: string;
21
+ scalars?: Record<string, string>;
22
+ }
12
23
 
13
24
  declare class File {
14
25
  filename: string;
@@ -43,18 +54,22 @@ type Ctx<T = unknown> = {
43
54
  didGenerate: string[];
44
55
  didEnd: string[];
45
56
  pluginNames: string[];
46
- generatorOptions: GeneratorOptions;
57
+ generatorOptions: NormalizedGeneratorOptions;
47
58
  watching: boolean;
48
59
  changedFile?: string;
49
60
  } & T;
50
61
 
62
+ declare function getModuleGetName(name: string): string;
63
+ declare function getModuleCreateName(name: string): string;
64
+ declare function getModuleVariableName(name: string): string;
65
+
51
66
  type MatchPattern = string | RegExp;
52
67
  type Matcher = MatchPattern | MatchPattern[];
53
68
  declare enum GeneratorPluginVersion {
54
- V1 = 0
69
+ V1 = "v1"
55
70
  }
56
71
  type GeneratorPluginV1Fn<Store = unknown> = (ctx: Ctx<Store>, next: () => Promise<void>) => Promise<void>;
57
- type GeneratorPluginV1WatchOptions = (options: GeneratorOptions) => {
72
+ type GeneratorPluginV1WatchOptions = (options: NormalizedGeneratorOptions) => {
58
73
  include: string | string[];
59
74
  ignore: Matcher;
60
75
  };
@@ -84,4 +99,4 @@ declare function getGeneratorPlugins(plugins?: Array<{
84
99
  type: PluginType;
85
100
  }>): GeneratorPluginV1<unknown>[];
86
101
 
87
- export { Ctx, File, FileManager, GeneratorOptions, GeneratorPluginV1, GeneratorPluginV1Factory, GeneratorPluginV1Fn, GeneratorPluginV1WatchOptions, GeneratorPluginVersion, createPluginV1, getGeneratorPlugins, isGeneratorPlugin };
102
+ export { Ctx, File, FileManager, GeneratorOptions, GeneratorPluginV1, GeneratorPluginV1Factory, GeneratorPluginV1Fn, GeneratorPluginV1WatchOptions, GeneratorPluginVersion, NormalizedGeneratorOptions, createPluginV1, getGeneratorPlugins, getModuleCreateName, getModuleGetName, getModuleVariableName, isGeneratorPlugin };
package/dist/index.js CHANGED
@@ -67,11 +67,13 @@ var FileManager = class {
67
67
  this.files = this.files.filter((file) => file.tag !== tag);
68
68
  }
69
69
  writeAll() {
70
- return Promise.all(this.files.map((file) => file.write()));
70
+ const toWrite = this.files.filter((file) => !file.persisted);
71
+ return Promise.all(toWrite.map((file) => file.write()));
71
72
  }
72
73
  writeByTag(tag) {
73
74
  const files = this.getByTag(tag);
74
- return Promise.all(files.map((file) => file.write()));
75
+ const toWrite = files.filter((file) => !file.persisted);
76
+ return Promise.all(toWrite.map((file) => file.write()));
75
77
  }
76
78
  unlinkAll() {
77
79
  return Promise.all(this.files.map((file) => file.unlink())).then(() => {
@@ -79,10 +81,22 @@ var FileManager = class {
79
81
  }
80
82
  };
81
83
 
84
+ // lib/module.ts
85
+ import { camelCase, pascalCase } from "change-case-all";
86
+ function getModuleGetName(name) {
87
+ return `get${pascalCase(name)}Module`;
88
+ }
89
+ function getModuleCreateName(name) {
90
+ return `create${pascalCase(name)}Module`;
91
+ }
92
+ function getModuleVariableName(name) {
93
+ return camelCase(`${name}Module`);
94
+ }
95
+
82
96
  // lib/plugin.ts
83
97
  import { PluginType } from "@baeta/plugin";
84
98
  var GeneratorPluginVersion = /* @__PURE__ */ ((GeneratorPluginVersion2) => {
85
- GeneratorPluginVersion2[GeneratorPluginVersion2["V1"] = 0] = "V1";
99
+ GeneratorPluginVersion2["V1"] = "v1";
86
100
  return GeneratorPluginVersion2;
87
101
  })(GeneratorPluginVersion || {});
88
102
  var defaultPluginFn = async (ctx, next) => {
@@ -93,7 +107,7 @@ function createPluginV1(options) {
93
107
  return {
94
108
  name: options.name,
95
109
  actionName: options.actionName,
96
- version: 0 /* V1 */,
110
+ version: "v1" /* V1 */,
97
111
  type: PluginType.Generator,
98
112
  end: options.end ?? defaultPluginFn,
99
113
  generate: options.generate ?? defaultPluginFn,
@@ -116,5 +130,8 @@ export {
116
130
  GeneratorPluginVersion,
117
131
  createPluginV1,
118
132
  getGeneratorPlugins,
133
+ getModuleCreateName,
134
+ getModuleGetName,
135
+ getModuleVariableName,
119
136
  isGeneratorPlugin
120
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baeta/generator-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "homepage": "https://github.com/andreisergiu98/baeta#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/andreisergiu98/baeta/issues"
@@ -24,14 +24,15 @@
24
24
  "types": "tsc --noEmit"
25
25
  },
26
26
  "dependencies": {
27
- "@baeta/plugin": "^0.0.17",
27
+ "@baeta/plugin": "^0.0.18",
28
+ "change-case-all": "1.0.15",
28
29
  "chokidar": "^3.5.3"
29
30
  },
30
31
  "devDependencies": {
31
- "@baeta/build-tools": "^0.0.0",
32
+ "@baeta/builder": "^0.0.0",
32
33
  "@baeta/tsconfig": "^0.0.0",
33
- "@types/node": "^18.11.18",
34
- "typescript": "^4.9.4"
34
+ "@types/node": "^18.15.11",
35
+ "typescript": "^4.9.5"
35
36
  },
36
37
  "engines": {
37
38
  "node": ">=18.0.0"