@baeta/plugin-gitignore 2.0.0-next.1 → 2.0.0-next.3

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,23 @@
1
1
  # @baeta/plugin-gitignore
2
2
 
3
+ ## 2.0.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Update generator-sdk package
8
+
9
+ - Updated dependencies [[`6de5d15`](https://github.com/andreisergiu98/baeta/commit/6de5d15484d341a1717a1b2f3f45272912e6a886)]:
10
+ - @baeta/generator-sdk@2.0.0-next.3
11
+
12
+ ## 2.0.0-next.2
13
+
14
+ ### Patch Changes
15
+
16
+ - Fix broken types
17
+
18
+ - Updated dependencies []:
19
+ - @baeta/generator-sdk@2.0.0-next.2
20
+
3
21
  ## 2.0.0-next.1
4
22
 
5
23
  ### 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
@@ -0,0 +1,27 @@
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
+ ignoreTags?: string[];
14
+ }
15
+ interface GitignoreOptions {
16
+ ignoreTags?: string[];
17
+ }
18
+ /**
19
+ * A plugin that adds .gitignore entries for generated files.
20
+ *
21
+ * @param options - Plugin configuration options
22
+ * @returns A Baeta generator plugin
23
+ */
24
+ declare function gitignorePlugin(options?: GitignoreOptions): _baeta_generator_sdk0.GeneratorPluginV1<unknown>;
25
+ //#endregion
26
+ export { GitignoreOptions, gitignorePlugin };
27
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,39 +1,36 @@
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 } from "@baeta/generator-sdk";
3
+
4
+ //#region index.ts
5
+ const defaultIgnoredTags = ["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 ignoredTags = [...options?.ignoreTags ?? [], ...defaultIgnoredTags];
19
+ const modulesDir = ctx.generatorOptions.modulesDir;
20
+ const moduleDefinitionName = ctx.generatorOptions.moduleDefinitionName;
21
+ const generatedPaths = ctx.fileManager.files.filter((file$1) => {
22
+ return !file$1.filename.endsWith(moduleDefinitionName) && !ignoredTags.includes(file$1.tag);
23
+ }).map((file$1) => file$1.filename).map((file$1) => relative(ctx.generatorOptions.cwd, file$1)).filter((file$1) => !file$1.endsWith(moduleDefinitionName));
24
+ generatedPaths.push(`${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`);
25
+ generatedPaths.sort((a, b) => a.localeCompare(b));
26
+ const gitignoreStart = "# Generated by Baeta - Begin";
27
+ const gitignoreInner = generatedPaths.join("\n");
28
+ const file = new FileBlock(resolve(ctx.generatorOptions.cwd, ".gitignore"), gitignoreInner, gitignoreStart, "# Generated by Baeta - End", "gitignore");
29
+ ctx.fileManager.add(file);
30
+ }
31
+ });
35
32
  }
36
- export {
37
- gitignorePlugin
38
- };
33
+
34
+ //#endregion
35
+ export { gitignorePlugin };
39
36
  //# 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 } 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":";;;;AAkBA,MAAM,qBAAqB,CAAC,aAAa;;;;;;;AAQzC,SAAgB,gBAAgB,SAA4B;AAC3D,QAAO,eAAe;EACrB,MAAM;EACN,YAAY;EACZ,UAAU,OAAO,KAAK,SAAS;AAC9B,SAAM,MAAM;GAEZ,MAAM,cAAc,CAAC,GAAI,SAAS,cAAc,EAAE,EAAG,GAAG,mBAAmB;GAE3E,MAAM,aAAa,IAAI,iBAAiB;GACxC,MAAM,uBAAuB,IAAI,iBAAiB;GAQlD,MAAM,iBANY,IAAI,YAAY,MAChC,QAAQ,WAAS;AACjB,WAAO,CAACA,OAAK,SAAS,SAAS,qBAAqB,IAAI,CAAC,YAAY,SAASA,OAAK,IAAI;KACtF,CACD,KAAK,WAASA,OAAK,SAAS,CAG5B,KAAK,WAAS,SAAS,IAAI,iBAAiB,KAAKA,OAAK,CAAC,CACvD,QAAQ,WAAS,CAACA,OAAK,SAAS,qBAAqB,CAAC;AAExD,kBAAe,KACd,GAAG,SAAS,IAAI,iBAAiB,KAAK,WAAW,CAAC,MAAM,uBACxD;AAED,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.1",
3
+ "version": "2.0.0-next.3",
4
4
  "keywords": [
5
5
  "baeta",
6
6
  "graphql",
@@ -37,18 +37,18 @@
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
43
  "types": "tsc --noEmit"
44
44
  },
45
45
  "dependencies": {
46
- "@baeta/generator-sdk": "^2.0.0-next.1"
46
+ "@baeta/generator-sdk": "^2.0.0-next.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@baeta/builder": "^0.0.0",
50
50
  "@baeta/tsconfig": "^0.0.0",
51
- "@types/node": "^22.18.11",
51
+ "@types/node": "^22.18.13",
52
52
  "typescript": "^5.9.3"
53
53
  },
54
54
  "engines": {