@form8ion/git 3.0.0-beta.1 → 3.0.0-beta.2
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 +8 -2
- package/example.js +8 -2
- package/lib/index.js +6 -7
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/ignore/lifter.js +2 -4
- package/src/ignore/lifter.test.js +11 -7
- package/src/lifter.js +2 -2
- package/src/lifter.test.js +3 -2
- package/src/scaffolder.js +2 -3
- package/src/scaffolder.test.js +2 -1
package/README.md
CHANGED
|
@@ -58,11 +58,17 @@ import {scaffold, test, lift} from '@form8ion/git';
|
|
|
58
58
|
|
|
59
59
|
```javascript
|
|
60
60
|
const projectRoot = process.cwd();
|
|
61
|
+
const logger = {
|
|
62
|
+
info: () => undefined,
|
|
63
|
+
success: () => undefined,
|
|
64
|
+
warn: () => undefined,
|
|
65
|
+
error: () => undefined
|
|
66
|
+
};
|
|
61
67
|
|
|
62
|
-
await scaffold({projectRoot});
|
|
68
|
+
await scaffold({projectRoot}, {logger});
|
|
63
69
|
|
|
64
70
|
if (await test({projectRoot})) {
|
|
65
|
-
await lift({projectRoot, results: {vcsIgnore: {file: [], directories: []}}});
|
|
71
|
+
await lift({projectRoot, results: {vcsIgnore: {file: [], directories: []}}}, {logger});
|
|
66
72
|
}
|
|
67
73
|
```
|
|
68
74
|
|
package/example.js
CHANGED
|
@@ -9,9 +9,15 @@ stubbedFs();
|
|
|
9
9
|
// #### Execute
|
|
10
10
|
|
|
11
11
|
const projectRoot = process.cwd();
|
|
12
|
+
const logger = {
|
|
13
|
+
info: () => undefined,
|
|
14
|
+
success: () => undefined,
|
|
15
|
+
warn: () => undefined,
|
|
16
|
+
error: () => undefined
|
|
17
|
+
};
|
|
12
18
|
|
|
13
|
-
await scaffold({projectRoot});
|
|
19
|
+
await scaffold({projectRoot}, {logger});
|
|
14
20
|
|
|
15
21
|
if (await test({projectRoot})) {
|
|
16
|
-
await lift({projectRoot, results: {vcsIgnore: {file: [], directories: []}}});
|
|
22
|
+
await lift({projectRoot, results: {vcsIgnore: {file: [], directories: []}}}, {logger});
|
|
17
23
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import simpleGit from 'simple-git';
|
|
2
|
-
import { info } from '@travi/cli-messages';
|
|
3
2
|
import { write, exists, read } from '@form8ion/ignore-file';
|
|
4
3
|
import '@form8ion/core';
|
|
5
4
|
import { promises } from 'node:fs';
|
|
@@ -30,9 +29,9 @@ async function appendToIgnoreFile({projectRoot, ignores}) {
|
|
|
30
29
|
await writeGitIgnore({projectRoot, ignores: [...existingIgnores, ...ignores]});
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
async function liftIgnore({projectRoot, results: {vcsIgnore}}) {
|
|
32
|
+
async function liftIgnore({projectRoot, results: {vcsIgnore}}, {logger}) {
|
|
34
33
|
if (vcsIgnore) {
|
|
35
|
-
info('Updating files and directories to be ignored from version control', {level: 'secondary'});
|
|
34
|
+
logger.info('Updating files and directories to be ignored from version control', {level: 'secondary'});
|
|
36
35
|
|
|
37
36
|
const {directories = [], files = []} = vcsIgnore;
|
|
38
37
|
|
|
@@ -42,8 +41,8 @@ async function liftIgnore({projectRoot, results: {vcsIgnore}}) {
|
|
|
42
41
|
return {};
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
async function scaffoldGit({projectRoot}) {
|
|
46
|
-
info('Initializing Git Repository');
|
|
44
|
+
async function scaffoldGit({projectRoot}, {logger}) {
|
|
45
|
+
logger.info('Initializing Git Repository');
|
|
47
46
|
|
|
48
47
|
const git = simpleGit({baseDir: projectRoot});
|
|
49
48
|
|
|
@@ -65,10 +64,10 @@ function scaffoldAttributes({projectRoot}) {
|
|
|
65
64
|
return promises.writeFile(`${projectRoot}/.gitattributes`, '* text=auto');
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
async function liftGit({projectRoot, results}) {
|
|
67
|
+
async function liftGit({projectRoot, results}, dependencies) {
|
|
69
68
|
await Promise.all([
|
|
70
69
|
scaffoldAttributes({projectRoot}),
|
|
71
|
-
liftIgnore({projectRoot, results})
|
|
70
|
+
liftIgnore({projectRoot, results}, dependencies)
|
|
72
71
|
]);
|
|
73
72
|
|
|
74
73
|
return {};
|
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 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
|
|
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 appendIgnores from './appender.js';\n\nexport default async function liftIgnore({projectRoot, results: {vcsIgnore}}, {logger}) {\n if (vcsIgnore) {\n logger.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';\n\nimport {scaffold as scaffoldIgnore} from './ignore/index.js';\n\nexport default async function scaffoldGit({projectRoot}, {logger}) {\n logger.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}, dependencies) {\n await Promise.all([\n scaffoldAttributes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AO,CAAC,EAAE,YAAY;AACnD,GAAG,CAAC;;AAEJ,EAAE,OAAO,EAAE;AACX;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@form8ion/git",
|
|
3
3
|
"description": "form8ion plugin for managing projects versioned with git",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "3.0.0-beta.
|
|
5
|
+
"version": "3.0.0-beta.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": "^22.22.2 || >=24.15"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"pretest": "run-s build",
|
|
23
23
|
"test": "npm-run-all --print-label --parallel lint:* --parallel test:*",
|
|
24
24
|
"lint:engines": "ls-engines",
|
|
25
|
-
"lint:gherkin": "
|
|
25
|
+
"lint:gherkin": "gplint --config .gplintrc.json",
|
|
26
26
|
"lint:js": "eslint . --cache",
|
|
27
27
|
"lint:js:fix": "run-s 'lint:js -- --fix'",
|
|
28
28
|
"lint:lockfile": "lockfile-lint",
|
|
@@ -59,9 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"packageManager": "npm@11.12.1+sha512.cdca14b85d647b3192028d02aadbe82d75f79a446aceea9874be98e6d768f20ebd3555770a48d0e9906106007877bbc690f715e9372f2e2dc644a3c3157fb14c",
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@form8ion/core": "^
|
|
62
|
+
"@form8ion/core": "^5.0.0-beta.15",
|
|
63
63
|
"@form8ion/ignore-file": "^1.0.0",
|
|
64
|
-
"@travi/cli-messages": "^1.1.1",
|
|
65
64
|
"simple-git": "^3.25.0"
|
|
66
65
|
},
|
|
67
66
|
"devDependencies": {
|
|
@@ -74,7 +73,8 @@
|
|
|
74
73
|
"@vitest/coverage-v8": "4.1.4",
|
|
75
74
|
"chai": "6.2.2",
|
|
76
75
|
"cz-conventional-changelog": "3.3.0",
|
|
77
|
-
"
|
|
76
|
+
"debug": "4.4.3",
|
|
77
|
+
"gplint": "2.5.2",
|
|
78
78
|
"husky": "9.1.7",
|
|
79
79
|
"lockfile-lint": "5.0.0",
|
|
80
80
|
"ls-engines": "0.9.4",
|
package/src/ignore/lifter.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {info} from '@travi/cli-messages';
|
|
2
|
-
|
|
3
1
|
import appendIgnores from './appender.js';
|
|
4
2
|
|
|
5
|
-
export default async function liftIgnore({projectRoot, results: {vcsIgnore}}) {
|
|
3
|
+
export default async function liftIgnore({projectRoot, results: {vcsIgnore}}, {logger}) {
|
|
6
4
|
if (vcsIgnore) {
|
|
7
|
-
info('Updating files and directories to be ignored from version control', {level: 'secondary'});
|
|
5
|
+
logger.info('Updating files and directories to be ignored from version control', {level: 'secondary'});
|
|
8
6
|
|
|
9
7
|
const {directories = [], files = []} = vcsIgnore;
|
|
10
8
|
|
|
@@ -10,31 +10,35 @@ describe('gitignore lifter', () => {
|
|
|
10
10
|
const projectRoot = any.string();
|
|
11
11
|
const ignoredDirectories = any.listOf(any.word);
|
|
12
12
|
const ignoredFiles = any.listOf(any.word);
|
|
13
|
+
const logger = {info: () => undefined};
|
|
13
14
|
|
|
14
15
|
it('should append the provided ignores to the gitignore file', async () => {
|
|
15
|
-
expect(
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
expect(await liftGitIgnore(
|
|
17
|
+
{projectRoot, results: {vcsIgnore: {directories: ignoredDirectories, files: ignoredFiles}}},
|
|
18
|
+
{logger}
|
|
19
|
+
)).toEqual({});
|
|
18
20
|
|
|
19
21
|
expect(appendToIgnores).toHaveBeenCalledWith({projectRoot, ignores: [...ignoredDirectories, ...ignoredFiles]});
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
it('should append provided directories to ignore', async () => {
|
|
23
|
-
expect(await liftGitIgnore(
|
|
24
|
-
|
|
25
|
+
expect(await liftGitIgnore(
|
|
26
|
+
{projectRoot, results: {vcsIgnore: {directories: ignoredDirectories}}},
|
|
27
|
+
{logger}
|
|
28
|
+
)).toEqual({});
|
|
25
29
|
|
|
26
30
|
expect(appendToIgnores).toHaveBeenCalledWith({projectRoot, ignores: ignoredDirectories});
|
|
27
31
|
});
|
|
28
32
|
|
|
29
33
|
it('should append provided directories to ignore', async () => {
|
|
30
|
-
expect(await liftGitIgnore({projectRoot, results: {vcsIgnore: {files: ignoredFiles}}}))
|
|
34
|
+
expect(await liftGitIgnore({projectRoot, results: {vcsIgnore: {files: ignoredFiles}}}, {logger}))
|
|
31
35
|
.toEqual({});
|
|
32
36
|
|
|
33
37
|
expect(appendToIgnores).toHaveBeenCalledWith({projectRoot, ignores: ignoredFiles});
|
|
34
38
|
});
|
|
35
39
|
|
|
36
40
|
it('should not update the ignore file if no additional ignores are provided', async () => {
|
|
37
|
-
expect(await liftGitIgnore({projectRoot, results: {}})).toEqual({});
|
|
41
|
+
expect(await liftGitIgnore({projectRoot, results: {}}, {logger})).toEqual({});
|
|
38
42
|
|
|
39
43
|
expect(appendToIgnores).not.toHaveBeenCalledWith({projectRoot});
|
|
40
44
|
});
|
package/src/lifter.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {scaffold as scaffoldAttributes} from './attributes/index.js';
|
|
2
2
|
import {lift as liftIgnore} from './ignore/index.js';
|
|
3
3
|
|
|
4
|
-
export default async function liftGit({projectRoot, results}) {
|
|
4
|
+
export default async function liftGit({projectRoot, results}, dependencies) {
|
|
5
5
|
await Promise.all([
|
|
6
6
|
scaffoldAttributes({projectRoot}),
|
|
7
|
-
liftIgnore({projectRoot, results})
|
|
7
|
+
liftIgnore({projectRoot, results}, dependencies)
|
|
8
8
|
]);
|
|
9
9
|
|
|
10
10
|
return {};
|
package/src/lifter.test.js
CHANGED
|
@@ -12,11 +12,12 @@ describe('git lifter', () => {
|
|
|
12
12
|
it('should define the attributes file', async () => {
|
|
13
13
|
const projectRoot = any.string();
|
|
14
14
|
const results = any.simpleObject();
|
|
15
|
+
const dependencies = any.simpleObject();
|
|
15
16
|
|
|
16
|
-
const result = await lift({projectRoot, results});
|
|
17
|
+
const result = await lift({projectRoot, results}, dependencies);
|
|
17
18
|
|
|
18
19
|
expect(result).toEqual({});
|
|
19
20
|
expect(scaffoldAttributes).toHaveBeenCalledWith({projectRoot});
|
|
20
|
-
expect(liftIgnore).toHaveBeenCalledWith({projectRoot, results});
|
|
21
|
+
expect(liftIgnore).toHaveBeenCalledWith({projectRoot, results}, dependencies);
|
|
21
22
|
});
|
|
22
23
|
});
|
package/src/scaffolder.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import simpleGit from 'simple-git';
|
|
2
|
-
import {info} from '@travi/cli-messages';
|
|
3
2
|
|
|
4
3
|
import {scaffold as scaffoldIgnore} from './ignore/index.js';
|
|
5
4
|
|
|
6
|
-
export default async function scaffoldGit({projectRoot}) {
|
|
7
|
-
info('Initializing Git Repository');
|
|
5
|
+
export default async function scaffoldGit({projectRoot}, {logger}) {
|
|
6
|
+
logger.info('Initializing Git Repository');
|
|
8
7
|
|
|
9
8
|
const git = simpleGit({baseDir: projectRoot});
|
|
10
9
|
|
package/src/scaffolder.test.js
CHANGED
|
@@ -16,9 +16,10 @@ describe('scaffold', () => {
|
|
|
16
16
|
it('should initialize the repo', async () => {
|
|
17
17
|
const projectRoot = any.string();
|
|
18
18
|
const init = vi.fn();
|
|
19
|
+
const logger = {info: () => undefined};
|
|
19
20
|
when(simpleGit.simpleGit).calledWith({baseDir: projectRoot}).thenReturn({init});
|
|
20
21
|
|
|
21
|
-
const results = await scaffold({projectRoot});
|
|
22
|
+
const results = await scaffold({projectRoot}, {logger});
|
|
22
23
|
|
|
23
24
|
expect(results).toEqual({});
|
|
24
25
|
expect(init).toHaveBeenCalled();
|