@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 +18 -0
- package/README.md +42 -17
- package/dist/index.d.ts +27 -0
- package/dist/index.js +33 -36
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
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 {
|
|
80
|
+
import { UserModule } from "./typedef.ts";
|
|
81
81
|
|
|
82
|
-
const { Query } =
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
Query
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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
|
|
116
|
-
|
|
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
ADDED
|
@@ -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
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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":"
|
|
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.
|
|
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": "
|
|
41
|
-
"prepack": "
|
|
42
|
-
"postpack": "
|
|
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.
|
|
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.
|
|
51
|
+
"@types/node": "^22.18.13",
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|