@baeta/plugin-gitignore 2.0.0-next.3 → 2.0.0-next.8
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 +8 -0
- package/README.md +5 -5
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @baeta/plugin-gitignore
|
|
2
2
|
|
|
3
|
+
## 2.0.0-next.8
|
|
4
|
+
|
|
5
|
+
## 2.0.0-next.7
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#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
|
|
10
|
+
|
|
3
11
|
## 2.0.0-next.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
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/
|
|
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 />
|
|
@@ -103,7 +103,7 @@ import { UserModule } from "./typedef.ts";
|
|
|
103
103
|
const { Query } = UserModule;
|
|
104
104
|
|
|
105
105
|
const userQuery = Query.user
|
|
106
|
-
|
|
106
|
+
.$auth({
|
|
107
107
|
$or: {
|
|
108
108
|
isPublic: true,
|
|
109
109
|
isLoggedIn: true,
|
|
@@ -122,16 +122,16 @@ const { Query, Mutation, User } = UserModule;
|
|
|
122
122
|
export const userCache = User.$createCache();
|
|
123
123
|
|
|
124
124
|
const userQuery = Query.user
|
|
125
|
-
|
|
125
|
+
.$auth({
|
|
126
126
|
// ...
|
|
127
127
|
})
|
|
128
|
-
|
|
128
|
+
.$useCache(userCache)
|
|
129
129
|
.resolve(async ({ args }) => {
|
|
130
130
|
// ...
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
const updateUserMutation = Mutation.updateUser
|
|
134
|
-
|
|
134
|
+
.$use(async (next) => {
|
|
135
135
|
const user = await next();
|
|
136
136
|
await userCache.save(user);
|
|
137
137
|
return user;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,14 @@ interface GitignoreOptions {
|
|
|
10
10
|
* File tags are identifiers assigned to generated files
|
|
11
11
|
* to categorize them by their plugin or purpose.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
skipTags?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Array of files to exclude from .gitignore.
|
|
16
|
+
*/
|
|
17
|
+
skipFilesGlobs?: string[];
|
|
14
18
|
}
|
|
15
19
|
interface GitignoreOptions {
|
|
16
|
-
|
|
20
|
+
skipTags?: string[];
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* A plugin that adds .gitignore entries for generated files.
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { relative, resolve } from "node:path";
|
|
2
|
-
import { FileBlock, createPluginV1 } from "@baeta/generator-sdk";
|
|
2
|
+
import { FileBlock, createPluginV1, micromatch } from "@baeta/generator-sdk";
|
|
3
3
|
|
|
4
4
|
//#region index.ts
|
|
5
|
-
const
|
|
5
|
+
const defaultSkipTags = ["cloudflare"];
|
|
6
6
|
/**
|
|
7
7
|
* A plugin that adds .gitignore entries for generated files.
|
|
8
8
|
*
|
|
@@ -15,13 +15,14 @@ function gitignorePlugin(options) {
|
|
|
15
15
|
actionName: "add generated files to .gitignore",
|
|
16
16
|
generate: async (ctx, next) => {
|
|
17
17
|
await next();
|
|
18
|
-
const ignoredTags = [...options?.ignoreTags ?? [], ...defaultIgnoredTags];
|
|
19
18
|
const modulesDir = ctx.generatorOptions.modulesDir;
|
|
20
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))];
|
|
21
22
|
const generatedPaths = ctx.fileManager.files.filter((file$1) => {
|
|
22
|
-
return !file$1.filename.endsWith(moduleDefinitionName) && !
|
|
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;
|
|
23
24
|
}).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
|
+
if (!skippedFilesGlobs.some((skippedFile) => micromatch.isMatch(`${modulesDir}/**/${moduleDefinitionName}`, skippedFile))) generatedPaths.push(`${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`);
|
|
25
26
|
generatedPaths.sort((a, b) => a.localeCompare(b));
|
|
26
27
|
const gitignoreStart = "# Generated by Baeta - Begin";
|
|
27
28
|
const gitignoreInner = generatedPaths.join("\n");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\
|
|
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;GAE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
"keywords": [
|
|
5
5
|
"baeta",
|
|
6
6
|
"graphql",
|
|
@@ -40,15 +40,23 @@
|
|
|
40
40
|
"build": "builder build",
|
|
41
41
|
"prepack": "builder prepare",
|
|
42
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
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.
|
|
59
|
+
"@types/node": "^22.19.1",
|
|
52
60
|
"typescript": "^5.9.3"
|
|
53
61
|
},
|
|
54
62
|
"engines": {
|