Skip to content
Draft
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
23 changes: 15 additions & 8 deletions docworks-cli/src/run-dts.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
const path = require('path')
const dts = require('docworks-dts')
const { dts2 } = require('docworks-dts')
const logger = require('./logger')
const {writeOutput} = require('./utils/fsUtil')
const {readRepoFromRemoteOrLocal} = require('./utils/gitUtils')
const isArray_ = require('lodash/isArray')

async function runDts(outputFileName, outputDirName,
{ remote, local, run$wFixer, summaryTemplate, ignoredModules, ignoredNamespaces }) {

try {
let repo = await readRepoFromRemoteOrLocal({remote, local})
const toPick = ''
const services = repo.services.filter(s => (s.name && s.name.endsWith(toPick)) || (s.memberOf && s.memberOf.includes(toPick)))

if(run$wFixer){
logger.command('running with $w fixer', '')
}

logger.command('docworks dts', '')
debugger
const dtsResult = dts2(services, {run$wFixer, summaryTemplate, ignoredModules, ignoredNamespaces })
if (isArray_(dtsResult)) {
return Promise.all(dtsResult.map(res => writeOutput(`${outputDirName}/${res.name}.d.ts`, res.content)))
}
else {
const fileNameWithExtensions = `${outputFileName}.d.ts`
const fullPath = path.join(outputDirName, fileNameWithExtensions)

const dtsContent = dts(repo.services, {run$wFixer, summaryTemplate, ignoredModules, ignoredNamespaces })

const fileNameWithExtensions = `${outputFileName}.d.ts`
const fullPath = path.join(outputDirName, fileNameWithExtensions)

logger.command('dts saving to file...', fullPath)
logger.command('dts saving to file...', fullPath)

return writeOutput(fullPath, dtsContent)
return writeOutput(fullPath, dtsContent)
}
}
catch (error) {
logger.error('failed to complete workflow\n' + error.stack)
Expand Down
2 changes: 2 additions & 0 deletions docworks-dts/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict'

const dts = require('./dts-repo')
const dts2 = require('./new/dts-repo')
const docworksToDtsConverters = require('./dts-converters')
const dtsGenerator = require('./dts-generator')

module.exports = dts
module.exports.docworksToDtsConverters = docworksToDtsConverters
module.exports.dtsGenerator = dtsGenerator
module.exports.dts2 = dts2
Loading