@botpress/cli 4.16.0 → 4.16.2

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.
@@ -1,32 +1,32 @@
1
1
 
2
- > @botpress/cli@4.16.0 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@4.16.2 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.16.0 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@4.16.2 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@4.16.0 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@4.16.2 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.16.0
14
- 🤖 Botpress CLI v4.16.0
15
- 🤖 Botpress CLI v4.16.0
16
- 🤖 Botpress CLI v4.16.0
17
- ○ Generating typings for plugin empty-plugin...
13
+ 🤖 Botpress CLI v4.16.2
14
+ 🤖 Botpress CLI v4.16.2
15
+ 🤖 Botpress CLI v4.16.2
16
+ 🤖 Botpress CLI v4.16.2
17
+ ○ Generating typings for integration hello-world...
18
+ ○ Generating typings for bot...
18
19
  ✓ Typings available at .botpress
19
20
 
20
- ○ Generating typings for bot...
21
21
  ✓ Typings available at .botpress
22
22
 
23
- ○ Generating typings for integration hello-world...
24
- ○ Generating typings for integration empty-integration...
23
+ ○ Generating typings for plugin empty-plugin...
25
24
  ✓ Typings available at .botpress
26
25
 
26
+ ○ Generating typings for integration empty-integration...
27
27
  ✓ Typings available at .botpress
28
28
 
29
- 🤖 Botpress CLI v4.16.0
29
+ 🤖 Botpress CLI v4.16.2
30
30
  ○ Generating typings for integration webhook-message...
31
31
  ✓ Typings available at .botpress
32
32
 
@@ -43,19 +43,27 @@ class InitCommand extends import_global_command.GlobalCommand {
43
43
  async run() {
44
44
  const projectType = await this._promptProjectType();
45
45
  const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir);
46
- if (projectType === "bot") {
47
- await this._initBot({ workDir });
48
- return;
49
- }
50
- if (projectType === "integration") {
51
- const workspaceHandle = await this._promptWorkspaceHandle();
52
- await this._initIntegration({ workDir, workspaceHandle });
53
- return;
54
- }
55
- if (projectType === "plugin") {
56
- const workspaceHandle = await this._promptWorkspaceHandle();
57
- await this._initPlugin({ workDir, workspaceHandle });
58
- return;
46
+ try {
47
+ if (projectType === "bot") {
48
+ await this._initBot({ workDir });
49
+ return;
50
+ }
51
+ if (projectType === "integration") {
52
+ const workspaceHandle = await this._promptWorkspaceHandle();
53
+ await this._initIntegration({ workDir, workspaceHandle });
54
+ return;
55
+ }
56
+ if (projectType === "plugin") {
57
+ const workspaceHandle = await this._promptWorkspaceHandle();
58
+ await this._initPlugin({ workDir, workspaceHandle });
59
+ return;
60
+ }
61
+ } catch (error) {
62
+ if (error instanceof errors.AbortedOperationError) {
63
+ this.logger.log(error.message);
64
+ return;
65
+ }
66
+ throw error;
59
67
  }
60
68
  throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`);
61
69
  }
@@ -88,22 +96,14 @@ class InitCommand extends import_global_command.GlobalCommand {
88
96
  const template = await this._getOrPromptForTemplate("plugin");
89
97
  const name = await this._getName("plugin", template.defaultProjectName);
90
98
  const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name });
91
- try {
92
- await this._copy({
93
- srcDir: template.absolutePath,
94
- destDir: workDir,
95
- name: shortName,
96
- pkgJson: {
97
- pluginName: fullName
98
- }
99
- });
100
- } catch (error) {
101
- if (error instanceof errors.AbortedOperationError) {
102
- this.logger.log("Aborted");
103
- return;
99
+ await this._copy({
100
+ srcDir: template.absolutePath,
101
+ destDir: workDir,
102
+ name: shortName,
103
+ pkgJson: {
104
+ pluginName: fullName
104
105
  }
105
- throw error;
106
- }
106
+ });
107
107
  this.logger.success(`Plugin project initialized in ${import_chalk.default.bold(pathlib.join(workDir, shortName))}`);
108
108
  };
109
109
  async _getOrPromptForTemplate(type) {
@@ -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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EnE,QAAI;AAEJ,OAAG;AACD,YAAM,gBAAgB,MAAM,KAAK,wBAAwB;AACzD,YAAM,cAAc,MAAM,KAAK,yBAAyB,aAAa;AAErE,UAAI,aAAa;AACf,wBAAgB;AAChB,cAAM,KAAK,2BAA2B,UAAU,IAAI,aAAa;AAAA,MACnE;AAAA,IACF,SAAS,CAAC;AAEV,SAAK,QAAQ,QAAQ,WAAW,0BAA0B;AAC1D,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,0BAA2C;AACvD,UAAM,gBAAgB,MAAM,KAAK,QAAQ,KAAK,iCAAiC;AAE/E,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,OAAO,iBAAiB,8BAA8B;AAAA,IAClE;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,yBAAyB,QAAkC;AACvE,UAAM,EAAE,WAAW,YAAY,IAAI,MAAM,KAAK,WAAW,EAAE,OAAO,wBAAwB,EAAE,OAAO,CAAC;AAEpG,QAAI,CAAC,WAAW;AACd,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;",
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 try {\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 } catch (error) {\n if (error instanceof errors.AbortedOperationError) {\n this.logger.log(error.message)\n return\n }\n throw error\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 await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n pluginName: fullName,\n },\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,KA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M,gBAAgB,MAAM,KAAK,QAAQ,KAAK,iCAAiC;AAE/E,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,OAAO,iBAAiB,8BAA8B;AAAA,IAClE;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,yBAAyB,QAAkC;AACvE,UAAM,EAAE,WAAW,YAAY,IAAI,MAAM,KAAK,WAAW,EAAE,OAAO,wBAAwB,EAAE,OAAO,CAAC;AAEpG,QAAI,CAAC,WAAW;AACd,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
  }
@@ -65,10 +65,12 @@ class ListProfilesCommand extends import_global_command.GlobalCommand {
65
65
  }
66
66
  class UseProfileCommand extends import_global_command.GlobalCommand {
67
67
  async run() {
68
+ const logSuccess = (profileName) => this.logger.success(`Now using profile "${profileName}"`);
68
69
  if (this.argv.profileToUse) {
69
70
  const profile2 = await this.readProfileFromFS(this.argv.profileToUse);
70
71
  await this.globalCache.set("activeProfile", this.argv.profileToUse);
71
72
  await _updateGlobalCache({ globalCache: this.globalCache, profileName: this.argv.profileToUse, profile: profile2 });
73
+ logSuccess(this.argv.profileToUse);
72
74
  return;
73
75
  }
74
76
  const profiles = await this.readProfilesFromFS();
@@ -87,6 +89,7 @@ class UseProfileCommand extends import_global_command.GlobalCommand {
87
89
  throw new errors.BotpressCLIError("The selected profile could not be read");
88
90
  await this.globalCache.set("activeProfile", selectedProfile);
89
91
  await _updateGlobalCache({ globalCache: this.globalCache, profileName: selectedProfile, profile });
92
+ logSuccess(selectedProfile);
90
93
  }
91
94
  }
92
95
  const _updateGlobalCache = async (props) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/profile-commands.ts"],
4
- "sourcesContent": ["import chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { GlobalCache, GlobalCommand, ProfileCredentials } from './global-command'\n\nexport type ActiveProfileCommandDefinition = typeof commandDefinitions.profiles.subcommands.active\nexport class ActiveProfileCommand extends GlobalCommand<ActiveProfileCommandDefinition> {\n public async run(): Promise<void> {\n let activeProfileName = await this.globalCache.get('activeProfile')\n\n if (!activeProfileName) {\n this.logger.log(`No active profile set, defaulting to ${consts.defaultProfileName}`)\n activeProfileName = consts.defaultProfileName\n await this.globalCache.set('activeProfile', activeProfileName)\n }\n\n const profile = await this.readProfileFromFS(activeProfileName)\n this.logger.log('Active profile:')\n this.logger.json({ [activeProfileName]: profile })\n }\n}\n\nexport type ListProfilesCommandDefinition = typeof commandDefinitions.profiles.subcommands.list\nexport class ListProfilesCommand extends GlobalCommand<ListProfilesCommandDefinition> {\n public async run(): Promise<void> {\n const profiles = await this.readProfilesFromFS()\n if (Object.keys(profiles).length === 0) {\n this.logger.log('No profiles found')\n return\n }\n const activeProfileName = await this.globalCache.get('activeProfile')\n const profileNames = Object.keys(profiles)\n this.logger.log(`Active profile: '${chalk.bold(activeProfileName)}'`)\n this.logger.json(profileNames)\n }\n}\n\nexport type UseProfileCommandDefinition = typeof commandDefinitions.profiles.subcommands.use\nexport class UseProfileCommand extends GlobalCommand<UseProfileCommandDefinition> {\n public async run(): Promise<void> {\n if (this.argv.profileToUse) {\n const profile = await this.readProfileFromFS(this.argv.profileToUse)\n await this.globalCache.set('activeProfile', this.argv.profileToUse)\n await _updateGlobalCache({ globalCache: this.globalCache, profileName: this.argv.profileToUse, profile })\n return\n }\n const profiles = await this.readProfilesFromFS()\n const choices = Object.entries(profiles).map(([profileName, _]) => ({\n title: profileName,\n description: '',\n value: profileName,\n }))\n const selectedProfile = await this.prompt.select('Select the profile you want to use.', { choices })\n\n if (!selectedProfile) {\n this.logger.log('No profile selected, aborting.')\n return\n }\n\n const profile = profiles[selectedProfile]\n if (!profile) throw new errors.BotpressCLIError('The selected profile could not be read')\n await this.globalCache.set('activeProfile', selectedProfile)\n await _updateGlobalCache({ globalCache: this.globalCache, profileName: selectedProfile, profile })\n }\n}\n\nconst _updateGlobalCache = async (props: {\n globalCache: utils.cache.FSKeyValueCache<GlobalCache>\n profileName: string\n profile: ProfileCredentials\n}): Promise<void> => {\n await props.globalCache.set('activeProfile', props.profileName)\n await props.globalCache.set('apiUrl', props.profile.apiUrl)\n await props.globalCache.set('token', props.profile.token)\n await props.globalCache.set('workspaceId', props.profile.workspaceId)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,aAAwB;AACxB,aAAwB;AAExB,4BAA+D;AAGxD,MAAM,6BAA6B,oCAA8C;AAAA,EACtF,MAAa,MAAqB;AAChC,QAAI,oBAAoB,MAAM,KAAK,YAAY,IAAI,eAAe;AAElE,QAAI,CAAC,mBAAmB;AACtB,WAAK,OAAO,IAAI,wCAAwC,OAAO,oBAAoB;AACnF,0BAAoB,OAAO;AAC3B,YAAM,KAAK,YAAY,IAAI,iBAAiB,iBAAiB;AAAA,IAC/D;AAEA,UAAM,UAAU,MAAM,KAAK,kBAAkB,iBAAiB;AAC9D,SAAK,OAAO,IAAI,iBAAiB;AACjC,SAAK,OAAO,KAAK,EAAE,CAAC,iBAAiB,GAAG,QAAQ,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AAa,aAAa,iBAAiB,QAAQ,CAAC;AAAA,EACnG;AACF;AAEA,MAAM,qBAAqB,OAAO,UAIb;AACnB,QAAM,MAAM,YAAY,IAAI,iBAAiB,MAAM,WAAW;AAC9D,QAAM,MAAM,YAAY,IAAI,UAAU,MAAM,QAAQ,MAAM;AAC1D,QAAM,MAAM,YAAY,IAAI,SAAS,MAAM,QAAQ,KAAK;AACxD,QAAM,MAAM,YAAY,IAAI,eAAe,MAAM,QAAQ,WAAW;AACtE;",
4
+ "sourcesContent": ["import chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { GlobalCache, GlobalCommand, ProfileCredentials } from './global-command'\n\nexport type ActiveProfileCommandDefinition = typeof commandDefinitions.profiles.subcommands.active\nexport class ActiveProfileCommand extends GlobalCommand<ActiveProfileCommandDefinition> {\n public async run(): Promise<void> {\n let activeProfileName = await this.globalCache.get('activeProfile')\n\n if (!activeProfileName) {\n this.logger.log(`No active profile set, defaulting to ${consts.defaultProfileName}`)\n activeProfileName = consts.defaultProfileName\n await this.globalCache.set('activeProfile', activeProfileName)\n }\n\n const profile = await this.readProfileFromFS(activeProfileName)\n this.logger.log('Active profile:')\n this.logger.json({ [activeProfileName]: profile })\n }\n}\n\nexport type ListProfilesCommandDefinition = typeof commandDefinitions.profiles.subcommands.list\nexport class ListProfilesCommand extends GlobalCommand<ListProfilesCommandDefinition> {\n public async run(): Promise<void> {\n const profiles = await this.readProfilesFromFS()\n if (Object.keys(profiles).length === 0) {\n this.logger.log('No profiles found')\n return\n }\n const activeProfileName = await this.globalCache.get('activeProfile')\n const profileNames = Object.keys(profiles)\n this.logger.log(`Active profile: '${chalk.bold(activeProfileName)}'`)\n this.logger.json(profileNames)\n }\n}\n\nexport type UseProfileCommandDefinition = typeof commandDefinitions.profiles.subcommands.use\nexport class UseProfileCommand extends GlobalCommand<UseProfileCommandDefinition> {\n public async run(): Promise<void> {\n const logSuccess = (profileName: string) => this.logger.success(`Now using profile \"${profileName}\"`)\n\n if (this.argv.profileToUse) {\n const profile = await this.readProfileFromFS(this.argv.profileToUse)\n await this.globalCache.set('activeProfile', this.argv.profileToUse)\n await _updateGlobalCache({ globalCache: this.globalCache, profileName: this.argv.profileToUse, profile })\n logSuccess(this.argv.profileToUse)\n return\n }\n const profiles = await this.readProfilesFromFS()\n const choices = Object.entries(profiles).map(([profileName, _]) => ({\n title: profileName,\n description: '',\n value: profileName,\n }))\n const selectedProfile = await this.prompt.select('Select the profile you want to use.', { choices })\n\n if (!selectedProfile) {\n this.logger.log('No profile selected, aborting.')\n return\n }\n\n const profile = profiles[selectedProfile]\n if (!profile) throw new errors.BotpressCLIError('The selected profile could not be read')\n await this.globalCache.set('activeProfile', selectedProfile)\n await _updateGlobalCache({ globalCache: this.globalCache, profileName: selectedProfile, profile })\n logSuccess(selectedProfile)\n }\n}\n\nconst _updateGlobalCache = async (props: {\n globalCache: utils.cache.FSKeyValueCache<GlobalCache>\n profileName: string\n profile: ProfileCredentials\n}): Promise<void> => {\n await props.globalCache.set('activeProfile', props.profileName)\n await props.globalCache.set('apiUrl', props.profile.apiUrl)\n await props.globalCache.set('token', props.profile.token)\n await props.globalCache.set('workspaceId', props.profile.workspaceId)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,aAAwB;AACxB,aAAwB;AAExB,4BAA+D;AAGxD,MAAM,6BAA6B,oCAA8C;AAAA,EACtF,MAAa,MAAqB;AAChC,QAAI,oBAAoB,MAAM,KAAK,YAAY,IAAI,eAAe;AAElE,QAAI,CAAC,mBAAmB;AACtB,WAAK,OAAO,IAAI,wCAAwC,OAAO,oBAAoB;AACnF,0BAAoB,OAAO;AAC3B,YAAM,KAAK,YAAY,IAAI,iBAAiB,iBAAiB;AAAA,IAC/D;AAEA,UAAM,UAAU,MAAM,KAAK,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,IAAI,gCAAgC;AAChD;AAAA,IACF;AAEA,UAAM,UAAU,SAAS,eAAe;AACxC,QAAI,CAAC;AAAS,YAAM,IAAI,OAAO,iBAAiB,wCAAwC;AACxF,UAAM,KAAK,YAAY,IAAI,iBAAiB,eAAe;AAC3D,UAAM,mBAAmB,EAAE,aAAa,KAAK,aAAa,aAAa,iBAAiB,QAAQ,CAAC;AACjG,eAAW,eAAe;AAAA,EAC5B;AACF;AAEA,MAAM,qBAAqB,OAAO,UAIb;AACnB,QAAM,MAAM,YAAY,IAAI,iBAAiB,MAAM,WAAW;AAC9D,QAAM,MAAM,YAAY,IAAI,UAAU,MAAM,QAAQ,MAAM;AAC1D,QAAM,MAAM,YAAY,IAAI,SAAS,MAAM,QAAQ,KAAK;AACxD,QAAM,MAAM,YAAY,IAAI,eAAe,MAAM,QAAQ,WAAW;AACtE;",
6
6
  "names": ["chalk", "profile"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "4.16.0",
3
+ "version": "4.16.2",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",