standard-tools
v1.1.0
Published
Predefined standards to use across all new project repositories
Downloads
1
Readme
Lazy init
Predefined standards to use across all new project repositories
Tools
- .gitignore
- package.json
- Prettier
- ESLint
- Hooks
- Typescript
- commitlint
- lint-staged
- Renovate*
- CI (
- prepare
- linting
- test
- build
- deploy
- synchronize )
- Readme
- Jest*
Commands
git init
curl -L "https://gitlab.goodgamestudios.com/lazy-init/-/blob/master/.gitignore" > ".gitignore"
npm init -y
mkdir src
npm i @goodgamestudios/standard-tools -D
Prettier
- npm i prettier -D
- echo "@goodgamestudios/standard-tools/prettier" > .prettierrc.json
- curl -L "https://gitlab.goodgamestudios.com/lazy-init/-/blob/master/.prettierignore" > .prettierignore
Eslint
npm i eslint -D (Not sure if this is needed when using npm link) To be able to extend eslint rules, we need to create an package called "@scope/eslint-config*", it's a naming convention from eslint that need to be followed
npm link @goodgamestudios/eslint-config Does it create the eslintrc.json? if not
curl -L "https://gitlab.goodgamestudios.com/lazy-init/-/blob/master/.eslintrc.json" > .eslintrc.json
Default npm scripts:
"scripts": {
"--------------- Generic scripts ---------------": "----------------------------------------------------------",
"clean": "rimraf dist/",
"build": "TODO...",
"deploy": "standard-version --prerelease $ENV && TODO...",
"test": "jest --coverage",
"--------------- build & deploy scripts ---------------": "---------------------------------------------------",
"serve": "npm run clean && cross-env NODE_ENV=dev TODO...",
"build:dev": "cross-env-shell ENV=dev NODE_ENV=dev \"npm run clean && npm run build\" ",
"deploy:dev": "cross-env ENV=dev npm run deploy",
"build:staging": "cross-env-shell ENV=staging NODE_ENV=staging \"npm run clean && npm run build\" ",
"deploy:staging": "cross-env ENV=staging npm run deploy",
"build:production": "cross-env-shell ENV=production NODE_ENV=production \"npm run clean && npm run build\" ",
"deploy:production": "standard-version && TODO...",
"--------------- ci deployment ---------------": "------------------------------------------------------------",
"ci:deploy:dev": "npm run build:dev && npm run deploy:dev",
"ci:deploy:staging": "npm run build:staging && npm run deploy:staging",
"ci:deploy:production": "npm run build:production && npm run deploy:production",
"--------------- formatting ---------------": "---------------------------------------------------------------",
"lint": "eslint \"**/*.{ts,tsx}\"",
"lint:fix": "npm run lint -- --fix",
"prettier": "prettier --check .",
"prettier:fix": "npm run prettier -- --write"
}
npm pkg set "scripts"='{ "--------------- Generic scripts ---------------": "----------------------------------------------------------", "clean": "rimraf dist/", "build": "TODO...", "deploy": "standard-version --prerelease $ENV && TODO...", "test": "jest --coverage", "--------------- build & deploy scripts ---------------": "---------------------------------------------------", "serve": "npm run clean && cross-env NODE_ENV=dev TODO...", "build:dev": "cross-env-shell ENV=dev NODE_ENV=dev \"npm run clean && npm run build\" ", "deploy:dev": "cross-env ENV=dev npm run deploy", "build:staging": "cross-env-shell ENV=staging NODE_ENV=staging \"npm run clean && npm run build\" ", "deploy:staging": "cross-env ENV=staging npm run deploy", "build:production": "cross-env-shell ENV=production NODE_ENV=production \"npm run clean && npm run build\" ", "deploy:production": "standard-version && TODO...", "--------------- ci deployment ---------------": "------------------------------------------------------------", "ci:deploy:dev": "npm run build:dev && npm run deploy:dev", "ci:deploy:staging": "npm run build:staging && npm run deploy:staging", "ci:deploy:production": "npm run build:production && npm run deploy:production", "--------------- formatting ---------------": "---------------------------------------------------------------", "lint": "eslint \"**/*.{ts,tsx}\"", "lint:fix": "npm run lint -- --fix", "prettier": "prettier --check .", "prettier:fix": "npm run prettier -- --write" }' --json
Add dev packages
- npm i -D
- rimraf
- cross-env
- standard-version (or semantic-release?)
- jest
- ts-jest
- simple-git-hooks
- lint-staged
- @commitlint/cli
- typescript
- ts-node
- @types/jest
- @types/node
npm i -D rimraf cross-env standard-version jest simple-git-hooks lint-staged @commitlint/cli typescript
Hooks
"simple-git-hooks": {
"pre-commit": "npx lint-staged",
"commit-msg": "npx commitlint --edit ",
"pre-push": "npm test"
}
npm pkg set "simple-git-hooks"='{ "pre-commit": "npx lint-staged", "commit-msg": "npx commitlint --edit ", "pre-push": "npm test" }' --json
git config core.hooksPath .git/hooks/
rm -rf .git/hooks
npx simple-git-hooks
Commitlint
"commitlint": {
"extends": [
"@goodgamestudios/standard-tools/commitlint"
]
}
npm pkg set "commitlint"='{ "extends": [ "@goodgamestudios/standard-tools/commitlint" ] }' --json
Lint staged
"lint-staged": {
"*.ts": [
"npm run prettier:fix",
"npm run lint:fix"
],
"*.md": [
"npm run prettier:fix"
]
}
npm pkg set "lint-staged"='{ "*.ts": [ "npm run prettier:fix", "npm run lint:fix" ], "*.md": [ "npm run prettier:fix" ] }' --json
typescript
echo '{ "extends": "@goodgamestudios/standard-tools/tsconfig" }' > tsconfig.json