@botpress/cli 3.2.2 → 3.3.0

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,22 +1,22 @@
1
1
 
2
- > @botpress/cli@3.2.2 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@3.3.0 build /home/runner/work/botpress/botpress/packages/cli
3
3
  > pnpm run bundle && pnpm run template:gen
4
4
 
5
5
 
6
- > @botpress/cli@3.2.2 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@3.3.0 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@3.2.2 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@3.3.0 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 v3.2.2
14
- šŸ¤– Botpress CLI v3.2.2
15
- šŸ¤– Botpress CLI v3.2.2
16
- šŸ¤– Botpress CLI v3.2.2
17
- ā—‹ Generating typings for bot...ā—‹ Generating typings for integration empty-integration...āœ“ Typings available at .botpress
13
+ šŸ¤– Botpress CLI v3.3.0
14
+ šŸ¤– Botpress CLI v3.3.0
15
+ šŸ¤– Botpress CLI v3.3.0
16
+ šŸ¤– Botpress CLI v3.3.0
17
+ ā—‹ Generating typings for integration hello-world...ā—‹ Generating typings for bot...āœ“ Typings available at .botpress
18
+ ā—‹ Generating typings for integration empty-integration...āœ“ Typings available at .botpress
18
19
  āœ“ Typings available at .botpress
19
- ā—‹ Generating typings for integration hello-world...ā—‹ Generating typings for plugin empty-plugin...āœ“ Typings available at .botpress
20
- āœ“ Typings available at .botpress
21
- šŸ¤– Botpress CLI v3.2.2
20
+ ā—‹ Generating typings for plugin empty-plugin...āœ“ Typings available at .botpress
21
+ šŸ¤– Botpress CLI v3.3.0
22
22
  ā—‹ Generating typings for integration webhook-message...āœ“ Typings available at .botpress
@@ -78,19 +78,26 @@ class GlobalCommand extends import_base_command.BaseCommand {
78
78
  teardown = async () => {
79
79
  this.logger.cleanup();
80
80
  };
81
- async ensureLoginAndCreateClient(credentials) {
81
+ async getAuthenticatedClient(credentials) {
82
82
  const cache = this.globalCache;
83
- const token = await cache.get("token");
83
+ const token = credentials.token ?? await cache.get("token");
84
84
  const workspaceId = credentials.workspaceId ?? await cache.get("workspaceId");
85
85
  const apiUrl = credentials.apiUrl ?? await cache.get("apiUrl");
86
86
  if (!(token && workspaceId && apiUrl)) {
87
- throw new errors.NotLoggedInError();
87
+ return null;
88
88
  }
89
89
  if (apiUrl !== consts.defaultBotpressApiUrl) {
90
90
  this.logger.log(`Using custom url ${apiUrl}`, { prefix: "\u{1F517}" });
91
91
  }
92
92
  return this.api.newClient({ apiUrl, token, workspaceId }, this.logger);
93
93
  }
94
+ async ensureLoginAndCreateClient(credentials) {
95
+ const client = await this.getAuthenticatedClient(credentials);
96
+ if (client === null) {
97
+ throw new errors.NotLoggedInError();
98
+ }
99
+ return client;
100
+ }
94
101
  _notifyUpdateCli = async () => {
95
102
  try {
96
103
  this.logger.debug("Checking if cli is up to date");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/global-command.ts"],
4
- "sourcesContent": ["import type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport latestVersion from 'latest-version'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport type { ApiClientFactory } from '../api/client'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { BaseCommand } from './base-command'\n\nexport type GlobalCommandDefinition = CommandDefinition<typeof config.schemas.global>\nexport type GlobalCache = { apiUrl: string; token: string; workspaceId: string }\n\nexport type ConfigurableGlobalPaths = { botpressHomeDir: string; cliRootDir: utils.path.AbsolutePath }\nexport type ConstantGlobalPaths = typeof consts.fromHomeDir & typeof consts.fromCliRootDir\nexport type AllGlobalPaths = ConfigurableGlobalPaths & ConstantGlobalPaths\n\nclass GlobalPaths extends utils.path.PathStore<keyof AllGlobalPaths> {\n public constructor(argv: CommandArgv<GlobalCommandDefinition>) {\n const absBotpressHome = utils.path.absoluteFrom(utils.path.cwd(), argv.botpressHome)\n super({\n cliRootDir: consts.cliRootDir,\n botpressHomeDir: absBotpressHome,\n ..._.mapValues(consts.fromHomeDir, (p) => utils.path.absoluteFrom(absBotpressHome, p)),\n ..._.mapValues(consts.fromCliRootDir, (p) => utils.path.absoluteFrom(consts.cliRootDir, p)),\n })\n }\n}\n\nexport abstract class GlobalCommand<C extends GlobalCommandDefinition> extends BaseCommand<C> {\n protected api: ApiClientFactory\n protected prompt: utils.prompt.CLIPrompt\n private _pkgJson: utils.pkgJson.PackageJson | undefined\n\n public constructor(\n api: ApiClientFactory,\n prompt: utils.prompt.CLIPrompt,\n ...args: ConstructorParameters<typeof BaseCommand<C>>\n ) {\n super(...args)\n this.api = api\n this.prompt = prompt\n }\n\n protected get globalPaths() {\n return new GlobalPaths(this.argv)\n }\n\n protected get globalCache() {\n return new utils.cache.FSKeyValueCache<GlobalCache>(this.globalPaths.abs.globalCacheFile)\n }\n\n protected override async bootstrap() {\n const pkgJson = await this.readPkgJson()\n const versionText = chalk.bold(`v${pkgJson.version}`)\n this.logger.log(`Botpress CLI ${versionText}`, { prefix: '\uD83E\uDD16' })\n\n await this._notifyUpdateCli()\n\n const paths = this.globalPaths\n if (paths.abs.botpressHomeDir !== consts.defaultBotpressHome) {\n this.logger.log(`Using custom botpress home: ${paths.abs.botpressHomeDir}`, { prefix: '\uD83C\uDFE0' })\n }\n }\n\n protected override teardown = async () => {\n this.logger.cleanup()\n }\n\n protected async ensureLoginAndCreateClient(credentials: YargsConfig<typeof config.schemas.credentials>) {\n const cache = this.globalCache\n\n const token = await cache.get('token')\n const workspaceId = credentials.workspaceId ?? (await cache.get('workspaceId'))\n const apiUrl = credentials.apiUrl ?? (await cache.get('apiUrl'))\n\n if (!(token && workspaceId && apiUrl)) {\n throw new errors.NotLoggedInError()\n }\n\n if (apiUrl !== consts.defaultBotpressApiUrl) {\n this.logger.log(`Using custom url ${apiUrl}`, { prefix: '\uD83D\uDD17' })\n }\n\n return this.api.newClient({ apiUrl, token, workspaceId }, this.logger)\n }\n\n private _notifyUpdateCli = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if cli is up to date')\n\n const pkgJson = await this.readPkgJson()\n if (!pkgJson.version) {\n throw new errors.BotpressCLIError('Could not find version in package.json')\n }\n\n const latest = await latestVersion(pkgJson.name)\n const isOutdated = semver.lt(pkgJson.version, latest)\n if (isOutdated) {\n this.logger.box(\n [\n `${chalk.bold('Update available')} ${chalk.dim(pkgJson.version)} \u2192 ${chalk.green(latest)}`,\n '',\n 'To update, run:',\n ` for npm ${chalk.cyan(`npm i -g ${pkgJson.name}`)}`,\n ` for yarn ${chalk.cyan(`yarn global add ${pkgJson.name}`)}`,\n ` for pnpm ${chalk.cyan(`pnpm i -g ${pkgJson.name}`)}`,\n ].join('\\n')\n )\n }\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if cli is up to date: ${err.message}`)\n }\n }\n\n protected async readPkgJson(): Promise<utils.pkgJson.PackageJson> {\n if (this._pkgJson) {\n return this._pkgJson\n }\n const { cliRootDir } = this.globalPaths.abs\n const pkgJson = await utils.pkgJson.readPackageJson(cliRootDir)\n if (!pkgJson) {\n throw new errors.BotpressCLIError(`Could not find package.json at \"${cliRootDir}\"`)\n }\n\n this._pkgJson = pkgJson\n return pkgJson\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,4BAA0B;AAC1B,oBAAc;AACd,oBAAmB;AAGnB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,0BAA4B;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AM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AAAA,EAEA,MAAgB,cAAkD;AAChE,QAAI,KAAK,UAAU;AACjB,aAAO,KAAK;AAAA,IACd;AACA,UAAM,EAAE,WAAW,IAAI,KAAK,YAAY;AACxC,UAAM,UAAU,MAAM,MAAM,QAAQ,gBAAgB,UAAU;AAC9D,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,OAAO,iBAAiB,mCAAmC,aAAa;AAAA,IACpF;AAEA,SAAK,WAAW;AAChB,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport latestVersion from 'latest-version'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport type { ApiClientFactory } from '../api/client'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { BaseCommand } from './base-command'\n\nexport type GlobalCommandDefinition = CommandDefinition<typeof config.schemas.global>\nexport type GlobalCache = { apiUrl: string; token: string; workspaceId: string }\n\nexport type ConfigurableGlobalPaths = { botpressHomeDir: string; cliRootDir: utils.path.AbsolutePath }\nexport type ConstantGlobalPaths = typeof consts.fromHomeDir & typeof consts.fromCliRootDir\nexport type AllGlobalPaths = ConfigurableGlobalPaths & ConstantGlobalPaths\n\nclass GlobalPaths extends utils.path.PathStore<keyof AllGlobalPaths> {\n public constructor(argv: CommandArgv<GlobalCommandDefinition>) {\n const absBotpressHome = utils.path.absoluteFrom(utils.path.cwd(), argv.botpressHome)\n super({\n cliRootDir: consts.cliRootDir,\n botpressHomeDir: absBotpressHome,\n ..._.mapValues(consts.fromHomeDir, (p) => utils.path.absoluteFrom(absBotpressHome, p)),\n ..._.mapValues(consts.fromCliRootDir, (p) => utils.path.absoluteFrom(consts.cliRootDir, p)),\n })\n }\n}\n\nexport abstract class GlobalCommand<C extends GlobalCommandDefinition> extends BaseCommand<C> {\n protected api: ApiClientFactory\n protected prompt: utils.prompt.CLIPrompt\n private _pkgJson: utils.pkgJson.PackageJson | undefined\n\n public constructor(\n api: ApiClientFactory,\n prompt: utils.prompt.CLIPrompt,\n ...args: ConstructorParameters<typeof BaseCommand<C>>\n ) {\n super(...args)\n this.api = api\n this.prompt = prompt\n }\n\n protected get globalPaths() {\n return new GlobalPaths(this.argv)\n }\n\n protected get globalCache() {\n return new utils.cache.FSKeyValueCache<GlobalCache>(this.globalPaths.abs.globalCacheFile)\n }\n\n protected override async bootstrap() {\n const pkgJson = await this.readPkgJson()\n const versionText = chalk.bold(`v${pkgJson.version}`)\n this.logger.log(`Botpress CLI ${versionText}`, { prefix: '\uD83E\uDD16' })\n\n await this._notifyUpdateCli()\n\n const paths = this.globalPaths\n if (paths.abs.botpressHomeDir !== consts.defaultBotpressHome) {\n this.logger.log(`Using custom botpress home: ${paths.abs.botpressHomeDir}`, { prefix: '\uD83C\uDFE0' })\n }\n }\n\n protected override teardown = async () => {\n this.logger.cleanup()\n }\n\n protected async getAuthenticatedClient(credentials: Partial<YargsConfig<typeof config.schemas.credentials>>) {\n const cache = this.globalCache\n\n const token = credentials.token ?? (await cache.get('token'))\n const workspaceId = credentials.workspaceId ?? (await cache.get('workspaceId'))\n const apiUrl = credentials.apiUrl ?? (await cache.get('apiUrl'))\n\n if (!(token && workspaceId && apiUrl)) {\n return null\n }\n\n if (apiUrl !== consts.defaultBotpressApiUrl) {\n this.logger.log(`Using custom url ${apiUrl}`, { prefix: '\uD83D\uDD17' })\n }\n\n return this.api.newClient({ apiUrl, token, workspaceId }, this.logger)\n }\n\n protected async ensureLoginAndCreateClient(credentials: YargsConfig<typeof config.schemas.credentials>) {\n const client = await this.getAuthenticatedClient(credentials)\n\n if (client === null) {\n throw new errors.NotLoggedInError()\n }\n\n return client\n }\n\n private _notifyUpdateCli = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if cli is up to date')\n\n const pkgJson = await this.readPkgJson()\n if (!pkgJson.version) {\n throw new errors.BotpressCLIError('Could not find version in package.json')\n }\n\n const latest = await latestVersion(pkgJson.name)\n const isOutdated = semver.lt(pkgJson.version, latest)\n if (isOutdated) {\n this.logger.box(\n [\n `${chalk.bold('Update available')} ${chalk.dim(pkgJson.version)} \u2192 ${chalk.green(latest)}`,\n '',\n 'To update, run:',\n ` for npm ${chalk.cyan(`npm i -g ${pkgJson.name}`)}`,\n ` for yarn ${chalk.cyan(`yarn global add ${pkgJson.name}`)}`,\n ` for pnpm ${chalk.cyan(`pnpm i -g ${pkgJson.name}`)}`,\n ].join('\\n')\n )\n }\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if cli is up to date: ${err.message}`)\n }\n }\n\n protected async readPkgJson(): Promise<utils.pkgJson.PackageJson> {\n if (this._pkgJson) {\n return this._pkgJson\n }\n const { cliRootDir } = this.globalPaths.abs\n const pkgJson = await utils.pkgJson.readPackageJson(cliRootDir)\n if (!pkgJson) {\n throw new errors.BotpressCLIError(`Could not find package.json at \"${cliRootDir}\"`)\n }\n\n this._pkgJson = pkgJson\n return pkgJson\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,4BAA0B;AAC1B,oBAAc;AACd,oBAAmB;AAGnB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,0BAA4B;AAS5B,MAAM,oBAAoB,MAAM,KAAK,UAAgC;AAAA,EAC5D,YAAY,MAA4C;AAC7D,UAAM,kBAAkB,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,YAAY;AACnF,UAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,iBAAiB;AAAA,MACjB,GAAG,cAAAA,QAAE,UAAU,OAAO,aAAa,CAAC,MAAM,MAAM,KAAK,aAAa,iB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B,cAAkD;AAChE,QAAI,KAAK,UAAU;AACjB,aAAO,KAAK;AAAA,IACd;AACA,UAAM,EAAE,WAAW,IAAI,KAAK,YAAY;AACxC,UAAM,UAAU,MAAM,MAAM,QAAQ,gBAAgB,UAAU;AAC9D,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,OAAO,iBAAiB,mCAAmC,aAAa;AAAA,IACpF;AAEA,SAAK,WAAW;AAChB,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["_", "chalk", "latestVersion", "semver"]
7
7
  }
@@ -41,52 +41,76 @@ var import_global_command = require("./global-command");
41
41
  const projectTypes = ["bot", "integration", "plugin"];
42
42
  class InitCommand extends import_global_command.GlobalCommand {
43
43
  async run() {
44
- let { type: projectType } = this.argv;
45
- if (!projectType) {
46
- const promptedType = await this.prompt.select("What type of project do you wish to initialize?", {
47
- choices: projectTypes.map((t) => ({ title: t, value: t }))
48
- });
49
- if (!promptedType) {
50
- throw new errors.ParamRequiredError("Project Type");
51
- }
52
- projectType = promptedType;
53
- }
44
+ const projectType = await this._promptProjectType();
54
45
  const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir);
55
46
  if (projectType === "bot") {
56
47
  await this._initBot({ workDir });
57
48
  return;
58
49
  }
59
50
  if (projectType === "integration") {
60
- await this._initIntegration({ workDir });
51
+ const workspaceHandle = await this._promptWorkspaceHandle();
52
+ await this._initIntegration({ workDir, workspaceHandle });
61
53
  return;
62
54
  }
63
55
  if (projectType === "plugin") {
64
- await this._initPlugin({ workDir });
56
+ const workspaceHandle = await this._promptWorkspaceHandle();
57
+ await this._initPlugin({ workDir, workspaceHandle });
65
58
  return;
66
59
  }
67
60
  throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`);
68
61
  }
62
+ async _promptWorkspaceHandle() {
63
+ const client = await this.getAuthenticatedClient({}) ?? void 0;
64
+ const nameParts = this.argv.name?.split("/", 2) ?? [];
65
+ const workspaceHandle = nameParts.length > 1 ? nameParts[0] : void 0;
66
+ const resolver = await WorkspaceResolver.from({
67
+ client,
68
+ workspaceHandle,
69
+ prompt: this.prompt,
70
+ logger: this.logger
71
+ });
72
+ return await resolver.getWorkspaceHandle();
73
+ }
74
+ async _promptProjectType() {
75
+ if (this.argv.type) {
76
+ return this.argv.type;
77
+ }
78
+ const promptedType = await this.prompt.select("What type of project do you wish to initialize?", {
79
+ choices: projectTypes.map((t) => ({ title: t, value: t }))
80
+ });
81
+ if (!promptedType) {
82
+ throw new errors.ParamRequiredError("Project Type");
83
+ }
84
+ return promptedType;
85
+ }
69
86
  _initPlugin = async (args) => {
70
- const { workDir } = args;
87
+ const { workDir, workspaceHandle } = args;
71
88
  const name = await this._getName("plugin", consts.emptyPluginDirName);
89
+ const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name });
72
90
  await this._copy({
73
91
  srcDir: this.globalPaths.abs.emptyPluginTemplate,
74
92
  destDir: workDir,
75
- name,
93
+ name: shortName,
76
94
  pkgJson: {
77
- pluginName: name
95
+ pluginName: fullName
78
96
  }
79
97
  });
80
- this.logger.success(`Plugin project initialized in ${import_chalk.default.bold(workDir)}`);
98
+ this.logger.success(`Plugin project initialized in ${import_chalk.default.bold(pathlib.join(workDir, shortName))}`);
81
99
  };
100
+ _getFullNameAndShortName(args) {
101
+ const [workspaceOrName, projectName] = args.name.split("/", 2);
102
+ const shortName = projectName ?? workspaceOrName;
103
+ const fullName = `${args.workspaceHandle}/${shortName}`;
104
+ return { shortName, fullName };
105
+ }
82
106
  _initBot = async (args) => {
83
107
  const { workDir } = args;
84
108
  const name = await this._getName("bot", consts.emptyBotDirName);
85
109
  await this._copy({ srcDir: this.globalPaths.abs.emptyBotTemplate, destDir: workDir, name, pkgJson: {} });
86
- this.logger.success(`Bot project initialized in ${import_chalk.default.bold(workDir)}`);
110
+ this.logger.success(`Bot project initialized in ${import_chalk.default.bold(pathlib.join(workDir, name))}`);
87
111
  };
88
112
  _initIntegration = async (args) => {
89
- const { workDir } = args;
113
+ const { workDir, workspaceHandle } = args;
90
114
  const template = await this.prompt.select("Which template do you want to use?", {
91
115
  choices: [
92
116
  { title: "Empty Integration", value: consts.emptyIntegrationDirName },
@@ -104,15 +128,16 @@ class InitCommand extends import_global_command.GlobalCommand {
104
128
  srcDirPath = this.globalPaths.abs.emptyIntegrationTemplate;
105
129
  }
106
130
  const name = await this._getName("integration", template ?? consts.emptyIntegrationDirName);
131
+ const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name });
107
132
  await this._copy({
108
133
  srcDir: srcDirPath,
109
134
  destDir: workDir,
110
- name,
135
+ name: shortName,
111
136
  pkgJson: {
112
- integrationName: name
137
+ integrationName: fullName
113
138
  }
114
139
  });
115
- this.logger.success(`Integration project initialized in ${import_chalk.default.bold(this.argv.workDir)}`);
140
+ this.logger.success(`Integration project initialized in ${import_chalk.default.bold(pathlib.join(workDir, shortName))}`);
116
141
  return;
117
142
  };
118
143
  _getName = async (projectType, defaultName) => {
@@ -155,6 +180,120 @@ class InitCommand extends import_global_command.GlobalCommand {
155
180
  return false;
156
181
  };
157
182
  }
183
+ class WorkspaceResolver {
184
+ constructor(_client, _workspaceHandle, _prompt, _logger) {
185
+ this._client = _client;
186
+ this._workspaceHandle = _workspaceHandle;
187
+ this._prompt = _prompt;
188
+ this._logger = _logger;
189
+ }
190
+ _workspaces = [];
191
+ _currentWorkspace;
192
+ static async from({
193
+ client,
194
+ workspaceHandle,
195
+ prompt,
196
+ logger
197
+ }) {
198
+ const resolver = new WorkspaceResolver(client, workspaceHandle, prompt, logger);
199
+ await resolver._fetchWorkspaces();
200
+ return resolver;
201
+ }
202
+ async getWorkspaceHandle() {
203
+ if (this._hasNoWorkspaces()) {
204
+ return this._promptForArbitraryWorkspaceHandle();
205
+ }
206
+ const workspace = await this._promptUserToSelectWorkspace();
207
+ return workspace.handle ?? await this._assignHandleToWorkspace(workspace);
208
+ }
209
+ async _fetchWorkspaces() {
210
+ if (!this._isAuthenticated()) {
211
+ return;
212
+ }
213
+ const workspaces = await this._getClient().client.list.workspaces({}).collect({}).catch((thrown) => {
214
+ throw errors.BotpressCLIError.wrap(thrown, "Unable to list your workspaces");
215
+ });
216
+ const currentWorkspace = workspaces.find((ws) => ws.id === this._getClient().workspaceId);
217
+ this._workspaces = workspaces;
218
+ this._currentWorkspace = currentWorkspace;
219
+ }
220
+ _isAuthenticated() {
221
+ return !!this._client;
222
+ }
223
+ _hasNoWorkspaces() {
224
+ return !this._isAuthenticated() || this._workspaces.length === 0 || !this._currentWorkspace;
225
+ }
226
+ async _promptForArbitraryWorkspaceHandle() {
227
+ if (this._workspaceHandle) {
228
+ return this._workspaceHandle;
229
+ }
230
+ const handle = await this._prompt.text("Enter your workspace handle");
231
+ if (!handle) {
232
+ throw new errors.ParamRequiredError("Workspace handle");
233
+ }
234
+ return handle;
235
+ }
236
+ async _promptUserToSelectWorkspace() {
237
+ const workspaceChoices = this._workspaces.map((ws) => ({
238
+ title: ws.name,
239
+ value: ws.id
240
+ }));
241
+ const initialChoice = {
242
+ title: this._currentWorkspace.name,
243
+ value: this._currentWorkspace.id
244
+ };
245
+ const workspaceId = await this._prompt.select("Which workspace do you want to use?", {
246
+ initial: initialChoice,
247
+ choices: workspaceChoices
248
+ });
249
+ if (!workspaceId) {
250
+ throw new errors.ParamRequiredError("Workspace");
251
+ }
252
+ return this._workspaces.find((ws) => ws.id === workspaceId);
253
+ }
254
+ async _assignHandleToWorkspace(workspace) {
255
+ this._logger.warn("It seems you don't have a workspace handle yet.");
256
+ let claimedHandle;
257
+ do {
258
+ const desiredHandle = await this._promptForDesiredHandle();
259
+ const isAvailable = await this._checkHandleAvailability(desiredHandle);
260
+ if (isAvailable) {
261
+ claimedHandle = desiredHandle;
262
+ await this._updateWorkspaceWithHandle(workspace.id, claimedHandle);
263
+ }
264
+ } while (!claimedHandle);
265
+ this._logger.success(`Handle "${claimedHandle}" is yours!`);
266
+ return claimedHandle;
267
+ }
268
+ async _promptForDesiredHandle() {
269
+ const desiredHandle = await this._prompt.text("Please enter a workspace handle");
270
+ if (!desiredHandle) {
271
+ throw new errors.BotpressCLIError("Workspace handle is required");
272
+ }
273
+ return desiredHandle;
274
+ }
275
+ async _checkHandleAvailability(handle) {
276
+ const { available, suggestions } = await this._getClient().client.checkHandleAvailability({ handle });
277
+ if (!available) {
278
+ this._logger.warn(`Handle "${handle}" is not available. Suggestions: ${suggestions.join(", ")}`);
279
+ return false;
280
+ }
281
+ return true;
282
+ }
283
+ async _updateWorkspaceWithHandle(workspaceId, handle) {
284
+ try {
285
+ await this._getClient().switchWorkspace(workspaceId).updateWorkspace({ handle });
286
+ } catch (thrown) {
287
+ throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle "${handle}"`);
288
+ }
289
+ }
290
+ _getClient() {
291
+ if (!this._client) {
292
+ throw new errors.BotpressCLIError("Could not authenticate");
293
+ }
294
+ return this._client;
295
+ }
296
+ }
158
297
  // Annotate the CommonJS export names for ESM import in node:
159
298
  0 && (module.exports = {
160
299
  InitCommand
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/init-command.ts"],
4
- "sourcesContent": ["import chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\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 let { type: projectType } = this.argv\n\n if (!projectType) {\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 projectType = promptedType\n }\n\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 await this._initIntegration({ workDir })\n return\n }\n\n if (projectType === 'plugin') {\n await this._initPlugin({ workDir })\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 _initPlugin = async (args: { workDir: string }) => {\n const { workDir } = args\n const name = await this._getName('plugin', consts.emptyPluginDirName)\n await this._copy({\n srcDir: this.globalPaths.abs.emptyPluginTemplate,\n destDir: workDir,\n name,\n pkgJson: {\n pluginName: name,\n },\n })\n this.logger.success(`Plugin project initialized in ${chalk.bold(workDir)}`)\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const name = await this._getName('bot', consts.emptyBotDirName)\n await this._copy({ srcDir: this.globalPaths.abs.emptyBotTemplate, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(workDir)}`)\n }\n\n private _initIntegration = async (args: { workDir: string }) => {\n const { workDir } = args\n\n const template = await this.prompt.select('Which template do you want to use?', {\n choices: [\n { title: 'Empty Integration', value: consts.emptyIntegrationDirName },\n { title: 'Hello World', value: consts.helloWorldIntegrationDirName },\n { title: 'Webhook Message', value: consts.webhookMessageIntegrationDirName },\n ],\n default: consts.emptyIntegrationDirName,\n })\n\n let srcDirPath: string\n if (template === consts.helloWorldIntegrationDirName) {\n srcDirPath = this.globalPaths.abs.helloWorldIntegrationTemplate\n } else if (template === consts.webhookMessageIntegrationDirName) {\n srcDirPath = this.globalPaths.abs.webhookMessageIntegrationTemplate\n } else {\n srcDirPath = this.globalPaths.abs.emptyIntegrationTemplate\n }\n\n const name = await this._getName('integration', template ?? consts.emptyIntegrationDirName)\n\n await this._copy({\n srcDir: srcDirPath,\n destDir: workDir,\n name,\n pkgJson: {\n integrationName: name,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(this.argv.workDir)}`)\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 exist = await this._checkIfDestinationExists(destination)\n if (exist) {\n return\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 _checkIfDestinationExists = 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 this.logger.log('Aborting')\n return true\n }\n }\n return false\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAE9B,MAAM,eAAe,CAAC,OAAO,eAAe,QAAQ;AAM7C,MAAM,oBAAoB,oCAAqC;AAAA,EACpE,MAAa,MAAqB;AAChC,QAAI,EAAE,MAAM,YAAY,IAAI,KAAK;AAEjC,QAAI,CAAC,aAAa;AAChB,YAAM,eAAe,MAAM,KAAK,OAAO,OAAO,mDAAmD;AAAA,QAC/F,SAAS,aAAa,IAAI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UAAM,UAAU,MAAM,OAAO,GAAG,UAAU,IAAI;AAC9C,UAAM,cAAc,QAAQ,KAAK,SAAS,OAAO;AAEjD,UAAM,QAAQ,MAAM,KAAK,0BAA0B,WAAW;AAC9D,QAAI,OAAO;AACT;AAAA,IACF;AAEA,UAAM,GAAG,SAAS,GAAG,QAAQ,aAAa,EAAE,WAAW,KAAK,CAAC;AAE7D,UAAM,cAAc,QAAQ,KAAK,aAAa,cAAc;AAC5D,UAAM,aAAa,MAAM,GAAG,SAAS,SAAS,aAAa,OAAO;AAClE,UAAM,OAAO,KAAK,MAAM,UAAU;AAElC,UAAM,cAAc,MAAM,OAAO,GAAG,UAAU,IAAI;AAClD,UAAM,cAAc,EAAE,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ;AAC7D,UAAM,GAAG,SAAS,UAAU,aAAa,KAAK,UAAU,aAAa,MAAM,CAAC,CAAC;AAAA,EAC/E;AAAA,EAEQ,4BAA4B,OAAO,gBAAwB;AACjE,QAAI,GAAG,WAAW,WAAW,GAAG;AAC9B,YAAM,WAAW,MAAM,KAAK,OAAO;AAAA,QACjC,aAAa,aAAAA,QAAM,KAAK,WAAW;AAAA,MACrC;AACA,UAAI,CAAC,UAAU;AACb,aAAK,OAAO,IAAI,UAAU;AAC1B,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;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 consts from '../consts'\nimport * as errors from '../errors'\nimport { Logger } from '../logger'\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 name = await this._getName('plugin', consts.emptyPluginDirName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: this.globalPaths.abs.emptyPluginTemplate,\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 _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 name = await this._getName('bot', consts.emptyBotDirName)\n\n await this._copy({ srcDir: this.globalPaths.abs.emptyBotTemplate, 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\n const template = await this.prompt.select('Which template do you want to use?', {\n choices: [\n { title: 'Empty Integration', value: consts.emptyIntegrationDirName },\n { title: 'Hello World', value: consts.helloWorldIntegrationDirName },\n { title: 'Webhook Message', value: consts.webhookMessageIntegrationDirName },\n ],\n default: consts.emptyIntegrationDirName,\n })\n\n let srcDirPath: string\n if (template === consts.helloWorldIntegrationDirName) {\n srcDirPath = this.globalPaths.abs.helloWorldIntegrationTemplate\n } else if (template === consts.webhookMessageIntegrationDirName) {\n srcDirPath = this.globalPaths.abs.webhookMessageIntegrationTemplate\n } else {\n srcDirPath = this.globalPaths.abs.emptyIntegrationTemplate\n }\n\n const name = await this._getName('integration', template ?? consts.emptyIntegrationDirName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: srcDirPath,\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 exist = await this._checkIfDestinationExists(destination)\n if (exist) {\n return\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 _checkIfDestinationExists = 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 this.logger.log('Aborting')\n return true\n }\n }\n return false\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;AACxB,aAAwB;AAExB,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;AAC5B,YAAM,kBAAkB,MAAM,KAAK,uBAAuB;AAC1D,YAAM,KAAK,YAAY,EAAE,SAAS,gBAAgB,CAAC;AACnD;AAAA,IACF;AAGA,UAAM,IAAI,OAAO,iBAAiB,yBAAyB,aAAa;AAAA,EAC1E;AAAA,EAEA,MAAc,yBAAyB;AACrC,UAAM,SAAU,MAAM,KAAK,uBAAuB,CAAC,CAAC,KAAM;AAE1D,UAAM,YAAY,KAAK,KAAK,MAAM,MAAM,KAAK,C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BAAyB,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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "3.2.2",
3
+ "version": "3.3.0",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",