pluggable-codegen 0.3.4 → 0.5.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.
Files changed (43) hide show
  1. package/README.md +4 -3
  2. package/dist/_virtual/_rolldown/runtime.cjs +2 -4
  3. package/dist/_virtual/_rolldown/runtime.mjs +2 -3
  4. package/dist/cache.cjs +10 -7
  5. package/dist/cache.mjs +9 -5
  6. package/dist/cli.d.mts +1 -1
  7. package/dist/cli.mjs +6 -5
  8. package/dist/codegen.cjs +30 -36
  9. package/dist/codegen.d.mts +4 -8
  10. package/dist/codegen.mjs +25 -31
  11. package/dist/file.cjs +1 -3
  12. package/dist/file.d.mts +2 -5
  13. package/dist/file.mjs +1 -2
  14. package/dist/index.cjs +7 -5
  15. package/dist/index.d.mts +4 -2
  16. package/dist/index.mjs +2 -1
  17. package/dist/options.cjs +8 -7
  18. package/dist/options.mjs +7 -5
  19. package/dist/plugin.cjs +2 -3
  20. package/dist/plugin.d.mts +4 -8
  21. package/dist/plugin.mjs +1 -2
  22. package/dist/postprocessors/eslint.cjs +20 -0
  23. package/dist/postprocessors/eslint.d.mts +8 -0
  24. package/dist/postprocessors/eslint.mjs +20 -0
  25. package/dist/postprocessors/index.cjs +12 -0
  26. package/dist/postprocessors/index.d.mts +7 -0
  27. package/dist/postprocessors/index.mjs +12 -0
  28. package/dist/postprocessors/oxfmt.cjs +34 -0
  29. package/dist/postprocessors/oxfmt.d.mts +9 -0
  30. package/dist/postprocessors/oxfmt.mjs +34 -0
  31. package/dist/postprocessors/prettier.cjs +15 -0
  32. package/dist/postprocessors/prettier.d.mts +7 -0
  33. package/dist/postprocessors/prettier.mjs +15 -0
  34. package/dist/postprocessors/types.d.mts +9 -0
  35. package/dist/presets/graphql-codegen.cjs +2 -4
  36. package/dist/presets/graphql-codegen.d.mts +2 -6
  37. package/dist/presets/graphql-codegen.mjs +2 -3
  38. package/dist/types.cjs +1 -3
  39. package/dist/types.d.mts +11 -20
  40. package/dist/types.mjs +1 -2
  41. package/dist/utils.cjs +1 -3
  42. package/dist/utils.mjs +1 -2
  43. package/package.json +32 -36
package/README.md CHANGED
@@ -38,6 +38,7 @@ export default defineCodegen(
38
38
  // auto-detected based on devDependencies:
39
39
  eslint: undefined,
40
40
  prettier: undefined,
41
+ oxfmt: undefined, // only an '.oxfmtrc.json' config file is supported for now
41
42
  },
42
43
  // followed by one or more codegen jobs:
43
44
  {
@@ -61,7 +62,7 @@ export default defineCodegen(
61
62
  // checking the cache; this can include e.g. `import.meta.filename`
62
63
  // to make the job rebuild when its definition changes
63
64
  extraDeps: undefined,
64
- // you can override the global 'eslint' and 'prettier' options
65
+ // you can override the global 'eslint', 'prettier', and 'oxfmt' options
65
66
  // per-job, e.g.:
66
67
  prettier: false,
67
68
  },
@@ -81,9 +82,9 @@ Within a bundler config, such as `vite.config.ts`, you would just use
81
82
  the `codegen()` plugin instead of the `defineCodegen()` typing helper:
82
83
 
83
84
  ```typescript
85
+ import { codegen } from 'pluggable-codegen';
84
86
  // vite.config.ts
85
87
  import { defineConfig } from 'vite';
86
- import { codegen } from 'pluggable-codegen';
87
88
 
88
89
  export default defineConfig({
89
90
  plugins: [
@@ -99,8 +100,8 @@ and before `svelte-check`:
99
100
  ```typescript
100
101
  // vite.config.ts
101
102
 
102
- import { defineConfig } from 'vite';
103
103
  import { codegen } from 'pluggable-codegen';
104
+ import { defineConfig } from 'vite';
104
105
  import codegenConfig from './codegen.config';
105
106
 
106
107
  export default defineConfig({
@@ -1,4 +1,4 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -19,11 +19,9 @@ var __copyProps = (to, from, except, desc) => {
19
19
  }
20
20
  return to;
21
21
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
23
  value: mod,
24
24
  enumerable: true
25
25
  }) : target, mod));
26
26
 
27
- //#endregion
28
-
29
27
  exports.__toESM = __toESM;
@@ -1,7 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
 
3
- //#region \0rolldown/runtime.js
4
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
+ // \0rolldown/runtime.js
4
+ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
5
5
 
6
- //#endregion
7
6
  export { __require };
package/dist/cache.cjs CHANGED
@@ -1,15 +1,14 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
- const require_utils = require('./utils.cjs');
1
+ const require_utils = require("./utils.cjs");
3
2
  let node_fs_promises = require("node:fs/promises");
4
3
  let node_path = require("node:path");
5
4
  let node_crypto = require("node:crypto");
6
5
 
7
- //#region src/cache.ts
6
+ // src/cache.ts
8
7
  var Cache = class {
9
8
  #rootDir;
10
9
  #cacheFile;
11
10
  #cacheData;
12
- #writeTmr;
11
+ #dirty = false;
13
12
  constructor(rootDir, cacheFile) {
14
13
  this.#rootDir = rootDir;
15
14
  this.#cacheFile = cacheFile;
@@ -32,8 +31,13 @@ var Cache = class {
32
31
  source: sourceHash,
33
32
  output: newHash
34
33
  });
35
- clearTimeout(this.#writeTmr);
36
- this.#writeTmr = setTimeout(() => this.#writeCacheData(cacheData), 250);
34
+ this.#dirty = true;
35
+ }
36
+ async flush() {
37
+ if (this.#dirty) {
38
+ this.#dirty = false;
39
+ await this.#writeCacheData(await (this.#cacheData ??= this.#readCacheData()));
40
+ }
37
41
  }
38
42
  async #getSourceHash(files, mode) {
39
43
  const hash = (0, node_crypto.createHash)("sha256");
@@ -73,5 +77,4 @@ function isValidEntry(v) {
73
77
  return Object.keys(v).length === 2 && "source" in v && typeof v.source === "string" && "output" in v && typeof v.output === "string";
74
78
  }
75
79
 
76
- //#endregion
77
80
  exports.Cache = Cache;
package/dist/cache.mjs CHANGED
@@ -3,12 +3,12 @@ import { readFile, writeFile } from "node:fs/promises";
3
3
  import { resolve } from "node:path";
4
4
  import { createHash } from "node:crypto";
5
5
 
6
- //#region src/cache.ts
6
+ // src/cache.ts
7
7
  var Cache = class {
8
8
  #rootDir;
9
9
  #cacheFile;
10
10
  #cacheData;
11
- #writeTmr;
11
+ #dirty = false;
12
12
  constructor(rootDir, cacheFile) {
13
13
  this.#rootDir = rootDir;
14
14
  this.#cacheFile = cacheFile;
@@ -31,8 +31,13 @@ var Cache = class {
31
31
  source: sourceHash,
32
32
  output: newHash
33
33
  });
34
- clearTimeout(this.#writeTmr);
35
- this.#writeTmr = setTimeout(() => this.#writeCacheData(cacheData), 250);
34
+ this.#dirty = true;
35
+ }
36
+ async flush() {
37
+ if (this.#dirty) {
38
+ this.#dirty = false;
39
+ await this.#writeCacheData(await (this.#cacheData ??= this.#readCacheData()));
40
+ }
36
41
  }
37
42
  async #getSourceHash(files, mode) {
38
43
  const hash = createHash("sha256");
@@ -72,5 +77,4 @@ function isValidEntry(v) {
72
77
  return Object.keys(v).length === 2 && "source" in v && typeof v.source === "string" && "output" in v && typeof v.output === "string";
73
78
  }
74
79
 
75
- //#endregion
76
80
  export { Cache };
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/cli.mjs CHANGED
@@ -4,7 +4,7 @@ import { lookupPath } from "./utils.mjs";
4
4
  import { Codegen } from "./codegen.mjs";
5
5
  import { resolve } from "node:path";
6
6
 
7
- //#region src/cli.ts
7
+ // src/cli.ts
8
8
  const configFiles = [
9
9
  "codegen.config.mjs",
10
10
  "codegen.config.cjs",
@@ -14,13 +14,15 @@ const configFiles = [
14
14
  const config = process.argv.length > 2 ? await importConfig(resolve(process.argv[2])) : await lookupPath(process.cwd(), configFiles, importConfig);
15
15
  if (!config) {
16
16
  console.log(`Usage: pluggable-codegen [config]`);
17
- process.exit(1);
17
+ process.exitCode = 1;
18
+ return;
18
19
  }
19
20
  if (!validateConfig(config)) {
20
21
  console.log(`Invalid config`);
21
- process.exit(1);
22
+ process.exitCode = 1;
23
+ return;
22
24
  }
23
- await (await Codegen.init(...config)).generateAll();
25
+ if (!await (await Codegen.init(...config)).generateAll()) process.exitCode = 1;
24
26
  })();
25
27
  async function importConfig(path) {
26
28
  try {
@@ -38,5 +40,4 @@ function validateConfig(config) {
38
40
  return true;
39
41
  }
40
42
 
41
- //#endregion
42
43
  export { };
package/dist/codegen.cjs CHANGED
@@ -1,26 +1,26 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
- const require_utils = require('./utils.cjs');
3
- const require_cache = require('./cache.cjs');
4
- const require_file = require('./file.cjs');
5
- const require_options = require('./options.cjs');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_utils = require("./utils.cjs");
3
+ const require_cache = require("./cache.cjs");
4
+ const require_file = require("./file.cjs");
5
+ const require_index = require("./postprocessors/index.cjs");
6
+ const require_options = require("./options.cjs");
6
7
  let node_fs_promises = require("node:fs/promises");
7
8
  let node_path = require("node:path");
8
9
  let picomatch = require("picomatch");
9
10
  picomatch = require_runtime.__toESM(picomatch, 1);
10
11
  let tinyglobby = require("tinyglobby");
11
12
 
12
- //#region src/codegen.ts
13
+ // src/codegen.ts
13
14
  var Codegen = class Codegen {
14
15
  #options;
15
16
  #cache;
16
17
  #jobs;
17
18
  #running = /* @__PURE__ */ new Map();
18
- #eslint;
19
- #prettier;
20
19
  static async init(jobOrOptions, ...moreJobs) {
21
20
  const [options, jobs] = typeof jobOrOptions === "function" || "input" in jobOrOptions ? [void 0, [jobOrOptions, ...moreJobs]] : [jobOrOptions, moreJobs];
22
21
  const normalizedOptions = await require_options.normalizeOptions(options);
23
- return new Codegen(normalizedOptions, await require_options.normalizeJobs(normalizedOptions.rootDir, jobs));
22
+ const normalizedJobs = await require_options.normalizeJobs(normalizedOptions.rootDir, jobs);
23
+ return new Codegen(normalizedOptions, normalizedJobs);
24
24
  }
25
25
  constructor(options, jobs) {
26
26
  this.#options = options;
@@ -28,28 +28,38 @@ var Codegen = class Codegen {
28
28
  this.#jobs = this.#createJobMap(jobs);
29
29
  }
30
30
  async generateAll() {
31
- await Promise.allSettled([...this.#jobs.values()].map(async (job) => this.#generate(job)));
31
+ const results = await Promise.all([...this.#jobs.values()].map(this.#generate));
32
+ await this.#cache.flush();
33
+ return results.every((v) => v);
32
34
  }
33
35
  async generateMatching(path) {
34
- await Promise.allSettled([...this.#jobs].map(async ([match, job]) => {
36
+ const results = await Promise.all([...this.#jobs].map(async ([match, job]) => {
35
37
  if (match(path)) await this.#generate(job);
36
38
  }));
39
+ await this.#cache.flush();
40
+ return results.every((v) => v);
37
41
  }
38
- async #generate(job) {
42
+ #generate = async (job) => {
39
43
  this.#running.get(job)?.abort();
40
44
  const controller = new AbortController();
41
45
  this.#running.set(job, controller);
42
46
  const files = await this.#scanFiles(job.input);
43
47
  const extraDeps = job.extraDeps?.length ? await this.#scanFiles(job.extraDeps) : [];
48
+ let success = true;
44
49
  await this.#cache.check([...files, ...extraDeps], job.output, job.cacheBy, async () => {
45
50
  try {
46
51
  const file = (0, node_path.resolve)(this.#options.rootDir, job.output);
47
52
  let output = await job.generate(files, controller.signal);
48
53
  if (output === null) return;
49
54
  if (controller.signal.aborted) return;
50
- if (typeof output === "string" && (job.eslint ?? this.#options.eslint)) output = await this.#applyESLint(output, file);
51
- if (controller.signal.aborted) return;
52
- if (typeof output === "string" && (job.prettier ?? this.#options.prettier)) output = await this.#applyPrettier(output, file);
55
+ const disabled = /* @__PURE__ */ new Set();
56
+ for (const postprocessor of require_index.postprocessors) {
57
+ if (typeof output !== "string") break;
58
+ if (!(job[postprocessor.id] ?? this.#options[postprocessor.id]) || disabled.has(postprocessor.id)) continue;
59
+ for (const id of postprocessor.conflicts) disabled.add(id);
60
+ output = await postprocessor.apply(output, file);
61
+ if (controller.signal.aborted) return;
62
+ }
53
63
  if (controller.signal.aborted) return;
54
64
  try {
55
65
  await (0, node_fs_promises.mkdir)((0, node_path.dirname)(file), {
@@ -63,42 +73,26 @@ var Codegen = class Codegen {
63
73
  console.log(`\nError while generating '${job.output}':`);
64
74
  console.log(e);
65
75
  console.log("");
76
+ success = false;
66
77
  return;
67
78
  }
68
79
  });
69
- }
80
+ return success;
81
+ };
70
82
  async #scanFiles(patterns) {
71
83
  return (await (0, tinyglobby.glob)(patterns, {
72
84
  cwd: this.#options.rootDir,
73
85
  absolute: true
74
86
  })).sort().map((path) => new require_file.File(path, this.#options.rootDir));
75
87
  }
76
- async #applyESLint(source, path) {
77
- const [result] = await (await this.#loadESLint()).lintText(source, { filePath: path });
78
- return result?.output ?? source;
79
- }
80
- async #applyPrettier(source, path) {
81
- const prettier = await this.#loadPrettier();
82
- const options = await prettier.resolveConfig(path);
83
- return prettier.format(source, {
84
- ...options ?? {},
85
- filepath: path
86
- });
87
- }
88
- async #loadESLint() {
89
- return this.#eslint ??= import("eslint").then(({ ESLint }) => new ESLint({ fix: true }));
90
- }
91
- async #loadPrettier() {
92
- return this.#prettier ??= import("prettier");
93
- }
94
88
  #createJobMap(jobs) {
95
89
  return new Map(jobs.map((job) => [this.#createMatcher(job), job]));
96
90
  }
97
91
  #createMatcher(job) {
98
92
  const root = (0, tinyglobby.escapePath)(this.#options.rootDir);
99
- return (0, picomatch.default)([job.input, job.extraDeps ?? []].flat().map((pattern) => (0, node_path.resolve)(root, pattern)));
93
+ const patterns = [job.input, job.extraDeps ?? []];
94
+ return (0, picomatch.default)(patterns.flat().map((pattern) => (0, node_path.resolve)(root, pattern)));
100
95
  }
101
96
  };
102
97
 
103
- //#endregion
104
98
  exports.Codegen = Codegen;
@@ -1,14 +1,10 @@
1
1
  import { CodegenInput, CodegenOptions } from "./types.mjs";
2
-
3
- //#region src/codegen.d.ts
4
- declare class Codegen {
2
+ export declare class Codegen {
5
3
  #private;
6
4
  static init(...jobs: CodegenInput[]): Promise<Codegen>;
7
5
  static init(options: CodegenOptions, ...jobs: CodegenInput[]): Promise<Codegen>;
8
6
  static init(jobOrOptions: CodegenInput | CodegenOptions, ...moreJobs: CodegenInput[]): Promise<Codegen>;
9
7
  private constructor();
10
- generateAll(): Promise<void>;
11
- generateMatching(path: string): Promise<void>;
12
- }
13
- //#endregion
14
- export { Codegen };
8
+ generateAll(): Promise<boolean>;
9
+ generateMatching(path: string): Promise<boolean>;
10
+ }
package/dist/codegen.mjs CHANGED
@@ -1,24 +1,24 @@
1
1
  import { hash } from "./utils.mjs";
2
2
  import { Cache } from "./cache.mjs";
3
3
  import { File } from "./file.mjs";
4
+ import { postprocessors } from "./postprocessors/index.mjs";
4
5
  import { normalizeJobs, normalizeOptions } from "./options.mjs";
5
6
  import { mkdir, writeFile } from "node:fs/promises";
6
7
  import { dirname, resolve } from "node:path";
7
8
  import picomatch from "picomatch";
8
9
  import { escapePath, glob } from "tinyglobby";
9
10
 
10
- //#region src/codegen.ts
11
+ // src/codegen.ts
11
12
  var Codegen = class Codegen {
12
13
  #options;
13
14
  #cache;
14
15
  #jobs;
15
16
  #running = /* @__PURE__ */ new Map();
16
- #eslint;
17
- #prettier;
18
17
  static async init(jobOrOptions, ...moreJobs) {
19
18
  const [options, jobs] = typeof jobOrOptions === "function" || "input" in jobOrOptions ? [void 0, [jobOrOptions, ...moreJobs]] : [jobOrOptions, moreJobs];
20
19
  const normalizedOptions = await normalizeOptions(options);
21
- return new Codegen(normalizedOptions, await normalizeJobs(normalizedOptions.rootDir, jobs));
20
+ const normalizedJobs = await normalizeJobs(normalizedOptions.rootDir, jobs);
21
+ return new Codegen(normalizedOptions, normalizedJobs);
22
22
  }
23
23
  constructor(options, jobs) {
24
24
  this.#options = options;
@@ -26,28 +26,38 @@ var Codegen = class Codegen {
26
26
  this.#jobs = this.#createJobMap(jobs);
27
27
  }
28
28
  async generateAll() {
29
- await Promise.allSettled([...this.#jobs.values()].map(async (job) => this.#generate(job)));
29
+ const results = await Promise.all([...this.#jobs.values()].map(this.#generate));
30
+ await this.#cache.flush();
31
+ return results.every((v) => v);
30
32
  }
31
33
  async generateMatching(path) {
32
- await Promise.allSettled([...this.#jobs].map(async ([match, job]) => {
34
+ const results = await Promise.all([...this.#jobs].map(async ([match, job]) => {
33
35
  if (match(path)) await this.#generate(job);
34
36
  }));
37
+ await this.#cache.flush();
38
+ return results.every((v) => v);
35
39
  }
36
- async #generate(job) {
40
+ #generate = async (job) => {
37
41
  this.#running.get(job)?.abort();
38
42
  const controller = new AbortController();
39
43
  this.#running.set(job, controller);
40
44
  const files = await this.#scanFiles(job.input);
41
45
  const extraDeps = job.extraDeps?.length ? await this.#scanFiles(job.extraDeps) : [];
46
+ let success = true;
42
47
  await this.#cache.check([...files, ...extraDeps], job.output, job.cacheBy, async () => {
43
48
  try {
44
49
  const file = resolve(this.#options.rootDir, job.output);
45
50
  let output = await job.generate(files, controller.signal);
46
51
  if (output === null) return;
47
52
  if (controller.signal.aborted) return;
48
- if (typeof output === "string" && (job.eslint ?? this.#options.eslint)) output = await this.#applyESLint(output, file);
49
- if (controller.signal.aborted) return;
50
- if (typeof output === "string" && (job.prettier ?? this.#options.prettier)) output = await this.#applyPrettier(output, file);
53
+ const disabled = /* @__PURE__ */ new Set();
54
+ for (const postprocessor of postprocessors) {
55
+ if (typeof output !== "string") break;
56
+ if (!(job[postprocessor.id] ?? this.#options[postprocessor.id]) || disabled.has(postprocessor.id)) continue;
57
+ for (const id of postprocessor.conflicts) disabled.add(id);
58
+ output = await postprocessor.apply(output, file);
59
+ if (controller.signal.aborted) return;
60
+ }
51
61
  if (controller.signal.aborted) return;
52
62
  try {
53
63
  await mkdir(dirname(file), {
@@ -61,42 +71,26 @@ var Codegen = class Codegen {
61
71
  console.log(`\nError while generating '${job.output}':`);
62
72
  console.log(e);
63
73
  console.log("");
74
+ success = false;
64
75
  return;
65
76
  }
66
77
  });
67
- }
78
+ return success;
79
+ };
68
80
  async #scanFiles(patterns) {
69
81
  return (await glob(patterns, {
70
82
  cwd: this.#options.rootDir,
71
83
  absolute: true
72
84
  })).sort().map((path) => new File(path, this.#options.rootDir));
73
85
  }
74
- async #applyESLint(source, path) {
75
- const [result] = await (await this.#loadESLint()).lintText(source, { filePath: path });
76
- return result?.output ?? source;
77
- }
78
- async #applyPrettier(source, path) {
79
- const prettier = await this.#loadPrettier();
80
- const options = await prettier.resolveConfig(path);
81
- return prettier.format(source, {
82
- ...options ?? {},
83
- filepath: path
84
- });
85
- }
86
- async #loadESLint() {
87
- return this.#eslint ??= import("eslint").then(({ ESLint }) => new ESLint({ fix: true }));
88
- }
89
- async #loadPrettier() {
90
- return this.#prettier ??= import("prettier");
91
- }
92
86
  #createJobMap(jobs) {
93
87
  return new Map(jobs.map((job) => [this.#createMatcher(job), job]));
94
88
  }
95
89
  #createMatcher(job) {
96
90
  const root = escapePath(this.#options.rootDir);
97
- return picomatch([job.input, job.extraDeps ?? []].flat().map((pattern) => resolve(root, pattern)));
91
+ const patterns = [job.input, job.extraDeps ?? []];
92
+ return picomatch(patterns.flat().map((pattern) => resolve(root, pattern)));
98
93
  }
99
94
  };
100
95
 
101
- //#endregion
102
96
  export { Codegen };
package/dist/file.cjs CHANGED
@@ -1,8 +1,7 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
1
  let node_fs_promises = require("node:fs/promises");
3
2
  let node_path = require("node:path");
4
3
 
5
- //#region src/file.ts
4
+ // src/file.ts
6
5
  var File = class {
7
6
  fullPath;
8
7
  localPath;
@@ -22,5 +21,4 @@ var File = class {
22
21
  }
23
22
  };
24
23
 
25
- //#endregion
26
24
  exports.File = File;
package/dist/file.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- //#region src/file.d.ts
2
- declare class File {
1
+ export declare class File {
3
2
  #private;
4
3
  readonly fullPath: string;
5
4
  readonly localPath: string;
@@ -7,6 +6,4 @@ declare class File {
7
6
  buffer(): Promise<Buffer>;
8
7
  text(encoding?: BufferEncoding): Promise<string>;
9
8
  json(): Promise<any>;
10
- }
11
- //#endregion
12
- export { File };
9
+ }
package/dist/file.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { relative } from "node:path";
3
3
 
4
- //#region src/file.ts
4
+ // src/file.ts
5
5
  var File = class {
6
6
  fullPath;
7
7
  localPath;
@@ -21,5 +21,4 @@ var File = class {
21
21
  }
22
22
  };
23
23
 
24
- //#endregion
25
24
  export { File };
package/dist/index.cjs CHANGED
@@ -1,10 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_file = require('./file.cjs');
3
- const require_codegen = require('./codegen.cjs');
4
- const require_plugin = require('./plugin.cjs');
5
- const require_types = require('./types.cjs');
2
+ const require_file = require("./file.cjs");
3
+ const require_index = require("./postprocessors/index.cjs");
4
+ const require_codegen = require("./codegen.cjs");
5
+ const require_plugin = require("./plugin.cjs");
6
+ const require_types = require("./types.cjs");
6
7
 
7
8
  exports.Codegen = require_codegen.Codegen;
8
9
  exports.File = require_file.File;
9
10
  exports.codegen = require_plugin.codegen;
10
- exports.defineCodegen = require_types.defineCodegen;
11
+ exports.defineCodegen = require_types.defineCodegen;
12
+ exports.postprocessors = require_index.postprocessors;
package/dist/index.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { File } from "./file.mjs";
2
- import { CodegenInput, CodegenJob, CodegenJobGenerator, CodegenOptions, CodegenPresetOptions, NormalizedCodegenOptions, defineCodegen } from "./types.mjs";
2
+ import { Postprocessor, PostprocessorId } from "./postprocessors/types.mjs";
3
+ import { PostprocessorOptions, postprocessors } from "./postprocessors/index.mjs";
4
+ import { CodegenInput, CodegenJob, CodegenJobGenerator, CodegenOptions, CodegenPresetOptions, MaybePromise, NormalizedCodegenOptions, defineCodegen } from "./types.mjs";
3
5
  import { Codegen } from "./codegen.mjs";
4
6
  import { Plugin, codegen } from "./plugin.mjs";
5
- export { Codegen, CodegenInput, CodegenJob, CodegenJobGenerator, CodegenOptions, CodegenPresetOptions, File, NormalizedCodegenOptions, Plugin, codegen, defineCodegen };
7
+ export { Codegen, CodegenInput, CodegenJob, CodegenJobGenerator, CodegenOptions, CodegenPresetOptions, File, MaybePromise, NormalizedCodegenOptions, Plugin, type Postprocessor, type PostprocessorId, PostprocessorOptions, codegen, defineCodegen, postprocessors };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { File } from "./file.mjs";
2
+ import { postprocessors } from "./postprocessors/index.mjs";
2
3
  import { Codegen } from "./codegen.mjs";
3
4
  import { codegen } from "./plugin.mjs";
4
5
  import { defineCodegen } from "./types.mjs";
5
6
 
6
- export { Codegen, File, codegen, defineCodegen };
7
+ export { Codegen, File, codegen, defineCodegen, postprocessors };
package/dist/options.cjs CHANGED
@@ -1,17 +1,19 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
- const require_utils = require('./utils.cjs');
1
+ const require_utils = require("./utils.cjs");
2
+ const require_index = require("./postprocessors/index.cjs");
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  let node_path = require("node:path");
5
5
 
6
- //#region src/options.ts
6
+ // src/options.ts
7
7
  async function normalizeOptions(options = {}) {
8
8
  let packageJson;
9
9
  const rootDir = (0, node_path.resolve)(options.rootDir ?? process.cwd());
10
+ const cacheFile = await resolveCacheFile(rootDir, options.cacheFile);
11
+ const ppopts = {};
12
+ for (const postprocessor of require_index.postprocessors) ppopts[postprocessor.id] = options[postprocessor.id] ?? hasDevDep(await getPackageJson(), postprocessor.packageName);
10
13
  return {
11
14
  rootDir,
12
- cacheFile: await resolveCacheFile(rootDir, options.cacheFile),
13
- prettier: options.prettier ?? hasDevDep(await getPackageJson(), "prettier"),
14
- eslint: options.eslint ?? hasDevDep(await getPackageJson(), "eslint")
15
+ cacheFile,
16
+ ...ppopts
15
17
  };
16
18
  async function getPackageJson() {
17
19
  return packageJson ??= readPackageJson(rootDir);
@@ -46,6 +48,5 @@ async function readPackageJson(dir) {
46
48
  });
47
49
  }
48
50
 
49
- //#endregion
50
51
  exports.normalizeJobs = normalizeJobs;
51
52
  exports.normalizeOptions = normalizeOptions;
package/dist/options.mjs CHANGED
@@ -1,16 +1,19 @@
1
1
  import { lookupPath } from "./utils.mjs";
2
+ import { postprocessors } from "./postprocessors/index.mjs";
2
3
  import { mkdir, readFile } from "node:fs/promises";
3
4
  import { dirname, resolve } from "node:path";
4
5
 
5
- //#region src/options.ts
6
+ // src/options.ts
6
7
  async function normalizeOptions(options = {}) {
7
8
  let packageJson;
8
9
  const rootDir = resolve(options.rootDir ?? process.cwd());
10
+ const cacheFile = await resolveCacheFile(rootDir, options.cacheFile);
11
+ const ppopts = {};
12
+ for (const postprocessor of postprocessors) ppopts[postprocessor.id] = options[postprocessor.id] ?? hasDevDep(await getPackageJson(), postprocessor.packageName);
9
13
  return {
10
14
  rootDir,
11
- cacheFile: await resolveCacheFile(rootDir, options.cacheFile),
12
- prettier: options.prettier ?? hasDevDep(await getPackageJson(), "prettier"),
13
- eslint: options.eslint ?? hasDevDep(await getPackageJson(), "eslint")
15
+ cacheFile,
16
+ ...ppopts
14
17
  };
15
18
  async function getPackageJson() {
16
19
  return packageJson ??= readPackageJson(rootDir);
@@ -45,5 +48,4 @@ async function readPackageJson(dir) {
45
48
  });
46
49
  }
47
50
 
48
- //#endregion
49
51
  export { normalizeJobs, normalizeOptions };
package/dist/plugin.cjs CHANGED
@@ -1,6 +1,6 @@
1
- const require_codegen = require('./codegen.cjs');
1
+ const require_codegen = require("./codegen.cjs");
2
2
 
3
- //#region src/plugin.ts
3
+ // src/plugin.ts
4
4
  function codegen(jobOrOptions, ...moreJobs) {
5
5
  const init = require_codegen.Codegen.init(jobOrOptions, ...moreJobs);
6
6
  return {
@@ -14,5 +14,4 @@ function codegen(jobOrOptions, ...moreJobs) {
14
14
  };
15
15
  }
16
16
 
17
- //#endregion
18
17
  exports.codegen = codegen;
package/dist/plugin.d.mts CHANGED
@@ -1,13 +1,9 @@
1
1
  import { CodegenInput, CodegenOptions } from "./types.mjs";
2
-
3
- //#region src/plugin.d.ts
4
- type Plugin = {
2
+ export type Plugin = {
5
3
  name: string;
6
4
  buildStart(): Promise<void>;
7
5
  watchChange(id: string): Promise<void>;
8
6
  };
9
- declare function codegen(...jobs: CodegenInput[]): Plugin;
10
- declare function codegen(options: CodegenOptions, ...jobs: CodegenInput[]): Plugin;
11
- declare function codegen(jobOrOptions: CodegenInput | CodegenOptions, ...moreJobs: CodegenInput[]): Plugin;
12
- //#endregion
13
- export { Plugin, codegen };
7
+ export declare function codegen(...jobs: CodegenInput[]): Plugin;
8
+ export declare function codegen(options: CodegenOptions, ...jobs: CodegenInput[]): Plugin;
9
+ export declare function codegen(jobOrOptions: CodegenInput | CodegenOptions, ...moreJobs: CodegenInput[]): Plugin;
package/dist/plugin.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Codegen } from "./codegen.mjs";
2
2
 
3
- //#region src/plugin.ts
3
+ // src/plugin.ts
4
4
  function codegen(jobOrOptions, ...moreJobs) {
5
5
  const init = Codegen.init(jobOrOptions, ...moreJobs);
6
6
  return {
@@ -14,5 +14,4 @@ function codegen(jobOrOptions, ...moreJobs) {
14
14
  };
15
15
  }
16
16
 
17
- //#endregion
18
17
  export { codegen };
@@ -0,0 +1,20 @@
1
+ // src/postprocessors/eslint.ts
2
+ var ESLint = class {
3
+ id = "eslint";
4
+ packageName = "eslint";
5
+ conflicts = [];
6
+ #linter;
7
+ async apply(source, path) {
8
+ const [result] = await (await this.#getLinter()).lintText(source, { filePath: path });
9
+ return result?.output ?? source;
10
+ }
11
+ #getLinter() {
12
+ return this.#linter ??= this.#loadLinter();
13
+ }
14
+ async #loadLinter() {
15
+ const { ESLint: Linter } = await import("eslint");
16
+ return new Linter({ fix: true });
17
+ }
18
+ };
19
+
20
+ exports.ESLint = ESLint;
@@ -0,0 +1,8 @@
1
+ import { Postprocessor } from "./types.mjs";
2
+ export declare class ESLint implements Postprocessor {
3
+ #private;
4
+ readonly id = "eslint";
5
+ readonly packageName = "eslint";
6
+ readonly conflicts: never[];
7
+ apply(source: string, path: string): Promise<string>;
8
+ }
@@ -0,0 +1,20 @@
1
+ // src/postprocessors/eslint.ts
2
+ var ESLint = class {
3
+ id = "eslint";
4
+ packageName = "eslint";
5
+ conflicts = [];
6
+ #linter;
7
+ async apply(source, path) {
8
+ const [result] = await (await this.#getLinter()).lintText(source, { filePath: path });
9
+ return result?.output ?? source;
10
+ }
11
+ #getLinter() {
12
+ return this.#linter ??= this.#loadLinter();
13
+ }
14
+ async #loadLinter() {
15
+ const { ESLint: Linter } = await import("eslint");
16
+ return new Linter({ fix: true });
17
+ }
18
+ };
19
+
20
+ export { ESLint };
@@ -0,0 +1,12 @@
1
+ const require_eslint = require("./eslint.cjs");
2
+ const require_oxfmt = require("./oxfmt.cjs");
3
+ const require_prettier = require("./prettier.cjs");
4
+
5
+ // src/postprocessors/index.ts
6
+ const postprocessors = [
7
+ new require_oxfmt.Oxfmt(),
8
+ new require_eslint.ESLint(),
9
+ new require_prettier.Prettier()
10
+ ];
11
+
12
+ exports.postprocessors = postprocessors;
@@ -0,0 +1,7 @@
1
+ import { Postprocessor, PostprocessorId } from "./types.mjs";
2
+ import { ESLint } from "./eslint.mjs";
3
+ import { Oxfmt } from "./oxfmt.mjs";
4
+ import { Prettier } from "./prettier.mjs";
5
+ export declare const postprocessors: [Oxfmt, ESLint, Prettier];
6
+ export type PostprocessorOptions = Record<PostprocessorId<(typeof postprocessors)[number]>, boolean>;
7
+ export type { Postprocessor, PostprocessorId };
@@ -0,0 +1,12 @@
1
+ import { ESLint } from "./eslint.mjs";
2
+ import { Oxfmt } from "./oxfmt.mjs";
3
+ import { Prettier } from "./prettier.mjs";
4
+
5
+ // src/postprocessors/index.ts
6
+ const postprocessors = [
7
+ new Oxfmt(),
8
+ new ESLint(),
9
+ new Prettier()
10
+ ];
11
+
12
+ export { postprocessors };
@@ -0,0 +1,34 @@
1
+ const require_utils = require("../utils.cjs");
2
+ let node_fs_promises = require("node:fs/promises");
3
+ let node_path = require("node:path");
4
+
5
+ // src/postprocessors/oxfmt.ts
6
+ const candidates = [".oxfmtrc.json"];
7
+ var Oxfmt = class {
8
+ id = "oxfmt";
9
+ packageName = "oxfmt";
10
+ conflicts = ["eslint", "prettier"];
11
+ cache = /* @__PURE__ */ new Map();
12
+ async apply(source, path) {
13
+ const { format } = await import("oxfmt");
14
+ const { code, errors } = await format(path, source, await this.#resolveConfig(path));
15
+ const firstError = errors.filter((e) => e.severity === "Error").pop();
16
+ if (firstError) throw new Error(firstError.message);
17
+ return code;
18
+ }
19
+ async #resolveConfig(from) {
20
+ const dir = (0, node_path.dirname)(from);
21
+ const cached = this.cache.get(dir);
22
+ if (cached) return cached;
23
+ const { promise, resolve } = Promise.withResolvers();
24
+ this.cache.set(dir, promise);
25
+ resolve(await require_utils.lookupPath(dir, candidates, this.#loadConfig));
26
+ return promise;
27
+ }
28
+ #loadConfig = async (file) => {
29
+ const contents = await (0, node_fs_promises.readFile)(file, "utf-8");
30
+ return JSON.parse(contents);
31
+ };
32
+ };
33
+
34
+ exports.Oxfmt = Oxfmt;
@@ -0,0 +1,9 @@
1
+ import { Postprocessor } from "./types.mjs";
2
+ export declare class Oxfmt implements Postprocessor {
3
+ #private;
4
+ readonly id = "oxfmt";
5
+ readonly packageName = "oxfmt";
6
+ readonly conflicts: string[];
7
+ private cache;
8
+ apply(source: string, path: string): Promise<string>;
9
+ }
@@ -0,0 +1,34 @@
1
+ import { lookupPath } from "../utils.mjs";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname } from "node:path";
4
+
5
+ // src/postprocessors/oxfmt.ts
6
+ const candidates = [".oxfmtrc.json"];
7
+ var Oxfmt = class {
8
+ id = "oxfmt";
9
+ packageName = "oxfmt";
10
+ conflicts = ["eslint", "prettier"];
11
+ cache = /* @__PURE__ */ new Map();
12
+ async apply(source, path) {
13
+ const { format } = await import("oxfmt");
14
+ const { code, errors } = await format(path, source, await this.#resolveConfig(path));
15
+ const firstError = errors.filter((e) => e.severity === "Error").pop();
16
+ if (firstError) throw new Error(firstError.message);
17
+ return code;
18
+ }
19
+ async #resolveConfig(from) {
20
+ const dir = dirname(from);
21
+ const cached = this.cache.get(dir);
22
+ if (cached) return cached;
23
+ const { promise, resolve } = Promise.withResolvers();
24
+ this.cache.set(dir, promise);
25
+ resolve(await lookupPath(dir, candidates, this.#loadConfig));
26
+ return promise;
27
+ }
28
+ #loadConfig = async (file) => {
29
+ const contents = await readFile(file, "utf-8");
30
+ return JSON.parse(contents);
31
+ };
32
+ };
33
+
34
+ export { Oxfmt };
@@ -0,0 +1,15 @@
1
+ // src/postprocessors/prettier.ts
2
+ var Prettier = class {
3
+ id = "prettier";
4
+ packageName = "prettier";
5
+ conflicts = [];
6
+ async apply(source, path) {
7
+ const { resolveConfig, format } = await import("prettier");
8
+ return format(source, {
9
+ ...await resolveConfig(path) ?? {},
10
+ filepath: path
11
+ });
12
+ }
13
+ };
14
+
15
+ exports.Prettier = Prettier;
@@ -0,0 +1,7 @@
1
+ import { Postprocessor } from "./types.mjs";
2
+ export declare class Prettier implements Postprocessor {
3
+ readonly id = "prettier";
4
+ readonly packageName = "prettier";
5
+ readonly conflicts: never[];
6
+ apply(source: string, path: string): Promise<string>;
7
+ }
@@ -0,0 +1,15 @@
1
+ // src/postprocessors/prettier.ts
2
+ var Prettier = class {
3
+ id = "prettier";
4
+ packageName = "prettier";
5
+ conflicts = [];
6
+ async apply(source, path) {
7
+ const { resolveConfig, format } = await import("prettier");
8
+ return format(source, {
9
+ ...await resolveConfig(path) ?? {},
10
+ filepath: path
11
+ });
12
+ }
13
+ };
14
+
15
+ export { Prettier };
@@ -0,0 +1,9 @@
1
+ export interface Postprocessor {
2
+ readonly id: string;
3
+ readonly packageName: string;
4
+ readonly conflicts: string[];
5
+ apply(source: string, path: string): Promise<string> | string;
6
+ }
7
+ export type PostprocessorId<P extends Postprocessor> = P extends {
8
+ id: infer Id;
9
+ } ? Id : never;
@@ -1,8 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _graphql_codegen_cli = require("@graphql-codegen/cli");
4
3
 
5
- //#region src/presets/graphql-codegen.ts
4
+ // src/presets/graphql-codegen.ts
6
5
  function graphqlCodegen(options = {}) {
7
6
  return async () => {
8
7
  const context = await (0, _graphql_codegen_cli.createContext)({
@@ -23,7 +22,7 @@ function graphqlCodegen(options = {}) {
23
22
  input: [...normalizeDocuments(config.documents), ...Array.isArray(options) ? [] : normalizeDocuments(options.documents)],
24
23
  output,
25
24
  cacheBy: "contents",
26
- extraDeps: [context.filepath],
25
+ extraDeps: context.filepath?.length ? [context.filepath] : [],
27
26
  generate: async (files) => {
28
27
  const [generatedFile] = await (0, _graphql_codegen_cli.generate)({
29
28
  ...config,
@@ -46,5 +45,4 @@ function normalizeDocuments(documents) {
46
45
  return documents;
47
46
  }
48
47
 
49
- //#endregion
50
48
  exports.graphqlCodegen = graphqlCodegen;
@@ -1,10 +1,6 @@
1
1
  import { CodegenJob } from "../types.mjs";
2
-
3
- //#region src/presets/graphql-codegen.d.ts
4
- type GraphqlCodegenOptions = {
2
+ export type GraphqlCodegenOptions = {
5
3
  config?: string;
6
4
  project?: string;
7
5
  };
8
- declare function graphqlCodegen(options?: GraphqlCodegenOptions): () => Promise<CodegenJob[]>;
9
- //#endregion
10
- export { GraphqlCodegenOptions, graphqlCodegen };
6
+ export declare function graphqlCodegen(options?: GraphqlCodegenOptions): () => Promise<CodegenJob[]>;
@@ -1,6 +1,6 @@
1
1
  import { createContext, generate } from "@graphql-codegen/cli";
2
2
 
3
- //#region src/presets/graphql-codegen.ts
3
+ // src/presets/graphql-codegen.ts
4
4
  function graphqlCodegen(options = {}) {
5
5
  return async () => {
6
6
  const context = await createContext({
@@ -21,7 +21,7 @@ function graphqlCodegen(options = {}) {
21
21
  input: [...normalizeDocuments(config.documents), ...Array.isArray(options) ? [] : normalizeDocuments(options.documents)],
22
22
  output,
23
23
  cacheBy: "contents",
24
- extraDeps: [context.filepath],
24
+ extraDeps: context.filepath?.length ? [context.filepath] : [],
25
25
  generate: async (files) => {
26
26
  const [generatedFile] = await generate({
27
27
  ...config,
@@ -44,5 +44,4 @@ function normalizeDocuments(documents) {
44
44
  return documents;
45
45
  }
46
46
 
47
- //#endregion
48
47
  export { graphqlCodegen };
package/dist/types.cjs CHANGED
@@ -1,8 +1,6 @@
1
-
2
- //#region src/types.ts
1
+ // src/types.ts
3
2
  function defineCodegen(optionsOrJob, ...jobs) {
4
3
  return [optionsOrJob, ...jobs];
5
4
  }
6
5
 
7
- //#endregion
8
6
  exports.defineCodegen = defineCodegen;
package/dist/types.d.mts CHANGED
@@ -1,33 +1,24 @@
1
1
  import { File } from "./file.mjs";
2
-
3
- //#region src/types.d.ts
4
- type MaybePromise<T> = Promise<T> | T;
5
- type CodegenOptions = {
2
+ import { PostprocessorOptions } from "./postprocessors/index.mjs";
3
+ export type MaybePromise<T> = Promise<T> | T;
4
+ export type CodegenOptions = Partial<PostprocessorOptions> & {
6
5
  rootDir?: string;
7
6
  cacheFile?: string | false;
8
- prettier?: boolean;
9
- eslint?: boolean;
10
7
  };
11
- type NormalizedCodegenOptions = {
8
+ export type NormalizedCodegenOptions = PostprocessorOptions & {
12
9
  rootDir: string;
13
10
  cacheFile?: string;
14
- prettier: boolean;
15
- eslint: boolean;
16
11
  };
17
- type CodegenJob = {
12
+ export type CodegenJob = Partial<PostprocessorOptions> & {
18
13
  input: string | string[];
19
14
  output: string;
20
15
  generate: (files: File[], signal: AbortSignal) => MaybePromise<Buffer | string | null>;
21
16
  cacheBy?: 'files' | 'contents';
22
17
  extraDeps?: string[];
23
- prettier?: boolean;
24
- eslint?: boolean;
25
18
  };
26
- type CodegenJobGenerator = (rootDir: string) => MaybePromise<CodegenJob[] | CodegenJob>;
27
- type CodegenInput = CodegenJobGenerator | CodegenJob;
28
- type CodegenPresetOptions = Omit<CodegenJob, 'input' | 'output' | 'generate'>;
29
- declare function defineCodegen(job: CodegenInput, ...jobs: CodegenInput[]): [CodegenInput, ...CodegenInput[]];
30
- declare function defineCodegen(options: CodegenOptions, ...jobs: CodegenInput[]): [CodegenOptions, ...CodegenInput[]];
31
- declare function defineCodegen(optionsOrJob: CodegenOptions | CodegenInput, ...jobs: CodegenInput[]): [CodegenOptions | CodegenInput, ...CodegenInput[]];
32
- //#endregion
33
- export { CodegenInput, CodegenJob, CodegenJobGenerator, CodegenOptions, CodegenPresetOptions, NormalizedCodegenOptions, defineCodegen };
19
+ export type CodegenJobGenerator = (rootDir: string) => MaybePromise<CodegenJob[] | CodegenJob>;
20
+ export type CodegenInput = CodegenJobGenerator | CodegenJob;
21
+ export type CodegenPresetOptions = Omit<CodegenJob, 'input' | 'output' | 'generate'>;
22
+ export declare function defineCodegen(job: CodegenInput, ...jobs: CodegenInput[]): [CodegenInput, ...CodegenInput[]];
23
+ export declare function defineCodegen(options: CodegenOptions, ...jobs: CodegenInput[]): [CodegenOptions, ...CodegenInput[]];
24
+ export declare function defineCodegen(optionsOrJob: CodegenOptions | CodegenInput, ...jobs: CodegenInput[]): [CodegenOptions | CodegenInput, ...CodegenInput[]];
package/dist/types.mjs CHANGED
@@ -1,7 +1,6 @@
1
- //#region src/types.ts
1
+ // src/types.ts
2
2
  function defineCodegen(optionsOrJob, ...jobs) {
3
3
  return [optionsOrJob, ...jobs];
4
4
  }
5
5
 
6
- //#endregion
7
6
  export { defineCodegen };
package/dist/utils.cjs CHANGED
@@ -1,8 +1,7 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
1
  let node_path = require("node:path");
3
2
  let node_crypto = require("node:crypto");
4
3
 
5
- //#region src/utils.ts
4
+ // src/utils.ts
6
5
  async function lookupPath(dir, candidates, check) {
7
6
  if (!Array.isArray(candidates)) candidates = [candidates];
8
7
  do
@@ -26,6 +25,5 @@ function hash(data) {
26
25
  return hash.digest("hex");
27
26
  }
28
27
 
29
- //#endregion
30
28
  exports.hash = hash;
31
29
  exports.lookupPath = lookupPath;
package/dist/utils.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { dirname, resolve } from "node:path";
2
2
  import { createHash } from "node:crypto";
3
3
 
4
- //#region src/utils.ts
4
+ // src/utils.ts
5
5
  async function lookupPath(dir, candidates, check) {
6
6
  if (!Array.isArray(candidates)) candidates = [candidates];
7
7
  do
@@ -25,5 +25,4 @@ function hash(data) {
25
25
  return hash.digest("hex");
26
26
  }
27
27
 
28
- //#endregion
29
28
  export { hash, lookupPath };
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "pluggable-codegen",
3
- "version": "0.3.4",
4
- "license": "MIT",
3
+ "version": "0.5.0",
5
4
  "homepage": "https://github.com/jahudka/pluggable-codegen",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/jahudka/pluggable-codegen.git"
9
- },
10
5
  "bugs": {
11
6
  "url": "https://github.com/jahudka/pluggable-codegen/issues"
12
7
  },
8
+ "license": "MIT",
13
9
  "maintainers": [
14
10
  {
15
- "name": "Dan Kadera",
11
+ "name": "Eliška Daniela Kaderová",
16
12
  "email": "me@subsonic.cz",
17
13
  "url": "https://github.com/jahudka"
18
14
  }
19
15
  ],
20
- "files": [
21
- "dist"
22
- ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/jahudka/pluggable-codegen.git"
19
+ },
23
20
  "bin": {
24
21
  "pluggable-codegen": "dist/cli.mjs"
25
22
  },
23
+ "files": [
24
+ "dist"
25
+ ],
26
26
  "type": "module",
27
- "types": "./dist/index.d.ts",
28
27
  "main": "./dist/index.cjs",
29
28
  "module": "./dist/index.mjs",
29
+ "types": "./dist/index.d.ts",
30
30
  "exports": {
31
31
  ".": {
32
32
  "types": "./dist/index.d.ts",
@@ -40,12 +40,24 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
- "picomatch": "^4.0.4",
44
- "tinyglobby": "^0.2.16"
43
+ "picomatch": "^4.0.7",
44
+ "tinyglobby": "^0.2.17"
45
+ },
46
+ "devDependencies": {
47
+ "@graphql-codegen/cli": "^7.4.6",
48
+ "@types/node": "^24.19.2",
49
+ "@types/picomatch": "^4.0.3",
50
+ "eslint": "^10.13.0",
51
+ "oxfmt": "^0.75.0",
52
+ "oxlint": "^1.90.0",
53
+ "prettier": "^3.9.10",
54
+ "tsdown": "^0.23.2",
55
+ "typescript": "^6.0.3",
56
+ "yaml": "^2.9.1"
45
57
  },
46
58
  "peerDependencies": {
47
59
  "@graphql-codegen/cli": "^5.0.0 || ^6.0.0 || ^7.0.0",
48
- "yaml": "^2.9.0"
60
+ "yaml": "^2.9.1"
49
61
  },
50
62
  "peerDependenciesMeta": {
51
63
  "@graphql-codegen/cli": {
@@ -55,30 +67,14 @@
55
67
  "optional": true
56
68
  }
57
69
  },
58
- "devDependencies": {
59
- "@eslint/js": "^10.0.1",
60
- "@graphql-codegen/cli": "^7.0.0",
61
- "@types/node": "^22.19.19",
62
- "@types/picomatch": "^4.0.3",
63
- "eslint": "^10.4.0",
64
- "eslint-config-prettier": "^10.1.8",
65
- "eslint-plugin-simple-import-sort": "^13.0.0",
66
- "eslint-plugin-unused-imports": "^4.4.1",
67
- "globals": "^17.6.0",
68
- "prettier": "^3.8.3",
69
- "tsdown": "^0.22.0",
70
- "typescript": "^6.0.3",
71
- "typescript-eslint": "^8.59.3",
72
- "yaml": "^2.9.0"
73
- },
74
70
  "scripts": {
75
71
  "clean": "rm -rf dist",
76
- "eslint": "eslint .",
77
- "eslint:fix": "eslint --fix .",
78
- "prettier": "prettier --check .",
79
- "prettier:fix": "prettier --write .",
80
- "lint": "pnpm run '/^(eslint|prettier)$/'",
81
- "format": "pnpm run --sequential '/^(eslint|prettier):fix$/'",
72
+ "oxlint": "oxlint",
73
+ "oxlint:fix": "oxlint --fix",
74
+ "oxfmt": "oxfmt --check",
75
+ "oxfmt:fix": "oxfmt --write",
76
+ "lint": "pnpm run '/^(oxlint|oxfmt)$/'",
77
+ "format": "pnpm run --sequential '/^(oxlint|oxfmt):fix$/'",
82
78
  "build": "tsc && tsdown"
83
79
  }
84
80
  }