chore(build): switch to kcd-scripts (#142)

This commit is contained in:
Kent C. Dodds
2017-09-07 23:19:21 -06:00
committed by GitHub
parent da1e82105c
commit dd7b1fec62
15 changed files with 92 additions and 213 deletions
-10
View File
@@ -1,10 +0,0 @@
{
"presets": [
["env", {
"targets": {
"node": 4
}
}],
"stage-2"
]
}
-3
View File
@@ -1,3 +0,0 @@
node_modules
coverage
dist
@@ -11,7 +11,7 @@ never done that before, that's great! Check this free short video tutorial to
learn how: http://kcd.im/pull-request
-->
- `cross-env` version:
- `downshift` version:
- `node` version:
- `npm` (or `yarn`) version:
@@ -1,5 +1,5 @@
<!--
Thanks for your interest in the project. I appreciate bugs filed and PRs submitted!
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).
@@ -23,5 +23,13 @@ merge of your pull request!
<!-- 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 -->
+1 -1
View File
@@ -1,2 +1,2 @@
registry=http://registry.npmjs.org/
save-exact=true
package-lock=false
+7 -9
View File
@@ -2,16 +2,14 @@ sudo: false
language: node_js
cache:
directories:
- node_modules
- ~/.npm
notifications:
email: false
node_js:
- '6'
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
+36 -30
View File
@@ -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 [`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/kentcdodds/cross-env.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]: ./other/ROADMAP.md
[nps]: https://npmjs.com/package/nps
[issues]: https://github.com/kentcdodds/cross-env/issues
+1 -1
View File
@@ -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
+3 -4
View File
@@ -1,6 +1,6 @@
environment:
matrix:
- node_version: "6"
- node_version: "8"
branches:
only:
@@ -8,14 +8,13 @@ branches:
install:
- ps: Install-Product node $env:node_version
- yarn
- npm i
test_script:
- node --version
- npm test
cache:
- node_modules
- "%LOCALAPPDATA%/Yarn"
- ~/.npm
build: off
+6
View File
@@ -0,0 +1,6 @@
const jestConfig = require('kcd-scripts/config').jest
jestConfig.coveragePathIgnorePatterns = jestConfig.coveragePathIgnorePatterns.concat(
['/bin/'],
)
module.exports = jestConfig
-74
View File
@@ -1,74 +0,0 @@
const npsUtils = require('nps-utils')
const series = npsUtils.series
const concurrent = npsUtils.concurrent
const rimraf = npsUtils.rimraf
module.exports = {
scripts: {
commit: {
description: 'This uses commitizen to help us generate well formatted commit messages',
script: 'git-cz',
},
test: {
default: 'jest --coverage',
watch: 'jest --watch',
},
build: {
description: 'delete the dist directory and run babel to build the files',
script: series(
rimraf('dist'),
'babel --copy-files --out-dir dist --ignore *.test.js src'
),
},
lint: {
description: 'lint the entire project',
script: 'eslint .',
},
format: {
description: 'formats the project',
script: 'prettier-eslint --write "src/**/*.js"',
},
reportCoverage: {
description: 'Report coverage stats to codecov. This should be run after the `test` script',
script: 'codecov',
},
release: {
description: 'We automate releases with semantic-release. This should only be run on travis',
script: series(
'semantic-release pre',
'npm publish',
'semantic-release post'
),
},
validate: {
description: 'This runs several scripts to make sure things look good before committing or on clean install',
script: concurrent.nps('lint', 'build', 'test'),
},
addContributor: {
description: 'When new people contribute to the project, run this',
script: 'all-contributors add',
},
generateContributors: {
description: 'Update the badge and contributors table',
script: 'all-contributors generate',
},
},
options: {
silent: false,
},
}
// this is not transpiled
/*
eslint
max-len: 0,
comma-dangle: [
2,
{
arrays: 'always-multiline',
objects: 'always-multiline',
functions: 'never'
}
]
*/
+14 -62
View File
@@ -1,7 +1,8 @@
{
"name": "cross-env",
"version": "0.0.0-semantically-released",
"description": "Run scripts that set and use environment variables across platforms",
"description":
"Run scripts that set and use environment variables across platforms",
"main": "dist/index.js",
"bin": {
"cross-env": "dist/bin/cross-env.js",
@@ -11,15 +12,16 @@
"node": ">=4.0"
},
"scripts": {
"start": "nps",
"test": "nps test",
"commitmsg": "opt --in commit-msg --exec \"validate-commit-msg\"",
"precommit": "lint-staged && opt --in pre-commit --exec \"npm start validate\""
"add-contributor": "kcd-scripts contributors add",
"build": "kcd-scripts build",
"lint": "kcd-scripts lint",
"test": "kcd-scripts test",
"test:update": "npm test -- --updateSnapshot --coverage",
"validate": "kcd-scripts validate",
"precommit": "kcd-scripts precommit"
},
"files": [
"dist"
],
"keywords": [],
"files": ["dist"],
"keywords": ["cross-environment", "environment variable", "windows"],
"author": "Kent C. Dodds <[email protected]> (http://kentcdodds.com/)",
"license": "MIT",
"dependencies": {
@@ -27,62 +29,12 @@
"is-windows": "^1.0.0"
},
"devDependencies": {
"all-contributors-cli": "^4.0.1",
"babel-cli": "^6.24.1",
"babel-core": "^6.23.1",
"babel-jest": "^20.0.3",
"babel-preset-env": "^1.2.0",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.23.0",
"codecov": "^2.3.0",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^3.17.0",
"eslint-config-kentcdodds": "^12.0.0",
"husky": "^0.14.3",
"jest-cli": "^20.0.4",
"lint-staged": "^3.3.1",
"nps": "^5.0.3",
"nps-utils": "^1.1.2",
"opt-cli": "^1.5.1",
"prettier-eslint-cli": "^4.1.1",
"semantic-release": "^6.3.6",
"validate-commit-msg": "^2.11.1"
"kcd-scripts": "^0.3.4"
},
"eslintConfig": {
"extends": [
"kentcdodds",
"kentcdodds/jest"
],
"rules": {
"max-len": [
"error",
80
]
}
},
"lint-staged": {
"*.js": [
"prettier-eslint --write",
"git add"
]
},
"jest": {
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
}
}
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
}
"extends": "./node_modules/kcd-scripts/eslint.js"
},
"eslintIgnore": ["node_modules", "coverage", "dist"],
"repository": {
"type": "git",
"url": "https://github.com/kentcdodds/cross-env.git"
@@ -1,5 +1,5 @@
import isWindowsMock from 'is-windows'
import commandConvert from './command'
import commandConvert from '../command'
beforeEach(() => {
isWindowsMock.__mock.reset()
@@ -33,19 +33,14 @@ test(`is stateless`, () => {
test(`converts embedded unix-style env variables usage for windows`, () => {
isWindowsMock.__mock.returnValue = true
expect(commandConvert('$test1/$test2/$test3')).toBe(
'%test1%/%test2%/%test3%',
)
expect(commandConvert('$test1/$test2/$test3')).toBe('%test1%/%test2%/%test3%')
})
// eslint-disable-next-line max-len
test(
`leaves embedded variables unchanged when using correct operating system`,
() => {
isWindowsMock.__mock.returnValue = false
expect(commandConvert('$test1/$test2/$test3')).toBe('$test1/$test2/$test3')
},
)
test(`leaves embedded variables unchanged when using correct operating system`, () => {
isWindowsMock.__mock.returnValue = false
expect(commandConvert('$test1/$test2/$test3')).toBe('$test1/$test2/$test3')
})
test(`converts braced unix-style env variable usage for windows`, () => {
isWindowsMock.__mock.returnValue = true
+3 -2
View File
@@ -1,7 +1,7 @@
import crossSpawnMock from 'cross-spawn'
import isWindowsMock from 'is-windows'
const crossEnv = require('.')
const crossEnv = require('../')
process.setMaxListeners(20)
@@ -119,7 +119,8 @@ it(`should propagate kill signals`, () => {
function testEnvSetting(expected, ...envSettings) {
if (expected.APPDATA === 2) {
// kill the APPDATA to test both is undefined
delete process.env.APPDATA
const {env} = process
delete env.APPDATA
delete expected.APPDATA
} else if (!process.env.APPDATA && expected.APPDATA === '0') {
// set APPDATA and test it
@@ -1,5 +1,5 @@
import isWindowsMock from 'is-windows'
import varValueConvert from './variable'
import varValueConvert from '../variable'
const JSON_VALUE = '{\\"foo\\":\\"bar\\"}'
@@ -11,9 +11,10 @@ beforeEach(() => {
})
afterEach(() => {
delete process.env.VAR1
delete process.env.VAR2
delete process.env.JSON_VAR
const {env} = process
delete env.VAR1
delete env.VAR2
delete env.JSON_VAR
})
test(`doesn't affect simple variable values`, () => {