docworks-cli
Advanced tools
Comparing version 1.5.7 to 1.6.0
#!/usr/bin/env node | ||
'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
require('babel-polyfill'); | ||
@@ -18,4 +16,5 @@ | ||
var optimist = require('optimist'); | ||
var resolve = require('resolve'); | ||
var _require = require('../dist/plugins'), | ||
resolveAndInitPlugins = _require.resolveAndInitPlugins; | ||
@@ -49,18 +48,2 @@ if (process.argv.length < 3) { | ||
function resolvePlugins(plugins) { | ||
return (plugins ? Array.isArray(plugins) ? plugins : [plugins] : []).map(function (pluginCmd) { | ||
var _pluginCmd$split = pluginCmd.split(/:(.+)/), | ||
_pluginCmd$split2 = _slicedToArray(_pluginCmd$split, 2), | ||
plugin = _pluginCmd$split2[0], | ||
param = _pluginCmd$split2[1]; | ||
plugin = resolve.sync(plugin, { basedir: '.' }); | ||
try { | ||
var pluginModule = require(plugin); | ||
if (param && pluginModule.init) pluginModule.init(param); | ||
} catch (err) {} | ||
return plugin; | ||
}); | ||
} | ||
function ecp() { | ||
@@ -76,3 +59,3 @@ var argv = optimist.usage('Usage: $0 ecp -r [remote repo] [-b [remote branch]] -s [local sources] -p [file pattern] [--plug [plugin]] [--dryrun]').demand('r').alias('r', 'remote').describe('r', 'remote repository to merge docs into').alias('b', 'branch').describe('b', 'branch on the remote repository to work with').demand('fs').alias('fs', 'sources').describe('fs', 'one or more folders containing the source files to extract docs from').alias('fx', 'excludes').describe('fx', 'one or more folders to exclude (including their children) from extracting docs').default('fp', ".+\\.js?$").alias('fp', 'pattern').describe('fp', 'file pattern, defaults to ".+\\.js$"').demand('p').alias('p', 'project').describe('p', 'project folder name in the docs repo').describe('plug', 'a module name that is a jsdoc or docworks plugin').describe('dryrun', 'dry run - do not push to remote repo').parse(process.argv.slice(3)); | ||
var dryrun = !!argv.dryrun; | ||
var plugins = resolvePlugins(argv.plug); | ||
var plugins = resolveAndInitPlugins(argv.plug); | ||
@@ -91,3 +74,3 @@ tmp.dir().then(function (o) { | ||
var pattern = argv.pattern; | ||
var plugins = resolvePlugins(argv.jsdocplugin); | ||
var plugins = resolveAndInitPlugins(argv.jsdocplugin); | ||
@@ -106,3 +89,3 @@ if (!validate({ "include": sources, "includePattern": pattern }, plugins)) process.exit(1); | ||
var outputFileName = argv.out; | ||
var plugins = resolvePlugins(argv.plug); | ||
var plugins = resolveAndInitPlugins(argv.plug); | ||
@@ -109,0 +92,0 @@ if (!remote && !local || !!remote && !!local) { |
@@ -31,2 +31,4 @@ 'use strict'; | ||
var _plugins = require('./plugins'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -154,7 +156,13 @@ | ||
logger.log(' running ecpAfterMerge plugins'); | ||
_context.next = 45; | ||
return (0, _plugins.runPlugins)(plugins, 'ecpAfterMerge', workingDir, projectSubdir); | ||
case 45: | ||
logger.command('git status', ''); | ||
_context.next = 45; | ||
_context.next = 48; | ||
return localGit.status(); | ||
case 45: | ||
case 48: | ||
statuses = _context.sent; | ||
@@ -168,3 +176,3 @@ files = []; | ||
if (!dryrun) { | ||
_context.next = 55; | ||
_context.next = 58; | ||
break; | ||
@@ -176,8 +184,8 @@ } | ||
logger.command('# git push', 'origin master'); | ||
_context.next = 68; | ||
_context.next = 71; | ||
break; | ||
case 55: | ||
case 58: | ||
if (!(files.length > 0)) { | ||
_context.next = 67; | ||
_context.next = 70; | ||
break; | ||
@@ -187,31 +195,31 @@ } | ||
logger.command('git', 'add ' + files.join(' ')); | ||
_context.next = 59; | ||
_context.next = 62; | ||
return localGit.add(files); | ||
case 59: | ||
case 62: | ||
logger.rawLog(' ' + _chalk2.default.white('git commit -m') + ' \'' + _chalk2.default.gray(commitMessage(projectSubdir, merged.messages, errors, ' ')) + '\''); | ||
_context.next = 62; | ||
_context.next = 65; | ||
return localGit.commit(commitMessage(projectSubdir, merged.messages, errors, '')); | ||
case 62: | ||
case 65: | ||
logger.command('git push', 'origin ' + (remoteBranch ? remoteBranch : 'master')); | ||
_context.next = 65; | ||
_context.next = 68; | ||
return localGit.push('origin', remoteBranch ? remoteBranch : 'master'); | ||
case 65: | ||
_context.next = 68; | ||
case 68: | ||
_context.next = 71; | ||
break; | ||
case 67: | ||
case 70: | ||
logger.log('no changes detected'); | ||
case 68: | ||
case 71: | ||
logger.success('completed workflow'); | ||
_context.next = 75; | ||
_context.next = 78; | ||
break; | ||
case 71: | ||
_context.prev = 71; | ||
case 74: | ||
_context.prev = 74; | ||
_context.t1 = _context['catch'](9); | ||
@@ -222,3 +230,3 @@ | ||
case 75: | ||
case 78: | ||
case 'end': | ||
@@ -228,3 +236,3 @@ return _context.stop(); | ||
} | ||
}, _callee, this, [[9, 71], [18, 25]]); | ||
}, _callee, this, [[9, 74], [18, 25]]); | ||
})); | ||
@@ -231,0 +239,0 @@ |
{ | ||
"name": "docworks-cli", | ||
"version": "1.5.7", | ||
"version": "1.6.0", | ||
"description": "", | ||
@@ -19,5 +19,5 @@ "main": "index.js", | ||
"chalk": "^2.3.0", | ||
"docworks-jsdoc2spec": "^1.5.7", | ||
"docworks-repo": "^1.5.7", | ||
"docworks-tern": "^1.5.7", | ||
"docworks-jsdoc2spec": "^1.6.0", | ||
"docworks-repo": "^1.6.0", | ||
"docworks-tern": "^1.6.0", | ||
"fs-extra": "^5.0.0", | ||
@@ -24,0 +24,0 @@ "optimist": "^0.6.1", |
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
let optimist = require('optimist'); | ||
let resolve = require('resolve'); | ||
let {resolveAndInitPlugins} = require('../dist/plugins'); | ||
import runTern from '../dist/run-tern'; | ||
@@ -41,20 +41,3 @@ | ||
function resolvePlugins(plugins) { | ||
return (plugins?(Array.isArray(plugins)?plugins:[plugins]):[]) | ||
.map(pluginCmd => { | ||
let [plugin, param] = pluginCmd.split(/:(.+)/); | ||
plugin = resolve.sync(plugin, {basedir: '.'}); | ||
try { | ||
let pluginModule = require(plugin); | ||
if (param && pluginModule.init) | ||
pluginModule.init(param); | ||
} | ||
catch (err) { | ||
} | ||
return plugin; | ||
} | ||
); | ||
} | ||
function ecp() { | ||
@@ -90,3 +73,3 @@ let argv = optimist | ||
let dryrun = !!argv.dryrun; | ||
let plugins = resolvePlugins(argv.plug); | ||
let plugins = resolveAndInitPlugins(argv.plug); | ||
@@ -116,3 +99,3 @@ tmp.dir().then(o => { | ||
let pattern = argv.pattern; | ||
let plugins = resolvePlugins(argv.jsdocplugin); | ||
let plugins = resolveAndInitPlugins(argv.jsdocplugin); | ||
@@ -148,3 +131,3 @@ if (!validate({"include": sources, "includePattern": pattern}, plugins)) | ||
let outputFileName = argv.out; | ||
let plugins = resolvePlugins(argv.plug); | ||
let plugins = resolveAndInitPlugins(argv.plug); | ||
@@ -151,0 +134,0 @@ if (!remote && !local || (!!remote && !!local)) { |
@@ -8,2 +8,3 @@ import runJsDoc from 'docworks-jsdoc2spec'; | ||
import chalk from 'chalk'; | ||
import {runPlugins} from './plugins'; | ||
@@ -92,2 +93,5 @@ function commitMessage(projectSubdir, messages, errors, indent) { | ||
logger.log(' running ecpAfterMerge plugins'); | ||
await runPlugins(plugins, 'ecpAfterMerge', workingDir, projectSubdir); | ||
logger.command('git status', ''); | ||
@@ -94,0 +98,0 @@ let statuses = await localGit.status(); |
@@ -223,2 +223,12 @@ import chai from 'chai'; | ||
it.only('run ecpAfterMerge plugin', async function() { | ||
await createRemoteOnVer1(); | ||
logger.log('run test'); | ||
logger.log('--------'); | ||
await runDocWorks(`.bin/docworks ecp -r ${remote} --fs test/include/folder1 -p ${project2} --fp .+\\.js?$ --plug ./test/ecp-plugin`.split(' ')); | ||
let remoteRepo = new Git(remote); | ||
let createdByPlugins = await remoteRepo.fileExists(join(project2, "created-by-plugin")); | ||
expect(createdByPlugins).to.be.true; | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 9 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97738
68
1976
15
11
Updateddocworks-jsdoc2spec@^1.6.0
Updateddocworks-repo@^1.6.0
Updateddocworks-tern@^1.6.0