|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import {CLIError, Command, flags} from '@microsoft/bf-cli-command' |
| 7 | +import fetch from 'node-fetch' |
7 | 8 |
|
8 | 9 | const utils = require('../../../utils/index') |
9 | 10 |
|
@@ -41,17 +42,26 @@ export default class LuisApplicationPublish extends Command { |
41 | 42 | const requiredProps = {endpoint, subscriptionKey, appId, versionId} |
42 | 43 | utils.validateRequiredProps(requiredProps) |
43 | 44 |
|
44 | | - const client = utils.getLUISClient(subscriptionKey, endpoint) |
45 | | - |
46 | 45 | const applicationPublishObject = { |
47 | 46 | versionId, |
48 | 47 | isStaging: staging, |
49 | 48 | directVersionPublish: direct |
50 | 49 | } |
51 | 50 |
|
52 | 51 | try { |
53 | | - const publishedAppData = await client.apps.publish(appId, applicationPublishObject) |
54 | | - this.log(`${JSON.stringify(publishedAppData, null, 2)}`) |
| 52 | + let url = endpoint + '/luis/authoring/v3.0-preview/apps/' + appId + '/publish' |
| 53 | + const headers = { |
| 54 | + 'Content-Type': 'application/json', |
| 55 | + 'Ocp-Apim-Subscription-Key': subscriptionKey |
| 56 | + } |
| 57 | + const response = await fetch(url, {method: 'POST', headers, body: JSON.stringify(applicationPublishObject)}) |
| 58 | + const messageData = await response.json() |
| 59 | + |
| 60 | + if (messageData.error) { |
| 61 | + throw new CLIError(messageData.error.message) |
| 62 | + } |
| 63 | + |
| 64 | + this.log(`${JSON.stringify(messageData, null, 2)}`) |
55 | 65 | } catch (err) { |
56 | 66 | throw new CLIError(`Failed to publish app: ${err}`) |
57 | 67 | } |
|
0 commit comments