Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Adding luis:version:export cmd #356

Merged
merged 8 commits into from
Nov 15, 2019
Merged

Adding luis:version:export cmd #356

merged 8 commits into from
Nov 15, 2019

Conversation

jspruance
Copy link

No description provided.

@jspruance
Copy link
Author

fixes #305

const appJSON = await client.versions.exportMethod(appId, versionId)
if (appJSON) {
const outputPath = out ? out : ''
await utils.writeOutput(outputPath, appJSON, force)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it is very clean and helps to reduce code duplication having this on the utils file, I think it is easier to understand the command flow by keeping the flags processing in the command. e.g

if (flags.out) {
 writeToFile()
} else {
writeToConsole()
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved flag parsing to cmd


const writeToConsole = (outputContents: string) => {
const output = JSON.stringify(outputContents, null, 2)
process.stdout.write('App successfully exported\n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep command responsibilities at the command level. e.g

// Command class
writeToConsole()
this.log(App successfully exported)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored

const validatedPath = utils.validatePath(outputLocation, '', force)
await fs.ensureFile(outputLocation)
await fs.writeJson(validatedPath, content, {spaces: 2})
process.stdout.write(`File successfully written: ${validatedPath}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep command responsibilities(logging) at the command level. e.g

// Command class
const path = writeToFile()
this.log(`File successfully written: ${path}`)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually wanted to do that too, but with this model, the tests have a hard time reading the message since 'ctx.stdout' typically only reads the first line. need to think about how to overcome that:

expect(ctx.stdout).to.contain('File successfully written')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This.log uses process.stdout.write under the hood

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored

Copy link
Contributor

@munozemilio munozemilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CIL

@@ -36,17 +36,27 @@ const getLUISClient = (subscriptionKey: string, endpoint: string) => {
return luisClient
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this util function in order to limit the allowed config vars to 'appId, region, subscriptionKey, versionId' per Eyal's specs

Copy link
Contributor

@munozemilio munozemilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@jspruance jspruance merged commit c08a09a into master Nov 15, 2019
ninggao pushed a commit that referenced this pull request Nov 18, 2019
* Adding luis:version:export cmd

* Remove dependency

* Update example

* Only store certain values in config, per specs

* Refactor / keep logging and flag parsing in cmd only

* Refactor write file error handling
@jspruance jspruance deleted the 305-luis-version-export branch December 19, 2019 00:07
@munozemilio
Copy link
Contributor

Fixes #47

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants