@botpress/cli 0.0.13 → 0.0.14

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.
@@ -50,12 +50,12 @@ class ActionOutputModule extends import_module.Module {
50
50
  return new ActionOutputModule(def);
51
51
  }
52
52
  }
53
- class ActionModule extends import_module.ReExportModule {
53
+ class ActionModule extends import_module.ReExportTypeModule {
54
54
  static async create(actionName, action) {
55
55
  const inputModule = await ActionInputModule.create(action.input ?? {});
56
56
  const outputModule = await ActionOutputModule.create(action.output ?? {});
57
57
  const inst = new ActionModule({
58
- exportName: `Action${import_utils.strings.pascalCase(actionName)}`
58
+ exportName: `Action${import_utils.casing.to.pascalCase(actionName)}`
59
59
  });
60
60
  inst.pushDep(inputModule);
61
61
  inst.pushDep(outputModule);
@@ -31,7 +31,7 @@ var import_bluebird = __toESM(require("bluebird"));
31
31
  var import_utils = require("../utils");
32
32
  var import_message = require("./message");
33
33
  var import_module = require("./module");
34
- class ChannelModule extends import_module.ReExportModule {
34
+ class ChannelModule extends import_module.ReExportTypeModule {
35
35
  static async create(channelName, channel) {
36
36
  const messages = channel.messages ?? {};
37
37
  const messageModules = await import_bluebird.default.map(
@@ -39,7 +39,7 @@ class ChannelModule extends import_module.ReExportModule {
39
39
  ([messageName, message]) => import_message.MessageModule.create(messageName, message)
40
40
  );
41
41
  const inst = new ChannelModule({
42
- exportName: `Channel${import_utils.strings.pascalCase(channelName)}`
42
+ exportName: `Channel${import_utils.casing.to.pascalCase(channelName)}`
43
43
  });
44
44
  inst.pushDep(...messageModules);
45
45
  return inst;
@@ -29,7 +29,7 @@ class EventModule extends import_module.Module {
29
29
  const schema = event.schema ?? {};
30
30
  const def = {
31
31
  path: `${name}.ts`,
32
- exportName: import_utils.strings.pascalCase(name),
32
+ exportName: import_utils.casing.to.pascalCase(name),
33
33
  content: await (0, import_json_schema_to_typescript.compile)(schema, name)
34
34
  };
35
35
  return new EventModule(def);
@@ -29,7 +29,9 @@ __export(code_generation_exports, {
29
29
  generateBotIndex: () => generateBotIndex,
30
30
  generateIntegrationImplementationTypings: () => generateIntegrationImplementationTypings,
31
31
  generateIntegrationIndex: () => generateIntegrationIndex,
32
- generateIntegrationInstance: () => generateIntegrationInstance
32
+ generateIntegrationInstance: () => generateIntegrationInstance,
33
+ generateIntegrationSecrets: () => generateIntegrationSecrets,
34
+ secretEnvVariableName: () => import_integration_secret2.secretEnvVariableName
33
35
  });
34
36
  module.exports = __toCommonJS(code_generation_exports);
35
37
  var import_path = __toESM(require("path"));
@@ -37,20 +39,34 @@ var import_utils = require("../utils");
37
39
  var import_const = require("./const");
38
40
  var import_integration_impl = require("./integration-impl");
39
41
  var import_integration_instance = require("./integration-instance");
42
+ var import_integration_secret = require("./integration-secret");
40
43
  var import_typings = require("./typings");
44
+ var import_integration_secret2 = require("./integration-secret");
41
45
  const INTEGRATION_JSON = "integration.json";
42
46
  const generateIntegrationImplementationTypings = async (integration, implementationTypingsPath) => {
43
47
  const indexModule = await import_integration_impl.IntegrationImplementationIndexModule.create(integration);
44
48
  indexModule.unshift(implementationTypingsPath);
45
49
  return indexModule.flatten();
46
50
  };
47
- const generateIntegrationIndex = async (implementationTypingsPath) => ({
48
- path: import_const.INDEX_FILE,
49
- content: `export * from './${implementationTypingsPath}'`
50
- });
51
+ const generateIntegrationSecrets = async (integration, secretsPath) => {
52
+ const indexModule = await import_integration_secret.IntegrationSecretIndexModule.create(integration);
53
+ indexModule.unshift(secretsPath);
54
+ return indexModule.flatten();
55
+ };
56
+ const generateIntegrationIndex = async (implementationTypingsPath, implementationSecretsPath) => {
57
+ let content = "";
58
+ content += `export * from './${implementationTypingsPath}'
59
+ `;
60
+ content += `export * from './${implementationSecretsPath}'
61
+ `;
62
+ return {
63
+ path: import_const.INDEX_FILE,
64
+ content
65
+ };
66
+ };
51
67
  const generateIntegrationInstance = async (integration, installPath) => {
52
68
  const indexModule = await import_integration_instance.IntegrationInstanceIndexModule.create(integration);
53
- const dirname = import_utils.strings.kebabCase(integration.name);
69
+ const dirname = import_utils.casing.to.kebabCase(integration.name);
54
70
  indexModule.unshift(installPath, dirname);
55
71
  const files = indexModule.flatten();
56
72
  const { name, version, id } = integration;
@@ -76,5 +92,7 @@ const generateBotIndex = async (installPath, instances) => ({
76
92
  generateBotIndex,
77
93
  generateIntegrationImplementationTypings,
78
94
  generateIntegrationIndex,
79
- generateIntegrationInstance
95
+ generateIntegrationInstance,
96
+ generateIntegrationSecrets,
97
+ secretEnvVariableName
80
98
  });
@@ -101,7 +101,7 @@ class IntegrationImplementationIndexModule extends import_module.Module {
101
101
  return content;
102
102
  }
103
103
  }
104
- class ChannelsModule extends import_module.ReExportModule {
104
+ class ChannelsModule extends import_module.ReExportTypeModule {
105
105
  static async create(channels) {
106
106
  const channelModules = await import_bluebird.default.map(Object.entries(channels), async ([channelName, channel]) => {
107
107
  const mod = await import_channel.ChannelModule.create(channelName, channel);
@@ -112,7 +112,7 @@ class ChannelsModule extends import_module.ReExportModule {
112
112
  return inst;
113
113
  }
114
114
  }
115
- class ActionsModule extends import_module.ReExportModule {
115
+ class ActionsModule extends import_module.ReExportTypeModule {
116
116
  static async create(actions) {
117
117
  const actionModules = await import_bluebird.default.map(Object.entries(actions), async ([actionName, action]) => {
118
118
  const mod = await import_action.ActionModule.create(actionName, action);
@@ -125,7 +125,7 @@ class ActionsModule extends import_module.ReExportModule {
125
125
  return inst;
126
126
  }
127
127
  }
128
- class EventsModule extends import_module.ReExportModule {
128
+ class EventsModule extends import_module.ReExportTypeModule {
129
129
  static async create(events) {
130
130
  const eventModules = await import_bluebird.default.map(
131
131
  Object.entries(events),
@@ -23,6 +23,7 @@ __export(integration_instance_exports, {
23
23
  module.exports = __toCommonJS(integration_instance_exports);
24
24
  var import_utils = require("../utils");
25
25
  var import_configuration = require("./configuration");
26
+ var import_const = require("./const");
26
27
  var import_module = require("./module");
27
28
  const CONTENT = ({
28
29
  name,
@@ -63,9 +64,9 @@ class IntegrationInstanceIndexModule extends import_module.Module {
63
64
  static async create(integration) {
64
65
  const { name, version, id } = integration;
65
66
  const configModule = await import_configuration.ConfigurationModule.create(integration.configuration ?? { schema: {} });
66
- const exportName = import_utils.strings.pascalCase(name);
67
+ const exportName = import_utils.casing.to.pascalCase(name);
67
68
  const content = CONTENT({ name, className: exportName, propsName: `${exportName}Props`, version, id });
68
- const inst = new IntegrationInstanceIndexModule({ path: "index.ts", content, exportName });
69
+ const inst = new IntegrationInstanceIndexModule({ path: import_const.INDEX_FILE, content, exportName });
69
70
  inst.pushDep(configModule);
70
71
  return inst;
71
72
  }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var integration_secret_exports = {};
20
+ __export(integration_secret_exports, {
21
+ IntegrationSecretIndexModule: () => IntegrationSecretIndexModule,
22
+ secretEnvVariableName: () => secretEnvVariableName
23
+ });
24
+ module.exports = __toCommonJS(integration_secret_exports);
25
+ var import_utils = require("../utils");
26
+ var import_const = require("./const");
27
+ var import_module = require("./module");
28
+ const secretEnvVariableName = (secretName) => `SECRET_${import_utils.casing.to.screamingSnakeCase(secretName)}`;
29
+ class IntegrationSecretIndexModule extends import_module.Module {
30
+ static async create(integration) {
31
+ let content = import_const.GENERATED_HEADER;
32
+ content += "class Secrets {\n";
33
+ for (const secretName of integration.secrets ?? []) {
34
+ const envVariableName = secretEnvVariableName(secretName);
35
+ const fieldName = import_utils.casing.to.screamingSnakeCase(secretName);
36
+ content += ` public get ${fieldName}(): string {
37
+ `;
38
+ content += ` const envVarValue = process.env.${envVariableName}
39
+ `;
40
+ content += ` if (!envVarValue) { throw new Error('Missing environment variable ${envVariableName}') }
41
+ `;
42
+ content += " return envVarValue\n";
43
+ content += " }\n";
44
+ }
45
+ content += "}\n";
46
+ content += "export const secrets = new Secrets()\n";
47
+ return new IntegrationSecretIndexModule({ content, exportName: "secrets", path: import_const.INDEX_FILE });
48
+ }
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ IntegrationSecretIndexModule,
53
+ secretEnvVariableName
54
+ });
@@ -29,7 +29,7 @@ class MessageModule extends import_module.Module {
29
29
  const schema = message.schema ?? {};
30
30
  const def = {
31
31
  path: `${name}.ts`,
32
- exportName: import_utils.strings.pascalCase(name),
32
+ exportName: import_utils.casing.to.pascalCase(name),
33
33
  content: await (0, import_json_schema_to_typescript.compile)(schema, name)
34
34
  };
35
35
  return new MessageModule(def);
@@ -25,7 +25,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
25
25
  var module_exports = {};
26
26
  __export(module_exports, {
27
27
  Module: () => Module,
28
- ReExportModule: () => ReExportModule
28
+ ReExportTypeModule: () => ReExportTypeModule
29
29
  });
30
30
  module.exports = __toCommonJS(module_exports);
31
31
  var import_path = require("path");
@@ -46,9 +46,10 @@ class Module {
46
46
  const basename = import_path.posix.basename(this.path);
47
47
  if (basename === import_const.INDEX_FILE) {
48
48
  const dirname = import_path.posix.basename(import_path.posix.dirname(this.path));
49
- return dirname;
49
+ return utils.casing.to.camelCase(dirname);
50
50
  }
51
- return utils.path.rmExtension(basename);
51
+ const withoutExtension = utils.path.rmExtension(basename);
52
+ return utils.casing.to.camelCase(withoutExtension);
52
53
  }
53
54
  get exports() {
54
55
  return this._def.exportName;
@@ -77,7 +78,7 @@ class Module {
77
78
  return utils.path.rmExtension(relativePath);
78
79
  }
79
80
  }
80
- class ReExportModule extends Module {
81
+ class ReExportTypeModule extends Module {
81
82
  constructor(def) {
82
83
  super({
83
84
  ...def,
@@ -111,5 +112,5 @@ class ReExportModule extends Module {
111
112
  // Annotate the CommonJS export names for ESM import in node:
112
113
  0 && (module.exports = {
113
114
  Module,
114
- ReExportModule
115
+ ReExportTypeModule
115
116
  });
@@ -34,6 +34,7 @@ class BaseCommand {
34
34
  this.argv = argv;
35
35
  }
36
36
  async handler() {
37
+ let exitCode = 0;
37
38
  try {
38
39
  if (this.bootstrap) {
39
40
  await this.bootstrap();
@@ -42,9 +43,13 @@ class BaseCommand {
42
43
  } catch (thrown) {
43
44
  const error = errors.BotpressCLIError.map(thrown);
44
45
  this.logger.error(error.message);
45
- process.exit(1);
46
+ exitCode = 1;
47
+ } finally {
48
+ if (this.teardown) {
49
+ await this.teardown();
50
+ }
46
51
  }
47
- process.exit(0);
52
+ process.exit(exitCode);
48
53
  }
49
54
  }
50
55
  // Annotate the CommonJS export names for ESM import in node:
@@ -54,7 +54,11 @@ class DeployCommand extends import_project_command.ProjectCommand {
54
54
  }
55
55
  async _deployIntegration(api, integrationDef) {
56
56
  const outfile = this.projectPaths.abs.outFile;
57
- const code = await fs.promises.readFile(outfile, "utf-8");
57
+ let code = await fs.promises.readFile(outfile, "utf-8");
58
+ const secrets = await this.promptSecrets(integrationDef, this.argv);
59
+ for (const [secretName, secretValue] of Object.entries(secrets)) {
60
+ code = code.replace(new RegExp(`process\\.env\\.${secretName}`, "g"), `"${secretValue}"`);
61
+ }
58
62
  const { name, version } = integrationDef;
59
63
  const integration = await api.findIntegration({ type: "name", name, version });
60
64
  let message;
@@ -42,8 +42,14 @@ class DevCommand extends import_project_command.ProjectCommand {
42
42
  }
43
43
  const api = await this.ensureLoginAndCreateClient(this.argv);
44
44
  const integrationDef = await this.readIntegrationDefinitionFromFS();
45
+ let env = {
46
+ BP_API_URL: api.host,
47
+ BP_TOKEN: api.token
48
+ };
45
49
  if (integrationDef) {
46
50
  await this._deployDevIntegration(api, this.argv.url, integrationDef);
51
+ const secrets = await this.promptSecrets(integrationDef, this.argv);
52
+ env = { ...env, ...secrets };
47
53
  } else {
48
54
  await this._deployDevBot(api, this.argv.url);
49
55
  }
@@ -55,10 +61,7 @@ class DevCommand extends import_project_command.ProjectCommand {
55
61
  {
56
62
  type: "code",
57
63
  code,
58
- env: {
59
- BP_API_URL: api.host,
60
- BP_TOKEN: api.token
61
- }
64
+ env
62
65
  },
63
66
  this.logger
64
67
  ).catch((thrown) => {
@@ -28,7 +28,10 @@ __export(gen_command_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(gen_command_exports);
30
30
  var import_chalk = __toESM(require("chalk"));
31
+ var import_lodash = __toESM(require("lodash"));
31
32
  var codegen = __toESM(require("../code-generation"));
33
+ var errors = __toESM(require("../errors"));
34
+ var utils = __toESM(require("../utils"));
32
35
  var import_project_command = require("./project-command");
33
36
  class GenerateCommand extends import_project_command.ProjectCommand {
34
37
  async run() {
@@ -37,6 +40,7 @@ class GenerateCommand extends import_project_command.ProjectCommand {
37
40
  this.logger.warn("No typings to generate for bot");
38
41
  return;
39
42
  }
43
+ this._validateSecrets(integrationDef);
40
44
  const line = this.logger.line();
41
45
  const { name } = integrationDef;
42
46
  line.started(`Generating typings for integration ${import_chalk.default.bold(name)}...`);
@@ -46,11 +50,29 @@ class GenerateCommand extends import_project_command.ProjectCommand {
46
50
  integrationDef,
47
51
  fromOutDir.implementationDir
48
52
  );
49
- const indexFile = await codegen.generateIntegrationIndex(fromOutDir.implementationDir);
50
- const generatedFiles = [...typingFiles, indexFile];
53
+ const secretFiles = await codegen.generateIntegrationSecrets(integrationDef, fromOutDir.secretsDir);
54
+ const indexFile = await codegen.generateIntegrationIndex(fromOutDir.implementationDir, fromOutDir.secretsDir);
55
+ const generatedFiles = [...typingFiles, ...secretFiles, indexFile];
51
56
  await this.writeGeneratedFilesToOutFolder(generatedFiles);
52
57
  line.success(`Typings available at ${import_chalk.default.grey(fromWorkDir.outDir)}`);
53
58
  }
59
+ _validateSecrets(integrationDef) {
60
+ const { secrets } = integrationDef;
61
+ if (!secrets) {
62
+ return;
63
+ }
64
+ for (const secret of secrets) {
65
+ if (!utils.casing.is.screamingSnakeCase(secret)) {
66
+ throw new errors.BotpressCLIError(`Secret ${secret} should be in SCREAMING_SNAKE_CASE`);
67
+ }
68
+ }
69
+ const groups = (0, import_lodash.default)(secrets).groupBy().mapValues((s) => s.length).toPairs().value();
70
+ for (const [secret, count] of groups) {
71
+ if (count > 1) {
72
+ throw new errors.BotpressCLIError(`Secret ${secret} is dupplicated; It appears ${count} times`);
73
+ }
74
+ }
75
+ }
54
76
  }
55
77
  // Annotate the CommonJS export names for ESM import in node:
56
78
  0 && (module.exports = {
@@ -77,6 +77,9 @@ class GlobalCommand extends import_base_command.BaseCommand {
77
77
  this.logger.log(`Using custom botpress home: ${paths.abs.botpressHomeDir}`, { prefix: "\u{1F3E0}" });
78
78
  }
79
79
  };
80
+ teardown = async () => {
81
+ this.logger.cleanup();
82
+ };
80
83
  async ensureLoginAndCreateClient(credentials) {
81
84
  const cache = this.globalCache;
82
85
  const token = await cache.get("token");
@@ -77,7 +77,7 @@ class InitCommand extends import_global_command.GlobalCommand {
77
77
  const pkgJsonPath = pathlib.join(destination, "package.json");
78
78
  const strContent = await fs.promises.readFile(pkgJsonPath, "utf-8");
79
79
  const { name: _, ...json } = JSON.parse(strContent);
80
- const pkgJsonName = utils.strings.snakeCase(name);
80
+ const pkgJsonName = utils.casing.to.snakeCase(name);
81
81
  const updatedJson = { name: pkgJsonName, ...json };
82
82
  await fs.promises.writeFile(pkgJsonPath, JSON.stringify(updatedJson, null, 2));
83
83
  };
@@ -31,6 +31,7 @@ var import_chalk = __toESM(require("chalk"));
31
31
  var import_fs = __toESM(require("fs"));
32
32
  var import_lodash = __toESM(require("lodash"));
33
33
  var import_path = __toESM(require("path"));
34
+ var codegen = __toESM(require("../code-generation"));
34
35
  var consts = __toESM(require("../consts"));
35
36
  var errors = __toESM(require("../errors"));
36
37
  var utils = __toESM(require("../utils"));
@@ -108,6 +109,53 @@ class ProjectCommand extends import_global_command.GlobalCommand {
108
109
  }
109
110
  }
110
111
  }
112
+ async promptSecrets(integrationDef, argv) {
113
+ const { secrets: secretDefinitions } = integrationDef;
114
+ if (!secretDefinitions) {
115
+ return {};
116
+ }
117
+ const secretArgv = this._parseArgvSecrets(argv.secrets);
118
+ const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions.includes(s));
119
+ if (invalidSecret) {
120
+ throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`);
121
+ }
122
+ const values = {};
123
+ for (const secretDef of secretDefinitions) {
124
+ const argvSecret = secretArgv[secretDef];
125
+ if (argvSecret) {
126
+ this.logger.debug(`Using secret "${secretDef}" from argv`);
127
+ values[secretDef] = argvSecret;
128
+ continue;
129
+ }
130
+ const prompted = await this.prompt.text(`Enter value for secret "${secretDef}"`);
131
+ if (!prompted) {
132
+ throw new errors.BotpressCLIError("Secret is required");
133
+ }
134
+ values[secretDef] = prompted;
135
+ }
136
+ const envVariables = import_lodash.default.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k));
137
+ return envVariables;
138
+ }
139
+ _parseArgvSecrets(argvSecrets) {
140
+ const parsed = {};
141
+ for (const secret of argvSecrets) {
142
+ const [key, value] = this._splitOnce(secret, "=");
143
+ if (!value) {
144
+ throw new errors.BotpressCLIError(
145
+ `Secret "${key}" is missing a value. Expected format: "SECRET_NAME=secretValue"`
146
+ );
147
+ }
148
+ parsed[key] = value;
149
+ }
150
+ return parsed;
151
+ }
152
+ _splitOnce = (text, separator) => {
153
+ const index = text.indexOf(separator);
154
+ if (index === -1) {
155
+ return [text, void 0];
156
+ }
157
+ return [text.slice(0, index), text.slice(index + 1)];
158
+ };
111
159
  }
112
160
  // Annotate the CommonJS export names for ESM import in node:
113
161
  0 && (module.exports = {
@@ -37,8 +37,14 @@ class ServeCommand extends import_project_command.ProjectCommand {
37
37
  if (!fs.existsSync(outfile)) {
38
38
  throw new errors.NoBundleFoundError();
39
39
  }
40
- const isIntegration = !!await this.readIntegrationDefinitionFromFS();
41
- this.logger.log(`Serving ${isIntegration ? "integration" : "bot"}...`);
40
+ const integrationDef = await this.readIntegrationDefinitionFromFS();
41
+ if (integrationDef) {
42
+ const secrets = await this.promptSecrets(integrationDef, this.argv);
43
+ for (const [key, value] of Object.entries(secrets)) {
44
+ process.env[key] = value;
45
+ }
46
+ }
47
+ this.logger.log(`Serving ${integrationDef ? "integration" : "bot"}...`);
42
48
  const { default: serveable } = utils.require.requireJsFile(outfile);
43
49
  const server = await serveable.start(this.argv.port);
44
50
  await new Promise((resolve, reject) => {
package/dist/config.js CHANGED
@@ -54,6 +54,12 @@ const workspaceId = {
54
54
  type: "string",
55
55
  description: "The Workspace Id to deploy to"
56
56
  };
57
+ const secrets = {
58
+ type: "string",
59
+ description: "Values for the integration secrets",
60
+ array: true,
61
+ default: []
62
+ };
57
63
  const botRef = {
58
64
  type: "string",
59
65
  description: "The bot ID. Bot Name is not supported.",
@@ -103,6 +109,9 @@ const credentialsSchema = {
103
109
  workspaceId,
104
110
  token
105
111
  };
112
+ const secretsSchema = {
113
+ secrets
114
+ };
106
115
  const generateSchema = {
107
116
  ...projectSchema
108
117
  };
@@ -114,11 +123,13 @@ const buildSchema = {
114
123
  };
115
124
  const serveSchema = {
116
125
  ...projectSchema,
126
+ ...secretsSchema,
117
127
  port
118
128
  };
119
129
  const deploySchema = {
120
130
  ...projectSchema,
121
131
  ...credentialsSchema,
132
+ ...secretsSchema,
122
133
  botId: { type: "string", description: "The bot ID to deploy. Only used when deploying a bot" },
123
134
  noBuild,
124
135
  createNewBot: { type: "boolean", description: "Create a new bot when deploying. Only used when deploying a bot" }
@@ -126,6 +137,7 @@ const deploySchema = {
126
137
  const devSchema = {
127
138
  ...projectSchema,
128
139
  ...credentialsSchema,
140
+ ...secretsSchema,
129
141
  url: {
130
142
  type: "string",
131
143
  description: "The publicly available URL of the bot or integration (often using ngrok)",
@@ -193,6 +205,7 @@ const schemas = {
193
205
  global: globalSchema,
194
206
  project: projectSchema,
195
207
  credentials: credentialsSchema,
208
+ secrets: secretsSchema,
196
209
  login: loginSchema,
197
210
  logout: logoutSchema,
198
211
  createBot: createBotSchema,
package/dist/consts.js CHANGED
@@ -62,6 +62,7 @@ const fromOutDir = {
62
62
  outFile: import_path.default.join("dist", "index.js"),
63
63
  installDir: "installations",
64
64
  implementationDir: "implementation",
65
+ secretsDir: "secrets",
65
66
  projectCacheFile: "project.cache.json"
66
67
  };
67
68
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to2, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to2, key) && key !== except)
16
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to2;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var case_utils_exports = {};
26
+ __export(case_utils_exports, {
27
+ is: () => is,
28
+ to: () => to
29
+ });
30
+ module.exports = __toCommonJS(case_utils_exports);
31
+ var import_lodash = __toESM(require("lodash"));
32
+ const capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
33
+ const splitHyphens = (tokens) => tokens.flatMap((token) => token.split("-"));
34
+ const splitUnderscores = (tokens) => tokens.flatMap((token) => token.split("_"));
35
+ const splitCaseChange = (tokens) => tokens.flatMap((token) => token.split(/(?<=[a-z])(?=[A-Z])/));
36
+ const splitTokens = (tokens) => {
37
+ return [splitHyphens, splitUnderscores, splitCaseChange].reduce((acc, step) => step(acc), tokens);
38
+ };
39
+ const fromTokens = {
40
+ pascalCase: (tokens) => {
41
+ return tokens.map(capitalizeFirstLetter).join("");
42
+ },
43
+ kebabCase: (tokens) => {
44
+ return tokens.map((token) => token.toLowerCase()).join("-");
45
+ },
46
+ snakeCase: (tokens) => {
47
+ return tokens.map((token) => token.toLowerCase()).join("_");
48
+ },
49
+ screamingSnakeCase: (tokens) => {
50
+ return tokens.map((token) => token.toUpperCase()).join("_");
51
+ },
52
+ camelCase: (tokens) => {
53
+ const [first, ...others] = tokens;
54
+ return [first.toLowerCase(), ...others.map(capitalizeFirstLetter)].join("");
55
+ }
56
+ };
57
+ const to = import_lodash.default.mapValues(fromTokens, (fn) => (text) => {
58
+ const tokens = splitTokens([text]);
59
+ return fn(tokens);
60
+ });
61
+ const is = import_lodash.default.mapValues(to, (fn) => (text) => {
62
+ const result = fn(text);
63
+ return result === text;
64
+ });
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ is,
68
+ to
69
+ });
@@ -25,13 +25,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
25
25
  var utils_exports = {};
26
26
  __export(utils_exports, {
27
27
  cache: () => cache,
28
+ casing: () => casing,
28
29
  emitter: () => emitter,
29
30
  esbuild: () => esbuild,
30
31
  filewatcher: () => filewatcher,
31
32
  path: () => path,
32
33
  prompt: () => prompt,
33
- require: () => require2,
34
- strings: () => strings
34
+ require: () => require2
35
35
  });
36
36
  module.exports = __toCommonJS(utils_exports);
37
37
  var esbuild = __toESM(require("./esbuild-utils"));
@@ -40,16 +40,16 @@ var require2 = __toESM(require("./require-utils"));
40
40
  var filewatcher = __toESM(require("./file-watcher"));
41
41
  var emitter = __toESM(require("./event-emitter"));
42
42
  var cache = __toESM(require("./cache-utils"));
43
- var strings = __toESM(require("./string-utils"));
43
+ var casing = __toESM(require("./case-utils"));
44
44
  var prompt = __toESM(require("./prompt-utils"));
45
45
  // Annotate the CommonJS export names for ESM import in node:
46
46
  0 && (module.exports = {
47
47
  cache,
48
+ casing,
48
49
  emitter,
49
50
  esbuild,
50
51
  filewatcher,
51
52
  path,
52
53
  prompt,
53
- require,
54
- strings
54
+ require
55
55
  });
@@ -38,7 +38,7 @@ class CLIPrompt {
38
38
  this._logger.debug(`Confirming automatically: ${message}`);
39
39
  return true;
40
40
  }
41
- const { confirm } = await (0, import_prompts.default)({
41
+ const { confirm } = await this._prompts({
42
42
  type: "confirm",
43
43
  name: "confirm",
44
44
  message,
@@ -50,7 +50,7 @@ class CLIPrompt {
50
50
  return true;
51
51
  }
52
52
  async password(message, opts) {
53
- const { prompted } = await (0, import_prompts.default)({
53
+ const { prompted } = await this._prompts({
54
54
  type: "password",
55
55
  name: "prompted",
56
56
  message,
@@ -59,7 +59,7 @@ class CLIPrompt {
59
59
  return prompted ? prompted : void 0;
60
60
  }
61
61
  async select(message, opts) {
62
- const { prompted } = await (0, import_prompts.default)({
62
+ const { prompted } = await this._prompts({
63
63
  type: "autocomplete",
64
64
  name: "prompted",
65
65
  message,
@@ -69,7 +69,7 @@ class CLIPrompt {
69
69
  return prompted ? prompted : void 0;
70
70
  }
71
71
  async text(message, opts) {
72
- const { prompted } = await (0, import_prompts.default)({
72
+ const { prompted } = await this._prompts({
73
73
  type: "text",
74
74
  name: "prompted",
75
75
  message,
@@ -77,6 +77,10 @@ class CLIPrompt {
77
77
  });
78
78
  return prompted ? prompted : void 0;
79
79
  }
80
+ _prompts = (...args) => {
81
+ this._logger.cleanup();
82
+ return (0, import_prompts.default)(...args);
83
+ };
80
84
  }
81
85
  // Annotate the CommonJS export names for ESM import in node:
82
86
  0 && (module.exports = {
@@ -7,21 +7,19 @@ var __export = (target, all) => {
7
7
  for (var name in all)
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
- var __copyProps = (to, from, except, desc) => {
10
+ var __copyProps = (to2, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ if (!__hasOwnProp.call(to2, key) && key !== except)
14
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
15
  }
16
- return to;
16
+ return to2;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var string_utils_exports = {};
20
20
  __export(string_utils_exports, {
21
- camelCase: () => camelCase,
22
- kebabCase: () => kebabCase,
23
- pascalCase: () => pascalCase,
24
- snakeCase: () => snakeCase
21
+ is: () => is,
22
+ to: () => to
25
23
  });
26
24
  module.exports = __toCommonJS(string_utils_exports);
27
25
  const capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
@@ -32,26 +30,39 @@ const split = (tokens) => {
32
30
  const steps = [splitHyphens, splitUnderscores, splitCaseChange];
33
31
  return steps.reduce((acc, step) => step(acc), tokens);
34
32
  };
35
- const pascalCase = (text) => {
36
- const words = split([text]);
37
- return words.map(capitalizeFirstLetter).join("");
38
- };
39
- const kebabCase = (text) => {
40
- const words = split([text]);
41
- return words.map((word) => word.toLowerCase()).join("-");
42
- };
43
- const snakeCase = (text) => {
44
- const words = split([text]);
45
- return words.map((word) => word.toLowerCase()).join("_");
46
- };
47
- const camelCase = (text) => {
48
- const [first, ...words] = split([text]);
49
- return [first.toLowerCase(), ...words.map(capitalizeFirstLetter)].join("");
50
- };
33
+ var to;
34
+ ((to2) => {
35
+ to2.pascalCase = (text) => {
36
+ const words = split([text]);
37
+ return words.map(capitalizeFirstLetter).join("");
38
+ };
39
+ to2.kebabCase = (text) => {
40
+ const words = split([text]);
41
+ return words.map((word) => word.toLowerCase()).join("-");
42
+ };
43
+ to2.snakeCase = (text) => {
44
+ const words = split([text]);
45
+ return words.map((word) => word.toLowerCase()).join("_");
46
+ };
47
+ to2.screamingSnakeCase = (text) => {
48
+ const words = split([text]);
49
+ return words.map((word) => word.toUpperCase()).join("_");
50
+ };
51
+ to2.camelCase = (text) => {
52
+ const [first, ...words] = split([text]);
53
+ return [first.toLowerCase(), ...words.map(capitalizeFirstLetter)].join("");
54
+ };
55
+ })(to || (to = {}));
56
+ var is;
57
+ ((is2) => {
58
+ is2.pascalCase = (text) => text === to.pascalCase(text);
59
+ is2.kebabCase = (text) => text === to.kebabCase(text);
60
+ is2.snakeCase = (text) => text === to.snakeCase(text);
61
+ is2.screamingSnakeCase = (text) => text === to.screamingSnakeCase(text);
62
+ is2.camelCase = (text) => text === to.camelCase(text);
63
+ })(is || (is = {}));
51
64
  // Annotate the CommonJS export names for ESM import in node:
52
65
  0 && (module.exports = {
53
- camelCase,
54
- kebabCase,
55
- pascalCase,
56
- snakeCase
66
+ is,
67
+ to
57
68
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run type-check && pnpm run bundle && pnpm run template:gen && pnpm run template:type-check",
@@ -20,7 +20,7 @@
20
20
  "main": "dist/index.js",
21
21
  "dependencies": {
22
22
  "@botpress/client": "0.0.11",
23
- "@bpinternal/yargs-extra": "^0.0.2",
23
+ "@bpinternal/yargs-extra": "^0.0.3",
24
24
  "@parcel/watcher": "^2.1.0",
25
25
  "@types/lodash": "^4.14.191",
26
26
  "@types/node": "^18.11.17",
@@ -45,7 +45,7 @@
45
45
  "zod-to-json-schema": "^3.20.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@botpress/sdk": "0.0.9",
48
+ "@botpress/sdk": "0.0.10",
49
49
  "@types/bluebird": "^3.5.38",
50
50
  "@types/prompts": "^2.0.14",
51
51
  "@types/semver": "^7.3.11",
@@ -10,7 +10,7 @@
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@botpress/client": "0.0.11",
13
- "@botpress/sdk": "0.0.9",
13
+ "@botpress/sdk": "0.0.10",
14
14
  "zod": "^3.20.6"
15
15
  },
16
16
  "devDependencies": {
@@ -1 +1,2 @@
1
- export * from './implementation'
1
+ export * from './implementation'
2
+ export * from './secrets'
@@ -0,0 +1,7 @@
1
+ /* tslint:disable */
2
+ // This file is generated
3
+ // Do not edit this file
4
+
5
+ class Secrets {
6
+ }
7
+ export const secrets = new Secrets()
@@ -10,7 +10,7 @@
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@botpress/client": "0.0.11",
13
- "@botpress/sdk": "0.0.9",
13
+ "@botpress/sdk": "0.0.10",
14
14
  "zod": "^3.20.6"
15
15
  },
16
16
  "devDependencies": {