@form8ion/git 2.1.1 → 3.0.0-beta.1
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/README.md +2 -2
- package/lib/index.js +8 -8
- package/lib/index.js.map +1 -1
- package/package.json +46 -42
- package/src/attributes/index.js +1 -0
- package/src/attributes/scaffolder.js +5 -0
- package/src/attributes/scaffolder.test.js +18 -0
- package/src/ignore/appender.js +13 -0
- package/src/ignore/appender.test.js +36 -0
- package/src/ignore/existence-checker.js +5 -0
- package/src/ignore/existence-checker.test.js +20 -0
- package/src/ignore/index.js +3 -0
- package/src/ignore/lifter.js +15 -0
- package/src/ignore/lifter.test.js +41 -0
- package/src/ignore/reader.js +5 -0
- package/src/ignore/reader.test.js +20 -0
- package/src/ignore/scaffolder.js +5 -0
- package/src/ignore/scaffolder.test.js +17 -0
- package/src/ignore/tester.js +5 -0
- package/src/ignore/tester.test.js +30 -0
- package/src/ignore/writer.js +5 -0
- package/src/ignore/writer.test.js +19 -0
- package/src/index.js +3 -0
- package/src/lifter.js +11 -0
- package/src/lifter.test.js +22 -0
- package/src/scaffolder.js +17 -0
- package/src/scaffolder.test.js +27 -0
- package/src/tester.js +7 -0
- package/src/tester.test.js +35 -0
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ $ npm test
|
|
|
105
105
|
|
|
106
106
|
[renovate-link]: https://renovatebot.com
|
|
107
107
|
|
|
108
|
-
[renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg?logo=
|
|
108
|
+
[renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg?logo=renovate
|
|
109
109
|
|
|
110
110
|
[PRs-link]: https://makeapullrequest.com
|
|
111
111
|
|
|
@@ -117,7 +117,7 @@ $ npm test
|
|
|
117
117
|
|
|
118
118
|
[coverage-link]: https://codecov.io/github/form8ion/git
|
|
119
119
|
|
|
120
|
-
[coverage-badge]: https://img.shields.io/codecov/c/github/form8ion/git?logo=codecov
|
|
120
|
+
[coverage-badge]: https://img.shields.io/codecov/c/github/form8ion/git/master?logo=codecov
|
|
121
121
|
|
|
122
122
|
[slsa-badge]: https://slsa.dev/images/gh-badge-level2.svg
|
|
123
123
|
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@ function writeGitIgnore({projectRoot, ignores}) {
|
|
|
8
8
|
return write({projectRoot, name: 'git', ignores});
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function scaffoldeIgnore({projectRoot}) {
|
|
12
12
|
return writeGitIgnore({projectRoot, ignores: []});
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -30,7 +30,7 @@ async function appendToIgnoreFile({projectRoot, ignores}) {
|
|
|
30
30
|
await writeGitIgnore({projectRoot, ignores: [...existingIgnores, ...ignores]});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function liftIgnore
|
|
33
|
+
async function liftIgnore({projectRoot, results: {vcsIgnore}}) {
|
|
34
34
|
if (vcsIgnore) {
|
|
35
35
|
info('Updating files and directories to be ignored from version control', {level: 'secondary'});
|
|
36
36
|
|
|
@@ -42,30 +42,30 @@ async function liftIgnore ({projectRoot, results: {vcsIgnore}}) {
|
|
|
42
42
|
return {};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
async function
|
|
45
|
+
async function scaffoldGit({projectRoot}) {
|
|
46
46
|
info('Initializing Git Repository');
|
|
47
47
|
|
|
48
48
|
const git = simpleGit({baseDir: projectRoot});
|
|
49
49
|
|
|
50
50
|
await Promise.all([
|
|
51
|
-
|
|
51
|
+
scaffoldeIgnore({projectRoot}),
|
|
52
52
|
git.init()
|
|
53
53
|
]);
|
|
54
54
|
|
|
55
55
|
return {};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function
|
|
58
|
+
function projectVersionedWithGit({projectRoot}) {
|
|
59
59
|
const git = simpleGit({baseDir: projectRoot});
|
|
60
60
|
|
|
61
61
|
return git.checkIsRepo('root');
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
function scaffoldAttributes
|
|
64
|
+
function scaffoldAttributes({projectRoot}) {
|
|
65
65
|
return promises.writeFile(`${projectRoot}/.gitattributes`, '* text=auto');
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
async function
|
|
68
|
+
async function liftGit({projectRoot, results}) {
|
|
69
69
|
await Promise.all([
|
|
70
70
|
scaffoldAttributes({projectRoot}),
|
|
71
71
|
liftIgnore({projectRoot, results})
|
|
@@ -74,5 +74,5 @@ async function lifter ({projectRoot, results}) {
|
|
|
74
74
|
return {};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
export {
|
|
77
|
+
export { liftGit as lift, scaffoldGit as scaffold, projectVersionedWithGit as test };
|
|
78
78
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/ignore/writer.js","../src/ignore/scaffolder.js","../src/ignore/existence-checker.js","../src/ignore/reader.js","../src/ignore/appender.js","../src/ignore/lifter.js","../src/scaffolder.js","../src/tester.js","../src/attributes/scaffolder.js","../src/lifter.js"],"sourcesContent":["import {write} from '@form8ion/ignore-file';\n\nexport default function writeGitIgnore({projectRoot, ignores}) {\n return write({projectRoot, name: 'git', ignores});\n}\n","import write from './writer.js';\n\nexport default function ({projectRoot}) {\n return write({projectRoot, ignores: []});\n}\n","import {exists} from '@form8ion/ignore-file';\n\nexport default function gitignoreExists({projectRoot} = {}) {\n return exists({projectRoot, name: 'git'});\n}\n","import {read} from '@form8ion/ignore-file';\n\nexport default function readGitIgnore({projectRoot}) {\n return read({projectRoot, name: 'git'});\n}\n","import gitignoreExists from './existence-checker.js';\nimport readGitIgnore from './reader.js';\nimport writeGitIgnore from './writer.js';\n\nexport default async function appendToIgnoreFile({projectRoot, ignores}) {\n let existingIgnores = [];\n\n if (await gitignoreExists({projectRoot})) {\n existingIgnores = await readGitIgnore({projectRoot});\n }\n\n await writeGitIgnore({projectRoot, ignores: [...existingIgnores, ...ignores]});\n}\n","import {info} from '@travi/cli-messages';\n\nimport appendIgnores from './appender.js';\n\nexport default async function ({projectRoot, results: {vcsIgnore}}) {\n if (vcsIgnore) {\n info('Updating files and directories to be ignored from version control', {level: 'secondary'});\n\n const {directories = [], files = []} = vcsIgnore;\n\n await appendIgnores({projectRoot, ignores: [...directories, ...files]});\n }\n\n return {};\n}\n","import simpleGit from 'simple-git';\nimport {info} from '@travi/cli-messages';\n\nimport {scaffold as scaffoldIgnore} from './ignore/index.js';\n\nexport default async function ({projectRoot}) {\n info('Initializing Git Repository');\n\n const git = simpleGit({baseDir: projectRoot});\n\n await Promise.all([\n scaffoldIgnore({projectRoot}),\n git.init()\n ]);\n\n return {};\n}\n","import simpleGit from 'simple-git';\n\nexport default function ({projectRoot}) {\n const git = simpleGit({baseDir: projectRoot});\n\n return git.checkIsRepo('root');\n}\n","import {promises as fs} from 'node:fs';\n\nexport default function ({projectRoot}) {\n return fs.writeFile(`${projectRoot}/.gitattributes`, '* text=auto');\n}\n","import {scaffold as scaffoldAttributes} from './attributes/index.js';\nimport {lift as liftIgnore} from './ignore/index.js';\n\nexport default async function ({projectRoot, results}) {\n await Promise.all([\n scaffoldAttributes({projectRoot}),\n liftIgnore({projectRoot, results})\n ]);\n\n return {};\n}\n"],"names":["write","appendIgnores","fs"],"mappings":";;;;;;AAEe,SAAS,cAAc,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;AAC/D,EAAE,OAAO,KAAK,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACnD;;ACFe,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/ignore/writer.js","../src/ignore/scaffolder.js","../src/ignore/existence-checker.js","../src/ignore/reader.js","../src/ignore/appender.js","../src/ignore/lifter.js","../src/scaffolder.js","../src/tester.js","../src/attributes/scaffolder.js","../src/lifter.js"],"sourcesContent":["import {write} from '@form8ion/ignore-file';\n\nexport default function writeGitIgnore({projectRoot, ignores}) {\n return write({projectRoot, name: 'git', ignores});\n}\n","import write from './writer.js';\n\nexport default function scaffoldeIgnore({projectRoot}) {\n return write({projectRoot, ignores: []});\n}\n","import {exists} from '@form8ion/ignore-file';\n\nexport default function gitignoreExists({projectRoot} = {}) {\n return exists({projectRoot, name: 'git'});\n}\n","import {read} from '@form8ion/ignore-file';\n\nexport default function readGitIgnore({projectRoot}) {\n return read({projectRoot, name: 'git'});\n}\n","import gitignoreExists from './existence-checker.js';\nimport readGitIgnore from './reader.js';\nimport writeGitIgnore from './writer.js';\n\nexport default async function appendToIgnoreFile({projectRoot, ignores}) {\n let existingIgnores = [];\n\n if (await gitignoreExists({projectRoot})) {\n existingIgnores = await readGitIgnore({projectRoot});\n }\n\n await writeGitIgnore({projectRoot, ignores: [...existingIgnores, ...ignores]});\n}\n","import {info} from '@travi/cli-messages';\n\nimport appendIgnores from './appender.js';\n\nexport default async function liftIgnore({projectRoot, results: {vcsIgnore}}) {\n if (vcsIgnore) {\n info('Updating files and directories to be ignored from version control', {level: 'secondary'});\n\n const {directories = [], files = []} = vcsIgnore;\n\n await appendIgnores({projectRoot, ignores: [...directories, ...files]});\n }\n\n return {};\n}\n","import simpleGit from 'simple-git';\nimport {info} from '@travi/cli-messages';\n\nimport {scaffold as scaffoldIgnore} from './ignore/index.js';\n\nexport default async function scaffoldGit({projectRoot}) {\n info('Initializing Git Repository');\n\n const git = simpleGit({baseDir: projectRoot});\n\n await Promise.all([\n scaffoldIgnore({projectRoot}),\n git.init()\n ]);\n\n return {};\n}\n","import simpleGit from 'simple-git';\n\nexport default function projectVersionedWithGit({projectRoot}) {\n const git = simpleGit({baseDir: projectRoot});\n\n return git.checkIsRepo('root');\n}\n","import {promises as fs} from 'node:fs';\n\nexport default function scaffoldAttributes({projectRoot}) {\n return fs.writeFile(`${projectRoot}/.gitattributes`, '* text=auto');\n}\n","import {scaffold as scaffoldAttributes} from './attributes/index.js';\nimport {lift as liftIgnore} from './ignore/index.js';\n\nexport default async function liftGit({projectRoot, results}) {\n await Promise.all([\n scaffoldAttributes({projectRoot}),\n liftIgnore({projectRoot, results})\n ]);\n\n return {};\n}\n"],"names":["write","appendIgnores","scaffoldIgnore","fs"],"mappings":";;;;;;AAEe,SAAS,cAAc,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;AAC/D,EAAE,OAAO,KAAK,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACnD;;ACFe,SAAS,eAAe,CAAC,CAAC,WAAW,CAAC,EAAE;AACvD,EAAE,OAAOA,cAAK,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1C;;ACFe,SAAS,eAAe,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE;AAC5D,EAAE,OAAO,MAAM,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3C;;ACFe,SAAS,aAAa,CAAC,CAAC,WAAW,CAAC,EAAE;AACrD,EAAE,OAAO,IAAI,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACzC;;ACAe,eAAe,kBAAkB,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;AACzE,EAAE,IAAI,eAAe,GAAG,EAAE;;AAE1B,EAAE,IAAI,MAAM,eAAe,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE;AAC5C,IAAI,eAAe,GAAG,MAAM,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC;AACxD,EAAE;;AAEF,EAAE,MAAM,cAAc,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,CAAC,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;AAChF;;ACRe,eAAe,UAAU,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE;AAC9E,EAAE,IAAI,SAAS,EAAE;AACjB,IAAI,IAAI,CAAC,mEAAmE,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;;AAEnG,IAAI,MAAM,CAAC,WAAW,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE,CAAC,GAAG,SAAS;;AAEpD,IAAI,MAAMC,kBAAa,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;AAC3E,EAAE;;AAEF,EAAE,OAAO,EAAE;AACX;;ACTe,eAAe,WAAW,CAAC,CAAC,WAAW,CAAC,EAAE;AACzD,EAAE,IAAI,CAAC,6BAA6B,CAAC;;AAErC,EAAE,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;;AAE/C,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;AACpB,IAAIC,eAAc,CAAC,CAAC,WAAW,CAAC,CAAC;AACjC,IAAI,GAAG,CAAC,IAAI;AACZ,GAAG,CAAC;;AAEJ,EAAE,OAAO,EAAE;AACX;;ACde,SAAS,uBAAuB,CAAC,CAAC,WAAW,CAAC,EAAE;AAC/D,EAAE,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;;AAE/C,EAAE,OAAO,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC;AAChC;;ACJe,SAAS,kBAAkB,CAAC,CAAC,WAAW,CAAC,EAAE;AAC1D,EAAE,OAAOC,QAAE,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC;AACrE;;ACDe,eAAe,OAAO,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;AAC9D,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;AACpB,IAAI,kBAAkB,CAAC,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,UAAU,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC;AACrC,GAAG,CAAC;;AAEJ,EAAE,OAAO,EAAE;AACX;;;;"}
|
package/package.json
CHANGED
|
@@ -2,57 +2,62 @@
|
|
|
2
2
|
"name": "@form8ion/git",
|
|
3
3
|
"description": "form8ion plugin for managing projects versioned with git",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "3.0.0-beta.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "^
|
|
8
|
+
"node": "^22.22.2 || >=24.15"
|
|
9
9
|
},
|
|
10
10
|
"author": "Matt Travi <npm@travi.org> (https://matt.travi.org)",
|
|
11
|
-
"repository":
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/form8ion/git.git"
|
|
14
|
+
},
|
|
12
15
|
"bugs": "https://github.com/form8ion/git/issues",
|
|
13
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://www.npmjs.com/package/@form8ion/git",
|
|
14
17
|
"runkitExampleFilename": "./example.js",
|
|
15
18
|
"exports": "./lib/index.js",
|
|
16
19
|
"main": "./lib/index.js",
|
|
17
20
|
"sideEffects": false,
|
|
18
21
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"pregenerate:md": "run-s build",
|
|
26
|
-
"test:unit": "cross-env NODE_ENV=test c8 run-s test:unit:base",
|
|
27
|
-
"test:unit:base": "DEBUG=any vitest run",
|
|
22
|
+
"pretest": "run-s build",
|
|
23
|
+
"test": "npm-run-all --print-label --parallel lint:* --parallel test:*",
|
|
24
|
+
"lint:engines": "ls-engines",
|
|
25
|
+
"lint:gherkin": "gherkin-lint --config=.gherkin-lintrc.json",
|
|
26
|
+
"lint:js": "eslint . --cache",
|
|
27
|
+
"lint:js:fix": "run-s 'lint:js -- --fix'",
|
|
28
28
|
"lint:lockfile": "lockfile-lint",
|
|
29
|
-
"prepare": "husky",
|
|
30
29
|
"lint:md": "remark . --frail",
|
|
31
|
-
"generate:md": "remark . --output",
|
|
32
30
|
"lint:peer": "npm ls >/dev/null",
|
|
33
|
-
"
|
|
31
|
+
"lint:publish": "publint --strict",
|
|
32
|
+
"test:unit": "run-s 'test:unit:base -- --coverage'",
|
|
33
|
+
"test:unit:base": "NODE_ENV=test DEBUG=any vitest run src/",
|
|
34
34
|
"test:integration": "run-s 'test:integration:base -- --profile noWip'",
|
|
35
|
+
"pretest:integration:base": "run-s build",
|
|
35
36
|
"test:integration:base": "NODE_OPTIONS=--enable-source-maps DEBUG=any cucumber-js test/integration",
|
|
36
37
|
"test:integration:debug": "DEBUG=test run-s test:integration",
|
|
38
|
+
"test:integration:focus": "run-s 'test:integration:base -- --profile focus'",
|
|
37
39
|
"test:integration:wip": "run-s 'test:integration:base -- --profile wip'",
|
|
38
40
|
"test:integration:wip:debug": "DEBUG=test run-s 'test:integration:wip'",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
41
|
+
"prebuild": "run-s clean",
|
|
42
|
+
"build": "npm-run-all --print-label --parallel build:*",
|
|
43
|
+
"build:js": "rollup --config",
|
|
44
|
+
"clean": "rimraf ./lib",
|
|
45
|
+
"pregenerate:md": "run-s build",
|
|
46
|
+
"generate:md": "remark . --output",
|
|
47
|
+
"prepack": "run-s build",
|
|
48
|
+
"prepare": "husky",
|
|
49
|
+
"watch": "run-s 'build:js -- --watch'"
|
|
46
50
|
},
|
|
47
51
|
"files": [
|
|
48
52
|
"example.js",
|
|
49
|
-
"lib/"
|
|
53
|
+
"lib/",
|
|
54
|
+
"src/"
|
|
50
55
|
],
|
|
51
56
|
"publishConfig": {
|
|
52
57
|
"access": "public",
|
|
53
58
|
"provenance": true
|
|
54
59
|
},
|
|
55
|
-
"packageManager": "npm@11.1
|
|
60
|
+
"packageManager": "npm@11.12.1+sha512.cdca14b85d647b3192028d02aadbe82d75f79a446aceea9874be98e6d768f20ebd3555770a48d0e9906106007877bbc690f715e9372f2e2dc644a3c3157fb14c",
|
|
56
61
|
"dependencies": {
|
|
57
62
|
"@form8ion/core": "^4.3.0",
|
|
58
63
|
"@form8ion/ignore-file": "^1.0.0",
|
|
@@ -60,31 +65,30 @@
|
|
|
60
65
|
"simple-git": "^3.25.0"
|
|
61
66
|
},
|
|
62
67
|
"devDependencies": {
|
|
63
|
-
"@cucumber/cucumber": "11.
|
|
64
|
-
"@form8ion/commitlint-config": "2.0.
|
|
65
|
-
"@form8ion/eslint-config": "7.0.
|
|
68
|
+
"@cucumber/cucumber": "11.3.0",
|
|
69
|
+
"@form8ion/commitlint-config": "2.0.11",
|
|
70
|
+
"@form8ion/eslint-config": "7.1.0-beta.1",
|
|
66
71
|
"@form8ion/eslint-config-cucumber": "1.4.1",
|
|
67
|
-
"@form8ion/remark-lint-preset": "6.0.
|
|
68
|
-
"@travi/any": "3.
|
|
69
|
-
"
|
|
70
|
-
"chai": "
|
|
71
|
-
"cross-env": "7.0.3",
|
|
72
|
+
"@form8ion/remark-lint-preset": "6.0.7",
|
|
73
|
+
"@travi/any": "3.3.0",
|
|
74
|
+
"@vitest/coverage-v8": "4.1.4",
|
|
75
|
+
"chai": "6.2.2",
|
|
72
76
|
"cz-conventional-changelog": "3.3.0",
|
|
73
77
|
"gherkin-lint": "4.2.4",
|
|
74
78
|
"husky": "9.1.7",
|
|
75
|
-
"lockfile-lint": "
|
|
76
|
-
"ls-engines": "0.9.
|
|
77
|
-
"mock-fs": "5.
|
|
78
|
-
"npm-run-all2": "
|
|
79
|
-
"publint": "0.3.
|
|
79
|
+
"lockfile-lint": "5.0.0",
|
|
80
|
+
"ls-engines": "0.9.4",
|
|
81
|
+
"mock-fs": "5.5.0",
|
|
82
|
+
"npm-run-all2": "8.0.4",
|
|
83
|
+
"publint": "0.3.18",
|
|
80
84
|
"remark-cli": "12.0.1",
|
|
81
85
|
"remark-toc": "9.0.0",
|
|
82
86
|
"remark-usage": "11.0.1",
|
|
83
|
-
"rimraf": "6.
|
|
84
|
-
"rollup": "4.
|
|
87
|
+
"rimraf": "6.1.3",
|
|
88
|
+
"rollup": "4.60.1",
|
|
85
89
|
"rollup-plugin-auto-external": "2.0.0",
|
|
86
90
|
"testdouble": "3.20.2",
|
|
87
|
-
"vitest": "
|
|
88
|
-
"vitest-when": "0.
|
|
91
|
+
"vitest": "4.1.4",
|
|
92
|
+
"vitest-when": "0.10.0"
|
|
89
93
|
}
|
|
90
94
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as scaffold} from './scaffolder.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {promises as fs} from 'node:fs';
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
4
|
+
import any from '@travi/any';
|
|
5
|
+
|
|
6
|
+
import scaffoldAttributes from './scaffolder.js';
|
|
7
|
+
|
|
8
|
+
vi.mock('node:fs');
|
|
9
|
+
|
|
10
|
+
describe('attributes scaffolder', () => {
|
|
11
|
+
it('should create the attributes file', async () => {
|
|
12
|
+
const projectRoot = any.string();
|
|
13
|
+
|
|
14
|
+
await scaffoldAttributes({projectRoot});
|
|
15
|
+
|
|
16
|
+
expect(fs.writeFile).toHaveBeenCalledWith(`${projectRoot}/.gitattributes`, '* text=auto');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import gitignoreExists from './existence-checker.js';
|
|
2
|
+
import readGitIgnore from './reader.js';
|
|
3
|
+
import writeGitIgnore from './writer.js';
|
|
4
|
+
|
|
5
|
+
export default async function appendToIgnoreFile({projectRoot, ignores}) {
|
|
6
|
+
let existingIgnores = [];
|
|
7
|
+
|
|
8
|
+
if (await gitignoreExists({projectRoot})) {
|
|
9
|
+
existingIgnores = await readGitIgnore({projectRoot});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
await writeGitIgnore({projectRoot, ignores: [...existingIgnores, ...ignores]});
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {describe, it, vi, expect} from 'vitest';
|
|
2
|
+
// eslint-disable-next-line import/no-unresolved
|
|
3
|
+
import {when} from 'vitest-when';
|
|
4
|
+
import any from '@travi/any';
|
|
5
|
+
|
|
6
|
+
import gitignoreExists from './existence-checker.js';
|
|
7
|
+
import read from './reader.js';
|
|
8
|
+
import write from './writer.js';
|
|
9
|
+
import appendToIgnoreFile from './appender.js';
|
|
10
|
+
|
|
11
|
+
vi.mock('./existence-checker.js');
|
|
12
|
+
vi.mock('./reader.js');
|
|
13
|
+
vi.mock('./writer.js');
|
|
14
|
+
|
|
15
|
+
describe('gitignore appender', () => {
|
|
16
|
+
const projectRoot = any.string();
|
|
17
|
+
const ignores = any.listOf(any.string);
|
|
18
|
+
|
|
19
|
+
it('should add the provided ignores to the existing gitignore', async () => {
|
|
20
|
+
const existingIgnores = any.listOf(any.string);
|
|
21
|
+
when(gitignoreExists).calledWith({projectRoot}).thenResolve(true);
|
|
22
|
+
when(read).calledWith({projectRoot}).thenResolve(existingIgnores);
|
|
23
|
+
|
|
24
|
+
await appendToIgnoreFile({projectRoot, ignores});
|
|
25
|
+
|
|
26
|
+
expect(write).toHaveBeenCalledWith({projectRoot, ignores: [...existingIgnores, ...ignores]});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should write only the provided ignores when the ignore file does not yet exist', async () => {
|
|
30
|
+
when(gitignoreExists).calledWith({projectRoot}).thenResolve(false);
|
|
31
|
+
|
|
32
|
+
await appendToIgnoreFile({projectRoot, ignores});
|
|
33
|
+
|
|
34
|
+
expect(write).toHaveBeenCalledWith({projectRoot, ignores});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {exists} from '@form8ion/ignore-file';
|
|
2
|
+
|
|
3
|
+
import {it, describe, vi, expect} from 'vitest';
|
|
4
|
+
import any from '@travi/any';
|
|
5
|
+
// eslint-disable-next-line import/no-unresolved
|
|
6
|
+
import {when} from 'vitest-when';
|
|
7
|
+
|
|
8
|
+
import gitignoreExists from './existence-checker.js';
|
|
9
|
+
|
|
10
|
+
vi.mock('@form8ion/ignore-file');
|
|
11
|
+
|
|
12
|
+
describe('gitignore existence checker', () => {
|
|
13
|
+
it('should check for existence of the gitignore', async () => {
|
|
14
|
+
const projectRoot = any.string();
|
|
15
|
+
const fileExists = any.boolean();
|
|
16
|
+
when(exists).calledWith({projectRoot, name: 'git'}).thenResolve(fileExists);
|
|
17
|
+
|
|
18
|
+
expect(await gitignoreExists({projectRoot})).toBe(fileExists);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {info} from '@travi/cli-messages';
|
|
2
|
+
|
|
3
|
+
import appendIgnores from './appender.js';
|
|
4
|
+
|
|
5
|
+
export default async function liftIgnore({projectRoot, results: {vcsIgnore}}) {
|
|
6
|
+
if (vcsIgnore) {
|
|
7
|
+
info('Updating files and directories to be ignored from version control', {level: 'secondary'});
|
|
8
|
+
|
|
9
|
+
const {directories = [], files = []} = vcsIgnore;
|
|
10
|
+
|
|
11
|
+
await appendIgnores({projectRoot, ignores: [...directories, ...files]});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
2
|
+
import any from '@travi/any';
|
|
3
|
+
|
|
4
|
+
import appendToIgnores from './appender.js';
|
|
5
|
+
import liftGitIgnore from './lifter.js';
|
|
6
|
+
|
|
7
|
+
vi.mock('./appender.js');
|
|
8
|
+
|
|
9
|
+
describe('gitignore lifter', () => {
|
|
10
|
+
const projectRoot = any.string();
|
|
11
|
+
const ignoredDirectories = any.listOf(any.word);
|
|
12
|
+
const ignoredFiles = any.listOf(any.word);
|
|
13
|
+
|
|
14
|
+
it('should append the provided ignores to the gitignore file', async () => {
|
|
15
|
+
expect(
|
|
16
|
+
await liftGitIgnore({projectRoot, results: {vcsIgnore: {directories: ignoredDirectories, files: ignoredFiles}}})
|
|
17
|
+
).toEqual({});
|
|
18
|
+
|
|
19
|
+
expect(appendToIgnores).toHaveBeenCalledWith({projectRoot, ignores: [...ignoredDirectories, ...ignoredFiles]});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should append provided directories to ignore', async () => {
|
|
23
|
+
expect(await liftGitIgnore({projectRoot, results: {vcsIgnore: {directories: ignoredDirectories}}}))
|
|
24
|
+
.toEqual({});
|
|
25
|
+
|
|
26
|
+
expect(appendToIgnores).toHaveBeenCalledWith({projectRoot, ignores: ignoredDirectories});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should append provided directories to ignore', async () => {
|
|
30
|
+
expect(await liftGitIgnore({projectRoot, results: {vcsIgnore: {files: ignoredFiles}}}))
|
|
31
|
+
.toEqual({});
|
|
32
|
+
|
|
33
|
+
expect(appendToIgnores).toHaveBeenCalledWith({projectRoot, ignores: ignoredFiles});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should not update the ignore file if no additional ignores are provided', async () => {
|
|
37
|
+
expect(await liftGitIgnore({projectRoot, results: {}})).toEqual({});
|
|
38
|
+
|
|
39
|
+
expect(appendToIgnores).not.toHaveBeenCalledWith({projectRoot});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {read} from '@form8ion/ignore-file';
|
|
2
|
+
|
|
3
|
+
import {it, describe, vi, expect} from 'vitest';
|
|
4
|
+
import any from '@travi/any';
|
|
5
|
+
// eslint-disable-next-line import/no-unresolved
|
|
6
|
+
import {when} from 'vitest-when';
|
|
7
|
+
|
|
8
|
+
import readGitIgnore from './reader.js';
|
|
9
|
+
|
|
10
|
+
vi.mock('@form8ion/ignore-file');
|
|
11
|
+
|
|
12
|
+
describe('gitignore reader', () => {
|
|
13
|
+
it('should read the contents of the .gitignore file', async () => {
|
|
14
|
+
const projectRoot = any.string();
|
|
15
|
+
const existingIgnores = any.listOf(any.word);
|
|
16
|
+
when(read).calledWith({projectRoot, name: 'git'}).thenResolve(existingIgnores);
|
|
17
|
+
|
|
18
|
+
expect(await readGitIgnore({projectRoot})).toEqual(existingIgnores);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
2
|
+
import any from '@travi/any';
|
|
3
|
+
|
|
4
|
+
import writeGitIgnore from './writer.js';
|
|
5
|
+
import scaffold from './scaffolder.js';
|
|
6
|
+
|
|
7
|
+
vi.mock('./writer.js');
|
|
8
|
+
|
|
9
|
+
describe('ignore scaffolder', () => {
|
|
10
|
+
const projectRoot = any.string();
|
|
11
|
+
|
|
12
|
+
it('should write the directories and files', async () => {
|
|
13
|
+
await scaffold({projectRoot});
|
|
14
|
+
|
|
15
|
+
expect(writeGitIgnore).toHaveBeenCalledWith({projectRoot, ignores: []});
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {fileExists} from '@form8ion/core';
|
|
2
|
+
|
|
3
|
+
import {describe, it, expect, vi, afterEach} from 'vitest';
|
|
4
|
+
import any from '@travi/any';
|
|
5
|
+
// eslint-disable-next-line import/no-unresolved
|
|
6
|
+
import {when} from 'vitest-when';
|
|
7
|
+
|
|
8
|
+
import gitignoreExists from './tester.js';
|
|
9
|
+
|
|
10
|
+
vi.mock('@form8ion/core');
|
|
11
|
+
|
|
12
|
+
describe('gitignore tester', () => {
|
|
13
|
+
const projectRoot = any.string();
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
vi.clearAllMocks();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return `true` if a `.gitignore` file exists', async () => {
|
|
20
|
+
when(fileExists).calledWith(`${projectRoot}/.gitignore`).thenResolve(true);
|
|
21
|
+
|
|
22
|
+
expect(await gitignoreExists({projectRoot})).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should return `false` if a `.gitignore` file does not exist', async () => {
|
|
26
|
+
when(fileExists).calledWith(`${projectRoot}/.gitignore`).thenResolve(false);
|
|
27
|
+
|
|
28
|
+
expect(await gitignoreExists({projectRoot})).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {write} from '@form8ion/ignore-file';
|
|
2
|
+
|
|
3
|
+
import {describe, it, vi, expect} from 'vitest';
|
|
4
|
+
import any from '@travi/any';
|
|
5
|
+
|
|
6
|
+
import writeGitIgnore from './writer.js';
|
|
7
|
+
|
|
8
|
+
vi.mock('@form8ion/ignore-file');
|
|
9
|
+
|
|
10
|
+
describe('gitignore writer', () => {
|
|
11
|
+
it('should write the provided ignores to the .gitignore file', async () => {
|
|
12
|
+
const projectRoot = any.string();
|
|
13
|
+
const ignores = any.listOf(any.string);
|
|
14
|
+
|
|
15
|
+
await writeGitIgnore({projectRoot, ignores});
|
|
16
|
+
|
|
17
|
+
expect(write).toHaveBeenCalledWith({projectRoot, name: 'git', ignores});
|
|
18
|
+
});
|
|
19
|
+
});
|
package/src/index.js
ADDED
package/src/lifter.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {scaffold as scaffoldAttributes} from './attributes/index.js';
|
|
2
|
+
import {lift as liftIgnore} from './ignore/index.js';
|
|
3
|
+
|
|
4
|
+
export default async function liftGit({projectRoot, results}) {
|
|
5
|
+
await Promise.all([
|
|
6
|
+
scaffoldAttributes({projectRoot}),
|
|
7
|
+
liftIgnore({projectRoot, results})
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import any from '@travi/any';
|
|
2
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
3
|
+
|
|
4
|
+
import {scaffold as scaffoldAttributes} from './attributes/index.js';
|
|
5
|
+
import {lift as liftIgnore} from './ignore/index.js';
|
|
6
|
+
import lift from './lifter.js';
|
|
7
|
+
|
|
8
|
+
vi.mock('./attributes/index.js');
|
|
9
|
+
vi.mock('./ignore/index.js');
|
|
10
|
+
|
|
11
|
+
describe('git lifter', () => {
|
|
12
|
+
it('should define the attributes file', async () => {
|
|
13
|
+
const projectRoot = any.string();
|
|
14
|
+
const results = any.simpleObject();
|
|
15
|
+
|
|
16
|
+
const result = await lift({projectRoot, results});
|
|
17
|
+
|
|
18
|
+
expect(result).toEqual({});
|
|
19
|
+
expect(scaffoldAttributes).toHaveBeenCalledWith({projectRoot});
|
|
20
|
+
expect(liftIgnore).toHaveBeenCalledWith({projectRoot, results});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import simpleGit from 'simple-git';
|
|
2
|
+
import {info} from '@travi/cli-messages';
|
|
3
|
+
|
|
4
|
+
import {scaffold as scaffoldIgnore} from './ignore/index.js';
|
|
5
|
+
|
|
6
|
+
export default async function scaffoldGit({projectRoot}) {
|
|
7
|
+
info('Initializing Git Repository');
|
|
8
|
+
|
|
9
|
+
const git = simpleGit({baseDir: projectRoot});
|
|
10
|
+
|
|
11
|
+
await Promise.all([
|
|
12
|
+
scaffoldIgnore({projectRoot}),
|
|
13
|
+
git.init()
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as simpleGit from 'simple-git';
|
|
2
|
+
|
|
3
|
+
import any from '@travi/any';
|
|
4
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
5
|
+
// eslint-disable-next-line import/no-unresolved
|
|
6
|
+
import {when} from 'vitest-when';
|
|
7
|
+
|
|
8
|
+
import {scaffold as scaffoldIgnore} from './ignore/index.js';
|
|
9
|
+
import scaffold from './scaffolder.js';
|
|
10
|
+
|
|
11
|
+
vi.mock('touch');
|
|
12
|
+
vi.mock('simple-git');
|
|
13
|
+
vi.mock('./ignore/index.js');
|
|
14
|
+
|
|
15
|
+
describe('scaffold', () => {
|
|
16
|
+
it('should initialize the repo', async () => {
|
|
17
|
+
const projectRoot = any.string();
|
|
18
|
+
const init = vi.fn();
|
|
19
|
+
when(simpleGit.simpleGit).calledWith({baseDir: projectRoot}).thenReturn({init});
|
|
20
|
+
|
|
21
|
+
const results = await scaffold({projectRoot});
|
|
22
|
+
|
|
23
|
+
expect(results).toEqual({});
|
|
24
|
+
expect(init).toHaveBeenCalled();
|
|
25
|
+
expect(scaffoldIgnore).toHaveBeenCalledWith({projectRoot});
|
|
26
|
+
});
|
|
27
|
+
});
|
package/src/tester.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as simpleGit from 'simple-git';
|
|
2
|
+
|
|
3
|
+
import any from '@travi/any';
|
|
4
|
+
import {beforeEach, describe, it, expect, vi} from 'vitest';
|
|
5
|
+
// eslint-disable-next-line import/no-unresolved
|
|
6
|
+
import {when} from 'vitest-when';
|
|
7
|
+
|
|
8
|
+
import gitIsPresent from './tester.js';
|
|
9
|
+
|
|
10
|
+
vi.mock('simple-git');
|
|
11
|
+
|
|
12
|
+
describe('git predicate', () => {
|
|
13
|
+
let checkIsRepo;
|
|
14
|
+
const projectRoot = any.string();
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
checkIsRepo = vi.fn();
|
|
18
|
+
|
|
19
|
+
when(simpleGit.simpleGit)
|
|
20
|
+
.calledWith({baseDir: projectRoot})
|
|
21
|
+
.thenReturn({checkIsRepo});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return `true` if a `.gitignore` file exists', async () => {
|
|
25
|
+
when(checkIsRepo).calledWith('root').thenResolve(true);
|
|
26
|
+
|
|
27
|
+
expect(await gitIsPresent({projectRoot})).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return `false` if a `.gitignore` file does not exist', async () => {
|
|
31
|
+
when(checkIsRepo).calledWith('root').thenResolve(false);
|
|
32
|
+
|
|
33
|
+
expect(await gitIsPresent({projectRoot})).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|