@botpress/cli 4.14.3 → 4.14.6
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/.turbo/turbo-build.log +10 -10
- package/dist/command-implementations/deploy-command.js +2 -2
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/init-command.js +1 -1
- package/dist/command-implementations/init-command.js.map +2 -2
- package/package.json +1 -1
- package/templates/empty-integration/.botpress/implementation/typings/index.ts +1 -1
- package/templates/empty-integration/integration.definition.ts +1 -1
- package/templates/empty-plugin/.botpress/implementation/typings/index.ts +1 -1
- package/templates/empty-plugin/plugin.definition.ts +1 -1
- package/templates/hello-world/.botpress/implementation/typings/index.ts +1 -1
- package/templates/hello-world/integration.definition.ts +1 -1
- package/templates/webhook-message/.botpress/implementation/typings/index.ts +1 -1
- package/templates/webhook-message/integration.definition.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@4.14.
|
|
2
|
+
> @botpress/cli@4.14.6 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@4.14.
|
|
6
|
+
> @botpress/cli@4.14.6 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@4.14.
|
|
10
|
+
> @botpress/cli@4.14.6 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
12
|
|
|
13
|
-
🤖 Botpress CLI v4.14.
|
|
14
|
-
🤖 Botpress CLI v4.14.
|
|
15
|
-
🤖 Botpress CLI v4.14.
|
|
16
|
-
🤖 Botpress CLI v4.14.
|
|
13
|
+
🤖 Botpress CLI v4.14.6
|
|
14
|
+
🤖 Botpress CLI v4.14.6
|
|
15
|
+
🤖 Botpress CLI v4.14.6
|
|
16
|
+
🤖 Botpress CLI v4.14.6
|
|
17
|
+
○ Generating typings for integration hello-world...
|
|
17
18
|
○ Generating typings for plugin empty-plugin...
|
|
18
19
|
✓ Typings available at .botpress
|
|
19
20
|
|
|
20
21
|
○ Generating typings for integration empty-integration...
|
|
21
|
-
○ Generating typings for bot...
|
|
22
22
|
✓ Typings available at .botpress
|
|
23
23
|
|
|
24
24
|
✓ Typings available at .botpress
|
|
25
25
|
|
|
26
|
-
○ Generating typings for
|
|
26
|
+
○ Generating typings for bot...
|
|
27
27
|
✓ Typings available at .botpress
|
|
28
28
|
|
|
29
|
-
🤖 Botpress CLI v4.14.
|
|
29
|
+
🤖 Botpress CLI v4.14.6
|
|
30
30
|
○ Generating typings for integration webhook-message...
|
|
31
31
|
✓ Typings available at .botpress
|
|
32
32
|
|
|
@@ -204,7 +204,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
204
204
|
const readme = await this.readProjectFile(interfaceDeclaration.readme, "base64");
|
|
205
205
|
const createBody = {
|
|
206
206
|
...await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration),
|
|
207
|
-
public: this.
|
|
207
|
+
public: this._visibility === "public",
|
|
208
208
|
icon,
|
|
209
209
|
readme
|
|
210
210
|
};
|
|
@@ -275,7 +275,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
275
275
|
const createBody = {
|
|
276
276
|
...await apiUtils.prepareCreatePluginBody(pluginDef),
|
|
277
277
|
...await this.preparePluginDependencies(pluginDef, api),
|
|
278
|
-
public: this.
|
|
278
|
+
public: this._visibility === "public",
|
|
279
279
|
icon,
|
|
280
280
|
readme,
|
|
281
281
|
code: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/deploy-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as tables from '../tables'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\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\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectDef.type === 'plugin') {\n return this._deployPlugin(api, projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private get _visibility(): 'public' | 'private' | 'unlisted' {\n if (this.argv.public && this.argv.visibility === 'private') {\n this.logger.warn('The --public flag is deprecated. Please use \"--visibility public\" instead.')\n return 'public'\n }\n\n if (this.argv.public && this.argv.visibility !== 'private') {\n this.logger.warn('The --public flag and --visibility option are both present. Ignoring the --public flag...')\n }\n\n return this.argv.visibility\n }\n\n private async _deployIntegration(api: apiUtils.ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const res = await this._manageWorkspaceHandle(api, integrationDef)\n if (!res) return\n const { integration: updatedIntegrationDef, workspaceId } = res\n integrationDef = updatedIntegrationDef\n if (workspaceId) {\n api = api.switchWorkspace(workspaceId)\n }\n\n const { name, version } = integrationDef\n\n if (integrationDef.icon && !integrationDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (integrationDef.readme && !integrationDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const integration = await api.findPublicOrPrivateIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.visibility !== 'private' && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n const createBody = {\n ...(await this.prepareCreateIntegrationBody(integrationDef)),\n ...(await this.prepareIntegrationDependencies(integrationDef, api)),\n visibility: this._visibility,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = apiUtils.prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration update...')\n\n await api.client.validateIntegrationUpdate(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n } else {\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n createBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration creation...')\n\n await api.client.validateIntegrationCreation(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n } else {\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: apiUtils.ApiClient, interfaceDeclaration: sdk.InterfaceDefinition) {\n if (this._visibility === 'unlisted') {\n throw new errors.BotpressCLIError(\n 'Unlisted visibility is not supported for interfaces. Please use \"public\" or \"private\".'\n )\n }\n\n if (interfaceDeclaration.icon && !interfaceDeclaration.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (interfaceDeclaration.readme && !interfaceDeclaration.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicOrPrivateInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${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 icon = await this.readProjectFile(interfaceDeclaration.icon, 'base64')\n const readme = await this.readProjectFile(interfaceDeclaration.readme, 'base64')\n\n const createBody = {\n ...(await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration)),\n public: this.argv.public,\n icon,\n readme,\n }\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = apiUtils.prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface updates. Skipping deployment...')\n } else {\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface creation. Skipping deployment...')\n } else {\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployPlugin(api: apiUtils.ApiClient, pluginDef: sdk.PluginDefinition) {\n if (this._visibility === 'unlisted') {\n throw new errors.BotpressCLIError(\n 'Unlisted visibility is not supported for plugins. Please use \"public\" or \"private\".'\n )\n }\n\n const codeCJS = await fs.promises.readFile(this.projectPaths.abs.outFileCJS, 'utf-8')\n const codeESM = await fs.promises.readFile(this.projectPaths.abs.outFileESM, 'utf-8')\n\n const { name, version } = pluginDef\n\n if (pluginDef.icon && !pluginDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (pluginDef.readme && !pluginDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const plugin = await api.findPublicOrPrivatePlugin({ type: 'name', name, version })\n\n let message: string\n if (plugin) {\n this.logger.warn('Plugin already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override plugin ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy plugin ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing plugin request body...')\n\n const icon = await this.readProjectFile(pluginDef.icon, 'base64')\n const readme = await this.readProjectFile(pluginDef.readme, 'base64')\n\n const createBody = {\n ...(await apiUtils.prepareCreatePluginBody(pluginDef)),\n ...(await this.preparePluginDependencies(pluginDef, api)),\n public: this.argv.public,\n icon,\n readme,\n code: {\n node: codeCJS,\n browser: codeESM,\n },\n }\n\n const startedMessage = `Deploying plugin ${chalk.bold(name)} v${version}...`\n const successMessage = 'Plugin deployed'\n if (plugin) {\n const updateBody = apiUtils.prepareUpdatePluginBody(\n {\n id: plugin.id,\n ...createBody,\n },\n plugin\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin updates. Skipping deployment...')\n } else {\n await api.client.updatePlugin(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin creation. Skipping deployment...')\n } else {\n await api.client.createPlugin(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private async _deployBot(\n api: apiUtils.ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for bot deployments. Skipping deployment...')\n return\n }\n\n const outfile = this.projectPaths.abs.outFileCJS\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.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 line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const updateBotBody = apiUtils.prepareUpdateBotBody(\n {\n ...(await apiUtils.prepareCreateBotBody(botDefinition)),\n ...(await this.prepareBotDependencies(botDefinition, api)),\n id: bot.id,\n code,\n },\n bot\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\n const tablesPublisher = new tables.TablesPublisher({ api, logger: this.logger, prompt: this.prompt })\n await tablesPublisher.deployTables({ botId: updatedBot.id, botDefinition })\n\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: apiUtils.ApiClient): Promise<client.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: apiUtils.ApiClient, botId: string | undefined): Promise<client.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 private async _manageWorkspaceHandle(\n api: apiUtils.ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<\n | {\n integration: sdk.IntegrationDefinition\n workspaceId?: string // Set if user opted to deploy on another available workspace\n }\n | undefined\n > {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n this.logger.log('Aborted')\n return\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,UAAqB;AACrB,mBAAkB;AAClB,SAAoB;AACpB,oBAAmB;AACnB,eAA0B;AAE1B,aAAwB;AACxB,aAAwB;AACxB,YA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W,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as tables from '../tables'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\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\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectDef.type === 'plugin') {\n return this._deployPlugin(api, projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private get _visibility(): 'public' | 'private' | 'unlisted' {\n if (this.argv.public && this.argv.visibility === 'private') {\n this.logger.warn('The --public flag is deprecated. Please use \"--visibility public\" instead.')\n return 'public'\n }\n\n if (this.argv.public && this.argv.visibility !== 'private') {\n this.logger.warn('The --public flag and --visibility option are both present. Ignoring the --public flag...')\n }\n\n return this.argv.visibility\n }\n\n private async _deployIntegration(api: apiUtils.ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const res = await this._manageWorkspaceHandle(api, integrationDef)\n if (!res) return\n const { integration: updatedIntegrationDef, workspaceId } = res\n integrationDef = updatedIntegrationDef\n if (workspaceId) {\n api = api.switchWorkspace(workspaceId)\n }\n\n const { name, version } = integrationDef\n\n if (integrationDef.icon && !integrationDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (integrationDef.readme && !integrationDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const integration = await api.findPublicOrPrivateIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.visibility !== 'private' && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n const createBody = {\n ...(await this.prepareCreateIntegrationBody(integrationDef)),\n ...(await this.prepareIntegrationDependencies(integrationDef, api)),\n visibility: this._visibility,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = apiUtils.prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration update...')\n\n await api.client.validateIntegrationUpdate(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n } else {\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n createBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.log('Dry-run mode is active. Simulating integration creation...')\n\n await api.client.validateIntegrationCreation(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n } else {\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: apiUtils.ApiClient, interfaceDeclaration: sdk.InterfaceDefinition) {\n if (this._visibility === 'unlisted') {\n throw new errors.BotpressCLIError(\n 'Unlisted visibility is not supported for interfaces. Please use \"public\" or \"private\".'\n )\n }\n\n if (interfaceDeclaration.icon && !interfaceDeclaration.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (interfaceDeclaration.readme && !interfaceDeclaration.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicOrPrivateInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${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 icon = await this.readProjectFile(interfaceDeclaration.icon, 'base64')\n const readme = await this.readProjectFile(interfaceDeclaration.readme, 'base64')\n\n const createBody = {\n ...(await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration)),\n public: this._visibility === 'public',\n icon,\n readme,\n }\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = apiUtils.prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface updates. Skipping deployment...')\n } else {\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for interface creation. Skipping deployment...')\n } else {\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private async _deployPlugin(api: apiUtils.ApiClient, pluginDef: sdk.PluginDefinition) {\n if (this._visibility === 'unlisted') {\n throw new errors.BotpressCLIError(\n 'Unlisted visibility is not supported for plugins. Please use \"public\" or \"private\".'\n )\n }\n\n const codeCJS = await fs.promises.readFile(this.projectPaths.abs.outFileCJS, 'utf-8')\n const codeESM = await fs.promises.readFile(this.projectPaths.abs.outFileESM, 'utf-8')\n\n const { name, version } = pluginDef\n\n if (pluginDef.icon && !pluginDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (pluginDef.readme && !pluginDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const plugin = await api.findPublicOrPrivatePlugin({ type: 'name', name, version })\n\n let message: string\n if (plugin) {\n this.logger.warn('Plugin already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override plugin ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy plugin ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing plugin request body...')\n\n const icon = await this.readProjectFile(pluginDef.icon, 'base64')\n const readme = await this.readProjectFile(pluginDef.readme, 'base64')\n\n const createBody = {\n ...(await apiUtils.prepareCreatePluginBody(pluginDef)),\n ...(await this.preparePluginDependencies(pluginDef, api)),\n public: this._visibility === 'public',\n icon,\n readme,\n code: {\n node: codeCJS,\n browser: codeESM,\n },\n }\n\n const startedMessage = `Deploying plugin ${chalk.bold(name)} v${version}...`\n const successMessage = 'Plugin deployed'\n if (plugin) {\n const updateBody = apiUtils.prepareUpdatePluginBody(\n {\n id: plugin.id,\n ...createBody,\n },\n plugin\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin updates. Skipping deployment...')\n } else {\n await api.client.updatePlugin(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for plugin creation. Skipping deployment...')\n } else {\n await api.client.createPlugin(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin \"${name}\"`)\n })\n }\n\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private async _deployBot(\n api: apiUtils.ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n if (this.argv.dryRun) {\n this.logger.warn('Dry-run mode is not supported for bot deployments. Skipping deployment...')\n return\n }\n\n const outfile = this.projectPaths.abs.outFileCJS\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.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 line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const updateBotBody = apiUtils.prepareUpdateBotBody(\n {\n ...(await apiUtils.prepareCreateBotBody(botDefinition)),\n ...(await this.prepareBotDependencies(botDefinition, api)),\n id: bot.id,\n code,\n },\n bot\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\n const tablesPublisher = new tables.TablesPublisher({ api, logger: this.logger, prompt: this.prompt })\n await tablesPublisher.deployTables({ botId: updatedBot.id, botDefinition })\n\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: apiUtils.ApiClient): Promise<client.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: apiUtils.ApiClient, botId: string | undefined): Promise<client.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 private async _manageWorkspaceHandle(\n api: apiUtils.ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<\n | {\n integration: sdk.IntegrationDefinition\n workspaceId?: string // Set if user opted to deploy on another available workspace\n }\n | undefined\n > {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n this.logger.log('Aborted')\n return\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\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AM,QAAQ,CAAC,EAAE;AAAA,EACzF;AAAA,EAEQ,wBAAwB,CAAC,oBAAwE;AACvG,UAAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B;AAAA,MAC/B;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": ["chalk", "semver", "newName", "name"]
|
|
7
7
|
}
|
|
@@ -183,7 +183,7 @@ class InitCommand extends import_global_command.GlobalCommand {
|
|
|
183
183
|
if (!destinationCanBeUsed) {
|
|
184
184
|
throw new errors.AbortedOperationError();
|
|
185
185
|
}
|
|
186
|
-
await fs.promises.cp(srcDir, destination, { recursive: true });
|
|
186
|
+
await fs.promises.cp(srcDir, destination, { recursive: true, filter: (src) => !src.includes("node_modules") });
|
|
187
187
|
const pkgJsonPath = pathlib.join(destination, "package.json");
|
|
188
188
|
const strContent = await fs.promises.readFile(pkgJsonPath, "utf-8");
|
|
189
189
|
const json = JSON.parse(strContent);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/init-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from 'src/api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { Logger } from '../logger'\nimport { ProjectTemplates } from '../project-templates'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nconst projectTypes = ['bot', 'integration', 'plugin'] as const\ntype ProjectType = (typeof projectTypes)[number]\n\ntype CopyProps = { srcDir: string; destDir: string; name: string; pkgJson: Record<string, unknown> }\n\nexport type InitCommandDefinition = typeof commandDefinitions.init\nexport class InitCommand extends GlobalCommand<InitCommandDefinition> {\n public async run(): Promise<void> {\n const projectType = await this._promptProjectType()\n const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir)\n\n if (projectType === 'bot') {\n await this._initBot({ workDir })\n return\n }\n\n if (projectType === 'integration') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initIntegration({ workDir, workspaceHandle })\n return\n }\n\n if (projectType === 'plugin') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initPlugin({ workDir, workspaceHandle })\n return\n }\n\n type _assertion = utils.types.AssertNever<typeof projectType>\n throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`)\n }\n\n private async _promptWorkspaceHandle() {\n const client = (await this.getAuthenticatedClient({})) ?? undefined\n\n const nameParts = this.argv.name?.split('/', 2) ?? []\n const workspaceHandle = nameParts.length > 1 ? nameParts[0] : undefined\n\n const resolver = await WorkspaceResolver.from({\n client,\n workspaceHandle,\n prompt: this.prompt,\n logger: this.logger,\n })\n\n return await resolver.getWorkspaceHandle()\n }\n\n private async _promptProjectType() {\n if (this.argv.type) {\n return this.argv.type\n }\n\n const promptedType = await this.prompt.select('What type of project do you wish to initialize?', {\n choices: projectTypes.map((t) => ({ title: t, value: t })),\n })\n\n if (!promptedType) {\n throw new errors.ParamRequiredError('Project Type')\n }\n\n return promptedType\n }\n\n private _initPlugin = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('plugin')\n const name = await this._getName('plugin', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n try {\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n pluginName: fullName,\n },\n })\n } catch (error) {\n if (error instanceof errors.AbortedOperationError) {\n this.logger.log('Aborted')\n return\n }\n throw error\n }\n this.logger.success(`Plugin project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n }\n\n private async _getOrPromptForTemplate(type: ProjectType): Promise<ProjectTemplates.Template> {\n const availableTemplates = ProjectTemplates.templates[type]\n\n if (this.argv.template) {\n const template = availableTemplates.find((t) => t.identifier === this.argv.template)\n if (!template) {\n throw new errors.BotpressCLIError(`No ${type} template found for identifier \"${this.argv.template}\"`)\n }\n return template\n }\n\n if (availableTemplates.length === 1) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return await this._promptForTemplate(availableTemplates)\n }\n\n private async _promptForTemplate(\n availableTemplates: ProjectTemplates.TemplateArray\n ): Promise<ProjectTemplates.Template> {\n const templateIndex = await this.prompt.select<number>('Which template do you want to use?', {\n choices: availableTemplates.map((template, index) => ({\n title: template.fullName,\n value: index,\n })),\n default: 0,\n })\n\n if (templateIndex === undefined || templateIndex < 0 || templateIndex >= availableTemplates.length) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return availableTemplates[templateIndex]!\n }\n\n private _getFullNameAndShortName(args: { workspaceHandle: string; name: string }) {\n const [workspaceOrName, projectName] = args.name.split('/', 2)\n const shortName = projectName ?? workspaceOrName!\n const fullName = `${args.workspaceHandle}/${shortName}`\n\n return { shortName, fullName }\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const template = await this._getOrPromptForTemplate('bot')\n const name = await this._getName('bot', template.defaultProjectName)\n\n await this._copy({ srcDir: template.absolutePath, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(pathlib.join(workDir, name))}`)\n }\n\n private _initIntegration = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('integration')\n const name = await this._getName('integration', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n integrationName: fullName,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n return\n }\n\n private _getName = async (projectType: ProjectType, defaultName: string): Promise<string> => {\n if (this.argv.name) {\n return this.argv.name\n }\n const promptMessage = `What is the name of your ${projectType}?`\n const promptedName = await this.prompt.text(promptMessage, { initial: defaultName })\n if (!promptedName) {\n throw new errors.ParamRequiredError('Project Name')\n }\n return promptedName\n }\n\n private _copy = async (props: CopyProps) => {\n const { srcDir, destDir, name, pkgJson } = props\n\n const dirName = utils.casing.to.kebabCase(name)\n const destination = pathlib.join(destDir, dirName)\n\n const destinationCanBeUsed = await this._checkIfDestinationCanBeUsed(destination)\n if (!destinationCanBeUsed) {\n throw new errors.AbortedOperationError()\n }\n\n await fs.promises.cp(srcDir, destination, { recursive: true })\n\n const pkgJsonPath = pathlib.join(destination, 'package.json')\n const strContent = await fs.promises.readFile(pkgJsonPath, 'utf-8')\n const json = JSON.parse(strContent)\n\n const pkgJsonName = utils.casing.to.snakeCase(name)\n const updatedJson = { name: pkgJsonName, ...json, ...pkgJson }\n await fs.promises.writeFile(pkgJsonPath, JSON.stringify(updatedJson, null, 2))\n }\n\n private _checkIfDestinationCanBeUsed = async (destination: string) => {\n if (fs.existsSync(destination)) {\n const override = await this.prompt.confirm(\n `Directory ${chalk.bold(destination)} already exists. Do you want to overwrite it?`\n )\n if (!override) {\n return false\n }\n }\n return true\n }\n}\n\nclass WorkspaceResolver {\n private _workspaces: client.Workspace[] = []\n private _currentWorkspace?: client.Workspace\n\n private constructor(\n private readonly _client: ApiClient | undefined,\n private readonly _workspaceHandle: string | undefined,\n private readonly _prompt: utils.prompt.CLIPrompt,\n private readonly _logger: Logger\n ) {}\n\n public static async from({\n client,\n workspaceHandle,\n prompt,\n logger,\n }: {\n client?: ApiClient\n workspaceHandle?: string\n prompt: utils.prompt.CLIPrompt\n logger: Logger\n }): Promise<WorkspaceResolver> {\n const resolver = new WorkspaceResolver(client, workspaceHandle, prompt, logger)\n await resolver._fetchWorkspaces()\n return resolver\n }\n\n public async getWorkspaceHandle(): Promise<string> {\n if (this._hasNoWorkspaces()) {\n return this._promptForArbitraryWorkspaceHandle()\n }\n\n const workspace = await this._promptUserToSelectWorkspace()\n return workspace.handle || (await this._assignHandleToWorkspace(workspace))\n }\n\n private async _fetchWorkspaces(): Promise<void> {\n if (!this._isAuthenticated()) {\n return\n }\n\n const workspaces = await this._getClient()\n .client.list.workspaces({})\n .collect({})\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Unable to list your workspaces')\n })\n const currentWorkspace = workspaces.find((ws) => ws.id === this._getClient().workspaceId)\n\n this._workspaces = workspaces\n this._currentWorkspace = currentWorkspace\n }\n\n private _isAuthenticated(): boolean {\n return !!this._client\n }\n\n private _hasNoWorkspaces(): boolean {\n return !this._isAuthenticated() || this._workspaces.length === 0 || !this._currentWorkspace\n }\n\n private async _promptForArbitraryWorkspaceHandle(): Promise<string> {\n if (this._workspaceHandle) {\n return this._workspaceHandle\n }\n\n const handle = await this._prompt.text('Enter your workspace handle')\n\n if (!handle) {\n throw new errors.ParamRequiredError('Workspace handle')\n }\n\n return handle\n }\n\n private async _promptUserToSelectWorkspace(): Promise<client.Workspace> {\n const workspaceChoices = this._workspaces.map((ws) => ({\n title: ws.name,\n value: ws.id,\n }))\n\n const initialChoice = {\n title: this._currentWorkspace!.name,\n value: this._currentWorkspace!.id,\n }\n\n const workspaceId = await this._prompt.select('Which workspace do you want to use?', {\n initial: initialChoice,\n choices: workspaceChoices,\n })\n\n if (!workspaceId) {\n throw new errors.ParamRequiredError('Workspace')\n }\n\n return this._workspaces.find((ws) => ws.id === workspaceId)!\n }\n\n private async _assignHandleToWorkspace(workspace: client.Workspace): Promise<string> {\n this._logger.warn(\"It seems you don't have a workspace handle yet.\")\n\n let claimedHandle: string | undefined\n\n do {\n const desiredHandle = await this._promptForDesiredHandle()\n const isAvailable = await this._checkHandleAvailability(desiredHandle)\n\n if (isAvailable) {\n claimedHandle = desiredHandle\n await this._updateWorkspaceWithHandle(workspace.id, claimedHandle)\n }\n } while (!claimedHandle)\n\n this._logger.success(`Handle \"${claimedHandle}\" is yours!`)\n return claimedHandle\n }\n\n private async _promptForDesiredHandle(): Promise<string> {\n const desiredHandle = await this._prompt.text('Please enter a workspace handle')\n\n if (!desiredHandle) {\n throw new errors.BotpressCLIError('Workspace handle is required')\n }\n\n return desiredHandle\n }\n\n private async _checkHandleAvailability(handle: string): Promise<boolean> {\n const { available, suggestions } = await this._getClient().client.checkHandleAvailability({ handle })\n\n if (!available) {\n this._logger.warn(`Handle \"${handle}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n return false\n }\n\n return true\n }\n\n private async _updateWorkspaceWithHandle(workspaceId: string, handle: string): Promise<void> {\n try {\n await this._getClient().switchWorkspace(workspaceId).updateWorkspace({ handle })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${handle}\"`)\n }\n }\n\n private _getClient(): ApiClient {\n if (!this._client) {\n throw new errors.BotpressCLIError('Could not authenticate')\n }\n return this._client\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AAGzB,aAAwB;AAExB,+BAAiC;AACjC,YAAuB;AACvB,4BAA8B;AAE9B,MAAM,eAAe,CAAC,OAAO,eAAe,QAAQ;AAM7C,MAAM,oBAAoB,oCAAqC;AAAA,EACpE,MAAa,MAAqB;AAChC,UAAM,cAAc,MAAM,KAAK,mBAAmB;AAClD,UAAM,UAAU,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,KAAK,OAAO;AAE3E,QAAI,gBAAgB,OAAO;AACzB,YAAM,KAAK,SAAS,EAAE,QAAQ,CAAC;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K,QAAQ,KAAK,SAAS,SAAS,CAAC,GAAG;AACxG;AAAA,EACF;AAAA,EAEQ,WAAW,OAAO,aAA0B,gBAAyC;AAC3F,QAAI,KAAK,KAAK,MAAM;AAClB,aAAO,KAAK,KAAK;AAAA,IACnB;AACA,UAAM,gBAAgB,4BAA4B;AAClD,UAAM,eAAe,MAAM,KAAK,OAAO,KAAK,eAAe,EAAE,SAAS,YAAY,CAAC;AACnF,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,OAAO,mBAAmB,cAAc;AAAA,IACpD;AACA,WAAO;AAAA,EACT;AAAA,EAEQ,QAAQ,OAAO,UAAqB;AAC1C,UAAM,EAAE,QAAQ,SAAS,MAAM,QAAQ,IAAI;AAE3C,UAAM,UAAU,MAAM,OAAO,GAAG,UAAU,IAAI;AAC9C,UAAM,cAAc,QAAQ,KAAK,SAAS,OAAO;AAEjD,UAAM,uBAAuB,MAAM,KAAK,6BAA6B,WAAW;AAChF,QAAI,CAAC,sBAAsB;AACzB,YAAM,IAAI,OAAO,sBAAsB;AAAA,IACzC;AAEA,UAAM,GAAG,SAAS,GAAG,QAAQ,aAAa,EAAE,WAAW,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from 'src/api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { Logger } from '../logger'\nimport { ProjectTemplates } from '../project-templates'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nconst projectTypes = ['bot', 'integration', 'plugin'] as const\ntype ProjectType = (typeof projectTypes)[number]\n\ntype CopyProps = { srcDir: string; destDir: string; name: string; pkgJson: Record<string, unknown> }\n\nexport type InitCommandDefinition = typeof commandDefinitions.init\nexport class InitCommand extends GlobalCommand<InitCommandDefinition> {\n public async run(): Promise<void> {\n const projectType = await this._promptProjectType()\n const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir)\n\n if (projectType === 'bot') {\n await this._initBot({ workDir })\n return\n }\n\n if (projectType === 'integration') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initIntegration({ workDir, workspaceHandle })\n return\n }\n\n if (projectType === 'plugin') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initPlugin({ workDir, workspaceHandle })\n return\n }\n\n type _assertion = utils.types.AssertNever<typeof projectType>\n throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`)\n }\n\n private async _promptWorkspaceHandle() {\n const client = (await this.getAuthenticatedClient({})) ?? undefined\n\n const nameParts = this.argv.name?.split('/', 2) ?? []\n const workspaceHandle = nameParts.length > 1 ? nameParts[0] : undefined\n\n const resolver = await WorkspaceResolver.from({\n client,\n workspaceHandle,\n prompt: this.prompt,\n logger: this.logger,\n })\n\n return await resolver.getWorkspaceHandle()\n }\n\n private async _promptProjectType() {\n if (this.argv.type) {\n return this.argv.type\n }\n\n const promptedType = await this.prompt.select('What type of project do you wish to initialize?', {\n choices: projectTypes.map((t) => ({ title: t, value: t })),\n })\n\n if (!promptedType) {\n throw new errors.ParamRequiredError('Project Type')\n }\n\n return promptedType\n }\n\n private _initPlugin = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('plugin')\n const name = await this._getName('plugin', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n try {\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n pluginName: fullName,\n },\n })\n } catch (error) {\n if (error instanceof errors.AbortedOperationError) {\n this.logger.log('Aborted')\n return\n }\n throw error\n }\n this.logger.success(`Plugin project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n }\n\n private async _getOrPromptForTemplate(type: ProjectType): Promise<ProjectTemplates.Template> {\n const availableTemplates = ProjectTemplates.templates[type]\n\n if (this.argv.template) {\n const template = availableTemplates.find((t) => t.identifier === this.argv.template)\n if (!template) {\n throw new errors.BotpressCLIError(`No ${type} template found for identifier \"${this.argv.template}\"`)\n }\n return template\n }\n\n if (availableTemplates.length === 1) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return await this._promptForTemplate(availableTemplates)\n }\n\n private async _promptForTemplate(\n availableTemplates: ProjectTemplates.TemplateArray\n ): Promise<ProjectTemplates.Template> {\n const templateIndex = await this.prompt.select<number>('Which template do you want to use?', {\n choices: availableTemplates.map((template, index) => ({\n title: template.fullName,\n value: index,\n })),\n default: 0,\n })\n\n if (templateIndex === undefined || templateIndex < 0 || templateIndex >= availableTemplates.length) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return availableTemplates[templateIndex]!\n }\n\n private _getFullNameAndShortName(args: { workspaceHandle: string; name: string }) {\n const [workspaceOrName, projectName] = args.name.split('/', 2)\n const shortName = projectName ?? workspaceOrName!\n const fullName = `${args.workspaceHandle}/${shortName}`\n\n return { shortName, fullName }\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const template = await this._getOrPromptForTemplate('bot')\n const name = await this._getName('bot', template.defaultProjectName)\n\n await this._copy({ srcDir: template.absolutePath, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(pathlib.join(workDir, name))}`)\n }\n\n private _initIntegration = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('integration')\n const name = await this._getName('integration', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n integrationName: fullName,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n return\n }\n\n private _getName = async (projectType: ProjectType, defaultName: string): Promise<string> => {\n if (this.argv.name) {\n return this.argv.name\n }\n const promptMessage = `What is the name of your ${projectType}?`\n const promptedName = await this.prompt.text(promptMessage, { initial: defaultName })\n if (!promptedName) {\n throw new errors.ParamRequiredError('Project Name')\n }\n return promptedName\n }\n\n private _copy = async (props: CopyProps) => {\n const { srcDir, destDir, name, pkgJson } = props\n\n const dirName = utils.casing.to.kebabCase(name)\n const destination = pathlib.join(destDir, dirName)\n\n const destinationCanBeUsed = await this._checkIfDestinationCanBeUsed(destination)\n if (!destinationCanBeUsed) {\n throw new errors.AbortedOperationError()\n }\n\n await fs.promises.cp(srcDir, destination, { recursive: true, filter: (src) => !src.includes('node_modules') })\n\n const pkgJsonPath = pathlib.join(destination, 'package.json')\n const strContent = await fs.promises.readFile(pkgJsonPath, 'utf-8')\n const json = JSON.parse(strContent)\n\n const pkgJsonName = utils.casing.to.snakeCase(name)\n const updatedJson = { name: pkgJsonName, ...json, ...pkgJson }\n await fs.promises.writeFile(pkgJsonPath, JSON.stringify(updatedJson, null, 2))\n }\n\n private _checkIfDestinationCanBeUsed = async (destination: string) => {\n if (fs.existsSync(destination)) {\n const override = await this.prompt.confirm(\n `Directory ${chalk.bold(destination)} already exists. Do you want to overwrite it?`\n )\n if (!override) {\n return false\n }\n }\n return true\n }\n}\n\nclass WorkspaceResolver {\n private _workspaces: client.Workspace[] = []\n private _currentWorkspace?: client.Workspace\n\n private constructor(\n private readonly _client: ApiClient | undefined,\n private readonly _workspaceHandle: string | undefined,\n private readonly _prompt: utils.prompt.CLIPrompt,\n private readonly _logger: Logger\n ) {}\n\n public static async from({\n client,\n workspaceHandle,\n prompt,\n logger,\n }: {\n client?: ApiClient\n workspaceHandle?: string\n prompt: utils.prompt.CLIPrompt\n logger: Logger\n }): Promise<WorkspaceResolver> {\n const resolver = new WorkspaceResolver(client, workspaceHandle, prompt, logger)\n await resolver._fetchWorkspaces()\n return resolver\n }\n\n public async getWorkspaceHandle(): Promise<string> {\n if (this._hasNoWorkspaces()) {\n return this._promptForArbitraryWorkspaceHandle()\n }\n\n const workspace = await this._promptUserToSelectWorkspace()\n return workspace.handle || (await this._assignHandleToWorkspace(workspace))\n }\n\n private async _fetchWorkspaces(): Promise<void> {\n if (!this._isAuthenticated()) {\n return\n }\n\n const workspaces = await this._getClient()\n .client.list.workspaces({})\n .collect({})\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Unable to list your workspaces')\n })\n const currentWorkspace = workspaces.find((ws) => ws.id === this._getClient().workspaceId)\n\n this._workspaces = workspaces\n this._currentWorkspace = currentWorkspace\n }\n\n private _isAuthenticated(): boolean {\n return !!this._client\n }\n\n private _hasNoWorkspaces(): boolean {\n return !this._isAuthenticated() || this._workspaces.length === 0 || !this._currentWorkspace\n }\n\n private async _promptForArbitraryWorkspaceHandle(): Promise<string> {\n if (this._workspaceHandle) {\n return this._workspaceHandle\n }\n\n const handle = await this._prompt.text('Enter your workspace handle')\n\n if (!handle) {\n throw new errors.ParamRequiredError('Workspace handle')\n }\n\n return handle\n }\n\n private async _promptUserToSelectWorkspace(): Promise<client.Workspace> {\n const workspaceChoices = this._workspaces.map((ws) => ({\n title: ws.name,\n value: ws.id,\n }))\n\n const initialChoice = {\n title: this._currentWorkspace!.name,\n value: this._currentWorkspace!.id,\n }\n\n const workspaceId = await this._prompt.select('Which workspace do you want to use?', {\n initial: initialChoice,\n choices: workspaceChoices,\n })\n\n if (!workspaceId) {\n throw new errors.ParamRequiredError('Workspace')\n }\n\n return this._workspaces.find((ws) => ws.id === workspaceId)!\n }\n\n private async _assignHandleToWorkspace(workspace: client.Workspace): Promise<string> {\n this._logger.warn(\"It seems you don't have a workspace handle yet.\")\n\n let claimedHandle: string | undefined\n\n do {\n const desiredHandle = await this._promptForDesiredHandle()\n const isAvailable = await this._checkHandleAvailability(desiredHandle)\n\n if (isAvailable) {\n claimedHandle = desiredHandle\n await this._updateWorkspaceWithHandle(workspace.id, claimedHandle)\n }\n } while (!claimedHandle)\n\n this._logger.success(`Handle \"${claimedHandle}\" is yours!`)\n return claimedHandle\n }\n\n private async _promptForDesiredHandle(): Promise<string> {\n const desiredHandle = await this._prompt.text('Please enter a workspace handle')\n\n if (!desiredHandle) {\n throw new errors.BotpressCLIError('Workspace handle is required')\n }\n\n return desiredHandle\n }\n\n private async _checkHandleAvailability(handle: string): Promise<boolean> {\n const { available, suggestions } = await this._getClient().client.checkHandleAvailability({ handle })\n\n if (!available) {\n this._logger.warn(`Handle \"${handle}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n return false\n }\n\n return true\n }\n\n private async _updateWorkspaceWithHandle(workspaceId: string, handle: string): Promise<void> {\n try {\n await this._getClient().switchWorkspace(workspaceId).updateWorkspace({ handle })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${handle}\"`)\n }\n }\n\n private _getClient(): ApiClient {\n if (!this._client) {\n throw new errors.BotpressCLIError('Could not authenticate')\n }\n return this._client\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AAGzB,aAAwB;AAExB,+BAAiC;AACjC,YAAuB;AACvB,4BAA8B;AAE9B,MAAM,eAAe,CAAC,OAAO,eAAe,QAAQ;AAM7C,MAAM,oBAAoB,oCAAqC;AAAA,EACpE,MAAa,MAAqB;AAChC,UAAM,cAAc,MAAM,KAAK,mBAAmB;AAClD,UAAM,UAAU,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,KAAK,OAAO;AAE3E,QAAI,gBAAgB,OAAO;AACzB,YAAM,KAAK,SAAS,EAAE,QAAQ,CAAC;AAC/B;AAAA,IACF;AAEA,QAAI,gBAAgB,eAAe;AACjC,YAAM,kBAAkB,MAAM,KAAK,uBAAuB;AAC1D,YAAM,KAAK,iBAAiB,EAAE,SAAS,gBAAgB,CAAC;AACxD;AAAA,IACF;AAEA,QAAI,gBAAgB,UAAU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d,WAAK,QAAQ,KAAK,WAAW,0CAA0C,YAAY,KAAK,IAAI,GAAG;AAC/F,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,2BAA2B,aAAqB,QAA+B;AAC3F,QAAI;AACF,YAAM,KAAK,WAAW,EAAE,gBAAgB,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC;AAAA,IACjF,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B,SAAS;AAAA,IACjF;AAAA,EACF;AAAA,EAEQ,aAAwB;AAC9B,QAAI,CAAC,KAAK,SAAS;AACjB,YAAM,IAAI,OAAO,iBAAiB,wBAAwB;AAAA,IAC5D;AACA,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ export * as entities from "./entities/index"
|
|
|
19
19
|
|
|
20
20
|
export type TIntegration = {
|
|
21
21
|
name: "empty-integration"
|
|
22
|
-
version: "0.0
|
|
22
|
+
version: "0.1.0"
|
|
23
23
|
user: { "tags": {}, "creation": { "enabled": false, "requiredTags": [] } }
|
|
24
24
|
configuration: configuration.Configuration
|
|
25
25
|
configurations: configurations.Configurations
|
|
@@ -22,7 +22,7 @@ export * as workflows from './workflows'
|
|
|
22
22
|
|
|
23
23
|
export type TPlugin = {
|
|
24
24
|
name: "empty-plugin"
|
|
25
|
-
version: "1.0
|
|
25
|
+
version: "0.1.0"
|
|
26
26
|
integrations: integrations.Integrations
|
|
27
27
|
interfaces: interfaces.Interfaces
|
|
28
28
|
configuration: configuration.Configuration
|
|
@@ -19,7 +19,7 @@ export * as entities from "./entities/index"
|
|
|
19
19
|
|
|
20
20
|
export type TIntegration = {
|
|
21
21
|
name: "hello-world"
|
|
22
|
-
version: "0.0
|
|
22
|
+
version: "0.1.0"
|
|
23
23
|
user: { "tags": {}, "creation": { "enabled": false, "requiredTags": [] } }
|
|
24
24
|
configuration: configuration.Configuration
|
|
25
25
|
configurations: configurations.Configurations
|
|
@@ -19,7 +19,7 @@ export * as entities from "./entities/index"
|
|
|
19
19
|
|
|
20
20
|
export type TIntegration = {
|
|
21
21
|
name: "webhook-message"
|
|
22
|
-
version: "0.0
|
|
22
|
+
version: "0.1.0"
|
|
23
23
|
user: { "tags": { "id": { "title": "User ID", "description": "The ID of the user" } }, "creation": { "enabled": false, "requiredTags": [] } }
|
|
24
24
|
configuration: configuration.Configuration
|
|
25
25
|
configurations: configurations.Configurations
|