@baeta/generator-sdk 0.1.1 → 0.1.2
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 +12 -0
- package/dist/index.cjs +25 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +12 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @baeta/generator-sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e3fb6f8`](https://github.com/andreisergiu98/baeta/commit/e3fb6f877b4b20e248ad79cbaa3655cabe973f6b) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - revert fileblock instead of removing the file
|
|
8
|
+
|
|
9
|
+
- [#170](https://github.com/andreisergiu98/baeta/pull/170) [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321)]:
|
|
12
|
+
- @baeta/plugin@0.1.2
|
|
13
|
+
- @baeta/util-path@0.1.2
|
|
14
|
+
|
|
3
15
|
## 0.1.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -122,9 +122,12 @@ var FileBlock = (_class2 = class extends File {
|
|
|
122
122
|
super(filename, content, tag, {
|
|
123
123
|
addEslintDisableHeader: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.addEslintDisableHeader]), () => ( false)),
|
|
124
124
|
addGenerationNoticeHeader: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _10 => _10.addGenerationNoticeHeader]), () => ( false))
|
|
125
|
-
});_class2.prototype.__init4.call(this);;
|
|
125
|
+
});_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);;
|
|
126
|
+
this.filename = filename;
|
|
127
|
+
this.content = content;
|
|
126
128
|
this.start = start;
|
|
127
129
|
this.end = end;
|
|
130
|
+
this.tag = tag;
|
|
128
131
|
}
|
|
129
132
|
__init4() {this.write = async () => {
|
|
130
133
|
if (this.persisted) {
|
|
@@ -144,6 +147,16 @@ var FileBlock = (_class2 = class extends File {
|
|
|
144
147
|
await _promises.writeFile.call(void 0, this.filename, content, "utf-8");
|
|
145
148
|
}
|
|
146
149
|
}}
|
|
150
|
+
__init5() {this.unlink = async () => {
|
|
151
|
+
this.persisted = false;
|
|
152
|
+
const [existingContent, fd] = await this.getExistingContent();
|
|
153
|
+
if (fd) {
|
|
154
|
+
const [start, end] = this.getSlices(existingContent);
|
|
155
|
+
await fd.truncate(0);
|
|
156
|
+
await fd.write(start + end, 0, "utf-8");
|
|
157
|
+
await fd.close();
|
|
158
|
+
}
|
|
159
|
+
}}
|
|
147
160
|
async getExistingContent() {
|
|
148
161
|
try {
|
|
149
162
|
const fd = await _promises.open.call(void 0, this.filename, "r+");
|
|
@@ -189,10 +202,10 @@ ${this.end}`;
|
|
|
189
202
|
|
|
190
203
|
// lib/file-manager.ts
|
|
191
204
|
var FileManager = (_class3 = class {
|
|
192
|
-
constructor(fileOptions) {;_class3.prototype.
|
|
205
|
+
constructor(fileOptions) {;_class3.prototype.__init6.call(this);
|
|
193
206
|
this.fileOptions = fileOptions;
|
|
194
207
|
}
|
|
195
|
-
|
|
208
|
+
__init6() {this.files = []}
|
|
196
209
|
createAndAdd(filename, content, tag) {
|
|
197
210
|
const file = new File(filename, content, tag, this.fileOptions);
|
|
198
211
|
this.add(file);
|
|
@@ -236,9 +249,6 @@ var FileManager = (_class3 = class {
|
|
|
236
249
|
getPersistedFiles() {
|
|
237
250
|
return this.files.filter((file) => file.persisted);
|
|
238
251
|
}
|
|
239
|
-
getPersistedFileNames() {
|
|
240
|
-
return this.getPersistedFiles().map((file) => file.filename);
|
|
241
|
-
}
|
|
242
252
|
}, _class3);
|
|
243
253
|
|
|
244
254
|
// lib/module.ts
|
|
@@ -296,14 +306,14 @@ var _micromatch = require('micromatch'); var _micromatch2 = _interopRequireDefau
|
|
|
296
306
|
|
|
297
307
|
|
|
298
308
|
var WatcherIgnore = (_class4 = class {
|
|
299
|
-
constructor(cwd) {;_class4.prototype.
|
|
309
|
+
constructor(cwd) {;_class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this);_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this);_class4.prototype.__init11.call(this);
|
|
300
310
|
this.cwd = cwd;
|
|
301
311
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
312
|
+
__init7() {this.files = []}
|
|
313
|
+
__init8() {this.regexps = []}
|
|
314
|
+
__init9() {this.functions = []}
|
|
315
|
+
__init10() {this.globs = []}
|
|
316
|
+
__init11() {this.globsMap = /* @__PURE__ */ new Map()}
|
|
307
317
|
ignore(pattern) {
|
|
308
318
|
if (pattern instanceof RegExp) {
|
|
309
319
|
this.regexps.push(pattern);
|
|
@@ -364,20 +374,20 @@ var WatcherIgnore = (_class4 = class {
|
|
|
364
374
|
// lib/watcher.ts
|
|
365
375
|
var isMatch = _micromatch2.default.isMatch;
|
|
366
376
|
var Watcher = (_class5 = class {
|
|
367
|
-
constructor(cwd, options) {;_class5.prototype.
|
|
377
|
+
constructor(cwd, options) {;_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);
|
|
368
378
|
this.cwd = cwd;
|
|
369
379
|
this.options = options;
|
|
370
380
|
this.watcherIgnore = new WatcherIgnore(cwd);
|
|
371
381
|
this.subscription = this.createSubscription();
|
|
372
382
|
}
|
|
373
383
|
|
|
374
|
-
|
|
384
|
+
__init12() {this.listeners = {
|
|
375
385
|
create: [],
|
|
376
386
|
update: [],
|
|
377
387
|
delete: []
|
|
378
388
|
}}
|
|
379
389
|
|
|
380
|
-
|
|
390
|
+
__init13() {this.onEvents = (err, events) => {
|
|
381
391
|
if (err) {
|
|
382
392
|
console.error(err);
|
|
383
393
|
return;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/baeta/baeta/packages/generator-sdk/dist/index.cjs","../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"],"names":["GeneratorPluginVersion","path","micromatch"],"mappings":"AAAA;ACAA,gGAA+D;AAiGxD,SAAS,WAAA,CAAY,OAAA,EAAuD;AAClF,EAAA,MAAM,IAAA,EAAM,iCAAA,iBAAU,OAAA,CAAQ,GAAA,UAAO,OAAA,CAAQ,GAAA,CAAI,GAAC,CAAA;AAClD,EAAA,MAAM,QAAA,mBAAU,OAAA,CAAQ,OAAA,UAAW,CAAC,kBAAkB,GAAA;AACtD,EAAA,MAAM,WAAA,EAAa,iCAAA,+BAAU,GAAQ,EAAK,OAAA,CAAQ,WAAA,GAAc,aAAa,CAAC,CAAA;AAC9E,EAAA,MAAM,qBAAA,EAAuB,OAAA,CAAQ,qBAAA,GAAwB,YAAA;AAE7D,EAAA,MAAM,qBAAA,EAAuB,+BAAA,UAAQ,EAAY,2BAA2B,CAAA;AAC5E,EAAA,MAAM,cAAA,EAAgB,+BAAA,GAAQ,EAAK,OAAA,CAAQ,cAAA,GAAiB,oBAAoB,CAAA;AAChF,EAAA,MAAM,cAAA,EAAgB,iCAAA,gCAAU,UAAS,EAAY,aAAa,CAAC,CAAA;AAEnE,EAAA,MAAM,YAAA,EAAc,kBAAA,CAAmB,GAAA,EAAK,aAAA,EAAe,OAAA,CAAQ,WAAW,CAAA;AAC9E,EAAA,MAAM,WAAA,EAAa,oBAAA,CAAqB,UAAA,EAAY,oBAAA,E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ACH,MAAA;AACD,IAAA;AAEI,IAAA;AACH,MAAA;AACD,IAAA;AAEO,IAAA;AACR,EAAA;AACD;ARqRY;AACA;AO/VC;AASA;AAWZ,EAAA;AACkB,IAAA;AACA,IAAA;AAEZ,IAAA;AACA,IAAA;AACN,EAAA;AAhBQ,EAAA;AAEA,mBAAA;AACC,IAAA;AACA,IAAA;AACA,IAAA;AACT,EAAA;AAEQ,EAAA;AAUR,mBAAA;AACK,IAAA;AACH,MAAA;AACA,MAAA;AACD,IAAA;AAEM,IAAA;AACL,MAAA;AACA,IAAA;AAED,IAAA;AACC,MAAA;AACC,QAAA;AACC,UAAA;AACA,UAAA;AACA,UAAA;AACA,QAAA;AACF,MAAA;AACD,IAAA;AACD,EAAA;AAEqB,EAAA;AACf,IAAA;AACN,EAAA;AAEI,EAAA;AACE,IAAA;AACN,EAAA;AAEO,EAAA;AACD,IAAA;AACN,EAAA;AAES,EAAA;AACH,IAAA;AACN,EAAA;AAEA,EAAA;AACO,IAAA;AAEA,IAAA;AACC,MAAA;AACA,MAAA;AACP,IAAA;AAEO,IAAA;AACN,MAAA;AACD,IAAA;AACD,EAAA;AAEQ,EAAA;AACA,IAAA;AACR,EAAA;AACD;AP0UY;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/baeta/baeta/packages/generator-sdk/dist/index.cjs","sourcesContent":[null,"import { isAbsolute, join, posixPath, relative, resolve } from '@baeta/util-path';\nimport type { FileOptions } from './file.ts';\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 graphql generator.\n */\nexport interface GeneratorOptions {\n\t/**\n\t * Current working directory.\n\t * @default process.cwd()\n\t */\n\tcwd?: string;\n\n\t/**\n\t * Glob pattern(s) to load graphql schema files.\n\t * @default ['src/∗∗/∗.graphql']\n\t */\n\tschemas: string[];\n\n\t/**\n\t * Directory where modules are defined.\n\t * @default 'src/modules'\n\t */\n\tmodulesDir?: string;\n\n\t/**\n\t * Name for the generated module definition file. This will contain type definitions and the graphql ast.\n\t * @default 'typedef.ts'\n\t */\n\tmoduleDefinitionName?: string;\n\n\t/**\n\t * Path for the generated base types file.\n\t * @default `${modulesDir}/../__generated__/types.ts`\n\t */\n\tbaseTypesPath?: string;\n\n\t/**\n\t * Path where the context type is exported.\n\t * @example contextType: 'src/types/context#Context' // for named export\n\t * @example contextType: 'src/types/context' // for default export\n\t * @default undefined\n\t */\n\tcontextType?: string;\n\n\t/**\n\t * Path where extensions (ex. auth-extension) are exported. Only default export is supported.\n\t * @example extensions: 'src/extensions'\n\t * @default undefined\n\t */\n\textensions?: string;\n\n\t/**\n\t * Custom scalar mappings.\n\t * @example scalars: { DateTime: 'Date' }\n\t * @default undefined\n\t */\n\tscalars?: Record<string, string>;\n\n\t/**\n\t * Options for generated files.\n\t */\n\tfileOptions?: FileOptions;\n\n\t/**\n\t * Additional schema loaders to be used for \"schemas\" option.\n\t */\n\tloaders?: Loader[];\n\n\t/**\n\t * File extension for generated import statements.\n\t */\n\timportExtension?: '.js' | '.ts';\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>;\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 = resolveContextType(cwd, baseTypesRoot, options.contextType);\n\tconst extensions = resolveExtensionPath(modulesDir, moduleDefinitionName, options.extensions);\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: options.scalars,\n\t\tfileOptions: options.fileOptions,\n\t\tloaders: options.loaders,\n\t\timportExtension: options.importExtension,\n\t};\n}\n\nfunction resolveContextType(root: string, baseTypesRoot: string, contextType?: string) {\n\tif (!contextType) {\n\t\treturn;\n\t}\n\n\tif (isAbsolute(contextType)) {\n\t\treturn contextType;\n\t}\n\n\tif (contextType[0] === '!') {\n\t\treturn contextType.slice(1);\n\t}\n\n\tconst contextTypeRoot = resolve(root, contextType);\n\n\treturn posixPath(relative(join(baseTypesRoot, '../'), contextTypeRoot));\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 * Add generation notice at the beginning of the file.\n\t * @default true\n\t */\n\taddGenerationNoticeHeader?: boolean;\n\n\t/**\n\t * Add eslint-disable comment at the beginning of the file.\n\t * @default true\n\t */\n\taddEslintDisableHeader?: 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?.addGenerationNoticeHeader !== false) {\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?.addEslintDisableHeader !== false) {\n\t\t\tconst comment = this.createComment('eslint-disable');\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\tfilename: string,\n\t\tcontent: string,\n\t\tprotected start: string,\n\t\tprotected end: string,\n\t\ttag: string,\n\t\toptions?: FileOptions,\n\t) {\n\t\tsuper(filename, content, tag, {\n\t\t\taddEslintDisableHeader: options?.addEslintDisableHeader ?? false,\n\t\t\taddGenerationNoticeHeader: options?.addGenerationNoticeHeader ?? false,\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\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 (err) {\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\tgetPersistedFileNames() {\n\t\treturn this.getPersistedFiles().map((file) => file.filename);\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"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/baeta/baeta/packages/generator-sdk/dist/index.cjs","../lib/config.ts","../lib/file.ts","../lib/file-block.ts","../lib/file-manager.ts","../lib/module.ts","../lib/plugin.ts","../lib/watcher.ts","../lib/watc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AAUR,mBAAA;AACK,IAAA;AACH,MAAA;AACA,MAAA;AACD,IAAA;AAEM,IAAA;AACL,MAAA;AACA,IAAA;AAED,IAAA;AACC,MAAA;AACC,QAAA;AACC,UAAA;AACA,UAAA;AACA,UAAA;AACA,QAAA;AACF,MAAA;AACD,IAAA;AACD,EAAA;AAEqB,EAAA;AACf,IAAA;AACN,EAAA;AAEI,EAAA;AACE,IAAA;AACN,EAAA;AAEO,EAAA;AACD,IAAA;AACN,EAAA;AAES,EAAA;AACH,IAAA;AACN,EAAA;AAEA,EAAA;AACO,IAAA;AAEA,IAAA;AACC,MAAA;AACA,MAAA;AACP,IAAA;AAEO,IAAA;AACN,MAAA;AACD,IAAA;AACD,EAAA;AAEQ,EAAA;AACA,IAAA;AACR,EAAA;AACD;APoVY;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/baeta/baeta/packages/generator-sdk/dist/index.cjs","sourcesContent":[null,"import { isAbsolute, join, posixPath, relative, resolve } from '@baeta/util-path';\nimport type { FileOptions } from './file.ts';\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 graphql generator.\n */\nexport interface GeneratorOptions {\n\t/**\n\t * Current working directory.\n\t * @default process.cwd()\n\t */\n\tcwd?: string;\n\n\t/**\n\t * Glob pattern(s) to load graphql schema files.\n\t * @default ['src/∗∗/∗.graphql']\n\t */\n\tschemas: string[];\n\n\t/**\n\t * Directory where modules are defined.\n\t * @default 'src/modules'\n\t */\n\tmodulesDir?: string;\n\n\t/**\n\t * Name for the generated module definition file. This will contain type definitions and the graphql ast.\n\t * @default 'typedef.ts'\n\t */\n\tmoduleDefinitionName?: string;\n\n\t/**\n\t * Path for the generated base types file.\n\t * @default `${modulesDir}/../__generated__/types.ts`\n\t */\n\tbaseTypesPath?: string;\n\n\t/**\n\t * Path where the context type is exported.\n\t * @example contextType: 'src/types/context#Context' // for named export\n\t * @example contextType: 'src/types/context' // for default export\n\t * @default undefined\n\t */\n\tcontextType?: string;\n\n\t/**\n\t * Path where extensions (ex. auth-extension) are exported. Only default export is supported.\n\t * @example extensions: 'src/extensions'\n\t * @default undefined\n\t */\n\textensions?: string;\n\n\t/**\n\t * Custom scalar mappings.\n\t * @example scalars: { DateTime: 'Date' }\n\t * @default undefined\n\t */\n\tscalars?: Record<string, string>;\n\n\t/**\n\t * Options for generated files.\n\t */\n\tfileOptions?: FileOptions;\n\n\t/**\n\t * Additional schema loaders to be used for \"schemas\" option.\n\t */\n\tloaders?: Loader[];\n\n\t/**\n\t * File extension for generated import statements.\n\t */\n\timportExtension?: '.js' | '.ts';\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>;\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 = resolveContextType(cwd, baseTypesRoot, options.contextType);\n\tconst extensions = resolveExtensionPath(modulesDir, moduleDefinitionName, options.extensions);\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: options.scalars,\n\t\tfileOptions: options.fileOptions,\n\t\tloaders: options.loaders,\n\t\timportExtension: options.importExtension,\n\t};\n}\n\nfunction resolveContextType(root: string, baseTypesRoot: string, contextType?: string) {\n\tif (!contextType) {\n\t\treturn;\n\t}\n\n\tif (isAbsolute(contextType)) {\n\t\treturn contextType;\n\t}\n\n\tif (contextType[0] === '!') {\n\t\treturn contextType.slice(1);\n\t}\n\n\tconst contextTypeRoot = resolve(root, contextType);\n\n\treturn posixPath(relative(join(baseTypesRoot, '../'), contextTypeRoot));\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 * Add generation notice at the beginning of the file.\n\t * @default true\n\t */\n\taddGenerationNoticeHeader?: boolean;\n\n\t/**\n\t * Add eslint-disable comment at the beginning of the file.\n\t * @default true\n\t */\n\taddEslintDisableHeader?: 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?.addGenerationNoticeHeader !== false) {\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?.addEslintDisableHeader !== false) {\n\t\t\tconst comment = this.createComment('eslint-disable');\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\taddEslintDisableHeader: options?.addEslintDisableHeader ?? false,\n\t\t\taddGenerationNoticeHeader: options?.addGenerationNoticeHeader ?? false,\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 (err) {\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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -137,7 +137,6 @@ declare class FileManager {
|
|
|
137
137
|
writeByTag(tag: string): Promise<void[]>;
|
|
138
138
|
unlinkAll(): Promise<void>;
|
|
139
139
|
getPersistedFiles(): File[];
|
|
140
|
-
getPersistedFileNames(): string[];
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
type MatchFn = (testString: string) => boolean;
|
|
@@ -180,10 +179,14 @@ type Ctx<T = unknown> = {
|
|
|
180
179
|
} & T;
|
|
181
180
|
|
|
182
181
|
declare class FileBlock extends File {
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
filename: string;
|
|
183
|
+
content: string;
|
|
184
|
+
start: string;
|
|
185
|
+
end: string;
|
|
186
|
+
tag: string;
|
|
185
187
|
constructor(filename: string, content: string, start: string, end: string, tag: string, options?: FileOptions);
|
|
186
188
|
write: () => Promise<void>;
|
|
189
|
+
unlink: () => Promise<void>;
|
|
187
190
|
protected getExistingContent(): Promise<readonly [string, fs_promises.FileHandle] | readonly ["", null]>;
|
|
188
191
|
protected getSlices(existingContent: string): readonly [string, "", false] | readonly [string, string, true];
|
|
189
192
|
protected addBlockToContent(existingContent: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,6 @@ declare class FileManager {
|
|
|
137
137
|
writeByTag(tag: string): Promise<void[]>;
|
|
138
138
|
unlinkAll(): Promise<void>;
|
|
139
139
|
getPersistedFiles(): File[];
|
|
140
|
-
getPersistedFileNames(): string[];
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
type MatchFn = (testString: string) => boolean;
|
|
@@ -180,10 +179,14 @@ type Ctx<T = unknown> = {
|
|
|
180
179
|
} & T;
|
|
181
180
|
|
|
182
181
|
declare class FileBlock extends File {
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
filename: string;
|
|
183
|
+
content: string;
|
|
184
|
+
start: string;
|
|
185
|
+
end: string;
|
|
186
|
+
tag: string;
|
|
185
187
|
constructor(filename: string, content: string, start: string, end: string, tag: string, options?: FileOptions);
|
|
186
188
|
write: () => Promise<void>;
|
|
189
|
+
unlink: () => Promise<void>;
|
|
187
190
|
protected getExistingContent(): Promise<readonly [string, fs_promises.FileHandle] | readonly ["", null]>;
|
|
188
191
|
protected getSlices(existingContent: string): readonly [string, "", false] | readonly [string, string, true];
|
|
189
192
|
protected addBlockToContent(existingContent: string): string;
|
package/dist/index.js
CHANGED
|
@@ -123,8 +123,11 @@ var FileBlock = class extends File {
|
|
|
123
123
|
addEslintDisableHeader: options?.addEslintDisableHeader ?? false,
|
|
124
124
|
addGenerationNoticeHeader: options?.addGenerationNoticeHeader ?? false
|
|
125
125
|
});
|
|
126
|
+
this.filename = filename;
|
|
127
|
+
this.content = content;
|
|
126
128
|
this.start = start;
|
|
127
129
|
this.end = end;
|
|
130
|
+
this.tag = tag;
|
|
128
131
|
}
|
|
129
132
|
write = async () => {
|
|
130
133
|
if (this.persisted) {
|
|
@@ -144,6 +147,16 @@ var FileBlock = class extends File {
|
|
|
144
147
|
await writeFile(this.filename, content, "utf-8");
|
|
145
148
|
}
|
|
146
149
|
};
|
|
150
|
+
unlink = async () => {
|
|
151
|
+
this.persisted = false;
|
|
152
|
+
const [existingContent, fd] = await this.getExistingContent();
|
|
153
|
+
if (fd) {
|
|
154
|
+
const [start, end] = this.getSlices(existingContent);
|
|
155
|
+
await fd.truncate(0);
|
|
156
|
+
await fd.write(start + end, 0, "utf-8");
|
|
157
|
+
await fd.close();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
147
160
|
async getExistingContent() {
|
|
148
161
|
try {
|
|
149
162
|
const fd = await open(this.filename, "r+");
|
|
@@ -236,9 +249,6 @@ var FileManager = class {
|
|
|
236
249
|
getPersistedFiles() {
|
|
237
250
|
return this.files.filter((file) => file.persisted);
|
|
238
251
|
}
|
|
239
|
-
getPersistedFileNames() {
|
|
240
|
-
return this.getPersistedFiles().map((file) => file.filename);
|
|
241
|
-
}
|
|
242
252
|
};
|
|
243
253
|
|
|
244
254
|
// lib/module.ts
|
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// 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 graphql generator.\n */\nexport interface GeneratorOptions {\n\t/**\n\t * Current working directory.\n\t * @default process.cwd()\n\t */\n\tcwd?: string;\n\n\t/**\n\t * Glob pattern(s) to load graphql schema files.\n\t * @default ['src/∗∗/∗.graphql']\n\t */\n\tschemas: string[];\n\n\t/**\n\t * Directory where modules are defined.\n\t * @default 'src/modules'\n\t */\n\tmodulesDir?: string;\n\n\t/**\n\t * Name for the generated module definition file. This will contain type definitions and the graphql ast.\n\t * @default 'typedef.ts'\n\t */\n\tmoduleDefinitionName?: string;\n\n\t/**\n\t * Path for the generated base types file.\n\t * @default `${modulesDir}/../__generated__/types.ts`\n\t */\n\tbaseTypesPath?: string;\n\n\t/**\n\t * Path where the context type is exported.\n\t * @example contextType: 'src/types/context#Context' // for named export\n\t * @example contextType: 'src/types/context' // for default export\n\t * @default undefined\n\t */\n\tcontextType?: string;\n\n\t/**\n\t * Path where extensions (ex. auth-extension) are exported. Only default export is supported.\n\t * @example extensions: 'src/extensions'\n\t * @default undefined\n\t */\n\textensions?: string;\n\n\t/**\n\t * Custom scalar mappings.\n\t * @example scalars: { DateTime: 'Date' }\n\t * @default undefined\n\t */\n\tscalars?: Record<string, string>;\n\n\t/**\n\t * Options for generated files.\n\t */\n\tfileOptions?: FileOptions;\n\n\t/**\n\t * Additional schema loaders to be used for \"schemas\" option.\n\t */\n\tloaders?: Loader[];\n\n\t/**\n\t * File extension for generated import statements.\n\t */\n\timportExtension?: '.js' | '.ts';\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>;\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 = resolveContextType(cwd, baseTypesRoot, options.contextType);\n\tconst extensions = resolveExtensionPath(modulesDir, moduleDefinitionName, options.extensions);\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: options.scalars,\n\t\tfileOptions: options.fileOptions,\n\t\tloaders: options.loaders,\n\t\timportExtension: options.importExtension,\n\t};\n}\n\nfunction resolveContextType(root: string, baseTypesRoot: string, contextType?: string) {\n\tif (!contextType) {\n\t\treturn;\n\t}\n\n\tif (isAbsolute(contextType)) {\n\t\treturn contextType;\n\t}\n\n\tif (contextType[0] === '!') {\n\t\treturn contextType.slice(1);\n\t}\n\n\tconst contextTypeRoot = resolve(root, contextType);\n\n\treturn posixPath(relative(join(baseTypesRoot, '../'), contextTypeRoot));\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 * Add generation notice at the beginning of the file.\n\t * @default true\n\t */\n\taddGenerationNoticeHeader?: boolean;\n\n\t/**\n\t * Add eslint-disable comment at the beginning of the file.\n\t * @default true\n\t */\n\taddEslintDisableHeader?: 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?.addGenerationNoticeHeader !== false) {\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?.addEslintDisableHeader !== false) {\n\t\t\tconst comment = this.createComment('eslint-disable');\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\tfilename: string,\n\t\tcontent: string,\n\t\tprotected start: string,\n\t\tprotected end: string,\n\t\ttag: string,\n\t\toptions?: FileOptions,\n\t) {\n\t\tsuper(filename, content, tag, {\n\t\t\taddEslintDisableHeader: options?.addEslintDisableHeader ?? false,\n\t\t\taddGenerationNoticeHeader: options?.addGenerationNoticeHeader ?? false,\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\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 (err) {\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\tgetPersistedFileNames() {\n\t\treturn this.getPersistedFiles().map((file) => file.filename);\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)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,MAAM,MAAM;AAAA,UACZ,MAAMA,WAAU,MAAM,IAAI;AAAA,UAC1B,cAAcA,WAAUC,MAAK,SAAS,KAAK,KAAK,MAAM,IAAI,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":["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 { isAbsolute, join, posixPath, relative, resolve } from '@baeta/util-path';\nimport type { FileOptions } from './file.ts';\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 graphql generator.\n */\nexport interface GeneratorOptions {\n\t/**\n\t * Current working directory.\n\t * @default process.cwd()\n\t */\n\tcwd?: string;\n\n\t/**\n\t * Glob pattern(s) to load graphql schema files.\n\t * @default ['src/∗∗/∗.graphql']\n\t */\n\tschemas: string[];\n\n\t/**\n\t * Directory where modules are defined.\n\t * @default 'src/modules'\n\t */\n\tmodulesDir?: string;\n\n\t/**\n\t * Name for the generated module definition file. This will contain type definitions and the graphql ast.\n\t * @default 'typedef.ts'\n\t */\n\tmoduleDefinitionName?: string;\n\n\t/**\n\t * Path for the generated base types file.\n\t * @default `${modulesDir}/../__generated__/types.ts`\n\t */\n\tbaseTypesPath?: string;\n\n\t/**\n\t * Path where the context type is exported.\n\t * @example contextType: 'src/types/context#Context' // for named export\n\t * @example contextType: 'src/types/context' // for default export\n\t * @default undefined\n\t */\n\tcontextType?: string;\n\n\t/**\n\t * Path where extensions (ex. auth-extension) are exported. Only default export is supported.\n\t * @example extensions: 'src/extensions'\n\t * @default undefined\n\t */\n\textensions?: string;\n\n\t/**\n\t * Custom scalar mappings.\n\t * @example scalars: { DateTime: 'Date' }\n\t * @default undefined\n\t */\n\tscalars?: Record<string, string>;\n\n\t/**\n\t * Options for generated files.\n\t */\n\tfileOptions?: FileOptions;\n\n\t/**\n\t * Additional schema loaders to be used for \"schemas\" option.\n\t */\n\tloaders?: Loader[];\n\n\t/**\n\t * File extension for generated import statements.\n\t */\n\timportExtension?: '.js' | '.ts';\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>;\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 = resolveContextType(cwd, baseTypesRoot, options.contextType);\n\tconst extensions = resolveExtensionPath(modulesDir, moduleDefinitionName, options.extensions);\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: options.scalars,\n\t\tfileOptions: options.fileOptions,\n\t\tloaders: options.loaders,\n\t\timportExtension: options.importExtension,\n\t};\n}\n\nfunction resolveContextType(root: string, baseTypesRoot: string, contextType?: string) {\n\tif (!contextType) {\n\t\treturn;\n\t}\n\n\tif (isAbsolute(contextType)) {\n\t\treturn contextType;\n\t}\n\n\tif (contextType[0] === '!') {\n\t\treturn contextType.slice(1);\n\t}\n\n\tconst contextTypeRoot = resolve(root, contextType);\n\n\treturn posixPath(relative(join(baseTypesRoot, '../'), contextTypeRoot));\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 * Add generation notice at the beginning of the file.\n\t * @default true\n\t */\n\taddGenerationNoticeHeader?: boolean;\n\n\t/**\n\t * Add eslint-disable comment at the beginning of the file.\n\t * @default true\n\t */\n\taddEslintDisableHeader?: 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?.addGenerationNoticeHeader !== false) {\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?.addEslintDisableHeader !== false) {\n\t\t\tconst comment = this.createComment('eslint-disable');\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\taddEslintDisableHeader: options?.addEslintDisableHeader ?? false,\n\t\t\taddGenerationNoticeHeader: options?.addGenerationNoticeHeader ?? false,\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 (err) {\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.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D;AAEA,UAAM,iBAAiB,OAAO,OAAO,CAAC,UAAU;AAC/C,aAAO,CAAC,KAAK,cAAc,UAAUC,WAAU,MAAM,IAAI,CAAC;AAAA,IAC3D,CAAC;AAED,eAAW,SAAS,gBAAgB;AACnC,iBAAW,YAAY,KAAK,UAAU,MAAM,IAAI,GAAG;AAClD,iBAAS;AAAA,UACR,MAAM,MAAM;AAAA,UACZ,MAAMA,WAAU,MAAM,IAAI;AAAA,UAC1B,cAAcA,WAAUC,MAAK,SAAS,KAAK,KAAK,MAAM,IAAI,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":["dirname","dirname","GeneratorPluginVersion","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": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"baeta",
|
|
6
6
|
"graphql",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"types": "tsc --noEmit"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@baeta/plugin": "^0.1.
|
|
48
|
-
"@baeta/util-path": "^0.1.
|
|
47
|
+
"@baeta/plugin": "^0.1.2",
|
|
48
|
+
"@baeta/util-path": "^0.1.2",
|
|
49
49
|
"@parcel/watcher": "^2.5.0",
|
|
50
50
|
"change-case-all": "2.1.0",
|
|
51
51
|
"micromatch": "^4.0.8"
|
|
@@ -54,14 +54,21 @@
|
|
|
54
54
|
"@baeta/builder": "^0.0.0",
|
|
55
55
|
"@baeta/tsconfig": "^0.0.0",
|
|
56
56
|
"@types/micromatch": "^4.0.9",
|
|
57
|
-
"@types/node": "^22.9.
|
|
57
|
+
"@types/node": "^22.9.1",
|
|
58
58
|
"typescript": "^5.6.3"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=22.0.0"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
|
-
"access": "public"
|
|
64
|
+
"access": "public",
|
|
65
|
+
"exports": {
|
|
66
|
+
".": {
|
|
67
|
+
"types": "./dist/index.d.ts",
|
|
68
|
+
"import": "./dist/index.js",
|
|
69
|
+
"require": "./dist/index.cjs"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
65
72
|
},
|
|
66
73
|
"ava": {
|
|
67
74
|
"extensions": {
|