This file contains hidden or 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
import { | |
namedTypes as types, | |
} from 'ast-types' | |
import type { | |
Options as RecastOptions, | |
} from 'recast' | |
import type { | |
Transform, | |
FileInfo, | |
API, |
This file contains hidden or 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
{ | |
/** | |
* pegjs grammar: | |
* https://github.com/pegjs/pegjs/blob/7d13580855/docs/grammar/README.md | |
* https://github.com/pegjs/pegjs/blob/7d13580855/docs/grammar/action-execution-environment.md | |
* | |
* playground: https://pegjs.org/online | |
* | |
* > pegjs expression.pegjs -o parser.js --format es | |
*/ |
This file contains hidden or 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
sudo mdutil -a -i off | |
sudo mdutil -V /System/Volumes/Data/Applications -i on |
This file contains hidden or 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
git fetch --all | |
# 7 天内有多少 commit 改动了 package-lock | |
git log --format=format:'%h' --no-merges --since="7 days ago" --all -- package-lock.json | wc -l | |
# 7 天内所有 commit 共产生了多少完全无重复的 package-lock | |
git log --format=format:'%h' --no-merges --since="7 days ago" --all -- package-lock.json | \ | |
xargs -I{} git ls-tree {} package-lock.json | \ | |
sort | uniq | wc -l |
This file contains hidden or 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
git log --name-status --diff-filter=D <file / dir> |
This file contains hidden or 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
import path from 'path' | |
import SuperExpressive from 'super-expressive' | |
// https://gist.github.com/zthxxx/0328559c300874139e483240073b12e6 | |
const genImportRegex = ({ pathExpr, pathFollowedAssert }: { | |
/** | |
* path match expressive to captured for replace | |
* | |
* pathExpr need to include `.namedCapture('importPath')` |
This file contains hidden or 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
import { | |
namedTypes as types, | |
} from 'ast-types' | |
import type { | |
Options as RecastOptions, | |
} from 'recast' | |
import type { | |
Transform, | |
FileInfo, | |
API, |
This file contains hidden or 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
import typescript from 'typescript' | |
/** | |
* let { tsconfig, projectReferences, compilerOptions } = parseTsconfigFile() | |
* | |
* console.debug(tsconfig, projectReferences, compilerOptions) | |
*/ | |
const parseTsconfigFile = (tsconfigFile = './tsconfig.json') => { | |
const { config: tsconfigRaw } = typescript.readConfigFile(tsconfigFile, typescript.sys.readFile) |
This file contains hidden or 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
module.exports = ({ types: t }) => ({ | |
name: 'require-context', | |
visitor: { | |
CallExpression: path => { | |
if ( | |
t.isMemberExpression(path.node.callee, { computed: false }) | |
&& t.isIdentifier(path.get('callee').node.object, { name: 'require' }) | |
&& t.isIdentifier(path.get('callee').node.property, { name: 'context' }) | |
) { | |
path.replaceWith( |
This file contains hidden or 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
import path from 'path' | |
import { promises as fs } from 'fs' | |
import { camelCase } from 'lodash-es' | |
const [ , self, dir, mergeFlag] = process.argv | |
if (!dir) { | |
console.log(` | |
usage: | |
node ${path.relative(process.cwd(), self)} <target-dir> [--merge] |