Skip to content

Commit

Permalink
refactor(git): leverage extracted lifter for creating the attributes …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
travi committed Jun 29, 2024
1 parent cf7469f commit 835e9bf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"dependencies": {
"@form8ion/core": "^4.3.0",
"@form8ion/execa-wrapper": "^1.0.0",
"@form8ion/git": "^1.0.0-alpha.4",
"@form8ion/git": "^1.0.0-alpha.5",
"@form8ion/overridable-prompts": "^1.1.0",
"@form8ion/readme": "3.1.0",
"@form8ion/results-reporter": "^1.1.0",
Expand Down
8 changes: 3 additions & 5 deletions src/vcs/git/git.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {promises as fs} from 'node:fs';

import {simpleGit} from 'simple-git';
import hostedGitInfo from 'hosted-git-info';
import {info, warn} from '@travi/cli-messages';
import {scaffold as scaffoldGit} from '@form8ion/git';
import {lift as liftGit, scaffold as scaffoldGit} from '@form8ion/git';

import promptForVcsHostDetails from '../host/prompt.js';
import {questionNames} from '../../prompts/question-names.js';
Expand All @@ -13,7 +11,6 @@ function generateConfigFiles(projectRoot, ignore) {
info('Generating Git config files', {level: 'secondary'});

return Promise.all([
fs.writeFile(`${projectRoot}/.gitattributes`, '* text=auto'),
ignore ? liftIgnoreFile({projectRoot, results: {vcsIgnore: ignore}}) : undefined
].filter(Boolean));
}
Expand Down Expand Up @@ -99,7 +96,8 @@ export async function scaffold({projectRoot, ignore, origin}) {

const [remoteOriginResults] = await Promise.all([
defineRemoteOrigin(projectRoot, origin),
generateConfigFiles(projectRoot, ignore)
generateConfigFiles(projectRoot, ignore),
liftGit({projectRoot})
]);

return {nextSteps: [{summary: 'Commit scaffolded files'}, ...remoteOriginResults.nextSteps]};
Expand Down
5 changes: 2 additions & 3 deletions src/vcs/git/git.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {promises as fs} from 'node:fs';
import hostedGitInfo from 'hosted-git-info';
import * as simpleGit from 'simple-git';
import {scaffold as scaffoldGit} from '@form8ion/git';
import {lift as liftGit, scaffold as scaffoldGit} from '@form8ion/git';

import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import any from '@travi/any';
Expand Down Expand Up @@ -93,7 +92,7 @@ describe('git', () => {

const results = await scaffold({projectRoot, origin: {}});

expect(fs.writeFile).toHaveBeenCalledWith(`${projectRoot}/.gitattributes`, '* text=auto');
expect(liftGit).toHaveBeenCalledWith({projectRoot});
expect(scaffoldGit).not.toHaveBeenCalled();

expect(results.nextSteps).toEqual([{summary: 'Commit scaffolded files'}]);
Expand Down

0 comments on commit 835e9bf

Please sign in to comment.