Browse Source

Merge pull request #31 from beaussan/renovate/isomorphic-git-1.x

⬆️ Upgrade dependency isomorphic-git to v1
pull/30/head
Nicolas Beaussart 6 years ago
committed by GitHub
parent
commit
47e9b61009
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 24
      src/commands/add/prettier.ts
  3. 24
      src/commands/add/tailwind.ts
  4. 46
      src/utls/base-add-command.ts
  5. 26
      yarn.lock

2
package.json

@ -18,7 +18,7 @@
"colors": "1.4.0", "colors": "1.4.0",
"cosmiconfig": "6.0.0", "cosmiconfig": "6.0.0",
"gluegun": "4.1.2", "gluegun": "4.1.2",
"isomorphic-git": "0.78.5",
"isomorphic-git": "1.0.0",
"latest-version": "5.1.0", "latest-version": "5.1.0",
"prompts": "2.3.1", "prompts": "2.3.1",
"tslib": "1.11.0" "tslib": "1.11.0"

24
src/commands/add/prettier.ts

@ -2,7 +2,6 @@
import { BaseCommand } from '../../utls/base-command'; import { BaseCommand } from '../../utls/base-command';
import { system, filesystem } from 'gluegun'; import { system, filesystem } from 'gluegun';
import * as prompts from 'prompts'; import * as prompts from 'prompts';
import { add, commit } from 'isomorphic-git';
import { BaseAddCommand } from '../../utls/base-add-command'; import { BaseAddCommand } from '../../utls/base-add-command';
export default class Prettier extends BaseAddCommand { export default class Prettier extends BaseAddCommand {
@ -70,9 +69,8 @@ export default class Prettier extends BaseAddCommand {
await system.exec('yarn'); await system.exec('yarn');
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'package.json', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: 'package.json' });
await this.gitCommit({
message: ':wrench: add script and husky to package.json', message: ':wrench: add script and husky to package.json',
}); });
} }
@ -92,9 +90,8 @@ export default class Prettier extends BaseAddCommand {
}); });
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: '.prettierrc', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: '.prettierrc' });
await this.gitCommit({
message: ':wrench: add prettierrc config file', message: ':wrench: add prettierrc config file',
}); });
} }
@ -105,8 +102,7 @@ export default class Prettier extends BaseAddCommand {
if (shouldCommit) { if (shouldCommit) {
await this.gitAddUnstaged(); await this.gitAddUnstaged();
await commit({
dir: '.',
await this.gitCommit({
message: ':art: apply prettier style to project', message: ':art: apply prettier style to project',
}); });
} }
@ -160,9 +156,8 @@ export default class Prettier extends BaseAddCommand {
await filesystem.write(eslintPath, finalEslintConfig, { jsonIndent: 2 }); await filesystem.write(eslintPath, finalEslintConfig, { jsonIndent: 2 });
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: eslintFileName, dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: eslintFileName });
await this.gitCommit({
message: ':wrench: update eslint to use prettier', message: ':wrench: update eslint to use prettier',
}); });
} }
@ -207,9 +202,8 @@ export default class Prettier extends BaseAddCommand {
await filesystem.write(tslintPath, finalEslintConfig, { jsonIndent: 2 }); await filesystem.write(tslintPath, finalEslintConfig, { jsonIndent: 2 });
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'tslint.json', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: 'tslint.json' });
await this.gitCommit({
message: ':wrench: update tslint to use prettier', message: ':wrench: update tslint to use prettier',
}); });
} }

24
src/commands/add/tailwind.ts

@ -1,7 +1,6 @@
import { BaseCommand } from '../../utls/base-command'; import { BaseCommand } from '../../utls/base-command';
import { system, filesystem, patching } from 'gluegun'; import { system, filesystem, patching } from 'gluegun';
import * as prompts from 'prompts'; import * as prompts from 'prompts';
import { add, commit } from 'isomorphic-git';
import { BaseAddCommand } from '../../utls/base-add-command'; import { BaseAddCommand } from '../../utls/base-add-command';
export default class Tailwind extends BaseAddCommand { export default class Tailwind extends BaseAddCommand {
@ -50,9 +49,8 @@ export default class Tailwind extends BaseAddCommand {
await system.exec('yarn tailwindcss init --full'); await system.exec('yarn tailwindcss init --full');
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'tailwind.config.js', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: 'tailwind.config.js' });
await this.gitCommit({
message: ':wrench: add tailwind config file', message: ':wrench: add tailwind config file',
}); });
} }
@ -77,8 +75,8 @@ module.exports = {
); );
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'postcss.config.js', dir: '.' });
await commit({ dir: '.', message: ':wrench: add postcss config file' });
await this.gitAdd({ filepath: 'postcss.config.js' });
await this.gitCommit({ message: ':wrench: add postcss config file' });
} }
}); });
@ -95,8 +93,8 @@ module.exports = {
); );
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'src/css/tailwind.src.css', dir: '.' });
await commit({ dir: '.', message: ':wrench: add tailwind css file' });
await this.gitAdd({ filepath: 'src/css/tailwind.src.css' });
await this.gitCommit({ message: ':wrench: add tailwind css file' });
} }
}); });
@ -119,9 +117,8 @@ module.exports = {
await filesystem.write(packagePath, finalPackageJson, { jsonIndent: 2 }); await filesystem.write(packagePath, finalPackageJson, { jsonIndent: 2 });
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'package.json', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: 'package.json' });
await this.gitCommit({
message: ':wrench: add script for tailwind to package.json', message: ':wrench: add script for tailwind to package.json',
}); });
} }
@ -131,9 +128,8 @@ module.exports = {
await patching.append('.gitignore', '\n# ignore tailwind generated css\nsrc/tailwind.css'); await patching.append('.gitignore', '\n# ignore tailwind generated css\nsrc/tailwind.css');
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: '.gitignore', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: '.gitignore' });
await this.gitCommit({
message: ':see_no_evil: add generated tailwind to .gitignore', message: ':see_no_evil: add generated tailwind to .gitignore',
}); });
} }

46
src/utls/base-add-command.ts

@ -1,11 +1,9 @@
import { BaseCommand } from './base-command'; import { BaseCommand } from './base-command';
import { add, plugins, commit, config as gitConfig, statusMatrix } from 'isomorphic-git';
import { add, commit, setConfig, statusMatrix } from 'isomorphic-git';
import * as latestVersion from 'latest-version'; import * as latestVersion from 'latest-version';
import { filesystem, system } from 'gluegun'; import { filesystem, system } from 'gluegun';
import * as fs from 'fs'; import * as fs from 'fs';
plugins.set('fs', fs);
export abstract class BaseAddCommand extends BaseCommand { export abstract class BaseAddCommand extends BaseCommand {
static flags = { static flags = {
...BaseCommand.flags, ...BaseCommand.flags,
@ -20,12 +18,14 @@ export abstract class BaseAddCommand extends BaseCommand {
this.error('Missing config key git.email for git commits'); this.error('Missing config key git.email for git commits');
} }
try { try {
await gitConfig({
await setConfig({
fs,
dir: '.', dir: '.',
path: 'user.name', path: 'user.name',
value: config?.git?.user, value: config?.git?.user,
}); });
await gitConfig({
await setConfig({
fs,
dir: '.', dir: '.',
path: 'user.email', path: 'user.email',
value: config?.git?.email, value: config?.git?.email,
@ -33,14 +33,26 @@ export abstract class BaseAddCommand extends BaseCommand {
} catch { } catch {
this.error('Could not set git config. Maybe the command was not run in a git repository.'); this.error('Could not set git config. Maybe the command was not run in a git repository.');
} }
const changes = (await statusMatrix({ dir: '.', pattern: '**' })).filter(
([_, head, workdir]) => head !== workdir,
const changes = (await statusMatrix({ dir: '.', fs })).filter(
([, head, workdir]) => head !== workdir,
); );
if (changes.length > 0) { if (changes.length > 0) {
this.error('There is unsaved changed in the git repository, aborting'); this.error('There is unsaved changed in the git repository, aborting');
} }
} }
async gitAdd({ filepath, dir = '.' }: { filepath: string; dir?: string }) {
await add({ filepath, dir, fs });
}
async gitCommit({ message }: { message: string }) {
await commit({
dir: '.',
fs,
message,
});
}
hasDirPackageJson() { hasDirPackageJson() {
return filesystem.isFile(filesystem.path('.', 'package.json')); return filesystem.isFile(filesystem.path('.', 'package.json'));
} }
@ -62,10 +74,10 @@ export abstract class BaseAddCommand extends BaseCommand {
} }
async gitAddUnstaged() { async gitAddUnstaged() {
const commitsPromice = (await statusMatrix({ dir: '.', pattern: '**' }))
.filter(([_, head, workdir]) => head !== workdir)
const commitsPromice = (await statusMatrix({ dir: '.', fs }))
.filter(([, head, workdir]) => head !== workdir)
.map(arr => arr[0]) .map(arr => arr[0])
.map(filepath => add({ filepath, dir: '.' }));
.map(filepath => this.gitAdd({ filepath }));
await Promise.all(commitsPromice); await Promise.all(commitsPromice);
} }
@ -75,10 +87,9 @@ export abstract class BaseAddCommand extends BaseCommand {
const versionToInstall = await latestVersion(name); const versionToInstall = await latestVersion(name);
await system.exec(`yarn add -D ${name}@${versionToInstall}`); await system.exec(`yarn add -D ${name}@${versionToInstall}`);
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'package.json', dir: '.' });
await add({ filepath: 'yarn.lock', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: 'package.json' });
await this.gitAdd({ filepath: 'yarn.lock' });
await this.gitCommit({
message: `:heavy_plus_sign: add ${name}@${versionToInstall} as a dev dependency`, message: `:heavy_plus_sign: add ${name}@${versionToInstall} as a dev dependency`,
}); });
} }
@ -90,10 +101,9 @@ export abstract class BaseAddCommand extends BaseCommand {
const versionToInstall = await latestVersion(name); const versionToInstall = await latestVersion(name);
await system.exec(`yarn add ${name}@${versionToInstall}`); await system.exec(`yarn add ${name}@${versionToInstall}`);
if (shouldCommit) { if (shouldCommit) {
await add({ filepath: 'package.json', dir: '.' });
await add({ filepath: 'yarn.lock', dir: '.' });
await commit({
dir: '.',
await this.gitAdd({ filepath: 'package.json' });
await this.gitAdd({ filepath: 'yarn.lock' });
await this.gitCommit({
message: `:heavy_plus_sign: add ${name}@${versionToInstall} as a dependency`, message: `:heavy_plus_sign: add ${name}@${versionToInstall} as a dependency`,
}); });
} }

26
yarn.lock

@ -3998,11 +3998,6 @@ globals@^12.1.0:
dependencies: dependencies:
type-fest "^0.8.1" type-fest "^0.8.1"
globalyzer@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f"
integrity sha512-LeguVWaxgHN0MNbWC6YljNMzHkrCny9fzjmEUdnF1kQ7wATFD1RHFRqA1qxaX2tgxGENlcxjOflopBwj3YZiXA==
globby@11.0.0, globby@^11.0.0: globby@11.0.0, globby@^11.0.0:
version "11.0.0" version "11.0.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.0.tgz#56fd0e9f0d4f8fb0c456f1ab0dee96e1380bc154" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.0.tgz#56fd0e9f0d4f8fb0c456f1ab0dee96e1380bc154"
@ -4029,11 +4024,6 @@ globby@^10.0.1:
merge2 "^1.2.3" merge2 "^1.2.3"
slash "^3.0.0" slash "^3.0.0"
globrex@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==
gluegun@4.1.2: gluegun@4.1.2:
version "4.1.2" version "4.1.2"
resolved "https://registry.yarnpkg.com/gluegun/-/gluegun-4.1.2.tgz#75b887450de2ebdc6656b598e5942b9a33157d06" resolved "https://registry.yarnpkg.com/gluegun/-/gluegun-4.1.2.tgz#75b887450de2ebdc6656b598e5942b9a33157d06"
@ -4815,20 +4805,17 @@ isobject@^4.0.0:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0"
integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==
isomorphic-git@0.78.5:
version "0.78.5"
resolved "https://registry.yarnpkg.com/isomorphic-git/-/isomorphic-git-0.78.5.tgz#013f8f8c280b8e0f8bb10ffa251eb87e9bb1190b"
integrity sha512-LrF5t9x7RdFeg84NsYpZo9qF1MZeb56LpBm6Jv47qMjnWMv0Il/3wPTA8I/lUYywgVbvF/e7xypHauj5auKW3w==
isomorphic-git@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isomorphic-git/-/isomorphic-git-1.0.0.tgz#6220fd649bc56ea447c6e75fb76d175a8a6dfeb5"
integrity sha512-YwyHqWP8ZGgb3Ul3HOg1MKSXD52ogWI4V3r58ck+EGuGKyXJYjxEjCRXeFEqOX3cxZRxvRyS1nD2J4at/l6fLQ==
dependencies: dependencies:
async-lock "^1.1.0" async-lock "^1.1.0"
clean-git-ref "^2.0.1" clean-git-ref "^2.0.1"
crc-32 "^1.2.0" crc-32 "^1.2.0"
diff3 "0.0.3" diff3 "0.0.3"
git-apply-delta "0.0.7" git-apply-delta "0.0.7"
globalyzer "^0.1.4"
globrex "^0.1.2"
ignore "^5.1.4" ignore "^5.1.4"
marky "^1.2.1"
minimisted "^2.0.0" minimisted "^2.0.0"
pako "^1.0.10" pako "^1.0.10"
pify "^4.0.1" pify "^4.0.1"
@ -6021,11 +6008,6 @@ marked@^0.8.0:
resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.0.tgz#ec5c0c9b93878dc52dd54be8d0e524097bd81a99" resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.0.tgz#ec5c0c9b93878dc52dd54be8d0e524097bd81a99"
integrity sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ== integrity sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ==
marky@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/marky/-/marky-1.2.1.tgz#a3fcf82ffd357756b8b8affec9fdbf3a30dc1b02"
integrity sha512-md9k+Gxa3qLH6sUKpeC2CNkJK/Ld+bEz5X96nYwloqphQE0CKCVEKco/6jxEZixinqNdz5RFi/KaCyfbMDMAXQ==
meant@~1.0.1: meant@~1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/meant/-/meant-1.0.1.tgz#66044fea2f23230ec806fb515efea29c44d2115d" resolved "https://registry.yarnpkg.com/meant/-/meant-1.0.1.tgz#66044fea2f23230ec806fb515efea29c44d2115d"

Loading…
Cancel
Save