@baeta/plugin-gitignore 2.0.0-next.2 → 2.0.0-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @baeta/plugin-gitignore
2
2
 
3
+ ## 2.0.0-next.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
9
+ ## 2.0.0-next.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Update generator-sdk package
14
+
15
+ - Updated dependencies [[`6de5d15`](https://github.com/andreisergiu98/baeta/commit/6de5d15484d341a1717a1b2f3f45272912e6a886)]:
16
+ - @baeta/generator-sdk@2.0.0-next.3
17
+
3
18
  ## 2.0.0-next.2
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -77,43 +77,68 @@ type Query {
77
77
  #### 2. Implement your resolvers
78
78
 
79
79
  ```typescript
80
- import { getUserModule } from "./typedef";
80
+ import { UserModule } from "./typedef.ts";
81
81
 
82
- const { Query } = getUserModule();
82
+ const { Query } = UserModule;
83
83
 
84
- Query.user(({ args }) => {
84
+ const userQuery = Query.user.resolve(({ args }) => {
85
85
  return dataSource.user.find(args.where);
86
86
  });
87
87
 
88
- Query.users(() => {
88
+ const usersQuery = Query.users.resolve(() => {
89
89
  return dataSource.user.findMany();
90
90
  });
91
+
92
+ Query.$fields({
93
+ user: userQuery,
94
+ users: usersQuery,
95
+ });
91
96
  ```
92
97
 
93
98
  #### 3. Add authorization
94
99
 
95
100
  ```typescript
96
- const { Query, Mutation } = getUserModule();
97
-
98
- Query.users.$auth({
99
- $or: {
100
- isPublic: true,
101
- isLoggedIn: true,
102
- },
103
- });
101
+ import { UserModule } from "./typedef.ts";
102
+
103
+ const { Query } = UserModule;
104
+
105
+ const userQuery = Query.user
106
+ .auth({
107
+ $or: {
108
+ isPublic: true,
109
+ isLoggedIn: true,
110
+ },
111
+ })
112
+ .resolve(async ({ args }) => {
113
+ // ...
114
+ });
104
115
  ```
105
116
 
106
117
  #### 4. Add caching
107
118
 
108
119
  ```typescript
109
- import { getUserModule } from "./typedef";
110
-
111
- const { User, Query } = getUserModule();
120
+ const { Query, Mutation, User } = UserModule;
112
121
 
113
122
  export const userCache = User.$createCache();
114
123
 
115
- Query.user.$useCache(userCache);
116
- Query.users.$useCache(userCache);
124
+ const userQuery = Query.user
125
+ .auth({
126
+ // ...
127
+ })
128
+ .useCache(userCache)
129
+ .resolve(async ({ args }) => {
130
+ // ...
131
+ });
132
+
133
+ const updateUserMutation = Mutation.updateUser
134
+ .$use(async (next) => {
135
+ const user = await next();
136
+ await userCache.save(user);
137
+ return user;
138
+ })
139
+ .resolve(async ({ args }) => {
140
+ // ...
141
+ });
117
142
  ```
118
143
 
119
144
  ## Compatibility
package/dist/index.d.ts CHANGED
@@ -1,18 +1,23 @@
1
- import * as _baeta_generator_sdk from '@baeta/generator-sdk';
1
+ import * as _baeta_generator_sdk0 from "@baeta/generator-sdk";
2
2
 
3
+ //#region index.d.ts
3
4
  /**
4
5
  * Configuration options for the gitignore plugin.
5
6
  */
6
7
  interface GitignoreOptions {
7
- /**
8
- * Array of file tags to exclude from .gitignore.
9
- * File tags are identifiers assigned to generated files
10
- * to categorize them by their plugin or purpose.
11
- */
12
- ignoreTags?: string[];
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[];
13
18
  }
14
19
  interface GitignoreOptions {
15
- ignoreTags?: string[];
20
+ skipTags?: string[];
16
21
  }
17
22
  /**
18
23
  * A plugin that adds .gitignore entries for generated files.
@@ -20,6 +25,7 @@ interface GitignoreOptions {
20
25
  * @param options - Plugin configuration options
21
26
  * @returns A Baeta generator plugin
22
27
  */
23
- declare function gitignorePlugin(options?: GitignoreOptions): _baeta_generator_sdk.GeneratorPluginV1<unknown>;
24
-
25
- export { type GitignoreOptions, gitignorePlugin };
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.2",
3
+ "version": "2.0.0-next.7",
4
4
  "keywords": [
5
5
  "baeta",
6
6
  "graphql",
@@ -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": "^2.0.0-next.2"
53
+ "@baeta/generator-sdk": "^2.0.0-next.3"
47
54
  },
48
55
  "devDependencies": {
49
56
  "@baeta/builder": "^0.0.0",
57
+ "@baeta/testing": "^0.0.0",
50
58
  "@baeta/tsconfig": "^0.0.0",
51
- "@types/node": "^22.18.11",
59
+ "@types/node": "^22.19.1",
52
60
  "typescript": "^5.9.3"
53
61
  },
54
62
  "engines": {