@baeta/plugin-gitignore 0.0.2 → 0.0.4
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 +20 -0
- package/dist/index.cjs +13 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +13 -28
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @baeta/plugin-gitignore
|
|
2
2
|
|
|
3
|
+
## 0.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#128](https://github.com/andreisergiu98/baeta/pull/128) [`534917a`](https://github.com/andreisergiu98/baeta/commit/534917a18e7ed5d788a90a0335a5370d6af8f4a4) Thanks [@andreisergiu98](https://github.com/andreisergiu98)! - update dependencies
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`534917a`](https://github.com/andreisergiu98/baeta/commit/534917a18e7ed5d788a90a0335a5370d6af8f4a4)]:
|
|
10
|
+
- @baeta/generator-sdk@0.0.13
|
|
11
|
+
|
|
12
|
+
## 0.0.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#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
|
|
17
|
+
|
|
18
|
+
- [#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
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`ceae50d`](https://github.com/andreisergiu98/baeta/commit/ceae50d88e4e59b22c603637620f4fc6b28b2454), [`d94ee47`](https://github.com/andreisergiu98/baeta/commit/d94ee47bc485c541ff011290c4ac6ef0c145c83f)]:
|
|
21
|
+
- @baeta/generator-sdk@0.0.12
|
|
22
|
+
|
|
3
23
|
## 0.0.2
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// index.ts
|
|
2
2
|
var _generatorsdk = require('@baeta/generator-sdk');
|
|
3
|
-
var _promises = require('fs/promises');
|
|
4
3
|
var _path = require('path');
|
|
5
|
-
|
|
4
|
+
var allowedTags = ["cloudflare"];
|
|
5
|
+
function gitignorePlugin(options) {
|
|
6
6
|
return _generatorsdk.createPluginV1.call(void 0, {
|
|
7
7
|
name: "gitignore-plugin",
|
|
8
8
|
actionName: "add generated files to .gitignore",
|
|
9
9
|
generate: async (ctx, next) => {
|
|
10
10
|
await next();
|
|
11
|
-
const
|
|
11
|
+
const ignoredTags = [..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.ignoreTags]), () => ( [])), ...allowedTags];
|
|
12
12
|
const modulesDir = ctx.generatorOptions.modulesDir;
|
|
13
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);
|
|
14
17
|
const generatedPaths = filePaths.map((file2) => _path.relative.call(void 0, ctx.generatorOptions.cwd, file2)).filter((file2) => !file2.endsWith(moduleDefinitionName));
|
|
15
18
|
generatedPaths.push(
|
|
16
19
|
`${_path.relative.call(void 0, ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`
|
|
@@ -19,32 +22,14 @@ function gitignorePlugin() {
|
|
|
19
22
|
const gitignoreStart = "# Generated by Baeta - Begin";
|
|
20
23
|
const gitignoreInner = generatedPaths.join("\n");
|
|
21
24
|
const gitignoreEnd = "# Generated by Baeta - End";
|
|
22
|
-
const
|
|
23
|
-
${gitignoreInner}
|
|
24
|
-
${gitignoreEnd}`;
|
|
25
|
-
const file = new (0, _generatorsdk.File)(".gitignore", "", "gitignore", {
|
|
26
|
-
addEslintDisableHeader: false,
|
|
27
|
-
addGenerationNoticeHeader: false
|
|
28
|
-
});
|
|
29
|
-
const exists = await _promises.stat.call(void 0, _path.resolve.call(void 0, ctx.generatorOptions.cwd, ".gitignore")).then(() => true).catch(() => false);
|
|
30
|
-
if (!exists) {
|
|
31
|
-
file.content = gitignoreContent;
|
|
32
|
-
return file.write();
|
|
33
|
-
}
|
|
34
|
-
const currentContent = await _promises.readFile.call(void 0,
|
|
25
|
+
const file = new (0, _generatorsdk.FileBlock)(
|
|
35
26
|
_path.resolve.call(void 0, ctx.generatorOptions.cwd, ".gitignore"),
|
|
36
|
-
|
|
27
|
+
gitignoreInner,
|
|
28
|
+
gitignoreStart,
|
|
29
|
+
gitignoreEnd,
|
|
30
|
+
"gitignore"
|
|
37
31
|
);
|
|
38
|
-
|
|
39
|
-
const endMarkerIndex = currentContent.indexOf(gitignoreEnd);
|
|
40
|
-
if (startMarkerIndex === -1 || endMarkerIndex === -1) {
|
|
41
|
-
file.content = `${currentContent}
|
|
42
|
-
|
|
43
|
-
${gitignoreContent}`;
|
|
44
|
-
return file.write();
|
|
45
|
-
}
|
|
46
|
-
file.content = currentContent.slice(0, startMarkerIndex) + gitignoreContent + currentContent.slice(endMarkerIndex + gitignoreEnd.length);
|
|
47
|
-
return file.write();
|
|
32
|
+
ctx.fileManager.add(file);
|
|
48
33
|
}
|
|
49
34
|
});
|
|
50
35
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"names":["file"],"mappings":";AAAA,SAAS,gBAAgB,
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"names":["file"],"mappings":";AAAA,SAAS,gBAAgB,iBAAiB;AAC1C,SAAS,UAAU,eAAe;AAMlC,IAAM,cAAc,CAAC,YAAY;AAE1B,SAAS,gBAAgB,SAA4B;AAC1D,SAAO,eAAe;AAAA,IACpB,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,UAAU,OAAO,KAAK,SAAS;AAC7B,YAAM,KAAK;AAEX,YAAM,cAAc,CAAC,GAAI,SAAS,cAAc,CAAC,GAAI,GAAG,WAAW;AAEnE,YAAM,aAAa,IAAI,iBAAiB;AACxC,YAAM,uBAAuB,IAAI,iBAAiB;AAElD,YAAM,YAAY,IAAI,YAAY,MAC/B,OAAO,CAACA,UAAS;AAChB,eAAO,CAACA,MAAK,SAAS,SAAS,oBAAoB,KAAK,CAAC,YAAY,SAASA,MAAK,GAAG;AAAA,MACxF,CAAC,EACA,IAAI,CAACA,UAASA,MAAK,QAAQ;AAE9B,YAAM,iBAAiB,UACpB,IAAI,CAACA,UAAS,SAAS,IAAI,iBAAiB,KAAKA,KAAI,CAAC,EACtD,OAAO,CAACA,UAAS,CAACA,MAAK,SAAS,oBAAoB,CAAC;AAExD,qBAAe;AAAA,QACb,GAAG,SAAS,IAAI,iBAAiB,KAAK,UAAU,CAAC,OAAO,oBAAoB;AAAA,MAC9E;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,QACf,QAAQ,IAAI,iBAAiB,KAAK,YAAY;AAAA,QAC9C;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,UAAI,YAAY,IAAI,IAAI;AAAA,IAC1B;AAAA,EACF,CAAC;AACH","sourcesContent":["import { createPluginV1, FileBlock } from '@baeta/generator-sdk';\nimport { relative, resolve } from 'node:path';\n\nexport interface GitignoreOptions {\n ignoreTags?: string[];\n}\n\nconst allowedTags = ['cloudflare'];\n\nexport function gitignorePlugin(options?: GitignoreOptions) {\n return createPluginV1({\n name: 'gitignore-plugin',\n actionName: 'add generated files to .gitignore',\n generate: async (ctx, next) => {\n await next();\n\n const ignoredTags = [...(options?.ignoreTags ?? []), ...allowedTags];\n\n const modulesDir = ctx.generatorOptions.modulesDir;\n const moduleDefinitionName = ctx.generatorOptions.moduleDefinitionName;\n\n const filePaths = ctx.fileManager.files\n .filter((file) => {\n return !file.filename.endsWith(moduleDefinitionName) && !ignoredTags.includes(file.tag);\n })\n .map((file) => file.filename);\n\n const generatedPaths = filePaths\n .map((file) => relative(ctx.generatorOptions.cwd, file))\n .filter((file) => !file.endsWith(moduleDefinitionName));\n\n generatedPaths.push(\n `${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`,\n );\n\n generatedPaths.sort((a, b) => a.localeCompare(b));\n\n const gitignoreStart = '# Generated by Baeta - Begin';\n const gitignoreInner = generatedPaths.join('\\n');\n const gitignoreEnd = '# Generated by Baeta - End';\n\n const file = new FileBlock(\n resolve(ctx.generatorOptions.cwd, '.gitignore'),\n gitignoreInner,\n gitignoreStart,\n gitignoreEnd,\n 'gitignore',\n );\n\n ctx.fileManager.add(file);\n },\n });\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as _baeta_generator_sdk from '@baeta/generator-sdk';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface GitignoreOptions {
|
|
4
|
+
ignoreTags?: string[];
|
|
5
|
+
}
|
|
6
|
+
declare function gitignorePlugin(options?: GitignoreOptions): _baeta_generator_sdk.GeneratorPluginV1<{}>;
|
|
4
7
|
|
|
5
|
-
export { gitignorePlugin };
|
|
8
|
+
export { type GitignoreOptions, gitignorePlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as _baeta_generator_sdk from '@baeta/generator-sdk';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface GitignoreOptions {
|
|
4
|
+
ignoreTags?: string[];
|
|
5
|
+
}
|
|
6
|
+
declare function gitignorePlugin(options?: GitignoreOptions): _baeta_generator_sdk.GeneratorPluginV1<{}>;
|
|
4
7
|
|
|
5
|
-
export { gitignorePlugin };
|
|
8
|
+
export { type GitignoreOptions, gitignorePlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
// index.ts
|
|
2
|
-
import { createPluginV1,
|
|
3
|
-
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { createPluginV1, FileBlock } from "@baeta/generator-sdk";
|
|
4
3
|
import { relative, resolve } from "node:path";
|
|
5
|
-
|
|
4
|
+
var allowedTags = ["cloudflare"];
|
|
5
|
+
function gitignorePlugin(options) {
|
|
6
6
|
return createPluginV1({
|
|
7
7
|
name: "gitignore-plugin",
|
|
8
8
|
actionName: "add generated files to .gitignore",
|
|
9
9
|
generate: async (ctx, next) => {
|
|
10
10
|
await next();
|
|
11
|
-
const
|
|
11
|
+
const ignoredTags = [...options?.ignoreTags ?? [], ...allowedTags];
|
|
12
12
|
const modulesDir = ctx.generatorOptions.modulesDir;
|
|
13
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);
|
|
14
17
|
const generatedPaths = filePaths.map((file2) => relative(ctx.generatorOptions.cwd, file2)).filter((file2) => !file2.endsWith(moduleDefinitionName));
|
|
15
18
|
generatedPaths.push(
|
|
16
19
|
`${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`
|
|
@@ -19,32 +22,14 @@ function gitignorePlugin() {
|
|
|
19
22
|
const gitignoreStart = "# Generated by Baeta - Begin";
|
|
20
23
|
const gitignoreInner = generatedPaths.join("\n");
|
|
21
24
|
const gitignoreEnd = "# Generated by Baeta - End";
|
|
22
|
-
const
|
|
23
|
-
${gitignoreInner}
|
|
24
|
-
${gitignoreEnd}`;
|
|
25
|
-
const file = new File(".gitignore", "", "gitignore", {
|
|
26
|
-
addEslintDisableHeader: false,
|
|
27
|
-
addGenerationNoticeHeader: false
|
|
28
|
-
});
|
|
29
|
-
const exists = await stat(resolve(ctx.generatorOptions.cwd, ".gitignore")).then(() => true).catch(() => false);
|
|
30
|
-
if (!exists) {
|
|
31
|
-
file.content = gitignoreContent;
|
|
32
|
-
return file.write();
|
|
33
|
-
}
|
|
34
|
-
const currentContent = await readFile(
|
|
25
|
+
const file = new FileBlock(
|
|
35
26
|
resolve(ctx.generatorOptions.cwd, ".gitignore"),
|
|
36
|
-
|
|
27
|
+
gitignoreInner,
|
|
28
|
+
gitignoreStart,
|
|
29
|
+
gitignoreEnd,
|
|
30
|
+
"gitignore"
|
|
37
31
|
);
|
|
38
|
-
|
|
39
|
-
const endMarkerIndex = currentContent.indexOf(gitignoreEnd);
|
|
40
|
-
if (startMarkerIndex === -1 || endMarkerIndex === -1) {
|
|
41
|
-
file.content = `${currentContent}
|
|
42
|
-
|
|
43
|
-
${gitignoreContent}`;
|
|
44
|
-
return file.write();
|
|
45
|
-
}
|
|
46
|
-
file.content = currentContent.slice(0, startMarkerIndex) + gitignoreContent + currentContent.slice(endMarkerIndex + gitignoreEnd.length);
|
|
47
|
-
return file.write();
|
|
32
|
+
ctx.fileManager.add(file);
|
|
48
33
|
}
|
|
49
34
|
});
|
|
50
35
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createPluginV1,
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createPluginV1, FileBlock } from '@baeta/generator-sdk';\nimport { relative, resolve } from 'node:path';\n\nexport interface GitignoreOptions {\n ignoreTags?: string[];\n}\n\nconst allowedTags = ['cloudflare'];\n\nexport function gitignorePlugin(options?: GitignoreOptions) {\n return createPluginV1({\n name: 'gitignore-plugin',\n actionName: 'add generated files to .gitignore',\n generate: async (ctx, next) => {\n await next();\n\n const ignoredTags = [...(options?.ignoreTags ?? []), ...allowedTags];\n\n const modulesDir = ctx.generatorOptions.modulesDir;\n const moduleDefinitionName = ctx.generatorOptions.moduleDefinitionName;\n\n const filePaths = ctx.fileManager.files\n .filter((file) => {\n return !file.filename.endsWith(moduleDefinitionName) && !ignoredTags.includes(file.tag);\n })\n .map((file) => file.filename);\n\n const generatedPaths = filePaths\n .map((file) => relative(ctx.generatorOptions.cwd, file))\n .filter((file) => !file.endsWith(moduleDefinitionName));\n\n generatedPaths.push(\n `${relative(ctx.generatorOptions.cwd, modulesDir)}/**/${moduleDefinitionName}`,\n );\n\n generatedPaths.sort((a, b) => a.localeCompare(b));\n\n const gitignoreStart = '# Generated by Baeta - Begin';\n const gitignoreInner = generatedPaths.join('\\n');\n const gitignoreEnd = '# Generated by Baeta - End';\n\n const file = new FileBlock(\n resolve(ctx.generatorOptions.cwd, '.gitignore'),\n gitignoreInner,\n gitignoreStart,\n gitignoreEnd,\n 'gitignore',\n );\n\n ctx.fileManager.add(file);\n },\n });\n}\n"],"mappings":";AAAA,SAAS,gBAAgB,iBAAiB;AAC1C,SAAS,UAAU,eAAe;AAMlC,IAAM,cAAc,CA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
|
6
6
|
"graphql",
|
|
@@ -39,22 +39,21 @@
|
|
|
39
39
|
],
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsup",
|
|
42
|
-
"dev": "tsup --watch",
|
|
43
42
|
"prepack": "prep",
|
|
44
43
|
"postpack": "prep --clean",
|
|
45
44
|
"types": "tsc --noEmit"
|
|
46
45
|
},
|
|
47
46
|
"dependencies": {
|
|
48
|
-
"@baeta/generator-sdk": "^0.0.
|
|
47
|
+
"@baeta/generator-sdk": "^0.0.13"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"@baeta/builder": "^0.0.0",
|
|
52
51
|
"@baeta/tsconfig": "^0.0.0",
|
|
53
|
-
"@types/node": "^
|
|
54
|
-
"typescript": "^5.4.
|
|
52
|
+
"@types/node": "^20.14.2",
|
|
53
|
+
"typescript": "^5.4.5"
|
|
55
54
|
},
|
|
56
55
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
56
|
+
"node": ">=20.0.0"
|
|
58
57
|
},
|
|
59
58
|
"publishConfig": {
|
|
60
59
|
"access": "public"
|