gign 0.0.3 → 0.3.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/LICENSE +21 -0
- package/README.md +175 -45
- package/dist/index.js +8612 -0
- package/dist/index.js.map +7 -0
- package/package.json +49 -7
- package/.vscode/launch.json +0 -17
- package/.vscode/settings.json +0 -3
- package/index.js +0 -9
- package/manual.json +0 -11
- package/pattern.json +0 -13
- package/src/actions/generateFile.js +0 -52
- package/src/util/download.js +0 -19
- package/src/util/os.js +0 -12
- package/src/util/project.js +0 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gign",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "gign generate .gitignore for your project",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,16 +12,58 @@
|
|
|
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
|
+
"semantic-release": "^25.0.9",
|
|
43
|
+
"ts-jest": "^29.4.14",
|
|
44
|
+
"ts-node": "^10.9.2",
|
|
45
|
+
"typescript": "^6.0.2",
|
|
46
|
+
"typescript-eslint": "^8.57.2"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
50
|
+
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
|
|
51
|
+
"lint": "eslint .",
|
|
52
|
+
"format": "prettier --write .",
|
|
53
|
+
"format:check": "prettier --check .",
|
|
54
|
+
"build": "esbuild index.ts --bundle --minify --sourcemap --platform=node --target=node20 --external:electron --format=esm --outfile=dist/index.js",
|
|
55
|
+
"prepack": "npm run build",
|
|
56
|
+
"sync:templates": "node scripts/sync-templates.mjs"
|
|
57
|
+
},
|
|
58
|
+
"type": "module",
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=20"
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"dist"
|
|
64
|
+
],
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public",
|
|
67
|
+
"provenance": true
|
|
26
68
|
}
|
|
27
69
|
}
|
package/.vscode/launch.json
DELETED
|
@@ -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
|
-
}
|
package/.vscode/settings.json
DELETED
package/index.js
DELETED
package/manual.json
DELETED
package/pattern.json
DELETED
|
@@ -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
|
-
}
|
package/src/util/download.js
DELETED
|
@@ -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
package/src/util/project.js
DELETED
|
@@ -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
|
-
}
|