Skip to content

Commit

Permalink
chore: updates setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed May 21, 2019
1 parent e5abae6 commit 48164c7
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 361 deletions.
17 changes: 3 additions & 14 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const project = require('./project.config');

const vars = {
node: project.get('nodeOnly'),
esnext: !!process.env.ESNEXT,
typescript: project.get('typescript')
};

const env = { targets: { node: '8.0.0' } };
module.exports = {
presets: [
vars.node && ['@babel/preset-env', env],
!vars.esnext && ['@babel/preset-env', { targets: { node: '8.0.0' } }],
vars.typescript && '@babel/typescript'
].filter(Boolean),
plugins: [
Expand All @@ -17,15 +16,5 @@ module.exports = {
'@babel/plugin-proposal-class-properties',
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }]
],
ignore: ['node_modules', '**/*.d.ts'],
env: {
test: {
presets: vars.node
? undefined
: [
['@babel/preset-env', env],
vars.typescript && '@babel/typescript'
].filter(Boolean)
}
}
ignore: ['node_modules', '**/*.d.ts']
};
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ To install *kpo* globally, run: [`npm install -g kpo`](https://www.npmjs.com/pac

These are common options for all *kpo* subcommands. They must always be passed before any subcommand or scope.

<!-- markdownlint-disable MD040 MD031 -->
```
Usage:
$ kpo [options] [@scope] [tasks] -- [streamArgs]
Expand Down Expand Up @@ -56,7 +55,6 @@ Examples:
$ kpo foo bar baz
$ kpo -e NODE_ENV=development -e BABEL_ENV=browser :run foo bar baz
```
<!-- markdownlint-enable MD040 MD031 -->

### `kpo :run` - default command

Expand All @@ -66,7 +64,6 @@ Note that **the `:run` command can be omitted,** that is, if no command is passe

### `kpo :cmd` - aliased `kpo :`

<!-- markdownlint-disable MD040 MD031 -->
```
Usage:
$ kpo :cmd [options] [command] [arguments]
Expand All @@ -80,11 +77,9 @@ Examples:
$ kpo : foo --bar --baz
$ kpo :cmd foo --bar --baz
```
<!-- markdownlint-enable MD040 MD031 -->

### `kpo :list`

<!-- markdownlint-disable MD040 MD031 -->
```
Usage:
$ kpo :list [options]
Expand All @@ -96,11 +91,9 @@ Options:
--scopes List scopes
-h, --help Show help
```
<!-- markdownlint-enable MD040 MD031 -->

### `kpo :raise`

<!-- markdownlint-disable MD040 MD031 -->
```
Usage:
$ kpo :raise [options]
Expand All @@ -114,11 +107,9 @@ Options:
--fail Fails if there are any changes to be made on dry mode, or if the user cancels the action when confirmation is required
-h, --help Show help
```
<!-- markdownlint-enable MD040 MD031 -->

### `kpo :series`

<!-- markdownlint-disable MD040 MD031 -->
```
Usage:
$ kpo :series [options] [commands] -- [streamArgs]
Expand All @@ -132,11 +123,9 @@ Options:
Examples:
$ kpo :series "foo --bar" "baz --foobar"
```
<!-- markdownlint-enable MD040 MD031 -->

### `kpo :parallel`

<!-- markdownlint-disable MD040 MD031 -->
```
Usage:
$ kpo :parallel [options] [commands] -- [streamArgs]
Expand All @@ -152,11 +141,9 @@ Options:
Examples:
$ kpo :parallel -n foo,baz -c blue,magenta "foo --bar" "baz --foobar"
```
<!-- markdownlint-enable MD040 MD031 -->

### `kpo :stream`

<!-- markdownlint-disable MD040 MD031 -->
```
Usage:
$ kpo :stream [options] [commands]
Expand All @@ -173,4 +160,3 @@ Options:
Examples:
$ kpo :stream :cmd foo --bar --baz
```
<!-- markdownlint-enable MD040 MD031 -->
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
collectCoverage: true,
collectCoverageFrom: [`<rootDir>/src/**/*.{${EXT}}`],
modulePathIgnorePatterns: [
'.*\\.d\\.ts$',
'<rootDir>/pkg',
'<rootDir>/src/@types',
'<rootDir>/src/.*/__mocks__'
Expand Down
51 changes: 29 additions & 22 deletions kpo.scripts.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// prettier-ignore
const { series, parallel, ensure, line, json, log, confirm, rm, remove, kpo, silent } = require('kpo');
const { series, parallel, ensure, line, json, log, confirm, rm, remove, kpo, silent, copy, glob } = require('kpo');
const path = require('path');
const bump = require('conventional-recommended-bump');
const { promisify } = require('util');
const { merge } = require('slimconf');
const project = require('./project.config');

// prettier-ignore
verify('nodeOnly', 'typescript', 'ext.js', 'ext.ts', 'paths.docs', 'release.build', 'release.docs');
verify('esnext', 'typescript', 'ext.js', 'ext.ts', 'paths.docs', 'release.build', 'release.docs');
const vars = {
node: !!project.nodeOnly,
semantic: !!process.env.SEMANTIC,
commit: !!process.env.COMMITIZEN || !!process.env.SEMANTIC,
ext: extensions(),
Expand All @@ -19,24 +17,33 @@ const vars = {
module.exports.scripts = {
start: kpo`watch`,
build: {
default: kpo`validate build.force`,
force: series.env('kpo build.pack build.types', { NODE_ENV: 'production' }),
$pack: [ensure`./pkg`, 'pack build'].concat(
vars.node && [
line`babel src --out-dir ./pkg/dist-node
--extensions ${vars.dotExt} --source-maps inline`,
json('./pkg/package.json', (pkg) => {
if (pkg.main || pkg.module || pkg.esnext) throw Error(`!node pack`);
return merge(pkg, { main: 'dist-node/index.js' });
})
]
default: [
kpo`validate`,
series.env('kpo build.pack', { NODE_ENV: 'production' })
],
pack: kpo`build.prepare build.node build.esnext build.types`,
$prepare: [
[rm`pkg`, ensure`pkg`],
copy(['README.md', 'LICENSE', 'CHANGELOG.md'], { to: 'pkg' }),
json('./package.json', './pkg/package.json', ({ json }) => ({
...json,
scripts: undefined,
files: ['dist-*/'],
main: 'dist-node/index.js',
esnext: project.esnext ? 'dist-src/index.js' : undefined,
types: project.typescript ? 'dist-types/index.d.ts' : undefined
}))
],
$node: series(
'babel ./src --out-dir ./pkg/dist-node --source-maps inline',
{ args: ['--extensions', vars.dotExt] }
),
$esnext: project.esnext && [
series.env('standard-pkg --src src/ --dist pkg/dist-src', { ESNEXT: '#' })
],
$types: project.typescript && [
`ttsc --project ttsconfig.json --outDir ./pkg/dist-types/`,
json('./pkg/package.json', (pkg) => {
return merge(pkg, { types: 'dist-types/index.d.ts' });
}),
log`Declaration files built`
copy(glob`./src/**/*.d.ts`, { from: 'src', to: 'pkg/dist-types' })
]
},
commit: series.env('git-cz', { COMMITIZEN: '#' }),
Expand All @@ -61,7 +68,7 @@ module.exports.scripts = {
default: 'onchange ./src --initial --kill -- kpo watch.task',
$task: [
log`\x1Bc⚡`,
parallel(['kpo build.pack build.types', 'kpo lint'], {
parallel(['kpo build.pack', 'kpo lint'], {
names: ['build', 'eslint'],
colors: ['blue', 'yellow']
})
Expand Down Expand Up @@ -113,8 +120,8 @@ module.exports.scripts = {
version: [
kpo`preversion`,
kpo`changelog`,
project.release.docs && kpo`docs`,
project.release.build && kpo`build`,
project.release.docs && kpo`docs`,
'git add .'
]
};
Expand All @@ -125,7 +132,7 @@ function verify(...arr) {

function extensions() {
return (project.typescript ? project.ext.ts.split(',') : [])
.concat(project.ext.js)
.concat(project.ext.js.split(','))
.filter(Boolean)
.join(',');
}
4 changes: 3 additions & 1 deletion markdown.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"indent": 2
},
"line-length": false,
"no-inline-html": false
"no-inline-html": false,
"fenced-code-language": false,
"commands-show-output": false
}
Loading

0 comments on commit 48164c7

Please sign in to comment.