@form8ion/git 2.0.0 → 2.1.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 CHANGED
@@ -123,7 +123,7 @@ $ npm test
123
123
 
124
124
  [license-link]: LICENSE
125
125
 
126
- [license-badge]: https://img.shields.io/github/license/form8ion/git.svg
126
+ [license-badge]: https://img.shields.io/github/license/form8ion/git.svg?logo=opensourceinitiative
127
127
 
128
128
  [npm-link]: https://www.npmjs.com/package/@form8ion/git
129
129
 
package/lib/index.js CHANGED
@@ -1,17 +1,42 @@
1
1
  import simpleGit from 'simple-git';
2
2
  import { info } from '@travi/cli-messages';
3
- import { promises } from 'node:fs';
3
+ import { write, exists, read } from '@form8ion/ignore-file';
4
4
  import '@form8ion/core';
5
+ import { promises } from 'node:fs';
6
+
7
+ function writeGitIgnore({projectRoot, ignores}) {
8
+ return write({projectRoot, name: 'git', ignores});
9
+ }
10
+
11
+ function scaffoldIgnore ({projectRoot}) {
12
+ return writeGitIgnore({projectRoot, ignores: []});
13
+ }
14
+
15
+ function gitignoreExists({projectRoot} = {}) {
16
+ return exists({projectRoot, name: 'git'});
17
+ }
5
18
 
6
- function scaffoldIgnore ({projectRoot, files = [], directories = []}) {
7
- return promises.appendFile(`${projectRoot}/.gitignore`, `\n${directories.join('\n')}\n\n${files.join('\n')}`);
19
+ function readGitIgnore({projectRoot}) {
20
+ return read({projectRoot, name: 'git'});
21
+ }
22
+
23
+ async function appendToIgnoreFile({projectRoot, ignores}) {
24
+ let existingIgnores = [];
25
+
26
+ if (await gitignoreExists({projectRoot})) {
27
+ existingIgnores = await readGitIgnore({projectRoot});
28
+ }
29
+
30
+ await writeGitIgnore({projectRoot, ignores: [...existingIgnores, ...ignores]});
8
31
  }
9
32
 
10
33
  async function liftIgnore ({projectRoot, results: {vcsIgnore}}) {
11
34
  if (vcsIgnore) {
12
35
  info('Updating files and directories to be ignored from version control', {level: 'secondary'});
13
36
 
14
- await scaffoldIgnore({projectRoot, ...vcsIgnore});
37
+ const {directories = [], files = []} = vcsIgnore;
38
+
39
+ await appendToIgnoreFile({projectRoot, ignores: [...directories, ...files]});
15
40
  }
16
41
 
17
42
  return {};
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/ignore/writer.js","../src/ignore/lifter.js","../src/scaffolder.js","../src/tester.js","../src/attributes/scaffolder.js","../src/lifter.js"],"sourcesContent":["import {promises as fs} from 'node:fs';\n\nexport default function ({projectRoot, files = [], directories = []}) {\n return fs.appendFile(`${projectRoot}/.gitignore`, `\\n${directories.join('\\n')}\\n\\n${files.join('\\n')}`);\n}\n","import {info} from '@travi/cli-messages';\n\nimport writeIgnores from './writer.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 await writeIgnores({projectRoot, ...vcsIgnore});\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":["fs","writeIgnores"],"mappings":";;;;;AAEe,uBAAQ,EAAE,CAAC,WAAW,EAAE,KAAK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;;ACDe,qBAAc,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;AACvD,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;;;;"}
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,uBAAQ,EAAE,CAAC,WAAW,CAAC,EAAE;AACxC,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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2BAAQ,EAAE,CAAC,WAAW,CAAC,EAAE;AACxC,EAAE,OAAOC,QAAE,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC;AACrE;;ACDe,qBAAc,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE;AACvD,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,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": "2.0.0",
5
+ "version": "2.1.1",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": "^18.19.0 || ^20.9.0 || >=22.11.0"
@@ -52,9 +52,10 @@
52
52
  "access": "public",
53
53
  "provenance": true
54
54
  },
55
- "packageManager": "npm@11.0.0",
55
+ "packageManager": "npm@11.1.0+sha512.acf301ad9b9ddba948fcb72341e2f0fcae477f56a95cc2a092934d133a7461062633cefbf93d5934a3dc0768674e2edee9f04dcfcc4bb4c327ff0e3a7d552a1b",
56
56
  "dependencies": {
57
57
  "@form8ion/core": "^4.3.0",
58
+ "@form8ion/ignore-file": "^1.0.0",
58
59
  "@travi/cli-messages": "^1.1.1",
59
60
  "simple-git": "^3.25.0"
60
61
  },
@@ -71,7 +72,6 @@
71
72
  "cz-conventional-changelog": "3.3.0",
72
73
  "gherkin-lint": "4.2.4",
73
74
  "husky": "9.1.7",
74
- "jest-when": "3.7.0",
75
75
  "lockfile-lint": "4.14.0",
76
76
  "ls-engines": "0.9.3",
77
77
  "mock-fs": "5.4.1",
@@ -84,6 +84,7 @@
84
84
  "rollup": "4.32.1",
85
85
  "rollup-plugin-auto-external": "2.0.0",
86
86
  "testdouble": "3.20.2",
87
- "vitest": "3.0.4"
87
+ "vitest": "3.0.5",
88
+ "vitest-when": "0.6.0"
88
89
  }
89
90
  }