docworks-cli
Advanced tools
Comparing version 1.10.7 to 1.10.8
{ | ||
"name": "docworks-cli", | ||
"version": "1.10.7", | ||
"version": "1.10.8", | ||
"description": "", | ||
@@ -21,6 +21,6 @@ "main": "src/docworks.js", | ||
"chalk": "^2.3.0", | ||
"docworks-dts": "^1.10.7", | ||
"docworks-jsdoc2spec": "^1.10.7", | ||
"docworks-repo": "^1.10.7", | ||
"docworks-tern": "^1.10.7", | ||
"docworks-dts": "^1.10.8", | ||
"docworks-jsdoc2spec": "^1.10.8", | ||
"docworks-repo": "^1.10.8", | ||
"docworks-tern": "^1.10.8", | ||
"fs-extra": "^5.0.0", | ||
@@ -44,3 +44,3 @@ "optimist": "^0.6.1", | ||
}, | ||
"gitHead": "997590a7092bf4a16de087ea35136e3d89188a13" | ||
"gitHead": "d5acf5d002a5b8b8b488f85972ee67d42e5d2eed" | ||
} |
@@ -126,5 +126,7 @@ const tmp = require('tmp-promise') | ||
const cmdDefinition = optimist | ||
.usage('Usage: $0 tern (-r [remote repo] | -l [local services folder] ) -u [base url] -n [api name] -o [output file]') | ||
.usage('Usage: $0 tern (-r [remote repo] [-b [remote branch]] | -l [local services folder] ) -u [base url] -n [api name] -o [output file]') | ||
.alias('r', 'remote') | ||
.describe('r', 'remote repository to read docworks services files from') | ||
.alias('b', 'branch') | ||
.describe('b', 'branch on the remote repository to fetch the docs from') | ||
.alias('l', 'local') | ||
@@ -146,2 +148,3 @@ .describe('l', 'folder containing docwork service files') | ||
let remote = argv.remote | ||
let branch = argv.branch | ||
let local = argv.local | ||
@@ -159,3 +162,3 @@ let baseUrl = argv.url | ||
return runTern(remote, local, baseUrl, apiName, outputFileName, plugins) | ||
return runTern({remote, branch, local, baseUrl, apiName, outputFileName, plugins}) | ||
.catch(() => { | ||
@@ -162,0 +165,0 @@ process.exit(1) |
@@ -6,6 +6,6 @@ const tern = require('docworks-tern') | ||
async function runTern(remote, local, baseUrl, apiName, outputFileName, plugins) { | ||
async function runTern({remote, branch, local, baseUrl, apiName, outputFileName, plugins}) { | ||
try { | ||
let repo = await readRepoFromRemoteOrLocal({remote, local}) | ||
let repo = await readRepoFromRemoteOrLocal({remote, branch, local}) | ||
@@ -12,0 +12,0 @@ logger.config('plugins: ', plugins.join(', ')) |
@@ -7,3 +7,3 @@ const Git = require('../git') | ||
async function cloneToDir(remote) { | ||
async function cloneToDir(remote, branch) { | ||
let tmpDir = await tmp.dir() | ||
@@ -16,4 +16,4 @@ | ||
let baseGit = new Git() | ||
logger.command('git', `clone ${remote} ${workingDir}`) | ||
await baseGit.clone(remote, workingDir, ['--depth', 1]) | ||
logger.command('git', `clone ${remote} ${branch ? `--branch ${branch}` : ''} ${workingDir}`) | ||
await baseGit.clone(remote, workingDir, ['--depth', 1].concat(branch ? ['--branch', branch] : [])) | ||
@@ -23,7 +23,7 @@ return workingDir | ||
async function readRepoFromRemoteOrLocal({remote, local}) { | ||
async function readRepoFromRemoteOrLocal({remote, branch, local}) { | ||
let localServicesDir | ||
if (remote) { | ||
logger.config('remote repo url: ', remote) | ||
localServicesDir = await cloneToDir(remote) | ||
localServicesDir = await cloneToDir(remote, branch) | ||
} else if (local) { | ||
@@ -30,0 +30,0 @@ logger.config('local sources: ', local) |
@@ -53,2 +53,32 @@ import chai from 'chai' | ||
it('generate tern from a remote repo\'s non-master branch', async function () { | ||
const remote = './tmp/remote' | ||
const branch = 'test-branch' | ||
await createRemoteOnVer1(remote, branch) | ||
logger.log('run test') | ||
logger.log('--------') | ||
await runCommand(`./bin/docworks tern -r ${remote} -b ${branch} -u http://base-url.com -n apiname -o ./tmp/tern.js`.split(' ')) | ||
let content = await fsExtra.readFile('tmp/tern.js', 'utf-8') | ||
expect(content).to.equal( | ||
`{ | ||
"!define": { | ||
"Service": { | ||
"!doc": "this is a service", | ||
"!url": "http://base-url.com/Service.html", | ||
"prototype": { | ||
"operation": { | ||
"!type": "fn(param: string)", | ||
"!doc": "", | ||
"!url": "http://base-url.com/Service.html#operation" | ||
} | ||
} | ||
} | ||
}, | ||
"!name": "apiname" | ||
}` | ||
) | ||
}) | ||
it('generate tern from a remote repo with a tern plugin', async function () { | ||
@@ -55,0 +85,0 @@ const remote = './tmp/remote' |
@@ -10,3 +10,3 @@ import fs from 'fs-extra' | ||
async function createRemoteOnVer1(remote) { | ||
async function createRemoteOnVer1(remote, branch) { | ||
const ver1 = './test/ver1' | ||
@@ -24,2 +24,11 @@ const project1 = 'project1' | ||
await asPromise(remoteBuildRepo, remoteBuildRepo.init)() | ||
logger.log('git commit -m "initial commit" --allow-empty') | ||
await asPromise(remoteBuildRepo, remoteBuildRepo.commit)('initial commit', undefined, {'--allow-empty': true}) | ||
if (branch) { | ||
logger.log(`git checkout -b ${branch}`) | ||
await asPromise(remoteBuildRepo, remoteBuildRepo.checkout)(['-b', branch]) | ||
} | ||
// run js doc | ||
@@ -37,4 +46,9 @@ logger.log(`jsdoc ${ver1}`) | ||
// commit | ||
await asPromise(remoteBuildRepo, remoteBuildRepo.commit)('initial commit') | ||
await asPromise(remoteBuildRepo, remoteBuildRepo.commit)('docs commit') | ||
if (branch) { | ||
logger.log('git checkout master') | ||
await asPromise(remoteBuildRepo, remoteBuildRepo.checkout)('master') | ||
} | ||
logger.log(`git clone ${remoteBuild} ${remote} --bare`) | ||
@@ -41,0 +55,0 @@ await asPromise(baseGit, baseGit.clone)(remoteBuild, remote, ['--bare']) |
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
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
66830
1752
Updateddocworks-dts@^1.10.8
Updateddocworks-jsdoc2spec@^1.10.8
Updateddocworks-repo@^1.10.8
Updateddocworks-tern@^1.10.8