@baeta/plugin-gitignore 2.0.0-next.0 → 2.0.0-next.10

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 ADDED
@@ -0,0 +1,195 @@
1
+ # @baeta/plugin-gitignore
2
+
3
+ ## 2.0.0-next.10
4
+
5
+ ## 2.0.0-next.9
6
+
7
+ ### Patch Changes
8
+
9
+ - Updated dependencies [[`831cfa2`](https://github.com/andreisergiu98/baeta/commit/831cfa2a11445aaf7f2d1a1d7ddf073db9bb8008)]:
10
+ - @baeta/generator-sdk@2.0.0-next.4
11
+
12
+ ## 2.0.0-next.8
13
+
14
+ ## 2.0.0-next.7
15
+
16
+ ### Patch Changes
17
+
18
+ - [#214](https://github.com/andreisergiu98/baeta/pull/214) [`c47665a`](https://github.com/andreisergiu98/baeta/commit/c47665a76a0f88bae07f42983b380361e4f0843a) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Fix gitignore plugin not skipping files that are only generated at init
19
+
20
+ ## 2.0.0-next.3
21
+
22
+ ### Patch Changes
23
+
24
+ - Update generator-sdk package
25
+
26
+ - Updated dependencies [[`6de5d15`](https://github.com/andreisergiu98/baeta/commit/6de5d15484d341a1717a1b2f3f45272912e6a886)]:
27
+ - @baeta/generator-sdk@2.0.0-next.3
28
+
29
+ ## 2.0.0-next.2
30
+
31
+ ### Patch Changes
32
+
33
+ - Fix broken types
34
+
35
+ - Updated dependencies []:
36
+ - @baeta/generator-sdk@2.0.0-next.2
37
+
38
+ ## 2.0.0-next.1
39
+
40
+ ### Patch Changes
41
+
42
+ - Fix release version
43
+
44
+ - Updated dependencies []:
45
+ - @baeta/generator-sdk@2.0.0-next.1
46
+
47
+ ## 2.0.0-next.0
48
+
49
+ ### Major Changes
50
+
51
+ - [#214](https://github.com/andreisergiu98/baeta/pull/214) [`31d1a50`](https://github.com/andreisergiu98/baeta/commit/31d1a509f96535b43ae85d19c770eb1a5f09dc94) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Baeta v2 – major refactor
52
+ - **Side-effect-free type generation & resolver definitions.**
53
+ The types generator and resolver definitions were reworked to be side-effect free, improving type safety.
54
+ - **Stricter type safety.**
55
+ You must now **explicitly define resolvers for every field** during development—breakages that used to surface at runtime are now caught at compile time.
56
+ - **Removed `@baeta/compiler`.**
57
+ Since modern runtimes can execute TypeScript natively, the separate compiler package is no longer needed. Use your runtime’s native TS support or your existing build setup.
58
+ - **Subscriptions update.**
59
+ `@baeta/subscriptions-pubsub` now targets **`graphql-subscriptions` v3**.
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies [[`31d1a50`](https://github.com/andreisergiu98/baeta/commit/31d1a509f96535b43ae85d19c770eb1a5f09dc94)]:
64
+ - @baeta/generator-sdk@2.0.0-next.0
65
+
66
+ ## 1.0.11
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [[`7cbd2ef`](https://github.com/andreisergiu98/baeta/commit/7cbd2ef5b7697f703e4cc6f8d9612c7d01a10dd1), [`c7b9c05`](https://github.com/andreisergiu98/baeta/commit/c7b9c0523eb9827c99b2bcfc7dbe02f5ef389f21)]:
71
+ - @baeta/generator-sdk@1.0.2
72
+
73
+ ## 1.0.9
74
+
75
+ ### Patch Changes
76
+
77
+ - [`583014f`](https://github.com/andreisergiu98/baeta/commit/583014f0bac810b25d9a8226bda2df4c9039f5e3) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Update dependencies
78
+
79
+ - Updated dependencies [[`583014f`](https://github.com/andreisergiu98/baeta/commit/583014f0bac810b25d9a8226bda2df4c9039f5e3)]:
80
+ - @baeta/generator-sdk@1.0.1
81
+
82
+ ## 1.0.8
83
+
84
+ ### Patch Changes
85
+
86
+ - [#189](https://github.com/andreisergiu98/baeta/pull/189) [`d500378`](https://github.com/andreisergiu98/baeta/commit/d500378198e0a9c48298c4242913bca8ad348228) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add jsdocs
87
+
88
+ - [#165](https://github.com/andreisergiu98/baeta/pull/165) [`1334c2a`](https://github.com/andreisergiu98/baeta/commit/1334c2a866676c88f0f3d380b22133d81c4e98bc) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - mark as stable
89
+
90
+ - Updated dependencies [[`d500378`](https://github.com/andreisergiu98/baeta/commit/d500378198e0a9c48298c4242913bca8ad348228), [`1334c2a`](https://github.com/andreisergiu98/baeta/commit/1334c2a866676c88f0f3d380b22133d81c4e98bc)]:
91
+ - @baeta/generator-sdk@1.0.0
92
+
93
+ ## 0.1.5
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [[`bf2d1a3`](https://github.com/andreisergiu98/baeta/commit/bf2d1a326235e5f34e723a5acc81cd7b974b913b)]:
98
+ - @baeta/generator-sdk@0.1.5
99
+
100
+ ## 0.1.4
101
+
102
+ ### Patch Changes
103
+
104
+ - [`b59db50`](https://github.com/andreisergiu98/baeta/commit/b59db501a83275ab2d964933080e688a3a5d8820) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add readme
105
+
106
+ - Updated dependencies [[`b59db50`](https://github.com/andreisergiu98/baeta/commit/b59db501a83275ab2d964933080e688a3a5d8820)]:
107
+ - @baeta/generator-sdk@0.1.4
108
+
109
+ ## 0.1.3
110
+
111
+ ### Patch Changes
112
+
113
+ - [#180](https://github.com/andreisergiu98/baeta/pull/180) [`483c709`](https://github.com/andreisergiu98/baeta/commit/483c70932f815fd114732c00b74f9488d7924c72) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Raise minimum required NodeJS version to 22.12.0. Drop CommonJS builds in favor of the require_esm feature from NodeJS 22.12.0 onwards.
114
+
115
+ - [`de6e89c`](https://github.com/andreisergiu98/baeta/commit/de6e89c1b592e280967c73a4137d24ee56ef1857) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - raise es target to 2024
116
+
117
+ - Updated dependencies [[`483c709`](https://github.com/andreisergiu98/baeta/commit/483c70932f815fd114732c00b74f9488d7924c72), [`de6e89c`](https://github.com/andreisergiu98/baeta/commit/de6e89c1b592e280967c73a4137d24ee56ef1857)]:
118
+ - @baeta/generator-sdk@0.1.3
119
+
120
+ ## 0.1.2
121
+
122
+ ### Patch Changes
123
+
124
+ - [#170](https://github.com/andreisergiu98/baeta/pull/170) [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
125
+
126
+ - Updated dependencies [[`e3fb6f8`](https://github.com/andreisergiu98/baeta/commit/e3fb6f877b4b20e248ad79cbaa3655cabe973f6b), [`59bbb9c`](https://github.com/andreisergiu98/baeta/commit/59bbb9c4baaf716f27dc251fe7aeb0231e6c5321)]:
127
+ - @baeta/generator-sdk@0.1.2
128
+
129
+ ## 0.1.1
130
+
131
+ ### Patch Changes
132
+
133
+ - [`a3f0e5d`](https://github.com/andreisergiu98/baeta/commit/a3f0e5d03fc9ef21a87d3ec6bf264d0e9707636a) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - fix exports order in package.json
134
+
135
+ - [#161](https://github.com/andreisergiu98/baeta/pull/161) [`cca37dd`](https://github.com/andreisergiu98/baeta/commit/cca37dd7135a2852f1f6e287c46911306bdc8da0) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
136
+
137
+ - Updated dependencies [[`7f1958c`](https://github.com/andreisergiu98/baeta/commit/7f1958c44d1b9bed473e48c875fdaa7020c434fa), [`b9638eb`](https://github.com/andreisergiu98/baeta/commit/b9638eb9fb713507efa9821b4f04cc7896a997b1), [`fd3a5d2`](https://github.com/andreisergiu98/baeta/commit/fd3a5d27b497aca4b8807155e801b1c1197c5fe2), [`9d8d6a1`](https://github.com/andreisergiu98/baeta/commit/9d8d6a15d63579a2e0bdaa07b7efdcf10aff2492), [`a3f0e5d`](https://github.com/andreisergiu98/baeta/commit/a3f0e5d03fc9ef21a87d3ec6bf264d0e9707636a), [`cca37dd`](https://github.com/andreisergiu98/baeta/commit/cca37dd7135a2852f1f6e287c46911306bdc8da0)]:
138
+ - @baeta/generator-sdk@0.1.1
139
+
140
+ ## 0.1.0
141
+
142
+ ### Minor Changes
143
+
144
+ - [#156](https://github.com/andreisergiu98/baeta/pull/156) [`01f3c20`](https://github.com/andreisergiu98/baeta/commit/01f3c20365539fad6e8a8694c59a8e86c95784e8) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - raise engine requirement to node >= 22
145
+
146
+ ### Patch Changes
147
+
148
+ - [#152](https://github.com/andreisergiu98/baeta/pull/152) [`d538c79`](https://github.com/andreisergiu98/baeta/commit/d538c7905e6ba96d9f294e2d528f9252e83acbe7) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update formatter
149
+
150
+ - [#145](https://github.com/andreisergiu98/baeta/pull/145) [`08428d4`](https://github.com/andreisergiu98/baeta/commit/08428d4f03b79cab9c116ff7b3a3cf9a0b2620f2) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
151
+
152
+ - Updated dependencies [[`01f3c20`](https://github.com/andreisergiu98/baeta/commit/01f3c20365539fad6e8a8694c59a8e86c95784e8), [`d538c79`](https://github.com/andreisergiu98/baeta/commit/d538c7905e6ba96d9f294e2d528f9252e83acbe7), [`08428d4`](https://github.com/andreisergiu98/baeta/commit/08428d4f03b79cab9c116ff7b3a3cf9a0b2620f2)]:
153
+ - @baeta/generator-sdk@0.1.0
154
+
155
+ ## 0.0.5
156
+
157
+ ### Patch Changes
158
+
159
+ - [#139](https://github.com/andreisergiu98/baeta/pull/139) [`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
160
+
161
+ - [#139](https://github.com/andreisergiu98/baeta/pull/139) [`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update typescript
162
+
163
+ - Updated dependencies [[`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4), [`00dbc8f`](https://github.com/andreisergiu98/baeta/commit/00dbc8f35839aaa6524a6c0125ff38a766e45be4)]:
164
+ - @baeta/generator-sdk@0.0.14
165
+
166
+ ## 0.0.4
167
+
168
+ ### Patch Changes
169
+
170
+ - [#128](https://github.com/andreisergiu98/baeta/pull/128) [`534917a`](https://github.com/andreisergiu98/baeta/commit/534917a18e7ed5d788a90a0335a5370d6af8f4a4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
171
+
172
+ - Updated dependencies [[`534917a`](https://github.com/andreisergiu98/baeta/commit/534917a18e7ed5d788a90a0335a5370d6af8f4a4)]:
173
+ - @baeta/generator-sdk@0.0.13
174
+
175
+ ## 0.0.3
176
+
177
+ ### Patch Changes
178
+
179
+ - [#121](https://github.com/andreisergiu98/baeta/pull/121) [`ceae50d`](https://github.com/andreisergiu98/baeta/commit/ceae50d88e4e59b22c603637620f4fc6b28b2454) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - Update Node to v20
180
+
181
+ - [#51](https://github.com/andreisergiu98/baeta/pull/51) [`d94ee47`](https://github.com/andreisergiu98/baeta/commit/d94ee47bc485c541ff011290c4ac6ef0c145c83f) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - add native support for file monifications
182
+
183
+ - Updated dependencies [[`ceae50d`](https://github.com/andreisergiu98/baeta/commit/ceae50d88e4e59b22c603637620f4fc6b28b2454), [`d94ee47`](https://github.com/andreisergiu98/baeta/commit/d94ee47bc485c541ff011290c4ac6ef0c145c83f)]:
184
+ - @baeta/generator-sdk@0.0.12
185
+
186
+ ## 0.0.2
187
+
188
+ ### Patch Changes
189
+
190
+ - [#117](https://github.com/andreisergiu98/baeta/pull/117) [`18db339`](https://github.com/andreisergiu98/baeta/commit/18db339719aa309c619372d2161c5fdbc08fa316) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - create gitignore plugin
191
+
192
+ - [#119](https://github.com/andreisergiu98/baeta/pull/119) [`643a2eb`](https://github.com/andreisergiu98/baeta/commit/643a2eb17c2789cd25361ddeede149a0e459e68a) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
193
+
194
+ - Updated dependencies [[`18db339`](https://github.com/andreisergiu98/baeta/commit/18db339719aa309c619372d2161c5fdbc08fa316), [`643a2eb`](https://github.com/andreisergiu98/baeta/commit/643a2eb17c2789cd25361ddeede149a0e459e68a)]:
195
+ - @baeta/generator-sdk@0.0.11
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <div align="center">
6
6
  <h1>Baeta</h1>
7
7
  <a href="https://www.npmjs.com/package/@baeta/cli"><img src="https://img.shields.io/npm/v/@baeta/cli.svg?style=flat" /></a>
8
- <a href="https://github.com/andreisergiu98/baeta/actions/workflows/testing.yml"><img src="https://img.shields.io/github/actions/workflow/status/andreisergiu98/baeta/testing.yml" /></a>
8
+ <a href="https://github.com/andreisergiu98/baeta/actions/workflows/checks.yml"><img src="https://img.shields.io/github/actions/workflow/status/andreisergiu98/baeta/checks.yml" /></a>
9
9
  <a href="https://github.com/andreisergiu98/baeta/pulls"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" /></a>
10
10
  <a href="https://github.com/andreisergiu98/baeta/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" /></a>
11
11
  <br />
@@ -77,43 +77,68 @@ type Query {
77
77
  #### 2. Implement your resolvers
78
78
 
79
79
  ```typescript
80
- import { getUserModule } from "./typedef";
80
+ import { UserModule } from "./typedef.ts";
81
81
 
82
- const { Query } = getUserModule();
82
+ const { Query } = UserModule;
83
83
 
84
- Query.user(({ args }) => {
84
+ const userQuery = Query.user.resolve(({ args }) => {
85
85
  return dataSource.user.find(args.where);
86
86
  });
87
87
 
88
- Query.users(() => {
88
+ const usersQuery = Query.users.resolve(() => {
89
89
  return dataSource.user.findMany();
90
90
  });
91
+
92
+ Query.$fields({
93
+ user: userQuery,
94
+ users: usersQuery,
95
+ });
91
96
  ```
92
97
 
93
98
  #### 3. Add authorization
94
99
 
95
100
  ```typescript
96
- const { Query, Mutation } = getUserModule();
97
-
98
- Query.users.$auth({
99
- $or: {
100
- isPublic: true,
101
- isLoggedIn: true,
102
- },
103
- });
101
+ import { UserModule } from "./typedef.ts";
102
+
103
+ const { Query } = UserModule;
104
+
105
+ const userQuery = Query.user
106
+ .$auth({
107
+ $or: {
108
+ isPublic: true,
109
+ isLoggedIn: true,
110
+ },
111
+ })
112
+ .resolve(async ({ args }) => {
113
+ // ...
114
+ });
104
115
  ```
105
116
 
106
117
  #### 4. Add caching
107
118
 
108
119
  ```typescript
109
- import { getUserModule } from "./typedef";
110
-
111
- const { User, Query } = getUserModule();
120
+ const { Query, Mutation, User } = UserModule;
112
121
 
113
122
  export const userCache = User.$createCache();
114
123
 
115
- Query.user.$useCache(userCache);
116
- Query.users.$useCache(userCache);
124
+ const userQuery = Query.user
125
+ .$auth({
126
+ // ...
127
+ })
128
+ .$useCache(userCache)
129
+ .resolve(async ({ args }) => {
130
+ // ...
131
+ });
132
+
133
+ const updateUserMutation = Mutation.updateUser
134
+ .$use(async (next) => {
135
+ const user = await next();
136
+ await userCache.save(user);
137
+ return user;
138
+ })
139
+ .resolve(async ({ args }) => {
140
+ // ...
141
+ });
117
142
  ```
118
143
 
119
144
  ## Compatibility
@@ -0,0 +1,31 @@
1
+ import * as _baeta_generator_sdk0 from "@baeta/generator-sdk";
2
+
3
+ //#region index.d.ts
4
+ /**
5
+ * Configuration options for the gitignore plugin.
6
+ */
7
+ interface GitignoreOptions {
8
+ /**
9
+ * Array of file tags to exclude from .gitignore.
10
+ * File tags are identifiers assigned to generated files
11
+ * to categorize them by their plugin or purpose.
12
+ */
13
+ skipTags?: string[];
14
+ /**
15
+ * Array of files to exclude from .gitignore.
16
+ */
17
+ skipFilesGlobs?: string[];
18
+ }
19
+ interface GitignoreOptions {
20
+ skipTags?: string[];
21
+ }
22
+ /**
23
+ * A plugin that adds .gitignore entries for generated files.
24
+ *
25
+ * @param options - Plugin configuration options
26
+ * @returns A Baeta generator plugin
27
+ */
28
+ declare function gitignorePlugin(options?: GitignoreOptions): _baeta_generator_sdk0.GeneratorPluginV1<unknown>;
29
+ //#endregion
30
+ export { GitignoreOptions, gitignorePlugin };
31
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,39 +1,37 @@
1
- // index.ts
2
- import { relative, resolve } from "path";
3
- import { createPluginV1, FileBlock } from "@baeta/generator-sdk";
4
- var defaultIgnoredTags = ["cloudflare"];
1
+ import { relative, resolve } from "node:path";
2
+ import { FileBlock, createPluginV1, micromatch } from "@baeta/generator-sdk";
3
+
4
+ //#region index.ts
5
+ const defaultSkipTags = ["cloudflare"];
6
+ /**
7
+ * A plugin that adds .gitignore entries for generated files.
8
+ *
9
+ * @param options - Plugin configuration options
10
+ * @returns A Baeta generator plugin
11
+ */
5
12
  function gitignorePlugin(options) {
6
- return createPluginV1({
7
- name: "gitignore-plugin",
8
- actionName: "add generated files to .gitignore",
9
- generate: async (ctx, next) => {
10
- await next();
11
- const ignoredTags = [...options?.ignoreTags ?? [], ...defaultIgnoredTags];
12
- const modulesDir = ctx.generatorOptions.modulesDir;
13
- const moduleDefinitionName = ctx.generatorOptions.moduleDefinitionName;
14
- const filePaths = ctx.fileManager.files.filter((file2) => {
15
- return !file2.filename.endsWith(moduleDefinitionName) && !ignoredTags.includes(file2.tag);
16
- }).map((file2) => file2.filename);
17
- const generatedPaths = filePaths.map((file2) => relative(ctx.generatorOptions.cwd, file2)).filter((file2) => !file2.endsWith(moduleDefinitionName));
18
- generatedPaths.push(
19
- `${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`
20
- );
21
- generatedPaths.sort((a, b) => a.localeCompare(b));
22
- const gitignoreStart = "# Generated by Baeta - Begin";
23
- const gitignoreInner = generatedPaths.join("\n");
24
- const gitignoreEnd = "# Generated by Baeta - End";
25
- const file = new FileBlock(
26
- resolve(ctx.generatorOptions.cwd, ".gitignore"),
27
- gitignoreInner,
28
- gitignoreStart,
29
- gitignoreEnd,
30
- "gitignore"
31
- );
32
- ctx.fileManager.add(file);
33
- }
34
- });
13
+ return createPluginV1({
14
+ name: "gitignore-plugin",
15
+ actionName: "add generated files to .gitignore",
16
+ generate: async (ctx, next) => {
17
+ await next();
18
+ const modulesDir = ctx.generatorOptions.modulesDir;
19
+ const moduleDefinitionName = ctx.generatorOptions.moduleDefinitionName;
20
+ const skipedTags = new Set([...options?.skipTags ?? [], ...defaultSkipTags]);
21
+ const skippedFilesGlobs = [...(options?.skipFilesGlobs ?? []).map((glob) => resolve(ctx.generatorOptions.cwd, glob))];
22
+ const generatedPaths = ctx.fileManager.files.filter((file$1) => {
23
+ return !file$1.filename.endsWith(moduleDefinitionName) && !skipedTags.has(file$1.tag) && !skippedFilesGlobs.some((skippedFile) => micromatch.isMatch(file$1.filename, skippedFile)) && file$1.options?.disableOverwrite !== true;
24
+ }).map((file$1) => file$1.filename).map((file$1) => relative(ctx.generatorOptions.cwd, file$1)).filter((file$1) => !file$1.endsWith(moduleDefinitionName));
25
+ if (!skippedFilesGlobs.some((skippedFile) => micromatch.isMatch(`${modulesDir}/**/${moduleDefinitionName}`, skippedFile))) generatedPaths.push(`${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`);
26
+ generatedPaths.sort((a, b) => a.localeCompare(b));
27
+ const gitignoreStart = "# Generated by Baeta - Begin";
28
+ const gitignoreInner = generatedPaths.join("\n");
29
+ const file = new FileBlock(resolve(ctx.generatorOptions.cwd, ".gitignore"), gitignoreInner, gitignoreStart, "# Generated by Baeta - End", "gitignore");
30
+ ctx.fileManager.add(file);
31
+ }
32
+ });
35
33
  }
36
- export {
37
- gitignorePlugin
38
- };
34
+
35
+ //#endregion
36
+ export { gitignorePlugin };
39
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts"],"sourcesContent":["import { relative, resolve } from 'node:path';\nimport { createPluginV1, FileBlock } from '@baeta/generator-sdk';\n\n/**\n * Configuration options for the gitignore plugin.\n */\nexport interface GitignoreOptions {\n\t/**\n\t * Array of file tags to exclude from .gitignore.\n\t * File tags are identifiers assigned to generated files\n\t * to categorize them by their plugin or purpose.\n\t */\n\tignoreTags?: string[];\n}\nexport interface GitignoreOptions {\n\tignoreTags?: string[];\n}\n\nconst defaultIgnoredTags = ['cloudflare'];\n\n/**\n * A plugin that adds .gitignore entries for generated files.\n *\n * @param options - Plugin configuration options\n * @returns A Baeta generator plugin\n */\nexport function gitignorePlugin(options?: GitignoreOptions) {\n\treturn createPluginV1({\n\t\tname: 'gitignore-plugin',\n\t\tactionName: 'add generated files to .gitignore',\n\t\tgenerate: async (ctx, next) => {\n\t\t\tawait next();\n\n\t\t\tconst ignoredTags = [...(options?.ignoreTags ?? []), ...defaultIgnoredTags];\n\n\t\t\tconst modulesDir = ctx.generatorOptions.modulesDir;\n\t\t\tconst moduleDefinitionName = ctx.generatorOptions.moduleDefinitionName;\n\n\t\t\tconst filePaths = ctx.fileManager.files\n\t\t\t\t.filter((file) => {\n\t\t\t\t\treturn !file.filename.endsWith(moduleDefinitionName) && !ignoredTags.includes(file.tag);\n\t\t\t\t})\n\t\t\t\t.map((file) => file.filename);\n\n\t\t\tconst generatedPaths = filePaths\n\t\t\t\t.map((file) => relative(ctx.generatorOptions.cwd, file))\n\t\t\t\t.filter((file) => !file.endsWith(moduleDefinitionName));\n\n\t\t\tgeneratedPaths.push(\n\t\t\t\t`${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`,\n\t\t\t);\n\n\t\t\tgeneratedPaths.sort((a, b) => a.localeCompare(b));\n\n\t\t\tconst gitignoreStart = '# Generated by Baeta - Begin';\n\t\t\tconst gitignoreInner = generatedPaths.join('\\n');\n\t\t\tconst gitignoreEnd = '# Generated by Baeta - End';\n\n\t\t\tconst file = new FileBlock(\n\t\t\t\tresolve(ctx.generatorOptions.cwd, '.gitignore'),\n\t\t\t\tgitignoreInner,\n\t\t\t\tgitignoreStart,\n\t\t\t\tgitignoreEnd,\n\t\t\t\t'gitignore',\n\t\t\t);\n\n\t\t\tctx.fileManager.add(file);\n\t\t},\n\t});\n}\n"],"mappings":";AAAA,SAAS,UAAU,eAAe;AAClC,SAAS,gBAAgB,iBAAiB;AAiB1C,IAAM,qBAAqB,CAAC,YAAY;AAQjC,SAAS,gBAAgB,SAA4B;AAC3D,SAAO,eAAe;AAAA,IACrB,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,UAAU,OAAO,KAAK,SAAS;AAC9B,YAAM,KAAK;AAEX,YAAM,cAAc,CAAC,GAAI,SAAS,cAAc,CAAC,GAAI,GAAG,kBAAkB;AAE1E,YAAM,aAAa,IAAI,iBAAiB;AACxC,YAAM,uBAAuB,IAAI,iBAAiB;AAElD,YAAM,YAAY,IAAI,YAAY,MAChC,OAAO,CAACA,UAAS;AACjB,eAAO,CAACA,MAAK,SAAS,SAAS,oBAAoB,KAAK,CAAC,YAAY,SAASA,MAAK,GAAG;AAAA,MACvF,CAAC,EACA,IAAI,CAACA,UAASA,MAAK,QAAQ;AAE7B,YAAM,iBAAiB,UACrB,IAAI,CAACA,UAAS,SAAS,IAAI,iBAAiB,KAAKA,KAAI,CAAC,EACtD,OAAO,CAACA,UAAS,CAACA,MAAK,SAAS,oBAAoB,CAAC;AAEvD,qBAAe;AAAA,QACd,GAAG,SAAS,IAAI,iBAAiB,KAAK,UAAU,CAAC,OAAO,oBAAoB;AAAA,MAC7E;AAEA,qBAAe,KAAK,CAAC,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;AAEhD,YAAM,iBAAiB;AACvB,YAAM,iBAAiB,eAAe,KAAK,IAAI;AAC/C,YAAM,eAAe;AAErB,YAAM,OAAO,IAAI;AAAA,QAChB,QAAQ,IAAI,iBAAiB,KAAK,YAAY;AAAA,QAC9C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAEA,UAAI,YAAY,IAAI,IAAI;AAAA,IACzB;AAAA,EACD,CAAC;AACF;","names":["file"]}
1
+ {"version":3,"file":"index.js","names":["file"],"sources":["../index.ts"],"sourcesContent":["import { relative, resolve } from 'node:path';\nimport { createPluginV1, FileBlock, micromatch } from '@baeta/generator-sdk';\n\n/**\n * Configuration options for the gitignore plugin.\n */\nexport interface GitignoreOptions {\n\t/**\n\t * Array of file tags to exclude from .gitignore.\n\t * File tags are identifiers assigned to generated files\n\t * to categorize them by their plugin or purpose.\n\t */\n\tskipTags?: string[];\n\n\t/**\n\t * Array of files to exclude from .gitignore.\n\t */\n\tskipFilesGlobs?: string[];\n}\nexport interface GitignoreOptions {\n\tskipTags?: string[];\n}\n\nconst defaultSkipTags = ['cloudflare'];\n\n/**\n * A plugin that adds .gitignore entries for generated files.\n *\n * @param options - Plugin configuration options\n * @returns A Baeta generator plugin\n */\nexport function gitignorePlugin(options?: GitignoreOptions) {\n\treturn createPluginV1({\n\t\tname: 'gitignore-plugin',\n\t\tactionName: 'add generated files to .gitignore',\n\t\tgenerate: async (ctx, next) => {\n\t\t\tawait next();\n\n\t\t\tconst modulesDir = ctx.generatorOptions.modulesDir;\n\t\t\tconst moduleDefinitionName = ctx.generatorOptions.moduleDefinitionName;\n\n\t\t\tconst skipedTags = new Set([...(options?.skipTags ?? []), ...defaultSkipTags]);\n\t\t\tconst skippedFilesGlobs = [\n\t\t\t\t...(options?.skipFilesGlobs ?? []).map((glob) => resolve(ctx.generatorOptions.cwd, glob)),\n\t\t\t];\n\n\t\t\tconst filePaths = ctx.fileManager.files\n\t\t\t\t.filter((file) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!file.filename.endsWith(moduleDefinitionName) &&\n\t\t\t\t\t\t!skipedTags.has(file.tag) &&\n\t\t\t\t\t\t!skippedFilesGlobs.some((skippedFile) =>\n\t\t\t\t\t\t\tmicromatch.isMatch(file.filename, skippedFile),\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tfile.options?.disableOverwrite !== true\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t\t.map((file) => file.filename);\n\n\t\t\tconst generatedPaths = filePaths\n\t\t\t\t.map((file) => relative(ctx.generatorOptions.cwd, file))\n\t\t\t\t.filter((file) => !file.endsWith(moduleDefinitionName));\n\n\t\t\tif (\n\t\t\t\t!skippedFilesGlobs.some((skippedFile) =>\n\t\t\t\t\tmicromatch.isMatch(`${modulesDir}/**/${moduleDefinitionName}`, skippedFile),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tgeneratedPaths.push(\n\t\t\t\t\t`${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tgeneratedPaths.sort((a, b) => a.localeCompare(b));\n\n\t\t\tconst gitignoreStart = '# Generated by Baeta - Begin';\n\t\t\tconst gitignoreInner = generatedPaths.join('\\n');\n\t\t\tconst gitignoreEnd = '# Generated by Baeta - End';\n\n\t\t\tconst file = new FileBlock(\n\t\t\t\tresolve(ctx.generatorOptions.cwd, '.gitignore'),\n\t\t\t\tgitignoreInner,\n\t\t\t\tgitignoreStart,\n\t\t\t\tgitignoreEnd,\n\t\t\t\t'gitignore',\n\t\t\t);\n\n\t\t\tctx.fileManager.add(file);\n\t\t},\n\t});\n}\n"],"mappings":";;;;AAuBA,MAAM,kBAAkB,CAAC,aAAa;;;;;;;AAQtC,SAAgB,gBAAgB,SAA4B;AAC3D,QAAO,eAAe;EACrB,MAAM;EACN,YAAY;EACZ,UAAU,OAAO,KAAK,SAAS;AAC9B,SAAM,MAAM;GAEZ,MAAM,aAAa,IAAI,iBAAiB;GACxC,MAAM,uBAAuB,IAAI,iBAAiB;GAElD,MAAM,aAAa,IAAI,IAAI,CAAC,GAAI,SAAS,YAAY,EAAE,EAAG,GAAG,gBAAgB,CAAC;GAC9E,MAAM,oBAAoB,CACzB,IAAI,SAAS,kBAAkB,EAAE,EAAE,KAAK,SAAS,QAAQ,IAAI,iBAAiB,KAAK,KAAK,CAAC,CACzF;GAeD,MAAM,iBAbY,IAAI,YAAY,MAChC,QAAQ,WAAS;AACjB,WACC,CAACA,OAAK,SAAS,SAAS,qBAAqB,IAC7C,CAAC,WAAW,IAAIA,OAAK,IAAI,IACzB,CAAC,kBAAkB,MAAM,gBACxB,WAAW,QAAQA,OAAK,UAAU,YAAY,CAC9C,IACDA,OAAK,SAAS,qBAAqB;KAEnC,CACD,KAAK,WAASA,OAAK,SAAS,CAG5B,KAAK,WAAS,SAAS,IAAI,iBAAiB,KAAKA,OAAK,CAAC,CACvD,QAAQ,WAAS,CAACA,OAAK,SAAS,qBAAqB,CAAC;AAExD,OACC,CAAC,kBAAkB,MAAM,gBACxB,WAAW,QAAQ,GAAG,WAAW,MAAM,wBAAwB,YAAY,CAC3E,CAED,gBAAe,KACd,GAAG,SAAS,IAAI,iBAAiB,KAAK,WAAW,CAAC,MAAM,uBACxD;AAGF,kBAAe,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC;GAEjD,MAAM,iBAAiB;GACvB,MAAM,iBAAiB,eAAe,KAAK,KAAK;GAGhD,MAAM,OAAO,IAAI,UAChB,QAAQ,IAAI,iBAAiB,KAAK,aAAa,EAC/C,gBACA,gBALoB,8BAOpB,YACA;AAED,OAAI,YAAY,IAAI,KAAK;;EAE1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baeta/plugin-gitignore",
3
- "version": "2.0.0-next.0",
3
+ "version": "2.0.0-next.10",
4
4
  "keywords": [
5
5
  "baeta",
6
6
  "graphql",
@@ -27,8 +27,8 @@
27
27
  "type": "module",
28
28
  "exports": {
29
29
  ".": {
30
- "types": "./index.ts",
31
- "default": "./index.ts"
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
32
  }
33
33
  },
34
34
  "types": "dist/index.d.ts",
@@ -37,18 +37,26 @@
37
37
  "package.json"
38
38
  ],
39
39
  "scripts": {
40
- "build": "tsup",
41
- "prepack": "prep",
42
- "postpack": "prep --clean",
40
+ "build": "builder build",
41
+ "prepack": "builder prepare",
42
+ "postpack": "builder prepare --clean",
43
+ "test": "builder test",
44
+ "test:circular": "builder test-circular",
43
45
  "types": "tsc --noEmit"
44
46
  },
47
+ "ava": {
48
+ "extensions": {
49
+ "ts": "module"
50
+ }
51
+ },
45
52
  "dependencies": {
46
- "@baeta/generator-sdk": "workspace:^"
53
+ "@baeta/generator-sdk": "^2.0.0-next.4"
47
54
  },
48
55
  "devDependencies": {
49
- "@baeta/builder": "workspace:^",
50
- "@baeta/tsconfig": "workspace:^",
51
- "@types/node": "^22.18.11",
56
+ "@baeta/builder": "^0.0.0",
57
+ "@baeta/testing": "^0.0.0",
58
+ "@baeta/tsconfig": "^0.0.0",
59
+ "@types/node": "^22.19.1",
52
60
  "typescript": "^5.9.3"
53
61
  },
54
62
  "engines": {
@@ -76,4 +84,4 @@
76
84
  "alphabetical-ignoring-documents"
77
85
  ]
78
86
  }
79
- }
87
+ }