Skip to content

Commit

Permalink
test(scripts): Move scripts to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Oct 28, 2022
1 parent eead66d commit 10b4eae
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,50 @@ test-update:
help: ## Show this help.
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
q ($(wildcard ./project),)
NODE_MODULES = "../../../node_modules"
else
NODE_MODULES = "./project/node_modules"
endif

.PHONY: stylelint
stylelint:
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'

.PHONY: stylelint-overrides
stylelint-overrides:
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'

.PHONY: stylelint-fix
stylelint-fix:
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix

.PHONY: prettier
prettier:
$(NODE_MODULES)/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'

.PHONY: prettier-fix
prettier-fix:
$(NODE_MODULES)/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'

.PHONY: lint
lint:
$(NODE_MODULES)/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'

.PHONY: lint-fix
lint-fix:
$(NODE_MODULES)/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'

.PHONY: i18n
i18n:
rm -rf build/messages
NODE_ENV=development $(NODE_MODULES)/.bin/i18n --addon

.PHONY: cypress-run
cypress-run:
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run

.PHONY: cypress-open
cypress-open:
NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@
},
"scripts": {
"release": "release-it",
"release-major-beta": "release-it major --preRelease=beta",
"release-beta": "release-it --preRelease=beta",
"bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
"test": "make test",
"test:fix": "make test-update",
"pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix",
"stylelint": "if [ -d ./project ]; then ./project/node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'; else ../../../node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'; fi",
"stylelint:overrides": "if [ -d ./project ]; then ./project/node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'; else ../../../node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'; fi",
"stylelint:fix": "yarn stylelint --fix && yarn stylelint:overrides --fix",
"prettier": "if [ -d ./project ]; then ./project/node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'; else ../../../node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'; fi",
"prettier:fix": "if [ -d ./project ]; then ./project/node_modules/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'; else ../../../node_modules/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'; fi",
"lint": "if [ -d ./project ]; then ./project/node_modules/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'; else ../../../node_modules/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'; fi",
"lint:fix": "if [ -d ./project ]; then ./project/node_modules/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'; else ../../../node_modules/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'; fi",
"i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
"cypress:run": "if [ -d ./project ]; then NODE_ENV=development ./project/node_modules/cypress/bin/cypress run; else NODE_ENV=development ../../../node_modules/cypress/bin/cypress run; fi",
"cypress:open": "if [ -d ./project ]; then NODE_ENV=development ./project/node_modules/cypress/bin/cypress open; else NODE_ENV=development ../../../node_modules/cypress/bin/cypress open; fi"
"stylelint": "make stylelint",
"stylelint:overrides": "make stylelint-overrides",
"stylelint:fix": "make stylelint-fix",
"prettier": "make prettier",
"prettier:fix": "make prettier-fix",
"lint": "make lint",
"lint:fix": "make lint-fix",
"i18n": "make i18n",
"cypress:run": "make cypress-run",
"cypress:open": "make cypress-open"
}
}

0 comments on commit 10b4eae

Please sign in to comment.