@baeta/generator-sdk 0.0.3 → 0.0.5
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 +19 -0
- package/dist/index.cjs +11 -9
- package/dist/index.d.ts +33 -24
- package/dist/index.js +11 -9
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @baeta/generator-sdk
|
|
2
2
|
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
- [#40](https://github.com/andreisergiu98/baeta/pull/40) [`9f937f4`](https://github.com/andreisergiu98/baeta/commit/9f937f47d3464a082680047414ee13a76cf6c056) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - normalize config
|
|
10
|
+
|
|
11
|
+
## 0.0.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`d1190c1`](https://github.com/andreisergiu98/baeta/commit/d1190c10e3c259c73ddeeb73a4bd312b22bf2ea4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - create cli sdk
|
|
16
|
+
release prisma plugin
|
|
17
|
+
update dependencies
|
|
18
|
+
refactor generator plugins
|
|
19
|
+
- Updated dependencies [[`d1190c1`](https://github.com/andreisergiu98/baeta/commit/d1190c10e3c259c73ddeeb73a4bd312b22bf2ea4)]:
|
|
20
|
+
- @baeta/plugin@0.0.17
|
|
21
|
+
|
|
3
22
|
## 0.0.3
|
|
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
|
-
|
|
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
|
-
|
|
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(() => {
|
|
@@ -85,21 +87,21 @@ var GeneratorPluginVersion = /* @__PURE__ */ ((GeneratorPluginVersion2) => {
|
|
|
85
87
|
GeneratorPluginVersion2[GeneratorPluginVersion2["V1"] = 0] = "V1";
|
|
86
88
|
return GeneratorPluginVersion2;
|
|
87
89
|
})(GeneratorPluginVersion || {});
|
|
88
|
-
var defaultPluginFn = async (
|
|
89
|
-
return
|
|
90
|
+
var defaultPluginFn = async (ctx, next) => {
|
|
91
|
+
return next();
|
|
90
92
|
};
|
|
91
93
|
var defaultWatchFn = () => ({ include: [], ignore: [] });
|
|
92
|
-
function
|
|
93
|
-
return
|
|
94
|
+
function createPluginV1(options) {
|
|
95
|
+
return {
|
|
94
96
|
name: options.name,
|
|
95
|
-
|
|
97
|
+
actionName: options.actionName,
|
|
96
98
|
version: 0 /* V1 */,
|
|
97
99
|
type: _plugin.PluginType.Generator,
|
|
98
100
|
end: _nullishCoalesce(options.end, () => ( defaultPluginFn)),
|
|
99
101
|
generate: _nullishCoalesce(options.generate, () => ( defaultPluginFn)),
|
|
100
102
|
setup: _nullishCoalesce(options.setup, () => ( defaultPluginFn)),
|
|
101
103
|
watch: _nullishCoalesce(options.watch, () => ( defaultWatchFn))
|
|
102
|
-
}
|
|
104
|
+
};
|
|
103
105
|
}
|
|
104
106
|
function isGeneratorPlugin(plugin) {
|
|
105
107
|
return plugin.type === _plugin.PluginType.Generator;
|
|
@@ -117,4 +119,4 @@ function getGeneratorPlugins(plugins) {
|
|
|
117
119
|
|
|
118
120
|
|
|
119
121
|
|
|
120
|
-
exports.File = File; exports.FileManager = FileManager; exports.GeneratorPluginVersion = GeneratorPluginVersion; exports.
|
|
122
|
+
exports.File = File; exports.FileManager = FileManager; exports.GeneratorPluginVersion = GeneratorPluginVersion; exports.createPluginV1 = createPluginV1; exports.getGeneratorPlugins = getGeneratorPlugins; 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;
|
|
@@ -37,13 +48,15 @@ declare class FileManager {
|
|
|
37
48
|
unlinkAll(): Promise<void>;
|
|
38
49
|
}
|
|
39
50
|
|
|
40
|
-
type Ctx<T =
|
|
51
|
+
type Ctx<T = unknown> = {
|
|
41
52
|
fileManager: FileManager;
|
|
42
53
|
didSetup: string[];
|
|
43
54
|
didGenerate: string[];
|
|
44
55
|
didEnd: string[];
|
|
45
56
|
pluginNames: string[];
|
|
46
|
-
generatorOptions:
|
|
57
|
+
generatorOptions: NormalizedGeneratorOptions;
|
|
58
|
+
watching: boolean;
|
|
59
|
+
changedFile?: string;
|
|
47
60
|
} & T;
|
|
48
61
|
|
|
49
62
|
type MatchPattern = string | RegExp;
|
|
@@ -51,39 +64,35 @@ type Matcher = MatchPattern | MatchPattern[];
|
|
|
51
64
|
declare enum GeneratorPluginVersion {
|
|
52
65
|
V1 = 0
|
|
53
66
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
ctx: Ctx<Store>;
|
|
57
|
-
next: () => Promise<void>;
|
|
58
|
-
}
|
|
59
|
-
type GeneratorPluginV1Fn<Config, Store> = (params: GeneratorPluginV1Params<Config, Store>) => Promise<void>;
|
|
60
|
-
type GeneratorPluginV1WatchOptions<Config> = (generatorOptions: GeneratorOptions, pluginConfig: Config) => {
|
|
67
|
+
type GeneratorPluginV1Fn<Store = unknown> = (ctx: Ctx<Store>, next: () => Promise<void>) => Promise<void>;
|
|
68
|
+
type GeneratorPluginV1WatchOptions = (options: NormalizedGeneratorOptions) => {
|
|
61
69
|
include: string | string[];
|
|
62
70
|
ignore: Matcher;
|
|
63
71
|
};
|
|
64
|
-
type GeneratorPluginV1Factory<
|
|
72
|
+
type GeneratorPluginV1Factory<Store = unknown> = {
|
|
65
73
|
name: string;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
actionName: string;
|
|
75
|
+
setup?: GeneratorPluginV1Fn<Store>;
|
|
76
|
+
generate?: GeneratorPluginV1Fn<Store>;
|
|
77
|
+
end?: GeneratorPluginV1Fn<Store>;
|
|
78
|
+
watch?: GeneratorPluginV1WatchOptions;
|
|
70
79
|
};
|
|
71
|
-
interface GeneratorPluginV1<
|
|
80
|
+
interface GeneratorPluginV1<Store = unknown> {
|
|
72
81
|
name: string;
|
|
82
|
+
actionName: string;
|
|
73
83
|
version: GeneratorPluginVersion.V1;
|
|
74
84
|
type: PluginType.Generator;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
watch: GeneratorPluginV1WatchOptions<Config>;
|
|
85
|
+
setup: GeneratorPluginV1Fn<Store>;
|
|
86
|
+
generate: GeneratorPluginV1Fn<Store>;
|
|
87
|
+
end: GeneratorPluginV1Fn<Store>;
|
|
88
|
+
watch: GeneratorPluginV1WatchOptions;
|
|
80
89
|
}
|
|
81
|
-
declare function
|
|
90
|
+
declare function createPluginV1<Store = {}>(options: GeneratorPluginV1Factory<Store>): GeneratorPluginV1<Store>;
|
|
82
91
|
declare function isGeneratorPlugin(plugin: {
|
|
83
92
|
type: PluginType;
|
|
84
|
-
}): plugin is GeneratorPluginV1<unknown
|
|
93
|
+
}): plugin is GeneratorPluginV1<unknown>;
|
|
85
94
|
declare function getGeneratorPlugins(plugins?: Array<{
|
|
86
95
|
type: PluginType;
|
|
87
|
-
}>): GeneratorPluginV1<unknown
|
|
96
|
+
}>): GeneratorPluginV1<unknown>[];
|
|
88
97
|
|
|
89
|
-
export { Ctx, File, FileManager, GeneratorOptions, GeneratorPluginV1, GeneratorPluginV1Factory, GeneratorPluginV1Fn,
|
|
98
|
+
export { Ctx, File, FileManager, GeneratorOptions, GeneratorPluginV1, GeneratorPluginV1Factory, GeneratorPluginV1Fn, GeneratorPluginV1WatchOptions, GeneratorPluginVersion, NormalizedGeneratorOptions, createPluginV1, getGeneratorPlugins, 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
|
-
|
|
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
|
-
|
|
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(() => {
|
|
@@ -85,21 +87,21 @@ var GeneratorPluginVersion = /* @__PURE__ */ ((GeneratorPluginVersion2) => {
|
|
|
85
87
|
GeneratorPluginVersion2[GeneratorPluginVersion2["V1"] = 0] = "V1";
|
|
86
88
|
return GeneratorPluginVersion2;
|
|
87
89
|
})(GeneratorPluginVersion || {});
|
|
88
|
-
var defaultPluginFn = async (
|
|
89
|
-
return
|
|
90
|
+
var defaultPluginFn = async (ctx, next) => {
|
|
91
|
+
return next();
|
|
90
92
|
};
|
|
91
93
|
var defaultWatchFn = () => ({ include: [], ignore: [] });
|
|
92
|
-
function
|
|
93
|
-
return
|
|
94
|
+
function createPluginV1(options) {
|
|
95
|
+
return {
|
|
94
96
|
name: options.name,
|
|
95
|
-
|
|
97
|
+
actionName: options.actionName,
|
|
96
98
|
version: 0 /* V1 */,
|
|
97
99
|
type: PluginType.Generator,
|
|
98
100
|
end: options.end ?? defaultPluginFn,
|
|
99
101
|
generate: options.generate ?? defaultPluginFn,
|
|
100
102
|
setup: options.setup ?? defaultPluginFn,
|
|
101
103
|
watch: options.watch ?? defaultWatchFn
|
|
102
|
-
}
|
|
104
|
+
};
|
|
103
105
|
}
|
|
104
106
|
function isGeneratorPlugin(plugin) {
|
|
105
107
|
return plugin.type === PluginType.Generator;
|
|
@@ -114,7 +116,7 @@ export {
|
|
|
114
116
|
File,
|
|
115
117
|
FileManager,
|
|
116
118
|
GeneratorPluginVersion,
|
|
117
|
-
|
|
119
|
+
createPluginV1,
|
|
118
120
|
getGeneratorPlugins,
|
|
119
121
|
isGeneratorPlugin
|
|
120
122
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/generator-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"homepage": "https://github.com/andreisergiu98/baeta#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/andreisergiu98/baeta/issues"
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
"types": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@baeta/plugin": "^0.0.
|
|
27
|
+
"@baeta/plugin": "^0.0.17",
|
|
28
28
|
"chokidar": "^3.5.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@baeta/build-tools": "^0.0.0",
|
|
32
|
+
"@baeta/tsconfig": "^0.0.0",
|
|
32
33
|
"@types/node": "^18.11.18",
|
|
33
34
|
"typescript": "^4.9.4"
|
|
34
35
|
},
|