-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from rocjs/next
v2.0.0
- Loading branch information
Showing
27 changed files
with
369 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": "airbnb-base", | ||
|
||
"rules": { | ||
"indent": [2, 4, { "SwitchCase": 1 }], | ||
"max-len": [2, 120, 4], | ||
"no-warning-comments": 1, | ||
|
||
"import/order": [2, { "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], "newlines-between": "always"}], | ||
"import/newline-after-import": [2], | ||
|
||
"global-require": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Verdens Gang AS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#! /usr/bin/env node | ||
|
||
const runCli = require('roc').runCli; | ||
|
||
const packageJSON = require('../package.json'); | ||
const commands = require('../commands'); | ||
|
||
runCli({ | ||
info: { | ||
version: packageJSON.version, | ||
name: Object.keys(packageJSON.bin)[0], | ||
}, | ||
commands, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
const babel = require.resolve('babel-cli/bin/babel'); | ||
|
||
const babelPlugins = [ | ||
require.resolve('babel-plugin-transform-object-rest-spread'), | ||
require.resolve('babel-plugin-transform-es2015-spread'), | ||
require.resolve('babel-plugin-transform-es2015-function-name'), | ||
require.resolve('babel-plugin-transform-es2015-sticky-regex'), | ||
require.resolve('babel-plugin-transform-es2015-unicode-regex'), | ||
require.resolve('babel-plugin-transform-es2015-parameters'), | ||
require.resolve('babel-plugin-transform-es2015-destructuring'), | ||
require.resolve('babel-plugin-transform-es2015-modules-commonjs'), | ||
require.resolve('babel-plugin-transform-export-extensions'), | ||
].join(','); | ||
'babel-plugin-transform-object-rest-spread', | ||
'babel-plugin-transform-es2015-spread', | ||
'babel-plugin-transform-es2015-function-name', | ||
'babel-plugin-transform-es2015-sticky-regex', | ||
'babel-plugin-transform-es2015-unicode-regex', | ||
'babel-plugin-transform-es2015-parameters', | ||
'babel-plugin-transform-es2015-destructuring', | ||
'babel-plugin-transform-es2015-modules-commonjs', | ||
'babel-plugin-transform-export-extensions', | ||
].map((plugin) => require.resolve(plugin)).join(','); | ||
|
||
const babelCommand = (package, extra) => { | ||
extra = extra ? ' ' + extra : ''; | ||
return `${babel} ${package.path}/src --out-dir ${package.path}/lib --source-maps --plugins ${babelPlugins}${extra}`; | ||
} | ||
const babelCommand = (extension, extra) => { | ||
const additional = extra ? ` ${extra}` : ''; | ||
return `${babel} ${extension.path}/src --out-dir ${extension.path}/lib ` + | ||
` --source-maps --plugins ${babelPlugins}${additional}`; | ||
}; | ||
|
||
module.exports = (packages, extra) => { | ||
return packages | ||
.map((package) => babelCommand(package, extra)) | ||
module.exports = (extensions, extra) => | ||
extensions | ||
.map((extension) => babelCommand(extension, extra)) | ||
.join(' & '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = (extensions) => require('./build')(extensions, '--watch'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
const rimraf = require.resolve('rimraf/bin'); | ||
|
||
const clean = (package) => `${rimraf} ${package.path}/lib ${package.path}/esdocs`; | ||
const clean = (extension) => `${rimraf} ${extension.path}/lib ${extension.path}/esdocs`; | ||
|
||
module.exports = (packages) => { | ||
return packages | ||
module.exports = (extensions) => | ||
extensions | ||
.map(clean) | ||
.join(' & '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,24 @@ | ||
const writeFile = require('fs').writeFile; | ||
const join = require('path').join; | ||
|
||
const toHide = Object.keys(require('roc').roc.config.commands).join(','); | ||
|
||
const getConfiguration = require('roc').getConfiguration; | ||
|
||
const rocPackage = require('roc'); | ||
|
||
const settingsDocs = | ||
'node bin/index.js markdown-settings > ./docs/Settings.md'; | ||
const commandsDocs = | ||
`node bin/index.js markdown-commands --hide-commands ${toHide} /dev/docs/Settings.md > ./docs/Commands.md`; | ||
const hooksDocs = | ||
'node bin/index.js markdown-hooks > ./docs/Hooks.md'; | ||
const actionsDocs = | ||
'node bin/index.js markdown-actions > ./docs/Actions.md'; | ||
|
||
const generateDocumentation = (path) => | ||
`cd ${path} && ${settingsDocs} && ${commandsDocs} && ${hooksDocs} && ${actionsDocs}`; | ||
|
||
const writeFilePromise = (file) => { | ||
return new Promise((resolve, reject) => { | ||
writeFile(file.path, file.content, (err) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
|
||
return resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = (packages) => () => { | ||
return Promise.all(packages.map((package) => { | ||
const rocCommandObject = getConfiguration(package.path); | ||
|
||
return Promise.all([ | ||
{ | ||
content: rocPackage.generateMarkdownActions(package.name, rocCommandObject.actions), | ||
path: `${package.path}/docs/Actions.md` | ||
}, { | ||
content: rocPackage.generateMarkdownHooks(package.name, rocCommandObject.hooks), | ||
path: `${package.path}/docs/Hooks.md` | ||
}, { | ||
content: rocPackage.generateMarkdownDocumentation(package.name, rocCommandObject.packageConfig, rocCommandObject.metaObject), | ||
path: `${package.path}/docs/Settings.md` | ||
}, { | ||
content: rocPackage.generateMarkdownCommands( | ||
package.name, | ||
rocCommandObject.packageConfig, | ||
rocCommandObject.metaObject, | ||
`/packages/${package.folder}/docs/Settings.md` | ||
), | ||
path: `${package.path}/docs/Commands.md` | ||
} | ||
].map(writeFilePromise)); | ||
})).then(() => console.log('Done')) | ||
const chalk = require('chalk'); | ||
const buildContext = require('roc/lib/context/buildContext').default; | ||
const generateDocumentation = require('roc/lib/documentation/markdown/generateDocumentation').default; | ||
const log = require('roc/log/default/small'); | ||
|
||
module.exports = (extensions) => () => | ||
extensions.reduce((promise, extension) => | ||
promise.then(() => { | ||
log.log(`Generating documentation for ${chalk.cyan(extension.name)}`); | ||
return generateDocumentation({ | ||
commandObject: { | ||
context: buildContext(extension.path, undefined, false), | ||
directory: extension.path, | ||
}, | ||
extension: true, | ||
}); | ||
}), Promise.resolve()) | ||
.then(() => { | ||
log.log(); | ||
log.success('Documentation created for all extensions!'); | ||
}) | ||
.catch((err) => { | ||
console.log('An error happened', err) | ||
process.exit(1); | ||
log.error('An error happened when generating documentation', err); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const fs = require('fs'); | ||
|
||
const roc = require('roc'); | ||
const converters = require('roc/converters'); | ||
const validators = require('roc/validators'); | ||
|
||
const extensions = | ||
!roc.folderExists(`${process.cwd()}/extensions`) ? [] : | ||
fs.readdirSync(`${process.cwd()}/extensions`) | ||
.map((extension) => { | ||
if (roc.fileExists(`${process.cwd()}/extensions/${extension}/package.json`)) { | ||
return { | ||
folder: extension, | ||
path: `${process.cwd()}/extensions/${extension}`, | ||
name: require(`${process.cwd()}/extensions/${extension}/package.json`).name, | ||
}; | ||
} | ||
return undefined; | ||
}) | ||
.filter((extension) => extension !== undefined); | ||
|
||
module.exports = { | ||
build: { | ||
command: require('./build')(extensions), | ||
description: 'Builds project', | ||
}, | ||
'build:watch': { | ||
command: require('./buildWatch')(extensions), | ||
description: 'Builds project in watch mode', | ||
}, | ||
clean: { | ||
command: require('./clean')(extensions), | ||
description: 'Cleans generated files', | ||
}, | ||
docs: { | ||
command: require('./docs')(extensions), | ||
description: 'Generates markdown documentation', | ||
}, | ||
esdocs: { | ||
command: require('./esdocs')(extensions), | ||
description: 'Generates ESDoc', | ||
}, | ||
link: { | ||
command: require('./link')(extensions), | ||
description: 'Links up the project', | ||
arguments: { | ||
modules: { | ||
description: 'Modules that should be linked into the extensions in extensions/', | ||
converter: converters.toArray(), | ||
validator: validators.isArray(), | ||
}, | ||
}, | ||
}, | ||
'lint:alias': { | ||
command: require('./lintAlias')(extensions), | ||
description: 'Run local lint inside packages', | ||
}, | ||
lint: { | ||
command: require('./lint')(extensions), | ||
description: 'Runs lint', | ||
}, | ||
release: { | ||
command: require('./release')(extensions), | ||
description: 'Run release script', | ||
options: { | ||
'use-alias': { | ||
description: 'If lint:alias should be used over the default lint when doing releases', | ||
default: false, | ||
converter: converters.toBoolean, | ||
validator: validators.isBoolean, | ||
}, | ||
}, | ||
}, | ||
rnm: { | ||
command: require('./removeNodeModules')(extensions), | ||
description: 'Removes node_modules folders in extensions/', | ||
}, | ||
}; |
Oops, something went wrong.