From 65b9ec0d538e44a85328d26928ee290d86d98aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 23 Mar 2020 03:53:33 +0100 Subject: [PATCH] fix(node): Drop Node 4-9 (require Node 10) (#20) BREAKING CHANGE: Requires Node>=10 --- .all-contributorsrc | 13 +-- .gitattributes | 3 +- .github/ISSUE_TEMPLATE.md | 6 +- .github/PULL_REQUEST_TEMPLATE.md | 10 +- .gitignore | 3 - .huskyrc.js | 1 + .npmrc | 3 +- .prettierignore | 5 + .prettierrc.js | 1 + .travis.yml | 23 ++++- CHANGELOG.md | 5 +- CONTRIBUTING.md | 51 +++-------- README.md | 106 +++++++++++++--------- jest.config.js | 9 +- lint-staged.config.js | 9 +- other/CODE_OF_CONDUCT.md | 45 ++++----- other/MAINTAINING.md | 77 +++++++++------- other/manual-releases.md | 9 +- other/snap-to-readme.js | 11 +-- package.json | 46 ++++++---- src/__tests__/__snapshots__/macro.js.snap | 9 +- src/__tests__/macro.js | 5 +- src/macro.js | 18 +++- 23 files changed, 256 insertions(+), 212 deletions(-) create mode 100644 .huskyrc.js create mode 100644 .prettierignore create mode 100644 .prettierrc.js diff --git a/.all-contributorsrc b/.all-contributorsrc index b3bc652..14498f9 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,11 +1,15 @@ { "projectName": "import-all.macro", "projectOwner": "kentcdodds", + "imageSize": 100, + "commit": false, + "contributorsPerLine": 7, + "repoHost": "https://github.com", + "repoType": "github", + "skipCi": false, "files": [ "README.md" ], - "imageSize": 100, - "commit": false, "contributors": [ { "login": "kentcdodds", @@ -47,8 +51,5 @@ "fundingFinding" ] } - ], - "repoType": "github", - "repoHost": "https://github.com", - "contributorsPerLine": 7 + ] } diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 5771c02..e4b7e11 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -11,9 +11,9 @@ never done that before, that's great! Check this free short video tutorial to learn how: http://kcd.im/pull-request --> -* `import-all.macro` version: -* `node` version: -* `npm` (or `yarn`) version: +- `import-all.macro` version: +- `node` version: +- `npm` (or `yarn`) version: Relevant code or config diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index aa0dc2b..ee765cc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -34,9 +34,11 @@ merge of your pull request! -* [ ] Documentation -* [ ] Tests -* [ ] Ready to be merged -* [ ] Added myself to contributors table +- [ ] Documentation +- [ ] Tests +- [ ] Ready to be merged + +- [ ] Added myself to contributors table + diff --git a/.gitignore b/.gitignore index 09048d2..8e0c70c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ node_modules coverage dist -.opt-in -.opt-out .DS_Store -.eslintcache # these cause more harm than good # when working with contributors diff --git a/.huskyrc.js b/.huskyrc.js new file mode 100644 index 0000000..5e45c45 --- /dev/null +++ b/.huskyrc.js @@ -0,0 +1 @@ +module.exports = require('kcd-scripts/husky') diff --git a/.npmrc b/.npmrc index d272289..1e23fdf 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1 @@ -registry=http://registry.npmjs.org/ -package-lock=false +registry=http://registry.npmjs.org diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..e2e13ed --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +node_modules +coverage +dist + +_package.json diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..4679d9b --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require('kcd-scripts/prettier') diff --git a/.travis.yml b/.travis.yml index 2e14c66..30fa818 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,22 @@ -sudo: false language: node_js +cache: npm notifications: email: false -node_js: '8' -script: npm run validate -after_success: kcd-scripts travis-after-success +node_js: + - 10.0.0 + - 12 + - node +install: npm install +script: + - npm run validate + - npx codecov@3 branches: - only: master + only: + - master + - beta + +jobs: + include: + - stage: release + node_js: 12 + script: kcd-scripts travis-release diff --git a/CHANGELOG.md b/CHANGELOG.md index 06d221a..2a67529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # CHANGELOG -The changelog is automatically updated using [semantic-release](https://github.com/semantic-release/semantic-release). -You can see it on the [releases page](../../releases). +The changelog is automatically updated using +[semantic-release](https://github.com/semantic-release/semantic-release). You +can see it on the [releases page](../../releases). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d95219..3011965 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,8 +2,8 @@ Thanks for being willing to contribute! -**Working on your first Pull Request?** You can learn how from this _free_ series -[How to Contribute to an Open Source Project on GitHub][egghead] +**Working on your first Pull Request?** You can learn how from this _free_ +series [How to Contribute to an Open Source Project on GitHub][egghead] ## Project setup @@ -16,50 +16,22 @@ Thanks for being willing to contribute! > pull requests from branches on your fork. To do this, run: > > ``` -> git remote add upstream https://github.com/kentcdodds/import-all.macro.git +> git remote add upstream https://github.com/kentcdodds/import-all.macro > git fetch upstream > git branch --set-upstream-to=upstream/master master > ``` > -> This will add the original repository as a "remote" called "upstream," -> Then fetch the git information from that remote, then set your local `master` -> branch to use the upstream master branch whenever you run `git pull`. -> Then you can make all of your pull request branches based on this `master` -> branch. Whenever you want to update your version of `master`, do a regular -> `git pull`. - -## Add yourself as a contributor - -This project follows the [all contributors][all-contributors] specification. -To add yourself to the table of contributors on the `README.md`, please use the -automated script as part of your PR: - -```console -npm run add-contributor -``` - -Follow the prompt and commit `.all-contributorsrc` and `README.md` in the PR. -If you've already added yourself to the list and are making -a new type of contribution, you can run it again and select the added -contribution type. +> This will add the original repository as a "remote" called "upstream," Then +> fetch the git information from that remote, then set your local `master` +> branch to use the upstream master branch whenever you run `git pull`. Then you +> can make all of your pull request branches based on this `master` branch. +> Whenever you want to update your version of `master`, do a regular `git pull`. ## Committing and Pushing changes Please make sure to run the tests before you commit your changes. You can run -`npm run test:update` which will update any snapshots that need updating. -Make sure to include those changes (if they exist) in your commit. - -### opt into git hooks - -There are git hooks set up with this project that are automatically installed -when you install dependencies. They're really handy, but are turned off by -default (so as to not hinder new contributors). You can opt into these by -creating a file called `.opt-in` at the root of the project and putting this -inside: - -``` -pre-commit -``` +`npm run test:update` which will update any snapshots that need updating. Make +sure to include those changes (if they exist) in your commit. ## Help needed @@ -68,6 +40,7 @@ Please checkout the [the open issues][issues] Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks! -[egghead]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github +[egghead]: + https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github [all-contributors]: https://github.com/kentcdodds/all-contributors [issues]: https://github.com/kentcdodds/import-all.macro/issues diff --git a/README.md b/README.md index 7806d97..ed9aed7 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,22 @@

A babel-plugin-macro that allows you to import all files that match a glob

-
+--- + [![Build Status][build-badge]][build] [![Code Coverage][coverage-badge]][coverage] [![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends] [![MIT License][license-badge]][license] + [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors) + [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] [![Babel Macro][macros-badge]][babel-plugin-macros] - -[![Watch on GitHub][github-watch-badge]][github-watch] -[![Star on GitHub][github-star-badge]][github-star] -[![Tweet][twitter-badge]][twitter] + ## The problem @@ -28,24 +28,26 @@ individually. ## This solution -This is a [babel-plugin-macro][babel-plugin-macros] which allows you to import files that -match a glob. It supports `import` statements for synchronous resolution as well -as dynamic `import()` for deferred resolution (for code splitting with react -router for example). +This is a [babel-plugin-macro][babel-plugin-macros] which allows you to import +files that match a glob. It supports `import` statements for synchronous +resolution as well as dynamic `import()` for deferred resolution (for code +splitting with react router for example). ## Table of Contents - -* [Installation](#installation) -* [Usage](#usage) -* [Caveats](#caveats) -* [Inspiration](#inspiration) -* [Other Solutions](#other-solutions) -* [Contributors](#contributors) -* [LICENSE](#license) +- [Installation](#installation) +- [Usage](#usage) +- [Caveats](#caveats) +- [Inspiration](#inspiration) +- [Other Solutions](#other-solutions) +- [Issues](#issues) + - [🐛 Bugs](#-bugs) + - [💡 Feature Requests](#-feature-requests) +- [Contributors ✨](#contributors-) +- [LICENSE](#license) @@ -60,21 +62,20 @@ npm install --save-dev import-all.macro ## Usage -Once you've [configured `babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/user.md) you can -import/require `import-all.macro`. +Once you've +[configured `babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/user.md) +you can import/require `import-all.macro`. The `importAll` functions accept a [`glob`][glob] and will transpile your code to import statements/dynamic imports for each file that matches the given glob. -Let's imagine you have a directory called `my-files` with the files -`a.js`, `b.js`, `c.js`, and `d.js`. +Let's imagine you have a directory called `my-files` with the files `a.js`, +`b.js`, `c.js`, and `d.js`. Here are a few before/after examples: - - **`importAll` uses dynamic import: README:1 `importAll` uses dynamic import** @@ -111,7 +112,8 @@ document.getElementById('load-stuff').addEventListener('click', () => { }) ``` -**`importAll.sync` uses static imports: README:2 `importAll.sync` uses static imports** +**`importAll.sync` uses static imports: README:2 `importAll.sync` uses static +imports** ```javascript import importAll from 'import-all.macro' @@ -124,7 +126,6 @@ import * as _filesAJs from './files/a.js' import * as _filesBJs from './files/b.js' import * as _filesCJs from './files/c.js' import * as _filesDJs from './files/d.js' - const a = { './files/a.js': _filesAJs, './files/b.js': _filesBJs, @@ -133,7 +134,8 @@ const a = { } ``` -**`importAll.deferred` gives an object with dynamic imports: README:3 `importAll.deferred` gives an object with dynamic imports** +**`importAll.deferred` gives an object with dynamic imports: README:3 +`importAll.deferred` gives an object with dynamic imports** ```javascript import importAll from 'import-all.macro' @@ -162,10 +164,10 @@ const routes = { ## Caveats -Some static analysis tools (like ESLint, Flow, and Jest) wont like this very much -without a little additional work. So Jest's watch mode may not pick up all your -tests that are relevant based on changes and some ESLint plugins -(like `eslint-plugin-import`) will probably fail on this. +Some static analysis tools (like ESLint, Flow, and Jest) wont like this very +much without a little additional work. So Jest's watch mode may not pick up all +your tests that are relevant based on changes and some ESLint plugins (like +`eslint-plugin-import`) will probably fail on this. ## Inspiration @@ -176,12 +178,31 @@ tests that are relevant based on changes and some ESLint plugins I'm not aware of any, if you are please [make a pull request][prs] and add it here! -## Contributors +## Issues + +_Looking to contribute? Look for the [Good First Issue][good-first-issue] +label._ + +### 🐛 Bugs + +Please file an issue for bugs, missing documentation, or unexpected behavior. + +[**See Bugs**][bugs] + +### 💡 Feature Requests + +Please file an issue to suggest new features. Vote on feature requests by adding +a 👍. This helps maintainers prioritize what to work on. + +[**See Feature Requests**][requests] + +## Contributors ✨ Thanks goes to these people ([emoji key][emojis]): - + + @@ -191,6 +212,9 @@ Thanks goes to these people ([emoji key][emojis]):
Kent C. Dodds
Kent C. Dodds

💻 📖 🚇 ⚠️
+ + + This project follows the [all-contributors][all-contributors] specification. @@ -200,7 +224,8 @@ Contributions of any kind welcome! MIT -[npm]: https://www.npmjs.com/ + +[npm]: https://www.npmjs.com [node]: https://nodejs.org [build-badge]: https://img.shields.io/travis/kentcdodds/import-all.macro.svg?style=flat-square [build]: https://travis-ci.org/kentcdodds/import-all.macro @@ -219,13 +244,12 @@ MIT [coc]: https://github.com/kentcdodds/import-all.macro/blob/master/other/CODE_OF_CONDUCT.md [macros-badge]: https://img.shields.io/badge/babel--macro-%F0%9F%8E%A3-f5da55.svg?style=flat-square [babel-plugin-macros]: https://github.com/kentcdodds/babel-plugin-macros -[github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/import-all.macro.svg?style=social -[github-watch]: https://github.com/kentcdodds/import-all.macro/watchers -[github-star-badge]: https://img.shields.io/github/stars/kentcdodds/import-all.macro.svg?style=social -[github-star]: https://github.com/kentcdodds/import-all.macro/stargazers -[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20import-all.macro%20by%20%40kentcdodds%20https%3A%2F%2Fgithub.com%2Fkentcdodds%2Fimport-all.macro%20%F0%9F%91%8D -[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/import-all.macro.svg?style=social -[emojis]: https://github.com/kentcdodds/all-contributors#emoji-key -[all-contributors]: https://github.com/kentcdodds/all-contributors +[emojis]: https://github.com/all-contributors/all-contributors#emoji-key +[all-contributors]: https://github.com/all-contributors/all-contributors +[bugs]: https://github.com/kentcdodds/import-all.macro/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug +[requests]: https://github.com/kentcdodds/import-all.macro/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement +[good-first-issue]: https://github.com/kentcdodds/import-all.macro/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement+label%3A%22good+first+issue%22 + [glob]: https://www.npmjs.com/package/glob [sunil-tweet]: https://twitter.com/threepointone/status/908290510225330176 + diff --git a/jest.config.js b/jest.config.js index ea6fc85..fbbd2a3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,6 @@ -const jestConfig = require('kcd-scripts/config').jest +const {jest: jestConfig} = require('kcd-scripts/config') -delete jestConfig.coverageThreshold - -module.exports = jestConfig +module.exports = { + ...jestConfig, + coverageThreshold: null, +} diff --git a/lint-staged.config.js b/lint-staged.config.js index 61ef8a3..321eac6 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -1,5 +1,6 @@ -const lintStagedConfig = require('kcd-scripts/config').lintStaged +const {lintStaged: lintStagedConfig} = require('kcd-scripts/config') -module.exports = Object.assign(lintStagedConfig.linters, { - '**/__snapshots__/**': ['node other/snap-to-readme.js', 'git add README.md'], -}) +module.exports = { + ...lintStagedConfig, + '**/__snapshots__/**': ['node other/snap-to-readme.js'], +} diff --git a/other/CODE_OF_CONDUCT.md b/other/CODE_OF_CONDUCT.md index afe2432..070cb5f 100644 --- a/other/CODE_OF_CONDUCT.md +++ b/other/CODE_OF_CONDUCT.md @@ -5,30 +5,30 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. +size, disability, ethnicity, gender identity and expression, level of +experience, nationality, personal appearance, race, religion, or sexual identity +and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or +- The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities @@ -37,11 +37,11 @@ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. ## Scope @@ -58,8 +58,9 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kent+coc@doddsfamily.us. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +obligated to maintain confidentiality with regard to the reporter of an +incident. Further details of specific enforcement policies may be posted +separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other @@ -67,8 +68,8 @@ members of the project's leadership. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ diff --git a/other/MAINTAINING.md b/other/MAINTAINING.md index 025b673..703126d 100644 --- a/other/MAINTAINING.md +++ b/other/MAINTAINING.md @@ -4,60 +4,67 @@ This is documentation for maintainers of this project. ## Code of Conduct -Please review, understand, and be an example of it. Violations of the code of conduct are -taken seriously, even (especially) for maintainers. +Please review, understand, and be an example of it. Violations of the code of +conduct are taken seriously, even (especially) for maintainers. ## Issues -We want to support and build the community. We do that best by helping people learn to solve -their own problems. We have an issue template and hopefully most folks follow it. If it's -not clear what the issue is, invite them to create a minimal reproduction of what they're trying -to accomplish or the bug they think they've found. +We want to support and build the community. We do that best by helping people +learn to solve their own problems. We have an issue template and hopefully most +folks follow it. If it's not clear what the issue is, invite them to create a +minimal reproduction of what they're trying to accomplish or the bug they think +they've found. Once it's determined that a code change is necessary, point people to -[makeapullrequest.com](http://makeapullrequest.com) and invite them to make a pull request. -If they're the one who needs the feature, they're the one who can build it. If they need -some hand holding and you have time to lend a hand, please do so. It's an investment into -another human being, and an investment into a potential maintainer. +[makeapullrequest.com](http://makeapullrequest.com) and invite them to make a +pull request. If they're the one who needs the feature, they're the one who can +build it. If they need some hand holding and you have time to lend a hand, +please do so. It's an investment into another human being, and an investment +into a potential maintainer. -Remember that this is open source, so the code is not yours, it's ours. If someone needs a change -in the codebase, you don't have to make it happen yourself. Commit as much time to the project -as you want/need to. Nobody can ask any more of you than that. +Remember that this is open source, so the code is not yours, it's ours. If +someone needs a change in the codebase, you don't have to make it happen +yourself. Commit as much time to the project as you want/need to. Nobody can ask +any more of you than that. ## Pull Requests -As a maintainer, you're fine to make your branches on the main repo or on your own fork. Either -way is fine. +As a maintainer, you're fine to make your branches on the main repo or on your +own fork. Either way is fine. -When we receive a pull request, a travis build is kicked off automatically (see the `.travis.yml` -for what runs in the travis build). We avoid merging anything that breaks the travis build. +When we receive a pull request, a travis build is kicked off automatically (see +the `.travis.yml` for what runs in the travis build). We avoid merging anything +that breaks the travis build. -Please review PRs and focus on the code rather than the individual. You never know when this is -someone's first ever PR and we want their experience to be as positive as possible, so be -uplifting and constructive. +Please review PRs and focus on the code rather than the individual. You never +know when this is someone's first ever PR and we want their experience to be as +positive as possible, so be uplifting and constructive. When you merge the pull request, 99% of the time you should use the -[Squash and merge](https://help.github.com/articles/merging-a-pull-request/) feature. This keeps -our git history clean, but more importantly, this allows us to make any necessary changes to the -commit message so we release what we want to release. See the next section on Releases for more -about that. +[Squash and merge](https://help.github.com/articles/merging-a-pull-request/) +feature. This keeps our git history clean, but more importantly, this allows us +to make any necessary changes to the commit message so we release what we want +to release. See the next section on Releases for more about that. ## Release -Our releases are automatic. They happen whenever code lands into `master`. A travis build gets -kicked off and if it's successful, a tool called -[`semantic-release`](https://github.com/semantic-release/semantic-release) is used to -automatically publish a new release to npm as well as a changelog to GitHub. It is only able to -determine the version and whether a release is necessary by the git commit messages. With this -in mind, **please brush up on [the commit message convention][commit] which drives our releases.** +Our releases are automatic. They happen whenever code lands into `master`. A +travis build gets kicked off and if it's successful, a tool called +[`semantic-release`](https://github.com/semantic-release/semantic-release) is +used to automatically publish a new release to npm as well as a changelog to +GitHub. It is only able to determine the version and whether a release is +necessary by the git commit messages. With this in mind, **please brush up on +[the commit message convention][commit] which drives our releases.** -> One important note about this: Please make sure that commit messages do NOT contain the words -> "BREAKING CHANGE" in them unless we want to push a major version. I've been burned by this -> more than once where someone will include "BREAKING CHANGE: None" and it will end up releasing -> a new major version. Not a huge deal honestly, but kind of annoying... +> One important note about this: Please make sure that commit messages do NOT +> contain the words "BREAKING CHANGE" in them unless we want to push a major +> version. I've been burned by this more than once where someone will include +> "BREAKING CHANGE: None" and it will end up releasing a new major version. Not +> a huge deal honestly, but kind of annoying... ## Thanks! Thank you so much for helping to maintain this project! -[commit]: https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md +[commit]: + https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md diff --git a/other/manual-releases.md b/other/manual-releases.md index a058d79..8b722db 100644 --- a/other/manual-releases.md +++ b/other/manual-releases.md @@ -1,9 +1,10 @@ # manual-releases -This project has an automated release set up. So things are only released when there are -useful changes in the code that justify a release. But sometimes things get messed up one way or another -and we need to trigger the release ourselves. When this happens, simply bump the number below and commit -that with the following commit message based on your needs: +This project has an automated release set up. So things are only released when +there are useful changes in the code that justify a release. But sometimes +things get messed up one way or another and we need to trigger the release +ourselves. When this happens, simply bump the number below and commit that with +the following commit message based on your needs: **Major** diff --git a/other/snap-to-readme.js b/other/snap-to-readme.js index 1127bdb..a80feef 100644 --- a/other/snap-to-readme.js +++ b/other/snap-to-readme.js @@ -10,12 +10,11 @@ const snapTitleRegex = /^macros README:\d+(.*) \d+$/ const readmeSnapRegex = /[\s\S]*?/ const snapsToUse = Object.keys(snaps) .filter(name => name.startsWith('macros README')) - .sort( - (nameA, nameB) => - Number(nameA.match(snapNumberRegex)[1]) > - Number(nameB.match(snapNumberRegex)[1]) - ? 1 - : 0, + .sort((nameA, nameB) => + Number(nameA.match(snapNumberRegex)[1]) > + Number(nameB.match(snapNumberRegex)[1]) + ? 1 + : 0, ) .reduce((acc, key) => { const title = key.match(snapTitleRegex)[1].trim() diff --git a/package.json b/package.json index 8534998..a0cf641 100644 --- a/package.json +++ b/package.json @@ -1,46 +1,56 @@ { "name": "import-all.macro", "version": "0.0.0-semantically-released", - "description": - "A macro for babel-plugin-macros that allows you to import all files that match a glob", + "description": "A macro for babel-plugin-macros that allows you to import all files that match a glob", "main": "dist/index.js", "engines": { - "node": "> 4", - "npm": "> 3" + "node": ">=10", + "npm": ">=6" }, "scripts": { - "add-contributor": "kcd-scripts contributors add", "build": "kcd-scripts build", "lint": "kcd-scripts lint", + "setup": "npm install && npm run validate -s", "test": "kcd-scripts test", "test:update": "npm test -- --updateSnapshot --coverage", - "validate": "kcd-scripts validate", - "precommit": "kcd-scripts precommit" + "validate": "kcd-scripts validate" }, - "files": ["dist"], - "keywords": ["babel-plugin-macros"], - "author": "Kent C. Dodds (http://kentcdodds.com/)", + "files": [ + "dist" + ], + "keywords": [ + "babel-plugin-macros" + ], + "author": "Kent C. Dodds (https://kentcdodds.com)", "license": "MIT", "dependencies": { - "babel-plugin-macros": "^2.0.0", - "glob": "^7.1.2" + "@babel/runtime": "^7.9.2", + "babel-plugin-macros": "^2.8.0", + "glob": "^7.1.6" }, "devDependencies": { "ast-pretty-print": "^2.0.1", - "babel-plugin-tester": "^5.0.0", - "kcd-scripts": "^0.32.1", - "prettier": "^1.10.2" + "babel-plugin-tester": "^8.0.1", + "kcd-scripts": "^5.6.0", + "prettier": "2.0.1" }, "eslintConfig": { "extends": "./node_modules/kcd-scripts/eslint.js", "rules": { - "complexity": ["error", 12] + "complexity": [ + "error", + 12 + ] } }, - "eslintIgnore": ["node_modules", "coverage", "dist"], + "eslintIgnore": [ + "node_modules", + "coverage", + "dist" + ], "repository": { "type": "git", - "url": "https://github.com/kentcdodds/import-all.macro.git" + "url": "https://github.com/kentcdodds/import-all.macro" }, "bugs": { "url": "https://github.com/kentcdodds/import-all.macro/issues" diff --git a/src/__tests__/__snapshots__/macro.js.snap b/src/__tests__/__snapshots__/macro.js.snap index 5ece84c..0011492 100644 --- a/src/__tests__/__snapshots__/macro.js.snap +++ b/src/__tests__/__snapshots__/macro.js.snap @@ -47,7 +47,6 @@ import * as _filesAJs from './files/a.js' import * as _filesBJs from './files/b.js' import * as _filesCJs from './files/c.js' import * as _filesDJs from './files/d.js' - const a = { './files/a.js': _filesAJs, './files/b.js': _filesBJs, @@ -67,16 +66,16 @@ const routes = importAll.deferred('./files/*.js') ↓ ↓ ↓ ↓ ↓ ↓ const routes = { - './files/a.js': function() { + './files/a.js': function () { return import('./files/a.js') }, - './files/b.js': function() { + './files/b.js': function () { return import('./files/b.js') }, - './files/c.js': function() { + './files/c.js': function () { return import('./files/c.js') }, - './files/d.js': function() { + './files/d.js': function () { return import('./files/d.js') }, } diff --git a/src/__tests__/macro.js b/src/__tests__/macro.js index 43e8703..1d2334c 100644 --- a/src/__tests__/macro.js +++ b/src/__tests__/macro.js @@ -26,10 +26,7 @@ pluginTester({ filename: __filename, }, formatResult(result) { - return prettier.format( - result, - Object.assign({trailingComma: 'es5'}, prettierConfig), - ) + return prettier.format(result, prettierConfig) }, tests: { 'no usage': `import importAll from '../macro'`, diff --git a/src/macro.js b/src/macro.js index 6184761..dbea65c 100644 --- a/src/macro.js +++ b/src/macro.js @@ -31,7 +31,11 @@ function prevalMacros({references, state, babel}) { function syncVersion({referencePath, state, babel}) { const {types: t} = babel - const {file: {opts: {filename}}} = state + const { + file: { + opts: {filename}, + }, + } = state const importSources = getImportSources( referencePath.parentPath.parentPath, path.dirname(filename), @@ -61,7 +65,11 @@ function syncVersion({referencePath, state, babel}) { function asyncVersion({referencePath, state, babel}) { const {types: t, template} = babel - const {file: {opts: {filename}}} = state + const { + file: { + opts: {filename}, + }, + } = state const promiseTemplate = template(` Promise.all(ALL_IMPORTS).then(function importAllHandler(importVals) { return IMPORT_OBJ @@ -103,7 +111,11 @@ function asyncVersion({referencePath, state, babel}) { function deferredVersion({referencePath, state, babel}) { const {types: t} = babel - const {file: {opts: {filename}}} = state + const { + file: { + opts: {filename}, + }, + } = state const importSources = getImportSources( referencePath.parentPath.parentPath, path.dirname(filename),