-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate code base to TypeScript
- Loading branch information
Showing
35 changed files
with
13,113 additions
and
4,670 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
dist | ||
node_modules | ||
test-dist | ||
*.log | ||
/.yarn/* | ||
!/.yarn/plugins | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@1stg/lint-staged/tsc') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
coverage | ||
dist | ||
test-dist | ||
/.yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@1stg/simple-git-hooks') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,3 @@ | ||
#!/usr/bin/env node | ||
// ! warning: this file is only here for compatibility, you should change to use `dist/cli.js` directly instead | ||
|
||
'use strict' | ||
|
||
const chalk = require('chalk') | ||
const mri = require('mri') | ||
|
||
const prettyQuick = require('..').default | ||
|
||
const args = mri(process.argv.slice(2), { | ||
alias: { | ||
'resolve-config': 'resolveConfig', | ||
'ignore-path': 'ignorePath', | ||
}, | ||
}) | ||
|
||
const prettyQuickResult = prettyQuick( | ||
process.cwd(), | ||
Object.assign({}, args, { | ||
onFoundSinceRevision: (scm, revision) => { | ||
console.log( | ||
`🔍 Finding changed files since ${chalk.bold( | ||
scm, | ||
)} revision ${chalk.bold(revision)}.`, | ||
) | ||
}, | ||
|
||
onFoundChangedFiles: changedFiles => { | ||
console.log( | ||
`🎯 Found ${chalk.bold(changedFiles.length)} changed ${ | ||
changedFiles.length === 1 ? 'file' : 'files' | ||
}.`, | ||
) | ||
}, | ||
|
||
onPartiallyStagedFile: file => { | ||
console.log(`✗ Found ${chalk.bold('partially')} staged file ${file}.`) | ||
}, | ||
|
||
onWriteFile: file => { | ||
console.log(`✍️ Fixing up ${chalk.bold(file)}.`) | ||
}, | ||
|
||
onCheckFile: (file, isFormatted) => { | ||
if (!isFormatted) { | ||
console.log(`⛔️ Check failed: ${chalk.bold(file)}`) | ||
} | ||
}, | ||
|
||
onExamineFile: file => { | ||
console.log(`🔍 Examining ${chalk.bold(file)}.`) | ||
}, | ||
}), | ||
) | ||
|
||
if (prettyQuickResult.success) { | ||
console.log('✅ Everything is awesome!') | ||
} else { | ||
if (prettyQuickResult.errors.indexOf('PARTIALLY_STAGED_FILE') !== -1) { | ||
console.log( | ||
'✗ Partially staged files were fixed up.' + | ||
` ${chalk.bold('Please update stage before committing')}.`, | ||
) | ||
} | ||
if (prettyQuickResult.errors.indexOf('BAIL_ON_WRITE') !== -1) { | ||
console.log( | ||
'✗ File had to be prettified and prettyQuick was set to bail mode.', | ||
) | ||
} | ||
if (prettyQuickResult.errors.indexOf('CHECK_FAILED') !== -1) { | ||
console.log( | ||
'✗ Code style issues found in the above file(s). Forgot to run Prettier?', | ||
) | ||
} | ||
process.exit(1) // ensure git hooks abort | ||
} | ||
module.exports = require('../dist/cli') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@total-typescript/ts-reset' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env node | ||
|
||
import chalk from 'chalk' | ||
import mri from 'mri' | ||
|
||
import prettyQuick from '.' | ||
|
||
const args = mri(process.argv.slice(2), { | ||
alias: { | ||
'resolve-config': 'resolveConfig', | ||
'ignore-path': 'ignorePath', | ||
}, | ||
}) | ||
|
||
const prettyQuickResult = prettyQuick(process.cwd(), { | ||
...args, | ||
onFoundSinceRevision: (scm, revision) => { | ||
console.log( | ||
`🔍 Finding changed files since ${chalk.bold(scm)} revision ${chalk.bold( | ||
revision, | ||
)}.`, | ||
) | ||
}, | ||
|
||
onFoundChangedFiles: changedFiles => { | ||
console.log( | ||
`🎯 Found ${chalk.bold(changedFiles.length)} changed ${ | ||
changedFiles.length === 1 ? 'file' : 'files' | ||
}.`, | ||
) | ||
}, | ||
|
||
onPartiallyStagedFile: file => { | ||
console.log(`✗ Found ${chalk.bold('partially')} staged file ${file}.`) | ||
}, | ||
|
||
onWriteFile: file => { | ||
console.log(`✍️ Fixing up ${chalk.bold(file)}.`) | ||
}, | ||
|
||
onCheckFile: (file, isFormatted) => { | ||
if (!isFormatted) { | ||
console.log(`⛔️ Check failed: ${chalk.bold(file)}`) | ||
} | ||
}, | ||
|
||
onExamineFile: file => { | ||
console.log(`🔍 Examining ${chalk.bold(file)}.`) | ||
}, | ||
}) | ||
|
||
if (prettyQuickResult.success) { | ||
console.log('✅ Everything is awesome!') | ||
} else { | ||
if (prettyQuickResult.errors.includes('PARTIALLY_STAGED_FILE')) { | ||
console.log( | ||
'✗ Partially staged files were fixed up.' + | ||
` ${chalk.bold('Please update stage before committing')}.`, | ||
) | ||
} | ||
if (prettyQuickResult.errors.includes('BAIL_ON_WRITE')) { | ||
console.log( | ||
'✗ File had to be prettified and prettyQuick was set to bail mode.', | ||
) | ||
} | ||
if (prettyQuickResult.errors.includes('CHECK_FAILED')) { | ||
console.log( | ||
'✗ Code style issues found in the above file(s). Forgot to run Prettier?', | ||
) | ||
} | ||
// eslint-disable-next-line n/no-process-exit | ||
process.exit(1) // ensure git hooks abort | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable unicorn/filename-case */ | ||
|
||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
import ignore from 'ignore' | ||
|
||
export default (directory: string, filename = '.prettierignore') => { | ||
const file = path.join(directory, filename) | ||
|
||
if (fs.existsSync(file)) { | ||
const text = fs.readFileSync(file, 'utf8') | ||
const filter = ignore().add(text).createFilter() | ||
return (filepath: string) => filter(path.join(filepath)) | ||
} | ||
|
||
return () => true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
/* eslint-disable unicorn/filename-case */ | ||
|
||
import path from 'path' | ||
|
||
import multimatch from 'multimatch' | ||
const path = require('path') | ||
|
||
export default pattern => { | ||
export default (pattern: string[] | string | undefined) => { | ||
// Match everything if no pattern was given | ||
if (typeof pattern !== 'string' && !Array.isArray(pattern)) { | ||
return () => true | ||
} | ||
const patterns = Array.isArray(pattern) ? pattern : [pattern] | ||
return file => | ||
return (file: string) => | ||
multimatch(path.normalize(file), patterns, { dot: true }).length > 0 | ||
} |
Oops, something went wrong.