gign 0.0.3 → 0.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gign",
3
- "version": "0.0.3",
3
+ "version": "0.2.0",
4
4
  "description": "gign generate .gitignore for your project",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,16 +12,57 @@
12
12
  },
13
13
  "keywords": [
14
14
  "git",
15
- "gitignore"
15
+ "gitignore",
16
+ "cli",
17
+ "generator",
18
+ "offline"
16
19
  ],
17
20
  "homepage": "https://github.com/juninmd/gign#readme",
18
21
  "license": "MIT",
19
- "dependencies": {
20
- "download": "^6.2.5",
21
- "loading-indicator": "^2.0.0"
22
- },
23
22
  "preferGlobal": true,
24
23
  "bin": {
25
- "gign": "index.js"
24
+ "gign": "dist/index.js"
25
+ },
26
+ "devDependencies": {
27
+ "@eslint/js": "^10.0.1",
28
+ "@jest/globals": "^30.3.0",
29
+ "@types/jest": "^30.0.0",
30
+ "@types/node": "^26.0.0",
31
+ "@typescript-eslint/eslint-plugin": "^8.57.2",
32
+ "@typescript-eslint/parser": "^8.57.2",
33
+ "esbuild": "^0.28.0",
34
+ "eslint": "^10.1.0",
35
+ "eslint-config-prettier": "^10.1.8",
36
+ "eslint-plugin-jest": "^29.15.0",
37
+ "eslint-plugin-prettier": "^5.5.5",
38
+ "globals": "^17.4.0",
39
+ "jest": "^30.3.0",
40
+ "jiti": "^2.7.0",
41
+ "prettier": "^3.8.1",
42
+ "ts-jest": "^29.4.14",
43
+ "ts-node": "^10.9.2",
44
+ "typescript": "^6.0.2",
45
+ "typescript-eslint": "^8.57.2"
46
+ },
47
+ "scripts": {
48
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
49
+ "test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
50
+ "lint": "eslint .",
51
+ "format": "prettier --write .",
52
+ "format:check": "prettier --check .",
53
+ "build": "esbuild index.ts --bundle --minify --sourcemap --platform=node --target=node20 --external:electron --format=esm --outfile=dist/index.js",
54
+ "prepack": "npm run build",
55
+ "sync:templates": "node scripts/sync-templates.mjs"
56
+ },
57
+ "type": "module",
58
+ "engines": {
59
+ "node": ">=20"
60
+ },
61
+ "files": [
62
+ "dist"
63
+ ],
64
+ "publishConfig": {
65
+ "access": "public",
66
+ "provenance": true
26
67
  }
27
68
  }
@@ -1,17 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible Node.js debug attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "program": "${workspaceRoot}/index.js",
12
- "args": [
13
- "-–harmony-async-await"
14
- ]
15
- }
16
- ]
17
- }
@@ -1,3 +0,0 @@
1
- {
2
- "eslint.enable": false
3
- }
package/index.js DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- const generateFile = require('./src/actions/generateFile');
3
-
4
- if (process.argv.length != 3) {
5
- console.info('[gign] use "gign <path>"')
6
- return;
7
- }
8
-
9
- generateFile(process.argv[2]);
package/manual.json DELETED
@@ -1,11 +0,0 @@
1
- [
2
- {
3
- "tag": "typescript",
4
- "search": [
5
- {
6
- "filename": "tsconfig.json",
7
- "struct": "compilerOptions.outDir"
8
- }
9
- ]
10
- }
11
- ]
package/pattern.json DELETED
@@ -1,13 +0,0 @@
1
- [
2
- {
3
- "node": [
4
- "package.json",
5
- "node_modules"
6
- ]
7
- },
8
- {
9
- "VisualStudioCode": [
10
- ".vscode"
11
- ]
12
- }
13
- ]
@@ -1,52 +0,0 @@
1
- const os = require('../util/os')
2
- const download = require('../util/download');
3
- const project = require('../util/project');
4
- const fs = require('fs');
5
-
6
- async function doit(dir) {
7
- try {
8
-
9
- if (!fs.existsSync(dir)) {
10
- console.warn('[gign] Directory does not exist');
11
- return;
12
- }
13
-
14
- let tags = [os()];
15
-
16
- let [projectTags, ignoreManual] = project(dir);
17
-
18
- tags.push(...projectTags);
19
-
20
- let path = await download({
21
- directory: dir,
22
- tags
23
- });
24
-
25
-
26
- let structManual = '';
27
- Object.keys(ignoreManual).map(q => {
28
- let i = ignoreManual[q];
29
- structManual += `# ${q}\r\n${i.values.join('\r\n')}`
30
- })
31
-
32
- if (structManual)
33
- fs.appendFileSync(path, structManual);
34
-
35
- if (Object.keys(ignoreManual).length == 0 && projectTags.length == 0) {
36
- console.info(`[gign] nothing detected`)
37
- return;
38
- }
39
-
40
- console.info(`[gign] generated at ${path}`)
41
- if (projectTags.length > 0)
42
- console.info(`[gign] tags: ${tags}`)
43
- if (Object.keys(ignoreManual).length > 0)
44
- console.info(`[gign] manual tags: ${Object.keys(ignoreManual)}`)
45
- } catch (ex) {
46
- console.error(`[gign] ${ex.message}`);
47
- }
48
- }
49
-
50
- module.exports = (dir) => {
51
- return doit(dir);
52
- }
@@ -1,19 +0,0 @@
1
- const download = require('download')
2
- const path = require('path');
3
- const fs = require('fs');
4
- const loading = require('loading-indicator');
5
-
6
- module.exports = (options) => {
7
- return new Promise((resolve, reject) => {
8
- const timer = loading.start('Download...');
9
- download(`https://www.gitignore.io/api/${options.tags}`)
10
- .then(data => {
11
- loading.stop(timer);
12
- fs.writeFileSync(`${options.directory}//.gitignore`, data);
13
- return resolve(path.join(options.directory, '.gitignore'));
14
- }).catch(err => {
15
- loading.stop(timer);
16
- return reject(err);
17
- });
18
- })
19
- }
package/src/util/os.js DELETED
@@ -1,12 +0,0 @@
1
- const os = require('os');
2
-
3
- module.exports = () => {
4
- switch (os.type()) {
5
- case 'Windows_NT':
6
- return "windows";
7
- case 'Linux':
8
- return "linux";
9
- default:
10
- return "macos";
11
- }
12
- }
@@ -1,55 +0,0 @@
1
- const fs = require('fs');
2
- const pattern = require('../../pattern.json');
3
- const manual = require('../../manual.json');
4
-
5
- module.exports = (dir) => {
6
- const tags = [];
7
- let ignorePaths = {};
8
-
9
- const files = fs.readdirSync(dir);
10
-
11
- if (!files.includes('.git')) {
12
- console.warn('[gign] Initialize a git repository, use "git init" command')
13
- }
14
-
15
- pattern.map(q => {
16
- let key = Object.keys(q)[0];
17
- let itens = q[key];
18
- if (itens.some(r => files.includes(r)) && !tags.includes(key))
19
- tags.push(key);
20
- })
21
-
22
-
23
- manual.map(item => {
24
-
25
- item.search.filter(q => {
26
- if (files.includes(q.filename)) {
27
- ignorePaths[item.tag] = { values: [] }
28
-
29
- if (q.struct) {
30
- try {
31
- let obj = JSON.parse(fs.readFileSync(`${dir}\\${q.filename}`).toString('utf8'));
32
- ignorePaths[item.tag].values.push(acessAttrObj(obj, q.struct));
33
- } catch (error) {
34
- delete ignorePaths[item.tag];
35
- console.error(`[gign] error on model of ${item.tag}, struct: ${q.struct}, file: ${q.filename}`);
36
- }
37
- }
38
- else if (q.path) {
39
- ignorePaths[item.tag].values.push(q.path)
40
- }
41
- }
42
- })
43
-
44
- })
45
-
46
- return [tags, ignorePaths];
47
- }
48
-
49
- function acessAttrObj(obj, struct) {
50
- let attrs = struct.split('.');
51
- attrs.forEach(att => {
52
- obj = obj[att];
53
- });
54
- return obj;
55
- }