Skip to content

Commit

Permalink
feat: remove global-object dep and upgrade build
Browse files Browse the repository at this point in the history
This upgrades us to kcd-scripts which will make maintaining this easier.

BREAKING CHANGE: If you use the UMD build, please note the changed location of the files. If you don't then you should be safe to upgrade.
  • Loading branch information
Kent C. Dodds committed Sep 22, 2017
1 parent 6f91081 commit 8613bf2
Show file tree
Hide file tree
Showing 23 changed files with 272 additions and 6,106 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

43 changes: 43 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
Thanks for your interest in the project. I appreciate bugs filed and PRs submitted!
Please make sure that you are familiar with and follow the Code of Conduct for
this project (found in the CODE_OF_CONDUCT.md file).
Please fill out this template with all the relevant information so we can
understand what's going on and fix the issue.
I'll probably ask you to submit the fix (after giving some direction). If you've
never done that before, that's great! Check this free short video tutorial to
learn how: http://kcd.im/pull-request
-->

- `match-sorter` version:
- `node` version:
- `npm` (or `yarn`) version:

Relevant code or config

```javascript

```

What you did:



What happened:

<!-- Please provide the full error message/screenshots/anything -->

Reproduction repository:

<!--
If possible, please create a repository that reproduces the issue with the
minimal amount of code possible.
-->

Problem description:



Suggested solution:
35 changes: 35 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
Thanks for your interest in the project. Bugs filed and PRs submitted are appreciated!
Please make sure that you are familiar with and follow the Code of Conduct for
this project (found in the CODE_OF_CONDUCT.md file).
Also, please make sure you're familiar with and follow the instructions in the
contributing guidelines (found in the CONTRIBUTING.md file).
If you're new to contributing to open source projects, you might find this free
video course helpful: http://kcd.im/pull-request
Please fill out the information below to expedite the review and (hopefully)
merge of your pull request!
-->

<!-- What changes are being made? (What feature/bug is being fixed here?) -->
**What**:

<!-- Why are these changes necessary? -->
**Why**:

<!-- How were these changes implemented? -->
**How**:

<!-- Have you done all of these things? -->
**Checklist**:
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
- [ ] Documentation
- [ ] Tests
- [ ] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
- [ ] Added myself to contributors table <!-- this is optional, see the contributing guidelines for instructions -->

<!-- feel free to add additional comments -->
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
node_modules
.nyc_output
coverage
dist
.opt-in
.opt-out
npm-debug.log
.DS_Store
.eslintcache

# these cause more harm than good
# when working with contributors
package-lock.json
yarn.lock
2 changes: 0 additions & 2 deletions .lgtm

This file was deleted.

2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
registry=http://registry.npmjs.org/
save-exact=true
package-lock=false
20 changes: 7 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@ sudo: false
language: node_js
cache:
directories:
- node_modules
- ~/.npm
notifications:
email: false
node_js:
- '6'
before_install:
- npm i -g npm@^3.0.0
before_script:
- npm prune
script:
- npm start validate
node_js: '8'
install: npm install
script: npm run validate
after_success:
- npm start report-coverage
- npm start release
- npx codecov
- npx -p semantic-release@7 -c "semantic-release pre && npm publish && semantic-release post"
branches:
only:
- master
only: master
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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).
You can see it on the [releases page](../../releases).
66 changes: 36 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,65 @@ Thanks for being willing to contribute!

1. Fork and clone the repo
2. `$ npm install` to install dependencies
3. `$ npm start validate` to validate you've got it working
3. `$ npm run validate` to validate you've got it working
4. Create a branch for your PR

This project uses [`p-s`][p-s] and you can run `npm start` to see what scripts are available.
> Tip: Keep your `master` branch pointing at the original repository and make
> pull requests from branches on your fork. To do this, run:
>
> ```
> git remote add upstream https://github.com/kentcdodds/match-sorter.git
> 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:
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 start addContributor <YOUR_GITHUB_USERNAME>
npm run add-contributor
```

Follow the prompt. 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.
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.

## Committing and Pushing changes

This project uses [`semantic-release`][semantic-release] to do automatic releases and generate a changelog based on the
commit history. So we follow [a convention][convention] for commit messages. Please follow this convention for your
commit messages.

You can use `commitizen` to help you to follow [the convention][convention]

Once you are ready to commit the changes, please use the below commands

1. `git add <files to be comitted>`
2. `$ npm start commit`

... and follow the instruction of the interactive prompt.
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:
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:

```
commit-msg
pre-commit
```

## Help needed

Please checkout the [ROADMAP.md][ROADMAP] and raise an issue to discuss
any of the items in the want to do or might do list.
Please checkout the [the open issues][issues]

Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks!
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
[semantic-release]: https://npmjs.com/package/semantic-release
[convention]: https://github.com/conventional-changelog/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md
[all-contributors]: https://github.com/kentcdodds/all-contributors
[ROADMAP]: ./ROADMAP.md
[p-s]: https://npmjs.com/package/p-s
[issues]: https://github.com/kentcdodds/match-sorter/issues
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2016 Kent C. Dodds
Copyright (c) 2017 Kent C. Dodds

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion MAINTAINERS

This file was deleted.

23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# match-sorter
<div align="center">
<h1>match-sorter</h1>

Simple, expected, and deterministic best-match sorting of an array in JavaScript. **[Demo](https://jsbin.com/vewoka/edit?js,output)**
<p>Simple, expected, and deterministic best-match sorting of an array in JavaScript</p>
</div>

<hr />

**[Demo](https://codesandbox.io/s/wyk856yo48)**

[![Build Status][build-badge]][build]
[![Code Coverage][coverage-badge]][coverage]
Expand All @@ -16,8 +22,8 @@ Simple, expected, and deterministic best-match sorting of an array in JavaScript
[![Roadmap][roadmap-badge]][roadmap]
[![Examples][examples-badge]][examples]

[![gzip size][gzip-badge]][unpkg-umd]
[![size][size-badge]][unpkg-umd]
[![gzip size][gzip-badge]][unpkg-dist]
[![size][size-badge]][unpkg-dist]
[![module formats: umd and cjs][module-formats-badge]][module-formats]
[![Watch on GitHub][github-watch-badge]][github-watch]
[![Star on GitHub][github-star-badge]][github-star]
Expand Down Expand Up @@ -47,7 +53,6 @@ To explain the ranking system, I'll use countries as an example:

This ranking seems to make sense in people's minds. At least it does in mine. Feedback welcome!


## Getting Started

### Installation
Expand Down Expand Up @@ -269,8 +274,8 @@ MIT
[emojis]: https://github.com/kentcdodds/all-contributors#emoji-key
[all-contributors]: https://github.com/kentcdodds/all-contributors
[genie]: https://github.com/kentcdodds/genie
[gzip-badge]: http://img.badgesize.io/https://unpkg.com/match-sorter/dist/umd/match-sorter.min.js?compression=gzip&label=gzip%20size&style=flat-square
[size-badge]: http://img.badgesize.io/https://unpkg.com/match-sorter/dist/umd/match-sorter.min.js?label=size&style=flat-square
[unpkg-umd]: https://unpkg.com/match-sorter/dist/umd/
[gzip-badge]: http://img.badgesize.io/https://unpkg.com/match-sorter/dist/match-sorter.umd.min.js?compression=gzip&label=gzip%20size&style=flat-square
[size-badge]: http://img.badgesize.io/https://unpkg.com/match-sorter/dist/match-sorter.umd.min.js?label=size&style=flat-square
[unpkg-dist]: https://unpkg.com/match-sorter/dist/
[module-formats-badge]: https://img.shields.io/badge/module%20formats-umd%2C%20cjs-green.svg?style=flat-square
[module-formats]: https://unpkg.com/match-sorter@1.8.0/dist/
[module-formats]: https://unpkg.com/match-sorter/dist/
31 changes: 17 additions & 14 deletions dist-test/index.js → other/__tests__/dist-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,53 @@ import umdImport, {rankings as umdRankings} from '../dist/umd/match-sorter'
const cjsRequire = require('../dist/cjs')
const umdRequire = require('../dist/umd/match-sorter')


assert(
isMatchSorterFunction(cjsImport) && isRankingsObject(cjsRankings),
'CJS build has a problem with ES6 modules',
'CJS build has a problem with ES6 modules',
)

assert(
isMatchSorterFunction(cjsRequire),
'CJS build has a problem with CJS',
)
assert(isMatchSorterFunction(cjsRequire), 'CJS build has a problem with CJS')

assert(
isMatchSorterFunction(umdImport) && isRankingsObject(umdRankings),
'UMD build has a problem with ES6 modules',
)

assert(
isMatchSorterFunction(umdRequire),
'UMD build has a problem with CJS',
)
assert(isMatchSorterFunction(umdRequire), 'UMD build has a problem with CJS')

// TODO: how could we validate the AMD/global modules?

console.log('Built modules look good 👍')

function isMatchSorterFunction(thing) {
if (typeof thing !== 'function') {
console.error(`matchSorter thing should be a function. It's a ${typeof thing}`)
console.error(
`matchSorter thing should be a function. It's a ${typeof thing}`,
)
return false
}
if (thing.name !== 'matchSorter') {
console.error(`the function is not called "matchSorter". It's called ${thing.name}`)
console.error(
`the function is not called "matchSorter". It's called ${thing.name}`,
)
return false
}
return isRankingsObject(thing.rankings)
}

function isRankingsObject(thing) {
if (typeof thing !== 'object') {
console.error(`rankings object thing should be an object. It's a ${typeof thing}`)
console.error(
`rankings object thing should be an object. It's a ${typeof thing}`,
)
return false
}
if (!Object.keys(thing).includes('NO_MATCH')) {
console.error(`rankings object should include a NO_MATCH key. It only has ${Object.keys(thing)}`)
console.error(
`rankings object should include a NO_MATCH key. It only has ${Object.keys(
thing,
)}`,
)
return false
}
return true
Expand Down
5 changes: 5 additions & 0 deletions other/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const jestConfig = require('kcd-scripts/config').jest

module.exports = Object.assign(jestConfig, {
roots: ['.'],
})
Loading

0 comments on commit 8613bf2

Please sign in to comment.