@solid-soda/scripts
Advanced tools
| const { packageJson, deleteFiles } = require('mrm-core'); | ||
| const clear = ({ files, packageJsonPath } = {}) => { | ||
| if (Array.isArray(files) && files.length > 0) { | ||
| deleteFiles(files); | ||
| } | ||
| if (packageJsonPath) { | ||
| packageJson().unset(packageJsonPath); | ||
| } | ||
| }; | ||
| module.exports = clear; |
+66
-87
| #!/usr/bin/env node | ||
| const spawn = require('cross-spawn') | ||
| const spawn = require('cross-spawn'); | ||
| const inquirer = require('inquirer'); | ||
| const chalk = require('chalk'); | ||
| const { version } = require('../package.json') | ||
| print = (text = '', color = (v) => v) => console.log(color(`${text}`)) | ||
| const { version } = require('../package.json'); | ||
| const print = (text = '', color = (v) => v) => console.log(color(`${text}`)); | ||
| const getMrmArgs = (presets = []) => { | ||
| const configs = presets.map(preset => `--config:${preset}`) | ||
| const configs = presets.map((preset) => `--config:${preset}`); | ||
| const path = __dirname.replace('/bin', '') | ||
| const path = __dirname.replace('/bin', ''); | ||
| return [ | ||
| 'all', `--dir=${path}`, ...configs, | ||
| ] | ||
| } | ||
| return ['all', `--dir=${path}`, ...configs]; | ||
| }; | ||
| const spawnArgs = { stdio: 'inherit' } | ||
| const spawnArgs = { stdio: 'inherit' }; | ||
| const fullArgs = process.argv.join('') | ||
| const isNpx = fullArgs.includes('npm') && fullArgs.includes('npx') | ||
| const isDlx = fullArgs.includes('yarn') && (fullArgs.includes('berry') || fullArgs.includes('unplugged')) | ||
| const fullArgs = process.argv.join(''); | ||
| const isNpx = fullArgs.includes('npm') && fullArgs.includes('npx'); | ||
| const isDlx = | ||
| fullArgs.includes('yarn') && | ||
| (fullArgs.includes('berry') || fullArgs.includes('unplugged')); | ||
| const invoke = async () => { | ||
| print(`Hello, it is @solid-soda/scripts v${version}`, chalk.blue.bold) | ||
| print('We ask you a few questions for setup scripts in your project', chalk.blue) | ||
| print() | ||
| print(`Hello, it is @solid-soda/scripts v${version}`, chalk.blue.bold); | ||
| print( | ||
| 'We ask you a few questions for setup scripts in your project', | ||
| chalk.blue, | ||
| ); | ||
| print(); | ||
| const answers = await inquirer.prompt([ | ||
| const answers = await inquirer.prompt([ | ||
| { | ||
| type: 'checkbox', | ||
| message: 'Select your project properties', | ||
| name: 'additional', | ||
| choices: [ | ||
| { | ||
| type: 'checkbox', | ||
| message: 'Select your project properties', | ||
| name: 'additional', | ||
| choices: [ | ||
| { | ||
| name: 'Has some styles (like css, scss)', | ||
| value: 'styles' | ||
| }, | ||
| { | ||
| name: 'Can be released by git-tag', | ||
| value: 'release' | ||
| }, | ||
| ] | ||
| } | ||
| ]) | ||
| name: 'Has some styles (like css, scss)', | ||
| value: 'styles', | ||
| }, | ||
| { | ||
| name: 'Can be released by git-tag', | ||
| value: 'release', | ||
| }, | ||
| ], | ||
| }, | ||
| ]); | ||
| print() | ||
| print("Thank you! Let's start setup 🧉", chalk.blue) | ||
| print() | ||
| print(); | ||
| print("Thank you! Let's start setup 🧉", chalk.blue); | ||
| print(); | ||
| let globalMrm = false | ||
| if (!isNpx && !isDlx) { | ||
| print("Seems like you aren't using npx or yarn-dlx", chalk.yellow) | ||
| print("We install some utils to global scope, sorry", chalk.yellow) | ||
| let globalMrm = false; | ||
| if (!isNpx && !isDlx) { | ||
| print("Seems like you aren't using npx or yarn-dlx", chalk.yellow); | ||
| print('We install some utils to global scope, sorry', chalk.yellow); | ||
| spawn.sync( | ||
| 'npm', | ||
| [ | ||
| 'install', | ||
| '-g', | ||
| 'mrm', | ||
| ], | ||
| spawnArgs, | ||
| ) | ||
| globalMrm = true | ||
| spawn.sync('npm', ['install', '-g', 'mrm'], spawnArgs); | ||
| globalMrm = true; | ||
| print() | ||
| print('Utils installed globally', chalk.yellow) | ||
| print() | ||
| } | ||
| print(); | ||
| print('Utils installed globally', chalk.yellow); | ||
| print(); | ||
| } | ||
| print('Start scripts generation, it takes a few seconds...', chalk.blue) | ||
| print() | ||
| print('Start scripts generation, it takes a few seconds...', chalk.blue); | ||
| print(); | ||
| const mrmArgs = getMrmArgs(answers.additional) | ||
| const mrmArgs = getMrmArgs(answers.additional); | ||
| if (globalMrm) { | ||
| spawn.sync( | ||
| 'mrm', | ||
| mrmArgs, | ||
| spawnArgs, | ||
| ) | ||
| } | ||
| if (globalMrm) { | ||
| spawn.sync('mrm', mrmArgs, spawnArgs); | ||
| } | ||
| if (isDlx) { | ||
| spawn.sync( | ||
| 'yarn', | ||
| [ | ||
| 'dlx', 'mrm', ...mrmArgs, | ||
| ], | ||
| spawnArgs, | ||
| ) | ||
| } | ||
| if (isDlx) { | ||
| spawn.sync('yarn', ['dlx', 'mrm', ...mrmArgs], spawnArgs); | ||
| } | ||
| if (isNpx) { | ||
| spawn.sync( | ||
| 'npx', | ||
| [ | ||
| 'mrm', ...mrmArgs, | ||
| ], | ||
| spawnArgs, | ||
| ) | ||
| } | ||
| if (isNpx) { | ||
| spawn.sync('npx', ['mrm', ...mrmArgs], spawnArgs); | ||
| } | ||
| print() | ||
| print('All done, enjoy! 🥑', chalk.blue) | ||
| print() | ||
| } | ||
| print(); | ||
| print('All done, enjoy! 🥑', chalk.blue); | ||
| print(); | ||
| }; | ||
| invoke() | ||
| invoke(); |
+43
-162
@@ -11,356 +11,237 @@ # Changelog | ||
| + support `yarn@berry` 🦁 | ||
| + your configs is your configs, we don't hide them 🌚 | ||
| + nice CLI 🧉 | ||
| + totaly rewritten 🤓 | ||
| + no conflicts with other tools 👌 | ||
| - support `yarn@berry` 🦁 | ||
| - your configs is your configs, we don't hide them 🌚 | ||
| - nice CLI 🧉 | ||
| - totaly rewritten 🤓 | ||
| - no conflicts with other tools 👌 | ||
| ## [1.20.0](https://github.com/solid-soda/scripts/compare/v1.19.1...v1.20.0) (2020-04-09) | ||
| ### Features | ||
| * **commmon:** bump all deps ([9bd706b](https://github.com/solid-soda/scripts/commit/9bd706b391721e464694ee0916580d08b665e49b)) | ||
| - **commmon:** bump all deps ([9bd706b](https://github.com/solid-soda/scripts/commit/9bd706b391721e464694ee0916580d08b665e49b)) | ||
| ### [1.19.1](https://github.com/solid-soda/scripts/compare/v1.19.0...v1.19.1) (2020-02-20) | ||
| ### Bug Fixes | ||
| * **fixpack:** add more specific rule for lint-staged ([c43a893](https://github.com/solid-soda/scripts/commit/c43a893)) | ||
| - **fixpack:** add more specific rule for lint-staged ([c43a893](https://github.com/solid-soda/scripts/commit/c43a893)) | ||
| ## [1.19.0](https://github.com/solid-soda/scripts/compare/v1.18.0...v1.19.0) (2020-02-20) | ||
| ### Features | ||
| * **fixpack:** add fixing package.json ([42138ed](https://github.com/solid-soda/scripts/commit/42138ed)) | ||
| - **fixpack:** add fixing package.json ([42138ed](https://github.com/solid-soda/scripts/commit/42138ed)) | ||
| ## [1.18.0](https://github.com/solid-soda/scripts/compare/v1.17.0...v1.18.0) (2020-02-18) | ||
| ### Features | ||
| * **lint:** disable double cast for boolean ([50d52ce](https://github.com/solid-soda/scripts/commit/50d52ce)) | ||
| - **lint:** disable double cast for boolean ([50d52ce](https://github.com/solid-soda/scripts/commit/50d52ce)) | ||
| ## [1.17.0](https://github.com/solid-soda/scripts/compare/v1.16.1...v1.17.0) (2020-02-13) | ||
| ### Features | ||
| * **lint:** remove deprecated tslint bridge ([15cda49](https://github.com/solid-soda/scripts/commit/15cda49)) | ||
| - **lint:** remove deprecated tslint bridge ([15cda49](https://github.com/solid-soda/scripts/commit/15cda49)) | ||
| ### [1.16.1](https://github.com/solid-soda/scripts/compare/v1.16.0...v1.16.1) (2020-02-12) | ||
| ## [1.16.0](https://github.com/solid-soda/scripts/compare/v1.15.2...v1.16.0) (2020-02-12) | ||
| ### Features | ||
| * **lint:** add curly rule ([7f561b6](https://github.com/solid-soda/scripts/commit/7f561b6)) | ||
| - **lint:** add curly rule ([7f561b6](https://github.com/solid-soda/scripts/commit/7f561b6)) | ||
| ### [1.15.2](https://github.com/solid-soda/scripts/compare/v1.15.1...v1.15.2) (2020-01-03) | ||
| ### Bug Fixes | ||
| * **lint:** fix bug with unused vars in for-of loops ([ea26ffb](https://github.com/solid-soda/scripts/commit/ea26ffb)) | ||
| - **lint:** fix bug with unused vars in for-of loops ([ea26ffb](https://github.com/solid-soda/scripts/commit/ea26ffb)) | ||
| ### [1.15.1](https://github.com/solid-soda/scripts/compare/v1.15.0...v1.15.1) (2019-12-25) | ||
| ### Bug Fixes | ||
| * use peerDependencies for defining plugins ([d01e51d](https://github.com/solid-soda/scripts/commit/d01e51d)) | ||
| - use peerDependencies for defining plugins ([d01e51d](https://github.com/solid-soda/scripts/commit/d01e51d)) | ||
| ## [1.15.0](https://github.com/solid-soda/scripts/compare/v1.14.9...v1.15.0) (2019-12-11) | ||
| ### Features | ||
| * bump eslint stuff ([6e9d5cf](https://github.com/solid-soda/scripts/commit/6e9d5cf)) | ||
| - bump eslint stuff ([6e9d5cf](https://github.com/solid-soda/scripts/commit/6e9d5cf)) | ||
| ### [1.14.9](https://github.com/solid-soda/scripts/compare/v1.14.8...v1.14.9) (2019-11-13) | ||
| ### Bug Fixes | ||
| * **lint:** add more grouping options ([a3c57ba](https://github.com/solid-soda/scripts/commit/a3c57ba)) | ||
| - **lint:** add more grouping options ([a3c57ba](https://github.com/solid-soda/scripts/commit/a3c57ba)) | ||
| ### [1.14.8](https://github.com/solid-soda/scripts/compare/v1.14.7...v1.14.8) (2019-11-13) | ||
| ### Bug Fixes | ||
| * **lint:** fix grouping of internal modules ([87c62df](https://github.com/solid-soda/scripts/commit/87c62df)) | ||
| - **lint:** fix grouping of internal modules ([87c62df](https://github.com/solid-soda/scripts/commit/87c62df)) | ||
| ### [1.14.7](https://github.com/solid-soda/scripts/compare/v1.14.6...v1.14.7) (2019-09-14) | ||
| ### Bug Fixes | ||
| * **lint:** disable incorrect rule for sorting imports ([0b64171](https://github.com/solid-soda/scripts/commit/0b64171)) | ||
| - **lint:** disable incorrect rule for sorting imports ([0b64171](https://github.com/solid-soda/scripts/commit/0b64171)) | ||
| ### [1.14.6](https://github.com/solid-soda/scripts/compare/v1.14.5...v1.14.6) (2019-09-10) | ||
| ### [1.14.5](https://github.com/solid-soda/scripts/compare/v1.14.4...v1.14.5) (2019-08-28) | ||
| ### Bug Fixes | ||
| * **lint:** fix decorators parsing and add ignore to ts linting ([b380ec2](https://github.com/solid-soda/scripts/commit/b380ec2)) | ||
| - **lint:** fix decorators parsing and add ignore to ts linting ([b380ec2](https://github.com/solid-soda/scripts/commit/b380ec2)) | ||
| ### [1.14.4](https://github.com/solid-soda/scripts/compare/v1.14.3...v1.14.4) (2019-08-28) | ||
| ### Bug Fixes | ||
| * add miss path for import sorting ([09f06d6](https://github.com/solid-soda/scripts/commit/09f06d6)) | ||
| - add miss path for import sorting ([09f06d6](https://github.com/solid-soda/scripts/commit/09f06d6)) | ||
| ### [1.14.3](https://github.com/solid-soda/scripts/compare/v1.14.2...v1.14.3) (2019-08-27) | ||
| ### Bug Fixes | ||
| * add ignore files starts from double undescore ([cdd769e](https://github.com/solid-soda/scripts/commit/cdd769e)) | ||
| - add ignore files starts from double undescore ([cdd769e](https://github.com/solid-soda/scripts/commit/cdd769e)) | ||
| ### [1.14.2](https://github.com/solid-soda/scripts/compare/v1.14.1...v1.14.2) (2019-08-15) | ||
| ### Bug Fixes | ||
| * **lint:** add new path strat rule ([62b8bed](https://github.com/solid-soda/scripts/commit/62b8bed)) | ||
| - **lint:** add new path strat rule ([62b8bed](https://github.com/solid-soda/scripts/commit/62b8bed)) | ||
| ### [1.14.1](https://github.com/solid-soda/scripts/compare/v1.14.0...v1.14.1) (2019-08-15) | ||
| ### Bug Fixes | ||
| * **lint:** remove confusing rules ([93069a6](https://github.com/solid-soda/scripts/commit/93069a6)) | ||
| - **lint:** remove confusing rules ([93069a6](https://github.com/solid-soda/scripts/commit/93069a6)) | ||
| ## [1.14.0](https://github.com/solid-soda/scripts/compare/v1.13.4...v1.14.0) (2019-08-15) | ||
| ### Features | ||
| * **line:** ass new eslint rules ([24c7376](https://github.com/solid-soda/scripts/commit/24c7376)), closes [#10](https://github.com/solid-soda/scripts/issues/10) | ||
| * **lint:** add import sotring and grouping ([c5e1ad4](https://github.com/solid-soda/scripts/commit/c5e1ad4)), closes [#7](https://github.com/solid-soda/scripts/issues/7) | ||
| - **line:** ass new eslint rules ([24c7376](https://github.com/solid-soda/scripts/commit/24c7376)), closes [#10](https://github.com/solid-soda/scripts/issues/10) | ||
| - **lint:** add import sotring and grouping ([c5e1ad4](https://github.com/solid-soda/scripts/commit/c5e1ad4)), closes [#7](https://github.com/solid-soda/scripts/issues/7) | ||
| ### [1.13.4](https://github.com/solid-soda/scripts/compare/v1.13.3...v1.13.4) (2019-08-14) | ||
| ### Bug Fixes | ||
| * **lint:** fix using default eslint file ([c6de31a](https://github.com/solid-soda/scripts/commit/c6de31a)) | ||
| - **lint:** fix using default eslint file ([c6de31a](https://github.com/solid-soda/scripts/commit/c6de31a)) | ||
| ### [1.13.3](https://github.com/solid-soda/scripts/compare/v1.13.2...v1.13.3) (2019-08-14) | ||
| ### Bug Fixes | ||
| * ensure gitignore exist ([6b4977b](https://github.com/solid-soda/scripts/commit/6b4977b)), closes [#9](https://github.com/solid-soda/scripts/issues/9) | ||
| - ensure gitignore exist ([6b4977b](https://github.com/solid-soda/scripts/commit/6b4977b)), closes [#9](https://github.com/solid-soda/scripts/issues/9) | ||
| ### [1.13.2](https://github.com/solid-soda/scripts/compare/v1.13.1...v1.13.2) (2019-08-14) | ||
| ### Bug Fixes | ||
| * fix bug with nested dirs in gitignore ([9ecbd69](https://github.com/solid-soda/scripts/commit/9ecbd69)), closes [#26](https://github.com/solid-soda/scripts/issues/26) | ||
| - fix bug with nested dirs in gitignore ([9ecbd69](https://github.com/solid-soda/scripts/commit/9ecbd69)), closes [#26](https://github.com/solid-soda/scripts/issues/26) | ||
| ### [1.13.1](https://github.com/solid-soda/scripts/compare/v1.13.0...v1.13.1) (2019-08-14) | ||
| ### Bug Fixes | ||
| * **config:** fix eslint config for ide ([4e91569](https://github.com/solid-soda/scripts/commit/4e91569)) | ||
| - **config:** fix eslint config for ide ([4e91569](https://github.com/solid-soda/scripts/commit/4e91569)) | ||
| ## [1.13.0](https://github.com/solid-soda/scripts/compare/v1.12.8...v1.13.0) (2019-08-14) | ||
| ### Features | ||
| * **pretty:** add semicolons by prettier ([0a31d4f](https://github.com/solid-soda/scripts/commit/0a31d4f)) | ||
| - **pretty:** add semicolons by prettier ([0a31d4f](https://github.com/solid-soda/scripts/commit/0a31d4f)) | ||
| ### [1.12.8](https://github.com/solid-soda/scripts/compare/v1.12.7...v1.12.8) (2019-08-09) | ||
| ### [1.12.7](https://github.com/solid-soda/scripts/compare/v1.12.6...v1.12.7) (2019-08-06) | ||
| ### [1.12.6](https://github.com/solid-soda/scripts/compare/v1.12.5...v1.12.6) (2019-07-19) | ||
| ### Bug Fixes | ||
| * fix bug with one extension in path ([3e26a50](https://github.com/solid-soda/scripts/commit/3e26a50)) | ||
| - fix bug with one extension in path ([3e26a50](https://github.com/solid-soda/scripts/commit/3e26a50)) | ||
| ### [1.12.5](https://github.com/solid-soda/scripts/compare/v1.12.4...v1.12.5) (2019-07-01) | ||
| ### Bug Fixes | ||
| * **lint-staged:** fix bug with lint-staged and pre-push ([2b5b2fb](https://github.com/solid-soda/scripts/commit/2b5b2fb)) | ||
| - **lint-staged:** fix bug with lint-staged and pre-push ([2b5b2fb](https://github.com/solid-soda/scripts/commit/2b5b2fb)) | ||
| ### [1.12.4](https://github.com/solid-soda/scripts/compare/v1.12.3...v1.12.4) (2019-07-01) | ||
| ### Bug Fixes | ||
| * fix bug with linting ([64684f0](https://github.com/solid-soda/scripts/commit/64684f0)) | ||
| - fix bug with linting ([64684f0](https://github.com/solid-soda/scripts/commit/64684f0)) | ||
| ### [1.12.3](https://github.com/solid-soda/scripts/compare/v1.12.2...v1.12.3) (2019-06-28) | ||
| ### [1.12.2](https://github.com/solid-soda/scripts/compare/v1.12.1...v1.12.2) (2019-06-28) | ||
| ### [1.12.1](https://github.com/solid-soda/scripts/compare/v1.12.0...v1.12.1) (2019-06-28) | ||
| ## [1.12.0](https://github.com/solid-soda/scripts/compare/v1.11.15...v1.12.0) (2019-06-28) | ||
| ### Features | ||
| * **lint-staged:** make pre-commit hook faster and add pre-push hook ([485d159](https://github.com/solid-soda/scripts/commit/485d159)) | ||
| - **lint-staged:** make pre-commit hook faster and add pre-push hook ([485d159](https://github.com/solid-soda/scripts/commit/485d159)) | ||
| ### [1.11.15](https://github.com/solid-soda/scripts/compare/v1.11.14...v1.11.15) (2019-06-26) | ||
| ### [1.11.14](https://github.com/solid-soda/scripts/compare/v1.11.13...v1.11.14) (2019-06-26) | ||
| ### Bug Fixes | ||
| * **config:** change exacutive-depts rule from err to warn ([3f56d6d](https://github.com/solid-soda/scripts/commit/3f56d6d)) | ||
| - **config:** change exacutive-depts rule from err to warn ([3f56d6d](https://github.com/solid-soda/scripts/commit/3f56d6d)) | ||
| ### [1.11.13](https://github.com/solid-soda/scripts/compare/v1.11.12...v1.11.13) (2019-06-07) | ||
| ### Bug Fixes | ||
| * **lint-staged:** fix mess flags ([69c3e6e](https://github.com/solid-soda/scripts/commit/69c3e6e)) | ||
| - **lint-staged:** fix mess flags ([69c3e6e](https://github.com/solid-soda/scripts/commit/69c3e6e)) | ||
| ### [1.11.12](https://github.com/solid-soda/scripts/compare/v1.11.11...v1.11.12) (2019-06-07) | ||
| ### Bug Fixes | ||
| * **lint-staged:** fix lint on lint-staged ([eb4a938](https://github.com/solid-soda/scripts/commit/eb4a938)) | ||
| - **lint-staged:** fix lint on lint-staged ([eb4a938](https://github.com/solid-soda/scripts/commit/eb4a938)) | ||
| ### [1.11.11](https://github.com/solid-soda/scripts/compare/v1.11.10...v1.11.11) (2019-06-05) | ||
| ### Bug Fixes | ||
| * **lint-staged:** fix scripts config ([ae0b36a](https://github.com/solid-soda/scripts/commit/ae0b36a)) | ||
| - **lint-staged:** fix scripts config ([ae0b36a](https://github.com/solid-soda/scripts/commit/ae0b36a)) | ||
| ### [1.11.10](https://github.com/solid-soda/scripts/compare/v1.11.9...v1.11.10) (2019-06-05) | ||
| ### Bug Fixes | ||
| * **utils:** fix typing checking ([8567616](https://github.com/solid-soda/scripts/commit/8567616)) | ||
| * replace async fileRead by sync ([2bff26a](https://github.com/solid-soda/scripts/commit/2bff26a)) | ||
| - **utils:** fix typing checking ([8567616](https://github.com/solid-soda/scripts/commit/8567616)) | ||
| - replace async fileRead by sync ([2bff26a](https://github.com/solid-soda/scripts/commit/2bff26a)) | ||
| ### [1.11.9](https://github.com/solid-soda/scripts/compare/v1.11.8...v1.11.9) (2019-06-05) | ||
| ### Bug Fixes | ||
| * **prettier:** fix typo ([e805638](https://github.com/solid-soda/scripts/commit/e805638)) | ||
| - **prettier:** fix typo ([e805638](https://github.com/solid-soda/scripts/commit/e805638)) | ||
| ### [1.11.8](https://github.com/solid-soda/scripts/compare/v1.11.7...v1.11.8) (2019-06-05) | ||
| ### Bug Fixes | ||
| * **lint-staged:** fix lint-staged config generation ([8e4dda3](https://github.com/solid-soda/scripts/commit/8e4dda3)) | ||
| - **lint-staged:** fix lint-staged config generation ([8e4dda3](https://github.com/solid-soda/scripts/commit/8e4dda3)) | ||
| ### [1.11.7](https://github.com/solid-soda/scripts/compare/v1.11.6...v1.11.7) (2019-06-05) | ||
| ### Bug Fixes | ||
| * fix bug with broken lint-staged ([5ce5588](https://github.com/solid-soda/scripts/commit/5ce5588)) | ||
| * remove old lint-staged config ([24e6fd9](https://github.com/solid-soda/scripts/commit/24e6fd9)) | ||
| - fix bug with broken lint-staged ([5ce5588](https://github.com/solid-soda/scripts/commit/5ce5588)) | ||
| - remove old lint-staged config ([24e6fd9](https://github.com/solid-soda/scripts/commit/24e6fd9)) | ||
| ### [1.11.6](https://github.com/solid-soda/scripts/compare/v1.11.5...v1.11.6) (2019-06-05) | ||
@@ -367,0 +248,0 @@ |
+10
-12
| const { install, packageJson } = require('mrm-core'); | ||
| const generateExecuteScript = require('../utils/generateExecuteScript') | ||
| const withVersions = require('../utils/withVersions') | ||
| const generateExecuteScript = require('../utils/generateExecuteScript'); | ||
| const withVersions = require('../utils/withVersions'); | ||
| function task() { | ||
| install(...withVersions(['commitizen', 'cz-conventional-changelog'])); | ||
| install(...withVersions(['commitizen', 'cz-conventional-changelog'])); | ||
| packageJson() | ||
| .set('config.commitizen', | ||
| { | ||
| path: "cz-conventional-changelog" | ||
| } | ||
| ) | ||
| .setScript('commit', generateExecuteScript('git-cz')) | ||
| .save() | ||
| packageJson() | ||
| .set('config.commitizen', { | ||
| path: 'cz-conventional-changelog', | ||
| }) | ||
| .setScript('commit', generateExecuteScript('git-cz')) | ||
| .save(); | ||
| } | ||
@@ -21,2 +19,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
+23
-15
| const { install, packageJson } = require('mrm-core'); | ||
| const clearConfigs = require('../utils/clearConfigs') | ||
| const withVersions = require('../utils/withVersions') | ||
| const generateExecuteScript = require('../utils/generateExecuteScript') | ||
| const clear = require('../utils/clear'); | ||
| const withVersions = require('../utils/withVersions'); | ||
| const generateExecuteScript = require('../utils/generateExecuteScript'); | ||
| function task() { | ||
| clearConfigs({ | ||
| files: ['.commitlintrc', 'commitlint.config.js', '.commitlintrc.js', '.commitlintrc.json', '.commitlintrc.yml'], | ||
| packageJsonPath: 'commitlint', | ||
| }) | ||
| clear({ | ||
| files: [ | ||
| '.commitlintrc', | ||
| 'commitlint.config.js', | ||
| '.commitlintrc.js', | ||
| '.commitlintrc.json', | ||
| '.commitlintrc.yml', | ||
| ], | ||
| packageJsonPath: 'commitlint', | ||
| }); | ||
| install(...withVersions(['@commitlint/cli', '@commitlint/config-conventional'])); | ||
| install( | ||
| ...withVersions(['@commitlint/cli', '@commitlint/config-conventional']), | ||
| ); | ||
| packageJson() | ||
| .set('commitlint', { | ||
| extends: ['@commitlint/config-conventional'] | ||
| }) | ||
| .setScript('commit', generateExecuteScript('commit')) | ||
| .save() | ||
| packageJson() | ||
| .set('commitlint', { | ||
| extends: ['@commitlint/config-conventional'], | ||
| }) | ||
| .setScript('commit', generateExecuteScript('commit')) | ||
| .save(); | ||
| } | ||
@@ -25,2 +33,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
+13
-4
| { | ||
| "aliases": { | ||
| "all": ["migrate", "prettier", "commitlint", "commitizen", "husky", "eslint", "stylelint", "standard-version"] | ||
| } | ||
| } | ||
| "aliases": { | ||
| "all": [ | ||
| "migrate", | ||
| "prettier", | ||
| "commitlint", | ||
| "commitizen", | ||
| "husky", | ||
| "eslint", | ||
| "stylelint", | ||
| "standard-version" | ||
| ] | ||
| } | ||
| } |
| module.exports = { | ||
| plugins: ['unicorn', 'eslint-plugin-import-helpers'], | ||
| extends: ["airbnb-base", 'plugin:unicorn/recommended', "prettier"], | ||
| extends: ['airbnb-base', 'plugin:unicorn/recommended', 'prettier'], | ||
| rules: { | ||
| "no-undef": 0, | ||
| "unicorn/filename-case": 0, | ||
| "class-methods-use-this": 0, | ||
| "unicorn/prevent-abbreviations": 0, | ||
| "unicorn/prefer-query-selector": 0, | ||
| "unicorn/prefer-number-properties": 0, | ||
| "import/no-unresolved": 0, | ||
| "import/prefer-default-export": 0, | ||
| "import/extensions": 0, | ||
| 'no-undef': 0, | ||
| 'unicorn/filename-case': 0, | ||
| 'class-methods-use-this': 0, | ||
| 'unicorn/prevent-abbreviations': 0, | ||
| 'unicorn/prefer-query-selector': 0, | ||
| 'unicorn/prefer-number-properties': 0, | ||
| 'import/no-unresolved': 0, | ||
| 'import/prefer-default-export': 0, | ||
| 'import/extensions': 0, | ||
| 'import-helpers/order-imports': [ | ||
@@ -29,2 +29,2 @@ 'warn', | ||
| }, | ||
| }; | ||
| }; |
| module.exports = { | ||
| parser: 'babel-eslint', | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| legacyDecorators: true, | ||
| }, | ||
| ecmaVersion: 2018, | ||
| sourceType: 'module', | ||
| parser: 'babel-eslint', | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| legacyDecorators: true, | ||
| }, | ||
| }; | ||
| ecmaVersion: 2018, | ||
| sourceType: 'module', | ||
| }, | ||
| }; |
| module.exports = { | ||
| extends: ['plugin:react/recommended'], | ||
| plugins: ['react-hooks'], | ||
| settings: { | ||
| react: { | ||
| version: 'detect', | ||
| }, | ||
| extends: ['plugin:react/recommended'], | ||
| plugins: ['react-hooks'], | ||
| settings: { | ||
| react: { | ||
| version: 'detect', | ||
| }, | ||
| rules: { | ||
| 'react/prop-types': 0, | ||
| }, | ||
| }; | ||
| }, | ||
| rules: { | ||
| 'react/prop-types': 0, | ||
| }, | ||
| }; |
| module.exports = { | ||
| parser: '@typescript-eslint/parser', | ||
| parserOptions: { | ||
| ecmaVersion: 2018, | ||
| sourceType: 'module', | ||
| project: 'tsconfig.json', | ||
| }, | ||
| plugins: ['@typescript-eslint'], | ||
| rules: { | ||
| 'no-unused-vars': 0, | ||
| 'no-useless-constructor': 0, | ||
| 'no-empty-function': ['error', { allow: ['constructors'] }], | ||
| 'react/prop-types': 0, | ||
| }, | ||
| }; | ||
| parser: '@typescript-eslint/parser', | ||
| parserOptions: { | ||
| ecmaVersion: 2018, | ||
| sourceType: 'module', | ||
| project: 'tsconfig.json', | ||
| }, | ||
| plugins: ['@typescript-eslint'], | ||
| rules: { | ||
| 'no-unused-vars': 0, | ||
| 'no-useless-constructor': 0, | ||
| 'no-empty-function': ['error', { allow: ['constructors'] }], | ||
| 'react/prop-types': 0, | ||
| }, | ||
| }; |
+87
-56
| const { packageJson, json, install, uninstall, lines } = require('mrm-core'); | ||
| const { difference, merge } = require('lodash') | ||
| const { difference, merge } = require('lodash'); | ||
| const overwrite = require('../utils/overwrite') | ||
| const hasDependency = require('../utils/hasDependency') | ||
| const clearConfigs = require('../utils/clearConfigs') | ||
| const generateExecuteScript = require('../utils/generateExecuteScript') | ||
| const withVersions = require('../utils/withVersions') | ||
| const createExtString = require('../utils/createExtString') | ||
| const getDefaultIgnore = require('../utils/getDefaultIgnore') | ||
| const overwrite = require('../utils/overwrite'); | ||
| const hasDependency = require('../utils/hasDependency'); | ||
| const clear = require('../utils/clear'); | ||
| const generateExecuteScript = require('../utils/generateExecuteScript'); | ||
| const withVersions = require('../utils/withVersions'); | ||
| const createExtString = require('../utils/createExtString'); | ||
| const getDefaultIgnore = require('../utils/getDefaultIgnore'); | ||
| const baseConfig = require('./config/eslint-base'); | ||
| const jsConfig = require('./config/eslint-js'); | ||
| const tsConfig = require('./config/eslint-ts'); | ||
| const reactConfig = require('./config/eslint-react'); | ||
| const baseConfig = require('./config/eslint-base') | ||
| const jsConfig = require('./config/eslint-js') | ||
| const tsConfig = require('./config/eslint-ts') | ||
| const reactConfig = require('./config/eslint-react') | ||
| const baseDependencies = [ | ||
| 'eslint', | ||
| 'eslint-plugin-import', | ||
| 'eslint-config-airbnb-base', | ||
| 'eslint-plugin-import-helpers', | ||
| 'eslint-plugin-unicorn', | ||
| 'eslint-config-prettier', | ||
| 'eslint-import-resolver-node', | ||
| ]; | ||
| const jsDependencies = ['babel-eslint']; | ||
| const tsDependencies = [ | ||
| '@typescript-eslint/eslint-plugin', | ||
| '@typescript-eslint/parser', | ||
| ]; | ||
| const reactDependencies = ['eslint-plugin-react', 'eslint-plugin-react-hooks']; | ||
| const baseDependencies = ['eslint', 'eslint-plugin-import', 'eslint-config-airbnb-base', 'eslint-plugin-import-helpers', 'eslint-plugin-unicorn', 'eslint-config-prettier'] | ||
| const jsDependencies = ['babel-eslint'] | ||
| const tsDependencies = ['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser'] | ||
| const reactDependencies = ['eslint-plugin-react', 'eslint-plugin-react-hooks'] | ||
| const jsExtensions = ['js', 'jsx']; | ||
| const tsExtensions = ['ts', 'tsx']; | ||
| const jsExtensions = ['js', 'jsx'] | ||
| const tsExtensions = ['ts', 'tsx'] | ||
| function task() { | ||
| clearConfigs({ | ||
| files: ['.eslintrc.js', '.eslintrc.cjs', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json'], | ||
| packageJsonPath: 'eslintConfig' | ||
| }) | ||
| clear({ | ||
| files: [ | ||
| '.eslintrc.js', | ||
| '.eslintrc.cjs', | ||
| '.eslintrc.yaml', | ||
| '.eslintrc.yml', | ||
| '.eslintrc.json', | ||
| ], | ||
| packageJsonPath: 'eslintConfig', | ||
| }); | ||
| // prepare | ||
| const packageHasDependency = hasDependency(packageJson()) | ||
| // prepare | ||
| const packageHasDependency = hasDependency(packageJson()); | ||
| const hasTypeScript = packageHasDependency('typescript') | ||
| const languageConfig = hasTypeScript ? tsConfig : jsConfig | ||
| const languageDependencies = hasTypeScript ? tsDependencies : jsDependencies | ||
| const languageExtensions = hasTypeScript ? tsExtensions : jsExtensions | ||
| const hasTypeScript = packageHasDependency('typescript'); | ||
| const languageConfig = hasTypeScript ? tsConfig : jsConfig; | ||
| const languageDependencies = hasTypeScript ? tsDependencies : jsDependencies; | ||
| const languageExtensions = hasTypeScript ? tsExtensions : jsExtensions; | ||
| let additionalConfig = {} | ||
| const additionalDependencies = [] | ||
| let additionalConfig = {}; | ||
| const additionalDependencies = []; | ||
| const hasReact = packageHasDependency('react') | ||
| if (hasReact) { | ||
| additionalConfig = merge(additionalConfig, reactConfig) | ||
| additionalDependencies.push(...reactDependencies) | ||
| } | ||
| const hasReact = packageHasDependency('react'); | ||
| if (hasReact) { | ||
| additionalConfig = merge(additionalConfig, reactConfig); | ||
| additionalDependencies.push(...reactDependencies); | ||
| } | ||
| // generate config | ||
| overwrite(json, '.eslintrc') | ||
| .merge(baseConfig) | ||
| .merge(languageConfig) | ||
| .merge(additionalConfig) | ||
| .save() | ||
| // generate config | ||
| overwrite(json, '.eslintrc') | ||
| .merge(baseConfig) | ||
| .merge(languageConfig) | ||
| .merge(additionalConfig) | ||
| .save(); | ||
| overwrite(lines, '.eslintignore') | ||
| .add(getDefaultIgnore()) | ||
| .save(); | ||
| overwrite(lines, '.eslintignore').add(getDefaultIgnore()).save(); | ||
| // dependencies | ||
| const allDependencies = [...baseDependencies, ...jsDependencies, ...tsDependencies, ...reactDependencies] | ||
| const installDependencies = [...baseDependencies, ...languageDependencies, ...additionalDependencies] | ||
| // dependencies | ||
| const allDependencies = [ | ||
| ...baseDependencies, | ||
| ...jsDependencies, | ||
| ...tsDependencies, | ||
| ...reactDependencies, | ||
| ]; | ||
| const installDependencies = [ | ||
| ...baseDependencies, | ||
| ...languageDependencies, | ||
| ...additionalDependencies, | ||
| ]; | ||
| const uninstallDependencies = difference(allDependencies, installDependencies) | ||
| uninstall(uninstallDependencies) | ||
| const uninstallDependencies = difference( | ||
| allDependencies, | ||
| installDependencies, | ||
| ); | ||
| uninstall(uninstallDependencies); | ||
| install(...withVersions(installDependencies)); | ||
| install(...withVersions(installDependencies)); | ||
| // scripts | ||
| packageJson() | ||
| .setScript('lint:code', generateExecuteScript(`eslint "./**/*.${createExtString(languageExtensions)}"`)) | ||
| .save() | ||
| // scripts | ||
| packageJson() | ||
| .setScript( | ||
| 'lint:code', | ||
| generateExecuteScript( | ||
| `eslint "./**/*.${createExtString(languageExtensions)}"`, | ||
| ), | ||
| ) | ||
| .save(); | ||
| } | ||
@@ -76,2 +107,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
+26
-36
@@ -1,42 +0,32 @@ | ||
| const { install, packageJson, json } = require('mrm-core'); | ||
| const { install, packageJson } = require('mrm-core'); | ||
| const overwrite = require('../utils/overwrite') | ||
| const createExtString = require('../utils/createExtString') | ||
| const clearConfigs = require('../utils/clearConfigs') | ||
| const generateExecuteScript = require('../utils/generateExecuteScript') | ||
| const withVersions = require('../utils/withVersions') | ||
| const createExtString = require('../utils/createExtString'); | ||
| const clear = require('../utils/clear'); | ||
| const generateExecuteScript = require('../utils/generateExecuteScript'); | ||
| const withVersions = require('../utils/withVersions'); | ||
| const EXTS = ['tsx', 'ts', 'js', 'jsx', 'scss', 'css', 'js', 'json', 'md'] | ||
| const EXTS = ['tsx', 'ts', 'js', 'jsx', 'scss', 'css', 'js', 'json', 'md']; | ||
| function task() { | ||
| clearConfigs({ | ||
| files: ['.huskyrc.js', 'husky.config.js'], | ||
| clear({ | ||
| files: ['.huskyrc.js', 'husky.config.js'], | ||
| }); | ||
| clear({ | ||
| files: ['lint-staged.config.js', '.lintstagedrc'], | ||
| packageJsonPath: 'lint-staged', | ||
| }); | ||
| install(...withVersions(['husky', 'lint-staged'])); | ||
| packageJson() | ||
| .set('lint-staged', { | ||
| [`*.${createExtString(EXTS)}`]: [ | ||
| generateExecuteScript('prettier --write'), | ||
| ], | ||
| }) | ||
| clearConfigs({ | ||
| files: ['lint-staged.config.js', '.lintstagedrc'], | ||
| packageJsonPath: 'lint-staged' | ||
| .set('husky.hooks', { | ||
| 'pre-commit': generateExecuteScript('lint-staged'), | ||
| 'commit-msg': generateExecuteScript('commitlint -E HUSKY_GIT_PARAMS'), | ||
| }) | ||
| // dependencies | ||
| install(...withVersions(['husky', 'lint-staged'])); | ||
| // config | ||
| overwrite(json, '.lintstagedrc') | ||
| .merge({ | ||
| [`*.${createExtString(EXTS)}`]: [generateExecuteScript('prettier --write')], | ||
| }) | ||
| .save() | ||
| packageJson() | ||
| .set('lint-staged', { | ||
| [`*.${createExtString(EXTS)}`]: [generateExecuteScript('prettier --write')] | ||
| }) | ||
| .set('husky.hooks', | ||
| { | ||
| "pre-commit": generateExecuteScript("lint-staged"), | ||
| "commit-msg": generateExecuteScript("commitlint -E HUSKY_GIT_PARAMS") | ||
| } | ||
| ) | ||
| .save() | ||
| .save(); | ||
| } | ||
@@ -46,2 +36,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
+8
-10
| const { uninstall, packageJson, markdown } = require('mrm-core'); | ||
| const { version } = require('../package.json') | ||
| const { version } = require('../package.json'); | ||
| function task() { | ||
| uninstall('@solid-soda/scripts') | ||
| uninstall('@solid-soda/scripts'); | ||
| packageJson() | ||
| .removeScript('s') | ||
| .save() | ||
| packageJson().removeScript('s').save(); | ||
| const readme = markdown('README.md') | ||
| const readme = markdown('README.md'); | ||
| if (readme.exists()) { | ||
@@ -17,7 +16,6 @@ readme | ||
| 'https://github.com/solid-soda/scripts', | ||
| `Scripts sets up by @solid-soda/scripts v${version}` | ||
| `Scripts sets up by @solid-soda/scripts v${version}`, | ||
| ) | ||
| .save() | ||
| .save(); | ||
| } | ||
| } | ||
@@ -27,2 +25,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
+47
-3
| { | ||
| "name": "@solid-soda/scripts", | ||
| "version": "2.0.0-beta.19", | ||
| "version": "2.0.0", | ||
| "author": "Igor Kamyshev <igor@kamyshev.me>", | ||
@@ -19,3 +19,6 @@ "license": "MIT", | ||
| "prepare": "echo 'Already prepared'", | ||
| "lint:code": "echo 0" | ||
| "lint:code": "yarn eslint \"./**/*.{js,jsx}\"", | ||
| "pretty": "yarn prettier --write .", | ||
| "commit": "yarn git-cz", | ||
| "release": "yarn standard-version" | ||
| }, | ||
@@ -31,4 +34,45 @@ "preferUnplugged": true, | ||
| "devDependencies": { | ||
| "@yarnpkg/pnpify": "^2.0.0-rc.20" | ||
| "@commitlint/cli": "^8.3.5", | ||
| "@commitlint/config-conventional": "^8.3.4", | ||
| "@yarnpkg/pnpify": "^2.0.0-rc.20", | ||
| "babel-eslint": "^10.1.0", | ||
| "commitizen": "^4.0.4", | ||
| "cz-conventional-changelog": "^3.1.0", | ||
| "eslint": "^6.8.0", | ||
| "eslint-config-airbnb-base": "^14.1.0", | ||
| "eslint-config-prettier": "^6.10.1", | ||
| "eslint-import-resolver-node": "^0.3.3", | ||
| "eslint-plugin-import": "^2.20.2", | ||
| "eslint-plugin-import-helpers": "^1.0.2", | ||
| "eslint-plugin-unicorn": "^18.0.1", | ||
| "husky": "^4.2.5", | ||
| "lint-staged": "^10.1.3", | ||
| "prettier": "^2.0.4", | ||
| "standard-version": "^7.1.0" | ||
| }, | ||
| "prettier": { | ||
| "trailingComma": "all", | ||
| "singleQuote": true | ||
| }, | ||
| "commitlint": { | ||
| "extends": [ | ||
| "@commitlint/config-conventional" | ||
| ] | ||
| }, | ||
| "config": { | ||
| "commitizen": { | ||
| "path": "cz-conventional-changelog" | ||
| } | ||
| }, | ||
| "lint-staged": { | ||
| "*.{tsx,ts,js,jsx,scss,css,js,json,md}": [ | ||
| "yarn prettier --write" | ||
| ] | ||
| }, | ||
| "husky": { | ||
| "hooks": { | ||
| "pre-commit": "yarn lint-staged", | ||
| "commit-msg": "yarn commitlint -E HUSKY_GIT_PARAMS" | ||
| } | ||
| } | ||
| } |
+21
-15
@@ -1,18 +0,24 @@ | ||
| const { json, install, packageJson, lines } = require('mrm-core'); | ||
| const { install, packageJson, lines } = require('mrm-core'); | ||
| const overwrite = require('../utils/overwrite') | ||
| const clearConfigs = require('../utils/clearConfigs') | ||
| const generateExecuteScript = require('../utils/generateExecuteScript') | ||
| const withVersions = require('../utils/withVersions') | ||
| const getDefaultIgnore = require('../utils/getDefaultIgnore') | ||
| const overwrite = require('../utils/overwrite'); | ||
| const clear = require('../utils/clear'); | ||
| const generateExecuteScript = require('../utils/generateExecuteScript'); | ||
| const withVersions = require('../utils/withVersions'); | ||
| const getDefaultIgnore = require('../utils/getDefaultIgnore'); | ||
| function task() { | ||
| clearConfigs({ | ||
| files: ['.prettierrc', '.prettierrc.json', '.prettierrc.yml', '.prettierrc.yaml', '.prettierrc.js', 'prettier.config.js', '.prettierrc.toml'], | ||
| packageJsonPath: 'prettier' | ||
| }) | ||
| clear({ | ||
| files: [ | ||
| '.prettierrc', | ||
| '.prettierrc.json', | ||
| '.prettierrc.yml', | ||
| '.prettierrc.yaml', | ||
| '.prettierrc.js', | ||
| 'prettier.config.js', | ||
| '.prettierrc.toml', | ||
| ], | ||
| packageJsonPath: 'prettier', | ||
| }); | ||
| overwrite(lines, '.prettierignore') | ||
| .add(getDefaultIgnore()) | ||
| .save() | ||
| overwrite(lines, '.prettierignore').add(getDefaultIgnore()).save(); | ||
@@ -27,3 +33,3 @@ install(...withVersions(['prettier'])); | ||
| }) | ||
| .save() | ||
| .save(); | ||
| } | ||
@@ -33,2 +39,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
+16
-8
| # @solid-soda/scripts | ||
| [](https://github.com/solid-soda/scripts) | ||
| <img src="https://raw.githubusercontent.com/solid-soda/assets/master/logo.png" align="right" | ||
@@ -8,5 +10,5 @@ alt="Solid Soda logo" width="160" height="160"> | ||
| + **Zero-config.** Any tool is already configured for you. | ||
| + **Universal.** Supports TS, React, and can be used with any tech. | ||
| + **Uniform.** Config can be shared (all projects have the same configs). | ||
| - **Zero-config.** Any tool is already configured for you. | ||
| - **Universal.** Supports TS, React, and can be used with any tech. | ||
| - **Uniform.** Config can be shared (all projects have the same configs). | ||
@@ -35,2 +37,3 @@ ## TL;DR | ||
| If you use `yarn@berry`, just run: | ||
| ```sh | ||
@@ -41,2 +44,3 @@ yarn dlx @solid-soda/scripts | ||
| If you use `npm` of `yarn@classic`, just run: | ||
| ```sh | ||
@@ -49,12 +53,15 @@ npx @solid-soda/scripts | ||
| Some scripts will be added to your `package.json`: | ||
| + `commit` — runs Commitizen and allow create nice commit messages | ||
| + `pretty` — runs Prettier and format all code in the repo | ||
| + `lint:code` — runs ESLint and preform static analysis of code | ||
| - `commit` — runs Commitizen and allow create nice commit messages | ||
| - `pretty` — runs Prettier and format all code in the repo | ||
| - `lint:code` — runs ESLint and preform static analysis of code | ||
| If you have some styles in the repo, we will add extra script: | ||
| + `lint:styles` — runs Stylelint and preform static analysis of styles | ||
| - `lint:styles` — runs Stylelint and preform static analysis of styles | ||
| If you want to release repo by git-tags, we will add ont more script: | ||
| + `release` — runs Standard Version, updates CHANGELOG.md, bump version in `package.json` and created git-tag | ||
| - `release` — runs Standard Version, updates CHANGELOG.md, bump version in `package.json` and created git-tag | ||
| Also, this library sets up `lint-staged` (prettify all staged files), `Commitlint` (check commit messages by [Conventional Commits specifications](https://www.conventionalcommits.org/en/v1.0.0-beta.2/#specification)) and `Husky` (to run Prettier and Commitlint). | ||
@@ -67,2 +74,3 @@ | ||
| For example: | ||
| ```sh | ||
@@ -69,0 +77,0 @@ npx @solid-soda/scripts |
| const { install, packageJson } = require('mrm-core'); | ||
| const clearConfigs = require('../utils/clearConfigs') | ||
| const generateExecuteScript = require('../utils/generateExecuteScript') | ||
| const withVersions = require('../utils/withVersions') | ||
| const clear = require('../utils/clear'); | ||
| const generateExecuteScript = require('../utils/generateExecuteScript'); | ||
| const withVersions = require('../utils/withVersions'); | ||
| function task(params) { | ||
| if (!params.release) { | ||
| return | ||
| } | ||
| if (!params.release) { | ||
| return; | ||
| } | ||
| clearConfigs({ | ||
| files: ['.versionrc', '.versionrc.json', '.versionrc.js'], | ||
| packageJsonPath: 'standard-version', | ||
| }) | ||
| clear({ | ||
| files: ['.versionrc', '.versionrc.json', '.versionrc.js'], | ||
| packageJsonPath: 'standard-version', | ||
| }); | ||
| // dependencies | ||
| install(...withVersions(['standard-version'])); | ||
| install(...withVersions(['standard-version'])); | ||
| // scripts | ||
| packageJson() | ||
| .setScript('release', generateExecuteScript("standard-version")) | ||
| .save(); | ||
| packageJson() | ||
| .setScript('release', generateExecuteScript('standard-version')) | ||
| .save(); | ||
| } | ||
@@ -28,2 +26,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
@@ -7,2 +7,2 @@ module.exports = { | ||
| }, | ||
| }; | ||
| }; |
+37
-30
| const { json, install, packageJson, lines } = require('mrm-core'); | ||
| const overwrite = require('../utils/overwrite') | ||
| const createExtString = require('../utils/createExtString') | ||
| const clearConfigs = require('../utils/clearConfigs') | ||
| const generateExecuteScript = require('../utils/generateExecuteScript') | ||
| const withVersions = require('../utils/withVersions') | ||
| const getDefaultIgnore = require('../utils/getDefaultIgnore') | ||
| const overwrite = require('../utils/overwrite'); | ||
| const createExtString = require('../utils/createExtString'); | ||
| const clear = require('../utils/clear'); | ||
| const generateExecuteScript = require('../utils/generateExecuteScript'); | ||
| const withVersions = require('../utils/withVersions'); | ||
| const getDefaultIgnore = require('../utils/getDefaultIgnore'); | ||
| const baseConfig = require('./config/stylelint-base'); | ||
| const baseConfig = require('./config/stylelint-base') | ||
| const EXTS = ['css']; | ||
| const EXTS = ['css'] | ||
| function task(params) { | ||
| if (!params.styles) { | ||
| return | ||
| } | ||
| if (!params.styles) { | ||
| return; | ||
| } | ||
| clearConfigs({ | ||
| files: ['.stylelintrc.json', '.stylelintrc.yaml', '.stylelintrc.yml', '.stylelintrc.js', 'stylelint.config.js'], | ||
| packageJsonPath: 'stylelint', | ||
| }) | ||
| clear({ | ||
| files: [ | ||
| '.stylelintrc.json', | ||
| '.stylelintrc.yaml', | ||
| '.stylelintrc.yml', | ||
| '.stylelintrc.js', | ||
| 'stylelint.config.js', | ||
| ], | ||
| packageJsonPath: 'stylelint', | ||
| }); | ||
| // generate config | ||
| overwrite(json, '.stylelintrc') | ||
| .merge(baseConfig) | ||
| .save() | ||
| overwrite(json, '.stylelintrc').merge(baseConfig).save(); | ||
| overwrite(lines, '.eslintignore') | ||
| .add(getDefaultIgnore()) | ||
| .save(); | ||
| overwrite(lines, '.stylelintignore').add(getDefaultIgnore()).save(); | ||
| // dependencies | ||
| install(...withVersions(['stylelint', 'stylelint-config-recess-order', 'stylelint-config-recommended'])); | ||
| install( | ||
| ...withVersions([ | ||
| 'stylelint', | ||
| 'stylelint-config-recess-order', | ||
| 'stylelint-config-recommended', | ||
| ]), | ||
| ); | ||
| // scripts | ||
| packageJson() | ||
| .setScript('lint:styles', generateExecuteScript(`stylelint "./**/*.${createExtString(EXTS)}"`)) | ||
| .save() | ||
| packageJson() | ||
| .setScript( | ||
| 'lint:styles', | ||
| generateExecuteScript(`stylelint "./**/*.${createExtString(EXTS)}"`), | ||
| ) | ||
| .save(); | ||
| } | ||
@@ -44,2 +51,2 @@ | ||
| module.exports = task | ||
| module.exports = task; |
| const createExtString = (normal, ...additional) => { | ||
| const all = [...normal, ...additional]; | ||
| if (all.length === 1) { | ||
| return all[0]; | ||
| } | ||
| return `{${all.join(',')}}`; | ||
| }; | ||
| module.exports = createExtString; | ||
| const all = [...normal, ...additional]; | ||
| if (all.length === 1) { | ||
| return all[0]; | ||
| } | ||
| return `{${all.join(',')}}`; | ||
| }; | ||
| module.exports = createExtString; |
@@ -1,13 +0,13 @@ | ||
| const { yaml } = require('mrm-core') | ||
| const { yaml } = require('mrm-core'); | ||
| const generateExecuteScript = (command) => { | ||
| const isYarnBerryPackage = yaml('.yarnrc.yml').exists() | ||
| const isYarnBerryPackage = yaml('.yarnrc.yml').exists(); | ||
| if (isYarnBerryPackage) { | ||
| return `yarn ${command}` | ||
| } | ||
| if (isYarnBerryPackage) { | ||
| return `yarn ${command}`; | ||
| } | ||
| return command | ||
| } | ||
| return command; | ||
| }; | ||
| module.exports = generateExecuteScript | ||
| module.exports = generateExecuteScript; |
@@ -1,8 +0,11 @@ | ||
| const { lines } = require('mrm-core') | ||
| const { lines } = require('mrm-core'); | ||
| const getDefaultIgnore = () => [ | ||
| '.yarn', 'node_modules', '.pnp.js', '.vscode', | ||
| ...lines('.gitignore').get(), | ||
| ] | ||
| '.yarn', | ||
| 'node_modules', | ||
| '.pnp.js', | ||
| '.vscode', | ||
| ...lines('.gitignore').get(), | ||
| ]; | ||
| module.exports = getDefaultIgnore | ||
| module.exports = getDefaultIgnore; |
@@ -1,3 +0,7 @@ | ||
| const hasDependency = (package) => (dependency) => Boolean(package.get(`dependencies.${dependency}`) || package.get(`devDependencies.${dependency}`)) | ||
| const hasDependency = (packageFile) => (dependency) => | ||
| Boolean( | ||
| packageFile.get(`dependencies.${dependency}`) || | ||
| packageFile.get(`devDependencies.${dependency}`), | ||
| ); | ||
| module.exports = hasDependency | ||
| module.exports = hasDependency; |
| const overwrite = (creator, name) => { | ||
| const oldFile = creator(name) | ||
| const oldFile = creator(name); | ||
| oldFile.delete() | ||
| oldFile.delete(); | ||
| const newFile = creator(name) | ||
| const newFile = creator(name); | ||
| return newFile | ||
| } | ||
| return newFile; | ||
| }; | ||
| module.exports = overwrite | ||
| module.exports = overwrite; |
+28
-28
@@ -1,34 +0,34 @@ | ||
| const { pick } = require('lodash') | ||
| const { pick } = require('lodash'); | ||
| const PACKAGE_VERSIONS = { | ||
| 'commitizen': '^4.0.4', | ||
| 'cz-conventional-changelog': '^3.1.0', | ||
| '@commitlint/cli': '^8.3.5', | ||
| '@commitlint/config-conventional': '^8.3.4', | ||
| 'eslint': '^6.8.0', | ||
| 'eslint-plugin-import-helpers': '^1.0.2', | ||
| 'eslint-plugin-unicorn': '^18.0.1', | ||
| 'babel-eslint': '^10.1.0', | ||
| '@typescript-eslint/eslint-plugin': '^2.27.0', | ||
| '@typescript-eslint/parser': '^2.27.0', | ||
| 'eslint-plugin-react': '^7.19.0', | ||
| 'eslint-plugin-react-hooks': '^3.0.0', | ||
| 'eslint-plugin-import': '^2.20.2', | ||
| 'eslint-config-airbnb-base': '^14.1.0', | ||
| 'eslint-config-prettier': '^6.10.1', | ||
| 'husky': '^4.2.5', | ||
| 'lint-staged': '^10.1.3', | ||
| 'prettier': '^2.0.4', | ||
| 'standard-version': '^7.1.0', | ||
| 'stylelint': '^13.3.1', | ||
| 'stylelint-config-recess-order': '^2.0.4', | ||
| 'stylelint-config-recommended': '^3.0.0' | ||
| } | ||
| commitizen: '^4.0.4', | ||
| 'cz-conventional-changelog': '^3.1.0', | ||
| '@commitlint/cli': '^8.3.5', | ||
| '@commitlint/config-conventional': '^8.3.4', | ||
| eslint: '^6.8.0', | ||
| 'eslint-plugin-import-helpers': '^1.0.2', | ||
| 'eslint-plugin-unicorn': '^18.0.1', | ||
| 'babel-eslint': '^10.1.0', | ||
| '@typescript-eslint/eslint-plugin': '^2.27.0', | ||
| '@typescript-eslint/parser': '^2.27.0', | ||
| 'eslint-plugin-react': '^7.19.0', | ||
| 'eslint-plugin-react-hooks': '^3.0.0', | ||
| 'eslint-plugin-import': '^2.20.2', | ||
| 'eslint-config-airbnb-base': '^14.1.0', | ||
| 'eslint-config-prettier': '^6.10.1', | ||
| husky: '^4.2.5', | ||
| 'lint-staged': '^10.1.3', | ||
| prettier: '^2.0.4', | ||
| 'standard-version': '^7.1.0', | ||
| stylelint: '^13.3.1', | ||
| 'stylelint-config-recess-order': '^2.0.4', | ||
| 'stylelint-config-recommended': '^3.0.0', | ||
| }; | ||
| const withVersions = (packages) => { | ||
| const versions = pick(PACKAGE_VERSIONS, ...packages) | ||
| const versions = pick(PACKAGE_VERSIONS, ...packages); | ||
| return [packages, { versions }] | ||
| } | ||
| return [packages, { versions }]; | ||
| }; | ||
| module.exports = withVersions | ||
| module.exports = withVersions; |
| const { packageJson, deleteFiles } = require('mrm-core'); | ||
| const clearConfigs = ({ files, packageJsonPath } = {}) => { | ||
| if (Array.isArray(files) && files.length > 0) { | ||
| deleteFiles(files) | ||
| } | ||
| if (packageJsonPath) { | ||
| packageJson().unset(packageJsonPath) | ||
| } | ||
| } | ||
| module.exports = clearConfigs |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
41440
0.71%508
10.43%1
-50%78
11.43%17
1600%1
Infinity%