@botpress/cli 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-generation/integration-instance.js +7 -10
- package/dist/code-generation/integration-instance.js.map +2 -2
- package/dist/command-implementations/base-command.js +1 -1
- package/dist/command-implementations/base-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +5 -5
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +32 -20
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/global-command.js +2 -2
- package/dist/command-implementations/global-command.js.map +2 -2
- package/dist/command-implementations/integration-commands.js.map +2 -2
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/consts.js +4 -0
- package/dist/consts.js.map +2 -2
- package/dist/index.js +1 -3
- package/dist/index.js.map +2 -2
- package/dist/init.js.map +2 -2
- package/dist/register-yargs.js +4 -3
- package/dist/register-yargs.js.map +2 -2
- package/dist/root.js +36 -0
- package/dist/root.js.map +7 -0
- package/dist/typings.js.map +1 -1
- package/dist/utils/case-utils.test.js +57 -0
- package/dist/utils/case-utils.test.js.map +7 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/require-utils.test.js +31 -0
- package/dist/utils/require-utils.test.js.map +7 -0
- package/dist/utils/tunnel-utils.js +126 -0
- package/dist/utils/tunnel-utils.js.map +7 -0
- package/dist/worker/child-wrapper.js +4 -0
- package/dist/worker/child-wrapper.js.map +2 -2
- package/package.json +3 -3
- package/templates/echo-bot/package.json +3 -4
- package/templates/echo-bot/tsconfig.json +14 -1
- package/templates/empty-integration/package.json +3 -4
- package/templates/empty-integration/tsconfig.json +14 -1
|
@@ -37,26 +37,23 @@ import type { Configuration } from './configuration'
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
export type ${propsName} = {
|
|
40
|
-
enabled
|
|
41
|
-
config: Configuration
|
|
42
|
-
} | {
|
|
43
|
-
enabled: false
|
|
40
|
+
enabled?: boolean
|
|
44
41
|
config?: Configuration
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
export class ${className} implements IntegrationInstance {
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
|
|
51
47
|
public readonly name = '${name}'
|
|
52
48
|
public readonly version = '${version}'
|
|
53
49
|
public readonly id = '${id}'
|
|
54
|
-
|
|
55
|
-
public readonly
|
|
50
|
+
|
|
51
|
+
public readonly enabled?: boolean
|
|
52
|
+
public readonly configuration?: Configuration
|
|
56
53
|
|
|
57
54
|
constructor(props?: ${propsName}) {
|
|
58
|
-
this.enabled = props?.enabled
|
|
59
|
-
this.configuration = props?.config
|
|
55
|
+
this.enabled = props?.enabled
|
|
56
|
+
this.configuration = props?.config
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/integration-instance.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Integration } from '@botpress/client'\nimport { casing } from '../utils'\nimport { ConfigurationModule } from './configuration'\nimport { INDEX_FILE } from './const'\nimport { Module, ModuleDef } from './module'\n\nconst CONTENT = ({\n name,\n className,\n propsName,\n version,\n id,\n}: {\n name: string\n className: string\n propsName: string\n version: string\n id: string\n}) => `\nimport type { IntegrationInstance } from '@botpress/sdk'\nimport type { Configuration } from './configuration'\n\n\nexport type ${propsName} = {\n enabled
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAuB;AACvB,2BAAoC;AACpC,mBAA2B;AAC3B,oBAAkC;AAElC,MAAM,UAAU,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMM;AAAA;AAAA;AAAA;AAAA;AAAA,cAKQ;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"sourcesContent": ["import type { Integration } from '@botpress/client'\nimport { casing } from '../utils'\nimport { ConfigurationModule } from './configuration'\nimport { INDEX_FILE } from './const'\nimport { Module, ModuleDef } from './module'\n\nconst CONTENT = ({\n name,\n className,\n propsName,\n version,\n id,\n}: {\n name: string\n className: string\n propsName: string\n version: string\n id: string\n}) => `\nimport type { IntegrationInstance } from '@botpress/sdk'\nimport type { Configuration } from './configuration'\n\n\nexport type ${propsName} = {\n enabled?: boolean\n config?: Configuration\n}\n\nexport class ${className} implements IntegrationInstance {\n \n \n public readonly name = '${name}'\n public readonly version = '${version}'\n public readonly id = '${id}'\n \n public readonly enabled?: boolean\n public readonly configuration?: Configuration\n\n constructor(props?: ${propsName}) {\n this.enabled = props?.enabled\n this.configuration = props?.config\n }\n}\n`\n\nexport class IntegrationInstanceIndexModule extends Module {\n public static async create(integration: Integration): Promise<IntegrationInstanceIndexModule> {\n const { name, version, id } = integration\n\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\n\n const exportName = casing.to.pascalCase(name)\n\n const content = CONTENT({ name, className: exportName, propsName: `${exportName}Props`, version, id })\n const inst = new IntegrationInstanceIndexModule({ path: INDEX_FILE, content, exportName })\n\n inst.pushDep(configModule)\n\n return inst\n }\n\n private constructor(def: ModuleDef) {\n super(def)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAuB;AACvB,2BAAoC;AACpC,mBAA2B;AAC3B,oBAAkC;AAElC,MAAM,UAAU,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAMM;AAAA;AAAA;AAAA;AAAA;AAAA,cAKQ;AAAA;AAAA;AAAA;AAAA;AAAA,eAKC;AAAA;AAAA;AAAA,4BAGa;AAAA,+BACG;AAAA,0BACL;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKF;AAAA;AAAA;AAAA;AAAA;AAAA;AAOjB,MAAM,uCAAuC,qBAAO;AAAA,EACzD,aAAoB,OAAO,aAAmE;AAC5F,UAAM,EAAE,MAAM,SAAS,GAAG,IAAI;AAE9B,UAAM,eAAe,MAAM,yCAAoB,OAAO,YAAY,iBAAiB,EAAE,QAAQ,CAAC,EAAE,CAAC;AAEjG,UAAM,aAAa,oBAAO,GAAG,WAAW,IAAI;AAE5C,UAAM,UAAU,QAAQ,EAAE,MAAM,WAAW,YAAY,WAAW,GAAG,mBAAmB,SAAS,GAAG,CAAC;AACrG,UAAM,OAAO,IAAI,+BAA+B,EAAE,MAAM,yBAAY,SAAS,WAAW,CAAC;AAEzF,SAAK,QAAQ,YAAY;AAEzB,WAAO;AAAA,EACT;AAAA,EAEQ,YAAY,KAAgB;AAClC,UAAM,GAAG;AAAA,EACX;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/base-command.ts"],
|
|
4
|
-
"sourcesContent": ["import * as errors from '../errors'\nimport type { Logger } from '../logger'\nimport type { CommandArgv, CommandDefinition } from '../typings'\n\nexport abstract class BaseCommand<C extends CommandDefinition> {\n public constructor(protected readonly logger: Logger, protected readonly argv: CommandArgv<C>) {}\n\n protected abstract run(): Promise<void>\n protected abstract bootstrap?: () => Promise<void>\n protected abstract teardown?: () => Promise<void>\n\n public async handler(): Promise<
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AAIjB,MAAe,YAAyC;AAAA,EACtD,YAA+B,QAAmC,MAAsB;AAAzD;AAAmC;AAAA,EAAuB;AAAA,EAMhG,MAAa,
|
|
4
|
+
"sourcesContent": ["import * as errors from '../errors'\nimport type { Logger } from '../logger'\nimport type { CommandArgv, CommandDefinition } from '../typings'\n\nexport abstract class BaseCommand<C extends CommandDefinition> {\n public constructor(protected readonly logger: Logger, protected readonly argv: CommandArgv<C>) {}\n\n protected abstract run(): Promise<void>\n protected abstract bootstrap?: () => Promise<void>\n protected abstract teardown?: () => Promise<void>\n\n public async handler(): Promise<{ exitCode: number }> {\n let exitCode = 0\n try {\n if (this.bootstrap) {\n await this.bootstrap()\n }\n await this.run()\n } catch (thrown) {\n const error = errors.BotpressCLIError.map(thrown)\n\n if (error.debug) {\n const msg = error.message + ' (Run with verbose flag (-v) to see more details)'\n this.logger.error(msg)\n this.logger.debug(error.debug)\n } else {\n this.logger.error(error.message)\n }\n\n exitCode = 1\n } finally {\n if (this.teardown) {\n await this.teardown()\n }\n }\n\n return { exitCode }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AAIjB,MAAe,YAAyC;AAAA,EACtD,YAA+B,QAAmC,MAAsB;AAAzD;AAAmC;AAAA,EAAuB;AAAA,EAMhG,MAAa,UAAyC;AACpD,QAAI,WAAW;AACf,QAAI;AACF,UAAI,KAAK,WAAW;AAClB,cAAM,KAAK,UAAU;AAAA,MACvB;AACA,YAAM,KAAK,IAAI;AAAA,IACjB,SAAS,QAAP;AACA,YAAM,QAAQ,OAAO,iBAAiB,IAAI,MAAM;AAEhD,UAAI,MAAM,OAAO;AACf,cAAM,MAAM,MAAM,UAAU;AAC5B,aAAK,OAAO,MAAM,GAAG;AACrB,aAAK,OAAO,MAAM,MAAM,KAAK;AAAA,MAC/B,OAAO;AACL,aAAK,OAAO,MAAM,MAAM,OAAO;AAAA,MACjC;AAEA,iBAAW;AAAA,IACb,UAAE;AACA,UAAI,KAAK,UAAU;AACjB,cAAM,KAAK,SAAS;AAAA,MACtB;AAAA,IACF;AAEA,WAAO,EAAE,SAAS;AAAA,EACpB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -113,15 +113,15 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
113
113
|
...acc,
|
|
114
114
|
[channelName]: {
|
|
115
115
|
...channelDef,
|
|
116
|
-
messages: utils.records.setOnNullMissingValues(channelDef
|
|
116
|
+
messages: utils.records.setOnNullMissingValues(channelDef?.messages, currentChannel?.messages),
|
|
117
117
|
message: {
|
|
118
|
-
...channelDef
|
|
119
|
-
tags: utils.records.setOnNullMissingValues(channelDef
|
|
118
|
+
...channelDef?.message,
|
|
119
|
+
tags: utils.records.setOnNullMissingValues(channelDef?.message?.tags, currentChannel?.message.tags)
|
|
120
120
|
},
|
|
121
121
|
conversation: {
|
|
122
|
-
...channelDef
|
|
122
|
+
...channelDef?.conversation,
|
|
123
123
|
tags: utils.records.setOnNullMissingValues(
|
|
124
|
-
channelDef
|
|
124
|
+
channelDef?.conversation?.tags,
|
|
125
125
|
currentChannel?.conversation.tags
|
|
126
126
|
)
|
|
127
127
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/deploy-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { Bot as BotImpl, IntegrationDefinition } from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport type { ApiClient } from 'src/api-client'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\ntype CreateIntegrationBody = Parameters<bpclient.Client['createIntegration']>[0]\ntype UpdateIntegrationBody = Parameters<bpclient.Client['updateIntegration']>[0]\ntype UpdateBotBody = Parameters<bpclient.Client['updateBot']>[0]\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n if (api.url !== consts.defaultBotpressApiUrl) {\n this.logger.log(`Using custom url ${api.url}`)\n }\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n return this._deployIntegration(api, integrationDef)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n let code = await fs.promises.readFile(outfile, 'utf-8')\n\n const secrets = await this.promptSecrets(integrationDef, this.argv)\n // TODO: provide these secrets to the backend by API and remove this string replacement hack\n for (const [secretName, secretValue] of Object.entries(secrets)) {\n code = code.replace(new RegExp(`process\\\\.env\\\\.${secretName}`, 'g'), `\"${secretValue}\"`)\n }\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath } = integrationDef\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will overwrite the existing one.')\n message = `Are you sure you want to override integration ${integrationDef.name} v${integrationDef.version}?`\n } else {\n message = `Are you sure you want to deploy integration ${integrationDef.name} v${integrationDef.version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const publishBody: CreateIntegrationBody = {\n ...integrationDef,\n icon: iconFileContent,\n readme: readmeFileContent,\n code,\n }\n\n const line = this.logger.line()\n line.started(`Deploying integration ${chalk.bold(integrationDef.name)} v${integrationDef.version}...`)\n if (integration) {\n const publishUpdateBody: UpdateIntegrationBody = this._prepareUpdateIntegrationBody(integration, {\n id: integration.id,\n ...publishBody,\n })\n\n await api.client.updateIntegration(publishUpdateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${integrationDef.name}\"`)\n })\n } else {\n await api.client.createIntegration(publishBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${integrationDef.name}\"`)\n })\n }\n line.success('Integration deployed')\n }\n\n // all fields that were removed are replaced by null for the API to remove them\n private _prepareUpdateIntegrationBody = (\n integration: bpclient.Integration,\n body: UpdateIntegrationBody\n ): UpdateIntegrationBody => ({\n ...body,\n actions: utils.records.setOnNullMissingValues(body.actions, integration.actions),\n events: utils.records.setOnNullMissingValues(body.events, integration.events),\n states: utils.records.setOnNullMissingValues(body.states, integration.states),\n user: {\n ...body.user,\n tags: utils.records.setOnNullMissingValues(body.user?.tags, integration.user?.tags),\n },\n channels: Object.entries(body.channels ?? {}).reduce((acc, [channelName, channelDef]) => {\n const currentChannel = integration.channels[channelName]\n return {\n ...acc,\n [channelName]: {\n ...channelDef,\n messages: utils.records.setOnNullMissingValues(channelDef.messages, currentChannel?.messages),\n message: {\n ...channelDef.message,\n tags: utils.records.setOnNullMissingValues(channelDef.message?.tags, currentChannel?.message.tags),\n },\n conversation: {\n ...channelDef.conversation,\n tags: utils.records.setOnNullMissingValues(\n channelDef.conversation?.tags,\n currentChannel?.conversation.tags\n ),\n },\n },\n }\n }, {} as UpdateIntegrationBody['channels']),\n })\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: BotImpl }>(outfile)\n\n const {\n states,\n events,\n recurringEvents,\n configuration: botConfiguration,\n user,\n conversation,\n message,\n } = botImpl.definition\n\n let bot: bpclient.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const integrations = this.prepareIntegrations(botImpl, bot)\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const updateBotBody: UpdateBotBody = this._prepareUpdateBotBody(bot, {\n id: bot.id,\n code,\n states,\n recurringEvents,\n configuration: botConfiguration,\n events,\n user,\n conversation,\n message,\n integrations,\n })\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n // all fields that were removed are replaced by null for the API to remove them\n private _prepareUpdateBotBody = (bot: bpclient.Bot, body: UpdateBotBody): UpdateBotBody => ({\n ...body,\n states: utils.records.setOnNullMissingValues(body.states, bot.states),\n recurringEvents: utils.records.setOnNullMissingValues(body.recurringEvents, bot.recurringEvents),\n events: utils.records.setOnNullMissingValues(body.events, bot.events),\n user: {\n ...body.user,\n tags: utils.records.setOnNullMissingValues(body.user?.tags, bot.user?.tags),\n },\n conversation: {\n ...body.conversation,\n tags: utils.records.setOnNullMissingValues(body.conversation?.tags, bot.conversation?.tags),\n },\n message: {\n ...body.message,\n tags: utils.records.setOnNullMissingValues(body.message?.tags, bot.message?.tags),\n },\n })\n\n private async _createNewBot(api: ApiClient): Promise<bpclient.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<bpclient.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkB;AAClB,SAAoB;AAGpB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAOxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,QAAI,IAAI,QAAQ,OAAO,uBAAuB;AAC5C,WAAK,OAAO,IAAI,oBAAoB,IAAI,KAAK;AAAA,IAC/C;AAEA,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,i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UAAU,MAAM,QAAQ,uBAAuB,
|
|
4
|
+
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { Bot as BotImpl, IntegrationDefinition } from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport type { ApiClient } from 'src/api-client'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\ntype CreateIntegrationBody = Parameters<bpclient.Client['createIntegration']>[0]\ntype UpdateIntegrationBody = Parameters<bpclient.Client['updateIntegration']>[0]\ntype UpdateBotBody = Parameters<bpclient.Client['updateBot']>[0]\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n if (api.url !== consts.defaultBotpressApiUrl) {\n this.logger.log(`Using custom url ${api.url}`)\n }\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n return this._deployIntegration(api, integrationDef)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n let code = await fs.promises.readFile(outfile, 'utf-8')\n\n const secrets = await this.promptSecrets(integrationDef, this.argv)\n // TODO: provide these secrets to the backend by API and remove this string replacement hack\n for (const [secretName, secretValue] of Object.entries(secrets)) {\n code = code.replace(new RegExp(`process\\\\.env\\\\.${secretName}`, 'g'), `\"${secretValue}\"`)\n }\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath } = integrationDef\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will overwrite the existing one.')\n message = `Are you sure you want to override integration ${integrationDef.name} v${integrationDef.version}?`\n } else {\n message = `Are you sure you want to deploy integration ${integrationDef.name} v${integrationDef.version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const publishBody: CreateIntegrationBody = {\n ...integrationDef,\n icon: iconFileContent,\n readme: readmeFileContent,\n code,\n }\n\n const line = this.logger.line()\n line.started(`Deploying integration ${chalk.bold(integrationDef.name)} v${integrationDef.version}...`)\n if (integration) {\n const publishUpdateBody: UpdateIntegrationBody = this._prepareUpdateIntegrationBody(integration, {\n id: integration.id,\n ...publishBody,\n })\n\n await api.client.updateIntegration(publishUpdateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${integrationDef.name}\"`)\n })\n } else {\n await api.client.createIntegration(publishBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${integrationDef.name}\"`)\n })\n }\n line.success('Integration deployed')\n }\n\n // all fields that were removed are replaced by null for the API to remove them\n private _prepareUpdateIntegrationBody = (\n integration: bpclient.Integration,\n body: UpdateIntegrationBody\n ): UpdateIntegrationBody => ({\n ...body,\n actions: utils.records.setOnNullMissingValues(body.actions, integration.actions),\n events: utils.records.setOnNullMissingValues(body.events, integration.events),\n states: utils.records.setOnNullMissingValues(body.states, integration.states),\n user: {\n ...body.user,\n tags: utils.records.setOnNullMissingValues(body.user?.tags, integration.user?.tags),\n },\n channels: Object.entries(body.channels ?? {}).reduce((acc, [channelName, channelDef]) => {\n const currentChannel = integration.channels[channelName]\n return {\n ...acc,\n [channelName]: {\n ...channelDef,\n messages: utils.records.setOnNullMissingValues(channelDef?.messages, currentChannel?.messages),\n message: {\n ...channelDef?.message,\n tags: utils.records.setOnNullMissingValues(channelDef?.message?.tags, currentChannel?.message.tags),\n },\n conversation: {\n ...channelDef?.conversation,\n tags: utils.records.setOnNullMissingValues(\n channelDef?.conversation?.tags,\n currentChannel?.conversation.tags\n ),\n },\n },\n }\n }, {} as UpdateIntegrationBody['channels']),\n })\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: BotImpl }>(outfile)\n\n const {\n states,\n events,\n recurringEvents,\n configuration: botConfiguration,\n user,\n conversation,\n message,\n } = botImpl.definition\n\n let bot: bpclient.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const integrations = this.prepareIntegrations(botImpl, bot)\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const updateBotBody: UpdateBotBody = this._prepareUpdateBotBody(bot, {\n id: bot.id,\n code,\n states,\n recurringEvents,\n configuration: botConfiguration,\n events,\n user,\n conversation,\n message,\n integrations,\n })\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n // all fields that were removed are replaced by null for the API to remove them\n private _prepareUpdateBotBody = (bot: bpclient.Bot, body: UpdateBotBody): UpdateBotBody => ({\n ...body,\n states: utils.records.setOnNullMissingValues(body.states, bot.states),\n recurringEvents: utils.records.setOnNullMissingValues(body.recurringEvents, bot.recurringEvents),\n events: utils.records.setOnNullMissingValues(body.events, bot.events),\n user: {\n ...body.user,\n tags: utils.records.setOnNullMissingValues(body.user?.tags, bot.user?.tags),\n },\n conversation: {\n ...body.conversation,\n tags: utils.records.setOnNullMissingValues(body.conversation?.tags, bot.conversation?.tags),\n },\n message: {\n ...body.message,\n tags: utils.records.setOnNullMissingValues(body.message?.tags, bot.message?.tags),\n },\n })\n\n private async _createNewBot(api: ApiClient): Promise<bpclient.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<bpclient.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkB;AAClB,SAAoB;AAGpB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAOxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,QAAI,IAAI,QAAQ,OAAO,uBAAuB;AAC5C,WAAK,OAAO,IAAI,oBAAoB,IAAI,KAAK;AAAA,IAC/C;AAEA,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,iBAAiB,MAAM,KAAK,gCAAgC;AAClE,QAAI,gBAAgB;AAClB,aAAO,KAAK,mBAAmB,KAAK,cAAc;AAAA,IACpD;AACA,WAAO,KAAK,WAAW,KAAK,KAAK,KAAK,OAAO,KAAK,KAAK,YAAY;AAAA,EACrE;AAAA,EAEA,MAAc,YAAY;AACxB,WAAO,IAAI,kCAAa,KAAK,KAAK,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE,IAAI;AAAA,EAC7E;AAAA,EAEA,MAAc,mBAAmB,KAAgB,gBAAuC;AACtF,UAAM,UAAU,KAAK,aAAa,IAAI;AACtC,QAAI,OAAO,MAAM,GAAG,SAAS,SAAS,SAAS,OAAO;AAEtD,UAAM,UAAU,MAAM,KAAK,cAAc,gBAAgB,KAAK,IAAI;AAElE,eAAW,CAAC,YAAY,WAAW,KAAK,OAAO,QAAQ,OAAO,GAAG;AAC/D,aAAO,KAAK,QAAQ,IAAI,OAAO,mBAAmB,cAAc,G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D,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,gBAAgB,KAAgB,OAAkD;AAC9F,UAAM,gBAAgB,MAAM,KAAK,aAAa,KAAK,SAAS,OAAO,OAAO,cAAc;AACtF,YAAM,WAAW,MAAM,IACpB,aAAa,IAAI,OAAO,UAAU,CAAC,MAAM,EAAE,IAAI,EAC/C,MAAM,CAAC,WAAW;AACjB,cAAM,OAAO,iBAAiB,KAAK,QAAQ,+BAA+B;AAAA,MAC5E,CAAC;AAEH,UAAI,CAAC,SAAS,QAAQ;AACpB,cAAM,IAAI,OAAO,iBAAiB;AAAA,MACpC;AAEA,YAAM,UAAU,SAAS,KAAK,CAAC,QAAQ,IAAI,OAAO,SAAS;AAE3D,YAAM,WAAW,MAAM,KAAK,OAAO,OAAO,oCAAoC;AAAA,QAC5E,SAAS,WAAW,EAAE,OAAO,QAAQ,MAAM,OAAO,QAAQ,GAAG;AAAA,QAC7D,SAAS,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,IAAI,MAAM,OAAO,IAAI,GAAG,EAAE;AAAA,MACrE,CAAC;AAED,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,mBAAmB,QAAQ;AAAA,MAC9C;AAEA,aAAO;AAAA,IACT,CAAC;AAED,UAAM,EAAE,KAAK,WAAW,IAAI,MAAM,IAAI,OAAO,OAAO,EAAE,IAAI,cAAc,CAAC,EAAE,MAAM,CAAC,WAAW;AAC3F,YAAM,OAAO,iBAAiB,KAAK,QAAQ,wBAAwB;AAAA,IACrE,CAAC;AAED,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -27,7 +27,6 @@ __export(dev_command_exports, {
|
|
|
27
27
|
DevCommand: () => DevCommand
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(dev_command_exports);
|
|
30
|
-
var import_tunnel = require("@bpinternal/tunnel");
|
|
31
30
|
var import_axios = __toESM(require("axios"));
|
|
32
31
|
var import_chalk = __toESM(require("chalk"));
|
|
33
32
|
var pathlib = __toESM(require("path"));
|
|
@@ -46,6 +45,7 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
46
45
|
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
47
46
|
this._initialDef = await this.readIntegrationDefinitionFromFS();
|
|
48
47
|
let env = {
|
|
48
|
+
...process.env,
|
|
49
49
|
BP_API_URL: api.url,
|
|
50
50
|
BP_TOKEN: api.token
|
|
51
51
|
};
|
|
@@ -69,23 +69,26 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
69
69
|
protocol: isSecured ? "https" : "http",
|
|
70
70
|
path: `/${tunnelId}`
|
|
71
71
|
});
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
const supervisor = new utils.tunnel.TunnelSupervisor(wsTunnelUrl, tunnelId, this.logger);
|
|
73
|
+
supervisor.events.on("connected", ({ tunnel }) => {
|
|
74
|
+
tunnel.events.on(
|
|
75
|
+
"request",
|
|
76
|
+
(req) => void this._forwardTunnelRequest(`http://localhost:${port}`, req).then((res) => {
|
|
77
|
+
tunnel.send(res);
|
|
78
|
+
}).catch((thrown) => {
|
|
79
|
+
const err = errors.BotpressCLIError.wrap(thrown, "An error occurred while handling request");
|
|
80
|
+
this.logger.error(err.message);
|
|
81
|
+
tunnel.send({
|
|
82
|
+
requestId: req.id,
|
|
83
|
+
status: 500,
|
|
84
|
+
body: err.message
|
|
85
|
+
});
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
await supervisor.start();
|
|
88
90
|
await this._runBuild();
|
|
91
|
+
await this._deploy(api, httpTunnelUrl);
|
|
89
92
|
const worker = await this._spawnWorker(env, port);
|
|
90
93
|
try {
|
|
91
94
|
const watcher = await utils.filewatcher.FileWatcher.watch(
|
|
@@ -102,8 +105,12 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
102
105
|
ignore: [this.projectPaths.abs.outDir]
|
|
103
106
|
}
|
|
104
107
|
);
|
|
105
|
-
await Promise.race([worker.wait(), watcher.wait(),
|
|
108
|
+
await Promise.race([worker.wait(), watcher.wait(), supervisor.wait()]);
|
|
109
|
+
if (worker.running) {
|
|
110
|
+
await worker.kill();
|
|
111
|
+
}
|
|
106
112
|
await watcher.close();
|
|
113
|
+
supervisor.close();
|
|
107
114
|
} catch (thrown) {
|
|
108
115
|
throw errors.BotpressCLIError.wrap(thrown, "An error occurred while running the dev server");
|
|
109
116
|
} finally {
|
|
@@ -113,7 +120,6 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
113
120
|
}
|
|
114
121
|
}
|
|
115
122
|
_restart = async (api, worker, tunnelUrl) => {
|
|
116
|
-
await this._deploy(api, tunnelUrl);
|
|
117
123
|
try {
|
|
118
124
|
await this._runBuild();
|
|
119
125
|
} catch (thrown) {
|
|
@@ -121,6 +127,7 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
121
127
|
this.logger.error(error.message);
|
|
122
128
|
return;
|
|
123
129
|
}
|
|
130
|
+
await this._deploy(api, tunnelUrl);
|
|
124
131
|
await worker.reload();
|
|
125
132
|
};
|
|
126
133
|
_deploy = async (api, tunnelUrl) => {
|
|
@@ -224,7 +231,12 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
224
231
|
const integrations = this.prepareIntegrations(botImpl, bot);
|
|
225
232
|
const updateLine = this.logger.line();
|
|
226
233
|
updateLine.started("Deploying dev bot...");
|
|
227
|
-
const { bot: updatedBot } = await api.client.updateBot({
|
|
234
|
+
const { bot: updatedBot } = await api.client.updateBot({
|
|
235
|
+
...botImpl.definition,
|
|
236
|
+
id: bot.id,
|
|
237
|
+
integrations,
|
|
238
|
+
url: externalUrl
|
|
239
|
+
}).catch((thrown) => {
|
|
228
240
|
throw errors.BotpressCLIError.wrap(thrown, "Could not deploy dev bot");
|
|
229
241
|
});
|
|
230
242
|
updateLine.success(`Dev Bot deployed with id "${updatedBot.id}"`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/dev-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { Bot as BotImpl, IntegrationDefinition } from '@botpress/sdk'\nimport { TunnelRequest, TunnelResponse, TunnelTail } from '@bpinternal/tunnel'\nimport axios, { AxiosRequestConfig, AxiosResponse } from 'axios'\nimport chalk from 'chalk'\nimport * as pathlib from 'path'\nimport * as uuid from 'uuid'\nimport type { ApiClient } from '../api-client'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { Worker } from '../worker'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nconst DEFAULT_BOT_PORT = 8075\nconst DEFAULT_INTEGRATION_PORT = 8076\n\nexport type DevCommandDefinition = typeof commandDefinitions.dev\nexport class DevCommand extends ProjectCommand<DevCommandDefinition> {\n private _initialDef: IntegrationDefinition | undefined = undefined\n\n public async run(): Promise<void> {\n this.logger.warn('This command is experimental and subject to breaking changes without notice.')\n\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n this._initialDef = await this.readIntegrationDefinitionFromFS()\n\n let env: Record<string, string> = {\n BP_API_URL: api.url,\n BP_TOKEN: api.token,\n }\n\n let defaultPort = DEFAULT_BOT_PORT\n if (this._initialDef) {\n defaultPort = DEFAULT_INTEGRATION_PORT\n const secrets = await this.promptSecrets(this._initialDef, this.argv)\n env = { ...env, ...secrets }\n }\n\n const port = this.argv.port ?? defaultPort\n\n const urlParseResult = utils.url.parse(this.argv.tunnelUrl)\n if (urlParseResult.status === 'error') {\n throw new errors.BotpressCLIError(`Invalid tunnel URL: ${urlParseResult.error}`)\n }\n\n const tunnelId = uuid.v4()\n\n const { url: parsedTunnelUrl } = urlParseResult\n const isSecured = parsedTunnelUrl.protocol === 'https' || parsedTunnelUrl.protocol === 'wss'\n\n const wsTunnelUrl: string = utils.url.format({ ...parsedTunnelUrl, protocol: isSecured ? 'wss' : 'ws' })\n const httpTunnelUrl: string = utils.url.format({\n ...parsedTunnelUrl,\n protocol: isSecured ? 'https' : 'http',\n path: `/${tunnelId}`,\n })\n\n const tunnel = await TunnelTail.new(wsTunnelUrl, tunnelId)\n tunnel.events.on(\n 'request',\n (req) =>\n void this._forwardTunnelRequest(`http://localhost:${port}`, req)\n .then((res) => {\n tunnel.send(res)\n })\n .catch((thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, 'An error occurred while handling request')\n this.logger.error(err.message)\n tunnel.send({\n requestId: req.id,\n status: 500,\n body: err.message,\n })\n })\n )\n\n await this._deploy(api, httpTunnelUrl)\n await this._runBuild()\n const worker = await this._spawnWorker(env, port)\n\n try {\n const watcher = await utils.filewatcher.FileWatcher.watch(\n this.argv.workDir,\n async (events) => {\n const typescriptEvents = events.filter((e) => pathlib.extname(e.path) === '.ts')\n if (typescriptEvents.length === 0) {\n return\n }\n\n this.logger.log('Changes detected, rebuilding')\n await this._restart(api, worker, httpTunnelUrl)\n },\n {\n ignore: [this.projectPaths.abs.outDir],\n }\n )\n\n await Promise.race([worker.wait(), watcher.wait(), tunnel.wait()])\n await watcher.close()\n // TODO: ensure all processes are closed\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'An error occurred while running the dev server')\n } finally {\n if (worker.running) {\n await worker.kill()\n }\n }\n }\n\n private _restart = async (api: ApiClient, worker: Worker, tunnelUrl: string) => {\n await this._deploy(api, tunnelUrl)\n\n try {\n await this._runBuild()\n } catch (thrown) {\n const error = errors.BotpressCLIError.wrap(thrown, 'Build failed')\n this.logger.error(error.message)\n return\n }\n\n await worker.reload()\n }\n\n private _deploy = async (api: ApiClient, tunnelUrl: string) => {\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n this._checkSecrets(integrationDef)\n await this._deployDevIntegration(api, tunnelUrl, integrationDef)\n } else {\n await this._deployDevBot(api, tunnelUrl)\n }\n }\n\n private _checkSecrets(integrationDef: IntegrationDefinition) {\n const initialSecrets = this._initialDef?.secrets ?? []\n const currentSecrets = integrationDef.secrets ?? []\n const newSecrets = currentSecrets.filter((s) => !initialSecrets.includes(s))\n if (newSecrets.length > 0) {\n throw new errors.BotpressCLIError('Secrets were added while the server was running. A restart is required.')\n }\n }\n\n private _spawnWorker = async (env: Record<string, string>, port: number) => {\n const outfile = this.projectPaths.abs.outFile\n const importPath = utils.path.toUnix(outfile)\n const requireFrom = utils.path.rmExtension(importPath)\n const code = `require('${requireFrom}').default.start(${port})`\n const worker = await Worker.spawn(\n {\n type: 'code',\n code,\n env,\n },\n this.logger\n ).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not start dev worker')\n })\n\n return worker\n }\n\n private _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployDevIntegration(\n api: ApiClient,\n externalUrl: string,\n integrationDef: IntegrationDefinition\n ): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let integration: bpclient.Integration | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getIntegration({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev integration with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { integration: undefined }\n })\n\n if (resp.integration?.dev) {\n integration = resp.integration\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying dev integration ${chalk.bold(integrationDef.name)}...`)\n if (integration) {\n const resp = await api.client\n .updateIntegration({ ...integrationDef, id: integration.id, url: externalUrl })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n } else {\n const resp = await api.client\n .createIntegration({ ...integrationDef, dev: true, url: externalUrl })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not deploy dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n }\n\n line.success(`Dev Integration deployed with id \"${integration.id}\"`)\n await this.projectCache.set('devId', integration.id)\n }\n\n private async _deployDevBot(api: ApiClient, externalUrl: string): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let bot: bpclient.Bot | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getBot({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev bot with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { bot: undefined }\n })\n\n if (resp.bot?.dev) {\n bot = resp.bot\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n if (!bot) {\n const createLine = this.logger.line()\n createLine.started('Creating dev bot...')\n const resp = await api.client\n .createBot({\n dev: true,\n url: externalUrl,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n\n bot = resp.bot\n createLine.success(`Dev Bot created with id \"${bot.id}\"`)\n await this.projectCache.set('devId', bot.id)\n }\n\n const outfile = this.projectPaths.abs.outFile\n const { default: botImpl } = utils.require.requireJsFile<{ default: BotImpl }>(outfile)\n\n const integrations = this.prepareIntegrations(botImpl, bot)\n\n const updateLine = this.logger.line()\n updateLine.started('Deploying dev bot...')\n\n const { bot: updatedBot } = await api.client\n .updateBot({ id: bot.id, integrations, url: externalUrl })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n updateLine.success(`Dev Bot deployed with id \"${updatedBot.id}\"`)\n\n this.displayWebhookUrls(updatedBot)\n }\n\n private _forwardTunnelRequest = async (baseUrl: string, request: TunnelRequest): Promise<TunnelResponse> => {\n const axiosConfig = {\n method: request.method,\n url: this._formatLocalUrl(baseUrl, request),\n headers: request.headers,\n data: request.body,\n responseType: 'text',\n validateStatus: () => true,\n } satisfies AxiosRequestConfig\n\n this.logger.debug(`Forwarding request to ${axiosConfig.url}`)\n const response = await axios(axiosConfig)\n this.logger.debug('Sending back response up the tunnel')\n\n return {\n requestId: request.id,\n status: response.status,\n headers: this._getHeaders(response.headers),\n body: response.data,\n }\n }\n\n private _formatLocalUrl = (baseUrl: string, req: TunnelRequest): string => {\n if (req.query) {\n return `${baseUrl}${req.path}?${req.query}`\n }\n return `${baseUrl}${req.path}`\n }\n\n private _getHeaders = (res: AxiosResponse['headers']): TunnelResponse['headers'] => {\n const headers: TunnelResponse['headers'] = {}\n for (const key in res) {\n if (typeof res[key] === 'string' || typeof res[key] === 'number') {\n headers[key] = res[key]\n }\n }\n return headers\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { Bot as BotImpl, IntegrationDefinition } from '@botpress/sdk'\nimport { TunnelRequest, TunnelResponse } from '@bpinternal/tunnel'\nimport axios, { AxiosRequestConfig, AxiosResponse } from 'axios'\nimport chalk from 'chalk'\nimport * as pathlib from 'path'\nimport * as uuid from 'uuid'\nimport type { ApiClient } from '../api-client'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { Worker } from '../worker'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nconst DEFAULT_BOT_PORT = 8075\nconst DEFAULT_INTEGRATION_PORT = 8076\n\nexport type DevCommandDefinition = typeof commandDefinitions.dev\nexport class DevCommand extends ProjectCommand<DevCommandDefinition> {\n private _initialDef: IntegrationDefinition | undefined = undefined\n\n public async run(): Promise<void> {\n this.logger.warn('This command is experimental and subject to breaking changes without notice.')\n\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n this._initialDef = await this.readIntegrationDefinitionFromFS()\n\n let env: Record<string, string> = {\n ...process.env,\n BP_API_URL: api.url,\n BP_TOKEN: api.token,\n }\n\n let defaultPort = DEFAULT_BOT_PORT\n if (this._initialDef) {\n defaultPort = DEFAULT_INTEGRATION_PORT\n const secrets = await this.promptSecrets(this._initialDef, this.argv)\n env = { ...env, ...secrets }\n }\n\n const port = this.argv.port ?? defaultPort\n\n const urlParseResult = utils.url.parse(this.argv.tunnelUrl)\n if (urlParseResult.status === 'error') {\n throw new errors.BotpressCLIError(`Invalid tunnel URL: ${urlParseResult.error}`)\n }\n\n const tunnelId = uuid.v4()\n\n const { url: parsedTunnelUrl } = urlParseResult\n const isSecured = parsedTunnelUrl.protocol === 'https' || parsedTunnelUrl.protocol === 'wss'\n\n const wsTunnelUrl: string = utils.url.format({ ...parsedTunnelUrl, protocol: isSecured ? 'wss' : 'ws' })\n const httpTunnelUrl: string = utils.url.format({\n ...parsedTunnelUrl,\n protocol: isSecured ? 'https' : 'http',\n path: `/${tunnelId}`,\n })\n\n const supervisor = new utils.tunnel.TunnelSupervisor(wsTunnelUrl, tunnelId, this.logger)\n supervisor.events.on('connected', ({ tunnel }) => {\n tunnel.events.on(\n 'request',\n (req) =>\n void this._forwardTunnelRequest(`http://localhost:${port}`, req)\n .then((res) => {\n tunnel.send(res)\n })\n .catch((thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, 'An error occurred while handling request')\n this.logger.error(err.message)\n tunnel.send({\n requestId: req.id,\n status: 500,\n body: err.message,\n })\n })\n )\n })\n await supervisor.start()\n\n await this._runBuild()\n await this._deploy(api, httpTunnelUrl)\n const worker = await this._spawnWorker(env, port)\n\n try {\n const watcher = await utils.filewatcher.FileWatcher.watch(\n this.argv.workDir,\n async (events) => {\n const typescriptEvents = events.filter((e) => pathlib.extname(e.path) === '.ts')\n if (typescriptEvents.length === 0) {\n return\n }\n\n this.logger.log('Changes detected, rebuilding')\n await this._restart(api, worker, httpTunnelUrl)\n },\n {\n ignore: [this.projectPaths.abs.outDir],\n }\n )\n\n await Promise.race([worker.wait(), watcher.wait(), supervisor.wait()])\n\n if (worker.running) {\n await worker.kill()\n }\n await watcher.close()\n supervisor.close()\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'An error occurred while running the dev server')\n } finally {\n if (worker.running) {\n await worker.kill()\n }\n }\n }\n\n private _restart = async (api: ApiClient, worker: Worker, tunnelUrl: string) => {\n try {\n await this._runBuild()\n } catch (thrown) {\n const error = errors.BotpressCLIError.wrap(thrown, 'Build failed')\n this.logger.error(error.message)\n return\n }\n\n await this._deploy(api, tunnelUrl)\n await worker.reload()\n }\n\n private _deploy = async (api: ApiClient, tunnelUrl: string) => {\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n this._checkSecrets(integrationDef)\n await this._deployDevIntegration(api, tunnelUrl, integrationDef)\n } else {\n await this._deployDevBot(api, tunnelUrl)\n }\n }\n\n private _checkSecrets(integrationDef: IntegrationDefinition) {\n const initialSecrets = this._initialDef?.secrets ?? []\n const currentSecrets = integrationDef.secrets ?? []\n const newSecrets = currentSecrets.filter((s) => !initialSecrets.includes(s))\n if (newSecrets.length > 0) {\n throw new errors.BotpressCLIError('Secrets were added while the server was running. A restart is required.')\n }\n }\n\n private _spawnWorker = async (env: Record<string, string>, port: number) => {\n const outfile = this.projectPaths.abs.outFile\n const importPath = utils.path.toUnix(outfile)\n const requireFrom = utils.path.rmExtension(importPath)\n const code = `require('${requireFrom}').default.start(${port})`\n const worker = await Worker.spawn(\n {\n type: 'code',\n code,\n env,\n },\n this.logger\n ).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not start dev worker')\n })\n\n return worker\n }\n\n private _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployDevIntegration(\n api: ApiClient,\n externalUrl: string,\n integrationDef: IntegrationDefinition\n ): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let integration: bpclient.Integration | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getIntegration({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev integration with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { integration: undefined }\n })\n\n if (resp.integration?.dev) {\n integration = resp.integration\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying dev integration ${chalk.bold(integrationDef.name)}...`)\n if (integration) {\n const resp = await api.client\n .updateIntegration({ ...integrationDef, id: integration.id, url: externalUrl })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n } else {\n const resp = await api.client\n .createIntegration({ ...integrationDef, dev: true, url: externalUrl })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not deploy dev integration \"${integrationDef.name}\"`)\n })\n integration = resp.integration\n }\n\n line.success(`Dev Integration deployed with id \"${integration.id}\"`)\n await this.projectCache.set('devId', integration.id)\n }\n\n private async _deployDevBot(api: ApiClient, externalUrl: string): Promise<void> {\n const devId = await this.projectCache.get('devId')\n\n let bot: bpclient.Bot | undefined = undefined\n\n if (devId) {\n const resp = await api.client.getBot({ id: devId }).catch(async (thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, `Could not find existing dev bot with id \"${devId}\"`)\n this.logger.warn(err.message)\n return { bot: undefined }\n })\n\n if (resp.bot?.dev) {\n bot = resp.bot\n } else {\n await this.projectCache.rm('devId')\n }\n }\n\n if (!bot) {\n const createLine = this.logger.line()\n createLine.started('Creating dev bot...')\n const resp = await api.client\n .createBot({\n dev: true,\n url: externalUrl,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n\n bot = resp.bot\n createLine.success(`Dev Bot created with id \"${bot.id}\"`)\n await this.projectCache.set('devId', bot.id)\n }\n\n const outfile = this.projectPaths.abs.outFile\n const { default: botImpl } = utils.require.requireJsFile<{ default: BotImpl }>(outfile)\n\n const integrations = this.prepareIntegrations(botImpl, bot)\n\n const updateLine = this.logger.line()\n updateLine.started('Deploying dev bot...')\n\n const { bot: updatedBot } = await api.client\n .updateBot({\n ...botImpl.definition,\n id: bot.id,\n integrations,\n url: externalUrl,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not deploy dev bot')\n })\n updateLine.success(`Dev Bot deployed with id \"${updatedBot.id}\"`)\n\n this.displayWebhookUrls(updatedBot)\n }\n\n private _forwardTunnelRequest = async (baseUrl: string, request: TunnelRequest): Promise<TunnelResponse> => {\n const axiosConfig = {\n method: request.method,\n url: this._formatLocalUrl(baseUrl, request),\n headers: request.headers,\n data: request.body,\n responseType: 'text',\n validateStatus: () => true,\n } satisfies AxiosRequestConfig\n\n this.logger.debug(`Forwarding request to ${axiosConfig.url}`)\n const response = await axios(axiosConfig)\n this.logger.debug('Sending back response up the tunnel')\n\n return {\n requestId: request.id,\n status: response.status,\n headers: this._getHeaders(response.headers),\n body: response.data,\n }\n }\n\n private _formatLocalUrl = (baseUrl: string, req: TunnelRequest): string => {\n if (req.query) {\n return `${baseUrl}${req.path}?${req.query}`\n }\n return `${baseUrl}${req.path}`\n }\n\n private _getHeaders = (res: AxiosResponse['headers']): TunnelResponse['headers'] => {\n const headers: TunnelResponse['headers'] = {}\n for (const key in res) {\n if (typeof res[key] === 'string' || typeof res[key] === 'number') {\n headers[key] = res[key]\n }\n }\n return headers\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAyD;AACzD,mBAAkB;AAClB,cAAyB;AACzB,WAAsB;AAGtB,aAAwB;AACxB,YAAuB;AACvB,oBAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAE/B,MAAM,mBAAmB;AACzB,MAAM,2BAA2B;AAG1B,MAAM,mBAAmB,sCAAqC;AAAA,EAC3D,cAAiD;AAAA,EAEzD,MAAa,MAAqB;AAChC,SAAK,OAAO,KAAK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WAAW;AACjB,YAAM,OAAO,iBAAiB,KAAK,QAAQ,0BAA0B;AAAA,IACvE,CAAC;AACH,eAAW,QAAQ,6BAA6B,WAAW,KAAK;AAEhE,SAAK,mBAAmB,UAAU;AAAA,EACpC;AAAA,EAEQ,wBAAwB,OAAO,SAAiB,YAAoD;AAC1G,UAAM,cAAc;AAAA,MAClB,QAAQ,QAAQ;AAAA,MAChB,KAAK,KAAK,gBAAgB,SAAS,OAAO;AAAA,MAC1C,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,MACd,cAAc;AAAA,MACd,gBAAgB,MAAM;AAAA,IACxB;AAEA,SAAK,OAAO,MAAM,yBAAyB,YAAY,KAAK;AAC5D,UAAM,WAAW,UAAM,aAAAC,SAAM,WAAW;AACxC,SAAK,OAAO,MAAM,qCAAqC;AAEvD,WAAO;AAAA,MACL,WAAW,QAAQ;AAAA,MACnB,QAAQ,SAAS;AAAA,MACjB,SAAS,KAAK,YAAY,SAAS,OAAO;AAAA,MAC1C,MAAM,SAAS;AAAA,IACjB;AAAA,EACF;AAAA,EAEQ,kBAAkB,CAAC,SAAiB,QAA+B;AACzE,QAAI,IAAI,OAAO;AACb,aAAO,GAAG,UAAU,IAAI,QAAQ,IAAI;AAAA,IACtC;AACA,WAAO,GAAG,UAAU,IAAI;AAAA,EAC1B;AAAA,EAEQ,cAAc,CAAC,QAA6D;AAClF,UAAM,UAAqC,CAAC;AAC5C,eAAW,OAAO,KAAK;AACrB,UAAI,OAAO,IAAI,SAAS,YAAY,OAAO,IAAI,SAAS,UAAU;AAChE,gBAAQ,OAAO,IAAI;AAAA,MACrB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["chalk", "axios"]
|
|
7
7
|
}
|
|
@@ -41,10 +41,10 @@ class GlobalPaths extends utils.path.PathStore {
|
|
|
41
41
|
constructor(argv) {
|
|
42
42
|
const absBotpressHome = utils.path.absoluteFrom(utils.path.cwd(), argv.botpressHome);
|
|
43
43
|
super({
|
|
44
|
-
cliRootDir:
|
|
44
|
+
cliRootDir: consts.cliRootDir,
|
|
45
45
|
botpressHomeDir: absBotpressHome,
|
|
46
46
|
...import_lodash.default.mapValues(consts.fromHomeDir, (p) => utils.path.absoluteFrom(absBotpressHome, p)),
|
|
47
|
-
...import_lodash.default.mapValues(consts.fromCliRootDir, (p) => utils.path.absoluteFrom(
|
|
47
|
+
...import_lodash.default.mapValues(consts.fromCliRootDir, (p) => utils.path.absoluteFrom(consts.cliRootDir, p))
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/global-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport latestVersion from 'latest-version'\nimport _ from 'lodash'\nimport * as pathlib from 'path'\nimport semver from 'semver'\nimport type { ApiClientFactory } from '../api-client'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { BaseCommand } from './base-command'\n\nexport type GlobalCommandDefinition = CommandDefinition<typeof config.schemas.global>\nexport type GlobalCache = { apiUrl: string; token: string; workspaceId: string }\n\nexport type ConfigurableGlobalPaths = { botpressHomeDir: string; cliRootDir: utils.path.AbsolutePath }\nexport type ConstantGlobalPaths = typeof consts.fromHomeDir & typeof consts.fromCliRootDir\nexport type AllGlobalPaths = ConfigurableGlobalPaths & ConstantGlobalPaths\n\nclass GlobalPaths extends utils.path.PathStore<keyof AllGlobalPaths> {\n public constructor(argv: CommandArgv<GlobalCommandDefinition>) {\n const absBotpressHome = utils.path.absoluteFrom(utils.path.cwd(), argv.botpressHome)\n super({\n cliRootDir:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,gBAAe;AACf,4BAA0B;AAC1B,oBAAc;AACd,cAAyB;AACzB,oBAAmB;AAGnB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,0BAA4B;AAS5B,MAAM,oBAAoB,MAAM,KAAK,UAAgC;AAAA,EAC5D,YAAY,MAA4C;AAC7D,UAAM,kBAAkB,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,YAAY;AACnF,UAAM;AAAA,MACJ,YAAY,
|
|
4
|
+
"sourcesContent": ["import type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport latestVersion from 'latest-version'\nimport _ from 'lodash'\nimport * as pathlib from 'path'\nimport semver from 'semver'\nimport type { ApiClientFactory } from '../api-client'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { BaseCommand } from './base-command'\n\nexport type GlobalCommandDefinition = CommandDefinition<typeof config.schemas.global>\nexport type GlobalCache = { apiUrl: string; token: string; workspaceId: string }\n\nexport type ConfigurableGlobalPaths = { botpressHomeDir: string; cliRootDir: utils.path.AbsolutePath }\nexport type ConstantGlobalPaths = typeof consts.fromHomeDir & typeof consts.fromCliRootDir\nexport type AllGlobalPaths = ConfigurableGlobalPaths & ConstantGlobalPaths\n\nclass GlobalPaths extends utils.path.PathStore<keyof AllGlobalPaths> {\n public constructor(argv: CommandArgv<GlobalCommandDefinition>) {\n const absBotpressHome = utils.path.absoluteFrom(utils.path.cwd(), argv.botpressHome)\n super({\n cliRootDir: consts.cliRootDir,\n botpressHomeDir: absBotpressHome,\n ..._.mapValues(consts.fromHomeDir, (p) => utils.path.absoluteFrom(absBotpressHome, p)),\n ..._.mapValues(consts.fromCliRootDir, (p) => utils.path.absoluteFrom(consts.cliRootDir, p)),\n })\n }\n}\n\ntype PackageJson = { name: string; version: string }\n\nconst UPDATE_MSG = (props: PackageJson & { latest: string }) =>\n `${chalk.bold('Update available')} ${chalk.dim(props.version)} \u2192 ${chalk.green(props.latest)}\n\nTo update, run:\n for npm ${chalk.cyan(`npm i -g ${props.name}`)}\n for yarn ${chalk.cyan(`yarn global add ${props.name}`)}\n for pnpm ${chalk.cyan(`pnpm i -g ${props.name}`)}`\n\nexport abstract class GlobalCommand<C extends GlobalCommandDefinition> extends BaseCommand<C> {\n protected api: ApiClientFactory\n protected prompt: utils.prompt.CLIPrompt\n\n public constructor(\n api: ApiClientFactory,\n prompt: utils.prompt.CLIPrompt,\n ...args: ConstructorParameters<typeof BaseCommand<C>>\n ) {\n super(...args)\n this.api = api\n this.prompt = prompt\n }\n\n protected get globalPaths() {\n return new GlobalPaths(this.argv)\n }\n\n protected get globalCache() {\n return new utils.cache.FSKeyValueCache<GlobalCache>(this.globalPaths.abs.globalCacheFile)\n }\n\n protected override bootstrap = async () => {\n const pkgJson = await this._readPackageJson()\n\n const versionText = chalk.bold(`v${pkgJson.version}`)\n this.logger.log(`Botpress CLI ${versionText}`, { prefix: '\uD83E\uDD16' })\n\n await this._notifyUpdate(pkgJson)\n\n const paths = this.globalPaths\n if (paths.abs.botpressHomeDir !== consts.defaultBotpressHome) {\n this.logger.log(`Using custom botpress home: ${paths.abs.botpressHomeDir}`, { prefix: '\uD83C\uDFE0' })\n }\n }\n\n protected override teardown = async () => {\n this.logger.cleanup()\n }\n\n protected async ensureLoginAndCreateClient(credentials: YargsConfig<typeof config.schemas.credentials>) {\n const cache = this.globalCache\n const token = await cache.get('token')\n const workspaceId = credentials.workspaceId ?? (await cache.get('workspaceId'))\n const apiUrl = credentials.apiUrl ?? (await cache.get('apiUrl'))\n\n if (!(token && workspaceId && apiUrl)) {\n throw new errors.NotLoggedInError()\n }\n\n return this.api.newClient({ apiUrl, token, workspaceId }, this.logger)\n }\n\n private _notifyUpdate = async (pkgJson: PackageJson): Promise<void> => {\n try {\n const latest = await latestVersion(pkgJson.name)\n const isOutdated = semver.lt(pkgJson.version, latest)\n if (isOutdated) {\n this.logger.box(UPDATE_MSG({ ...pkgJson, latest }))\n }\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check for updates: ${err.message}`)\n }\n }\n\n private _readPackageJson = async (): Promise<PackageJson> => {\n const path = pathlib.join(this.globalPaths.abs.cliRootDir, 'package.json')\n const strContent = await fs.promises.readFile(path, 'utf8')\n const jsonContent = JSON.parse(strContent)\n return jsonContent\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,gBAAe;AACf,4BAA0B;AAC1B,oBAAc;AACd,cAAyB;AACzB,oBAAmB;AAGnB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,0BAA4B;AAS5B,MAAM,oBAAoB,MAAM,KAAK,UAAgC;AAAA,EAC5D,YAAY,MAA4C;AAC7D,UAAM,kBAAkB,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,YAAY;AACnF,UAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,iBAAiB;AAAA,MACjB,GAAG,cAAAA,QAAE,UAAU,OAAO,aAAa,CAAC,MAAM,MAAM,KAAK,aAAa,iBAAiB,CAAC,CAAC;AAAA,MACrF,GAAG,cAAAA,QAAE,UAAU,OAAO,gBAAgB,CAAC,MAAM,MAAM,KAAK,aAAa,OAAO,YAAY,CAAC,CAAC;AAAA,IAC5F,CAAC;AAAA,EACH;AACF;AAIA,MAAM,aAAa,CAAC,UAClB,GAAG,aAAAC,QAAM,KAAK,kBAAkB,KAAK,aAAAA,QAAM,IAAI,MAAM,OAAO,YAAO,aAAAA,QAAM,MAAM,MAAM,MAAM;AAAA;AAAA;AAAA,aAGhF,aAAAA,QAAM,KAAK,YAAY,MAAM,MAAM;AAAA,aACnC,aAAAA,QAAM,KAAK,mBAAmB,MAAM,MAAM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AAgB,OAAO,YAAwC;AACrE,QAAI;AACF,YAAM,SAAS,UAAM,sBAAAC,SAAc,QAAQ,IAAI;AAC/C,YAAM,aAAa,cAAAC,QAAO,GAAG,QAAQ,SAAS,MAAM;AACpD,UAAI,YAAY;AACd,aAAK,OAAO,IAAI,WAAW,EAAE,GAAG,SAAS,OAAO,CAAC,CAAC;AAAA,MACpD;AAAA,IACF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,gCAAgC,IAAI,SAAS;AAAA,IACjE;AAAA,EACF;AAAA,EAEQ,mBAAmB,YAAkC;AAC3D,UAAM,OAAO,QAAQ,KAAK,KAAK,YAAY,IAAI,YAAY,cAAc;AACzE,UAAM,aAAa,MAAM,UAAAC,QAAG,SAAS,SAAS,MAAM,MAAM;AAC1D,UAAM,cAAc,KAAK,MAAM,UAAU;AACzC,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["_", "chalk", "latestVersion", "semver", "fs"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/integration-commands.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport chalk from 'chalk'\nimport _ from 'lodash'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parseIntegrationRef } from '../integration-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.get\nexport class GetIntegrationCommand extends GlobalCommand<GetIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parseIntegrationRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(this.argv.integrationRef)\n }\n\n try {\n const integration = await api.findIntegration(parsedRef)\n if (integration) {\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)}:`)\n this.logger.json(integration)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n}\n\nexport type
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAc;AAEd,aAAwB;AACxB,6BAAoC;AACpC,4BAA8B;AAGvB,MAAM,8BAA8B,oCAA+C;AAAA,EACxF,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,gBAAY,4CAAoB,KAAK,KAAK,cAAc;AAC9D,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,OAAO,iCAAiC,KAAK,KAAK,cAAc;AAAA,IAC5E;AAEA,QAAI;AACF,YAAM,cAAc,MAAM,IAAI,gBAAgB,SAAS;AACvD,UAAI,aAAa;AACf,aAAK,OAAO,QAAQ,eAAe,aAAAA,QAAM,KAAK,KAAK,KAAK,cAAc,IAAI;AAC1E,aAAK,OAAO,KAAK,WAAW;AAC5B;AAAA,MACF;AAAA,IACF,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6BAA6B,KAAK,KAAK,gBAAgB;AAAA,IACpG;AAEA,UAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,0BAA0B;AAAA,EACvF;AACF;AAGO,MAAM,gCAAgC,
|
|
4
|
+
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport chalk from 'chalk'\nimport _ from 'lodash'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parseIntegrationRef } from '../integration-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.get\nexport class GetIntegrationCommand extends GlobalCommand<GetIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parseIntegrationRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(this.argv.integrationRef)\n }\n\n try {\n const integration = await api.findIntegration(parsedRef)\n if (integration) {\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)}:`)\n this.logger.json(integration)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n}\n\nexport type ListIntegrationsCommandDefinition = typeof commandDefinitions.integrations.subcommands.list\nexport class ListIntegrationsCommand extends GlobalCommand<ListIntegrationsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const privateLister = (req: { nextToken?: string }) =>\n api.client.listIntegrations({ nextToken: req.nextToken, name: this.argv.name, version: this.argv.version })\n\n const publicLister = (req: { nextToken?: string }) =>\n api.client.listPublicIntegrations({ nextToken: req.nextToken, name: this.argv.name, version: this.argv.version })\n\n try {\n const privateIntegrations = await api.listAllPages(privateLister, (r) => r.integrations)\n const publicIntegrations = await api.listAllPages(publicLister, (r) => r.integrations)\n const integrations = _.uniqBy([...privateIntegrations, ...publicIntegrations], (i) => i.id)\n\n this.logger.success('Integrations:')\n this.logger.json(integrations)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list integrations')\n }\n }\n}\n\nexport type DeleteIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.delete\nexport class DeleteIntegrationCommand extends GlobalCommand<DeleteIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parseIntegrationRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(this.argv.integrationRef)\n }\n\n let integration: bpclient.Integration | undefined\n try {\n integration = await api.findPrivateIntegration(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n if (!integration) {\n const publicIntegration = await api.findPublicIntegration(parsedRef)\n if (publicIntegration) {\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} does not belong to your workspace`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n\n try {\n await api.client.deleteIntegration({ id: integration.id })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete integration ${this.argv.integrationRef}`)\n }\n\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)} deleted`)\n return\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAc;AAEd,aAAwB;AACxB,6BAAoC;AACpC,4BAA8B;AAGvB,MAAM,8BAA8B,oCAA+C;AAAA,EACxF,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,gBAAY,4CAAoB,KAAK,KAAK,cAAc;AAC9D,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,OAAO,iCAAiC,KAAK,KAAK,cAAc;AAAA,IAC5E;AAEA,QAAI;AACF,YAAM,cAAc,MAAM,IAAI,gBAAgB,SAAS;AACvD,UAAI,aAAa;AACf,aAAK,OAAO,QAAQ,eAAe,aAAAA,QAAM,KAAK,KAAK,KAAK,cAAc,IAAI;AAC1E,aAAK,OAAO,KAAK,WAAW;AAC5B;AAAA,MACF;AAAA,IACF,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6BAA6B,KAAK,KAAK,gBAAgB;AAAA,IACpG;AAEA,UAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,0BAA0B;AAAA,EACv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AM,oBAAoB,MAAM,IAAI,sBAAsB,SAAS;AACnE,UAAI,mBAAmB;AACrB,cAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,kDAAkD;AAAA,MAC/G;AAEA,YAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,0BAA0B;AAAA,IACvF;AAEA,QAAI;AACF,YAAM,IAAI,OAAO,kBAAkB,EAAE,IAAI,YAAY,GAAG,CAAC;AAAA,IAC3D,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,gCAAgC,KAAK,KAAK,gBAAgB;AAAA,IACvG;AAEA,SAAK,OAAO,QAAQ,eAAe,aAAAD,QAAM,KAAK,KAAK,KAAK,cAAc,WAAW;AACjF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["chalk", "_"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/project-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { IntegrationDefinition, Bot as BotImpl } from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async readIntegrationDefinitionFromFS(): Promise<IntegrationDefinition | undefined> {\n const abs = this.projectPaths.abs\n const rel = this.projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.definition)) {\n this.logger.debug(`Integration definition not found at ${rel.definition}`)\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.definition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: IntegrationDefinition }>(artifact.text)\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected prepareIntegrations(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,kBAAoB;AACpB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,4BAA8B;
|
|
4
|
+
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { IntegrationDefinition, Bot as BotImpl } from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\ntype IntegrationInstances = Parameters<bpclient.Client['updateBot']>[0]['integrations']\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async readIntegrationDefinitionFromFS(): Promise<IntegrationDefinition | undefined> {\n const abs = this.projectPaths.abs\n const rel = this.projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.definition)) {\n this.logger.debug(`Integration definition not found at ${rel.definition}`)\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.definition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: IntegrationDefinition }>(artifact.text)\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected prepareIntegrations(botImpl: BotImpl, botInfo: bpclient.Bot): IntegrationInstances {\n const { integrations: integrationList } = botImpl.definition\n\n const integrationsToUninstall: IntegrationInstances = _(botInfo.integrations)\n .keys()\n .filter((key) => !integrationList?.map((i) => i.id).includes(key))\n .zipObject()\n .mapValues(() => null)\n .value()\n\n const integrationsToInstall: IntegrationInstances = _(integrationList ?? [])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configuration }) => ({ enabled, configuration }))\n .value()\n\n return { ...integrationsToUninstall, ...integrationsToInstall }\n }\n\n protected displayWebhookUrls(bot: bpclient.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>\n ): Promise<Record<string, string>> {\n const { secrets: secretDefinitions } = integrationDef\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions.includes(s))\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`)\n }\n\n const values: Record<string, string> = {}\n for (const secretDef of secretDefinitions) {\n const argvSecret = secretArgv[secretDef]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretDef}\" from argv`)\n values[secretDef] = argvSecret\n continue\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretDef}\"`)\n if (!prompted) {\n throw new errors.BotpressCLIError('Secret is required')\n }\n values[secretDef] = prompted\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = this._splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _splitOnce = (text: string, separator: string): [string, string | undefined] => {\n const index = text.indexOf(separator)\n if (index === -1) {\n return [text, undefined]\n }\n return [text.slice(0, index), text.slice(index + 1)]\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,kBAAoB;AACpB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,4BAA8B;AAW9B,MAAM,qBA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GAAG;AAChD,UAAI,CAAC,OAAO;AACV,cAAM,IAAI,OAAO;AAAA,UACf,WAAW;AAAA,QACb;AAAA,MACF;AACA,aAAO,OAAQ;AAAA,IACjB;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,aAAa,CAAC,MAAc,cAAoD;AACtF,UAAM,QAAQ,KAAK,QAAQ,SAAS;AACpC,QAAI,UAAU,IAAI;AAChB,aAAO,CAAC,MAAM,MAAS;AAAA,IACzB;AACA,WAAO,CAAC,KAAK,MAAM,GAAG,KAAK,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC;AAAA,EACrD;AACF;",
|
|
6
6
|
"names": ["_", "fs", "pathlib", "chalk"]
|
|
7
7
|
}
|
package/dist/consts.js
CHANGED
|
@@ -24,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
var consts_exports = {};
|
|
26
26
|
__export(consts_exports, {
|
|
27
|
+
cliRootDir: () => cliRootDir,
|
|
27
28
|
defaultBotpressApiUrl: () => defaultBotpressApiUrl,
|
|
28
29
|
defaultBotpressAppUrl: () => defaultBotpressAppUrl,
|
|
29
30
|
defaultBotpressHome: () => defaultBotpressHome,
|
|
@@ -40,12 +41,14 @@ __export(consts_exports, {
|
|
|
40
41
|
module.exports = __toCommonJS(consts_exports);
|
|
41
42
|
var import_os = __toESM(require("os"));
|
|
42
43
|
var import_path = __toESM(require("path"));
|
|
44
|
+
var import_root = require("./root");
|
|
43
45
|
const defaultBotpressHome = import_path.default.join(import_os.default.homedir(), ".botpress");
|
|
44
46
|
const defaultOutputFolder = ".botpress";
|
|
45
47
|
const defaultEntrypoint = import_path.default.join("src", "index.ts");
|
|
46
48
|
const defaultBotpressApiUrl = "https://api.botpress.cloud";
|
|
47
49
|
const defaultBotpressAppUrl = "https://app.botpress.cloud";
|
|
48
50
|
const defaultTunnelUrl = "https://tunnel.botpress.cloud";
|
|
51
|
+
const cliRootDir = import_root.CLI_ROOT_DIR;
|
|
49
52
|
const echoBotDirName = "echo-bot";
|
|
50
53
|
const emptyIntegrationDirName = "empty-integration";
|
|
51
54
|
const fromCliRootDir = {
|
|
@@ -69,6 +72,7 @@ const fromOutDir = {
|
|
|
69
72
|
};
|
|
70
73
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71
74
|
0 && (module.exports = {
|
|
75
|
+
cliRootDir,
|
|
72
76
|
defaultBotpressApiUrl,
|
|
73
77
|
defaultBotpressAppUrl,
|
|
74
78
|
defaultBotpressHome,
|
package/dist/consts.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/consts.ts"],
|
|
4
|
-
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\n\nexport const defaultOutputFolder = '.botpress'\nexport const defaultEntrypoint = pathlib.join('src', 'index.ts')\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\n\n// not configurable\n\nexport const echoBotDirName = 'echo-bot'\nexport const emptyIntegrationDirName = 'empty-integration'\n\nexport const fromCliRootDir = {\n packageJson: 'package.json',\n echoBotTemplate: pathlib.join('templates', echoBotDirName),\n emptyIntegrationTemplate: pathlib.join('templates', emptyIntegrationDirName),\n}\n\nexport const fromHomeDir = {\n globalCacheFile: 'global.cache.json',\n}\n\nexport const fromWorkDir = {\n definition: 'integration.definition.ts',\n}\n\nexport const fromOutDir = {\n distDir: 'dist',\n outFile: pathlib.join('dist', 'index.js'),\n installDir: 'installations',\n implementationDir: 'implementation',\n secretsDir: 'secrets',\n projectCacheFile: 'project.cache.json',\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;
|
|
4
|
+
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\nimport { CLI_ROOT_DIR } from './root'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\n\nexport const defaultOutputFolder = '.botpress'\nexport const defaultEntrypoint = pathlib.join('src', 'index.ts')\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\n\n// not configurable\n\nexport const cliRootDir = CLI_ROOT_DIR\n\nexport const echoBotDirName = 'echo-bot'\nexport const emptyIntegrationDirName = 'empty-integration'\n\nexport const fromCliRootDir = {\n packageJson: 'package.json',\n echoBotTemplate: pathlib.join('templates', echoBotDirName),\n emptyIntegrationTemplate: pathlib.join('templates', emptyIntegrationDirName),\n}\n\nexport const fromHomeDir = {\n globalCacheFile: 'global.cache.json',\n}\n\nexport const fromWorkDir = {\n definition: 'integration.definition.ts',\n}\n\nexport const fromOutDir = {\n distDir: 'dist',\n outFile: pathlib.join('dist', 'index.js'),\n installDir: 'installations',\n implementationDir: 'implementation',\n secretsDir: 'secrets',\n projectCacheFile: 'project.cache.json',\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;AACpB,kBAA6B;AAItB,MAAM,sBAAsB,YAAAA,QAAQ,KAAK,UAAAC,QAAG,QAAQ,GAAG,WAAW;AAElE,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB,YAAAD,QAAQ,KAAK,OAAO,UAAU;AACxD,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AAIzB,MAAM,aAAa;AAEnB,MAAM,iBAAiB;AACvB,MAAM,0BAA0B;AAEhC,MAAM,iBAAiB;AAAA,EAC5B,aAAa;AAAA,EACb,iBAAiB,YAAAA,QAAQ,KAAK,aAAa,cAAc;AAAA,EACzD,0BAA0B,YAAAA,QAAQ,KAAK,aAAa,uBAAuB;AAC7E;AAEO,MAAM,cAAc;AAAA,EACzB,iBAAiB;AACnB;AAEO,MAAM,cAAc;AAAA,EACzB,YAAY;AACd;AAEO,MAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,SAAS,YAAAA,QAAQ,KAAK,QAAQ,UAAU;AAAA,EACxC,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,kBAAkB;AACpB;",
|
|
6
6
|
"names": ["pathlib", "os"]
|
|
7
7
|
}
|