@botpress/cli 1.7.3 → 2.0.1
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 -9
- package/dist/api/bot-body.js +20 -6
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/client.js +18 -0
- package/dist/api/client.js.map +2 -2
- package/dist/api/interface-body.js.map +2 -2
- package/dist/api/plugin-body.js +79 -0
- package/dist/api/plugin-body.js.map +7 -0
- package/dist/api/types.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-implementation.js +40 -21
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-plugins/index.js +76 -0
- package/dist/code-generation/bot-implementation/bot-plugins/index.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +125 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/index.js +27 -22
- package/dist/code-generation/bot-implementation/index.js.map +2 -2
- package/dist/code-generation/consts.js +3 -0
- package/dist/code-generation/consts.js.map +2 -2
- package/dist/code-generation/generators.js +8 -0
- package/dist/code-generation/generators.js.map +2 -2
- package/dist/code-generation/index.js +6 -0
- package/dist/code-generation/index.js.map +2 -2
- package/dist/code-generation/integration-package/index.js +11 -2
- package/dist/code-generation/integration-package/index.js.map +2 -2
- package/dist/code-generation/interface-implementation/index.js +29 -0
- package/dist/code-generation/interface-implementation/index.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js +84 -0
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js +103 -0
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js +59 -0
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js +59 -0
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/index.js +117 -0
- package/dist/code-generation/interface-implementation/integration-typings/index.js.map +7 -0
- package/dist/code-generation/interface-package/index.js +11 -2
- package/dist/code-generation/interface-package/index.js.map +2 -2
- package/dist/code-generation/module.js +17 -4
- package/dist/code-generation/module.js.map +2 -2
- package/dist/code-generation/plugin-implementation/index.js +56 -0
- package/dist/code-generation/plugin-implementation/index.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js +86 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js +84 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js +57 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js +59 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js +146 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js +60 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js.map +7 -0
- package/dist/code-generation/plugin-package/index.js +146 -0
- package/dist/code-generation/plugin-package/index.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js +84 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js +52 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js +62 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js +103 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js +62 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js +17 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js.map +7 -0
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-definitions.js +8 -0
- package/dist/command-definitions.js.map +2 -2
- package/dist/command-implementations/add-command.js +47 -10
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/bundle-command.js +7 -2
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +51 -0
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/gen-command.js +11 -0
- package/dist/command-implementations/gen-command.js.map +2 -2
- package/dist/command-implementations/index.js +8 -0
- package/dist/command-implementations/index.js.map +2 -2
- package/dist/command-implementations/init-command.js +36 -8
- package/dist/command-implementations/init-command.js.map +2 -2
- package/dist/command-implementations/lint-command.js +1 -1
- package/dist/command-implementations/lint-command.js.map +2 -2
- package/dist/command-implementations/plugin-commands.js +107 -0
- package/dist/command-implementations/plugin-commands.js.map +7 -0
- package/dist/command-implementations/project-command.js +30 -3
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/command-implementations/read-command.js +13 -1
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/config.js +23 -2
- package/dist/config.js.map +2 -2
- package/dist/consts.js +7 -0
- package/dist/consts.js.map +2 -2
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/index.js.map +2 -2
- package/dist/sdk/resolve-bot-interfaces.js +6 -1
- package/dist/sdk/resolve-bot-interfaces.js.map +2 -2
- package/dist/sdk/resolve-integration-interfaces.js +16 -8
- package/dist/sdk/resolve-integration-interfaces.js.map +2 -2
- package/dist/sdk/validate-bot.js +84 -0
- package/dist/sdk/validate-bot.js.map +7 -0
- package/dist/utils/esbuild-utils.js +3 -2
- package/dist/utils/esbuild-utils.js.map +2 -2
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/object-utils.js +32 -0
- package/dist/utils/object-utils.js.map +7 -0
- package/dist/utils/schema-utils.js.map +2 -2
- package/dist/utils/type-utils.js.map +1 -1
- package/e2e/tests/install-package.ts +1 -1
- package/package.json +3 -3
- package/templates/empty-bot/.botpress/implementation/index.ts +27 -18
- package/templates/empty-bot/.botpress/implementation/plugins/index.ts +11 -0
- package/templates/empty-bot/.botpress/index.ts +5 -1
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/.botpress/implementation/index.ts +35 -0
- package/templates/empty-plugin/.botpress/implementation/typings/actions/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/empty-plugin/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/index.ts +26 -0
- package/templates/empty-plugin/.botpress/implementation/typings/integrations/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/interfaces/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/empty-plugin/.botpress/index.ts +1 -0
- package/templates/empty-plugin/package.json +16 -0
- package/templates/empty-plugin/plugin.definition.ts +7 -0
- package/templates/empty-plugin/src/index.ts +7 -0
- package/templates/empty-plugin/tsconfig.json +28 -0
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
|
@@ -56,6 +56,14 @@ var command_definitions_default = {
|
|
|
56
56
|
list: { description: "List interfaces", schema: config.schemas.listInterfaces, alias: "ls" }
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
+
plugins: {
|
|
60
|
+
description: "Plugin related commands",
|
|
61
|
+
subcommands: {
|
|
62
|
+
get: { description: "Get plugin", schema: config.schemas.getPlugin },
|
|
63
|
+
delete: { description: "Delete plugin", schema: config.schemas.deletePlugin, alias: "rm" },
|
|
64
|
+
list: { description: "List plugins", schema: config.schemas.listPlugins, alias: "ls" }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
59
67
|
init: { description: "Initialize a new project", schema: config.schemas.init },
|
|
60
68
|
generate: { description: "Generate typings for intellisense", schema: config.schemas.generate, alias: "gen" },
|
|
61
69
|
bundle: { description: "Bundle a botpress project", schema: config.schemas.bundle },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/command-definitions.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DefinitionTree } from './command-tree'\nimport * as config from './config'\n\nexport default {\n login: { description: 'Login to Botpress Cloud', schema: config.schemas.login },\n logout: { description: 'Logout of Botpress Cloud', schema: config.schemas.logout },\n bots: {\n description: 'Bot related commands',\n subcommands: {\n create: { description: 'Create new bot', schema: config.schemas.createBot, alias: 'new' },\n get: { description: 'Get bot', schema: config.schemas.getBot },\n delete: { description: 'Delete bot', schema: config.schemas.deleteBot, alias: 'rm' },\n list: { description: 'List bots', schema: config.schemas.listBots, alias: 'ls' },\n },\n },\n integrations: {\n description: 'Integration related commands',\n subcommands: {\n get: { description: 'Get integration', schema: config.schemas.getIntegration },\n delete: { description: 'Delete integration', schema: config.schemas.deleteIntegration, alias: 'rm' },\n list: { description: 'List integrations', schema: config.schemas.listIntegrations, alias: 'ls' },\n },\n },\n interfaces: {\n description: 'Interface related commands',\n subcommands: {\n get: { description: 'Get interface', schema: config.schemas.getInterface },\n delete: { description: 'Delete interface', schema: config.schemas.deleteInterface, alias: 'rm' },\n list: { description: 'List interfaces', schema: config.schemas.listInterfaces, alias: 'ls' },\n },\n },\n init: { description: 'Initialize a new project', schema: config.schemas.init },\n generate: { description: 'Generate typings for intellisense', schema: config.schemas.generate, alias: 'gen' },\n bundle: { description: 'Bundle a botpress project', schema: config.schemas.bundle },\n build: { description: 'Generate typings and bundle a botpress project', schema: config.schemas.build },\n read: { description: 'Read and parse an integration definition', schema: config.schemas.read },\n serve: { description: 'Serve your project locally', schema: config.schemas.serve },\n deploy: { description: 'Deploy your project to the cloud', schema: config.schemas.deploy },\n add: { description: 'Install a package; could be an integration or an interface', schema: config.schemas.add },\n dev: { description: 'Run your project in dev mode', schema: config.schemas.dev },\n lint: { description: 'EXPERIMENTAL: Lint an integration definition', schema: config.schemas.lint },\n} satisfies DefinitionTree\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,IAAO,8BAAQ;AAAA,EACb,OAAO,EAAE,aAAa,2BAA2B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EAC9E,QAAQ,EAAE,aAAa,4BAA4B,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACjF,MAAM;AAAA,IACJ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,QAAQ,EAAE,aAAa,kBAAkB,QAAQ,OAAO,QAAQ,WAAW,OAAO,MAAM;AAAA,MACxF,KAAK,EAAE,aAAa,WAAW,QAAQ,OAAO,QAAQ,OAAO;AAAA,MAC7D,QAAQ,EAAE,aAAa,cAAc,QAAQ,OAAO,QAAQ,WAAW,OAAO,KAAK;AAAA,MACnF,MAAM,EAAE,aAAa,aAAa,QAAQ,OAAO,QAAQ,UAAU,OAAO,KAAK;AAAA,IACjF;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,KAAK,EAAE,aAAa,mBAAmB,QAAQ,OAAO,QAAQ,eAAe;AAAA,MAC7E,QAAQ,EAAE,aAAa,sBAAsB,QAAQ,OAAO,QAAQ,mBAAmB,OAAO,KAAK;AAAA,MACnG,MAAM,EAAE,aAAa,qBAAqB,QAAQ,OAAO,QAAQ,kBAAkB,OAAO,KAAK;AAAA,IACjG;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,aAAa;AAAA,IACb,aAAa;AAAA,MACX,KAAK,EAAE,aAAa,iBAAiB,QAAQ,OAAO,QAAQ,aAAa;AAAA,MACzE,QAAQ,EAAE,aAAa,oBAAoB,QAAQ,OAAO,QAAQ,iBAAiB,OAAO,KAAK;AAAA,MAC/F,MAAM,EAAE,aAAa,mBAAmB,QAAQ,OAAO,QAAQ,gBAAgB,OAAO,KAAK;AAAA,IAC7F;AAAA,EACF;AAAA,EACA,MAAM,EAAE,aAAa,4BAA4B,QAAQ,OAAO,QAAQ,KAAK;AAAA,EAC7E,UAAU,EAAE,aAAa,qCAAqC,QAAQ,OAAO,QAAQ,UAAU,OAAO,MAAM;AAAA,EAC5G,QAAQ,EAAE,aAAa,6BAA6B,QAAQ,OAAO,QAAQ,OAAO;AAAA,EAClF,OAAO,EAAE,aAAa,kDAAkD,QAAQ,OAAO,QAAQ,MAAM;AAAA,EACrG,MAAM,EAAE,aAAa,4CAA4C,QAAQ,OAAO,QAAQ,KAAK;AAAA,EAC7F,OAAO,EAAE,aAAa,8BAA8B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EACjF,QAAQ,EAAE,aAAa,oCAAoC,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACzF,KAAK,EAAE,aAAa,8DAA8D,QAAQ,OAAO,QAAQ,IAAI;AAAA,EAC7G,KAAK,EAAE,aAAa,gCAAgC,QAAQ,OAAO,QAAQ,IAAI;AAAA,EAC/E,MAAM,EAAE,aAAa,gDAAgD,QAAQ,OAAO,QAAQ,KAAK;AACnG;",
|
|
4
|
+
"sourcesContent": ["import type { DefinitionTree } from './command-tree'\nimport * as config from './config'\n\nexport default {\n login: { description: 'Login to Botpress Cloud', schema: config.schemas.login },\n logout: { description: 'Logout of Botpress Cloud', schema: config.schemas.logout },\n bots: {\n description: 'Bot related commands',\n subcommands: {\n create: { description: 'Create new bot', schema: config.schemas.createBot, alias: 'new' },\n get: { description: 'Get bot', schema: config.schemas.getBot },\n delete: { description: 'Delete bot', schema: config.schemas.deleteBot, alias: 'rm' },\n list: { description: 'List bots', schema: config.schemas.listBots, alias: 'ls' },\n },\n },\n integrations: {\n description: 'Integration related commands',\n subcommands: {\n get: { description: 'Get integration', schema: config.schemas.getIntegration },\n delete: { description: 'Delete integration', schema: config.schemas.deleteIntegration, alias: 'rm' },\n list: { description: 'List integrations', schema: config.schemas.listIntegrations, alias: 'ls' },\n },\n },\n interfaces: {\n description: 'Interface related commands',\n subcommands: {\n get: { description: 'Get interface', schema: config.schemas.getInterface },\n delete: { description: 'Delete interface', schema: config.schemas.deleteInterface, alias: 'rm' },\n list: { description: 'List interfaces', schema: config.schemas.listInterfaces, alias: 'ls' },\n },\n },\n plugins: {\n description: 'Plugin related commands',\n subcommands: {\n get: { description: 'Get plugin', schema: config.schemas.getPlugin },\n delete: { description: 'Delete plugin', schema: config.schemas.deletePlugin, alias: 'rm' },\n list: { description: 'List plugins', schema: config.schemas.listPlugins, alias: 'ls' },\n },\n },\n init: { description: 'Initialize a new project', schema: config.schemas.init },\n generate: { description: 'Generate typings for intellisense', schema: config.schemas.generate, alias: 'gen' },\n bundle: { description: 'Bundle a botpress project', schema: config.schemas.bundle },\n build: { description: 'Generate typings and bundle a botpress project', schema: config.schemas.build },\n read: { description: 'Read and parse an integration definition', schema: config.schemas.read },\n serve: { description: 'Serve your project locally', schema: config.schemas.serve },\n deploy: { description: 'Deploy your project to the cloud', schema: config.schemas.deploy },\n add: { description: 'Install a package; could be an integration or an interface', schema: config.schemas.add },\n dev: { description: 'Run your project in dev mode', schema: config.schemas.dev },\n lint: { description: 'EXPERIMENTAL: Lint an integration definition', schema: config.schemas.lint },\n} satisfies DefinitionTree\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,IAAO,8BAAQ;AAAA,EACb,OAAO,EAAE,aAAa,2BAA2B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EAC9E,QAAQ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Aa,gBAAgB,QAAQ,OAAO,QAAQ,aAAa,OAAO,KAAK;AAAA,IACvF;AAAA,EACF;AAAA,EACA,MAAM,EAAE,aAAa,4BAA4B,QAAQ,OAAO,QAAQ,KAAK;AAAA,EAC7E,UAAU,EAAE,aAAa,qCAAqC,QAAQ,OAAO,QAAQ,UAAU,OAAO,MAAM;AAAA,EAC5G,QAAQ,EAAE,aAAa,6BAA6B,QAAQ,OAAO,QAAQ,OAAO;AAAA,EAClF,OAAO,EAAE,aAAa,kDAAkD,QAAQ,OAAO,QAAQ,MAAM;AAAA,EACrG,MAAM,EAAE,aAAa,4CAA4C,QAAQ,OAAO,QAAQ,KAAK;AAAA,EAC7F,OAAO,EAAE,aAAa,8BAA8B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EACjF,QAAQ,EAAE,aAAa,oCAAoC,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACzF,KAAK,EAAE,aAAa,8DAA8D,QAAQ,OAAO,QAAQ,IAAI;AAAA,EAC7G,KAAK,EAAE,aAAa,gCAAgC,QAAQ,OAAO,QAAQ,IAAI;AAAA,EAC/E,MAAM,EAAE,aAAa,gDAAgD,QAAQ,OAAO,QAAQ,KAAK;AACnG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -48,7 +48,7 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
48
48
|
const notFoundMessage = this.argv.packageType ? `Could not find package "${this.argv.packageRef}" of type "${this.argv.packageType}"` : `Could not find package "${this.argv.packageRef}"`;
|
|
49
49
|
throw new errors.BotpressCLIError(notFoundMessage);
|
|
50
50
|
}
|
|
51
|
-
const packageName = targetPackage.name;
|
|
51
|
+
const packageName = targetPackage.pkg.name;
|
|
52
52
|
const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath);
|
|
53
53
|
const packageDirName = utils.casing.to.kebabCase(packageName);
|
|
54
54
|
const installPath = utils.path.join(baseInstallPath, consts.installDirName, packageDirName);
|
|
@@ -65,8 +65,12 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
65
65
|
let files;
|
|
66
66
|
if (targetPackage.type === "integration") {
|
|
67
67
|
files = await codegen.generateIntegrationPackage(targetPackage.pkg);
|
|
68
|
-
} else {
|
|
68
|
+
} else if (targetPackage.type === "interface") {
|
|
69
69
|
files = await codegen.generateInterfacePackage(targetPackage.pkg);
|
|
70
|
+
} else if (targetPackage.type === "plugin") {
|
|
71
|
+
files = await codegen.generatePluginPackage(targetPackage.pkg);
|
|
72
|
+
} else {
|
|
73
|
+
throw new errors.BotpressCLIError("Invalid package type");
|
|
70
74
|
}
|
|
71
75
|
await this._install(installPath, files);
|
|
72
76
|
}
|
|
@@ -75,32 +79,59 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
75
79
|
if (this._pkgCouldBe("integration")) {
|
|
76
80
|
const integration = await api.findIntegration(ref);
|
|
77
81
|
if (integration) {
|
|
78
|
-
|
|
82
|
+
const { name, version } = integration;
|
|
83
|
+
return { type: "integration", pkg: { source: "remote", integration, name, version } };
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
if (this._pkgCouldBe("interface")) {
|
|
82
87
|
const intrface = await api.findPublicInterface(ref);
|
|
83
88
|
if (intrface) {
|
|
84
|
-
|
|
89
|
+
const { name, version } = intrface;
|
|
90
|
+
return { type: "interface", pkg: { source: "remote", interface: intrface, name, version } };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (this._pkgCouldBe("plugin")) {
|
|
94
|
+
const plugin = await api.findPublicPlugin(ref);
|
|
95
|
+
if (plugin) {
|
|
96
|
+
const { name, version } = plugin;
|
|
97
|
+
return { type: "plugin", pkg: { source: "remote", plugin, name, version } };
|
|
85
98
|
}
|
|
86
99
|
}
|
|
87
100
|
return;
|
|
88
101
|
}
|
|
89
102
|
async _findLocalPackage(ref) {
|
|
90
103
|
const absPath = utils.path.absoluteFrom(utils.path.cwd(), ref.path);
|
|
91
|
-
const projectDefinition = await this._readProject(absPath);
|
|
104
|
+
const { definition: projectDefinition, implementation: projectImplementation } = await this._readProject(absPath);
|
|
92
105
|
if (this._pkgCouldBe("integration") && projectDefinition?.type === "integration") {
|
|
106
|
+
const { name, version } = projectDefinition.definition;
|
|
93
107
|
return {
|
|
94
108
|
type: "integration",
|
|
95
|
-
|
|
96
|
-
pkg: { source: "local", path: absPath }
|
|
109
|
+
pkg: { source: "local", path: absPath, name, version }
|
|
97
110
|
};
|
|
98
111
|
}
|
|
99
112
|
if (this._pkgCouldBe("interface") && projectDefinition?.type === "interface") {
|
|
113
|
+
const { name, version } = projectDefinition.definition;
|
|
100
114
|
return {
|
|
101
115
|
type: "interface",
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
pkg: { source: "local", path: absPath, name, version }
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (this._pkgCouldBe("plugin") && projectDefinition?.type === "plugin") {
|
|
120
|
+
if (!projectImplementation) {
|
|
121
|
+
throw new errors.BotpressCLIError(
|
|
122
|
+
"Plugin implementation not found; Please build the plugin project before installing"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const { name, version } = projectDefinition.definition;
|
|
126
|
+
return {
|
|
127
|
+
type: "plugin",
|
|
128
|
+
pkg: {
|
|
129
|
+
source: "local",
|
|
130
|
+
path: absPath,
|
|
131
|
+
implementationCode: projectImplementation,
|
|
132
|
+
name,
|
|
133
|
+
version
|
|
134
|
+
}
|
|
104
135
|
};
|
|
105
136
|
}
|
|
106
137
|
if (projectDefinition?.type === "bot") {
|
|
@@ -139,12 +170,18 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
139
170
|
...this.argv,
|
|
140
171
|
workDir
|
|
141
172
|
});
|
|
142
|
-
|
|
173
|
+
const definition = await cmd.readProjectDefinitionFromFS().catch((thrown) => {
|
|
143
174
|
if (thrown instanceof errors.ProjectDefinitionNotFoundError) {
|
|
144
175
|
return void 0;
|
|
145
176
|
}
|
|
146
177
|
throw thrown;
|
|
147
178
|
});
|
|
179
|
+
const implementationAbsPath = utils.path.join(workDir, consts.fromWorkDir.outFile);
|
|
180
|
+
if (!fslib.existsSync(implementationAbsPath)) {
|
|
181
|
+
return { definition };
|
|
182
|
+
}
|
|
183
|
+
const implementation = await fslib.promises.readFile(implementationAbsPath, "utf8");
|
|
184
|
+
return { definition, implementation };
|
|
148
185
|
}
|
|
149
186
|
_pkgCouldBe = (pkgType) => {
|
|
150
187
|
if (!this.argv.packageType) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/add-command.ts"],
|
|
4
|
-
"sourcesContent": ["import * as fslib from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from '../api'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as pkgRef from '../package-ref'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\nimport { ProjectCommand, ProjectCommandDefinition, ProjectDefinition } from './project-command'\n\ntype InstallablePackage =\n | {\n type: 'integration'\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,cAAyB;AACzB,iBAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAC9B,6BAA4E;
|
|
4
|
+
"sourcesContent": ["import * as fslib from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from '../api'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as pkgRef from '../package-ref'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\nimport { ProjectCommand, ProjectCommandDefinition, ProjectDefinition } from './project-command'\n\ntype InstallablePackage =\n | {\n type: 'integration'\n pkg: codegen.IntegrationInstallablePackage\n }\n | {\n type: 'interface'\n pkg: codegen.InterfaceInstallablePackage\n }\n | {\n type: 'plugin'\n pkg: codegen.PluginInstallablePackage\n }\n\nexport type AddCommandDefinition = typeof commandDefinitions.add\nexport class AddCommand extends GlobalCommand<AddCommandDefinition> {\n public async run(): Promise<void> {\n const parsedRef = pkgRef.parsePackageRef(this.argv.packageRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.packageRef)\n }\n\n const targetPackage =\n parsedRef.type === 'path' ? await this._findLocalPackage(parsedRef) : await this._findRemotePackage(parsedRef)\n\n if (!targetPackage) {\n const notFoundMessage = this.argv.packageType\n ? `Could not find package \"${this.argv.packageRef}\" of type \"${this.argv.packageType}\"`\n : `Could not find package \"${this.argv.packageRef}\"`\n throw new errors.BotpressCLIError(notFoundMessage)\n }\n\n const packageName = targetPackage.pkg.name // TODO: eventually replace name by alias (with argv --alias)\n const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath)\n const packageDirName = utils.casing.to.kebabCase(packageName)\n const installPath = utils.path.join(baseInstallPath, consts.installDirName, packageDirName)\n\n const alreadyInstalled = fslib.existsSync(installPath)\n if (alreadyInstalled) {\n this.logger.warn(`Package with name \"${packageName}\" already installed.`)\n const res = await this.prompt.confirm('Do you want to overwrite the existing package?')\n if (!res) {\n this.logger.log('Aborted')\n return\n }\n\n await this._uninstall(installPath)\n }\n\n let files: codegen.File[]\n if (targetPackage.type === 'integration') {\n files = await codegen.generateIntegrationPackage(targetPackage.pkg)\n } else if (targetPackage.type === 'interface') {\n files = await codegen.generateInterfacePackage(targetPackage.pkg)\n } else if (targetPackage.type === 'plugin') {\n files = await codegen.generatePluginPackage(targetPackage.pkg)\n } else {\n type _assertion = utils.types.AssertNever<typeof targetPackage>\n throw new errors.BotpressCLIError('Invalid package type')\n }\n\n await this._install(installPath, files)\n }\n\n private async _findRemotePackage(ref: pkgRef.ApiPackageRef): Promise<InstallablePackage | undefined> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n if (this._pkgCouldBe('integration')) {\n const integration = await api.findIntegration(ref)\n if (integration) {\n const { name, version } = integration\n return { type: 'integration', pkg: { source: 'remote', integration, name, version } }\n }\n }\n if (this._pkgCouldBe('interface')) {\n const intrface = await api.findPublicInterface(ref)\n if (intrface) {\n const { name, version } = intrface\n return { type: 'interface', pkg: { source: 'remote', interface: intrface, name, version } }\n }\n }\n if (this._pkgCouldBe('plugin')) {\n const plugin = await api.findPublicPlugin(ref)\n if (plugin) {\n const { name, version } = plugin\n return { type: 'plugin', pkg: { source: 'remote', plugin, name, version } }\n }\n }\n return\n }\n\n private async _findLocalPackage(ref: pkgRef.LocalPackageRef): Promise<InstallablePackage | undefined> {\n const absPath = utils.path.absoluteFrom(utils.path.cwd(), ref.path)\n const { definition: projectDefinition, implementation: projectImplementation } = await this._readProject(absPath)\n if (this._pkgCouldBe('integration') && projectDefinition?.type === 'integration') {\n const { name, version } = projectDefinition.definition\n return {\n type: 'integration',\n pkg: { source: 'local', path: absPath, name, version },\n }\n }\n\n if (this._pkgCouldBe('interface') && projectDefinition?.type === 'interface') {\n const { name, version } = projectDefinition.definition\n return {\n type: 'interface',\n pkg: { source: 'local', path: absPath, name, version },\n }\n }\n\n if (this._pkgCouldBe('plugin') && projectDefinition?.type === 'plugin') {\n if (!projectImplementation) {\n throw new errors.BotpressCLIError(\n 'Plugin implementation not found; Please build the plugin project before installing'\n )\n }\n\n const { name, version } = projectDefinition.definition\n return {\n type: 'plugin',\n pkg: {\n source: 'local',\n path: absPath,\n implementationCode: projectImplementation,\n name,\n version,\n },\n }\n }\n\n if (projectDefinition?.type === 'bot') {\n throw new errors.BotpressCLIError('Cannot install a bot as a package')\n }\n return\n }\n\n private async _install(installPath: utils.path.AbsolutePath, files: codegen.File[]): Promise<void> {\n const line = this.logger.line()\n line.started(`Installing ${files.length} files to \"${installPath}\"`)\n try {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(installPath, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fslib.promises.mkdir(dirPath, { recursive: true })\n await fslib.promises.writeFile(filePath, file.content)\n }\n line.success(`Installed ${files.length} files to \"${installPath}\"`)\n } finally {\n line.commit()\n }\n }\n\n private async _uninstall(installPath: utils.path.AbsolutePath): Promise<void> {\n await fslib.promises.rm(installPath, { recursive: true })\n }\n\n private async _readProject(workDir: utils.path.AbsolutePath): Promise<{\n definition?: ProjectDefinition\n implementation?: string\n }> {\n // this is a hack to avoid refactoring the project command class\n class AnyProjectCommand extends ProjectCommand<ProjectCommandDefinition> {\n public async run(): Promise<void> {\n throw new errors.BotpressCLIError('Not implemented')\n }\n\n public async readProjectDefinitionFromFS(): Promise<ProjectDefinition> {\n return super.readProjectDefinitionFromFS()\n }\n }\n\n const cmd = new AnyProjectCommand(ApiClient, this.prompt, this.logger, {\n ...this.argv,\n workDir,\n })\n\n const definition = await cmd.readProjectDefinitionFromFS().catch((thrown) => {\n if (thrown instanceof errors.ProjectDefinitionNotFoundError) {\n return undefined\n }\n throw thrown\n })\n\n const implementationAbsPath = utils.path.join(workDir, consts.fromWorkDir.outFile)\n if (!fslib.existsSync(implementationAbsPath)) {\n return { definition }\n }\n\n const implementation = await fslib.promises.readFile(implementationAbsPath, 'utf8')\n return { definition, implementation }\n }\n\n private _pkgCouldBe = (pkgType: InstallablePackage['type']) => {\n if (!this.argv.packageType) {\n return true\n }\n return this.argv.packageType === pkgType\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,cAAyB;AACzB,iBAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAC9B,6BAA4E;AAiBrE,MAAM,mBAAmB,oCAAoC;AAAA,EAClE,MAAa,MAAqB;AAChC,UAAM,YAAY,OAAO,gBAAgB,KAAK,KAAK,UAAU;AAC7D,QAAI,CAAC,WA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AAA,EAEA,MAAc,aAAa,SAGxB;AAED,UAAM,0BAA0B,sCAAyC;AAAA,MACvE,MAAa,MAAqB;AAChC,cAAM,IAAI,OAAO,iBAAiB,iBAAiB;AAAA,MACrD;AAAA,MAEA,MAAa,8BAA0D;AACrE,eAAO,MAAM,4BAA4B;AAAA,MAC3C;AAAA,IACF;AAEA,UAAM,MAAM,IAAI,kBAAkB,sBAAW,KAAK,QAAQ,KAAK,QAAQ;AAAA,MACrE,GAAG,KAAK;AAAA,MACR;AAAA,IACF,CAAC;AAED,UAAM,aAAa,MAAM,IAAI,4BAA4B,EAAE,MAAM,CAAC,WAAW;AAC3E,UAAI,kBAAkB,OAAO,gCAAgC;AAC3D,eAAO;AAAA,MACT;AACA,YAAM;AAAA,IACR,CAAC;AAED,UAAM,wBAAwB,MAAM,KAAK,KAAK,SAAS,OAAO,YAAY,OAAO;AACjF,QAAI,CAAC,MAAM,WAAW,qBAAqB,GAAG;AAC5C,aAAO,EAAE,WAAW;AAAA,IACtB;AAEA,UAAM,iBAAiB,MAAM,MAAM,SAAS,SAAS,uBAAuB,MAAM;AAClF,WAAO,EAAE,YAAY,eAAe;AAAA,EACtC;AAAA,EAEQ,cAAc,CAAC,YAAwC;AAC7D,QAAI,CAAC,KAAK,KAAK,aAAa;AAC1B,aAAO;AAAA,IACT;AACA,WAAO,KAAK,KAAK,gBAAgB;AAAA,EACnC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -48,9 +48,13 @@ class BundleCommand extends import_project_command.ProjectCommand {
|
|
|
48
48
|
line.started("Bundling bot...");
|
|
49
49
|
return await this._bundle(line);
|
|
50
50
|
}
|
|
51
|
+
if (projectDef.type === "plugin") {
|
|
52
|
+
line.started("Bundling plugin...");
|
|
53
|
+
return await this._bundle(line);
|
|
54
|
+
}
|
|
51
55
|
throw new errors.UnsupportedProjectType();
|
|
52
56
|
}
|
|
53
|
-
async _bundle(line) {
|
|
57
|
+
async _bundle(line, props = {}) {
|
|
54
58
|
const logLevel = this.argv.verbose ? "info" : "silent";
|
|
55
59
|
const abs = this.projectPaths.abs;
|
|
56
60
|
const rel = this.projectPaths.rel("workDir");
|
|
@@ -66,7 +70,8 @@ class BundleCommand extends import_project_command.ProjectCommand {
|
|
|
66
70
|
logLevel,
|
|
67
71
|
write: true,
|
|
68
72
|
sourcemap: this.argv.sourceMap,
|
|
69
|
-
minify: this.argv.minify
|
|
73
|
+
minify: this.argv.minify,
|
|
74
|
+
...props
|
|
70
75
|
});
|
|
71
76
|
line.success(`Bundle available at ${import_chalk.default.grey(rel.outDir)}`);
|
|
72
77
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/bundle-command.ts"],
|
|
4
|
-
"sourcesContent": ["import chalk from 'chalk'\nimport { SingleLineLogger } from 'src/logger'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type BundleCommandDefinition = typeof commandDefinitions.bundle\nexport class BundleCommand extends ProjectCommand<BundleCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'interface') {\n this.logger.success('Interface projects have no implementation to bundle.')\n return\n }\n\n const line = this.logger.line()\n\n if (projectDef.type === 'integration') {\n const { name } = projectDef.definition\n line.started(`Bundling integration ${chalk.bold(name)}...`)\n return await this._bundle(line)\n }\n\n if (projectDef.type === 'bot') {\n line.started('Bundling bot...')\n return await this._bundle(line)\n }\n\n throw new errors.UnsupportedProjectType()\n }\n\n private async _bundle(line: SingleLineLogger) {\n const logLevel = this.argv.verbose ? 'info' : 'silent'\n const abs = this.projectPaths.abs\n const rel = this.projectPaths.rel('workDir')\n\n const unixPath = utils.path.toUnix(rel.entryPoint)\n const importFrom = utils.path.rmExtension(unixPath)\n const code = `import x from './${importFrom}'; export default x; export const handler = x.handler;`\n\n const outfile = abs.outFile // TODO: ensure dir exists\n line.debug(`Writing bundle to ${outfile}`)\n\n await utils.esbuild.buildCode({\n code,\n cwd: abs.workDir,\n outfile,\n logLevel,\n write: true,\n sourcemap: this.argv.sourceMap,\n minify: this.argv.minify,\n })\n\n line.success(`Bundle available at ${chalk.grey(rel.outDir)}`)\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,QAAI,WAAW,SAAS,aAAa;AACnC,WAAK,OAAO,QAAQ,sDAAsD;AAC1E;AAAA,IACF;AAEA,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,QAAI,WAAW,SAAS,eAAe;AACrC,YAAM,EAAE,KAAK,IAAI,WAAW;AAC5B,WAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,IAAI,MAAM;AAC1D,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,QAAI,WAAW,SAAS,OAAO;AAC7B,WAAK,QAAQ,iBAAiB;AAC9B,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,UAAM,IAAI,OAAO,uBAAuB;AAAA,EAC1C;AAAA,EAEA,MAAc,QAAQ,MAAwB;
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport { SingleLineLogger } from 'src/logger'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type BundleCommandDefinition = typeof commandDefinitions.bundle\nexport class BundleCommand extends ProjectCommand<BundleCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'interface') {\n this.logger.success('Interface projects have no implementation to bundle.')\n return\n }\n\n const line = this.logger.line()\n\n if (projectDef.type === 'integration') {\n const { name } = projectDef.definition\n line.started(`Bundling integration ${chalk.bold(name)}...`)\n return await this._bundle(line)\n }\n\n if (projectDef.type === 'bot') {\n line.started('Bundling bot...')\n return await this._bundle(line)\n }\n\n if (projectDef.type === 'plugin') {\n line.started('Bundling plugin...')\n return await this._bundle(line)\n }\n\n throw new errors.UnsupportedProjectType()\n }\n\n private async _bundle(line: SingleLineLogger, props: Partial<utils.esbuild.BuildCodeProps> = {}) {\n const logLevel = this.argv.verbose ? 'info' : 'silent'\n const abs = this.projectPaths.abs\n const rel = this.projectPaths.rel('workDir')\n\n const unixPath = utils.path.toUnix(rel.entryPoint)\n const importFrom = utils.path.rmExtension(unixPath)\n const code = `import x from './${importFrom}'; export default x; export const handler = x.handler;`\n\n const outfile = abs.outFile // TODO: ensure dir exists\n line.debug(`Writing bundle to ${outfile}`)\n\n await utils.esbuild.buildCode({\n code,\n cwd: abs.workDir,\n outfile,\n logLevel,\n write: true,\n sourcemap: this.argv.sourceMap,\n minify: this.argv.minify,\n ...props,\n })\n\n line.success(`Bundle available at ${chalk.grey(rel.outDir)}`)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,QAAI,WAAW,SAAS,aAAa;AACnC,WAAK,OAAO,QAAQ,sDAAsD;AAC1E;AAAA,IACF;AAEA,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,QAAI,WAAW,SAAS,eAAe;AACrC,YAAM,EAAE,KAAK,IAAI,WAAW;AAC5B,WAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,IAAI,MAAM;AAC1D,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,QAAI,WAAW,SAAS,OAAO;AAC7B,WAAK,QAAQ,iBAAiB;AAC9B,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,QAAI,WAAW,SAAS,UAAU;AAChC,WAAK,QAAQ,oBAAoB;AACjC,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,UAAM,IAAI,OAAO,uBAAuB;AAAA,EAC1C;AAAA,EAEA,MAAc,QAAQ,MAAwB,QAA+C,CAAC,GAAG;AAC/F,UAAM,WAAW,KAAK,KAAK,UAAU,SAAS;AAC9C,UAAM,MAAM,KAAK,aAAa;AAC9B,UAAM,MAAM,KAAK,aAAa,IAAI,SAAS;AAE3C,UAAM,WAAW,MAAM,KAAK,OAAO,IAAI,UAAU;AACjD,UAAM,aAAa,MAAM,KAAK,YAAY,QAAQ;AAClD,UAAM,OAAO,oBAAoB;AAEjC,UAAM,UAAU,IAAI;AACpB,SAAK,MAAM,qBAAqB,SAAS;AAEzC,UAAM,MAAM,QAAQ,UAAU;AAAA,MAC5B;AAAA,MACA,KAAK,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,WAAW,KAAK,KAAK;AAAA,MACrB,QAAQ,KAAK,KAAK;AAAA,MAClB,GAAG;AAAA,IACL,CAAC;AAED,SAAK,QAAQ,uBAAuB,aAAAA,QAAM,KAAK,IAAI,MAAM,GAAG;AAAA,EAC9D;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -34,6 +34,7 @@ var import_semver = __toESM(require("semver"));
|
|
|
34
34
|
var import_bot_body = require("../api/bot-body");
|
|
35
35
|
var import_integration_body = require("../api/integration-body");
|
|
36
36
|
var import_interface_body = require("../api/interface-body");
|
|
37
|
+
var import_plugin_body = require("../api/plugin-body");
|
|
37
38
|
var errors = __toESM(require("../errors"));
|
|
38
39
|
var import_sdk = require("../sdk");
|
|
39
40
|
var utils = __toESM(require("../utils"));
|
|
@@ -52,6 +53,9 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
52
53
|
if (projectDef.type === "interface") {
|
|
53
54
|
return this._deployInterface(api, projectDef.definition);
|
|
54
55
|
}
|
|
56
|
+
if (projectDef.type === "plugin") {
|
|
57
|
+
return this._deployPlugin(api, projectDef.definition);
|
|
58
|
+
}
|
|
55
59
|
if (projectDef.type === "bot") {
|
|
56
60
|
return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot);
|
|
57
61
|
}
|
|
@@ -199,6 +203,53 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
199
203
|
line.success(successMessage);
|
|
200
204
|
}
|
|
201
205
|
}
|
|
206
|
+
async _deployPlugin(api, pluginDef) {
|
|
207
|
+
const outfile = this.projectPaths.abs.outFile;
|
|
208
|
+
const code = await fs.promises.readFile(outfile, "utf-8");
|
|
209
|
+
const { name, version } = pluginDef;
|
|
210
|
+
const plugin = await api.findPublicPlugin({ type: "name", name, version });
|
|
211
|
+
let message;
|
|
212
|
+
if (plugin) {
|
|
213
|
+
this.logger.warn("Plugin already exists. If you decide to deploy, it will override the existing one.");
|
|
214
|
+
message = `Are you sure you want to override plugin ${name} v${version}?`;
|
|
215
|
+
} else {
|
|
216
|
+
message = `Are you sure you want to deploy plugin ${name} v${version}?`;
|
|
217
|
+
}
|
|
218
|
+
const confirm = await this.prompt.confirm(message);
|
|
219
|
+
if (!confirm) {
|
|
220
|
+
this.logger.log("Aborted");
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
this.logger.debug("Preparing plugin request body...");
|
|
224
|
+
const createBody = {
|
|
225
|
+
...await (0, import_plugin_body.prepareCreatePluginBody)(pluginDef),
|
|
226
|
+
code
|
|
227
|
+
};
|
|
228
|
+
const startedMessage = `Deploying plugin ${import_chalk.default.bold(name)} v${version}...`;
|
|
229
|
+
const successMessage = "Plugin deployed";
|
|
230
|
+
if (plugin) {
|
|
231
|
+
const updateBody = (0, import_plugin_body.prepareUpdatePluginBody)(
|
|
232
|
+
{
|
|
233
|
+
id: plugin.id,
|
|
234
|
+
...createBody
|
|
235
|
+
},
|
|
236
|
+
plugin
|
|
237
|
+
);
|
|
238
|
+
const line = this.logger.line();
|
|
239
|
+
line.started(startedMessage);
|
|
240
|
+
await api.client.updatePlugin(updateBody).catch((thrown) => {
|
|
241
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin "${name}"`);
|
|
242
|
+
});
|
|
243
|
+
line.success(successMessage);
|
|
244
|
+
} else {
|
|
245
|
+
const line = this.logger.line();
|
|
246
|
+
line.started(startedMessage);
|
|
247
|
+
await api.client.createPlugin(createBody).catch((thrown) => {
|
|
248
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin "${name}"`);
|
|
249
|
+
});
|
|
250
|
+
line.success(successMessage);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
202
253
|
_allowDeprecatedFeatures(integrationDef, previousVersion) {
|
|
203
254
|
if (this.argv.allowDeprecated) {
|
|
204
255
|
return true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/deploy-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n CreateIntegrationBody,\n prepareUpdateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport { CreateInterfaceBody, prepareCreateInterfaceBody, prepareUpdateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { getImplementationStatements } from '../sdk'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath, identifier } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this.readProjectFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this.readProjectFile(identifier?.fallbackHandlerScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n let createBody: CreateIntegrationBody = await prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this._formatInterfacesImplStatements(api, integrationDef),\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: await this.readIntegrationConfigDefinition(createBody.configuration),\n configurations: await utils.promises.awaitRecord(\n utils.records.mapValues(createBody.configurations ?? {}, this.readIntegrationConfigDefinition.bind(this))\n ),\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: ApiClient, interfaceDeclaration: sdk.InterfaceDeclaration) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody: CreateInterfaceBody = await prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(\n api: ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botDefinition, api)\n const createBotBody = await prepareCreateBotBody(botDefinition)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...createBotBody,\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return integration // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return new sdk.IntegrationDefinition({ ...integration, name: newName })\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return integration\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return new sdk.IntegrationDefinition({ ...integration, name: newName })\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n\n private _formatInterfacesImplStatements = async (\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<CreateIntegrationBody['interfaces']> => {\n const interfacesStatements = getImplementationStatements(integration)\n const interfaces: NonNullable<CreateIntegrationBody['interfaces']> = {}\n for (const [key, i] of Object.entries(interfacesStatements)) {\n const { name, version, entities, actions, events, channels } = i\n const id = await this._getInterfaceId(api, { id: i.id, name, version })\n interfaces[key] = { id, entities, actions, events, channels }\n }\n\n return interfaces\n }\n\n private _getInterfaceId = async (\n api: ApiClient,\n ref: { id?: string; name: string; version: string }\n ): Promise<string> => {\n if (ref.id) {\n return ref.id\n }\n const intrface = await api.findPublicInterface({ type: 'name', name: ref.name, version: ref.version })\n if (!intrface) {\n throw new errors.BotpressCLIError(`Could not find interface \"${ref.name}@${ref.version}\"`)\n }\n return intrface.id\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;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,GAAG,aAAa,MAAM,QAAQ,CAAC;AAAA,EACxE;AAAA,EAEQ,wBAAwB,CAAC,oBAAwE;AACvG,UAAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B;AAAA,MAC/B;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AAAA,EAEQ,kCAAkC,OACxC,KACA,gBACiD;AACjD,UAAM,2BAAuB,wCAA4B,WAAW;AACpE,UAAM,aAA+D,CAAC;AACtE,eAAW,CAAC,KAAK,CAAC,KAAK,OAAO,QAAQ,oBAAoB,GAAG;AAC3D,YAAM,EAAE,MAAM,SAAS,UAAU,SAAS,QAAQ,SAAS,IAAI;AAC/D,YAAM,KAAK,MAAM,KAAK,gBAAgB,KAAK,EAAE,IAAI,EAAE,IAAI,MAAM,QAAQ,CAAC;AACtE,iBAAW,OAAO,EAAE,IAAI,UAAU,SAAS,QAAQ,SAAS;AAAA,IAC9D;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,kBAAkB,OACxB,KACA,QACoB;AACpB,QAAI,IAAI,IAAI;AACV,aAAO,IAAI;AAAA,IACb;AACA,UAAM,WAAW,MAAM,IAAI,oBAAoB,EAAE,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,CAAC;AACrG,QAAI,CAAC,UAAU;AACb,YAAM,IAAI,OAAO,iBAAiB,6BAA6B,IAAI,QAAQ,IAAI,UAAU;AAAA,IAC3F;AACA,WAAO,SAAS;AAAA,EAClB;AACF;",
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n CreateIntegrationBody,\n prepareUpdateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport { CreateInterfaceBody, prepareCreateInterfaceBody, prepareUpdateInterfaceBody } from '../api/interface-body'\nimport { prepareCreatePluginBody, prepareUpdatePluginBody } from '../api/plugin-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { getImplementationStatements } from '../sdk'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectDef.type === 'plugin') {\n return this._deployPlugin(api, projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath, identifier } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this.readProjectFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this.readProjectFile(identifier?.fallbackHandlerScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n let createBody: CreateIntegrationBody = await prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this._formatInterfacesImplStatements(api, integrationDef),\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: await this.readIntegrationConfigDefinition(createBody.configuration),\n configurations: await utils.promises.awaitRecord(\n utils.records.mapValues(createBody.configurations ?? {}, this.readIntegrationConfigDefinition.bind(this))\n ),\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: ApiClient, interfaceDeclaration: sdk.InterfaceDefinition) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody: CreateInterfaceBody = await prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployPlugin(api: ApiClient, pluginDef: sdk.PluginDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n const { name, version } = pluginDef\n\n const plugin = await api.findPublicPlugin({ type: 'name', name, version })\n\n let message: string\n if (plugin) {\n this.logger.warn('Plugin already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override plugin ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy plugin ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing plugin request body...')\n\n const createBody = {\n ...(await prepareCreatePluginBody(pluginDef)),\n code,\n }\n\n const startedMessage = `Deploying plugin ${chalk.bold(name)} v${version}...`\n const successMessage = 'Plugin deployed'\n if (plugin) {\n const updateBody = prepareUpdatePluginBody(\n {\n id: plugin.id,\n ...createBody,\n },\n plugin\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updatePlugin(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createPlugin(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(\n api: ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botDefinition, api)\n const createBotBody = await prepareCreateBotBody(botDefinition)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...createBotBody,\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return integration // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return new sdk.IntegrationDefinition({ ...integration, name: newName })\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return integration\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return new sdk.IntegrationDefinition({ ...integration, name: newName })\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n\n private _formatInterfacesImplStatements = async (\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<CreateIntegrationBody['interfaces']> => {\n const interfacesStatements = getImplementationStatements(integration)\n const interfaces: NonNullable<CreateIntegrationBody['interfaces']> = {}\n for (const [key, i] of Object.entries(interfacesStatements)) {\n const { name, version, entities, actions, events, channels } = i\n const id = await this._getInterfaceId(api, { id: i.id, name, version })\n interfaces[key] = { id, entities, actions, events, channels }\n }\n\n return interfaces\n }\n\n private _getInterfaceId = async (\n api: ApiClient,\n ref: { id?: string; name: string; version: string }\n ): Promise<string> => {\n if (ref.id) {\n return ref.id\n }\n const intrface = await api.findPublicInterface({ type: 'name', name: ref.name, version: ref.version })\n if (!intrface) {\n throw new errors.BotpressCLIError(`Could not find interface \"${ref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,IAAI,MAAM,SAAS,IAAI,QAAQ,CAAC;AACrG,QAAI,CAAC,UAAU;AACb,YAAM,IAAI,OAAO,iBAAiB,6BAA6B,IAAI,QAAQ,IAAI,UAAU;AAAA,IAC3F;AACA,WAAO,SAAS;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": ["chalk", "semver", "newName", "name"]
|
|
7
7
|
}
|
|
@@ -47,6 +47,9 @@ class GenerateCommand extends import_project_command.ProjectCommand {
|
|
|
47
47
|
if (projectDef.type === "bot") {
|
|
48
48
|
return await this._generateBot(projectDef.definition);
|
|
49
49
|
}
|
|
50
|
+
if (projectDef.type === "plugin") {
|
|
51
|
+
return await this._generatePlugin(projectDef.definition);
|
|
52
|
+
}
|
|
50
53
|
throw new errors.UnsupportedProjectType();
|
|
51
54
|
}
|
|
52
55
|
async _generateIntegration(integrationDef) {
|
|
@@ -67,6 +70,14 @@ class GenerateCommand extends import_project_command.ProjectCommand {
|
|
|
67
70
|
await this._writeGeneratedFilesToOutFolder(generatedFiles);
|
|
68
71
|
line.success(`Typings available at ${import_chalk.default.grey(fromWorkDir.outDir)}`);
|
|
69
72
|
}
|
|
73
|
+
async _generatePlugin(pluginDefinition) {
|
|
74
|
+
const line = this.logger.line();
|
|
75
|
+
line.started("Generating typings for plugin...");
|
|
76
|
+
const fromWorkDir = this.projectPaths.rel("workDir");
|
|
77
|
+
const generatedFiles = await codegen.generatePluginImplementation(pluginDefinition);
|
|
78
|
+
await this._writeGeneratedFilesToOutFolder(generatedFiles);
|
|
79
|
+
line.success(`Typings available at ${import_chalk.default.grey(fromWorkDir.outDir)}`);
|
|
80
|
+
}
|
|
70
81
|
async _writeGeneratedFilesToOutFolder(files) {
|
|
71
82
|
for (const file of files) {
|
|
72
83
|
const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/gen-command.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport fslib from 'fs'\nimport pathlib from 'path'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type GenerateCommandDefinition = typeof commandDefinitions.generate\nexport class GenerateCommand extends ProjectCommand<GenerateCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'interface') {\n this.logger.success('Interface projects have no code to generate since they have no implementation.')\n return\n }\n if (projectDef.type === 'integration') {\n return await this._generateIntegration(projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return await this._generateBot(projectDef.definition)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _generateIntegration(integrationDef: sdk.IntegrationDefinition): Promise<void> {\n this._validateSecrets(integrationDef)\n\n const line = this.logger.line()\n\n const { name } = integrationDef\n line.started(`Generating typings for integration ${chalk.bold(name)}...`)\n\n const fromWorkDir = this.projectPaths.rel('workDir')\n\n const generatedFiles = await codegen.generateIntegrationImplementation(integrationDef)\n\n await this._writeGeneratedFilesToOutFolder(generatedFiles)\n\n line.success(`Typings available at ${chalk.grey(fromWorkDir.outDir)}`)\n }\n\n private async _generateBot(botDefinition: sdk.BotDefinition): Promise<void> {\n const line = this.logger.line()\n\n line.started('Generating typings for bot...')\n\n const fromWorkDir = this.projectPaths.rel('workDir')\n\n const generatedFiles = await codegen.generateBotImplementation(botDefinition)\n\n await this._writeGeneratedFilesToOutFolder(generatedFiles)\n\n line.success(`Typings available at ${chalk.grey(fromWorkDir.outDir)}`)\n }\n\n private async _writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fslib.promises.mkdir(dirPath, { recursive: true })\n await fslib.promises.writeFile(filePath, file.content)\n }\n }\n\n private _validateSecrets(integrationDef: sdk.IntegrationDefinition): void {\n const { secrets } = integrationDef\n if (!secrets) {\n return\n }\n\n for (const secretName in secrets) {\n if (!utils.casing.is.screamingSnakeCase(secretName)) {\n throw new errors.BotpressCLIError(`Secret ${secretName} should be in SCREAMING_SNAKE_CASE`)\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,gBAAkB;AAClB,kBAAoB;AACpB,cAAyB;AAEzB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,wBAAwB,sCAA0C;AAAA,EAC7E,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAC1D,QAAI,WAAW,SAAS,aAAa;AACnC,WAAK,OAAO,QAAQ,gFAAgF;AACpG;AAAA,IACF;AACA,QAAI,WAAW,SAAS,eAAe;AACrC,aAAO,MAAM,KAAK,qBAAqB,WAAW,UAAU;AAAA,IAC9D;AACA,QAAI,WAAW,SAAS,OAAO;AAC7B,aAAO,MAAM,KAAK,aAAa,WAAW,UAAU;AAAA,IACtD;AACA,UAAM,IAAI,OAAO,uBAAuB;AAAA,EAC1C;AAAA,EAEA,MAAc,qBAAqB,gBAA0D;AAC3F,SAAK,iBAAiB,cAAc;AAEpC,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,UAAM,EAAE,KAAK,IAAI;AACjB,SAAK,QAAQ,sCAAsC,aAAAA,QAAM,KAAK,IAAI,MAAM;AAExE,UAAM,cAAc,KAAK,aAAa,IAAI,SAAS;AAEnD,UAAM,iBAAiB,MAAM,QAAQ,kCAAkC,cAAc;AAErF,UAAM,KAAK,gCAAgC,cAAc;AAEzD,SAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,YAAY,MAAM,GAAG;AAAA,EACvE;AAAA,EAEA,MAAc,aAAa,eAAiD;AAC1E,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,SAAK,QAAQ,+BAA+B;AAE5C,UAAM,cAAc,KAAK,aAAa,IAAI,SAAS;AAEnD,UAAM,iBAAiB,MAAM,QAAQ,0BAA0B,aAAa;AAE5E,UAAM,KAAK,gCAAgC,cAAc;AAEzD,SAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,YAAY,MAAM,GAAG;AAAA,EACvE;AAAA,EAEA,MAAc,gCAAgC,OAAuB;AACnE,eAAW,QAAQ,OAAO;AACxB,YAAM,WAAW,MAAM,KAAK,aAAa,KAAK,aAAa,IAAI,QAAQ,KAAK,IAAI;AAChF,YAAM,UAAU,YAAAC,QAAQ,QAAQ,QAAQ;AACxC,YAAM,UAAAC,QAAM,SAAS,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;AACvD,YAAM,UAAAA,QAAM,SAAS,UAAU,UAAU,KAAK,OAAO;AAAA,IACvD;AAAA,EACF;AAAA,EAEQ,iBAAiB,gBAAiD;AACxE,UAAM,EAAE,QAAQ,IAAI;AACpB,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,eAAW,cAAc,SAAS;AAChC,UAAI,CAAC,MAAM,OAAO,GAAG,mBAAmB,UAAU,GAAG;AACnD,cAAM,IAAI,OAAO,iBAAiB,UAAU,8CAA8C;AAAA,MAC5F;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport fslib from 'fs'\nimport pathlib from 'path'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type GenerateCommandDefinition = typeof commandDefinitions.generate\nexport class GenerateCommand extends ProjectCommand<GenerateCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type === 'interface') {\n this.logger.success('Interface projects have no code to generate since they have no implementation.')\n return\n }\n if (projectDef.type === 'integration') {\n return await this._generateIntegration(projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return await this._generateBot(projectDef.definition)\n }\n if (projectDef.type === 'plugin') {\n return await this._generatePlugin(projectDef.definition)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _generateIntegration(integrationDef: sdk.IntegrationDefinition): Promise<void> {\n this._validateSecrets(integrationDef)\n\n const line = this.logger.line()\n\n const { name } = integrationDef\n line.started(`Generating typings for integration ${chalk.bold(name)}...`)\n\n const fromWorkDir = this.projectPaths.rel('workDir')\n\n const generatedFiles = await codegen.generateIntegrationImplementation(integrationDef)\n\n await this._writeGeneratedFilesToOutFolder(generatedFiles)\n\n line.success(`Typings available at ${chalk.grey(fromWorkDir.outDir)}`)\n }\n\n private async _generateBot(botDefinition: sdk.BotDefinition): Promise<void> {\n const line = this.logger.line()\n\n line.started('Generating typings for bot...')\n\n const fromWorkDir = this.projectPaths.rel('workDir')\n\n const generatedFiles = await codegen.generateBotImplementation(botDefinition)\n\n await this._writeGeneratedFilesToOutFolder(generatedFiles)\n\n line.success(`Typings available at ${chalk.grey(fromWorkDir.outDir)}`)\n }\n\n private async _generatePlugin(pluginDefinition: sdk.PluginDefinition): Promise<void> {\n const line = this.logger.line()\n\n line.started('Generating typings for plugin...')\n\n const fromWorkDir = this.projectPaths.rel('workDir')\n\n const generatedFiles = await codegen.generatePluginImplementation(pluginDefinition)\n\n await this._writeGeneratedFilesToOutFolder(generatedFiles)\n\n line.success(`Typings available at ${chalk.grey(fromWorkDir.outDir)}`)\n }\n\n private async _writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fslib.promises.mkdir(dirPath, { recursive: true })\n await fslib.promises.writeFile(filePath, file.content)\n }\n }\n\n private _validateSecrets(integrationDef: sdk.IntegrationDefinition): void {\n const { secrets } = integrationDef\n if (!secrets) {\n return\n }\n\n for (const secretName in secrets) {\n if (!utils.casing.is.screamingSnakeCase(secretName)) {\n throw new errors.BotpressCLIError(`Secret ${secretName} should be in SCREAMING_SNAKE_CASE`)\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,gBAAkB;AAClB,kBAAoB;AACpB,cAAyB;AAEzB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,wBAAwB,sCAA0C;AAAA,EAC7E,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAC1D,QAAI,WAAW,SAAS,aAAa;AACnC,WAAK,OAAO,QAAQ,gFAAgF;AACpG;AAAA,IACF;AACA,QAAI,WAAW,SAAS,eAAe;AACrC,aAAO,MAAM,KAAK,qBAAqB,WAAW,UAAU;AAAA,IAC9D;AACA,QAAI,WAAW,SAAS,OAAO;AAC7B,aAAO,MAAM,KAAK,aAAa,WAAW,UAAU;AAAA,IACtD;AACA,QAAI,WAAW,SAAS,UAAU;AAChC,aAAO,MAAM,KAAK,gBAAgB,WAAW,UAAU;AAAA,IACzD;AACA,UAAM,IAAI,OAAO,uBAAuB;AAAA,EAC1C;AAAA,EAEA,MAAc,qBAAqB,gBAA0D;AAC3F,SAAK,iBAAiB,cAAc;AAEpC,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,UAAM,EAAE,KAAK,IAAI;AACjB,SAAK,QAAQ,sCAAsC,aAAAA,QAAM,KAAK,IAAI,MAAM;AAExE,UAAM,cAAc,KAAK,aAAa,IAAI,SAAS;AAEnD,UAAM,iBAAiB,MAAM,QAAQ,kCAAkC,cAAc;AAErF,UAAM,KAAK,gCAAgC,cAAc;AAEzD,SAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,YAAY,MAAM,GAAG;AAAA,EACvE;AAAA,EAEA,MAAc,aAAa,eAAiD;AAC1E,UAAM,OAAO,KA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aces = __toESM(require("./interface-commands"));
|
|
|
43
43
|
var import_lint_command = require("./lint-command");
|
|
44
44
|
var import_login_command = require("./login-command");
|
|
45
45
|
var import_logout_command = require("./logout-command");
|
|
46
|
+
var plugins = __toESM(require("./plugin-commands"));
|
|
46
47
|
var import_read_command = require("./read-command");
|
|
47
48
|
var import_serve_command = require("./serve-command");
|
|
48
49
|
const getHandler = (cls) => async (argv) => {
|
|
@@ -75,6 +76,13 @@ var command_implementations_default = {
|
|
|
75
76
|
delete: getHandler(interfaces.DeleteInterfaceCommand)
|
|
76
77
|
}
|
|
77
78
|
},
|
|
79
|
+
plugins: {
|
|
80
|
+
subcommands: {
|
|
81
|
+
get: getHandler(plugins.GetPluginCommand),
|
|
82
|
+
list: getHandler(plugins.ListPluginsCommand),
|
|
83
|
+
delete: getHandler(plugins.DeletePluginCommand)
|
|
84
|
+
}
|
|
85
|
+
},
|
|
78
86
|
init: getHandler(import_init_command.InitCommand),
|
|
79
87
|
generate: getHandler(import_gen_command.GenerateCommand),
|
|
80
88
|
bundle: getHandler(import_bundle_command.BundleCommand),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { ApiClient } from '../api/client'\nimport type commandDefinitions from '../command-definitions'\nimport type { ImplementationTree } from '../command-tree'\nimport { Logger } from '../logger'\nimport type { CommandArgv } from '../typings'\nimport * as utils from '../utils'\nimport { AddCommand } from './add-command'\nimport type { BaseCommand } from './base-command'\nimport * as bots from './bot-commands'\nimport { BuildCommand } from './build-command'\nimport { BundleCommand } from './bundle-command'\nimport { DeployCommand } from './deploy-command'\nimport { DevCommand } from './dev-command'\nimport { GenerateCommand } from './gen-command'\nimport type { GlobalCommand, GlobalCommandDefinition } from './global-command'\nimport { InitCommand } from './init-command'\nimport * as integrations from './integration-commands'\nimport * as interfaces from './interface-commands'\nimport { LintCommand } from './lint-command'\nimport { LoginCommand } from './login-command'\nimport { LogoutCommand } from './logout-command'\nimport { ReadCommand } from './read-command'\nimport { ServeCommand } from './serve-command'\n\ntype GlobalCtor<C extends GlobalCommandDefinition> = new (\n ...args: ConstructorParameters<typeof GlobalCommand<C>>\n) => BaseCommand<C>\n\nconst getHandler =\n <C extends GlobalCommandDefinition>(cls: GlobalCtor<C>) =>\n async (argv: CommandArgv<C>) => {\n const logger = new Logger(argv)\n const prompt = new utils.prompt.CLIPrompt(argv, logger)\n return new cls(ApiClient, prompt, logger, argv).handler()\n }\n\nexport default {\n login: getHandler(LoginCommand),\n logout: getHandler(LogoutCommand),\n bots: {\n subcommands: {\n create: getHandler(bots.CreateBotCommand),\n get: getHandler(bots.GetBotCommand),\n delete: getHandler(bots.DeleteBotCommand),\n list: getHandler(bots.ListBotsCommand),\n },\n },\n integrations: {\n subcommands: {\n get: getHandler(integrations.GetIntegrationCommand),\n list: getHandler(integrations.ListIntegrationsCommand),\n delete: getHandler(integrations.DeleteIntegrationCommand),\n },\n },\n interfaces: {\n subcommands: {\n get: getHandler(interfaces.GetInterfaceCommand),\n list: getHandler(interfaces.ListInterfacesCommand),\n delete: getHandler(interfaces.DeleteInterfaceCommand),\n },\n },\n init: getHandler(InitCommand),\n generate: getHandler(GenerateCommand),\n bundle: getHandler(BundleCommand),\n build: getHandler(BuildCommand),\n read: getHandler(ReadCommand),\n serve: getHandler(ServeCommand),\n deploy: getHandler(DeployCommand),\n add: getHandler(AddCommand),\n dev: getHandler(DevCommand),\n lint: getHandler(LintCommand),\n} satisfies ImplementationTree<typeof commandDefinitions>\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAG1B,oBAAuB;AAEvB,YAAuB;AACvB,yBAA2B;AAE3B,WAAsB;AACtB,2BAA6B;AAC7B,4BAA8B;AAC9B,4BAA8B;AAC9B,yBAA2B;AAC3B,yBAAgC;AAEhC,0BAA4B;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KAAK,WAAW,6BAAU;AAAA,EAC1B,MAAM,WAAW,+BAAW;AAC9B;",
|
|
4
|
+
"sourcesContent": ["import { ApiClient } from '../api/client'\nimport type commandDefinitions from '../command-definitions'\nimport type { ImplementationTree } from '../command-tree'\nimport { Logger } from '../logger'\nimport type { CommandArgv } from '../typings'\nimport * as utils from '../utils'\nimport { AddCommand } from './add-command'\nimport type { BaseCommand } from './base-command'\nimport * as bots from './bot-commands'\nimport { BuildCommand } from './build-command'\nimport { BundleCommand } from './bundle-command'\nimport { DeployCommand } from './deploy-command'\nimport { DevCommand } from './dev-command'\nimport { GenerateCommand } from './gen-command'\nimport type { GlobalCommand, GlobalCommandDefinition } from './global-command'\nimport { InitCommand } from './init-command'\nimport * as integrations from './integration-commands'\nimport * as interfaces from './interface-commands'\nimport { LintCommand } from './lint-command'\nimport { LoginCommand } from './login-command'\nimport { LogoutCommand } from './logout-command'\nimport * as plugins from './plugin-commands'\nimport { ReadCommand } from './read-command'\nimport { ServeCommand } from './serve-command'\n\ntype GlobalCtor<C extends GlobalCommandDefinition> = new (\n ...args: ConstructorParameters<typeof GlobalCommand<C>>\n) => BaseCommand<C>\n\nconst getHandler =\n <C extends GlobalCommandDefinition>(cls: GlobalCtor<C>) =>\n async (argv: CommandArgv<C>) => {\n const logger = new Logger(argv)\n const prompt = new utils.prompt.CLIPrompt(argv, logger)\n return new cls(ApiClient, prompt, logger, argv).handler()\n }\n\nexport default {\n login: getHandler(LoginCommand),\n logout: getHandler(LogoutCommand),\n bots: {\n subcommands: {\n create: getHandler(bots.CreateBotCommand),\n get: getHandler(bots.GetBotCommand),\n delete: getHandler(bots.DeleteBotCommand),\n list: getHandler(bots.ListBotsCommand),\n },\n },\n integrations: {\n subcommands: {\n get: getHandler(integrations.GetIntegrationCommand),\n list: getHandler(integrations.ListIntegrationsCommand),\n delete: getHandler(integrations.DeleteIntegrationCommand),\n },\n },\n interfaces: {\n subcommands: {\n get: getHandler(interfaces.GetInterfaceCommand),\n list: getHandler(interfaces.ListInterfacesCommand),\n delete: getHandler(interfaces.DeleteInterfaceCommand),\n },\n },\n plugins: {\n subcommands: {\n get: getHandler(plugins.GetPluginCommand),\n list: getHandler(plugins.ListPluginsCommand),\n delete: getHandler(plugins.DeletePluginCommand),\n },\n },\n init: getHandler(InitCommand),\n generate: getHandler(GenerateCommand),\n bundle: getHandler(BundleCommand),\n build: getHandler(BuildCommand),\n read: getHandler(ReadCommand),\n serve: getHandler(ServeCommand),\n deploy: getHandler(DeployCommand),\n add: getHandler(AddCommand),\n dev: getHandler(DevCommand),\n lint: getHandler(LintCommand),\n} satisfies ImplementationTree<typeof commandDefinitions>\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAG1B,oBAAuB;AAEvB,YAAuB;AACvB,yBAA2B;AAE3B,WAAsB;AACtB,2BAA6B;AAC7B,4BAA8B;AAC9B,4BAA8B;AAC9B,yBAA2B;AAC3B,yBAAgC;AAEhC,0BAA4B;AAC5B,mBAA8B;AAC9B,iBAA4B;AAC5B,0BAA4B;AAC5B,2BAA6B;AAC7B,4BAA8B;AAC9B,cAAyB;AACzB,0BAA4B;AAC5B,2BAA6B;AAM7B,MAAM,aACJ,CAAoC,QACpC,OAAO,SAAyB;AAC9B,QAAM,SAAS,IAAI,qBAAO,IAAI;AAC9B,QAAM,SAAS,IAAI,MAAM,OAAO,UAAU,MAAM,MAAM;AACtD,SAAO,IAAI,IAAI,yBAAW,QAAQ,QAAQ,IAAI,EAAE,QAAQ;AAC1D;AAEF,IAAO,kCAAQ;AAAA,EACb,OAAO,WAAW,iCAAY;AAAA,EAC9B,QAAQ,WAAW,mCAAa;AAAA,EAChC,MAAM;AAAA,IACJ,aAAa;AAAA,MACX,QAAQ,WAAW,KAAK,gBAAgB;AAAA,MACxC,KAAK,WAAW,KAAK,aAAa;AAAA,MAClC,QAAQ,WAAW,KAAK,gBAAgB;AAAA,MACxC,M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