Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmds/z-commitlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ module.exports = {
...forwardOptions
], {
stdio: 'inherit',
localDir: path.join(__dirname, '..')
localDir: path.join(__dirname, '..'),
preferLocal: true
})
}
}
3 changes: 2 additions & 1 deletion cmds/z-dependency-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = {
...forwardOptions
], {
stdio: 'inherit',
localDir: path.join(__dirname, '..')
localDir: path.join(__dirname, '..'),
preferLocal: true
})
}
}
8 changes: 3 additions & 5 deletions cmds/z-lint-package-json.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
'use strict'

const resolveBin = require('resolve-bin')
const execa = require('execa')
const path = require('path')
const { fromAegir, fromRoot } = require('../src/utils')

const bin = resolveBin.sync('npm-package-json-lint', { executable: 'npmPkgJsonLint' })

const EPILOG = `
Supports options forwarding with '--' for more info check https://github.com/tclindner/npm-package-json-lint#cli-commands-and-configuration
`
Expand All @@ -27,14 +24,15 @@ module.exports = {
? ['-c', fromAegir('src/config/.npmpackagejsonlintrc.json')]
: []

return execa(bin, [
return execa('npmPkgJsonLint', [
fromRoot('package.json'),
...config,
...input,
...forwardOptions
], {
stdio: 'inherit',
localDir: path.join(__dirname, '..')
localDir: path.join(__dirname, '..'),
preferLocal: true
})
}
}
92 changes: 41 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,106 +39,96 @@
"release-major": "npm run test && node cli.js release --no-build --no-test --type major"
},
"dependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-transform-regenerator": "^7.7.5",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.6",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.7.6",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"@commitlint/lint": "^8.0.0",
"@commitlint/load": "^8.0.0",
"@commitlint/read": "^8.0.0",
"@commitlint/travis-cli": "^8.0.0",
"@hapi/joi": "^15.1.0",
"arrify": "^2.0.1",
"async": "^2.6.1",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/plugin-transform-regenerator": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/register": "^7.8.3",
"@babel/runtime": "^7.8.4",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@commitlint/lint": "^8.3.5",
"@commitlint/load": "^8.3.5",
"@commitlint/read": "^8.3.4",
"@commitlint/travis-cli": "^8.3.5",
"babel-loader": "^8.0.5",
"babel-plugin-transform-flow-comments": "^6.22.0",
"browserify-zlib": "~0.2.0",
"bundlesize": "~0.18.0",
"camelcase": "^5.3.1",
"chalk": "^3.0.0",
"codecov": "^3.3.0",
"conventional-changelog": "^3.1.15",
"codecov": "^3.6.3",
"conventional-changelog": "^3.1.18",
"conventional-github-releaser": "^3.1.3",
"del": "^5.1.0",
"dependency-check": "^4.1.0",
"detect-node": "^2.0.4",
"documentation": "^12.1.4",
"electron": "^6.0.9",
"electron-mocha": "^8.1.2",
"es6-promisify": "^6.0.2",
"electron": "^8.0.0",
"electron-mocha": "^8.2.0",
"eslint": "^6.3.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"execa": "^1.0.0",
"filesize": "^6.0.1",
"execa": "^4.0.0",
"findup-sync": "^4.0.0",
"fs-extra": "^8.1.0",
"gh-pages": "^2.1.1",
"gh-pages": "^2.2.0",
"git-authors-cli": "^1.0.20",
"git-validate": "^2.2.4",
"globby": "^10.0.1",
"globby": "^11.0.0",
"ipfs-utils": "^0.7.1",
"it-glob": "~0.0.5",
"json-loader": "~0.5.7",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-edge-launcher": "~0.4.2",
"karma-firefox-launcher": "^1.2.0",
"karma-firefox-launcher": "^1.3.0",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-mocha-webworker": "^1.3.0",
"karma-sourcemap-loader": "~0.3.7",
"karma-webpack": "4.0.2",
"listr": "~0.14.2",
"listr-verbose-renderer": "~0.6.0",
"lodash": "^4.17.14",
"mocha": "^6.2.2",
"npm-package-json-lint": "^4.4.0",
"npm-which": "^3.0.1",
"nyc": "^14.1.0",
"merge-options": "^2.0.0",
"mocha": "^7.0.1",
"npm-package-json-lint": "^4.5.1",
"nyc": "^15.0.0",
"p-map": "^3.0.0",
"pascalcase": "^1.0.0",
"pify": "^4.0.1",
"pretty-hrtime": "^1.0.3",
"prompt-promise": "^1.0.3",
"read-pkg-up": "^7.0.1",
"resolve-bin": "~0.4.0",
"rimraf": "^3.0.0",
"semver": "^6.3.0",
"simple-git": "^1.128.0",
"rimraf": "^3.0.1",
"semver": "^7.1.2",
"simple-git": "^1.131.0",
"stats-webpack-plugin": "~0.7.0",
"stream-array": "^1.1.2",
"stream-http": "^3.1.0",
"terser-webpack-plugin": "^2.2.3",
"through": "^2.3.8",
"terser-webpack-plugin": "^2.3.4",
"transform-loader": "~0.2.4",
"update-notifier": "^3.0.1",
"update-notifier": "^4.0.0",
"vinyl-fs": "^3.0.3",
"webpack": "^4.41.2",
"webpack": "^4.41.5",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.10",
"webpack-merge": "^4.2.2",
"yargs": "^15.0.2",
"yargs": "^15.1.0",
"yargs-parser": "^16.1.0"
},
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cross-env": "^6.0.3",
"cross-env": "^7.0.0",
"dirty-chai": "^2.0.1",
"mock-require": "^3.0.2",
"sinon": "^7.4.2"
"sinon": "^8.1.1"
},
"engines": {
"node": ">=8.0.0",
"npm": ">=5.0.0"
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"browserslist": [
">1%",
Expand Down
2 changes: 2 additions & 0 deletions src/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = (argv) => {
AEGIR_BUILD_ANALYZE: analyze || ''
},
localDir: path.join(__dirname, '../..'),
preferLocal: true,
stdio: 'inherit'
})

Expand All @@ -41,6 +42,7 @@ module.exports = (argv) => {
.then(r => {
return execa('bundlesize', ['-f', config.bundlesize.path, '-s', config.bundlesize.maxSize], {
localDir: path.join(__dirname, '..'),
preferLocal: true,
stdio: 'inherit'
})
})
Expand Down
8 changes: 4 additions & 4 deletions src/config/intro-template.md.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const _ = require('lodash')
const camelCase = require('camelcase')

function exampleTmpl (example) {
if (!example) {
Expand Down Expand Up @@ -34,19 +34,19 @@ $ npm install --save ${name}
You can then \`require()\` ${name} as normal:

\`\`\`js
const ${_.camelCase(name.replace(/-/g, ' '))} = require('${name}')
const ${camelCase(name)} = require('${name}')
\`\`\`

## In the Browser
${_.upperFirst(name)} should work in any ES2015 environment out of the box.
\`${name}\` should work in any ECMAScript 2018 environment out of the box.

Usage:

\`\`\`html
<script type="text/javascript" src="index.js"></script>
\`\`\`

The portable versions of ${name}, including \`index.js\` and \`index.min.js\`, are included in the \`/dist\` folder. ${_.upperFirst(name)} can also be found on [unpkg.com](https://unpkg.com) under
The portable versions of \`${name}\`, including \`index.js\` and \`index.min.js\`, are included in the \`/dist\` folder. \`${name}\` can also be found on [unpkg.com](https://unpkg.com) under

- https://unpkg.com/${name}/dist/index.min.js
- https://unpkg.com/${name}/dist/index.js
Expand Down
102 changes: 32 additions & 70 deletions src/config/user.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,48 @@
'use strict'

const _ = require('lodash')
const Joi = require('@hapi/joi')
const { promisify } = require('es6-promisify')
const merge = require('merge-options')
const utils = require('../utils')

const hookSchema = Joi.object().keys({
pre: Joi.func(),
post: Joi.func()
}).unknown(false)

const envSchema = Joi.object().keys({
browser: hookSchema,
node: hookSchema
}).unknown(false)

const HOOK_ENVS = [
'browser',
'node'
]

const HOOK_STAGES = [
'pre',
'post'
]

function promisifyHooks (hooks) {
Object.keys(hooks).forEach((key) => {
if (hooks[key].length) {
// hook takes args, is expecting a callback so promisify it
hooks[key] = promisify(hooks[key])
function normalizeHooks (hooks = {}) {
const result = {
browser: {
pre: () => Promise.resolve(),
post: () => Promise.resolve()
},
node: {
pre: () => Promise.resolve(),
post: () => Promise.resolve()
}
})

return hooks
}

function normalizeHooks (hooks) {
const keys = Object.keys(hooks)

// no hooks provided
if (keys.length === 0) {
return hooks
}

// same hooks for all envs
if (_.every(keys, (k) => _.includes(HOOK_STAGES, k))) {
const v = promisifyHooks(Joi.attempt(hooks, hookSchema))

const res = {}
HOOK_ENVS.forEach((env) => {
res[env] = v
})

return res
}
if (hooks.pre && hooks.post) {
result.browser.pre = hooks.pre
result.browser.post = hooks.post
result.node.pre = hooks.pre
result.node.post = hooks.post

// regular per env hook specification
if (_.every(keys, (k) => _.includes(HOOK_ENVS, k))) {
const res = Joi.attempt(hooks, envSchema)
keys.forEach((key) => {
res[key] = promisifyHooks(res[key])
})
return res
return result
}

throw new Error(`Found unknown keys in hook definiton: "${keys.join(' ')}"`)
return merge(result, hooks)
}

function userConfig () {
const config = utils.getUserConfig()

const user = _.defaultsDeep({}, config, {
webpack: {},
karma: {},
hooks: {},
entry: utils.fromRoot('src', 'index.js'),
bundlesize: {
path: './dist/index.min.js',
maxSize: '100kB'
}
})
const userConfig = utils.getUserConfig()

const user = merge(
{
webpack: {},
karma: {},
hooks: {},
entry: utils.fromRoot('src', 'index.js'),
bundlesize: {
path: './dist/index.min.js',
maxSize: '100kB'
}
},
userConfig
)

user.hooks = normalizeHooks(user.hooks)

Expand Down
2 changes: 1 addition & 1 deletion src/fixtures.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global self */
'use strict'

const isNode = require('detect-node')
const { isNode } = require('ipfs-utils/src/env')
const path = require('path')

// note: filePath needs to be relative to the module root
Expand Down
Loading