@baeta/generator-sdk 1.0.2 → 2.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -85
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/CHANGELOG.md +0 -243
- package/dist/index.d.ts +0 -270
package/dist/index.js
CHANGED
|
@@ -1,90 +1,48 @@
|
|
|
1
1
|
// lib/config.ts
|
|
2
|
-
import {
|
|
2
|
+
import { posixPath, resolve } from "@baeta/util-path";
|
|
3
3
|
function loadOptions(options) {
|
|
4
4
|
const cwd = posixPath(options.cwd ?? process.cwd());
|
|
5
5
|
const schemas = options.schemas ?? ["src/**/*.graphql"];
|
|
6
6
|
const modulesDir = posixPath(resolve(cwd, options.modulesDir || "src/modules"));
|
|
7
7
|
const moduleDefinitionName = options.moduleDefinitionName || "typedef.ts";
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const baseTypesPath = posixPath(relative(modulesDir, baseTypesRoot));
|
|
11
|
-
const contextType = options.contextType && resolvePotentialImport(cwd, baseTypesRoot, options.contextType);
|
|
12
|
-
const extensions = resolveExtensionPath(modulesDir, moduleDefinitionName, options.extensions);
|
|
13
|
-
const scalars = resolveScalars(cwd, baseTypesRoot, options.scalars);
|
|
8
|
+
const defaultTypesDir = resolve(modulesDir, "../__generated__/");
|
|
9
|
+
const typesDir = resolve(cwd, options.typesDir || defaultTypesDir);
|
|
14
10
|
return {
|
|
15
11
|
cwd,
|
|
16
12
|
schemas,
|
|
17
13
|
modulesDir,
|
|
18
14
|
moduleDefinitionName,
|
|
19
|
-
|
|
20
|
-
contextType,
|
|
21
|
-
extensions,
|
|
22
|
-
scalars,
|
|
15
|
+
typesDir,
|
|
23
16
|
fileOptions: options.fileOptions,
|
|
24
17
|
loaders: options.loaders,
|
|
25
|
-
importExtension: options.importExtension === false ?
|
|
18
|
+
importExtension: options.importExtension === false ? "" : options.importExtension ?? ".ts"
|
|
26
19
|
};
|
|
27
20
|
}
|
|
28
|
-
function resolvePotentialImport(root, baseTypesRoot, path3) {
|
|
29
|
-
if (!path3.includes("#")) {
|
|
30
|
-
return path3;
|
|
31
|
-
}
|
|
32
|
-
if (isAbsolute(path3) || path3.startsWith("@")) {
|
|
33
|
-
return path3;
|
|
34
|
-
}
|
|
35
|
-
if (path3[0] === "!") {
|
|
36
|
-
return path3.slice(1);
|
|
37
|
-
}
|
|
38
|
-
const contextTypeRoot = resolve(root, path3);
|
|
39
|
-
return posixPath(relative(join(baseTypesRoot, "../"), contextTypeRoot));
|
|
40
|
-
}
|
|
41
|
-
function resolveScalars(root, baseTypesRoot, scalars) {
|
|
42
|
-
if (!scalars) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const resolved = {};
|
|
46
|
-
for (const key in scalars) {
|
|
47
|
-
const value = scalars[key];
|
|
48
|
-
if (typeof value === "string") {
|
|
49
|
-
resolved[key] = resolvePotentialImport(root, baseTypesRoot, value);
|
|
50
|
-
} else {
|
|
51
|
-
resolved[key] = {
|
|
52
|
-
input: resolvePotentialImport(root, baseTypesRoot, value.input),
|
|
53
|
-
output: resolvePotentialImport(root, baseTypesRoot, value.output)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return resolved;
|
|
58
|
-
}
|
|
59
|
-
function resolveExtensionPath(modulesDir, moduleDefinitionName, extensionsPath) {
|
|
60
|
-
if (!extensionsPath) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (isAbsolute(extensionsPath)) {
|
|
64
|
-
return extensionsPath;
|
|
65
|
-
}
|
|
66
|
-
if (extensionsPath[0] === "!") {
|
|
67
|
-
return extensionsPath.slice(1);
|
|
68
|
-
}
|
|
69
|
-
return posixPath(relative(join(modulesDir, moduleDefinitionName), extensionsPath));
|
|
70
|
-
}
|
|
71
21
|
|
|
72
22
|
// lib/file.ts
|
|
73
23
|
import fs from "fs/promises";
|
|
74
24
|
import { dirname, extname } from "@baeta/util-path";
|
|
75
25
|
var File = class {
|
|
26
|
+
persisted = false;
|
|
27
|
+
filename;
|
|
28
|
+
content;
|
|
29
|
+
tag;
|
|
30
|
+
options;
|
|
76
31
|
constructor(filename, content, tag, options) {
|
|
77
32
|
this.filename = filename;
|
|
78
33
|
this.content = content;
|
|
79
34
|
this.tag = tag;
|
|
80
35
|
this.options = options;
|
|
81
36
|
}
|
|
82
|
-
persisted = false;
|
|
83
37
|
write = async () => {
|
|
84
38
|
if (this.persisted) {
|
|
85
39
|
return;
|
|
86
40
|
}
|
|
87
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
|
+
}
|
|
88
46
|
const dir = dirname(this.filename);
|
|
89
47
|
await fs.mkdir(dir, { recursive: true });
|
|
90
48
|
const content = await this.buildContent();
|
|
@@ -141,6 +99,11 @@ var File = class {
|
|
|
141
99
|
import { mkdir, open, writeFile } from "fs/promises";
|
|
142
100
|
import { dirname as dirname2 } from "@baeta/util-path";
|
|
143
101
|
var FileBlock = class extends File {
|
|
102
|
+
filename;
|
|
103
|
+
content;
|
|
104
|
+
start;
|
|
105
|
+
end;
|
|
106
|
+
tag;
|
|
144
107
|
constructor(filename, content, start, end, tag, options) {
|
|
145
108
|
super(filename, content, tag, {
|
|
146
109
|
disableBiomeHeader: options?.disableBiomeHeader ?? true,
|
|
@@ -226,12 +189,13 @@ ${this.end}`;
|
|
|
226
189
|
|
|
227
190
|
// lib/file-manager.ts
|
|
228
191
|
var FileManager = class {
|
|
192
|
+
files = [];
|
|
193
|
+
fileOptions;
|
|
229
194
|
constructor(fileOptions) {
|
|
230
195
|
this.fileOptions = fileOptions;
|
|
231
196
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const file = new File(filename, content, tag, this.fileOptions);
|
|
197
|
+
createAndAdd(filename, content, tag, options) {
|
|
198
|
+
const file = new File(filename, content, tag, { ...this.fileOptions, ...options });
|
|
235
199
|
this.add(file);
|
|
236
200
|
return file;
|
|
237
201
|
}
|
|
@@ -276,23 +240,16 @@ var FileManager = class {
|
|
|
276
240
|
};
|
|
277
241
|
|
|
278
242
|
// lib/module.ts
|
|
279
|
-
import {
|
|
280
|
-
function
|
|
281
|
-
return
|
|
282
|
-
}
|
|
283
|
-
function getModuleCreateName(name) {
|
|
284
|
-
return `create${pascalCase(name)}Module`;
|
|
285
|
-
}
|
|
286
|
-
function getModuleVariableName(name) {
|
|
287
|
-
return camelCase(`${name}Module`);
|
|
243
|
+
import { pascalCase } from "change-case-all";
|
|
244
|
+
function getModuleExportName(name) {
|
|
245
|
+
return `${pascalCase(name)}Module`;
|
|
288
246
|
}
|
|
289
247
|
|
|
290
248
|
// lib/plugin.ts
|
|
291
249
|
import { PluginType } from "@baeta/plugin";
|
|
292
|
-
var GeneratorPluginVersion =
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
})(GeneratorPluginVersion || {});
|
|
250
|
+
var GeneratorPluginVersion = {
|
|
251
|
+
V1: "v1"
|
|
252
|
+
};
|
|
296
253
|
var defaultPluginFn = async (_ctx, next) => {
|
|
297
254
|
return next();
|
|
298
255
|
};
|
|
@@ -301,7 +258,7 @@ function createPluginV1(options) {
|
|
|
301
258
|
return {
|
|
302
259
|
name: options.name,
|
|
303
260
|
actionName: options.actionName,
|
|
304
|
-
version:
|
|
261
|
+
version: GeneratorPluginVersion.V1,
|
|
305
262
|
type: PluginType.Generator,
|
|
306
263
|
end: options.end ?? defaultPluginFn,
|
|
307
264
|
generate: options.generate ?? defaultPluginFn,
|
|
@@ -330,14 +287,15 @@ import micromatch2 from "micromatch";
|
|
|
330
287
|
import path from "@baeta/util-path";
|
|
331
288
|
import micromatch from "micromatch";
|
|
332
289
|
var WatcherIgnore = class {
|
|
333
|
-
|
|
334
|
-
this.cwd = cwd;
|
|
335
|
-
}
|
|
290
|
+
cwd;
|
|
336
291
|
files = [];
|
|
337
292
|
regexps = [];
|
|
338
293
|
functions = [];
|
|
339
294
|
globs = [];
|
|
340
295
|
globsMap = /* @__PURE__ */ new Map();
|
|
296
|
+
constructor(cwd) {
|
|
297
|
+
this.cwd = cwd;
|
|
298
|
+
}
|
|
341
299
|
ignore(pattern) {
|
|
342
300
|
if (pattern instanceof RegExp) {
|
|
343
301
|
this.regexps.push(pattern);
|
|
@@ -398,12 +356,8 @@ var WatcherIgnore = class {
|
|
|
398
356
|
// lib/watcher.ts
|
|
399
357
|
var isMatch = micromatch2.isMatch;
|
|
400
358
|
var Watcher = class {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
this.options = options;
|
|
404
|
-
this.watcherIgnore = new WatcherIgnore(cwd);
|
|
405
|
-
this.subscription = this.createSubscription();
|
|
406
|
-
}
|
|
359
|
+
cwd;
|
|
360
|
+
options;
|
|
407
361
|
subscription;
|
|
408
362
|
listeners = {
|
|
409
363
|
create: [],
|
|
@@ -411,6 +365,12 @@ var Watcher = class {
|
|
|
411
365
|
delete: []
|
|
412
366
|
};
|
|
413
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
|
+
}
|
|
414
374
|
onEvents = (err, events) => {
|
|
415
375
|
if (err) {
|
|
416
376
|
console.error(err);
|
|
@@ -464,9 +424,7 @@ export {
|
|
|
464
424
|
WatcherIgnore,
|
|
465
425
|
createPluginV1,
|
|
466
426
|
getGeneratorPlugins,
|
|
467
|
-
|
|
468
|
-
getModuleGetName,
|
|
469
|
-
getModuleVariableName,
|
|
427
|
+
getModuleExportName,
|
|
470
428
|
isGeneratorPlugin,
|
|
471
429
|
isMatch,
|
|
472
430
|
loadOptions,
|
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 { isAbsolute, join, posixPath, relative, 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\nexport interface Loader<TOptions = any> {\n\t// biome-ignore lint/suspicious/noExplicitAny: Same reason as above\n\tload(pointer: string, options?: TOptions): Promise<any[] | null | never>;\n\t// biome-ignore lint/suspicious/noExplicitAny: Same reason as above\n\tloadSync?(pointer: string, options?: TOptions): any[] | 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 base types file.\n\t * @defaultValue ```ts\n\t * `${modulesDir}/../__generated__/types.ts`\n\t * ```\n\t */\n\tbaseTypesPath?: string;\n\n\t/**\n\t * Path to the context type definition.\n\t * Supports both named and default exports.\n\t * @example contextType: 'src/types/context.ts#Context' // for named export\n\t * @example contextType: 'src/types/context.ts' // for default export\n\t * @defaultValue undefined\n\t */\n\tcontextType?: string;\n\n\t/**\n\t * Path to Baeta Extensions (ex. auth-extension).\n\t * Only default export is supported.\n\t * @example extensions: 'src/extensions.ts'\n\t * @defaultValue undefined\n\t */\n\textensions?: string;\n\n\t/**\n\t * Custom scalar type mappings.\n\t * Maps GraphQL scalar types to TypeScript types.\n\t * Supports global types and imports.\n\t * @example { DateTime: 'Date', JSON: 'Record<string, unknown>' }\t * @defaultValue undefined\n\t */\n\tscalars?: Record<string, string | { input: string; output: 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\tbaseTypesPath: string;\n\tcontextType?: string;\n\textensions?: string;\n\tscalars?: Record<string, string | { input: string; output: 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\n\tconst defaultBaseTypesRoot = resolve(modulesDir, '../__generated__/types.ts');\n\tconst baseTypesRoot = resolve(cwd, options.baseTypesPath || defaultBaseTypesRoot);\n\tconst baseTypesPath = posixPath(relative(modulesDir, baseTypesRoot));\n\n\tconst contextType =\n\t\toptions.contextType && resolvePotentialImport(cwd, baseTypesRoot, options.contextType);\n\tconst extensions = resolveExtensionPath(modulesDir, moduleDefinitionName, options.extensions);\n\n\tconst scalars = resolveScalars(cwd, baseTypesRoot, options.scalars);\n\n\treturn {\n\t\tcwd,\n\t\tschemas,\n\t\tmodulesDir,\n\t\tmoduleDefinitionName,\n\t\tbaseTypesPath,\n\t\tcontextType,\n\t\textensions,\n\t\tscalars,\n\t\tfileOptions: options.fileOptions,\n\t\tloaders: options.loaders,\n\t\timportExtension:\n\t\t\toptions.importExtension === false ? undefined : (options.importExtension ?? '.ts'),\n\t};\n}\n\nfunction resolvePotentialImport(root: string, baseTypesRoot: string, path: string) {\n\tif (!path.includes('#')) {\n\t\treturn path;\n\t}\n\n\tif (isAbsolute(path) || path.startsWith('@')) {\n\t\treturn path;\n\t}\n\n\tif (path[0] === '!') {\n\t\treturn path.slice(1);\n\t}\n\n\tconst contextTypeRoot = resolve(root, path);\n\treturn posixPath(relative(join(baseTypesRoot, '../'), contextTypeRoot));\n}\n\nfunction resolveScalars(\n\troot: string,\n\tbaseTypesRoot: string,\n\tscalars?: Record<string, string | { input: string; output: string }>,\n) {\n\tif (!scalars) {\n\t\treturn;\n\t}\n\n\tconst resolved: Record<string, string | { input: string; output: string }> = {};\n\n\tfor (const key in scalars) {\n\t\tconst value = scalars[key];\n\n\t\tif (typeof value === 'string') {\n\t\t\tresolved[key] = resolvePotentialImport(root, baseTypesRoot, value);\n\t\t} else {\n\t\t\tresolved[key] = {\n\t\t\t\tinput: resolvePotentialImport(root, baseTypesRoot, value.input),\n\t\t\t\toutput: resolvePotentialImport(root, baseTypesRoot, value.output),\n\t\t\t};\n\t\t}\n\t}\n\n\treturn resolved;\n}\n\nfunction resolveExtensionPath(\n\tmodulesDir: string,\n\tmoduleDefinitionName: string,\n\textensionsPath?: string,\n) {\n\tif (!extensionsPath) {\n\t\treturn;\n\t}\n\n\tif (isAbsolute(extensionsPath)) {\n\t\treturn extensionsPath;\n\t}\n\n\tif (extensionsPath[0] === '!') {\n\t\treturn extensionsPath.slice(1);\n\t}\n\n\treturn posixPath(relative(join(modulesDir, moduleDefinitionName), extensionsPath));\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 * 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\n\tconstructor(\n\t\tpublic filename: string,\n\t\tpublic content: string,\n\t\tpublic tag: string,\n\t\tprivate options?: FileOptions,\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 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\tconstructor(\n\t\tpublic filename: string,\n\t\tpublic content: string,\n\t\tpublic start: string,\n\t\tpublic end: string,\n\t\tpublic tag: 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}\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\n\tconstructor(public fileOptions?: FileOptions) {}\n\n\tcreateAndAdd(filename: string, content: string, tag: string) {\n\t\tconst file = new File(filename, content, tag, this.fileOptions);\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 { camelCase, pascalCase } from 'change-case-all';\n\nexport function getModuleGetName(name: string) {\n\treturn `get${pascalCase(name)}Module`;\n}\n\nexport function getModuleCreateName(name: string) {\n\treturn `create${pascalCase(name)}Module`;\n}\n\nexport function getModuleVariableName(name: string) {\n\treturn camelCase(`${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 enum GeneratorPluginVersion {\n\tV1 = 'v1',\n}\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: GeneratorPluginVersion.V1;\n\ttype: 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 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(\n\t\tprivate readonly cwd: string,\n\t\tprivate readonly options?: Options,\n\t) {\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 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(private readonly cwd: string) {}\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,YAAY,MAAM,WAAW,UAAU,eAAe;AA8GxD,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;AAE7D,QAAM,uBAAuB,QAAQ,YAAY,2BAA2B;AAC5E,QAAM,gBAAgB,QAAQ,KAAK,QAAQ,iBAAiB,oBAAoB;AAChF,QAAM,gBAAgB,UAAU,SAAS,YAAY,aAAa,CAAC;AAEnE,QAAM,cACL,QAAQ,eAAe,uBAAuB,KAAK,eAAe,QAAQ,WAAW;AACtF,QAAM,aAAa,qBAAqB,YAAY,sBAAsB,QAAQ,UAAU;AAE5F,QAAM,UAAU,eAAe,KAAK,eAAe,QAAQ,OAAO;AAElE,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,QAAQ;AAAA,IACrB,SAAS,QAAQ;AAAA,IACjB,iBACC,QAAQ,oBAAoB,QAAQ,SAAa,QAAQ,mBAAmB;AAAA,EAC9E;AACD;AAEA,SAAS,uBAAuB,MAAc,eAAuBA,OAAc;AAClF,MAAI,CAACA,MAAK,SAAS,GAAG,GAAG;AACxB,WAAOA;AAA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,CAAC;AAAA,QAC5D,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD;AAAA,EAEA,GAAG,OAAkB,UAA2B;AAC/C,SAAK,UAAU,KAAK,EAAE,KAAK,QAAQ;AAAA,EACpC;AAAA,EAEA,IAAI,OAAkB,UAA2B;AAChD,SAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,EAAE,OAAO,CAAC,MAAM,MAAM,QAAQ;AAAA,EAC3E;AAAA,EAEA,OAAO,SAAuB;AAC7B,SAAK,cAAc,OAAO,OAAO;AAAA,EAClC;AAAA,EAEA,SAAS,SAAuB;AAC/B,SAAK,cAAc,SAAS,OAAO;AAAA,EACpC;AAAA,EAEA,qBAAqB;AACpB,UAAM,UAAU,UAAU,KAAK,KAAK,KAAK,UAAU,KAAK,OAAO;AAE/D,UAAM,cAAc,YAAY;AAC/B,YAAM,eAAe,MAAM;AAC3B,YAAM,aAAa,YAAY;AAAA,IAChC;AAEA,WAAO;AAAA,MACN;AAAA,IACD;AAAA,EACD;AAAA,EAEA,QAAQ;AACP,WAAO,KAAK,aAAa,YAAY;AAAA,EACtC;AACD;","names":["path","dirname","dirname","GeneratorPluginVersion","path","posixPath","micromatch","path","micromatch","posixPath","path"]}
|
|
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,WAA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AAC,MAAM,MAAM,QAAQ;AAAA,EAC3E;AAAA,EAEA,OAAO,SAAuB;AAC7B,SAAK,cAAc,OAAO,OAAO;AAAA,EAClC;AAAA,EAEA,SAAS,SAAuB;AAC/B,SAAK,cAAc,SAAS,OAAO;AAAA,EACpC;AAAA,EAEA,qBAAqB;AACpB,UAAM,UAAU,UAAU,KAAK,KAAK,KAAK,UAAU,KAAK,OAAO;AAE/D,UAAM,cAAc,YAAY;AAC/B,YAAM,eAAe,MAAM;AAC3B,YAAM,aAAa,YAAY;AAAA,IAChC;AAEA,WAAO;AAAA,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baeta/generator-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"baeta",
|
|
6
6
|
"graphql",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"type": "module",
|
|
28
28
|
"exports": {
|
|
29
29
|
".": {
|
|
30
|
-
"types": "./
|
|
31
|
-
"default": "./
|
|
30
|
+
"types": "./index.ts",
|
|
31
|
+
"default": "./index.ts"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
@@ -43,21 +43,21 @@
|
|
|
43
43
|
"types": "tsc --noEmit"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@baeta/plugin": "
|
|
47
|
-
"@baeta/util-path": "
|
|
46
|
+
"@baeta/plugin": "workspace:^",
|
|
47
|
+
"@baeta/util-path": "workspace:^",
|
|
48
48
|
"@parcel/watcher": "^2.5.1",
|
|
49
49
|
"change-case-all": "2.1.0",
|
|
50
50
|
"micromatch": "^4.0.8"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@baeta/builder": "
|
|
54
|
-
"@baeta/tsconfig": "
|
|
53
|
+
"@baeta/builder": "workspace:^",
|
|
54
|
+
"@baeta/tsconfig": "workspace:^",
|
|
55
55
|
"@types/micromatch": "^4.0.9",
|
|
56
|
-
"@types/node": "^22.
|
|
57
|
-
"typescript": "^5.
|
|
56
|
+
"@types/node": "^22.18.11",
|
|
57
|
+
"typescript": "^5.9.3"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
|
-
"node": ">=22.
|
|
60
|
+
"node": ">=22.20.0"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public",
|
|
@@ -81,4 +81,4 @@
|
|
|
81
81
|
"alphabetical-ignoring-documents"
|
|
82
82
|
]
|
|
83
83
|
}
|
|
84
|
-
}
|
|
84
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
# @baeta/generator-sdk
|
|
2
|
-
|
|
3
|
-
## 1.0.2
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [`7cbd2ef`](https://github.com/andreisergiu98/baeta/commit/7cbd2ef5b7697f703e4cc6f8d9612c7d01a10dd1) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Add biome disable comment for generated files
|
|
8
|
-
|
|
9
|
-
- [`c7b9c05`](https://github.com/andreisergiu98/baeta/commit/c7b9c0523eb9827c99b2bcfc7dbe02f5ef389f21) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Allow import from packages for scalars and context
|
|
10
|
-
|
|
11
|
-
## 1.0.1
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- [`583014f`](https://github.com/andreisergiu98/baeta/commit/583014f0bac810b25d9a8226bda2df4c9039f5e3) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Update dependencies
|
|
16
|
-
|
|
17
|
-
- Updated dependencies [[`583014f`](https://github.com/andreisergiu98/baeta/commit/583014f0bac810b25d9a8226bda2df4c9039f5e3)]:
|
|
18
|
-
- @baeta/plugin@1.0.1
|
|
19
|
-
- @baeta/util-path@1.0.1
|
|
20
|
-
|
|
21
|
-
## 1.0.0
|
|
22
|
-
|
|
23
|
-
### Major Changes
|
|
24
|
-
|
|
25
|
-
- [#165](https://github.com/andreisergiu98/baeta/pull/165) [`1334c2a`](https://github.com/andreisergiu98/baeta/commit/1334c2a866676c88f0f3d380b22133d81c4e98bc) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - mark as stable
|
|
26
|
-
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
- [#189](https://github.com/andreisergiu98/baeta/pull/189) [`d500378`](https://github.com/andreisergiu98/baeta/commit/d500378198e0a9c48298c4242913bca8ad348228) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add jsdocs
|
|
30
|
-
|
|
31
|
-
- Updated dependencies [[`d500378`](https://github.com/andreisergiu98/baeta/commit/d500378198e0a9c48298c4242913bca8ad348228), [`1334c2a`](https://github.com/andreisergiu98/baeta/commit/1334c2a866676c88f0f3d380b22133d81c4e98bc)]:
|
|
32
|
-
- @baeta/plugin@1.0.0
|
|
33
|
-
- @baeta/util-path@1.0.0
|
|
34
|
-
|
|
35
|
-
## 0.1.5
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- [#184](https://github.com/andreisergiu98/baeta/pull/184) [`bf2d1a3`](https://github.com/andreisergiu98/baeta/commit/bf2d1a326235e5f34e723a5acc81cd7b974b913b) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - generate with .ts extension by default
|
|
40
|
-
|
|
41
|
-
## 0.1.4
|
|
42
|
-
|
|
43
|
-
### Patch Changes
|
|
44
|
-
|
|
45
|
-
- [`b59db50`](https://github.com/andreisergiu98/baeta/commit/b59db501a83275ab2d964933080e688a3a5d8820) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add readme
|
|
46
|
-
|
|
47
|
-
- Updated dependencies [[`b59db50`](https://github.com/andreisergiu98/baeta/commit/b59db501a83275ab2d964933080e688a3a5d8820)]:
|
|
48
|
-
- @baeta/plugin@0.1.4
|
|
49
|
-
- @baeta/util-path@0.1.4
|
|
50
|
-
|
|
51
|
-
## 0.1.3
|
|
52
|
-
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- [#180](https://github.com/andreisergiu98/baeta/pull/180) [`483c709`](https://github.com/andreisergiu98/baeta/commit/483c70932f815fd114732c00b74f9488d7924c72) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Raise minimum required NodeJS version to 22.12.0. Drop CommonJS builds in favor of the require_esm feature from NodeJS 22.12.0 onwards.
|
|
56
|
-
|
|
57
|
-
- [`de6e89c`](https://github.com/andreisergiu98/baeta/commit/de6e89c1b592e280967c73a4137d24ee56ef1857) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - raise es target to 2024
|
|
58
|
-
|
|
59
|
-
- Updated dependencies [[`483c709`](https://github.com/andreisergiu98/baeta/commit/483c70932f815fd114732c00b74f9488d7924c72), [`de6e89c`](https://github.com/andreisergiu98/baeta/commit/de6e89c1b592e280967c73a4137d24ee56ef1857)]:
|
|
60
|
-
- @baeta/plugin@0.1.3
|
|
61
|
-
- @baeta/util-path@0.1.3
|
|
62
|
-
|
|
63
|
-
## 0.1.2
|
|
64
|
-
|
|
65
|
-
### Patch Changes
|
|
66
|
-
|
|
67
|
-
- [`e3fb6f8`](https://github.com/andreisergiu98/baeta/commit/e3fb6f877b4b20e248ad79cbaa3655cabe973f6b) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - revert fileblock instead of removing the file
|
|
68
|
-
|
|
69
|
-
- [#170](https://github.com/andreisergiu98/baeta/pull/170) [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
70
|
-
|
|
71
|
-
- Updated dependencies [[`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321)]:
|
|
72
|
-
- @baeta/plugin@0.1.2
|
|
73
|
-
- @baeta/util-path@0.1.2
|
|
74
|
-
|
|
75
|
-
## 0.1.1
|
|
76
|
-
|
|
77
|
-
### Patch Changes
|
|
78
|
-
|
|
79
|
-
- [`7f1958c`](https://github.com/andreisergiu98/baeta/commit/7f1958c44d1b9bed473e48c875fdaa7020c434fa) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - allow custom extension for generated file imports
|
|
80
|
-
|
|
81
|
-
- [#157](https://github.com/andreisergiu98/baeta/pull/157) [`b9638eb`](https://github.com/andreisergiu98/baeta/commit/b9638eb9fb713507efa9821b4f04cc7896a997b1) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - stricter linting, better type safety
|
|
82
|
-
|
|
83
|
-
- [`fd3a5d2`](https://github.com/andreisergiu98/baeta/commit/fd3a5d27b497aca4b8807155e801b1c1197c5fe2) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - handle cloudflare cache in cloudflare plugin
|
|
84
|
-
|
|
85
|
-
- [`9d8d6a1`](https://github.com/andreisergiu98/baeta/commit/9d8d6a15d63579a2e0bdaa07b7efdcf10aff2492) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - remove all loaders apart from graphql file loader, and let users define extra loaders if needed
|
|
86
|
-
|
|
87
|
-
- [`a3f0e5d`](https://github.com/andreisergiu98/baeta/commit/a3f0e5d03fc9ef21a87d3ec6bf264d0e9707636a) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - fix exports order in package.json
|
|
88
|
-
|
|
89
|
-
- [#161](https://github.com/andreisergiu98/baeta/pull/161) [`cca37dd`](https://github.com/andreisergiu98/baeta/commit/cca37dd7135a2852f1f6e287c46911306bdc8da0) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
90
|
-
|
|
91
|
-
- Updated dependencies [[`a3f0e5d`](https://github.com/andreisergiu98/baeta/commit/a3f0e5d03fc9ef21a87d3ec6bf264d0e9707636a), [`cca37dd`](https://github.com/andreisergiu98/baeta/commit/cca37dd7135a2852f1f6e287c46911306bdc8da0)]:
|
|
92
|
-
- @baeta/plugin@0.1.1
|
|
93
|
-
- @baeta/util-path@0.1.1
|
|
94
|
-
|
|
95
|
-
## 0.1.0
|
|
96
|
-
|
|
97
|
-
### Minor Changes
|
|
98
|
-
|
|
99
|
-
- [#156](https://github.com/andreisergiu98/baeta/pull/156) [`01f3c20`](https://github.com/andreisergiu98/baeta/commit/01f3c20365539fad6e8a8694c59a8e86c95784e8) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - raise engine requirement to node >= 22
|
|
100
|
-
|
|
101
|
-
### Patch Changes
|
|
102
|
-
|
|
103
|
-
- [#152](https://github.com/andreisergiu98/baeta/pull/152) [`d538c79`](https://github.com/andreisergiu98/baeta/commit/d538c7905e6ba96d9f294e2d528f9252e83acbe7) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update formatter
|
|
104
|
-
|
|
105
|
-
- [#145](https://github.com/andreisergiu98/baeta/pull/145) [`08428d4`](https://github.com/andreisergiu98/baeta/commit/08428d4f03b79cab9c116ff7b3a3cf9a0b2620f2) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
106
|
-
|
|
107
|
-
- Updated dependencies [[`01f3c20`](https://github.com/andreisergiu98/baeta/commit/01f3c20365539fad6e8a8694c59a8e86c95784e8), [`d538c79`](https://github.com/andreisergiu98/baeta/commit/d538c7905e6ba96d9f294e2d528f9252e83acbe7), [`08428d4`](https://github.com/andreisergiu98/baeta/commit/08428d4f03b79cab9c116ff7b3a3cf9a0b2620f2)]:
|
|
108
|
-
- @baeta/plugin@0.1.0
|
|
109
|
-
- @baeta/util-path@0.1.0
|
|
110
|
-
|
|
111
|
-
## 0.0.14
|
|
112
|
-
|
|
113
|
-
### Patch Changes
|
|
114
|
-
|
|
115
|
-
- [#139](https://github.com/andreisergiu98/baeta/pull/139) [`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
116
|
-
|
|
117
|
-
- [#139](https://github.com/andreisergiu98/baeta/pull/139) [`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update typescript
|
|
118
|
-
|
|
119
|
-
- Updated dependencies [[`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4), [`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4)]:
|
|
120
|
-
- @baeta/plugin@0.0.25
|
|
121
|
-
- @baeta/util-path@0.0.6
|
|
122
|
-
|
|
123
|
-
## 0.0.13
|
|
124
|
-
|
|
125
|
-
### Patch Changes
|
|
126
|
-
|
|
127
|
-
- [#128](https://github.com/andreisergiu98/baeta/pull/128) [`534917a`](https://github.com/andreisergiu98/baeta/commit/534917a18e7ed5d788a90a0335a5370d6af8f4a4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
128
|
-
|
|
129
|
-
- Updated dependencies [[`534917a`](https://github.com/andreisergiu98/baeta/commit/534917a18e7ed5d788a90a0335a5370d6af8f4a4)]:
|
|
130
|
-
- @baeta/plugin@0.0.24
|
|
131
|
-
- @baeta/util-path@0.0.5
|
|
132
|
-
|
|
133
|
-
## 0.0.12
|
|
134
|
-
|
|
135
|
-
### Patch Changes
|
|
136
|
-
|
|
137
|
-
- [#121](https://github.com/andreisergiu98/baeta/pull/121) [`ceae50d`](https://github.com/andreisergiu98/baeta/commit/ceae50d88e4e59b22c603637620f4fc6b28b2454) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Update Node to v20
|
|
138
|
-
|
|
139
|
-
- [#51](https://github.com/andreisergiu98/baeta/pull/51) [`d94ee47`](https://github.com/andreisergiu98/baeta/commit/d94ee47bc485c541ff011290c4ac6ef0c145c83f) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add native support for file monifications
|
|
140
|
-
|
|
141
|
-
- Updated dependencies [[`ceae50d`](https://github.com/andreisergiu98/baeta/commit/ceae50d88e4e59b22c603637620f4fc6b28b2454)]:
|
|
142
|
-
- @baeta/plugin@0.0.23
|
|
143
|
-
- @baeta/util-path@0.0.4
|
|
144
|
-
|
|
145
|
-
## 0.0.11
|
|
146
|
-
|
|
147
|
-
### Patch Changes
|
|
148
|
-
|
|
149
|
-
- [#117](https://github.com/andreisergiu98/baeta/pull/117) [`18db339`](https://github.com/andreisergiu98/baeta/commit/18db339719aa309c619372d2161c5fdbc08fa316) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add comments to config types
|
|
150
|
-
|
|
151
|
-
- [#119](https://github.com/andreisergiu98/baeta/pull/119) [`643a2eb`](https://github.com/andreisergiu98/baeta/commit/643a2eb17c2789cd25361ddeede149a0e459e68a) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
152
|
-
|
|
153
|
-
- Updated dependencies [[`643a2eb`](https://github.com/andreisergiu98/baeta/commit/643a2eb17c2789cd25361ddeede149a0e459e68a)]:
|
|
154
|
-
- @baeta/plugin@0.0.22
|
|
155
|
-
- @baeta/util-path@0.0.3
|
|
156
|
-
|
|
157
|
-
## 0.0.10
|
|
158
|
-
|
|
159
|
-
### Patch Changes
|
|
160
|
-
|
|
161
|
-
- [#102](https://github.com/andreisergiu98/baeta/pull/102) [`c9e37fd`](https://github.com/andreisergiu98/baeta/commit/c9e37fd1d64588fd8eb63facd7eda08c0009470c) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
162
|
-
|
|
163
|
-
- [#102](https://github.com/andreisergiu98/baeta/pull/102) [`c9e37fd`](https://github.com/andreisergiu98/baeta/commit/c9e37fd1d64588fd8eb63facd7eda08c0009470c) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies and builder
|
|
164
|
-
|
|
165
|
-
- [#106](https://github.com/andreisergiu98/baeta/pull/106) [`01788ab`](https://github.com/andreisergiu98/baeta/commit/01788ab04ff6956b2b50186af5bec8ed7ebbe76e) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add compatibility with windows
|
|
166
|
-
|
|
167
|
-
- Updated dependencies [[`c9e37fd`](https://github.com/andreisergiu98/baeta/commit/c9e37fd1d64588fd8eb63facd7eda08c0009470c), [`c9e37fd`](https://github.com/andreisergiu98/baeta/commit/c9e37fd1d64588fd8eb63facd7eda08c0009470c), [`01788ab`](https://github.com/andreisergiu98/baeta/commit/01788ab04ff6956b2b50186af5bec8ed7ebbe76e)]:
|
|
168
|
-
- @baeta/plugin@0.0.21
|
|
169
|
-
- @baeta/util-path@0.0.2
|
|
170
|
-
|
|
171
|
-
## 0.0.9
|
|
172
|
-
|
|
173
|
-
### Patch Changes
|
|
174
|
-
|
|
175
|
-
- [#81](https://github.com/andreisergiu98/baeta/pull/81) [`3ff5e54`](https://github.com/andreisergiu98/baeta/commit/3ff5e54f31cf42ba2264b12309338d6e78710722) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add file transformation function from config
|
|
176
|
-
|
|
177
|
-
- [#69](https://github.com/andreisergiu98/baeta/pull/69) [`3cdd9b3`](https://github.com/andreisergiu98/baeta/commit/3cdd9b30369d21179769a4b8d5f76e326ae6db37) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
178
|
-
|
|
179
|
-
- [#91](https://github.com/andreisergiu98/baeta/pull/91) [`e0944f6`](https://github.com/andreisergiu98/baeta/commit/e0944f6320e6cf2f0a3d2c9f51edd282bdce0546) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
180
|
-
|
|
181
|
-
- Updated dependencies [[`3cdd9b3`](https://github.com/andreisergiu98/baeta/commit/3cdd9b30369d21179769a4b8d5f76e326ae6db37), [`e0944f6`](https://github.com/andreisergiu98/baeta/commit/e0944f6320e6cf2f0a3d2c9f51edd282bdce0546)]:
|
|
182
|
-
- @baeta/plugin@0.0.20
|
|
183
|
-
|
|
184
|
-
## 0.0.8
|
|
185
|
-
|
|
186
|
-
### Patch Changes
|
|
187
|
-
|
|
188
|
-
- [#66](https://github.com/andreisergiu98/baeta/pull/66) [`9a4a021`](https://github.com/andreisergiu98/baeta/commit/9a4a0214351b70295ce4f7eecaa8c49ab0e1325b) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - replace chokidar with @parcel/watcher
|
|
189
|
-
|
|
190
|
-
## 0.0.7
|
|
191
|
-
|
|
192
|
-
### Patch Changes
|
|
193
|
-
|
|
194
|
-
- Updated dependencies [[`6a2dd11`](https://github.com/andreisergiu98/baeta/commit/6a2dd110d6ffd2bff25d9c4501faebb052e0cd40)]:
|
|
195
|
-
- @baeta/plugin@0.0.19
|
|
196
|
-
|
|
197
|
-
## 0.0.6
|
|
198
|
-
|
|
199
|
-
### Patch Changes
|
|
200
|
-
|
|
201
|
-
- [#47](https://github.com/andreisergiu98/baeta/pull/47) [`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
202
|
-
|
|
203
|
-
- [#43](https://github.com/andreisergiu98/baeta/pull/43) [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - bump dependencies
|
|
204
|
-
|
|
205
|
-
- Updated dependencies [[`eb7096d`](https://github.com/andreisergiu98/baeta/commit/eb7096d42a53b17bae0a8365eccb795e7ded02e9), [`670501b`](https://github.com/andreisergiu98/baeta/commit/670501b2b1cfb1126be3421293b8ccd597c6ffc2)]:
|
|
206
|
-
- @baeta/plugin@0.0.18
|
|
207
|
-
|
|
208
|
-
## 0.0.5
|
|
209
|
-
|
|
210
|
-
### Patch Changes
|
|
211
|
-
|
|
212
|
-
- [#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
|
|
213
|
-
|
|
214
|
-
- [#40](https://github.com/andreisergiu98/baeta/pull/40) [`9f937f4`](https://github.com/andreisergiu98/baeta/commit/9f937f47d3464a082680047414ee13a76cf6c056) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - normalize config
|
|
215
|
-
|
|
216
|
-
## 0.0.4
|
|
217
|
-
|
|
218
|
-
### Patch Changes
|
|
219
|
-
|
|
220
|
-
- [`d1190c1`](https://github.com/andreisergiu98/baeta/commit/d1190c10e3c259c73ddeeb73a4bd312b22bf2ea4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - create cli sdk
|
|
221
|
-
release prisma plugin
|
|
222
|
-
update dependencies
|
|
223
|
-
refactor generator plugins
|
|
224
|
-
- Updated dependencies [[`d1190c1`](https://github.com/andreisergiu98/baeta/commit/d1190c10e3c259c73ddeeb73a4bd312b22bf2ea4)]:
|
|
225
|
-
- @baeta/plugin@0.0.17
|
|
226
|
-
|
|
227
|
-
## 0.0.3
|
|
228
|
-
|
|
229
|
-
### Patch Changes
|
|
230
|
-
|
|
231
|
-
- [`02936ae`](https://github.com/andreisergiu98/baeta/commit/02936aeb606c75a2a79b6ce4524851c6c62afb82) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - bump packages
|
|
232
|
-
|
|
233
|
-
- Updated dependencies [[`02936ae`](https://github.com/andreisergiu98/baeta/commit/02936aeb606c75a2a79b6ce4524851c6c62afb82)]:
|
|
234
|
-
- @baeta/plugin@0.0.16
|
|
235
|
-
|
|
236
|
-
## 0.0.2
|
|
237
|
-
|
|
238
|
-
### Patch Changes
|
|
239
|
-
|
|
240
|
-
- [#25](https://github.com/andreisergiu98/baeta/pull/25) [`c2c5875`](https://github.com/andreisergiu98/baeta/commit/c2c5875f8356e166f34a20b3e4384f9bce093e61) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - refactor cli and plugins
|
|
241
|
-
|
|
242
|
-
- Updated dependencies [[`c2c5875`](https://github.com/andreisergiu98/baeta/commit/c2c5875f8356e166f34a20b3e4384f9bce093e61)]:
|
|
243
|
-
- @baeta/plugin@0.0.15
|
package/dist/index.d.ts
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { EventType, Options, Event } from '@parcel/watcher';
|
|
2
|
-
import micromatch from 'micromatch';
|
|
3
|
-
export { default as micromatch } from 'micromatch';
|
|
4
|
-
import * as fs_promises from 'fs/promises';
|
|
5
|
-
import { PluginType } from '@baeta/plugin';
|
|
6
|
-
|
|
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 comment at the beginning of the file.
|
|
23
|
-
* @defaultValue false
|
|
24
|
-
*/
|
|
25
|
-
disableBiomeHeader?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Add custom header at the beginning of the file.
|
|
28
|
-
*/
|
|
29
|
-
addHeader?: (name: string, content: string, tag: string) => string;
|
|
30
|
-
/**
|
|
31
|
-
* Edit the content of the file before writing it.
|
|
32
|
-
*/
|
|
33
|
-
transformContent?: (name: string, content: string, tag: string) => string | Promise<string>;
|
|
34
|
-
}
|
|
35
|
-
declare class File {
|
|
36
|
-
filename: string;
|
|
37
|
-
content: string;
|
|
38
|
-
tag: string;
|
|
39
|
-
private options?;
|
|
40
|
-
persisted: boolean;
|
|
41
|
-
constructor(filename: string, content: string, tag: string, options?: FileOptions | undefined);
|
|
42
|
-
write: () => Promise<void>;
|
|
43
|
-
unlink: () => Promise<void>;
|
|
44
|
-
protected buildContent(): Promise<string>;
|
|
45
|
-
protected buildHeader(): string;
|
|
46
|
-
protected createComment(comment: string): string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Interface for custom schema loaders.
|
|
51
|
-
*/
|
|
52
|
-
interface Loader<TOptions = any> {
|
|
53
|
-
load(pointer: string, options?: TOptions): Promise<any[] | null | never>;
|
|
54
|
-
loadSync?(pointer: string, options?: TOptions): any[] | null | never;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Options for the Baeta Generator.
|
|
58
|
-
*/
|
|
59
|
-
interface GeneratorOptions {
|
|
60
|
-
/**
|
|
61
|
-
* Current working directory for resolving relative paths.
|
|
62
|
-
* @defaultValue process.cwd()
|
|
63
|
-
*/
|
|
64
|
-
cwd?: string;
|
|
65
|
-
/**
|
|
66
|
-
* Glob pattern(s) to locate GraphQL schema files.
|
|
67
|
-
* @defaultValue ```ts
|
|
68
|
-
* ['src/∗∗/∗.gql', 'src/∗∗/∗.graphql']
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
schemas: string[];
|
|
72
|
-
/**
|
|
73
|
-
* Root directory where GraphQL modules are defined.
|
|
74
|
-
* @defaultValue 'src/modules'
|
|
75
|
-
*/
|
|
76
|
-
modulesDir?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Filename for the generated module definition file.
|
|
79
|
-
* Contains type definitions and the GraphQL AST.
|
|
80
|
-
* @defaultValue 'typedef.ts'
|
|
81
|
-
*/
|
|
82
|
-
moduleDefinitionName?: string;
|
|
83
|
-
/**
|
|
84
|
-
* Output path for the generated base types file.
|
|
85
|
-
* @defaultValue ```ts
|
|
86
|
-
* `${modulesDir}/../__generated__/types.ts`
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
baseTypesPath?: string;
|
|
90
|
-
/**
|
|
91
|
-
* Path to the context type definition.
|
|
92
|
-
* Supports both named and default exports.
|
|
93
|
-
* @example contextType: 'src/types/context.ts#Context' // for named export
|
|
94
|
-
* @example contextType: 'src/types/context.ts' // for default export
|
|
95
|
-
* @defaultValue undefined
|
|
96
|
-
*/
|
|
97
|
-
contextType?: string;
|
|
98
|
-
/**
|
|
99
|
-
* Path to Baeta Extensions (ex. auth-extension).
|
|
100
|
-
* Only default export is supported.
|
|
101
|
-
* @example extensions: 'src/extensions.ts'
|
|
102
|
-
* @defaultValue undefined
|
|
103
|
-
*/
|
|
104
|
-
extensions?: string;
|
|
105
|
-
/**
|
|
106
|
-
* Custom scalar type mappings.
|
|
107
|
-
* Maps GraphQL scalar types to TypeScript types.
|
|
108
|
-
* Supports global types and imports.
|
|
109
|
-
* @example { DateTime: 'Date', JSON: 'Record<string, unknown>' } * @defaultValue undefined
|
|
110
|
-
*/
|
|
111
|
-
scalars?: Record<string, string | {
|
|
112
|
-
input: string;
|
|
113
|
-
output: string;
|
|
114
|
-
}>;
|
|
115
|
-
/**
|
|
116
|
-
* Configuration options for generated files.
|
|
117
|
-
*/
|
|
118
|
-
fileOptions?: FileOptions;
|
|
119
|
-
/**
|
|
120
|
-
* Custom schema loaders for processing schema files.
|
|
121
|
-
*/
|
|
122
|
-
loaders?: Loader[];
|
|
123
|
-
/**
|
|
124
|
-
* File extension to use in generated import statements.
|
|
125
|
-
* Set to false to omit extensions.
|
|
126
|
-
* @defaultValue '.ts'
|
|
127
|
-
*/
|
|
128
|
-
importExtension?: '.js' | '.ts' | false;
|
|
129
|
-
}
|
|
130
|
-
interface NormalizedGeneratorOptions {
|
|
131
|
-
cwd: string;
|
|
132
|
-
schemas: string[];
|
|
133
|
-
modulesDir: string;
|
|
134
|
-
moduleDefinitionName: string;
|
|
135
|
-
baseTypesPath: string;
|
|
136
|
-
contextType?: string;
|
|
137
|
-
extensions?: string;
|
|
138
|
-
scalars?: Record<string, string | {
|
|
139
|
-
input: string;
|
|
140
|
-
output: string;
|
|
141
|
-
}>;
|
|
142
|
-
fileOptions?: FileOptions;
|
|
143
|
-
loaders?: Loader[];
|
|
144
|
-
importExtension?: '.js' | '.ts';
|
|
145
|
-
}
|
|
146
|
-
declare function loadOptions(options: GeneratorOptions): NormalizedGeneratorOptions;
|
|
147
|
-
|
|
148
|
-
declare class FileManager {
|
|
149
|
-
fileOptions?: FileOptions | undefined;
|
|
150
|
-
files: File[];
|
|
151
|
-
constructor(fileOptions?: FileOptions | undefined);
|
|
152
|
-
createAndAdd(filename: string, content: string, tag: string): File;
|
|
153
|
-
add(...file: File[]): void;
|
|
154
|
-
get(filename: string): File | undefined;
|
|
155
|
-
getAll(): File[];
|
|
156
|
-
getByTag(tag: string): File[];
|
|
157
|
-
remove(filename: string): void;
|
|
158
|
-
removeAll(): void;
|
|
159
|
-
removeByTag(tag: string): void;
|
|
160
|
-
writeAll(): Promise<void[]>;
|
|
161
|
-
writeByTag(tag: string): Promise<void[]>;
|
|
162
|
-
unlinkAll(): Promise<void>;
|
|
163
|
-
getPersistedFiles(): File[];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
type MatchFn = (testString: string) => boolean;
|
|
167
|
-
type MatchPattern = string | RegExp | MatchFn;
|
|
168
|
-
declare class WatcherIgnore {
|
|
169
|
-
private readonly cwd;
|
|
170
|
-
private files;
|
|
171
|
-
private regexps;
|
|
172
|
-
private functions;
|
|
173
|
-
private globs;
|
|
174
|
-
private globsMap;
|
|
175
|
-
constructor(cwd: string);
|
|
176
|
-
ignore(pattern: MatchPattern): void;
|
|
177
|
-
isMicromatch(pattern: string): boolean;
|
|
178
|
-
resolveFile(file: string): string;
|
|
179
|
-
unignore(pattern: MatchPattern): void;
|
|
180
|
-
isIgnored(path: string): boolean;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
declare const isMatch: (string: string, pattern: string | readonly string[], options?: micromatch.Options) => boolean;
|
|
184
|
-
type WatcherListener = (path: WatcherFile) => void;
|
|
185
|
-
interface WatcherFile {
|
|
186
|
-
type: EventType;
|
|
187
|
-
path: string;
|
|
188
|
-
relativePath: string;
|
|
189
|
-
}
|
|
190
|
-
declare class Watcher {
|
|
191
|
-
private readonly cwd;
|
|
192
|
-
private readonly options?;
|
|
193
|
-
private subscription;
|
|
194
|
-
private listeners;
|
|
195
|
-
private watcherIgnore;
|
|
196
|
-
constructor(cwd: string, options?: Options | undefined);
|
|
197
|
-
onEvents: (err: Error | null, events: Event[]) => void;
|
|
198
|
-
on(event: EventType, listener: WatcherListener): void;
|
|
199
|
-
off(event: EventType, listener: WatcherListener): void;
|
|
200
|
-
ignore(pattern: MatchPattern): void;
|
|
201
|
-
unignore(pattern: MatchPattern): void;
|
|
202
|
-
createSubscription(): {
|
|
203
|
-
unsubscribe: () => Promise<void>;
|
|
204
|
-
};
|
|
205
|
-
close(): Promise<void>;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
type Ctx<T = unknown> = {
|
|
209
|
-
fileManager: FileManager;
|
|
210
|
-
didSetup: string[];
|
|
211
|
-
didGenerate: string[];
|
|
212
|
-
didEnd: string[];
|
|
213
|
-
pluginNames: string[];
|
|
214
|
-
generatorOptions: NormalizedGeneratorOptions;
|
|
215
|
-
watching: boolean;
|
|
216
|
-
changedFile?: WatcherFile;
|
|
217
|
-
} & T;
|
|
218
|
-
|
|
219
|
-
declare class FileBlock extends File {
|
|
220
|
-
filename: string;
|
|
221
|
-
content: string;
|
|
222
|
-
start: string;
|
|
223
|
-
end: string;
|
|
224
|
-
tag: string;
|
|
225
|
-
constructor(filename: string, content: string, start: string, end: string, tag: string, options?: FileOptions);
|
|
226
|
-
write: () => Promise<void>;
|
|
227
|
-
unlink: () => Promise<void>;
|
|
228
|
-
protected getExistingContent(): Promise<readonly [string, fs_promises.FileHandle] | readonly ["", null]>;
|
|
229
|
-
protected getSlices(existingContent: string): readonly [string, "", false] | readonly [string, string, true];
|
|
230
|
-
protected addBlockToContent(existingContent: string): string;
|
|
231
|
-
protected buildPadding(existingContent: string): "" | "\n" | "\n\n";
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
declare function getModuleGetName(name: string): string;
|
|
235
|
-
declare function getModuleCreateName(name: string): string;
|
|
236
|
-
declare function getModuleVariableName(name: string): string;
|
|
237
|
-
|
|
238
|
-
declare enum GeneratorPluginVersion {
|
|
239
|
-
V1 = "v1"
|
|
240
|
-
}
|
|
241
|
-
type GeneratorPluginV1Fn<Store = unknown> = (ctx: Ctx<Store>, next: () => Promise<void>) => Promise<void>;
|
|
242
|
-
type GeneratorPluginV1ReloadFn = (file: WatcherFile) => void;
|
|
243
|
-
type GeneratorPluginV1WatchOptions = (options: NormalizedGeneratorOptions, watcher: Watcher, reload: GeneratorPluginV1ReloadFn) => void;
|
|
244
|
-
type GeneratorPluginV1Factory<Store = unknown> = {
|
|
245
|
-
name: string;
|
|
246
|
-
actionName: string;
|
|
247
|
-
setup?: GeneratorPluginV1Fn<Store>;
|
|
248
|
-
generate?: GeneratorPluginV1Fn<Store>;
|
|
249
|
-
end?: GeneratorPluginV1Fn<Store>;
|
|
250
|
-
watch?: GeneratorPluginV1WatchOptions;
|
|
251
|
-
};
|
|
252
|
-
interface GeneratorPluginV1<Store = unknown> {
|
|
253
|
-
name: string;
|
|
254
|
-
actionName: string;
|
|
255
|
-
version: GeneratorPluginVersion.V1;
|
|
256
|
-
type: PluginType.Generator;
|
|
257
|
-
setup: GeneratorPluginV1Fn<Store>;
|
|
258
|
-
generate: GeneratorPluginV1Fn<Store>;
|
|
259
|
-
end: GeneratorPluginV1Fn<Store>;
|
|
260
|
-
watch: GeneratorPluginV1WatchOptions;
|
|
261
|
-
}
|
|
262
|
-
declare function createPluginV1<Store = unknown>(options: GeneratorPluginV1Factory<Store>): GeneratorPluginV1<Store>;
|
|
263
|
-
declare function isGeneratorPlugin(plugin: {
|
|
264
|
-
type: PluginType;
|
|
265
|
-
}): plugin is GeneratorPluginV1<unknown>;
|
|
266
|
-
declare function getGeneratorPlugins(plugins?: Array<{
|
|
267
|
-
type: PluginType;
|
|
268
|
-
}>): GeneratorPluginV1<unknown>[];
|
|
269
|
-
|
|
270
|
-
export { type Ctx, File, FileBlock, FileManager, type FileOptions, type GeneratorOptions, type GeneratorPluginV1, type GeneratorPluginV1Factory, type GeneratorPluginV1Fn, type GeneratorPluginV1ReloadFn, type GeneratorPluginV1WatchOptions, GeneratorPluginVersion, type Loader, type MatchFn, type MatchPattern, type NormalizedGeneratorOptions, Watcher, type WatcherFile, WatcherIgnore, type WatcherListener, createPluginV1, getGeneratorPlugins, getModuleCreateName, getModuleGetName, getModuleVariableName, isGeneratorPlugin, isMatch, loadOptions };
|