@botpress/cli 0.1.3 → 0.1.5

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/dist/index.js CHANGED
@@ -44,5 +44,5 @@ process.on("uncaughtException", (thrown) => onError(thrown));
44
44
  process.on("unhandledRejection", (thrown) => onError(thrown));
45
45
  const commands = tree.zipTree(import_command_definitions.default, import_command_implementations.default);
46
46
  (0, import_register_yargs.registerYargs)(import_yargs_extra.default, commands, { cliRootDir: CLI_ROOT_DIR });
47
- void import_yargs_extra.default.version(false).scriptName("bp").demandCommand(1, "You didn't provide any command. Use the --help flag to see the list of available commands.").recommendCommands().strict().help().fail(yargsFail).parse();
47
+ void import_yargs_extra.default.version().scriptName("bp").demandCommand(1, "You didn't provide any command. Use the --help flag to see the list of available commands.").recommendCommands().strict().help().fail(yargsFail).parse();
48
48
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import yargs from '@bpinternal/yargs-extra'\nimport commandDefinitions from './command-definitions'\nimport commandImplementations from './command-implementations'\nimport * as tree from './command-tree'\nimport * as errors from './errors'\nimport { Logger } from './logger'\nimport { registerYargs } from './register-yargs'\nimport * as utils from './utils'\n\nconst CLI_ROOT_DIR = utils.path.join(__dirname as utils.path.AbsolutePath, '..')\n\nconst logError = (thrown: unknown) => {\n const error = errors.BotpressCLIError.map(thrown)\n new Logger().error(error.message)\n}\n\nconst onError = (thrown: unknown) => {\n logError(thrown)\n process.exit(1)\n}\n\nconst yargsFail = (msg: string) => {\n logError(`${msg}\\n`)\n yargs.showHelp()\n process.exit(1)\n}\n\nprocess.on('uncaughtException', (thrown: unknown) => onError(thrown))\nprocess.on('unhandledRejection', (thrown: unknown) => onError(thrown))\n\nconst commands = tree.zipTree(commandDefinitions, commandImplementations)\n\nregisterYargs(yargs, commands, { cliRootDir: CLI_ROOT_DIR })\n\nvoid yargs\n .version(false)\n .scriptName('bp')\n .demandCommand(1, \"You didn't provide any command. Use the --help flag to see the list of available commands.\")\n .recommendCommands()\n .strict()\n .help()\n .fail(yargsFail)\n .parse()\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA,yBAAkB;AAClB,iCAA+B;AAC/B,qCAAmC;AACnC,WAAsB;AACtB,aAAwB;AACxB,oBAAuB;AACvB,4BAA8B;AAC9B,YAAuB;AAEvB,MAAM,eAAe,MAAM,KAAK,KAAK,WAAsC,IAAI;AAE/E,MAAM,WAAW,CAAC,WAAoB;AACpC,QAAM,QAAQ,OAAO,iBAAiB,IAAI,MAAM;AAChD,MAAI,qBAAO,EAAE,MAAM,MAAM,OAAO;AAClC;AAEA,MAAM,UAAU,CAAC,WAAoB;AACnC,WAAS,MAAM;AACf,UAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,YAAY,CAAC,QAAgB;AACjC,WAAS,GAAG;AAAA,CAAO;AACnB,qBAAAA,QAAM,SAAS;AACf,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,GAAG,qBAAqB,CAAC,WAAoB,QAAQ,MAAM,CAAC;AACpE,QAAQ,GAAG,sBAAsB,CAAC,WAAoB,QAAQ,MAAM,CAAC;AAErE,MAAM,WAAW,KAAK,QAAQ,2BAAAC,SAAoB,+BAAAC,OAAsB;AAAA,IAExE,qCAAc,mBAAAF,SAAO,UAAU,EAAE,YAAY,aAAa,CAAC;AAE3D,KAAK,mBAAAA,QACF,QAAQ,KAAK,EACb,WAAW,IAAI,EACf,cAAc,GAAG,4FAA4F,EAC7G,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,KAAK,SAAS,EACd,MAAM;",
4
+ "sourcesContent": ["import yargs from '@bpinternal/yargs-extra'\nimport commandDefinitions from './command-definitions'\nimport commandImplementations from './command-implementations'\nimport * as tree from './command-tree'\nimport * as errors from './errors'\nimport { Logger } from './logger'\nimport { registerYargs } from './register-yargs'\nimport * as utils from './utils'\n\nconst CLI_ROOT_DIR = utils.path.join(__dirname as utils.path.AbsolutePath, '..')\n\nconst logError = (thrown: unknown) => {\n const error = errors.BotpressCLIError.map(thrown)\n new Logger().error(error.message)\n}\n\nconst onError = (thrown: unknown) => {\n logError(thrown)\n process.exit(1)\n}\n\nconst yargsFail = (msg: string) => {\n logError(`${msg}\\n`)\n yargs.showHelp()\n process.exit(1)\n}\n\nprocess.on('uncaughtException', (thrown: unknown) => onError(thrown))\nprocess.on('unhandledRejection', (thrown: unknown) => onError(thrown))\n\nconst commands = tree.zipTree(commandDefinitions, commandImplementations)\n\nregisterYargs(yargs, commands, { cliRootDir: CLI_ROOT_DIR })\n\nvoid yargs\n .version()\n .scriptName('bp')\n .demandCommand(1, \"You didn't provide any command. Use the --help flag to see the list of available commands.\")\n .recommendCommands()\n .strict()\n .help()\n .fail(yargsFail)\n .parse()\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA,yBAAkB;AAClB,iCAA+B;AAC/B,qCAAmC;AACnC,WAAsB;AACtB,aAAwB;AACxB,oBAAuB;AACvB,4BAA8B;AAC9B,YAAuB;AAEvB,MAAM,eAAe,MAAM,KAAK,KAAK,WAAsC,IAAI;AAE/E,MAAM,WAAW,CAAC,WAAoB;AACpC,QAAM,QAAQ,OAAO,iBAAiB,IAAI,MAAM;AAChD,MAAI,qBAAO,EAAE,MAAM,MAAM,OAAO;AAClC;AAEA,MAAM,UAAU,CAAC,WAAoB;AACnC,WAAS,MAAM;AACf,UAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,YAAY,CAAC,QAAgB;AACjC,WAAS,GAAG;AAAA,CAAO;AACnB,qBAAAA,QAAM,SAAS;AACf,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,GAAG,qBAAqB,CAAC,WAAoB,QAAQ,MAAM,CAAC;AACpE,QAAQ,GAAG,sBAAsB,CAAC,WAAoB,QAAQ,MAAM,CAAC;AAErE,MAAM,WAAW,KAAK,QAAQ,2BAAAC,SAAoB,+BAAAC,OAAsB;AAAA,IAExE,qCAAc,mBAAAF,SAAO,UAAU,EAAE,YAAY,aAAa,CAAC;AAE3D,KAAK,mBAAAA,QACF,QAAQ,EACR,WAAW,IAAI,EACf,cAAc,GAAG,4FAA4F,EAC7G,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,KAAK,SAAS,EACd,MAAM;",
6
6
  "names": ["yargs", "commandDefinitions", "commandImplementations"]
7
7
  }
@@ -24,10 +24,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
25
  var prompt_utils_exports = {};
26
26
  __export(prompt_utils_exports, {
27
- CLIPrompt: () => CLIPrompt
27
+ CLIPrompt: () => CLIPrompt,
28
+ NonInteractiveError: () => NonInteractiveError
28
29
  });
29
30
  module.exports = __toCommonJS(prompt_utils_exports);
30
31
  var import_prompts = __toESM(require("prompts"));
32
+ class NonInteractiveError extends Error {
33
+ constructor(message) {
34
+ super(`${message}:
35
+ Cannot prompt for input in non-interactive mode`);
36
+ }
37
+ }
31
38
  class CLIPrompt {
32
39
  constructor(_props, _logger) {
33
40
  this._props = _props;
@@ -50,6 +57,9 @@ class CLIPrompt {
50
57
  return true;
51
58
  }
52
59
  async password(message, opts) {
60
+ if (this._props.confirm) {
61
+ throw new NonInteractiveError(message);
62
+ }
53
63
  const { prompted } = await this._prompts({
54
64
  type: "password",
55
65
  name: "prompted",
@@ -59,6 +69,9 @@ class CLIPrompt {
59
69
  return prompted ? prompted : void 0;
60
70
  }
61
71
  async select(message, opts) {
72
+ if (this._props.confirm) {
73
+ throw new NonInteractiveError(message);
74
+ }
62
75
  const { prompted } = await this._prompts({
63
76
  type: "autocomplete",
64
77
  name: "prompted",
@@ -69,6 +82,9 @@ class CLIPrompt {
69
82
  return prompted ? prompted : void 0;
70
83
  }
71
84
  async text(message, opts) {
85
+ if (this._props.confirm) {
86
+ throw new NonInteractiveError(message);
87
+ }
72
88
  const { prompted } = await this._prompts({
73
89
  type: "text",
74
90
  name: "prompted",
@@ -84,6 +100,7 @@ class CLIPrompt {
84
100
  }
85
101
  // Annotate the CommonJS export names for ESM import in node:
86
102
  0 && (module.exports = {
87
- CLIPrompt
103
+ CLIPrompt,
104
+ NonInteractiveError
88
105
  });
89
106
  //# sourceMappingURL=prompt-utils.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/prompt-utils.ts"],
4
- "sourcesContent": ["import prompts from 'prompts'\nimport type { Logger } from '../logger'\n\nexport type CLIPromptsProps = {\n confirm: boolean\n}\n\nexport type CLIPromptsChoice<V extends string> = {\n title: string\n value: V\n}\n\nexport class CLIPrompt {\n constructor(private _props: CLIPromptsProps, private _logger: Logger) {}\n\n public async confirm(message: string): Promise<boolean> {\n if (this._props.confirm) {\n this._logger.debug(`Confirming automatically: ${message}`)\n return true\n }\n\n const { confirm } = await this._prompts({\n type: 'confirm',\n name: 'confirm',\n message,\n initial: false,\n })\n\n if (!confirm) {\n return false\n }\n return true\n }\n\n public async password(message: string, opts?: { initial?: string }): Promise<string | undefined> {\n const { prompted } = await this._prompts({\n type: 'password',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n public async select<V extends string>(\n message: string,\n opts?: { initial?: CLIPromptsChoice<V>; choices: CLIPromptsChoice<V>[] }\n ): Promise<V | undefined> {\n const { prompted } = await this._prompts({\n type: 'autocomplete',\n name: 'prompted',\n message,\n initial: opts?.initial?.value,\n choices: opts?.choices,\n })\n return prompted ? prompted : undefined\n }\n\n public async text(message: string, opts?: { initial?: string }): Promise<string | undefined> {\n const { prompted } = await this._prompts({\n type: 'text',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n private _prompts = (...args: Parameters<typeof prompts>): ReturnType<typeof prompts> => {\n this._logger.cleanup()\n return prompts(...args)\n }\n}\n"],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G,IAAI;AAAA,EACxB;AACF;",
4
+ "sourcesContent": ["import prompts from 'prompts'\nimport type { Logger } from '../logger'\n\nexport type CLIPromptsProps = {\n confirm: boolean\n}\n\nexport type CLIPromptsChoice<V extends string> = {\n title: string\n value: V\n}\n\nexport class NonInteractiveError extends Error {\n constructor(message: string) {\n super(`${message}:\\n Cannot prompt for input in non-interactive mode`)\n }\n}\n\nexport class CLIPrompt {\n constructor(private _props: CLIPromptsProps, private _logger: Logger) {}\n\n public async confirm(message: string): Promise<boolean> {\n if (this._props.confirm) {\n this._logger.debug(`Confirming automatically: ${message}`)\n return true\n }\n\n const { confirm } = await this._prompts({\n type: 'confirm',\n name: 'confirm',\n message,\n initial: false,\n })\n\n if (!confirm) {\n return false\n }\n return true\n }\n\n public async password(message: string, opts?: { initial?: string }): Promise<string | undefined> {\n if (this._props.confirm) {\n throw new NonInteractiveError(message)\n }\n\n const { prompted } = await this._prompts({\n type: 'password',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n public async select<V extends string>(\n message: string,\n opts?: { initial?: CLIPromptsChoice<V>; choices: CLIPromptsChoice<V>[] }\n ): Promise<V | undefined> {\n if (this._props.confirm) {\n throw new NonInteractiveError(message)\n }\n\n const { prompted } = await this._prompts({\n type: 'autocomplete',\n name: 'prompted',\n message,\n initial: opts?.initial?.value,\n choices: opts?.choices,\n })\n return prompted ? prompted : undefined\n }\n\n public async text(message: string, opts?: { initial?: string }): Promise<string | undefined> {\n if (this._props.confirm) {\n throw new NonInteractiveError(message)\n }\n\n const { prompted } = await this._prompts({\n type: 'text',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n private _prompts = (...args: Parameters<typeof prompts>): ReturnType<typeof prompts> => {\n this._logger.cleanup()\n return prompts(...args)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,q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,EAAE,SAAS,IAAI,MAAM,KAAK,SAAS;AAAA,MACvC,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,SAAS,MAAM;AAAA,IACjB,CAAC;AAED,WAAO,WAAW,WAAW;AAAA,EAC/B;AAAA,EAEQ,WAAW,IAAI,SAAiE;AACtF,SAAK,QAAQ,QAAQ;AACrB,eAAO,eAAAA,SAAQ,GAAG,IAAI;AAAA,EACxB;AACF;",
6
6
  "names": ["prompts"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -44,7 +44,7 @@
44
44
  "zod-to-json-schema": "^3.20.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@botpress/sdk": "0.1.2",
47
+ "@botpress/sdk": "0.1.3",
48
48
  "@types/bluebird": "^3.5.38",
49
49
  "@types/prompts": "^2.0.14",
50
50
  "@types/semver": "^7.3.11",
@@ -9,7 +9,7 @@
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
11
  "@botpress/client": "0.1.1",
12
- "@botpress/sdk": "0.1.2",
12
+ "@botpress/sdk": "0.1.3",
13
13
  "zod": "^3.20.6"
14
14
  },
15
15
  "devDependencies": {
@@ -9,7 +9,7 @@
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
11
  "@botpress/client": "0.1.1",
12
- "@botpress/sdk": "0.1.2",
12
+ "@botpress/sdk": "0.1.3",
13
13
  "zod": "^3.20.6"
14
14
  },
15
15
  "devDependencies": {