@botpress/cli 3.3.2 ā 3.4.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.
- package/.turbo/turbo-build.log +11 -11
- package/dist/command-implementations/init-command.js +39 -23
- package/dist/command-implementations/init-command.js.map +2 -2
- package/dist/config.js +6 -0
- package/dist/config.js.map +2 -2
- package/dist/consts.js +3 -24
- package/dist/consts.js.map +2 -2
- package/dist/project-templates.js +83 -0
- package/dist/project-templates.js.map +7 -0
- package/dist/utils/prompt-utils.js +4 -2
- package/dist/utils/prompt-utils.js.map +2 -2
- package/package.json +2 -5
- package/templates/empty-bot/package.json +1 -1
- package/templates/empty-integration/package.json +1 -1
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@3.
|
|
2
|
+
> @botpress/cli@3.4.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.
|
|
6
|
+
> @botpress/cli@3.4.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@3.
|
|
10
|
+
> @botpress/cli@3.4.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.
|
|
14
|
-
š¤ Botpress CLI v3.
|
|
15
|
-
š¤ Botpress CLI v3.
|
|
16
|
-
š¤ Botpress CLI v3.
|
|
17
|
-
[2K[1Gā Generating typings for integration empty-integration...[2K[1Gā Typings available at .botpress
|
|
18
|
-
[2K[1Gā Generating typings for plugin empty-plugin...[2K[1Gā Typings available at .botpress
|
|
19
|
-
[2K[1Gā Generating typings for integration hello-world...[2K[1Gā Typings available at .botpress
|
|
13
|
+
š¤ Botpress CLI v3.4.0
|
|
14
|
+
š¤ Botpress CLI v3.4.0
|
|
15
|
+
š¤ Botpress CLI v3.4.0
|
|
16
|
+
š¤ Botpress CLI v3.4.0
|
|
20
17
|
[2K[1Gā Generating typings for bot...[2K[1Gā Typings available at .botpress
|
|
21
|
-
|
|
18
|
+
[2K[1Gā Generating typings for integration hello-world...[2K[1Gā Typings available at .botpress
|
|
19
|
+
[2K[1Gā Generating typings for plugin empty-plugin...[2K[1Gā Typings available at .botpress
|
|
20
|
+
[2K[1Gā Generating typings for integration empty-integration...[2K[1Gā Typings available at .botpress
|
|
21
|
+
š¤ Botpress CLI v3.4.0
|
|
22
22
|
[2K[1Gā Generating typings for integration webhook-message...[2K[1Gā Typings available at .botpress
|
|
@@ -34,8 +34,8 @@ module.exports = __toCommonJS(init_command_exports);
|
|
|
34
34
|
var import_chalk = __toESM(require("chalk"));
|
|
35
35
|
var fs = __toESM(require("fs"));
|
|
36
36
|
var pathlib = __toESM(require("path"));
|
|
37
|
-
var consts = __toESM(require("../consts"));
|
|
38
37
|
var errors = __toESM(require("../errors"));
|
|
38
|
+
var import_project_templates = require("../project-templates");
|
|
39
39
|
var utils = __toESM(require("../utils"));
|
|
40
40
|
var import_global_command = require("./global-command");
|
|
41
41
|
const projectTypes = ["bot", "integration", "plugin"];
|
|
@@ -85,10 +85,11 @@ class InitCommand extends import_global_command.GlobalCommand {
|
|
|
85
85
|
}
|
|
86
86
|
_initPlugin = async (args) => {
|
|
87
87
|
const { workDir, workspaceHandle } = args;
|
|
88
|
-
const
|
|
88
|
+
const template = await this._getOrPromptForTemplate("plugin");
|
|
89
|
+
const name = await this._getName("plugin", template.defaultProjectName);
|
|
89
90
|
const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name });
|
|
90
91
|
await this._copy({
|
|
91
|
-
srcDir:
|
|
92
|
+
srcDir: template.absolutePath,
|
|
92
93
|
destDir: workDir,
|
|
93
94
|
name: shortName,
|
|
94
95
|
pkgJson: {
|
|
@@ -97,6 +98,35 @@ class InitCommand extends import_global_command.GlobalCommand {
|
|
|
97
98
|
});
|
|
98
99
|
this.logger.success(`Plugin project initialized in ${import_chalk.default.bold(pathlib.join(workDir, shortName))}`);
|
|
99
100
|
};
|
|
101
|
+
async _getOrPromptForTemplate(type) {
|
|
102
|
+
const availableTemplates = import_project_templates.ProjectTemplates.templates[type];
|
|
103
|
+
if (this.argv.template) {
|
|
104
|
+
const template = availableTemplates.find((t) => t.identifier === this.argv.template);
|
|
105
|
+
if (!template) {
|
|
106
|
+
throw new errors.BotpressCLIError(`No ${type} template found for identifier "${this.argv.template}"`);
|
|
107
|
+
}
|
|
108
|
+
return template;
|
|
109
|
+
}
|
|
110
|
+
if (availableTemplates.length === 1) {
|
|
111
|
+
this.logger.log(`Using default template: ${import_chalk.default.bold(availableTemplates[0].fullName)}`);
|
|
112
|
+
return availableTemplates[0];
|
|
113
|
+
}
|
|
114
|
+
return await this._promptForTemplate(availableTemplates);
|
|
115
|
+
}
|
|
116
|
+
async _promptForTemplate(availableTemplates) {
|
|
117
|
+
const templateIndex = await this.prompt.select("Which template do you want to use?", {
|
|
118
|
+
choices: availableTemplates.map((template, index) => ({
|
|
119
|
+
title: template.fullName,
|
|
120
|
+
value: index
|
|
121
|
+
})),
|
|
122
|
+
default: 0
|
|
123
|
+
});
|
|
124
|
+
if (templateIndex === void 0 || templateIndex < 0 || templateIndex >= availableTemplates.length) {
|
|
125
|
+
this.logger.log(`Using default template: ${import_chalk.default.bold(availableTemplates[0].fullName)}`);
|
|
126
|
+
return availableTemplates[0];
|
|
127
|
+
}
|
|
128
|
+
return availableTemplates[templateIndex];
|
|
129
|
+
}
|
|
100
130
|
_getFullNameAndShortName(args) {
|
|
101
131
|
const [workspaceOrName, projectName] = args.name.split("/", 2);
|
|
102
132
|
const shortName = projectName ?? workspaceOrName;
|
|
@@ -105,32 +135,18 @@ class InitCommand extends import_global_command.GlobalCommand {
|
|
|
105
135
|
}
|
|
106
136
|
_initBot = async (args) => {
|
|
107
137
|
const { workDir } = args;
|
|
108
|
-
const
|
|
109
|
-
await this.
|
|
138
|
+
const template = await this._getOrPromptForTemplate("bot");
|
|
139
|
+
const name = await this._getName("bot", template.defaultProjectName);
|
|
140
|
+
await this._copy({ srcDir: template.absolutePath, destDir: workDir, name, pkgJson: {} });
|
|
110
141
|
this.logger.success(`Bot project initialized in ${import_chalk.default.bold(pathlib.join(workDir, name))}`);
|
|
111
142
|
};
|
|
112
143
|
_initIntegration = async (args) => {
|
|
113
144
|
const { workDir, workspaceHandle } = args;
|
|
114
|
-
const template = await this.
|
|
115
|
-
|
|
116
|
-
{ title: "Empty Integration", value: consts.emptyIntegrationDirName },
|
|
117
|
-
{ title: "Hello World", value: consts.helloWorldIntegrationDirName },
|
|
118
|
-
{ title: "Webhook Message", value: consts.webhookMessageIntegrationDirName }
|
|
119
|
-
],
|
|
120
|
-
default: consts.emptyIntegrationDirName
|
|
121
|
-
});
|
|
122
|
-
let srcDirPath;
|
|
123
|
-
if (template === consts.helloWorldIntegrationDirName) {
|
|
124
|
-
srcDirPath = this.globalPaths.abs.helloWorldIntegrationTemplate;
|
|
125
|
-
} else if (template === consts.webhookMessageIntegrationDirName) {
|
|
126
|
-
srcDirPath = this.globalPaths.abs.webhookMessageIntegrationTemplate;
|
|
127
|
-
} else {
|
|
128
|
-
srcDirPath = this.globalPaths.abs.emptyIntegrationTemplate;
|
|
129
|
-
}
|
|
130
|
-
const name = await this._getName("integration", template ?? consts.emptyIntegrationDirName);
|
|
145
|
+
const template = await this._getOrPromptForTemplate("integration");
|
|
146
|
+
const name = await this._getName("integration", template.defaultProjectName);
|
|
131
147
|
const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name });
|
|
132
148
|
await this._copy({
|
|
133
|
-
srcDir:
|
|
149
|
+
srcDir: template.absolutePath,
|
|
134
150
|
destDir: workDir,
|
|
135
151
|
name: shortName,
|
|
136
152
|
pkgJson: {
|
|
@@ -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 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;
|
|
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 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 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;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,YA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/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/dist/config.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(config_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(config_exports);
|
|
34
34
|
var consts = __toESM(require("./consts"));
|
|
35
|
+
var import_project_templates = require("./project-templates");
|
|
35
36
|
const port = {
|
|
36
37
|
type: "number",
|
|
37
38
|
description: "The port to use"
|
|
@@ -300,6 +301,11 @@ const initSchema = {
|
|
|
300
301
|
...globalSchema,
|
|
301
302
|
workDir,
|
|
302
303
|
type: { type: "string", choices: ["bot", "integration", "plugin"] },
|
|
304
|
+
template: {
|
|
305
|
+
type: "string",
|
|
306
|
+
choices: import_project_templates.ProjectTemplates.getAllChoices(),
|
|
307
|
+
description: "The template to use"
|
|
308
|
+
},
|
|
303
309
|
name: { type: "string", description: "The name of the project" }
|
|
304
310
|
};
|
|
305
311
|
const lintSchema = {
|
package/dist/config.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/config.ts"],
|
|
4
|
-
"sourcesContent": ["import * as consts from './consts'\nimport type { CommandOption, CommandSchema } from './typings'\n\n// command options\n\nconst port = {\n type: 'number',\n description: 'The port to use',\n} satisfies CommandOption\n\nconst workDir = {\n type: 'string',\n description: 'The path to the project',\n default: consts.defaultWorkDir,\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} satisfies CommandOption\n\nconst dryRun = {\n type: 'boolean',\n description: 'Ask the API not to perform the actual operation',\n default: false,\n} as const satisfies CommandOption\n\nconst apiUrl = {\n type: 'string',\n description: 'The URL of the Botpress server',\n} satisfies CommandOption\n\nconst token = {\n type: 'string',\n description: 'You Personal Access Token ',\n} satisfies CommandOption\n\nconst workspaceId = {\n type: 'string',\n description: 'The Workspace Id to deploy to',\n} satisfies CommandOption\n\nconst secrets = {\n type: 'string',\n description: 'Values for the integration secrets',\n array: true,\n default: [],\n} satisfies CommandOption\n\nconst botRef = {\n type: 'string',\n description: 'The bot ID. Bot Name is not supported.',\n demandOption: true,\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst packageType = {\n type: 'string',\n description:\n 'Either an integration or an interface; helps disambiguate the package type in case both an integration and an interface have the same reference.',\n choices: ['integration', 'interface', 'plugin'] as const,\n} satisfies CommandOption\n\nconst packageRef = {\n type: 'string',\n description:\n 'The package ID or name with optional version. The package can be either an integration or an interface. Ex: teams, teams@0.2.0, llm@5.1.0',\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst integrationRef = {\n ...packageRef,\n demandOption: true,\n description: 'The integration ID or name with optional version. Ex: teams or teams@0.2.0',\n} satisfies CommandOption\n\nconst interfaceRef = {\n ...packageRef,\n demandOption: true,\n description: 'The interface ID or name and version. Ex: llm@5.1.0',\n} satisfies CommandOption\n\nconst pluginRef = {\n ...packageRef,\n demandOption: true,\n description: 'The plugin ID or name and version. Ex: knowledge@0.0.1',\n} satisfies CommandOption\n\nconst sourceMap = { type: 'boolean', description: 'Generate sourcemaps', default: false } satisfies CommandOption\n\nconst minify = { type: 'boolean', description: 'Minify the bundled code', default: true } satisfies CommandOption\n\nconst dev = {\n type: 'boolean',\n description: 'List only dev bots / dev integrations',\n default: false,\n} satisfies CommandOption\n\nconst isPublic = {\n type: 'boolean',\n description: 'Weither or not to deploy the integration publicly',\n default: false,\n} satisfies CommandOption\n\n// base schemas\n\nconst globalSchema = {\n verbose: {\n type: 'boolean',\n description: 'Enable verbose logging',\n alias: 'v',\n default: false,\n },\n confirm: {\n type: 'boolean',\n description: 'Confirm all prompts',\n alias: 'y',\n default: false,\n },\n json: {\n type: 'boolean',\n description: 'Prevent logging anything else than raw json in stdout. Useful for piping output to other tools',\n default: false,\n },\n botpressHome: {\n type: 'string',\n description: 'The path to the Botpress home directory',\n default: consts.defaultBotpressHome,\n },\n} satisfies CommandSchema\n\nconst projectSchema = {\n ...globalSchema,\n workDir,\n} satisfies CommandSchema\n\nconst credentialsSchema = {\n apiUrl,\n workspaceId,\n token,\n} satisfies CommandSchema\n\nconst secretsSchema = {\n secrets,\n} satisfies CommandSchema\n\n// command schemas\n\nconst generateSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst bundleSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst buildSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst readSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst serveSchema = {\n ...projectSchema,\n ...secretsSchema,\n port,\n} satisfies CommandSchema\n\nconst deploySchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n botId: { type: 'string', description: 'The bot ID to deploy. Only used when deploying a bot' },\n noBuild,\n dryRun,\n createNewBot: { type: 'boolean', description: 'Create a new bot when deploying. Only used when deploying a bot' },\n sourceMap,\n minify,\n public: isPublic,\n allowDeprecated: {\n type: 'boolean',\n description: 'Allow deprecated features in the project',\n default: false,\n },\n} satisfies CommandSchema\n\nconst devSchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n sourceMap,\n minify,\n port,\n tunnelUrl: {\n type: 'string',\n description: 'The tunnel HTTP URL to use',\n default: consts.defaultTunnelUrl,\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\n packageType,\n installPath: {\n type: 'string',\n description: 'The path where to install the package',\n default: consts.defaultInstallPath,\n },\n useDev: {\n type: 'boolean',\n description: 'If a dev version of the package is found, use it',\n default: false,\n },\n} satisfies CommandSchema\n\nconst loginSchema = {\n ...globalSchema,\n token,\n workspaceId,\n apiUrl: { ...apiUrl, default: consts.defaultBotpressApiUrl },\n} satisfies CommandSchema\n\nconst logoutSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst createBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name of the bot to create' },\n ifNotExists: {\n type: 'boolean',\n description: 'Do not create if a bot with the same name already exists',\n default: false,\n },\n} satisfies CommandSchema\n\nconst getBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst deleteBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst listBotsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n dev,\n} satisfies CommandSchema\n\nconst getIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst listIntegrationsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing integrations' },\n versionNumber: { type: 'string', description: 'The version filter when listing integrations' },\n dev,\n} satisfies CommandSchema\n\nconst deleteIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst getInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst listInterfacesSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deleteInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst getPluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst listPluginsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deletePluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst initSchema = {\n ...globalSchema,\n workDir,\n type: { type: 'string', choices: ['bot', 'integration', 'plugin'] as const },\n name: { type: 'string', description: 'The name of the project' },\n} satisfies CommandSchema\n\nconst lintSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst chatSchema = {\n ...globalSchema,\n ...credentialsSchema,\n chatApiUrl: {\n type: 'string',\n description: 'The URL of the chat server',\n },\n botId: {\n type: 'string',\n positional: true,\n idx: 0,\n description: 'The bot ID to chat with',\n },\n} satisfies CommandSchema\n\n// exports\n\nexport const schemas = {\n global: globalSchema,\n project: projectSchema,\n credentials: credentialsSchema,\n secrets: secretsSchema,\n login: loginSchema,\n logout: logoutSchema,\n createBot: createBotSchema,\n getBot: getBotSchema,\n deleteBot: deleteBotSchema,\n listBots: listBotsSchema,\n getIntegration: getIntegrationSchema,\n listIntegrations: listIntegrationsSchema,\n deleteIntegration: deleteIntegrationSchema,\n getInterface: getInterfaceSchema,\n listInterfaces: listInterfacesSchema,\n deleteInterface: deleteInterfaceSchema,\n getPlugin: getPluginSchema,\n listPlugins: listPluginsSchema,\n deletePlugin: deletePluginSchema,\n init: initSchema,\n generate: generateSchema,\n bundle: bundleSchema,\n build: buildSchema,\n read: readSchema,\n serve: serveSchema,\n deploy: deploySchema,\n add: addSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n} as const\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;
|
|
4
|
+
"sourcesContent": ["import * as consts from './consts'\nimport { ProjectTemplates } from './project-templates'\nimport type { CommandOption, CommandSchema } from './typings'\n\n// command options\n\nconst port = {\n type: 'number',\n description: 'The port to use',\n} satisfies CommandOption\n\nconst workDir = {\n type: 'string',\n description: 'The path to the project',\n default: consts.defaultWorkDir,\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} satisfies CommandOption\n\nconst dryRun = {\n type: 'boolean',\n description: 'Ask the API not to perform the actual operation',\n default: false,\n} as const satisfies CommandOption\n\nconst apiUrl = {\n type: 'string',\n description: 'The URL of the Botpress server',\n} satisfies CommandOption\n\nconst token = {\n type: 'string',\n description: 'You Personal Access Token ',\n} satisfies CommandOption\n\nconst workspaceId = {\n type: 'string',\n description: 'The Workspace Id to deploy to',\n} satisfies CommandOption\n\nconst secrets = {\n type: 'string',\n description: 'Values for the integration secrets',\n array: true,\n default: [],\n} satisfies CommandOption\n\nconst botRef = {\n type: 'string',\n description: 'The bot ID. Bot Name is not supported.',\n demandOption: true,\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst packageType = {\n type: 'string',\n description:\n 'Either an integration or an interface; helps disambiguate the package type in case both an integration and an interface have the same reference.',\n choices: ['integration', 'interface', 'plugin'] as const,\n} satisfies CommandOption\n\nconst packageRef = {\n type: 'string',\n description:\n 'The package ID or name with optional version. The package can be either an integration or an interface. Ex: teams, teams@0.2.0, llm@5.1.0',\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst integrationRef = {\n ...packageRef,\n demandOption: true,\n description: 'The integration ID or name with optional version. Ex: teams or teams@0.2.0',\n} satisfies CommandOption\n\nconst interfaceRef = {\n ...packageRef,\n demandOption: true,\n description: 'The interface ID or name and version. Ex: llm@5.1.0',\n} satisfies CommandOption\n\nconst pluginRef = {\n ...packageRef,\n demandOption: true,\n description: 'The plugin ID or name and version. Ex: knowledge@0.0.1',\n} satisfies CommandOption\n\nconst sourceMap = { type: 'boolean', description: 'Generate sourcemaps', default: false } satisfies CommandOption\n\nconst minify = { type: 'boolean', description: 'Minify the bundled code', default: true } satisfies CommandOption\n\nconst dev = {\n type: 'boolean',\n description: 'List only dev bots / dev integrations',\n default: false,\n} satisfies CommandOption\n\nconst isPublic = {\n type: 'boolean',\n description: 'Weither or not to deploy the integration publicly',\n default: false,\n} satisfies CommandOption\n\n// base schemas\n\nconst globalSchema = {\n verbose: {\n type: 'boolean',\n description: 'Enable verbose logging',\n alias: 'v',\n default: false,\n },\n confirm: {\n type: 'boolean',\n description: 'Confirm all prompts',\n alias: 'y',\n default: false,\n },\n json: {\n type: 'boolean',\n description: 'Prevent logging anything else than raw json in stdout. Useful for piping output to other tools',\n default: false,\n },\n botpressHome: {\n type: 'string',\n description: 'The path to the Botpress home directory',\n default: consts.defaultBotpressHome,\n },\n} satisfies CommandSchema\n\nconst projectSchema = {\n ...globalSchema,\n workDir,\n} satisfies CommandSchema\n\nconst credentialsSchema = {\n apiUrl,\n workspaceId,\n token,\n} satisfies CommandSchema\n\nconst secretsSchema = {\n secrets,\n} satisfies CommandSchema\n\n// command schemas\n\nconst generateSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst bundleSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst buildSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst readSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst serveSchema = {\n ...projectSchema,\n ...secretsSchema,\n port,\n} satisfies CommandSchema\n\nconst deploySchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n botId: { type: 'string', description: 'The bot ID to deploy. Only used when deploying a bot' },\n noBuild,\n dryRun,\n createNewBot: { type: 'boolean', description: 'Create a new bot when deploying. Only used when deploying a bot' },\n sourceMap,\n minify,\n public: isPublic,\n allowDeprecated: {\n type: 'boolean',\n description: 'Allow deprecated features in the project',\n default: false,\n },\n} satisfies CommandSchema\n\nconst devSchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n sourceMap,\n minify,\n port,\n tunnelUrl: {\n type: 'string',\n description: 'The tunnel HTTP URL to use',\n default: consts.defaultTunnelUrl,\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\n packageType,\n installPath: {\n type: 'string',\n description: 'The path where to install the package',\n default: consts.defaultInstallPath,\n },\n useDev: {\n type: 'boolean',\n description: 'If a dev version of the package is found, use it',\n default: false,\n },\n} satisfies CommandSchema\n\nconst loginSchema = {\n ...globalSchema,\n token,\n workspaceId,\n apiUrl: { ...apiUrl, default: consts.defaultBotpressApiUrl },\n} satisfies CommandSchema\n\nconst logoutSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst createBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name of the bot to create' },\n ifNotExists: {\n type: 'boolean',\n description: 'Do not create if a bot with the same name already exists',\n default: false,\n },\n} satisfies CommandSchema\n\nconst getBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst deleteBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst listBotsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n dev,\n} satisfies CommandSchema\n\nconst getIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst listIntegrationsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing integrations' },\n versionNumber: { type: 'string', description: 'The version filter when listing integrations' },\n dev,\n} satisfies CommandSchema\n\nconst deleteIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst getInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst listInterfacesSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deleteInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst getPluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst listPluginsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deletePluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst initSchema = {\n ...globalSchema,\n workDir,\n type: { type: 'string', choices: ['bot', 'integration', 'plugin'] as const },\n template: {\n type: 'string',\n choices: ProjectTemplates.getAllChoices(),\n description: 'The template to use',\n },\n name: { type: 'string', description: 'The name of the project' },\n} satisfies CommandSchema\n\nconst lintSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst chatSchema = {\n ...globalSchema,\n ...credentialsSchema,\n chatApiUrl: {\n type: 'string',\n description: 'The URL of the chat server',\n },\n botId: {\n type: 'string',\n positional: true,\n idx: 0,\n description: 'The bot ID to chat with',\n },\n} satisfies CommandSchema\n\n// exports\n\nexport const schemas = {\n global: globalSchema,\n project: projectSchema,\n credentials: credentialsSchema,\n secrets: secretsSchema,\n login: loginSchema,\n logout: logoutSchema,\n createBot: createBotSchema,\n getBot: getBotSchema,\n deleteBot: deleteBotSchema,\n listBots: listBotsSchema,\n getIntegration: getIntegrationSchema,\n listIntegrations: listIntegrationsSchema,\n deleteIntegration: deleteIntegrationSchema,\n getInterface: getInterfaceSchema,\n listInterfaces: listInterfacesSchema,\n deleteInterface: deleteInterfaceSchema,\n getPlugin: getPluginSchema,\n listPlugins: listPluginsSchema,\n deletePlugin: deletePluginSchema,\n init: initSchema,\n generate: generateSchema,\n bundle: bundleSchema,\n build: buildSchema,\n read: readSchema,\n serve: serveSchema,\n deploy: deploySchema,\n add: addSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n} as const\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,+BAAiC;AAKjC,MAAM,OAAO;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A,EAChB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/consts.js
CHANGED
|
@@ -37,17 +37,12 @@ __export(consts_exports, {
|
|
|
37
37
|
defaultTunnelUrl: () => defaultTunnelUrl,
|
|
38
38
|
defaultWorkDir: () => defaultWorkDir,
|
|
39
39
|
distDirName: () => distDirName,
|
|
40
|
-
emptyBotDirName: () => emptyBotDirName,
|
|
41
|
-
emptyIntegrationDirName: () => emptyIntegrationDirName,
|
|
42
|
-
emptyPluginDirName: () => emptyPluginDirName,
|
|
43
40
|
fromCliRootDir: () => fromCliRootDir,
|
|
44
41
|
fromHomeDir: () => fromHomeDir,
|
|
45
42
|
fromOutDir: () => fromOutDir,
|
|
46
43
|
fromWorkDir: () => fromWorkDir,
|
|
47
|
-
helloWorldIntegrationDirName: () => helloWorldIntegrationDirName,
|
|
48
44
|
installDirName: () => installDirName,
|
|
49
|
-
outDirName: () => outDirName
|
|
50
|
-
webhookMessageIntegrationDirName: () => webhookMessageIntegrationDirName
|
|
45
|
+
outDirName: () => outDirName
|
|
51
46
|
});
|
|
52
47
|
module.exports = __toCommonJS(consts_exports);
|
|
53
48
|
var import_os = __toESM(require("os"));
|
|
@@ -61,21 +56,10 @@ const defaultBotpressAppUrl = "https://app.botpress.cloud";
|
|
|
61
56
|
const defaultTunnelUrl = "https://tunnel.botpress.cloud";
|
|
62
57
|
const defaultChatApiUrl = "https://chat.botpress.cloud";
|
|
63
58
|
const cliRootDir = import_root.CLI_ROOT_DIR;
|
|
64
|
-
const emptyBotDirName = "empty-bot";
|
|
65
|
-
const emptyPluginDirName = "empty-plugin";
|
|
66
|
-
const emptyIntegrationDirName = "empty-integration";
|
|
67
|
-
const helloWorldIntegrationDirName = "hello-world";
|
|
68
|
-
const webhookMessageIntegrationDirName = "webhook-message";
|
|
69
59
|
const installDirName = "bp_modules";
|
|
70
60
|
const outDirName = ".botpress";
|
|
71
61
|
const distDirName = "dist";
|
|
72
|
-
const fromCliRootDir = {
|
|
73
|
-
emptyBotTemplate: import_path.default.join("templates", emptyBotDirName),
|
|
74
|
-
emptyPluginTemplate: import_path.default.join("templates", emptyPluginDirName),
|
|
75
|
-
emptyIntegrationTemplate: import_path.default.join("templates", emptyIntegrationDirName),
|
|
76
|
-
helloWorldIntegrationTemplate: import_path.default.join("templates", helloWorldIntegrationDirName),
|
|
77
|
-
webhookMessageIntegrationTemplate: import_path.default.join("templates", webhookMessageIntegrationDirName)
|
|
78
|
-
};
|
|
62
|
+
const fromCliRootDir = {};
|
|
79
63
|
const fromHomeDir = {
|
|
80
64
|
globalCacheFile: "global.cache.json"
|
|
81
65
|
};
|
|
@@ -114,16 +98,11 @@ const fromWorkDir = {
|
|
|
114
98
|
defaultTunnelUrl,
|
|
115
99
|
defaultWorkDir,
|
|
116
100
|
distDirName,
|
|
117
|
-
emptyBotDirName,
|
|
118
|
-
emptyIntegrationDirName,
|
|
119
|
-
emptyPluginDirName,
|
|
120
101
|
fromCliRootDir,
|
|
121
102
|
fromHomeDir,
|
|
122
103
|
fromOutDir,
|
|
123
104
|
fromWorkDir,
|
|
124
|
-
helloWorldIntegrationDirName,
|
|
125
105
|
installDirName,
|
|
126
|
-
outDirName
|
|
127
|
-
webhookMessageIntegrationDirName
|
|
106
|
+
outDirName
|
|
128
107
|
});
|
|
129
108
|
//# sourceMappingURL=consts.js.map
|
package/dist/consts.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/consts.ts"],
|
|
4
|
-
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\nimport { CLI_ROOT_DIR } from './root'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\nexport const defaultWorkDir = process.cwd()\nexport const defaultInstallPath = process.cwd()\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\nexport const defaultChatApiUrl = 'https://chat.botpress.cloud'\n\n// not configurable\n\nexport const cliRootDir = CLI_ROOT_DIR\nexport const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\nimport { CLI_ROOT_DIR } from './root'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\nexport const defaultWorkDir = process.cwd()\nexport const defaultInstallPath = process.cwd()\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\nexport const defaultChatApiUrl = 'https://chat.botpress.cloud'\n\n// not configurable\n\nexport const cliRootDir = CLI_ROOT_DIR\nexport const installDirName = 'bp_modules'\nexport const outDirName = '.botpress'\nexport const distDirName = 'dist'\n\nexport const fromCliRootDir = {}\n\nexport const fromHomeDir = {\n globalCacheFile: 'global.cache.json',\n}\n\nexport const fromOutDir = {\n distDir: distDirName,\n outFileCJS: pathlib.join(distDirName, 'index.cjs'),\n outFileESM: pathlib.join(distDirName, 'index.mjs'),\n implementationDir: 'implementation',\n pluginsDir: 'plugins',\n secretsDir: 'secrets',\n projectCacheFile: 'project.cache.json',\n}\n\nexport const fromWorkDir = {\n integrationDefinition: 'integration.definition.ts',\n interfaceDefinition: 'interface.definition.ts',\n botDefinition: 'bot.definition.ts',\n pluginDefinition: 'plugin.definition.ts',\n entryPoint: pathlib.join('src', 'index.ts'),\n outDir: outDirName,\n distDir: pathlib.join(outDirName, fromOutDir.distDir),\n outFileCJS: pathlib.join(outDirName, fromOutDir.outFileCJS),\n outFileESM: pathlib.join(outDirName, fromOutDir.outFileESM),\n implementationDir: pathlib.join(outDirName, fromOutDir.implementationDir),\n pluginsDir: pathlib.join(outDirName, fromOutDir.pluginsDir),\n secretsDir: pathlib.join(outDirName, fromOutDir.secretsDir),\n projectCacheFile: pathlib.join(outDirName, fromOutDir.projectCacheFile),\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;AACpB,kBAA6B;AAItB,MAAM,sBAAsB,YAAAA,QAAQ,KAAK,UAAAC,QAAG,QAAQ,GAAG,WAAW;AAClE,MAAM,iBAAiB,QAAQ,IAAI;AACnC,MAAM,qBAAqB,QAAQ,IAAI;AACvC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAI1B,MAAM,aAAa;AACnB,MAAM,iBAAiB;AACvB,MAAM,aAAa;AACnB,MAAM,cAAc;AAEpB,MAAM,iBAAiB,CAAC;AAExB,MAAM,cAAc;AAAA,EACzB,iBAAiB;AACnB;AAEO,MAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,YAAY,YAAAD,QAAQ,KAAK,aAAa,WAAW;AAAA,EACjD,YAAY,YAAAA,QAAQ,KAAK,aAAa,WAAW;AAAA,EACjD,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,kBAAkB;AACpB;AAEO,MAAM,cAAc;AAAA,EACzB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,YAAY,YAAAA,QAAQ,KAAK,OAAO,UAAU;AAAA,EAC1C,QAAQ;AAAA,EACR,SAAS,YAAAA,QAAQ,KAAK,YAAY,WAAW,OAAO;AAAA,EACpD,YAAY,YAAAA,QAAQ,KAAK,YAAY,WAAW,UAAU;AAAA,EAC1D,YAAY,YAAAA,QAAQ,KAAK,YAAY,WAAW,UAAU;AAAA,EAC1D,mBAAmB,YAAAA,QAAQ,KAAK,YAAY,WAAW,iBAAiB;AAAA,EACxE,YAAY,YAAAA,QAAQ,KAAK,YAAY,WAAW,UAAU;AAAA,EAC1D,YAAY,YAAAA,QAAQ,KAAK,YAAY,WAAW,UAAU;AAAA,EAC1D,kBAAkB,YAAAA,QAAQ,KAAK,YAAY,WAAW,gBAAgB;AACxE;",
|
|
6
6
|
"names": ["pathlib", "os"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var project_templates_exports = {};
|
|
30
|
+
__export(project_templates_exports, {
|
|
31
|
+
ProjectTemplates: () => ProjectTemplates
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(project_templates_exports);
|
|
34
|
+
var consts = __toESM(require("./consts"));
|
|
35
|
+
var utils = __toESM(require("./utils"));
|
|
36
|
+
var ProjectTemplates;
|
|
37
|
+
((ProjectTemplates2) => {
|
|
38
|
+
const _dirNameToAbsPath = (directoryName) => utils.path.join(consts.cliRootDir, "templates", directoryName);
|
|
39
|
+
ProjectTemplates2.templates = {
|
|
40
|
+
bot: [
|
|
41
|
+
{
|
|
42
|
+
fullName: "Empty Bot",
|
|
43
|
+
identifier: "empty",
|
|
44
|
+
defaultProjectName: "empty-bot",
|
|
45
|
+
absolutePath: _dirNameToAbsPath("empty-bot")
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
plugin: [
|
|
49
|
+
{
|
|
50
|
+
fullName: "Empty Plugin",
|
|
51
|
+
identifier: "empty",
|
|
52
|
+
defaultProjectName: "empty-plugin",
|
|
53
|
+
absolutePath: _dirNameToAbsPath("empty-plugin")
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
integration: [
|
|
57
|
+
{
|
|
58
|
+
fullName: "Empty Integration",
|
|
59
|
+
identifier: "empty",
|
|
60
|
+
defaultProjectName: "empty-integration",
|
|
61
|
+
absolutePath: _dirNameToAbsPath("empty-integration")
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
fullName: "Hello World",
|
|
65
|
+
identifier: "hello-world",
|
|
66
|
+
defaultProjectName: "hello-world",
|
|
67
|
+
absolutePath: _dirNameToAbsPath("hello-world")
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
fullName: "Webhook Message",
|
|
71
|
+
identifier: "webhook-message",
|
|
72
|
+
defaultProjectName: "webhook-message",
|
|
73
|
+
absolutePath: _dirNameToAbsPath("webhook-message")
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
ProjectTemplates2.getAllChoices = () => [...new Set(Object.values(ProjectTemplates2.templates).flatMap((t) => t.map((tt) => tt.identifier)))];
|
|
78
|
+
})(ProjectTemplates || (ProjectTemplates = {}));
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
ProjectTemplates
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=project-templates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/project-templates.ts"],
|
|
4
|
+
"sourcesContent": ["import * as consts from './consts'\nimport * as utils from './utils'\n\nexport namespace ProjectTemplates {\n export type Template = Readonly<{\n fullName: string\n identifier: string\n defaultProjectName: string\n absolutePath: utils.path.AbsolutePath\n }>\n export type TemplateArray = Readonly<[Template, ...Template[]]>\n export type ProjectType = 'bot' | 'plugin' | 'integration'\n\n const _dirNameToAbsPath = (directoryName: string) => utils.path.join(consts.cliRootDir, 'templates', directoryName)\n\n export const templates = {\n bot: [\n {\n fullName: 'Empty Bot',\n identifier: 'empty',\n defaultProjectName: 'empty-bot',\n absolutePath: _dirNameToAbsPath('empty-bot'),\n },\n ],\n plugin: [\n {\n fullName: 'Empty Plugin',\n identifier: 'empty',\n defaultProjectName: 'empty-plugin',\n absolutePath: _dirNameToAbsPath('empty-plugin'),\n },\n ],\n integration: [\n {\n fullName: 'Empty Integration',\n identifier: 'empty',\n defaultProjectName: 'empty-integration',\n absolutePath: _dirNameToAbsPath('empty-integration'),\n },\n {\n fullName: 'Hello World',\n identifier: 'hello-world',\n defaultProjectName: 'hello-world',\n absolutePath: _dirNameToAbsPath('hello-world'),\n },\n {\n fullName: 'Webhook Message',\n identifier: 'webhook-message',\n defaultProjectName: 'webhook-message',\n absolutePath: _dirNameToAbsPath('webhook-message'),\n },\n ],\n } as const satisfies { [k in ProjectType]: TemplateArray }\n\n export const getAllChoices = () => [...new Set(Object.values(templates).flatMap((t) => t.map((tt) => tt.identifier)))]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,YAAuB;AAEhB,IAAU;AAAA,CAAV,CAAUA,sBAAV;AAUL,QAAM,oBAAoB,CAAC,kBAA0B,MAAM,KAAK,KAAK,OAAO,YAAY,aAAa,aAAa;AAE3G,EAAMA,kBAAA,YAAY;AAAA,IACvB,KAAK;AAAA,MACH;AAAA,QACE,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,cAAc,kBAAkB,WAAW;AAAA,MAC7C;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,QACE,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,cAAc,kBAAkB,cAAc;AAAA,MAChD;AAAA,IACF;AAAA,IACA,aAAa;AAAA,MACX;AAAA,QACE,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,cAAc,kBAAkB,mBAAmB;AAAA,MACrD;AAAA,MACA;AAAA,QACE,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,cAAc,kBAAkB,aAAa;AAAA,MAC/C;AAAA,MACA;AAAA,QACE,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,oBAAoB;AAAA,QACpB,cAAc,kBAAkB,iBAAiB;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AAEO,EAAMA,kBAAA,gBAAgB,MAAM,CAAC,GAAG,IAAI,IAAI,OAAO,OAAOA,kBAAA,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC;AAAA,GAnDtG;",
|
|
6
|
+
"names": ["ProjectTemplates"]
|
|
7
|
+
}
|
|
@@ -71,14 +71,16 @@ class CLIPrompt {
|
|
|
71
71
|
this._logger.debug(`Return default (non-interactive mode): ${message}`);
|
|
72
72
|
return opts?.default;
|
|
73
73
|
}
|
|
74
|
+
const isNumber = typeof opts?.choices?.[0]?.value === "number";
|
|
75
|
+
const transformedChoices = isNumber ? opts?.choices?.map((c) => ({ ...c, value: c.value === 0 ? Symbol.for("0") : c.value })) : opts?.choices;
|
|
74
76
|
const { prompted } = await this._prompts({
|
|
75
77
|
type: "autocomplete",
|
|
76
78
|
name: "prompted",
|
|
77
79
|
message,
|
|
78
80
|
initial: opts?.initial?.value,
|
|
79
|
-
choices:
|
|
81
|
+
choices: transformedChoices
|
|
80
82
|
});
|
|
81
|
-
return prompted ? prompted : void 0;
|
|
83
|
+
return prompted !== void 0 ? isNumber && prompted === Symbol.for("0") ? 0 : prompted : void 0;
|
|
82
84
|
}
|
|
83
85
|
async text(message, opts = {}) {
|
|
84
86
|
if (this._props.confirm) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/prompt-utils.ts"],
|
|
4
|
-
"sourcesContent": ["import prompts from 'prompts'\nimport type { Logger } from '../logger'\n\nexport type CLIPromptsProps = {\n confirm: boolean\n}\n\nexport type CLIPromptsChoice<V extends
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;
|
|
4
|
+
"sourcesContent": ["import prompts from 'prompts'\nimport type { Logger } from '../logger'\n\nexport type CLIPromptsProps = {\n confirm: boolean\n}\n\ntype ChoiceValueType = string | number\n\nexport type CLIPromptsChoice<V extends ChoiceValueType> = {\n title: string\n value: V\n}\n\ntype PasswordOptions = Partial<{\n default: string | undefined\n initial: string\n}>\ntype SelectOptions<V extends ChoiceValueType> = Partial<{\n default: V | undefined\n initial: CLIPromptsChoice<V>\n choices: CLIPromptsChoice<V>[]\n}>\ntype TextOptions = Partial<{\n default: string | undefined\n initial: string\n}>\n\nexport class CLIPrompt {\n public constructor(\n private _props: CLIPromptsProps,\n private _logger: Logger\n ) {}\n\n public async confirm(message: string): Promise<boolean> {\n if (this._props.confirm) {\n this._logger.debug(`Confirming automatically (non-interactive mode): ${message}`)\n return true\n }\n\n const { confirm } = await this._prompts({\n type: 'confirm',\n name: 'confirm',\n message,\n initial: false,\n })\n\n if (!confirm) {\n return false\n }\n return true\n }\n\n public async password(message: string, opts: PasswordOptions = {}): Promise<string | undefined> {\n if (this._props.confirm) {\n this._logger.debug(`Return default (non-interactive mode): ${message}`)\n return opts?.default\n }\n\n const { prompted } = await this._prompts({\n type: 'password',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n public async select<V extends ChoiceValueType = string>(\n message: string,\n opts: SelectOptions<V> = {}\n ): Promise<V | undefined> {\n if (this._props.confirm) {\n this._logger.debug(`Return default (non-interactive mode): ${message}`)\n return opts?.default\n }\n\n // NOTE: whilst Prompts supports string, number, date and boolean values for\n // choices, it behaves unexpectedly when the value is a number and is\n // equal to 0. To work around this, we convert the value to a symbol\n // if it is 0, and then convert it back to a number if it was 0.\n\n const isNumber = typeof opts?.choices?.[0]?.value === 'number'\n const transformedChoices = isNumber\n ? opts?.choices?.map((c) => ({ ...c, value: c.value === 0 ? Symbol.for('0') : c.value }))\n : opts?.choices\n\n const { prompted } = await this._prompts({\n type: 'autocomplete',\n name: 'prompted',\n message,\n initial: opts?.initial?.value,\n choices: transformedChoices as prompts.PromptObject['choices'],\n })\n\n return prompted !== undefined ? (isNumber && prompted === Symbol.for('0') ? 0 : prompted) : undefined\n }\n\n public async text(message: string, opts: TextOptions = {}): Promise<string | undefined> {\n if (this._props.confirm) {\n this._logger.debug(`Return default (non-interactive mode): ${message}`)\n return opts?.default\n }\n\n const { prompted } = await this._prompts({\n type: 'text',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n private _prompts = (...args: Parameters<typeof prompts>): ReturnType<typeof prompts> => {\n this._logger.cleanup()\n return prompts(...args)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AA4Bb,MAAM,UAAU;AAAA,EACd,YACG,QACA,SACR;AAFQ;AACA;AAAA,EACP;AAAA,EAEH,MAAa,QAAQ,SAAmC;AACtD,QAAI,KAAK,OAAO,SAAS;AACvB,WAAK,QAAQ,MAAM,oDAAoD,SAAS;AAChF,aAAO;AAAA,IACT;AAEA,UAAM,EAAE,QAAQ,IAAI,MAAM,KAAK,SAAS;AAAA,MACtC,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,SAAS;AAAA,IACX,CAAC;AAED,QAAI,CAAC,SAAS;AACZ,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAa,SAAS,SAAiB,OAAwB,CAAC,GAAgC;AAC9F,QAAI,KAAK,OAAO,SAAS;AACvB,WAAK,QAAQ,MAAM,0CAA0C,SAAS;AACtE,aAAO,MAAM;AAAA,IACf;AAEA,UAAM,EAAE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json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run bundle && pnpm run template:gen",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@apidevtools/json-schema-ref-parser": "^11.7.0",
|
|
23
23
|
"@botpress/chat": "0.5.1",
|
|
24
24
|
"@botpress/client": "0.47.0",
|
|
25
|
-
"@botpress/sdk": "3.
|
|
25
|
+
"@botpress/sdk": "3.4.0",
|
|
26
26
|
"@bpinternal/const": "^0.1.0",
|
|
27
27
|
"@bpinternal/tunnel": "^0.1.1",
|
|
28
28
|
"@bpinternal/yargs-extra": "^0.0.3",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"bluebird": "^3.7.2",
|
|
37
37
|
"boxen": "5.1.2",
|
|
38
38
|
"chalk": "^4.1.2",
|
|
39
|
-
"chokidar": "^3.5.3",
|
|
40
39
|
"dotenv": "^16.4.4",
|
|
41
40
|
"esbuild": "^0.16.12",
|
|
42
41
|
"handlebars": "^4.7.8",
|
|
@@ -44,11 +43,9 @@
|
|
|
44
43
|
"lodash": "^4.17.21",
|
|
45
44
|
"prettier": "^3.4.2",
|
|
46
45
|
"prompts": "^2.4.2",
|
|
47
|
-
"radash": "^9.5.0",
|
|
48
46
|
"semver": "^7.3.8",
|
|
49
47
|
"uuid": "^9.0.0",
|
|
50
48
|
"verror": "^1.10.1",
|
|
51
|
-
"winston": "^3.8.2",
|
|
52
49
|
"yn": "^4.0.0"
|
|
53
50
|
},
|
|
54
51
|
"devDependencies": {
|