Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
chore(build): upgrade to kcd-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds authored and Kent C. Dodds committed Sep 12, 2017
1 parent 3b612ee commit 2a57031
Show file tree
Hide file tree
Showing 41 changed files with 276 additions and 528 deletions.
15 changes: 0 additions & 15 deletions .babelrc

This file was deleted.

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
node_modules
coverage
dist
preact
.opt-in
.opt-out
test-ts
typings/*.js
*.log
yarn.lock
package-lock.json
.vscode
.vscode
preact/**/*
15 changes: 5 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ sudo: false
language: node_js
cache:
directories:
- node_modules
- ~/.npm
notifications:
email: false
node_js:
- '8'
script:
- npm start validate
node_js: '8'
script: npm run validate
after_success:
- npx codecov
- npm i -g semantic-release
- semantic-release pre && npm publish && semantic-release post
- npm start validate.examples
- npx -p semantic-release@7 -c "semantic-release pre && npm publish && semantic-release post"
branches:
only:
- master
only: master
62 changes: 36 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,67 @@ Thanks for being willing to contribute!

## Project setup

(`node` v6 is required to run tests.)
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 [`nps`][nps] 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/paypal/glamorous.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 contributors.add
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. If you don't, it's not a huge deal because we can change your commit message when we merge anyway.

Please make sure to run the tests before you commit your changes. You can run `npm start test.update` which will
update any snapshots that need updating. Make sure to include those changes in your commit.
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:

```
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]: ./other/ROADMAP.md
[nps]: https://npmjs.com/package/nps
[examples-readme]: ./examples
[with-jest]: ./examples/with-jest
[issues]: https://github.com/paypal/glamorous/issues
2 changes: 1 addition & 1 deletion examples/with-jest/testSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import {matcher, serializer} from 'jest-glamor-react'
expect.addSnapshotSerializer(serializer)

// this adds toMatchSnapshot to expect and makes the snapshot diff output look nice in the terminal
expect.extend(matcher)
expect.extend(matcher)
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const jest = require('kcd-scripts/config').jest

jest.coveragePathIgnorePatterns = jest.coveragePathIgnorePatterns || []
jest.coveragePathIgnorePatterns.push('/src/.*-entry.js$', '/src/constants.js$')

module.exports = Object.assign({}, jest, {
snapshotSerializers: ['enzyme-to-json/serializer', 'jest-glamor-react'],
})
11 changes: 4 additions & 7 deletions dist-test/preact.js → other/__tests__/dist-preact.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
* This file is unable to validate the global export.
*/
import assert from 'assert'
import {oneLine} from 'common-tags'

import * as esImportStar from '../preact/dist/glamorous.es'
import * as esImportStarTiny from '../preact/dist/glamorous.es.tiny'
import esImport from '../preact/dist/glamorous.es'
import esImportTiny from '../preact/dist/glamorous.es.tiny'

import cjsImport from '../' // picks up the main from package.json
import cjsImport from '../preact' // picks up the main from package.json
import cjsImportTiny from '../preact/dist/glamorous.cjs.tiny'

import umdImport from '../preact/dist/glamorous.umd'
Expand Down Expand Up @@ -100,11 +99,9 @@ console.log('Built modules look good 👍')
function isGlamorousFunction(thing) {
if (typeof thing !== 'function') {
console.error(
oneLine`
glamorous thing should be a function.
It's a ${typeof thing} with the
properties of: ${Object.keys(thing).join(', ')}
`,
`glamorous thing should be a function. It's a ${typeof thing} with the properties of: ${Object.keys(
thing,
).join(', ')}`,
)
return false
}
Expand Down
9 changes: 3 additions & 6 deletions dist-test/index.js → other/__tests__/dist-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* This file is unable to validate the global export.
*/
import assert from 'assert'
import {oneLine} from 'common-tags'

import * as esImportStar from '../dist/glamorous.es'
import * as esImportStarTiny from '../dist/glamorous.es.tiny'
Expand Down Expand Up @@ -100,11 +99,9 @@ console.log('Built modules look good 👍')
function isGlamorousFunction(thing) {
if (typeof thing !== 'function') {
console.error(
oneLine`
glamorous thing should be a function.
It's a ${typeof thing} with the
properties of: ${Object.keys(thing).join(', ')}
`,
`glamorous thing should be a function. It's a ${typeof thing} with the properties of: ${Object.keys(
thing,
).join(', ')}`,
)
return false
}
Expand Down
21 changes: 3 additions & 18 deletions other/codemods/__snapshots__/theme-move.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ glamorous.div((props, theme) => ({fontSize: theme.fontSize}))
↓ ↓ ↓ ↓ ↓ ↓
import glamorous from 'glamorous'
glamorous.div(props => ({fontSize: props.theme.fontSize}))
`;
Expand All @@ -21,7 +20,6 @@ glamorous.div((props, theme, context) => ({ fontSize: theme.main.fontSize }))
↓ ↓ ↓ ↓ ↓ ↓
import glamorous from 'glamorous'
glamorous.div((props, context) => ({fontSize: props.theme.main.fontSize}))
`;
Expand Down Expand Up @@ -58,7 +56,6 @@ glamorous.div((props, theme) => ({fontSize: theme.main.fontSize}))
↓ ↓ ↓ ↓ ↓ ↓
const glamorous = require('glamorous')
glamorous.div(props => ({fontSize: props.theme.main.fontSize}))
`;
Expand Down Expand Up @@ -143,7 +140,6 @@ glamorous('div')((props, theme) => ({fontSize: theme.fontSize}))
↓ ↓ ↓ ↓ ↓ ↓
import glamorous from 'glamorous'
glamorous('div')(props => ({fontSize: props.theme.fontSize}))
`;
Expand All @@ -156,7 +152,6 @@ glamorous.div([(props, theme) => ({fontSize: theme.fontSize})])
↓ ↓ ↓ ↓ ↓ ↓
import glamorous from 'glamorous'
glamorous.div([props => ({fontSize: props.theme.fontSize})])
`;
Expand Down Expand Up @@ -205,10 +200,7 @@ const ui = <glamorous.Div css={(props, theme) => ({fontSize: theme.fontSize})} /
↓ ↓ ↓ ↓ ↓ ↓
import glamorous from 'glamorous'
const ui = (
<glamorous.Div css={props => ({fontSize: props.theme.fontSize})} />
)
const ui = <glamorous.Div css={props => ({fontSize: props.theme.fontSize})} />
`;

Expand Down Expand Up @@ -240,7 +232,6 @@ const ui = <Span css={(props, theme) => ({fontSize: theme.fontSize})}>content</S
import glamorous from 'glamorous'
import {Span} from 'glamorous'
const ui = (
<Span css={props => ({fontSize: props.theme.fontSize})}>content</Span>
)
Expand All @@ -261,10 +252,7 @@ glamorous.div((props, {primary: {headings: {font: {size: fontSize}}}}) => ({
import glamorous from 'glamorous'
glamorous.div(
({
theme: {primary: {headings: {font: {size: fontSize}}}},
...props
}) => ({
({theme: {primary: {headings: {font: {size: fontSize}}}}, ...props}) => ({
color: props.color,
fontSize,
}),
Expand All @@ -286,10 +274,7 @@ glamorous.div(({color}, {primary: {headings: {font: {size: fontSize}}}}) => ({
import glamorous from 'glamorous'
glamorous.div(
({
color,
theme: {primary: {headings: {font: {size: fontSize}}}},
}) => ({
({color, theme: {primary: {headings: {font: {size: fontSize}}}}}) => ({
color,
fontSize,
}),
Expand Down
8 changes: 7 additions & 1 deletion other/codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
"ast-pretty-print": "^2.0.0",
"babel-core": "^6.25.0",
"babel-plugin-tester": "^3.3.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"jest": "^20.0.4",
"prettier-eslint": "^6.4.2",
"prettier": "^1.6.1",
"recast": "^0.12.6",
"strip-indent": "^2.0.0"
},
"babel": {
"presets": ["env", "react", "stage-2"]
}
}
2 changes: 1 addition & 1 deletion other/codemods/theme-move.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function glamorousThemeCodemod(babel) {
exit(path, {file: {opts: {filename}}}) {
// now that we've traversed everything, we can go through each of them
// and convert the ones that need to be converted
(identifiers[filename] || []).forEach(identifier => {
;(identifiers[filename] || []).forEach(identifier => {
if (identifier.isJSXIdentifier()) {
const openingElement = identifier.findParent(
t.isJSXOpeningElement,
Expand Down
18 changes: 13 additions & 5 deletions other/codemods/theme-move.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint max-len:0 */
import path from 'path'
import prettierEslint from 'prettier-eslint'
import prettier from 'prettier'
import stripIndent from 'strip-indent'
// not sure why, but travis seems to error out
// due to this import 🙃
Expand Down Expand Up @@ -167,10 +167,18 @@ function withGlamorousImport(tests) {
}

function formatResult(result) {
return prettierEslint({
filePath: __filename,
text: result,
}).trim()
return prettier
.format(result, {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: false,
jsxBracketSameLine: false,
})
.trim()
}

/*
Expand Down
6 changes: 6 additions & 0 deletions other/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const jestConfig = require('kcd-scripts/config').jest

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

0 comments on commit 2a57031

Please sign in to comment.