@baeta/generator-sdk 2.0.0-next.1 → 2.0.0-next.3

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,21 @@
1
1
  # @baeta/generator-sdk
2
2
 
3
+ ## 2.0.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#214](https://github.com/andreisergiu98/baeta/pull/214) [`6de5d15`](https://github.com/andreisergiu98/baeta/commit/6de5d15484d341a1717a1b2f3f45272912e6a886) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Fix generated import paths with custom config
8
+
9
+ ## 2.0.0-next.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Fix broken types
14
+
15
+ - Updated dependencies []:
16
+ - @baeta/util-path@2.0.0-next.2
17
+ - @baeta/plugin@2.0.0-next.2
18
+
3
19
  ## 2.0.0-next.1
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -77,43 +77,68 @@ type Query {
77
77
  #### 2. Implement your resolvers
78
78
 
79
79
  ```typescript
80
- import { getUserModule } from "./typedef";
80
+ import { UserModule } from "./typedef.ts";
81
81
 
82
- const { Query } = getUserModule();
82
+ const { Query } = UserModule;
83
83
 
84
- Query.user(({ args }) => {
84
+ const userQuery = Query.user.resolve(({ args }) => {
85
85
  return dataSource.user.find(args.where);
86
86
  });
87
87
 
88
- Query.users(() => {
88
+ const usersQuery = Query.users.resolve(() => {
89
89
  return dataSource.user.findMany();
90
90
  });
91
+
92
+ Query.$fields({
93
+ user: userQuery,
94
+ users: usersQuery,
95
+ });
91
96
  ```
92
97
 
93
98
  #### 3. Add authorization
94
99
 
95
100
  ```typescript
96
- const { Query, Mutation } = getUserModule();
97
-
98
- Query.users.$auth({
99
- $or: {
100
- isPublic: true,
101
- isLoggedIn: true,
102
- },
103
- });
101
+ import { UserModule } from "./typedef.ts";
102
+
103
+ const { Query } = UserModule;
104
+
105
+ const userQuery = Query.user
106
+ .auth({
107
+ $or: {
108
+ isPublic: true,
109
+ isLoggedIn: true,
110
+ },
111
+ })
112
+ .resolve(async ({ args }) => {
113
+ // ...
114
+ });
104
115
  ```
105
116
 
106
117
  #### 4. Add caching
107
118
 
108
119
  ```typescript
109
- import { getUserModule } from "./typedef";
110
-
111
- const { User, Query } = getUserModule();
120
+ const { Query, Mutation, User } = UserModule;
112
121
 
113
122
  export const userCache = User.$createCache();
114
123
 
115
- Query.user.$useCache(userCache);
116
- Query.users.$useCache(userCache);
124
+ const userQuery = Query.user
125
+ .auth({
126
+ // ...
127
+ })
128
+ .useCache(userCache)
129
+ .resolve(async ({ args }) => {
130
+ // ...
131
+ });
132
+
133
+ const updateUserMutation = Mutation.updateUser
134
+ .use(async (next) => {
135
+ const user = await next();
136
+ await userCache.save(user);
137
+ return user;
138
+ })
139
+ .resolve(async ({ args }) => {
140
+ // ...
141
+ });
117
142
  ```
118
143
 
119
144
  ## Compatibility
@@ -0,0 +1,258 @@
1
+ import { PluginType } from "@baeta/plugin";
2
+ import { Event, EventType, Options } from "@parcel/watcher";
3
+ import micromatch from "micromatch";
4
+ import * as fs_promises0 from "fs/promises";
5
+
6
+ //#region lib/file.d.ts
7
+ /**
8
+ * Options for generated files.
9
+ */
10
+ interface FileOptions {
11
+ /**
12
+ * Disable generation notice at the beginning of the file.
13
+ * @defaultValue false
14
+ */
15
+ disableGenerationNoticeHeader?: boolean;
16
+ /**
17
+ * Disable eslint-disable comment at the beginning of the file.
18
+ * @defaultValue false
19
+ */
20
+ disableEslintHeader?: boolean;
21
+ /**
22
+ * Disable biome v1 comment at the beginning of the file.
23
+ * @defaultValue false
24
+ */
25
+ disableBiomeV1Header?: boolean;
26
+ /**
27
+ * Disable biome v2 comment at the beginning of the file.
28
+ * @defaultValue false
29
+ */
30
+ disableBiomeV2Header?: boolean;
31
+ /**
32
+ * Allow overwriting the file.
33
+ * @defaultValue true
34
+ */
35
+ allowOverwrite?: boolean;
36
+ /**
37
+ * Add custom header at the beginning of the file.
38
+ */
39
+ addHeader?: (name: string, content: string, tag: string) => string;
40
+ /**
41
+ * Edit the content of the file before writing it.
42
+ */
43
+ transformContent?: (name: string, content: string, tag: string) => string | Promise<string>;
44
+ }
45
+ declare class File {
46
+ persisted: boolean;
47
+ filename: string;
48
+ content: string;
49
+ tag: string;
50
+ private options?;
51
+ constructor(filename: string, content: string, tag: string, options?: FileOptions);
52
+ write: () => Promise<void>;
53
+ unlink: () => Promise<void>;
54
+ protected buildContent(): Promise<string>;
55
+ protected buildHeader(): string;
56
+ protected createComment(comment: string): string;
57
+ }
58
+ //#endregion
59
+ //#region lib/config.d.ts
60
+ /**
61
+ * Interface for custom schema loaders.
62
+ */
63
+ type GraphQlLoaderAny = any;
64
+ interface Loader<TOptions = GraphQlLoaderAny> {
65
+ load(pointer: string, options?: TOptions): Promise<GraphQlLoaderAny[] | null | never>;
66
+ loadSync?(pointer: string, options?: TOptions): GraphQlLoaderAny[] | null | never;
67
+ }
68
+ /**
69
+ * Options for the Baeta Generator.
70
+ */
71
+ interface GeneratorOptions {
72
+ /**
73
+ * Current working directory for resolving relative paths.
74
+ * @defaultValue process.cwd()
75
+ */
76
+ cwd?: string;
77
+ /**
78
+ * Glob pattern(s) to locate GraphQL schema files.
79
+ * @defaultValue ```ts
80
+ * ['src/∗∗/∗.gql', 'src/∗∗/∗.graphql']
81
+ * ```
82
+ */
83
+ schemas: string[];
84
+ /**
85
+ * Root directory where GraphQL modules are defined.
86
+ * @defaultValue 'src/modules'
87
+ */
88
+ modulesDir?: string;
89
+ /**
90
+ * Filename for the generated module definition file.
91
+ * Contains type definitions and the GraphQL AST.
92
+ * @defaultValue 'typedef.ts'
93
+ */
94
+ moduleDefinitionName?: string;
95
+ /**
96
+ * Output path for the generated type files.
97
+ * @defaultValue ```ts
98
+ * `${modulesDir}/../__generated__/types.ts`
99
+ * ```
100
+ */
101
+ typesDir?: string;
102
+ /**
103
+ * Configuration options for generated files.
104
+ */
105
+ fileOptions?: FileOptions;
106
+ /**
107
+ * Custom schema loaders for processing schema files.
108
+ */
109
+ loaders?: Loader[];
110
+ /**
111
+ * File extension to use in generated import statements.
112
+ * Set to false to omit extensions.
113
+ * @defaultValue '.ts'
114
+ */
115
+ importExtension?: '.js' | '.ts' | false;
116
+ }
117
+ interface NormalizedGeneratorOptions {
118
+ cwd: string;
119
+ schemas: string[];
120
+ modulesDir: string;
121
+ moduleDefinitionName: string;
122
+ typesDir: string;
123
+ fileOptions?: FileOptions;
124
+ loaders?: Loader[];
125
+ importExtension: '.js' | '.ts' | '';
126
+ }
127
+ declare function loadOptions(options: GeneratorOptions): NormalizedGeneratorOptions;
128
+ //#endregion
129
+ //#region lib/file-manager.d.ts
130
+ declare class FileManager {
131
+ files: File[];
132
+ fileOptions?: FileOptions;
133
+ constructor(fileOptions?: FileOptions);
134
+ createAndAdd(filename: string, content: string, tag: string, options?: FileOptions): File;
135
+ add(...file: File[]): void;
136
+ get(filename: string): File | undefined;
137
+ getAll(): File[];
138
+ getByTag(tag: string): File[];
139
+ remove(filename: string): void;
140
+ removeAll(): void;
141
+ removeByTag(tag: string): void;
142
+ writeAll(): Promise<void[]>;
143
+ writeByTag(tag: string): Promise<void[]>;
144
+ unlinkAll(): Promise<void>;
145
+ getPersistedFiles(): File[];
146
+ }
147
+ //#endregion
148
+ //#region lib/watcher-ignore.d.ts
149
+ type MatchFn = (testString: string) => boolean;
150
+ type MatchPattern = string | RegExp | MatchFn;
151
+ declare class WatcherIgnore {
152
+ private readonly cwd;
153
+ private files;
154
+ private regexps;
155
+ private functions;
156
+ private globs;
157
+ private globsMap;
158
+ constructor(cwd: string);
159
+ ignore(pattern: MatchPattern): void;
160
+ isMicromatch(pattern: string): boolean;
161
+ resolveFile(file: string): string;
162
+ unignore(pattern: MatchPattern): void;
163
+ isIgnored(path: string): boolean;
164
+ }
165
+ //#endregion
166
+ //#region lib/watcher.d.ts
167
+ declare const isMatch: (string: string, pattern: string | readonly string[], options?: micromatch.Options) => boolean;
168
+ type WatcherListener = (path: WatcherFile) => void;
169
+ interface WatcherFile {
170
+ type: EventType;
171
+ path: string;
172
+ relativePath: string;
173
+ }
174
+ declare class Watcher {
175
+ private readonly cwd;
176
+ private readonly options?;
177
+ private subscription;
178
+ private listeners;
179
+ private watcherIgnore;
180
+ constructor(cwd: string, options?: Options);
181
+ onEvents: (err: Error | null, events: Event[]) => void;
182
+ on(event: EventType, listener: WatcherListener): void;
183
+ off(event: EventType, listener: WatcherListener): void;
184
+ ignore(pattern: MatchPattern): void;
185
+ unignore(pattern: MatchPattern): void;
186
+ createSubscription(): {
187
+ unsubscribe: () => Promise<void>;
188
+ };
189
+ close(): Promise<void>;
190
+ }
191
+ //#endregion
192
+ //#region lib/ctx.d.ts
193
+ type Ctx<T = unknown> = {
194
+ fileManager: FileManager;
195
+ didSetup: string[];
196
+ didGenerate: string[];
197
+ didEnd: string[];
198
+ pluginNames: string[];
199
+ generatorOptions: NormalizedGeneratorOptions;
200
+ watching: boolean;
201
+ changedFile?: WatcherFile;
202
+ } & T;
203
+ //#endregion
204
+ //#region lib/file-block.d.ts
205
+ declare class FileBlock extends File {
206
+ filename: string;
207
+ content: string;
208
+ start: string;
209
+ end: string;
210
+ tag: string;
211
+ constructor(filename: string, content: string, start: string, end: string, tag: string, options?: FileOptions);
212
+ write: () => Promise<void>;
213
+ unlink: () => Promise<void>;
214
+ protected getExistingContent(): Promise<readonly [string, fs_promises0.FileHandle] | readonly ["", null]>;
215
+ protected getSlices(existingContent: string): readonly [string, "", false] | readonly [string, string, true];
216
+ protected addBlockToContent(existingContent: string): string;
217
+ protected buildPadding(existingContent: string): "" | "\n" | "\n\n";
218
+ }
219
+ //#endregion
220
+ //#region lib/module.d.ts
221
+ declare function getModuleExportName(name: string): string;
222
+ //#endregion
223
+ //#region lib/plugin.d.ts
224
+ declare const GeneratorPluginVersion: {
225
+ readonly V1: "v1";
226
+ };
227
+ type GeneratorPluginVersion = (typeof GeneratorPluginVersion)[keyof typeof GeneratorPluginVersion];
228
+ type GeneratorPluginV1Fn<Store = unknown> = (ctx: Ctx<Store>, next: () => Promise<void>) => Promise<void>;
229
+ type GeneratorPluginV1ReloadFn = (file: WatcherFile) => void;
230
+ type GeneratorPluginV1WatchOptions = (options: NormalizedGeneratorOptions, watcher: Watcher, reload: GeneratorPluginV1ReloadFn) => void;
231
+ type GeneratorPluginV1Factory<Store = unknown> = {
232
+ name: string;
233
+ actionName: string;
234
+ setup?: GeneratorPluginV1Fn<Store>;
235
+ generate?: GeneratorPluginV1Fn<Store>;
236
+ end?: GeneratorPluginV1Fn<Store>;
237
+ watch?: GeneratorPluginV1WatchOptions;
238
+ };
239
+ interface GeneratorPluginV1<Store = unknown> {
240
+ name: string;
241
+ actionName: string;
242
+ version: typeof GeneratorPluginVersion.V1;
243
+ type: typeof PluginType.Generator;
244
+ setup: GeneratorPluginV1Fn<Store>;
245
+ generate: GeneratorPluginV1Fn<Store>;
246
+ end: GeneratorPluginV1Fn<Store>;
247
+ watch: GeneratorPluginV1WatchOptions;
248
+ }
249
+ declare function createPluginV1<Store = unknown>(options: GeneratorPluginV1Factory<Store>): GeneratorPluginV1<Store>;
250
+ declare function isGeneratorPlugin(plugin: {
251
+ type: PluginType;
252
+ }): plugin is GeneratorPluginV1<unknown>;
253
+ declare function getGeneratorPlugins(plugins?: Array<{
254
+ type: PluginType;
255
+ }>): GeneratorPluginV1<unknown>[];
256
+ //#endregion
257
+ export { Ctx, File, FileBlock, FileManager, FileOptions, GeneratorOptions, GeneratorPluginV1, GeneratorPluginV1Factory, GeneratorPluginV1Fn, GeneratorPluginV1ReloadFn, GeneratorPluginV1WatchOptions, GeneratorPluginVersion, Loader, MatchFn, MatchPattern, NormalizedGeneratorOptions, Watcher, WatcherFile, WatcherIgnore, WatcherListener, createPluginV1, getGeneratorPlugins, getModuleExportName, isGeneratorPlugin, isMatch, loadOptions, micromatch };
258
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,433 +1,382 @@
1
- // lib/config.ts
2
- import { posixPath, resolve } from "@baeta/util-path";
1
+ import path, { dirname, extname, posixPath, resolve } from "@baeta/util-path";
2
+ import fs, { mkdir, open, writeFile } from "node:fs/promises";
3
+ import { pascalCase } from "change-case-all";
4
+ import { PluginType } from "@baeta/plugin";
5
+ import { subscribe } from "@parcel/watcher";
6
+ import micromatch, { default as micromatch$1 } from "micromatch";
7
+
8
+ //#region lib/config.ts
3
9
  function loadOptions(options) {
4
- const cwd = posixPath(options.cwd ?? process.cwd());
5
- const schemas = options.schemas ?? ["src/**/*.graphql"];
6
- const modulesDir = posixPath(resolve(cwd, options.modulesDir || "src/modules"));
7
- const moduleDefinitionName = options.moduleDefinitionName || "typedef.ts";
8
- const defaultTypesDir = resolve(modulesDir, "../__generated__/");
9
- const typesDir = resolve(cwd, options.typesDir || defaultTypesDir);
10
- return {
11
- cwd,
12
- schemas,
13
- modulesDir,
14
- moduleDefinitionName,
15
- typesDir,
16
- fileOptions: options.fileOptions,
17
- loaders: options.loaders,
18
- importExtension: options.importExtension === false ? "" : options.importExtension ?? ".ts"
19
- };
10
+ const cwd = posixPath(options.cwd ?? process.cwd());
11
+ const schemas = options.schemas ?? ["src/**/*.graphql"];
12
+ const modulesDir = posixPath(resolve(cwd, options.modulesDir || "src/modules"));
13
+ const moduleDefinitionName = options.moduleDefinitionName || "typedef.ts";
14
+ const defaultTypesDir = resolve(modulesDir, "../__generated__/");
15
+ return {
16
+ cwd,
17
+ schemas,
18
+ modulesDir,
19
+ moduleDefinitionName,
20
+ typesDir: resolve(cwd, options.typesDir || defaultTypesDir),
21
+ fileOptions: options.fileOptions,
22
+ loaders: options.loaders,
23
+ importExtension: options.importExtension === false ? "" : options.importExtension ?? ".ts"
24
+ };
20
25
  }
21
26
 
22
- // lib/file.ts
23
- import fs from "fs/promises";
24
- import { dirname, extname } from "@baeta/util-path";
27
+ //#endregion
28
+ //#region lib/file.ts
25
29
  var File = class {
26
- persisted = false;
27
- filename;
28
- content;
29
- tag;
30
- options;
31
- constructor(filename, content, tag, options) {
32
- this.filename = filename;
33
- this.content = content;
34
- this.tag = tag;
35
- this.options = options;
36
- }
37
- write = async () => {
38
- if (this.persisted) {
39
- return;
40
- }
41
- this.persisted = true;
42
- if (this.options?.allowOverwrite === false) {
43
- const exists = await fs.stat(this.filename).then((res) => res.isFile()).catch(() => false);
44
- if (exists) return;
45
- }
46
- const dir = dirname(this.filename);
47
- await fs.mkdir(dir, { recursive: true });
48
- const content = await this.buildContent();
49
- return fs.writeFile(this.filename, content, "utf-8");
50
- };
51
- unlink = async () => {
52
- this.persisted = false;
53
- return fs.unlink(this.filename);
54
- };
55
- async buildContent() {
56
- const content = this.buildHeader() + this.content;
57
- if (this.options?.transformContent) {
58
- return this.options.transformContent(this.filename, content, this.tag);
59
- }
60
- return content;
61
- }
62
- buildHeader() {
63
- const headerItems = [];
64
- if (this.options?.disableGenerationNoticeHeader !== true) {
65
- const comment = this.createComment(
66
- "This file was generated by Baeta. Do not edit it directly. All changes will be overwritten by the generator."
67
- );
68
- headerItems.push(comment);
69
- }
70
- if (this.options?.disableEslintHeader !== true) {
71
- const comment = this.createComment("eslint-disable");
72
- headerItems.push(comment);
73
- }
74
- if (this.options?.disableBiomeHeader !== true) {
75
- const comment = this.createComment("@biome-ignore-all: generated file");
76
- headerItems.push(comment);
77
- }
78
- if (this.options?.addHeader) {
79
- const customHeader = this.options.addHeader(this.filename, this.content, this.tag);
80
- headerItems.push(customHeader);
81
- }
82
- if (headerItems.length === 0) {
83
- return "";
84
- }
85
- return `${headerItems.join("\n")}
86
-
87
- `;
88
- }
89
- createComment(comment) {
90
- const extension = extname(this.filename);
91
- if ([".gql", ".graphql"].includes(extension)) {
92
- return `# ${comment}`;
93
- }
94
- return `/* ${comment} */`;
95
- }
30
+ persisted = false;
31
+ filename;
32
+ content;
33
+ tag;
34
+ options;
35
+ constructor(filename, content, tag, options) {
36
+ this.filename = filename;
37
+ this.content = content;
38
+ this.tag = tag;
39
+ this.options = options;
40
+ }
41
+ write = async () => {
42
+ if (this.persisted) return;
43
+ this.persisted = true;
44
+ if (this.options?.allowOverwrite === false) {
45
+ if (await fs.stat(this.filename).then((res) => res.isFile()).catch(() => false)) return;
46
+ }
47
+ const dir = dirname(this.filename);
48
+ await fs.mkdir(dir, { recursive: true });
49
+ const content = await this.buildContent();
50
+ return fs.writeFile(this.filename, content, "utf-8");
51
+ };
52
+ unlink = async () => {
53
+ this.persisted = false;
54
+ return fs.unlink(this.filename);
55
+ };
56
+ async buildContent() {
57
+ const content = this.buildHeader() + this.content;
58
+ if (this.options?.transformContent) return this.options.transformContent(this.filename, content, this.tag);
59
+ return content;
60
+ }
61
+ buildHeader() {
62
+ const headerItems = [];
63
+ if (this.options?.disableGenerationNoticeHeader !== true) {
64
+ const comment = this.createComment("This file was generated by Baeta. Do not edit it directly. All changes will be overwritten by the generator.");
65
+ headerItems.push(comment);
66
+ }
67
+ if (this.options?.disableEslintHeader !== true) {
68
+ const comment = this.createComment("eslint-disable");
69
+ headerItems.push(comment);
70
+ }
71
+ if (this.options?.disableBiomeV1Header !== true) {
72
+ const comment = this.createComment("@biome-ignore-all: generated file");
73
+ headerItems.push(comment);
74
+ }
75
+ if (this.options?.disableBiomeV2Header !== true) {
76
+ const comment = this.createComment("biome-ignore-all lint: generated file");
77
+ headerItems.push(comment);
78
+ }
79
+ if (this.options?.addHeader) {
80
+ const customHeader = this.options.addHeader(this.filename, this.content, this.tag);
81
+ headerItems.push(customHeader);
82
+ }
83
+ if (headerItems.length === 0) return "";
84
+ return `${headerItems.join("\n")}\n\n`;
85
+ }
86
+ createComment(comment) {
87
+ const extension = extname(this.filename);
88
+ if ([".gql", ".graphql"].includes(extension)) return `# ${comment}`;
89
+ return `/* ${comment} */`;
90
+ }
96
91
  };
97
92
 
98
- // lib/file-block.ts
99
- import { mkdir, open, writeFile } from "fs/promises";
100
- import { dirname as dirname2 } from "@baeta/util-path";
93
+ //#endregion
94
+ //#region lib/file-block.ts
101
95
  var FileBlock = class extends File {
102
- filename;
103
- content;
104
- start;
105
- end;
106
- tag;
107
- constructor(filename, content, start, end, tag, options) {
108
- super(filename, content, tag, {
109
- disableBiomeHeader: options?.disableBiomeHeader ?? true,
110
- disableEslintHeader: options?.disableEslintHeader ?? true,
111
- disableGenerationNoticeHeader: options?.disableGenerationNoticeHeader ?? true
112
- });
113
- this.filename = filename;
114
- this.content = content;
115
- this.start = start;
116
- this.end = end;
117
- this.tag = tag;
118
- }
119
- write = async () => {
120
- if (this.persisted) {
121
- return;
122
- }
123
- this.persisted = true;
124
- const dir = dirname2(this.filename);
125
- await mkdir(dir, { recursive: true });
126
- const [existingContent, fd] = await this.getExistingContent();
127
- this.content = this.addBlockToContent(existingContent);
128
- const content = await this.buildContent();
129
- if (fd) {
130
- await fd.truncate(0);
131
- await fd.write(content, 0, "utf-8");
132
- await fd.close();
133
- } else {
134
- await writeFile(this.filename, content, "utf-8");
135
- }
136
- };
137
- unlink = async () => {
138
- this.persisted = false;
139
- const [existingContent, fd] = await this.getExistingContent();
140
- if (fd) {
141
- const [start, end] = this.getSlices(existingContent);
142
- await fd.truncate(0);
143
- await fd.write(start + end, 0, "utf-8");
144
- await fd.close();
145
- }
146
- };
147
- async getExistingContent() {
148
- try {
149
- const fd = await open(this.filename, "r+");
150
- const existingContent = await fd.readFile("utf-8");
151
- return [existingContent, fd];
152
- } catch {
153
- return ["", null];
154
- }
155
- }
156
- getSlices(existingContent) {
157
- const startMarkerIndex = existingContent.indexOf(this.start);
158
- const endMarkerIndex = existingContent.lastIndexOf(this.end);
159
- if (startMarkerIndex === -1 || endMarkerIndex === -1) {
160
- return [existingContent, "", false];
161
- }
162
- return [
163
- existingContent.slice(0, startMarkerIndex),
164
- existingContent.slice(endMarkerIndex + this.end.length),
165
- true
166
- ];
167
- }
168
- addBlockToContent(existingContent) {
169
- const block = `${this.start}
170
- ${this.content}
171
- ${this.end}`;
172
- const [startSlice, endSlice, hasMarkers] = this.getSlices(existingContent);
173
- const padding = hasMarkers ? "" : this.buildPadding(existingContent);
174
- return startSlice + padding + block + endSlice;
175
- }
176
- buildPadding(existingContent) {
177
- if (existingContent === "") {
178
- return "";
179
- }
180
- if (existingContent.endsWith("\n\n")) {
181
- return "";
182
- }
183
- if (existingContent.endsWith("\n")) {
184
- return "\n";
185
- }
186
- return "\n\n";
187
- }
96
+ filename;
97
+ content;
98
+ start;
99
+ end;
100
+ tag;
101
+ constructor(filename, content, start, end, tag, options) {
102
+ super(filename, content, tag, {
103
+ disableBiomeV1Header: options?.disableBiomeV1Header ?? true,
104
+ disableBiomeV2Header: options?.disableBiomeV2Header ?? true,
105
+ disableEslintHeader: options?.disableEslintHeader ?? true,
106
+ disableGenerationNoticeHeader: options?.disableGenerationNoticeHeader ?? true
107
+ });
108
+ this.filename = filename;
109
+ this.content = content;
110
+ this.start = start;
111
+ this.end = end;
112
+ this.tag = tag;
113
+ }
114
+ write = async () => {
115
+ if (this.persisted) return;
116
+ this.persisted = true;
117
+ await mkdir(dirname(this.filename), { recursive: true });
118
+ const [existingContent, fd] = await this.getExistingContent();
119
+ this.content = this.addBlockToContent(existingContent);
120
+ const content = await this.buildContent();
121
+ if (fd) {
122
+ await fd.truncate(0);
123
+ await fd.write(content, 0, "utf-8");
124
+ await fd.close();
125
+ } else await writeFile(this.filename, content, "utf-8");
126
+ };
127
+ unlink = async () => {
128
+ this.persisted = false;
129
+ const [existingContent, fd] = await this.getExistingContent();
130
+ if (fd) {
131
+ const [start, end] = this.getSlices(existingContent);
132
+ await fd.truncate(0);
133
+ await fd.write(start + end, 0, "utf-8");
134
+ await fd.close();
135
+ }
136
+ };
137
+ async getExistingContent() {
138
+ try {
139
+ const fd = await open(this.filename, "r+");
140
+ return [await fd.readFile("utf-8"), fd];
141
+ } catch {
142
+ return ["", null];
143
+ }
144
+ }
145
+ getSlices(existingContent) {
146
+ const startMarkerIndex = existingContent.indexOf(this.start);
147
+ const endMarkerIndex = existingContent.lastIndexOf(this.end);
148
+ if (startMarkerIndex === -1 || endMarkerIndex === -1) return [
149
+ existingContent,
150
+ "",
151
+ false
152
+ ];
153
+ return [
154
+ existingContent.slice(0, startMarkerIndex),
155
+ existingContent.slice(endMarkerIndex + this.end.length),
156
+ true
157
+ ];
158
+ }
159
+ addBlockToContent(existingContent) {
160
+ const block = `${this.start}\n${this.content}\n${this.end}`;
161
+ const [startSlice, endSlice, hasMarkers] = this.getSlices(existingContent);
162
+ return startSlice + (hasMarkers ? "" : this.buildPadding(existingContent)) + block + endSlice;
163
+ }
164
+ buildPadding(existingContent) {
165
+ if (existingContent === "") return "";
166
+ if (existingContent.endsWith("\n\n")) return "";
167
+ if (existingContent.endsWith("\n")) return "\n";
168
+ return "\n\n";
169
+ }
188
170
  };
189
171
 
190
- // lib/file-manager.ts
172
+ //#endregion
173
+ //#region lib/file-manager.ts
191
174
  var FileManager = class {
192
- files = [];
193
- fileOptions;
194
- constructor(fileOptions) {
195
- this.fileOptions = fileOptions;
196
- }
197
- createAndAdd(filename, content, tag, options) {
198
- const file = new File(filename, content, tag, { ...this.fileOptions, ...options });
199
- this.add(file);
200
- return file;
201
- }
202
- add(...file) {
203
- this.files.push(...file);
204
- }
205
- get(filename) {
206
- return this.files.find((file) => file.filename === filename);
207
- }
208
- getAll() {
209
- return this.files;
210
- }
211
- getByTag(tag) {
212
- return this.files.filter((file) => file.tag === tag);
213
- }
214
- remove(filename) {
215
- const index = this.files.findIndex((file) => file.filename === filename);
216
- this.files.splice(index, 1);
217
- }
218
- removeAll() {
219
- this.files = [];
220
- }
221
- removeByTag(tag) {
222
- this.files = this.files.filter((file) => file.tag !== tag);
223
- }
224
- writeAll() {
225
- const toWrite = this.files.filter((file) => !file.persisted);
226
- return Promise.all(toWrite.map((file) => file.write()));
227
- }
228
- writeByTag(tag) {
229
- const files = this.getByTag(tag);
230
- const toWrite = files.filter((file) => !file.persisted);
231
- return Promise.all(toWrite.map((file) => file.write()));
232
- }
233
- unlinkAll() {
234
- return Promise.all(this.files.map((file) => file.unlink())).then(() => {
235
- });
236
- }
237
- getPersistedFiles() {
238
- return this.files.filter((file) => file.persisted);
239
- }
175
+ files = [];
176
+ fileOptions;
177
+ constructor(fileOptions) {
178
+ this.fileOptions = fileOptions;
179
+ }
180
+ createAndAdd(filename, content, tag, options) {
181
+ const file = new File(filename, content, tag, {
182
+ ...this.fileOptions,
183
+ ...options
184
+ });
185
+ this.add(file);
186
+ return file;
187
+ }
188
+ add(...file) {
189
+ this.files.push(...file);
190
+ }
191
+ get(filename) {
192
+ return this.files.find((file) => file.filename === filename);
193
+ }
194
+ getAll() {
195
+ return this.files;
196
+ }
197
+ getByTag(tag) {
198
+ return this.files.filter((file) => file.tag === tag);
199
+ }
200
+ remove(filename) {
201
+ const index = this.files.findIndex((file) => file.filename === filename);
202
+ this.files.splice(index, 1);
203
+ }
204
+ removeAll() {
205
+ this.files = [];
206
+ }
207
+ removeByTag(tag) {
208
+ this.files = this.files.filter((file) => file.tag !== tag);
209
+ }
210
+ writeAll() {
211
+ const toWrite = this.files.filter((file) => !file.persisted);
212
+ return Promise.all(toWrite.map((file) => file.write()));
213
+ }
214
+ writeByTag(tag) {
215
+ const toWrite = this.getByTag(tag).filter((file) => !file.persisted);
216
+ return Promise.all(toWrite.map((file) => file.write()));
217
+ }
218
+ unlinkAll() {
219
+ return Promise.all(this.files.map((file) => file.unlink())).then(() => {});
220
+ }
221
+ getPersistedFiles() {
222
+ return this.files.filter((file) => file.persisted);
223
+ }
240
224
  };
241
225
 
242
- // lib/module.ts
243
- import { pascalCase } from "change-case-all";
226
+ //#endregion
227
+ //#region lib/module.ts
244
228
  function getModuleExportName(name) {
245
- return `${pascalCase(name)}Module`;
229
+ return `${pascalCase(name)}Module`;
246
230
  }
247
231
 
248
- // lib/plugin.ts
249
- import { PluginType } from "@baeta/plugin";
250
- var GeneratorPluginVersion = {
251
- V1: "v1"
252
- };
253
- var defaultPluginFn = async (_ctx, next) => {
254
- return next();
232
+ //#endregion
233
+ //#region lib/plugin.ts
234
+ const GeneratorPluginVersion = { V1: "v1" };
235
+ const defaultPluginFn = async (_ctx, next) => {
236
+ return next();
255
237
  };
256
- var defaultWatchFn = () => ({ include: [], ignore: [] });
238
+ const defaultWatchFn = () => ({
239
+ include: [],
240
+ ignore: []
241
+ });
257
242
  function createPluginV1(options) {
258
- return {
259
- name: options.name,
260
- actionName: options.actionName,
261
- version: GeneratorPluginVersion.V1,
262
- type: PluginType.Generator,
263
- end: options.end ?? defaultPluginFn,
264
- generate: options.generate ?? defaultPluginFn,
265
- setup: options.setup ?? defaultPluginFn,
266
- watch: options.watch ?? defaultWatchFn
267
- };
243
+ return {
244
+ name: options.name,
245
+ actionName: options.actionName,
246
+ version: GeneratorPluginVersion.V1,
247
+ type: PluginType.Generator,
248
+ end: options.end ?? defaultPluginFn,
249
+ generate: options.generate ?? defaultPluginFn,
250
+ setup: options.setup ?? defaultPluginFn,
251
+ watch: options.watch ?? defaultWatchFn
252
+ };
268
253
  }
269
254
  function isGeneratorPlugin(plugin) {
270
- return plugin.type === PluginType.Generator;
255
+ return plugin.type === PluginType.Generator;
271
256
  }
272
257
  function getGeneratorPlugins(plugins) {
273
- if (!plugins) {
274
- return [];
275
- }
276
- return plugins.filter(isGeneratorPlugin);
258
+ if (!plugins) return [];
259
+ return plugins.filter(isGeneratorPlugin);
277
260
  }
278
261
 
279
- // lib/watcher.ts
280
- import path2, { posixPath as posixPath2 } from "@baeta/util-path";
281
- import {
282
- subscribe
283
- } from "@parcel/watcher";
284
- import micromatch2 from "micromatch";
285
-
286
- // lib/watcher-ignore.ts
287
- import path from "@baeta/util-path";
288
- import micromatch from "micromatch";
262
+ //#endregion
263
+ //#region lib/watcher-ignore.ts
289
264
  var WatcherIgnore = class {
290
- cwd;
291
- files = [];
292
- regexps = [];
293
- functions = [];
294
- globs = [];
295
- globsMap = /* @__PURE__ */ new Map();
296
- constructor(cwd) {
297
- this.cwd = cwd;
298
- }
299
- ignore(pattern) {
300
- if (pattern instanceof RegExp) {
301
- this.regexps.push(pattern);
302
- return;
303
- }
304
- if (typeof pattern === "function") {
305
- this.functions.push(pattern);
306
- return;
307
- }
308
- if (!this.isMicromatch(pattern)) {
309
- this.files.push(this.resolveFile(pattern));
310
- return;
311
- }
312
- this.globsMap.set(pattern, micromatch.matcher(pattern));
313
- this.globs = Array.from(this.globsMap.values());
314
- }
315
- isMicromatch(pattern) {
316
- const result = micromatch.scan(pattern);
317
- return result.isBrace || result.isGlobstar || result.isExtglob || result.isGlob;
318
- }
319
- resolveFile(file) {
320
- return path.isAbsolute(file) ? file : path.join(this.cwd, file);
321
- }
322
- unignore(pattern) {
323
- if (pattern instanceof RegExp) {
324
- this.regexps = this.regexps.filter((p) => p !== pattern);
325
- return;
326
- }
327
- if (typeof pattern === "function") {
328
- this.functions = this.functions.filter((p) => p !== pattern);
329
- return;
330
- }
331
- if (!this.isMicromatch(pattern)) {
332
- const file = this.resolveFile(pattern);
333
- this.files = this.files.filter((p) => p !== file);
334
- return;
335
- }
336
- this.globsMap.delete(pattern);
337
- this.globs = Array.from(this.globsMap.values());
338
- }
339
- isIgnored(path3) {
340
- if (this.files.includes(path3)) {
341
- return true;
342
- }
343
- if (this.globs.some((f) => f(path3))) {
344
- return true;
345
- }
346
- if (this.regexps.some((r) => r.test(path3))) {
347
- return true;
348
- }
349
- if (this.functions.some((f) => f(path3))) {
350
- return true;
351
- }
352
- return false;
353
- }
265
+ cwd;
266
+ files = [];
267
+ regexps = [];
268
+ functions = [];
269
+ globs = [];
270
+ globsMap = /* @__PURE__ */ new Map();
271
+ constructor(cwd) {
272
+ this.cwd = cwd;
273
+ }
274
+ ignore(pattern) {
275
+ if (pattern instanceof RegExp) {
276
+ this.regexps.push(pattern);
277
+ return;
278
+ }
279
+ if (typeof pattern === "function") {
280
+ this.functions.push(pattern);
281
+ return;
282
+ }
283
+ if (!this.isMicromatch(pattern)) {
284
+ this.files.push(this.resolveFile(pattern));
285
+ return;
286
+ }
287
+ this.globsMap.set(pattern, micromatch$1.matcher(pattern));
288
+ this.globs = Array.from(this.globsMap.values());
289
+ }
290
+ isMicromatch(pattern) {
291
+ const result = micromatch$1.scan(pattern);
292
+ return result.isBrace || result.isGlobstar || result.isExtglob || result.isGlob;
293
+ }
294
+ resolveFile(file) {
295
+ return path.isAbsolute(file) ? file : path.join(this.cwd, file);
296
+ }
297
+ unignore(pattern) {
298
+ if (pattern instanceof RegExp) {
299
+ this.regexps = this.regexps.filter((p) => p !== pattern);
300
+ return;
301
+ }
302
+ if (typeof pattern === "function") {
303
+ this.functions = this.functions.filter((p) => p !== pattern);
304
+ return;
305
+ }
306
+ if (!this.isMicromatch(pattern)) {
307
+ const file = this.resolveFile(pattern);
308
+ this.files = this.files.filter((p) => p !== file);
309
+ return;
310
+ }
311
+ this.globsMap.delete(pattern);
312
+ this.globs = Array.from(this.globsMap.values());
313
+ }
314
+ isIgnored(path$1) {
315
+ if (this.files.includes(path$1)) return true;
316
+ if (this.globs.some((f) => f(path$1))) return true;
317
+ if (this.regexps.some((r) => r.test(path$1))) return true;
318
+ if (this.functions.some((f) => f(path$1))) return true;
319
+ return false;
320
+ }
354
321
  };
355
322
 
356
- // lib/watcher.ts
357
- var isMatch = micromatch2.isMatch;
323
+ //#endregion
324
+ //#region lib/watcher.ts
325
+ const isMatch = micromatch.isMatch;
358
326
  var Watcher = class {
359
- cwd;
360
- options;
361
- subscription;
362
- listeners = {
363
- create: [],
364
- update: [],
365
- delete: []
366
- };
367
- watcherIgnore;
368
- constructor(cwd, options) {
369
- this.cwd = cwd;
370
- this.options = options;
371
- this.watcherIgnore = new WatcherIgnore(cwd);
372
- this.subscription = this.createSubscription();
373
- }
374
- onEvents = (err, events) => {
375
- if (err) {
376
- console.error(err);
377
- return;
378
- }
379
- const filteredEvents = events.filter((event) => {
380
- return !this.watcherIgnore.isIgnored(posixPath2(event.path));
381
- });
382
- for (const event of filteredEvents) {
383
- for (const listener of this.listeners[event.type]) {
384
- listener({
385
- type: event.type,
386
- path: posixPath2(event.path),
387
- relativePath: posixPath2(path2.relative(this.cwd, event.path))
388
- });
389
- }
390
- }
391
- };
392
- on(event, listener) {
393
- this.listeners[event].push(listener);
394
- }
395
- off(event, listener) {
396
- this.listeners[event] = this.listeners[event].filter((l) => l !== listener);
397
- }
398
- ignore(pattern) {
399
- this.watcherIgnore.ignore(pattern);
400
- }
401
- unignore(pattern) {
402
- this.watcherIgnore.unignore(pattern);
403
- }
404
- createSubscription() {
405
- const promise = subscribe(this.cwd, this.onEvents, this.options);
406
- const unsubscribe = async () => {
407
- const subscription = await promise;
408
- await subscription.unsubscribe();
409
- };
410
- return {
411
- unsubscribe
412
- };
413
- }
414
- close() {
415
- return this.subscription.unsubscribe();
416
- }
417
- };
418
- export {
419
- File,
420
- FileBlock,
421
- FileManager,
422
- GeneratorPluginVersion,
423
- Watcher,
424
- WatcherIgnore,
425
- createPluginV1,
426
- getGeneratorPlugins,
427
- getModuleExportName,
428
- isGeneratorPlugin,
429
- isMatch,
430
- loadOptions,
431
- micromatch2 as micromatch
327
+ cwd;
328
+ options;
329
+ subscription;
330
+ listeners = {
331
+ create: [],
332
+ update: [],
333
+ delete: []
334
+ };
335
+ watcherIgnore;
336
+ constructor(cwd, options) {
337
+ this.cwd = cwd;
338
+ this.options = options;
339
+ this.watcherIgnore = new WatcherIgnore(cwd);
340
+ this.subscription = this.createSubscription();
341
+ }
342
+ onEvents = (err, events) => {
343
+ if (err) {
344
+ console.error(err);
345
+ return;
346
+ }
347
+ const filteredEvents = events.filter((event) => {
348
+ return !this.watcherIgnore.isIgnored(posixPath(event.path));
349
+ });
350
+ for (const event of filteredEvents) for (const listener of this.listeners[event.type]) listener({
351
+ type: event.type,
352
+ path: posixPath(event.path),
353
+ relativePath: posixPath(path.relative(this.cwd, event.path))
354
+ });
355
+ };
356
+ on(event, listener) {
357
+ this.listeners[event].push(listener);
358
+ }
359
+ off(event, listener) {
360
+ this.listeners[event] = this.listeners[event].filter((l) => l !== listener);
361
+ }
362
+ ignore(pattern) {
363
+ this.watcherIgnore.ignore(pattern);
364
+ }
365
+ unignore(pattern) {
366
+ this.watcherIgnore.unignore(pattern);
367
+ }
368
+ createSubscription() {
369
+ const promise = subscribe(this.cwd, this.onEvents, this.options);
370
+ const unsubscribe = async () => {
371
+ await (await promise).unsubscribe();
372
+ };
373
+ return { unsubscribe };
374
+ }
375
+ close() {
376
+ return this.subscription.unsubscribe();
377
+ }
432
378
  };
379
+
380
+ //#endregion
381
+ export { File, FileBlock, FileManager, GeneratorPluginVersion, Watcher, WatcherIgnore, createPluginV1, getGeneratorPlugins, getModuleExportName, isGeneratorPlugin, isMatch, loadOptions, micromatch };
433
382
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../lib/config.ts","../lib/file.ts","../lib/file-block.ts","../lib/file-manager.ts","../lib/module.ts","../lib/plugin.ts","../lib/watcher.ts","../lib/watcher-ignore.ts"],"sourcesContent":["import { posixPath, resolve } from '@baeta/util-path';\nimport type { FileOptions } from './file.ts';\n\n/**\n * Interface for custom schema loaders.\n */\n// biome-ignore lint/suspicious/noExplicitAny: We don't want to import graphql for this type\ntype GraphQlLoaderAny = any;\nexport interface Loader<TOptions = GraphQlLoaderAny> {\n\tload(pointer: string, options?: TOptions): Promise<GraphQlLoaderAny[] | null | never>;\n\tloadSync?(pointer: string, options?: TOptions): GraphQlLoaderAny[] | null | never;\n}\n\n/**\n * Options for the Baeta Generator.\n */\nexport interface GeneratorOptions {\n\t/**\n\t * Current working directory for resolving relative paths.\n\t * @defaultValue process.cwd()\n\t */\n\tcwd?: string;\n\n\t/**\n\t * Glob pattern(s) to locate GraphQL schema files.\n\t * @defaultValue ```ts\n\t * ['src/∗∗/∗.gql', 'src/∗∗/∗.graphql']\n\t * ```\n\t */\n\tschemas: string[];\n\n\t/**\n\t * Root directory where GraphQL modules are defined.\n\t * @defaultValue 'src/modules'\n\t */\n\tmodulesDir?: string;\n\n\t/**\n\t * Filename for the generated module definition file.\n\t * Contains type definitions and the GraphQL AST.\n\t * @defaultValue 'typedef.ts'\n\t */\n\tmoduleDefinitionName?: string;\n\n\t/**\n\t * Output path for the generated type files.\n\t * @defaultValue ```ts\n\t * `${modulesDir}/../__generated__/types.ts`\n\t * ```\n\t */\n\ttypesDir?: string;\n\n\t/**\n\t * Configuration options for generated files.\n\t */\n\tfileOptions?: FileOptions;\n\n\t/**\n\t * Custom schema loaders for processing schema files.\n\t */\n\tloaders?: Loader[];\n\n\t/**\n\t * File extension to use in generated import statements.\n\t * Set to false to omit extensions.\n\t * @defaultValue '.ts'\n\t */\n\timportExtension?: '.js' | '.ts' | false;\n}\n\nexport interface NormalizedGeneratorOptions {\n\tcwd: string;\n\tschemas: string[];\n\tmodulesDir: string;\n\tmoduleDefinitionName: string;\n\ttypesDir: string;\n\tfileOptions?: FileOptions;\n\tloaders?: Loader[];\n\timportExtension: '.js' | '.ts' | '';\n}\n\nexport function loadOptions(options: GeneratorOptions): NormalizedGeneratorOptions {\n\tconst cwd = posixPath(options.cwd ?? process.cwd());\n\tconst schemas = options.schemas ?? ['src/**/*.graphql'];\n\tconst modulesDir = posixPath(resolve(cwd, options.modulesDir || 'src/modules'));\n\tconst moduleDefinitionName = options.moduleDefinitionName || 'typedef.ts';\n\tconst defaultTypesDir = resolve(modulesDir, '../__generated__/');\n\tconst typesDir = resolve(cwd, options.typesDir || defaultTypesDir);\n\n\treturn {\n\t\tcwd,\n\t\tschemas,\n\t\tmodulesDir,\n\t\tmoduleDefinitionName,\n\t\ttypesDir,\n\t\tfileOptions: options.fileOptions,\n\t\tloaders: options.loaders,\n\t\timportExtension: options.importExtension === false ? '' : (options.importExtension ?? '.ts'),\n\t};\n}\n","import fs from 'node:fs/promises';\nimport { dirname, extname } from '@baeta/util-path';\n\n/**\n * Options for generated files.\n */\nexport interface FileOptions {\n\t/**\n\t * Disable generation notice at the beginning of the file.\n\t * @defaultValue false\n\t */\n\tdisableGenerationNoticeHeader?: boolean;\n\n\t/**\n\t * Disable eslint-disable comment at the beginning of the file.\n\t * @defaultValue false\n\t */\n\tdisableEslintHeader?: boolean;\n\n\t/**\n\t * Disable biome comment at the beginning of the file.\n\t * @defaultValue false\n\t */\n\tdisableBiomeHeader?: boolean;\n\n\t/**\n\t * Allow overwriting the file.\n\t * @defaultValue true\n\t */\n\tallowOverwrite?: boolean;\n\n\t/**\n\t * Add custom header at the beginning of the file.\n\t */\n\taddHeader?: (name: string, content: string, tag: string) => string;\n\n\t/**\n\t * Edit the content of the file before writing it.\n\t */\n\ttransformContent?: (name: string, content: string, tag: string) => string | Promise<string>;\n}\n\nexport class File {\n\tpersisted = false;\n\tfilename: string;\n\tcontent: string;\n\ttag: string;\n\tprivate options?: FileOptions;\n\n\tconstructor(filename: string, content: string, tag: string, options?: FileOptions) {\n\t\tthis.filename = filename;\n\t\tthis.content = content;\n\t\tthis.tag = tag;\n\t\tthis.options = options;\n\t}\n\n\twrite = async () => {\n\t\tif (this.persisted) {\n\t\t\treturn;\n\t\t}\n\t\tthis.persisted = true;\n\n\t\tif (this.options?.allowOverwrite === false) {\n\t\t\tconst exists = await fs\n\t\t\t\t.stat(this.filename)\n\t\t\t\t.then((res) => res.isFile())\n\t\t\t\t.catch(() => false);\n\t\t\tif (exists) return;\n\t\t}\n\n\t\tconst dir = dirname(this.filename);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\n\t\tconst content = await this.buildContent();\n\n\t\treturn fs.writeFile(this.filename, content, 'utf-8');\n\t};\n\n\tunlink = async () => {\n\t\tthis.persisted = false;\n\t\treturn fs.unlink(this.filename);\n\t};\n\n\tprotected async buildContent() {\n\t\tconst content = this.buildHeader() + this.content;\n\n\t\tif (this.options?.transformContent) {\n\t\t\treturn this.options.transformContent(this.filename, content, this.tag);\n\t\t}\n\n\t\treturn content;\n\t}\n\n\tprotected buildHeader() {\n\t\tconst headerItems: string[] = [];\n\n\t\tif (this.options?.disableGenerationNoticeHeader !== true) {\n\t\t\tconst comment = this.createComment(\n\t\t\t\t'This file was generated by Baeta. Do not edit it directly. All changes will be overwritten by the generator.',\n\t\t\t);\n\t\t\theaderItems.push(comment);\n\t\t}\n\n\t\tif (this.options?.disableEslintHeader !== true) {\n\t\t\tconst comment = this.createComment('eslint-disable');\n\t\t\theaderItems.push(comment);\n\t\t}\n\n\t\tif (this.options?.disableBiomeHeader !== true) {\n\t\t\tconst comment = this.createComment('@biome-ignore-all: generated file');\n\t\t\theaderItems.push(comment);\n\t\t}\n\n\t\tif (this.options?.addHeader) {\n\t\t\tconst customHeader = this.options.addHeader(this.filename, this.content, this.tag);\n\t\t\theaderItems.push(customHeader);\n\t\t}\n\n\t\tif (headerItems.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn `${headerItems.join('\\n')}\\n\\n`;\n\t}\n\n\tprotected createComment(comment: string) {\n\t\tconst extension = extname(this.filename);\n\n\t\tif (['.gql', '.graphql'].includes(extension)) {\n\t\t\treturn `# ${comment}`;\n\t\t}\n\n\t\treturn `/* ${comment} */`;\n\t}\n}\n","import { mkdir, open, writeFile } from 'node:fs/promises';\nimport { dirname } from '@baeta/util-path';\nimport { File, type FileOptions } from './file.ts';\n\nexport class FileBlock extends File {\n\tpublic filename: string;\n\tpublic content: string;\n\tpublic start: string;\n\tpublic end: string;\n\tpublic tag: string;\n\tconstructor(\n\t\tfilename: string,\n\t\tcontent: string,\n\t\tstart: string,\n\t\tend: string,\n\t\ttag: string,\n\t\toptions?: FileOptions,\n\t) {\n\t\tsuper(filename, content, tag, {\n\t\t\tdisableBiomeHeader: options?.disableBiomeHeader ?? true,\n\t\t\tdisableEslintHeader: options?.disableEslintHeader ?? true,\n\t\t\tdisableGenerationNoticeHeader: options?.disableGenerationNoticeHeader ?? true,\n\t\t});\n\t\tthis.filename = filename;\n\t\tthis.content = content;\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t\tthis.tag = tag;\n\t}\n\n\twrite = async () => {\n\t\tif (this.persisted) {\n\t\t\treturn;\n\t\t}\n\t\tthis.persisted = true;\n\n\t\tconst dir = dirname(this.filename);\n\t\tawait mkdir(dir, { recursive: true });\n\n\t\tconst [existingContent, fd] = await this.getExistingContent();\n\n\t\tthis.content = this.addBlockToContent(existingContent);\n\t\tconst content = await this.buildContent();\n\n\t\tif (fd) {\n\t\t\tawait fd.truncate(0);\n\t\t\tawait fd.write(content, 0, 'utf-8');\n\t\t\tawait fd.close();\n\t\t} else {\n\t\t\tawait writeFile(this.filename, content, 'utf-8');\n\t\t}\n\t};\n\n\tunlink = async () => {\n\t\tthis.persisted = false;\n\n\t\tconst [existingContent, fd] = await this.getExistingContent();\n\n\t\tif (fd) {\n\t\t\tconst [start, end] = this.getSlices(existingContent);\n\t\t\tawait fd.truncate(0);\n\t\t\tawait fd.write(start + end, 0, 'utf-8');\n\t\t\tawait fd.close();\n\t\t}\n\t};\n\n\tprotected async getExistingContent() {\n\t\ttry {\n\t\t\tconst fd = await open(this.filename, 'r+');\n\t\t\tconst existingContent = await fd.readFile('utf-8');\n\t\t\treturn [existingContent, fd] as const;\n\t\t} catch {\n\t\t\treturn ['', null] as const;\n\t\t}\n\t}\n\n\tprotected getSlices(existingContent: string) {\n\t\tconst startMarkerIndex = existingContent.indexOf(this.start);\n\t\tconst endMarkerIndex = existingContent.lastIndexOf(this.end);\n\n\t\tif (startMarkerIndex === -1 || endMarkerIndex === -1) {\n\t\t\treturn [existingContent, '', false] as const;\n\t\t}\n\n\t\treturn [\n\t\t\texistingContent.slice(0, startMarkerIndex),\n\t\t\texistingContent.slice(endMarkerIndex + this.end.length),\n\t\t\ttrue,\n\t\t] as const;\n\t}\n\n\tprotected addBlockToContent(existingContent: string) {\n\t\tconst block = `${this.start}\\n${this.content}\\n${this.end}`;\n\t\tconst [startSlice, endSlice, hasMarkers] = this.getSlices(existingContent);\n\t\tconst padding = hasMarkers ? '' : this.buildPadding(existingContent);\n\t\treturn startSlice + padding + block + endSlice;\n\t}\n\n\tprotected buildPadding(existingContent: string) {\n\t\tif (existingContent === '') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (existingContent.endsWith('\\n\\n')) {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (existingContent.endsWith('\\n')) {\n\t\t\treturn '\\n';\n\t\t}\n\n\t\treturn '\\n\\n';\n\t}\n}\n","import { File, type FileOptions } from './file.ts';\n\nexport class FileManager {\n\tfiles: File[] = [];\n\tfileOptions?: FileOptions;\n\n\tconstructor(fileOptions?: FileOptions) {\n\t\tthis.fileOptions = fileOptions;\n\t}\n\n\tcreateAndAdd(filename: string, content: string, tag: string, options?: FileOptions) {\n\t\tconst file = new File(filename, content, tag, { ...this.fileOptions, ...options });\n\t\tthis.add(file);\n\t\treturn file;\n\t}\n\n\tadd(...file: File[]) {\n\t\tthis.files.push(...file);\n\t}\n\n\tget(filename: string) {\n\t\treturn this.files.find((file) => file.filename === filename);\n\t}\n\n\tgetAll() {\n\t\treturn this.files;\n\t}\n\n\tgetByTag(tag: string) {\n\t\treturn this.files.filter((file) => file.tag === tag);\n\t}\n\n\tremove(filename: string) {\n\t\tconst index = this.files.findIndex((file) => file.filename === filename);\n\t\tthis.files.splice(index, 1);\n\t}\n\n\tremoveAll() {\n\t\tthis.files = [];\n\t}\n\n\tremoveByTag(tag: string) {\n\t\tthis.files = this.files.filter((file) => file.tag !== tag);\n\t}\n\n\twriteAll() {\n\t\tconst toWrite = this.files.filter((file) => !file.persisted);\n\t\treturn Promise.all(toWrite.map((file) => file.write()));\n\t}\n\n\twriteByTag(tag: string) {\n\t\tconst files = this.getByTag(tag);\n\t\tconst toWrite = files.filter((file) => !file.persisted);\n\t\treturn Promise.all(toWrite.map((file) => file.write()));\n\t}\n\n\tunlinkAll() {\n\t\treturn Promise.all(this.files.map((file) => file.unlink())).then(() => {\n\t\t\t// void\n\t\t});\n\t}\n\n\tgetPersistedFiles() {\n\t\treturn this.files.filter((file) => file.persisted);\n\t}\n}\n","import { pascalCase } from 'change-case-all';\n\nexport function getModuleExportName(name: string) {\n\treturn `${pascalCase(name)}Module`;\n}\n","import { PluginType } from '@baeta/plugin';\nimport type { NormalizedGeneratorOptions } from './config.ts';\nimport type { Ctx } from './ctx.ts';\nimport type { Watcher, WatcherFile } from './watcher.ts';\n\nexport const GeneratorPluginVersion = {\n\tV1: 'v1',\n} as const;\n\nexport type GeneratorPluginVersion =\n\t(typeof GeneratorPluginVersion)[keyof typeof GeneratorPluginVersion];\n\nexport type GeneratorPluginV1Fn<Store = unknown> = (\n\tctx: Ctx<Store>,\n\tnext: () => Promise<void>,\n) => Promise<void>;\n\nexport type GeneratorPluginV1ReloadFn = (file: WatcherFile) => void;\n\nexport type GeneratorPluginV1WatchOptions = (\n\toptions: NormalizedGeneratorOptions,\n\twatcher: Watcher,\n\treload: GeneratorPluginV1ReloadFn,\n) => void;\n\nexport type GeneratorPluginV1Factory<Store = unknown> = {\n\tname: string;\n\tactionName: string;\n\tsetup?: GeneratorPluginV1Fn<Store>;\n\tgenerate?: GeneratorPluginV1Fn<Store>;\n\tend?: GeneratorPluginV1Fn<Store>;\n\twatch?: GeneratorPluginV1WatchOptions;\n};\n\nexport interface GeneratorPluginV1<Store = unknown> {\n\tname: string;\n\tactionName: string;\n\tversion: typeof GeneratorPluginVersion.V1;\n\ttype: typeof PluginType.Generator;\n\tsetup: GeneratorPluginV1Fn<Store>;\n\tgenerate: GeneratorPluginV1Fn<Store>;\n\tend: GeneratorPluginV1Fn<Store>;\n\twatch: GeneratorPluginV1WatchOptions;\n}\n\nconst defaultPluginFn: GeneratorPluginV1Fn<unknown> = async (_ctx, next) => {\n\treturn next();\n};\n\nconst defaultWatchFn = () => ({ include: [], ignore: [] });\n\nexport function createPluginV1<Store = unknown>(\n\toptions: GeneratorPluginV1Factory<Store>,\n): GeneratorPluginV1<Store> {\n\treturn {\n\t\tname: options.name,\n\t\tactionName: options.actionName,\n\t\tversion: GeneratorPluginVersion.V1,\n\t\ttype: PluginType.Generator,\n\t\tend: options.end ?? defaultPluginFn,\n\t\tgenerate: options.generate ?? defaultPluginFn,\n\t\tsetup: options.setup ?? defaultPluginFn,\n\t\twatch: options.watch ?? defaultWatchFn,\n\t};\n}\n\nexport function isGeneratorPlugin(plugin: {\n\ttype: PluginType;\n}): plugin is GeneratorPluginV1<unknown> {\n\treturn plugin.type === PluginType.Generator;\n}\n\nexport function getGeneratorPlugins(plugins?: Array<{ type: PluginType }>) {\n\tif (!plugins) {\n\t\treturn [];\n\t}\n\treturn plugins.filter(isGeneratorPlugin);\n}\n","import path, { posixPath } from '@baeta/util-path';\nimport {\n\ttype AsyncSubscription,\n\ttype Event,\n\ttype EventType,\n\ttype Options,\n\tsubscribe,\n} from '@parcel/watcher';\nimport micromatch from 'micromatch';\nimport { type MatchPattern, WatcherIgnore } from './watcher-ignore.ts';\n\nexport { micromatch };\nexport const isMatch = micromatch.isMatch;\n\nexport type WatcherListener = (path: WatcherFile) => void;\n\nexport interface WatcherFile {\n\ttype: EventType;\n\tpath: string;\n\trelativePath: string;\n}\nexport class Watcher {\n\tprivate readonly cwd: string;\n\tprivate readonly options?: Options;\n\n\tprivate subscription: AsyncSubscription;\n\n\tprivate listeners: Record<EventType, WatcherListener[]> = {\n\t\tcreate: [],\n\t\tupdate: [],\n\t\tdelete: [],\n\t};\n\n\tprivate watcherIgnore: WatcherIgnore;\n\n\tconstructor(cwd: string, options?: Options) {\n\t\tthis.cwd = cwd;\n\t\tthis.options = options;\n\t\tthis.watcherIgnore = new WatcherIgnore(cwd);\n\t\tthis.subscription = this.createSubscription();\n\t}\n\n\tonEvents = (err: Error | null, events: Event[]) => {\n\t\tif (err) {\n\t\t\tconsole.error(err);\n\t\t\treturn;\n\t\t}\n\n\t\tconst filteredEvents = events.filter((event) => {\n\t\t\treturn !this.watcherIgnore.isIgnored(posixPath(event.path));\n\t\t});\n\n\t\tfor (const event of filteredEvents) {\n\t\t\tfor (const listener of this.listeners[event.type]) {\n\t\t\t\tlistener({\n\t\t\t\t\ttype: event.type,\n\t\t\t\t\tpath: posixPath(event.path),\n\t\t\t\t\trelativePath: posixPath(path.relative(this.cwd, event.path)),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n\n\ton(event: EventType, listener: WatcherListener) {\n\t\tthis.listeners[event].push(listener);\n\t}\n\n\toff(event: EventType, listener: WatcherListener) {\n\t\tthis.listeners[event] = this.listeners[event].filter((l) => l !== listener);\n\t}\n\n\tignore(pattern: MatchPattern) {\n\t\tthis.watcherIgnore.ignore(pattern);\n\t}\n\n\tunignore(pattern: MatchPattern) {\n\t\tthis.watcherIgnore.unignore(pattern);\n\t}\n\n\tcreateSubscription() {\n\t\tconst promise = subscribe(this.cwd, this.onEvents, this.options);\n\n\t\tconst unsubscribe = async () => {\n\t\t\tconst subscription = await promise;\n\t\t\tawait subscription.unsubscribe();\n\t\t};\n\n\t\treturn {\n\t\t\tunsubscribe,\n\t\t};\n\t}\n\n\tclose() {\n\t\treturn this.subscription.unsubscribe();\n\t}\n}\n","import path from '@baeta/util-path';\nimport micromatch from 'micromatch';\n\nexport type MatchFn = (testString: string) => boolean;\nexport type MatchPattern = string | RegExp | MatchFn;\n\nexport class WatcherIgnore {\n\tprivate readonly cwd: string;\n\tprivate files: string[] = [];\n\tprivate regexps: RegExp[] = [];\n\tprivate functions: MatchFn[] = [];\n\n\tprivate globs: MatchFn[] = [];\n\tprivate globsMap = new Map<string, MatchFn>();\n\n\tconstructor(cwd: string) {\n\t\tthis.cwd = cwd;\n\t}\n\n\tignore(pattern: MatchPattern) {\n\t\tif (pattern instanceof RegExp) {\n\t\t\tthis.regexps.push(pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof pattern === 'function') {\n\t\t\tthis.functions.push(pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.isMicromatch(pattern)) {\n\t\t\tthis.files.push(this.resolveFile(pattern));\n\t\t\treturn;\n\t\t}\n\n\t\tthis.globsMap.set(pattern, micromatch.matcher(pattern));\n\t\tthis.globs = Array.from(this.globsMap.values());\n\t}\n\n\tisMicromatch(pattern: string) {\n\t\tconst result = micromatch.scan(pattern);\n\t\treturn result.isBrace || result.isGlobstar || result.isExtglob || result.isGlob;\n\t}\n\n\tresolveFile(file: string) {\n\t\treturn path.isAbsolute(file) ? file : path.join(this.cwd, file);\n\t}\n\n\tunignore(pattern: MatchPattern) {\n\t\tif (pattern instanceof RegExp) {\n\t\t\tthis.regexps = this.regexps.filter((p) => p !== pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof pattern === 'function') {\n\t\t\tthis.functions = this.functions.filter((p) => p !== pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.isMicromatch(pattern)) {\n\t\t\tconst file = this.resolveFile(pattern);\n\t\t\tthis.files = this.files.filter((p) => p !== file);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.globsMap.delete(pattern);\n\t\tthis.globs = Array.from(this.globsMap.values());\n\t}\n\n\tisIgnored(path: string) {\n\t\tif (this.files.includes(path)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.globs.some((f) => f(path))) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.regexps.some((r) => r.test(path))) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.functions.some((f) => f(path))) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n}\n"],"mappings":";AAAA,SAAS,WAAW,eAAe;AAiF5B,SAAS,YAAY,SAAuD;AAClF,QAAM,MAAM,UAAU,QAAQ,OAAO,QAAQ,IAAI,CAAC;AAClD,QAAM,UAAU,QAAQ,WAAW,CAAC,kBAAkB;AACtD,QAAM,aAAa,UAAU,QAAQ,KAAK,QAAQ,cAAc,aAAa,CAAC;AAC9E,QAAM,uBAAuB,QAAQ,wBAAwB;AAC7D,QAAM,kBAAkB,QAAQ,YAAY,mBAAmB;AAC/D,QAAM,WAAW,QAAQ,KAAK,QAAQ,YAAY,eAAe;AAEjE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,QAAQ;AAAA,IACrB,SAAS,QAAQ;AAAA,IACjB,iBAAiB,QAAQ,oBAA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MACN;AAAA,IACD;AAAA,EACD;AAAA,EAEA,QAAQ;AACP,WAAO,KAAK,aAAa,YAAY;AAAA,EACtC;AACD;","names":["dirname","dirname","path","posixPath","micromatch","path","micromatch","posixPath","path"]}
1
+ {"version":3,"file":"index.js","names":["headerItems: string[]","defaultPluginFn: GeneratorPluginV1Fn<unknown>","micromatch","path"],"sources":["../lib/config.ts","../lib/file.ts","../lib/file-block.ts","../lib/file-manager.ts","../lib/module.ts","../lib/plugin.ts","../lib/watcher-ignore.ts","../lib/watcher.ts"],"sourcesContent":["import { posixPath, resolve } from '@baeta/util-path';\nimport type { FileOptions } from './file.ts';\n\n/**\n * Interface for custom schema loaders.\n */\n// biome-ignore lint/suspicious/noExplicitAny: We don't want to import graphql for this type\ntype GraphQlLoaderAny = any;\nexport interface Loader<TOptions = GraphQlLoaderAny> {\n\tload(pointer: string, options?: TOptions): Promise<GraphQlLoaderAny[] | null | never>;\n\tloadSync?(pointer: string, options?: TOptions): GraphQlLoaderAny[] | null | never;\n}\n\n/**\n * Options for the Baeta Generator.\n */\nexport interface GeneratorOptions {\n\t/**\n\t * Current working directory for resolving relative paths.\n\t * @defaultValue process.cwd()\n\t */\n\tcwd?: string;\n\n\t/**\n\t * Glob pattern(s) to locate GraphQL schema files.\n\t * @defaultValue ```ts\n\t * ['src/∗∗/∗.gql', 'src/∗∗/∗.graphql']\n\t * ```\n\t */\n\tschemas: string[];\n\n\t/**\n\t * Root directory where GraphQL modules are defined.\n\t * @defaultValue 'src/modules'\n\t */\n\tmodulesDir?: string;\n\n\t/**\n\t * Filename for the generated module definition file.\n\t * Contains type definitions and the GraphQL AST.\n\t * @defaultValue 'typedef.ts'\n\t */\n\tmoduleDefinitionName?: string;\n\n\t/**\n\t * Output path for the generated type files.\n\t * @defaultValue ```ts\n\t * `${modulesDir}/../__generated__/types.ts`\n\t * ```\n\t */\n\ttypesDir?: string;\n\n\t/**\n\t * Configuration options for generated files.\n\t */\n\tfileOptions?: FileOptions;\n\n\t/**\n\t * Custom schema loaders for processing schema files.\n\t */\n\tloaders?: Loader[];\n\n\t/**\n\t * File extension to use in generated import statements.\n\t * Set to false to omit extensions.\n\t * @defaultValue '.ts'\n\t */\n\timportExtension?: '.js' | '.ts' | false;\n}\n\nexport interface NormalizedGeneratorOptions {\n\tcwd: string;\n\tschemas: string[];\n\tmodulesDir: string;\n\tmoduleDefinitionName: string;\n\ttypesDir: string;\n\tfileOptions?: FileOptions;\n\tloaders?: Loader[];\n\timportExtension: '.js' | '.ts' | '';\n}\n\nexport function loadOptions(options: GeneratorOptions): NormalizedGeneratorOptions {\n\tconst cwd = posixPath(options.cwd ?? process.cwd());\n\tconst schemas = options.schemas ?? ['src/**/*.graphql'];\n\tconst modulesDir = posixPath(resolve(cwd, options.modulesDir || 'src/modules'));\n\tconst moduleDefinitionName = options.moduleDefinitionName || 'typedef.ts';\n\tconst defaultTypesDir = resolve(modulesDir, '../__generated__/');\n\tconst typesDir = resolve(cwd, options.typesDir || defaultTypesDir);\n\n\treturn {\n\t\tcwd,\n\t\tschemas,\n\t\tmodulesDir,\n\t\tmoduleDefinitionName,\n\t\ttypesDir,\n\t\tfileOptions: options.fileOptions,\n\t\tloaders: options.loaders,\n\t\timportExtension: options.importExtension === false ? '' : (options.importExtension ?? '.ts'),\n\t};\n}\n","import fs from 'node:fs/promises';\nimport { dirname, extname } from '@baeta/util-path';\n\n/**\n * Options for generated files.\n */\nexport interface FileOptions {\n\t/**\n\t * Disable generation notice at the beginning of the file.\n\t * @defaultValue false\n\t */\n\tdisableGenerationNoticeHeader?: boolean;\n\n\t/**\n\t * Disable eslint-disable comment at the beginning of the file.\n\t * @defaultValue false\n\t */\n\tdisableEslintHeader?: boolean;\n\n\t/**\n\t * Disable biome v1 comment at the beginning of the file.\n\t * @defaultValue false\n\t */\n\tdisableBiomeV1Header?: boolean;\n\n\t/**\n\t * Disable biome v2 comment at the beginning of the file.\n\t * @defaultValue false\n\t */\n\tdisableBiomeV2Header?: boolean;\n\n\t/**\n\t * Allow overwriting the file.\n\t * @defaultValue true\n\t */\n\tallowOverwrite?: boolean;\n\n\t/**\n\t * Add custom header at the beginning of the file.\n\t */\n\taddHeader?: (name: string, content: string, tag: string) => string;\n\n\t/**\n\t * Edit the content of the file before writing it.\n\t */\n\ttransformContent?: (name: string, content: string, tag: string) => string | Promise<string>;\n}\n\nexport class File {\n\tpersisted = false;\n\tfilename: string;\n\tcontent: string;\n\ttag: string;\n\tprivate options?: FileOptions;\n\n\tconstructor(filename: string, content: string, tag: string, options?: FileOptions) {\n\t\tthis.filename = filename;\n\t\tthis.content = content;\n\t\tthis.tag = tag;\n\t\tthis.options = options;\n\t}\n\n\twrite = async () => {\n\t\tif (this.persisted) {\n\t\t\treturn;\n\t\t}\n\t\tthis.persisted = true;\n\n\t\tif (this.options?.allowOverwrite === false) {\n\t\t\tconst exists = await fs\n\t\t\t\t.stat(this.filename)\n\t\t\t\t.then((res) => res.isFile())\n\t\t\t\t.catch(() => false);\n\t\t\tif (exists) return;\n\t\t}\n\n\t\tconst dir = dirname(this.filename);\n\t\tawait fs.mkdir(dir, { recursive: true });\n\n\t\tconst content = await this.buildContent();\n\n\t\treturn fs.writeFile(this.filename, content, 'utf-8');\n\t};\n\n\tunlink = async () => {\n\t\tthis.persisted = false;\n\t\treturn fs.unlink(this.filename);\n\t};\n\n\tprotected async buildContent() {\n\t\tconst content = this.buildHeader() + this.content;\n\n\t\tif (this.options?.transformContent) {\n\t\t\treturn this.options.transformContent(this.filename, content, this.tag);\n\t\t}\n\n\t\treturn content;\n\t}\n\n\tprotected buildHeader() {\n\t\tconst headerItems: string[] = [];\n\n\t\tif (this.options?.disableGenerationNoticeHeader !== true) {\n\t\t\tconst comment = this.createComment(\n\t\t\t\t'This file was generated by Baeta. Do not edit it directly. All changes will be overwritten by the generator.',\n\t\t\t);\n\t\t\theaderItems.push(comment);\n\t\t}\n\n\t\tif (this.options?.disableEslintHeader !== true) {\n\t\t\tconst comment = this.createComment('eslint-disable');\n\t\t\theaderItems.push(comment);\n\t\t}\n\n\t\tif (this.options?.disableBiomeV1Header !== true) {\n\t\t\tconst comment = this.createComment('@biome-ignore-all: generated file');\n\t\t\theaderItems.push(comment);\n\t\t}\n\n\t\tif (this.options?.disableBiomeV2Header !== true) {\n\t\t\tconst comment = this.createComment('biome-ignore-all lint: generated file');\n\t\t\theaderItems.push(comment);\n\t\t}\n\n\t\tif (this.options?.addHeader) {\n\t\t\tconst customHeader = this.options.addHeader(this.filename, this.content, this.tag);\n\t\t\theaderItems.push(customHeader);\n\t\t}\n\n\t\tif (headerItems.length === 0) {\n\t\t\treturn '';\n\t\t}\n\n\t\treturn `${headerItems.join('\\n')}\\n\\n`;\n\t}\n\n\tprotected createComment(comment: string) {\n\t\tconst extension = extname(this.filename);\n\n\t\tif (['.gql', '.graphql'].includes(extension)) {\n\t\t\treturn `# ${comment}`;\n\t\t}\n\n\t\treturn `/* ${comment} */`;\n\t}\n}\n","import { mkdir, open, writeFile } from 'node:fs/promises';\nimport { dirname } from '@baeta/util-path';\nimport { File, type FileOptions } from './file.ts';\n\nexport class FileBlock extends File {\n\tpublic filename: string;\n\tpublic content: string;\n\tpublic start: string;\n\tpublic end: string;\n\tpublic tag: string;\n\tconstructor(\n\t\tfilename: string,\n\t\tcontent: string,\n\t\tstart: string,\n\t\tend: string,\n\t\ttag: string,\n\t\toptions?: FileOptions,\n\t) {\n\t\tsuper(filename, content, tag, {\n\t\t\tdisableBiomeV1Header: options?.disableBiomeV1Header ?? true,\n\t\t\tdisableBiomeV2Header: options?.disableBiomeV2Header ?? true,\n\t\t\tdisableEslintHeader: options?.disableEslintHeader ?? true,\n\t\t\tdisableGenerationNoticeHeader: options?.disableGenerationNoticeHeader ?? true,\n\t\t});\n\t\tthis.filename = filename;\n\t\tthis.content = content;\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t\tthis.tag = tag;\n\t}\n\n\twrite = async () => {\n\t\tif (this.persisted) {\n\t\t\treturn;\n\t\t}\n\t\tthis.persisted = true;\n\n\t\tconst dir = dirname(this.filename);\n\t\tawait mkdir(dir, { recursive: true });\n\n\t\tconst [existingContent, fd] = await this.getExistingContent();\n\n\t\tthis.content = this.addBlockToContent(existingContent);\n\t\tconst content = await this.buildContent();\n\n\t\tif (fd) {\n\t\t\tawait fd.truncate(0);\n\t\t\tawait fd.write(content, 0, 'utf-8');\n\t\t\tawait fd.close();\n\t\t} else {\n\t\t\tawait writeFile(this.filename, content, 'utf-8');\n\t\t}\n\t};\n\n\tunlink = async () => {\n\t\tthis.persisted = false;\n\n\t\tconst [existingContent, fd] = await this.getExistingContent();\n\n\t\tif (fd) {\n\t\t\tconst [start, end] = this.getSlices(existingContent);\n\t\t\tawait fd.truncate(0);\n\t\t\tawait fd.write(start + end, 0, 'utf-8');\n\t\t\tawait fd.close();\n\t\t}\n\t};\n\n\tprotected async getExistingContent() {\n\t\ttry {\n\t\t\tconst fd = await open(this.filename, 'r+');\n\t\t\tconst existingContent = await fd.readFile('utf-8');\n\t\t\treturn [existingContent, fd] as const;\n\t\t} catch {\n\t\t\treturn ['', null] as const;\n\t\t}\n\t}\n\n\tprotected getSlices(existingContent: string) {\n\t\tconst startMarkerIndex = existingContent.indexOf(this.start);\n\t\tconst endMarkerIndex = existingContent.lastIndexOf(this.end);\n\n\t\tif (startMarkerIndex === -1 || endMarkerIndex === -1) {\n\t\t\treturn [existingContent, '', false] as const;\n\t\t}\n\n\t\treturn [\n\t\t\texistingContent.slice(0, startMarkerIndex),\n\t\t\texistingContent.slice(endMarkerIndex + this.end.length),\n\t\t\ttrue,\n\t\t] as const;\n\t}\n\n\tprotected addBlockToContent(existingContent: string) {\n\t\tconst block = `${this.start}\\n${this.content}\\n${this.end}`;\n\t\tconst [startSlice, endSlice, hasMarkers] = this.getSlices(existingContent);\n\t\tconst padding = hasMarkers ? '' : this.buildPadding(existingContent);\n\t\treturn startSlice + padding + block + endSlice;\n\t}\n\n\tprotected buildPadding(existingContent: string) {\n\t\tif (existingContent === '') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (existingContent.endsWith('\\n\\n')) {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (existingContent.endsWith('\\n')) {\n\t\t\treturn '\\n';\n\t\t}\n\n\t\treturn '\\n\\n';\n\t}\n}\n","import { File, type FileOptions } from './file.ts';\n\nexport class FileManager {\n\tfiles: File[] = [];\n\tfileOptions?: FileOptions;\n\n\tconstructor(fileOptions?: FileOptions) {\n\t\tthis.fileOptions = fileOptions;\n\t}\n\n\tcreateAndAdd(filename: string, content: string, tag: string, options?: FileOptions) {\n\t\tconst file = new File(filename, content, tag, { ...this.fileOptions, ...options });\n\t\tthis.add(file);\n\t\treturn file;\n\t}\n\n\tadd(...file: File[]) {\n\t\tthis.files.push(...file);\n\t}\n\n\tget(filename: string) {\n\t\treturn this.files.find((file) => file.filename === filename);\n\t}\n\n\tgetAll() {\n\t\treturn this.files;\n\t}\n\n\tgetByTag(tag: string) {\n\t\treturn this.files.filter((file) => file.tag === tag);\n\t}\n\n\tremove(filename: string) {\n\t\tconst index = this.files.findIndex((file) => file.filename === filename);\n\t\tthis.files.splice(index, 1);\n\t}\n\n\tremoveAll() {\n\t\tthis.files = [];\n\t}\n\n\tremoveByTag(tag: string) {\n\t\tthis.files = this.files.filter((file) => file.tag !== tag);\n\t}\n\n\twriteAll() {\n\t\tconst toWrite = this.files.filter((file) => !file.persisted);\n\t\treturn Promise.all(toWrite.map((file) => file.write()));\n\t}\n\n\twriteByTag(tag: string) {\n\t\tconst files = this.getByTag(tag);\n\t\tconst toWrite = files.filter((file) => !file.persisted);\n\t\treturn Promise.all(toWrite.map((file) => file.write()));\n\t}\n\n\tunlinkAll() {\n\t\treturn Promise.all(this.files.map((file) => file.unlink())).then(() => {\n\t\t\t// void\n\t\t});\n\t}\n\n\tgetPersistedFiles() {\n\t\treturn this.files.filter((file) => file.persisted);\n\t}\n}\n","import { pascalCase } from 'change-case-all';\n\nexport function getModuleExportName(name: string) {\n\treturn `${pascalCase(name)}Module`;\n}\n","import { PluginType } from '@baeta/plugin';\nimport type { NormalizedGeneratorOptions } from './config.ts';\nimport type { Ctx } from './ctx.ts';\nimport type { Watcher, WatcherFile } from './watcher.ts';\n\nexport const GeneratorPluginVersion = {\n\tV1: 'v1',\n} as const;\n\nexport type GeneratorPluginVersion =\n\t(typeof GeneratorPluginVersion)[keyof typeof GeneratorPluginVersion];\n\nexport type GeneratorPluginV1Fn<Store = unknown> = (\n\tctx: Ctx<Store>,\n\tnext: () => Promise<void>,\n) => Promise<void>;\n\nexport type GeneratorPluginV1ReloadFn = (file: WatcherFile) => void;\n\nexport type GeneratorPluginV1WatchOptions = (\n\toptions: NormalizedGeneratorOptions,\n\twatcher: Watcher,\n\treload: GeneratorPluginV1ReloadFn,\n) => void;\n\nexport type GeneratorPluginV1Factory<Store = unknown> = {\n\tname: string;\n\tactionName: string;\n\tsetup?: GeneratorPluginV1Fn<Store>;\n\tgenerate?: GeneratorPluginV1Fn<Store>;\n\tend?: GeneratorPluginV1Fn<Store>;\n\twatch?: GeneratorPluginV1WatchOptions;\n};\n\nexport interface GeneratorPluginV1<Store = unknown> {\n\tname: string;\n\tactionName: string;\n\tversion: typeof GeneratorPluginVersion.V1;\n\ttype: typeof PluginType.Generator;\n\tsetup: GeneratorPluginV1Fn<Store>;\n\tgenerate: GeneratorPluginV1Fn<Store>;\n\tend: GeneratorPluginV1Fn<Store>;\n\twatch: GeneratorPluginV1WatchOptions;\n}\n\nconst defaultPluginFn: GeneratorPluginV1Fn<unknown> = async (_ctx, next) => {\n\treturn next();\n};\n\nconst defaultWatchFn = () => ({ include: [], ignore: [] });\n\nexport function createPluginV1<Store = unknown>(\n\toptions: GeneratorPluginV1Factory<Store>,\n): GeneratorPluginV1<Store> {\n\treturn {\n\t\tname: options.name,\n\t\tactionName: options.actionName,\n\t\tversion: GeneratorPluginVersion.V1,\n\t\ttype: PluginType.Generator,\n\t\tend: options.end ?? defaultPluginFn,\n\t\tgenerate: options.generate ?? defaultPluginFn,\n\t\tsetup: options.setup ?? defaultPluginFn,\n\t\twatch: options.watch ?? defaultWatchFn,\n\t};\n}\n\nexport function isGeneratorPlugin(plugin: {\n\ttype: PluginType;\n}): plugin is GeneratorPluginV1<unknown> {\n\treturn plugin.type === PluginType.Generator;\n}\n\nexport function getGeneratorPlugins(plugins?: Array<{ type: PluginType }>) {\n\tif (!plugins) {\n\t\treturn [];\n\t}\n\treturn plugins.filter(isGeneratorPlugin);\n}\n","import path from '@baeta/util-path';\nimport micromatch from 'micromatch';\n\nexport type MatchFn = (testString: string) => boolean;\nexport type MatchPattern = string | RegExp | MatchFn;\n\nexport class WatcherIgnore {\n\tprivate readonly cwd: string;\n\tprivate files: string[] = [];\n\tprivate regexps: RegExp[] = [];\n\tprivate functions: MatchFn[] = [];\n\n\tprivate globs: MatchFn[] = [];\n\tprivate globsMap = new Map<string, MatchFn>();\n\n\tconstructor(cwd: string) {\n\t\tthis.cwd = cwd;\n\t}\n\n\tignore(pattern: MatchPattern) {\n\t\tif (pattern instanceof RegExp) {\n\t\t\tthis.regexps.push(pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof pattern === 'function') {\n\t\t\tthis.functions.push(pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.isMicromatch(pattern)) {\n\t\t\tthis.files.push(this.resolveFile(pattern));\n\t\t\treturn;\n\t\t}\n\n\t\tthis.globsMap.set(pattern, micromatch.matcher(pattern));\n\t\tthis.globs = Array.from(this.globsMap.values());\n\t}\n\n\tisMicromatch(pattern: string) {\n\t\tconst result = micromatch.scan(pattern);\n\t\treturn result.isBrace || result.isGlobstar || result.isExtglob || result.isGlob;\n\t}\n\n\tresolveFile(file: string) {\n\t\treturn path.isAbsolute(file) ? file : path.join(this.cwd, file);\n\t}\n\n\tunignore(pattern: MatchPattern) {\n\t\tif (pattern instanceof RegExp) {\n\t\t\tthis.regexps = this.regexps.filter((p) => p !== pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (typeof pattern === 'function') {\n\t\t\tthis.functions = this.functions.filter((p) => p !== pattern);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!this.isMicromatch(pattern)) {\n\t\t\tconst file = this.resolveFile(pattern);\n\t\t\tthis.files = this.files.filter((p) => p !== file);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.globsMap.delete(pattern);\n\t\tthis.globs = Array.from(this.globsMap.values());\n\t}\n\n\tisIgnored(path: string) {\n\t\tif (this.files.includes(path)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.globs.some((f) => f(path))) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.regexps.some((r) => r.test(path))) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.functions.some((f) => f(path))) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n}\n","import path, { posixPath } from '@baeta/util-path';\nimport {\n\ttype AsyncSubscription,\n\ttype Event,\n\ttype EventType,\n\ttype Options,\n\tsubscribe,\n} from '@parcel/watcher';\nimport micromatch from 'micromatch';\nimport { type MatchPattern, WatcherIgnore } from './watcher-ignore.ts';\n\nexport { micromatch };\nexport const isMatch = micromatch.isMatch;\n\nexport type WatcherListener = (path: WatcherFile) => void;\n\nexport interface WatcherFile {\n\ttype: EventType;\n\tpath: string;\n\trelativePath: string;\n}\nexport class Watcher {\n\tprivate readonly cwd: string;\n\tprivate readonly options?: Options;\n\n\tprivate subscription: AsyncSubscription;\n\n\tprivate listeners: Record<EventType, WatcherListener[]> = {\n\t\tcreate: [],\n\t\tupdate: [],\n\t\tdelete: [],\n\t};\n\n\tprivate watcherIgnore: WatcherIgnore;\n\n\tconstructor(cwd: string, options?: Options) {\n\t\tthis.cwd = cwd;\n\t\tthis.options = options;\n\t\tthis.watcherIgnore = new WatcherIgnore(cwd);\n\t\tthis.subscription = this.createSubscription();\n\t}\n\n\tonEvents = (err: Error | null, events: Event[]) => {\n\t\tif (err) {\n\t\t\tconsole.error(err);\n\t\t\treturn;\n\t\t}\n\n\t\tconst filteredEvents = events.filter((event) => {\n\t\t\treturn !this.watcherIgnore.isIgnored(posixPath(event.path));\n\t\t});\n\n\t\tfor (const event of filteredEvents) {\n\t\t\tfor (const listener of this.listeners[event.type]) {\n\t\t\t\tlistener({\n\t\t\t\t\ttype: event.type,\n\t\t\t\t\tpath: posixPath(event.path),\n\t\t\t\t\trelativePath: posixPath(path.relative(this.cwd, event.path)),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n\n\ton(event: EventType, listener: WatcherListener) {\n\t\tthis.listeners[event].push(listener);\n\t}\n\n\toff(event: EventType, listener: WatcherListener) {\n\t\tthis.listeners[event] = this.listeners[event].filter((l) => l !== listener);\n\t}\n\n\tignore(pattern: MatchPattern) {\n\t\tthis.watcherIgnore.ignore(pattern);\n\t}\n\n\tunignore(pattern: MatchPattern) {\n\t\tthis.watcherIgnore.unignore(pattern);\n\t}\n\n\tcreateSubscription() {\n\t\tconst promise = subscribe(this.cwd, this.onEvents, this.options);\n\n\t\tconst unsubscribe = async () => {\n\t\t\tconst subscription = await promise;\n\t\t\tawait subscription.unsubscribe();\n\t\t};\n\n\t\treturn {\n\t\t\tunsubscribe,\n\t\t};\n\t}\n\n\tclose() {\n\t\treturn this.subscription.unsubscribe();\n\t}\n}\n"],"mappings":";;;;;;;;AAiFA,SAAgB,YAAY,SAAuD;CAClF,MAAM,MAAM,UAAU,QAAQ,OAAO,QAAQ,KAAK,CAAC;CACnD,MAAM,UAAU,QAAQ,WAAW,CAAC,mBAAmB;CACvD,MAAM,aAAa,UAAU,QAAQ,KAAK,QAAQ,cAAc,cAAc,CAAC;CAC/E,MAAM,uBAAuB,QAAQ,wBAAwB;CAC7D,MAAM,kBAAkB,QAAQ,YAAY,oBAAoB;AAGhE,QAAO;EACN;EACA;EACA;EACA;EACA,UAPgB,QAAQ,KAAK,QAAQ,YAAY,gBAAgB;EAQjE,aAAa,QAAQ;EACrB,SAAS,QAAQ;EACjB,iBAAiB,QAAQ,oBAAoB,QAAQ,KAAM,QAAQ,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AiB,OAAO,QAAQ,UAAU;AAC/C,UAAO,CAAC,KAAK,cAAc,UAAU,UAAU,MAAM,KAAK,CAAC;IAC1D;AAEF,OAAK,MAAM,SAAS,eACnB,MAAK,MAAM,YAAY,KAAK,UAAU,MAAM,MAC3C,UAAS;GACR,MAAM,MAAM;GACZ,MAAM,UAAU,MAAM,KAAK;GAC3B,cAAc,UAAU,KAAK,SAAS,KAAK,KAAK,MAAM,KAAK,CAAC;GAC5D,CAAC;;CAKL,GAAG,OAAkB,UAA2B;AAC/C,OAAK,UAAU,OAAO,KAAK,SAAS;;CAGrC,IAAI,OAAkB,UAA2B;AAChD,OAAK,UAAU,SAAS,KAAK,UAAU,OAAO,QAAQ,MAAM,MAAM,SAAS;;CAG5E,OAAO,SAAuB;AAC7B,OAAK,cAAc,OAAO,QAAQ;;CAGnC,SAAS,SAAuB;AAC/B,OAAK,cAAc,SAAS,QAAQ;;CAGrC,qBAAqB;EACpB,MAAM,UAAU,UAAU,KAAK,KAAK,KAAK,UAAU,KAAK,QAAQ;EAEhE,MAAM,cAAc,YAAY;AAE/B,UADqB,MAAM,SACR,aAAa;;AAGjC,SAAO,EACN,aACA;;CAGF,QAAQ;AACP,SAAO,KAAK,aAAa,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baeta/generator-sdk",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.3",
4
4
  "keywords": [
5
5
  "baeta",
6
6
  "graphql",
@@ -37,14 +37,14 @@
37
37
  "package.json"
38
38
  ],
39
39
  "scripts": {
40
- "build": "tsup",
41
- "prepack": "prep",
42
- "postpack": "prep --clean",
40
+ "build": "builder build",
41
+ "prepack": "builder prepare",
42
+ "postpack": "builder prepare --clean",
43
43
  "types": "tsc --noEmit"
44
44
  },
45
45
  "dependencies": {
46
- "@baeta/plugin": "^2.0.0-next.1",
47
- "@baeta/util-path": "^2.0.0-next.1",
46
+ "@baeta/plugin": "^2.0.0-next.2",
47
+ "@baeta/util-path": "^2.0.0-next.2",
48
48
  "@parcel/watcher": "^2.5.1",
49
49
  "change-case-all": "2.1.0",
50
50
  "micromatch": "^4.0.8"
@@ -52,8 +52,8 @@
52
52
  "devDependencies": {
53
53
  "@baeta/builder": "^0.0.0",
54
54
  "@baeta/tsconfig": "^0.0.0",
55
- "@types/micromatch": "^4.0.9",
56
- "@types/node": "^22.18.11",
55
+ "@types/micromatch": "^4.0.10",
56
+ "@types/node": "^22.18.13",
57
57
  "typescript": "^5.9.3"
58
58
  },
59
59
  "engines": {