@botpress/cli 2.2.2 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
1
 
2
- > @botpress/cli@2.2.2 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@2.2.4 build /home/runner/work/botpress/botpress/packages/cli
3
3
  > pnpm run bundle && pnpm run template:gen
4
4
 
5
5
 
6
- > @botpress/cli@2.2.2 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@2.2.4 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@2.2.2 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@2.2.4 template:gen /home/runner/work/botpress/botpress/packages/cli
11
11
  > pnpm -r --stream -F @bp-templates/* exec bp gen
12
12
 
13
- šŸ¤– Botpress CLI v2.2.2
14
- šŸ¤– Botpress CLI v2.2.2
15
- šŸ¤– Botpress CLI v2.2.2
16
- šŸ¤– Botpress CLI v2.2.2
13
+ šŸ¤– Botpress CLI v2.2.4
14
+ šŸ¤– Botpress CLI v2.2.4
15
+ šŸ¤– Botpress CLI v2.2.4
16
+ šŸ¤– Botpress CLI v2.2.4
17
+ ā—‹ Generating typings for plugin empty-plugin...āœ“ Typings available at .botpress
18
+ ā—‹ Generating typings for integration empty-integration...ā—‹ Generating typings for integration hello-world...āœ“ Typings available at .botpress
17
19
  ā—‹ Generating typings for bot...āœ“ Typings available at .botpress
18
- ā—‹ Generating typings for integration empty-integration...āœ“ Typings available at .botpress
19
- ā—‹ Generating typings for integration hello-world...ā—‹ Generating typings for plugin empty-plugin...āœ“ Typings available at .botpress
20
20
  āœ“ Typings available at .botpress
21
- šŸ¤– Botpress CLI v2.2.2
21
+ šŸ¤– Botpress CLI v2.2.4
22
22
  ā—‹ Generating typings for integration webhook-message...āœ“ Typings available at .botpress
@@ -37,7 +37,7 @@ var gen = __toESM(require("../generators"));
37
37
  var import_integration_package_definition = require("./integration-package-definition");
38
38
  const generateIntegrationPackageModule = (definitionImport, pkg) => {
39
39
  const id = pkg.source === "remote" ? pkg.integration.id : pkg.devId;
40
- const uri = pkg.source === "local" ? utils.path.win32.escapeBackslashes(pkg.path) : void 0;
40
+ const uri = pkg.source === "local" ? utils.path.toNormalizedPosixPath(pkg.path) : void 0;
41
41
  const tsId = gen.primitiveToTypescriptValue(id);
42
42
  const tsUri = gen.primitiveToTypescriptValue(uri);
43
43
  const tsName = gen.primitiveToTypescriptValue(pkg.name);
@@ -46,7 +46,7 @@ const generateIntegrationPackageModule = (definitionImport, pkg) => {
46
46
  consts.GENERATED_HEADER,
47
47
  'import * as sdk from "@botpress/sdk"',
48
48
  "",
49
- `import definition from "${utils.path.win32.escapeBackslashes(definitionImport)}"`,
49
+ `import definition from "${utils.path.toNormalizedPosixPath(definitionImport)}"`,
50
50
  "",
51
51
  "export default {",
52
52
  ' type: "integration",',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/code-generation/integration-package/index.ts"],
4
- "sourcesContent": ["import * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as gen from '../generators'\nimport * as types from '../typings'\nimport { IntegrationPackageDefinitionModule } from './integration-package-definition'\n\nconst generateIntegrationPackageModule = (\n definitionImport: string,\n pkg: types.IntegrationInstallablePackage\n): string => {\n const id = pkg.source === 'remote' ? pkg.integration.id : pkg.devId\n const uri = pkg.source === 'local' ? utils.path.win32.escapeBackslashes(pkg.path) : undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(pkg.version)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${utils.path.win32.escapeBackslashes(definitionImport)}\"`,\n '',\n 'export default {',\n ' type: \"integration\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n '} satisfies sdk.IntegrationPackage',\n ].join('\\n')\n}\n\nconst generateIntegrationPackageFromRemote = async (\n pkg: Extract<types.IntegrationInstallablePackage, { source: 'remote' }>\n): Promise<types.File[]> => {\n const definitionDir = 'definition'\n const definitionModule = new IntegrationPackageDefinitionModule(pkg.integration)\n definitionModule.unshift(definitionDir)\n\n const definitionFiles = await definitionModule.flatten()\n return [\n ...definitionFiles,\n {\n path: consts.INDEX_FILE,\n content: generateIntegrationPackageModule(`./${definitionDir}`, pkg),\n },\n ]\n}\n\nconst generateIntegrationPackageFromLocal = async (\n pkg: Extract<types.IntegrationInstallablePackage, { source: 'local' }>\n): Promise<types.File[]> => {\n let definitionImport: string = utils.path.join(pkg.path, consts.fromWorkDir.integrationDefinition)\n definitionImport = utils.path.rmExtension(definitionImport)\n return [\n {\n path: consts.INDEX_FILE,\n content: generateIntegrationPackageModule(definitionImport, pkg),\n },\n ]\n}\n\nexport const generateIntegrationPackage = async (pkg: types.IntegrationInstallablePackage): Promise<types.File[]> => {\n if (pkg.source === 'remote') {\n return generateIntegrationPackageFromRemote(pkg)\n }\n return generateIntegrationPackageFromLocal(pkg)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,UAAqB;AAErB,4CAAmD;AAEnD,MAAM,mCAAmC,CACvC,kBACA,QACW;AACX,QAAM,KAAK,IAAI,WAAW,WAAW,IAAI,YAAY,KAAK,IAAI;AAC9D,QAAM,MAAM,IAAI,WAAW,UAAU,MAAM,KAAK,MAAM,kBAAkB,IAAI,IAAI,IAAI;AAEpF,QAAM,OAAO,IAAI,2BAA2B,EAAE;AAC9C,QAAM,QAAQ,IAAI,2BAA2B,GAAG;AAChD,QAAM,SAAS,IAAI,2BAA2B,IAAI,IAAI;AACtD,QAAM,YAAY,IAAI,2BAA2B,IAAI,OAAO;AAE5D,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,2BAA2B,MAAM,KAAK,MAAM,kBAAkB,gBAAgB;AAAA,IAC9E;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEA,MAAM,uCAAuC,OAC3C,QAC0B;AAC1B,QAAM,gBAAgB;AACtB,QAAM,mBAAmB,IAAI,yEAAmC,IAAI,WAAW;AAC/E,mBAAiB,QAAQ,aAAa;AAEtC,QAAM,kBAAkB,MAAM,iBAAiB,QAAQ;AACvD,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,iCAAiC,KAAK,iBAAiB,GAAG;AAAA,IACrE;AAAA,EACF;AACF;AAEA,MAAM,sCAAsC,OAC1C,QAC0B;AAC1B,MAAI,mBAA2B,MAAM,KAAK,KAAK,IAAI,MAAM,OAAO,YAAY,qBAAqB;AACjG,qBAAmB,MAAM,KAAK,YAAY,gBAAgB;AAC1D,SAAO;AAAA,IACL;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,iCAAiC,kBAAkB,GAAG;AAAA,IACjE;AAAA,EACF;AACF;AAEO,MAAM,6BAA6B,OAAO,QAAoE;AACnH,MAAI,IAAI,WAAW,UAAU;AAC3B,WAAO,qCAAqC,GAAG;AAAA,EACjD;AACA,SAAO,oCAAoC,GAAG;AAChD;",
4
+ "sourcesContent": ["import * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as gen from '../generators'\nimport * as types from '../typings'\nimport { IntegrationPackageDefinitionModule } from './integration-package-definition'\n\nconst generateIntegrationPackageModule = (\n definitionImport: string,\n pkg: types.IntegrationInstallablePackage\n): string => {\n const id = pkg.source === 'remote' ? pkg.integration.id : pkg.devId\n const uri = pkg.source === 'local' ? utils.path.toNormalizedPosixPath(pkg.path) : undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(pkg.version)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${utils.path.toNormalizedPosixPath(definitionImport)}\"`,\n '',\n 'export default {',\n ' type: \"integration\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n '} satisfies sdk.IntegrationPackage',\n ].join('\\n')\n}\n\nconst generateIntegrationPackageFromRemote = async (\n pkg: Extract<types.IntegrationInstallablePackage, { source: 'remote' }>\n): Promise<types.File[]> => {\n const definitionDir = 'definition'\n const definitionModule = new IntegrationPackageDefinitionModule(pkg.integration)\n definitionModule.unshift(definitionDir)\n\n const definitionFiles = await definitionModule.flatten()\n return [\n ...definitionFiles,\n {\n path: consts.INDEX_FILE,\n content: generateIntegrationPackageModule(`./${definitionDir}`, pkg),\n },\n ]\n}\n\nconst generateIntegrationPackageFromLocal = async (\n pkg: Extract<types.IntegrationInstallablePackage, { source: 'local' }>\n): Promise<types.File[]> => {\n let definitionImport: string = utils.path.join(pkg.path, consts.fromWorkDir.integrationDefinition)\n definitionImport = utils.path.rmExtension(definitionImport)\n return [\n {\n path: consts.INDEX_FILE,\n content: generateIntegrationPackageModule(definitionImport, pkg),\n },\n ]\n}\n\nexport const generateIntegrationPackage = async (pkg: types.IntegrationInstallablePackage): Promise<types.File[]> => {\n if (pkg.source === 'remote') {\n return generateIntegrationPackageFromRemote(pkg)\n }\n return generateIntegrationPackageFromLocal(pkg)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;A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AAEO,MAAM,6BAA6B,OAAO,QAAoE;AACnH,MAAI,IAAI,WAAW,UAAU;AAC3B,WAAO,qCAAqC,GAAG;AAAA,EACjD;AACA,SAAO,oCAAoC,GAAG;AAChD;",
6
6
  "names": []
7
7
  }
@@ -37,7 +37,7 @@ var gen = __toESM(require("../generators"));
37
37
  var import_interface_package_definition = require("./interface-package-definition");
38
38
  const generateInterfacePackageModule = (definitionImport, pkg) => {
39
39
  const id = pkg.source === "remote" ? pkg.interface.id : void 0;
40
- const uri = pkg.source === "local" ? utils.path.win32.escapeBackslashes(pkg.path) : void 0;
40
+ const uri = pkg.source === "local" ? utils.path.toNormalizedPosixPath(pkg.path) : void 0;
41
41
  const tsId = gen.primitiveToTypescriptValue(id);
42
42
  const tsUri = gen.primitiveToTypescriptValue(uri);
43
43
  const tsName = gen.primitiveToTypescriptValue(pkg.name);
@@ -46,7 +46,7 @@ const generateInterfacePackageModule = (definitionImport, pkg) => {
46
46
  consts.GENERATED_HEADER,
47
47
  'import * as sdk from "@botpress/sdk"',
48
48
  "",
49
- `import definition from "${utils.path.win32.escapeBackslashes(definitionImport)}"`,
49
+ `import definition from "${utils.path.toNormalizedPosixPath(definitionImport)}"`,
50
50
  "",
51
51
  "export default {",
52
52
  ' type: "interface",',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/code-generation/interface-package/index.ts"],
4
- "sourcesContent": ["import * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as gen from '../generators'\nimport * as types from '../typings'\nimport { InterfacePackageDefinitionModule } from './interface-package-definition'\n\nconst generateInterfacePackageModule = (definitionImport: string, pkg: types.InterfaceInstallablePackage): string => {\n const id = pkg.source === 'remote' ? pkg.interface.id : undefined\n const uri = pkg.source === 'local' ? utils.path.win32.escapeBackslashes(pkg.path) : undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(pkg.version)\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${utils.path.win32.escapeBackslashes(definitionImport)}\"`,\n '',\n 'export default {',\n ' type: \"interface\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n '} satisfies sdk.InterfacePackage',\n ].join('\\n')\n}\n\nconst generateInterfacePackageFromRemote = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'remote' }>\n): Promise<types.File[]> => {\n const definitionDir = 'definition'\n const definitionModule = new InterfacePackageDefinitionModule(pkg.interface)\n definitionModule.unshift(definitionDir)\n\n const definitionFiles = await definitionModule.flatten()\n return [\n ...definitionFiles,\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(`./${definitionDir}`, pkg),\n },\n ]\n}\n\nconst generateInterfacePackageFromLocal = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'local' }>\n): Promise<types.File[]> => {\n let definitionImport: string = utils.path.join(pkg.path, consts.fromWorkDir.interfaceDefinition)\n definitionImport = utils.path.rmExtension(definitionImport)\n return [\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(definitionImport, pkg),\n },\n ]\n}\n\nexport const generateInterfacePackage = async (pkg: types.InterfaceInstallablePackage): Promise<types.File[]> => {\n if (pkg.source === 'remote') {\n return generateInterfacePackageFromRemote(pkg)\n }\n return generateInterfacePackageFromLocal(pkg)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,UAAqB;AAErB,0CAAiD;AAEjD,MAAM,iCAAiC,CAAC,kBAA0B,QAAmD;AACnH,QAAM,KAAK,IAAI,WAAW,WAAW,IAAI,UAAU,KAAK;AACxD,QAAM,MAAM,IAAI,WAAW,UAAU,MAAM,KA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\nimport * as gen from '../generators'\nimport * as types from '../typings'\nimport { InterfacePackageDefinitionModule } from './interface-package-definition'\n\nconst generateInterfacePackageModule = (definitionImport: string, pkg: types.InterfaceInstallablePackage): string => {\n const id = pkg.source === 'remote' ? pkg.interface.id : undefined\n const uri = pkg.source === 'local' ? utils.path.toNormalizedPosixPath(pkg.path) : undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(pkg.version)\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${utils.path.toNormalizedPosixPath(definitionImport)}\"`,\n '',\n 'export default {',\n ' type: \"interface\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n '} satisfies sdk.InterfacePackage',\n ].join('\\n')\n}\n\nconst generateInterfacePackageFromRemote = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'remote' }>\n): Promise<types.File[]> => {\n const definitionDir = 'definition'\n const definitionModule = new InterfacePackageDefinitionModule(pkg.interface)\n definitionModule.unshift(definitionDir)\n\n const definitionFiles = await definitionModule.flatten()\n return [\n ...definitionFiles,\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(`./${definitionDir}`, pkg),\n },\n ]\n}\n\nconst generateInterfacePackageFromLocal = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'local' }>\n): Promise<types.File[]> => {\n let definitionImport: string = utils.path.join(pkg.path, consts.fromWorkDir.interfaceDefinition)\n definitionImport = utils.path.rmExtension(definitionImport)\n return [\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(definitionImport, pkg),\n },\n ]\n}\n\nexport const generateInterfacePackage = async (pkg: types.InterfaceInstallablePackage): Promise<types.File[]> => {\n if (pkg.source === 'remote') {\n return generateInterfacePackageFromRem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;AAC1D,SAAO;AAAA,IACL;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,+BAA+B,kBAAkB,GAAG;AAAA,IAC/D;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,OAAO,QAAkE;AAC/G,MAAI,IAAI,WAAW,UAAU;AAC3B,WAAO,mCAAmC,GAAG;AAAA,EAC/C;AACA,SAAO,kCAAkC,GAAG;AAC9C;",
6
6
  "names": []
7
7
  }
@@ -70,9 +70,9 @@ class LocalPluginModule extends mod.Module {
70
70
  async getContent() {
71
71
  const implImport = this._implModule.import(this);
72
72
  const id = void 0;
73
- const uri = utils.path.win32.escapeBackslashes(this._pkg.path);
74
- const definitionImport = utils.path.rmExtension(
75
- utils.path.join(this._pkg.path, consts.fromWorkDir.pluginDefinition)
73
+ const uri = utils.path.toNormalizedPosixPath(this._pkg.path);
74
+ const definitionImport = utils.path.toNormalizedPosixPath(
75
+ utils.path.rmExtension(utils.path.join(this._pkg.path, consts.fromWorkDir.pluginDefinition))
76
76
  );
77
77
  const tsId = gen.primitiveToTypescriptValue(id);
78
78
  const tsUri = gen.primitiveToTypescriptValue(uri);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/code-generation/plugin-package/index.ts"],
4
- "sourcesContent": ["import _ from 'lodash'\nimport * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as gen from '../generators'\nimport * as mod from '../module'\nimport * as types from '../typings'\nimport { PluginPackageDefinitionModule } from './plugin-package-definition'\n\nclass ImplementationModule extends mod.Module {\n public constructor(private _implementationCode: string) {\n super({\n path: 'implementation.ts',\n exportName: 'default',\n })\n }\n\n public async getContent(): Promise<string> {\n const base64Str = Buffer.from(this._implementationCode).toString('base64')\n const chunks: string[] = _.chunk(base64Str, 80).map((chunk) => chunk.join(''))\n\n return [\n //\n 'export default Buffer.from([',\n ...chunks.map((chunk) => ` \"${chunk}\",`),\n '].join(\"\"), \"base64\")',\n ].join('\\n')\n }\n}\n\nclass LocalPluginModule extends mod.Module {\n private _implModule: ImplementationModule\n\n public constructor(private _pkg: Extract<types.PluginInstallablePackage, { source: 'local' }>) {\n super({\n path: consts.INDEX_FILE,\n exportName: consts.DEFAULT_EXPORT_NAME,\n })\n\n this._implModule = new ImplementationModule(this._pkg.implementationCode)\n this.pushDep(this._implModule)\n }\n\n public async getContent(): Promise<string> {\n const implImport = this._implModule.import(this)\n\n const id = undefined\n const uri = utils.path.win32.escapeBackslashes(this._pkg.path)\n\n const definitionImport = utils.path.rmExtension(\n utils.path.join(this._pkg.path, consts.fromWorkDir.pluginDefinition)\n )\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(this._pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(this._pkg.version)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${definitionImport}\"`,\n `import implementation from \"./${implImport}\"`,\n '',\n 'export default {',\n ' type: \"plugin\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n ' implementation,',\n '} satisfies sdk.PluginPackage',\n ].join('\\n')\n }\n}\n\nclass RemotePluginModule extends mod.Module {\n private _implModule: ImplementationModule\n private _defModule: PluginPackageDefinitionModule\n\n public constructor(private _pkg: Extract<types.PluginInstallablePackage, { source: 'remote' }>) {\n super({\n path: consts.INDEX_FILE,\n exportName: consts.DEFAULT_EXPORT_NAME,\n })\n\n this._implModule = new ImplementationModule(this._pkg.plugin.code)\n this.pushDep(this._implModule)\n\n this._defModule = new PluginPackageDefinitionModule(this._pkg.plugin)\n this._defModule.unshift('definition')\n this.pushDep(this._defModule)\n }\n\n public async getContent(): Promise<string> {\n const implImport = this._implModule.import(this)\n const defImport = this._defModule.import(this)\n\n const id = this._pkg.plugin.id\n const uri = undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(this._pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(this._pkg.version)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"./${defImport}\"`,\n `import implementation from \"./${implImport}\"`,\n '',\n 'export default {',\n ' type: \"plugin\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n ' implementation,',\n '} satisfies sdk.PluginPackage',\n ].join('\\n')\n }\n}\n\nexport const generatePluginPackage = async (pkg: types.PluginInstallablePackage): Promise<types.File[]> => {\n const module = pkg.source === 'local' ? new LocalPluginModule(pkg) : new RemotePluginModule(pkg)\n return module.flatten()\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc;AACd,YAAuB;AACvB,aAAwB;AACxB,UAAqB;AACrB,UAAqB;AAErB,uCAA8C;AAE9C,MAAM,6BAA6B,IAAI,OAAO;AAAA,EACrC,YAAoB,qBAA6B;AACtD,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AAJwB;AAAA,EAK3B;AAAA,EAEA,MAAa,aAA8B;AACzC,UAAM,YAAY,OAAO,KAAK,KAAK,mBAAmB,EAAE,SAAS,QAAQ;AACzE,UAAM,SAAmB,cAAAA,QAAE,MAAM,WAAW,EAAE,EAAE,IAAI,CAAC,UAAU,MAAM,KAAK,EAAE,CAAC;AAE7E,WAAO;AAAA;AAAA,MAEL;AAAA,MACA,GAAG,OAAO,IAAI,CAAC,UAAU,MAAM,SAAS;AAAA,MACxC;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEA,MAAM,0BAA0B,IAAI,OAAO;AAAA,EAGlC,YAAoB,MAAoE;AAC7F,UAAM;AAAA,MACJ,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;AAAA,EAC9B;AAAA,EAfQ;AAAA,EACA;AAAA,EAgBR,MAAa,aAA8B;AACzC,UAAM,aAAa,KAAK,YAAY,OAAO,IAAI;AAC/C,UAAM,YAAY,KAAK,WAAW,OAAO,IAAI;AAE7C,UAAM,KAAK,KAAK,KAAK,OAAO;AAC5B,UAAM,MAAM;AAEZ,UAAM,OAAO,IAAI,2BAA2B,EAAE;AAC9C,UAAM,QAAQ,IAAI,2BAA2B,GAAG;AAChD,UAAM,SAAS,IAAI,2BAA2B,KAAK,KAAK,IAAI;AAC5D,UAAM,YAAY,IAAI,2BAA2B,KAAK,KAAK,OAAO;AAElE,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,6BAA6B;AAAA,MAC7B,iCAAiC;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,MACX,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,wBAAwB,OAAO,QAA+D;AACzG,QAAMC,UAAS,IAAI,WAAW,UAAU,IAAI,kBAAkB,GAAG,IAAI,IAAI,mBAAmB,GAAG;AAC/F,SAAOA,QAAO,QAAQ;AACxB;",
4
+ "sourcesContent": ["import _ from 'lodash'\nimport * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as gen from '../generators'\nimport * as mod from '../module'\nimport * as types from '../typings'\nimport { PluginPackageDefinitionModule } from './plugin-package-definition'\n\nclass ImplementationModule extends mod.Module {\n public constructor(private _implementationCode: string) {\n super({\n path: 'implementation.ts',\n exportName: 'default',\n })\n }\n\n public async getContent(): Promise<string> {\n const base64Str = Buffer.from(this._implementationCode).toString('base64')\n const chunks: string[] = _.chunk(base64Str, 80).map((chunk) => chunk.join(''))\n\n return [\n //\n 'export default Buffer.from([',\n ...chunks.map((chunk) => ` \"${chunk}\",`),\n '].join(\"\"), \"base64\")',\n ].join('\\n')\n }\n}\n\nclass LocalPluginModule extends mod.Module {\n private _implModule: ImplementationModule\n\n public constructor(private _pkg: Extract<types.PluginInstallablePackage, { source: 'local' }>) {\n super({\n path: consts.INDEX_FILE,\n exportName: consts.DEFAULT_EXPORT_NAME,\n })\n\n this._implModule = new ImplementationModule(this._pkg.implementationCode)\n this.pushDep(this._implModule)\n }\n\n public async getContent(): Promise<string> {\n const implImport = this._implModule.import(this)\n\n const id = undefined\n const uri = utils.path.toNormalizedPosixPath(this._pkg.path)\n\n const definitionImport = utils.path.toNormalizedPosixPath(\n utils.path.rmExtension(utils.path.join(this._pkg.path, consts.fromWorkDir.pluginDefinition))\n )\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(this._pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(this._pkg.version)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${definitionImport}\"`,\n `import implementation from \"./${implImport}\"`,\n '',\n 'export default {',\n ' type: \"plugin\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n ' implementation,',\n '} satisfies sdk.PluginPackage',\n ].join('\\n')\n }\n}\n\nclass RemotePluginModule extends mod.Module {\n private _implModule: ImplementationModule\n private _defModule: PluginPackageDefinitionModule\n\n public constructor(private _pkg: Extract<types.PluginInstallablePackage, { source: 'remote' }>) {\n super({\n path: consts.INDEX_FILE,\n exportName: consts.DEFAULT_EXPORT_NAME,\n })\n\n this._implModule = new ImplementationModule(this._pkg.plugin.code)\n this.pushDep(this._implModule)\n\n this._defModule = new PluginPackageDefinitionModule(this._pkg.plugin)\n this._defModule.unshift('definition')\n this.pushDep(this._defModule)\n }\n\n public async getContent(): Promise<string> {\n const implImport = this._implModule.import(this)\n const defImport = this._defModule.import(this)\n\n const id = this._pkg.plugin.id\n const uri = undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(this._pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(this._pkg.version)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"./${defImport}\"`,\n `import implementation from \"./${implImport}\"`,\n '',\n 'export default {',\n ' type: \"plugin\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n ' implementation,',\n '} satisfies sdk.PluginPackage',\n ].join('\\n')\n }\n}\n\nexport const generatePluginPackage = async (pkg: types.PluginInstallablePackage): Promise<types.File[]> => {\n const module = pkg.source === 'local' ? new LocalPluginModule(pkg) : new RemotePluginModule(pkg)\n return module.flatten()\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc;AACd,YAAuB;AACvB,aAAwB;AACxB,UAAqB;AACrB,UAAqB;AAErB,uCAA8C;AAE9C,MAAM,6BAA6B,IAAI,OAAO;AAAA,EACrC,YAAoB,qBAA6B;AACtD,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AAJwB;AAAA,EAK3B;AAAA,EAEA,MAAa,aAA8B;AACzC,UAAM,YAAY,OAAO,KAAK,KAAK,mBAAmB,EAAE,SAAS,QAAQ;AACzE,UAAM,SAAmB,cAAAA,QAAE,MAAM,WAAW,EAAE,EAAE,IAAI,CAAC,UAAU,MAAM,KAAK,EAAE,CAAC;AAE7E,WAAO;AAAA;AAAA,MAEL;AAAA,MACA,GAAG,OAAO,IAAI,CAAC,UAAU,MAAM,SAAS;AAAA,MACxC;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEA,MAAM,0BAA0B,IAAI,OAAO;AA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K,MAAM;AACpE,SAAK,WAAW,QAAQ,YAAY;AACpC,SAAK,QAAQ,KAAK,UAAU;AAAA,EAC9B;AAAA,EAfQ;AAAA,EACA;AAAA,EAgBR,MAAa,aAA8B;AACzC,UAAM,aAAa,KAAK,YAAY,OAAO,IAAI;AAC/C,UAAM,YAAY,KAAK,WAAW,OAAO,IAAI;AAE7C,UAAM,KAAK,KAAK,KAAK,OAAO;AAC5B,UAAM,MAAM;AAEZ,UAAM,OAAO,IAAI,2BAA2B,EAAE;AAC9C,UAAM,QAAQ,IAAI,2BAA2B,GAAG;AAChD,UAAM,SAAS,IAAI,2BAA2B,KAAK,KAAK,IAAI;AAC5D,UAAM,YAAY,IAAI,2BAA2B,KAAK,KAAK,OAAO;AAElE,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,6BAA6B;AAAA,MAC7B,iCAAiC;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,MACX,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,wBAAwB,OAAO,QAA+D;AACzG,QAAMC,UAAS,IAAI,WAAW,UAAU,IAAI,kBAAkB,GAAG,IAAI,IAAI,mBAAmB,GAAG;AAC/F,SAAOA,QAAO,QAAQ;AACxB;",
6
6
  "names": ["_", "module"]
7
7
  }
@@ -44,9 +44,9 @@ class BundleCommand extends import_project_command.ProjectCommand {
44
44
  }
45
45
  const line = this.logger.line();
46
46
  if (projectDef.type === "integration") {
47
- const { name } = projectDef.definition;
47
+ const { name, __advanced } = projectDef.definition;
48
48
  line.started(`Bundling integration ${import_chalk.default.bold(name)}...`);
49
- return await this._bundle(line);
49
+ return await this._bundle(line, __advanced?.esbuild ?? {});
50
50
  }
51
51
  if (projectDef.type === "bot") {
52
52
  line.started("Bundling bot...");
@@ -59,23 +59,24 @@ class BundleCommand extends import_project_command.ProjectCommand {
59
59
  throw new errors.UnsupportedProjectType();
60
60
  }
61
61
  async _bundle(line, props = {}) {
62
- const logLevel = this.argv.verbose ? "info" : "silent";
63
62
  const abs = this.projectPaths.abs;
64
63
  const rel = this.projectPaths.rel("workDir");
65
64
  const unixPath = utils.path.toUnix(rel.entryPoint);
66
65
  const importFrom = utils.path.rmExtension(unixPath);
67
66
  const code = `import x from './${importFrom}'; export default x; export const handler = x.handler;`;
68
- const outfile = abs.outFile;
69
- line.debug(`Writing bundle to ${outfile}`);
70
- await utils.esbuild.buildCode({
71
- code,
72
- cwd: abs.workDir,
73
- outfile,
74
- logLevel,
75
- write: true,
67
+ line.debug(`Writing bundle to ${abs.outFile}`);
68
+ const buildOptions = {
69
+ logLevel: this.argv.verbose ? "info" : "silent",
76
70
  sourcemap: this.argv.sourceMap,
77
71
  minify: this.argv.minify,
78
72
  ...props
73
+ };
74
+ await utils.esbuild.buildCode({
75
+ ...buildOptions,
76
+ absWorkingDir: abs.workDir,
77
+ outfile: abs.outFile,
78
+ write: true,
79
+ code
79
80
  });
80
81
  line.success(`Bundle available at ${import_chalk.default.grey(rel.outDir)}`);
81
82
  }
@@ -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 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;",
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, __advanced } = projectDef.definition\n line.started(`Bundling integration ${chalk.bold(name)}...`)\n return await this._bundle(line, __advanced?.esbuild ?? {})\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.BuildOptions> = {}) {\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 line.debug(`Writing bundle to ${abs.outFile}`)\n\n const buildOptions: Partial<utils.esbuild.BuildOptions> = {\n logLevel: this.argv.verbose ? 'info' : 'silent',\n sourcemap: this.argv.sourceMap,\n minify: this.argv.minify,\n ...props,\n }\n\n await utils.esbuild.buildCode({\n ...buildOptions,\n absWorkingDir: abs.workDir,\n outfile: abs.outFile,\n write: true,\n code,\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,MAAM,WAAW,IAAI,WAAW;AACxC,WAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,IAAI,MAAM;AAC1D,aAAO,MAAM,KAAK,QAAQ,MAAM,YAAY,WAAW,CAAC,CAAC;AAAA,IAC3D;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,QAA6C,CAAC,GAAG;AAC7F,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,SAAK,MAAM,qBAAqB,IAAI,SAAS;AAE7C,UAAM,eAAoD;AAAA,MACxD,UAAU,KAAK,KAAK,UAAU,SAAS;AAAA,MACvC,WAAW,KAAK,KAAK;AAAA,MACrB,QAAQ,KAAK,KAAK;AAAA,MAClB,GAAG;AAAA,IACL;AAEA,UAAM,MAAM,QAAQ,UAAU;AAAA,MAC5B,GAAG;AAAA,MACH,eAAe,IAAI;AAAA,MACnB,SAAS,IAAI;AAAA,MACb,OAAO;AAAA,MACP;AAAA,IACF,CAAC;AAED,SAAK,QAAQ,uBAAuB,aAAAA,QAAM,KAAK,IAAI,MAAM,GAAG;AAAA,EAC9D;AACF;",
6
6
  "names": ["chalk"]
7
7
  }
@@ -126,8 +126,7 @@ class ProjectCommand extends import_global_command.GlobalCommand {
126
126
  }
127
127
  const bpLintDisabled = await this._isBpLintDisabled(abs.integrationDefinition);
128
128
  const { outputFiles } = await utils.esbuild.buildEntrypoint({
129
- cwd: abs.workDir,
130
- outfile: "",
129
+ absWorkingDir: abs.workDir,
131
130
  entrypoint: rel.integrationDefinition,
132
131
  write: false,
133
132
  minify: false
@@ -149,8 +148,7 @@ class ProjectCommand extends import_global_command.GlobalCommand {
149
148
  }
150
149
  const bpLintDisabled = await this._isBpLintDisabled(abs.interfaceDefinition);
151
150
  const { outputFiles } = await utils.esbuild.buildEntrypoint({
152
- cwd: abs.workDir,
153
- outfile: "",
151
+ absWorkingDir: abs.workDir,
154
152
  entrypoint: rel.interfaceDefinition,
155
153
  write: false,
156
154
  minify: false
@@ -170,8 +168,7 @@ class ProjectCommand extends import_global_command.GlobalCommand {
170
168
  }
171
169
  const bpLintDisabled = await this._isBpLintDisabled(abs.botDefinition);
172
170
  const { outputFiles } = await utils.esbuild.buildEntrypoint({
173
- cwd: abs.workDir,
174
- outfile: "",
171
+ absWorkingDir: abs.workDir,
175
172
  entrypoint: rel.botDefinition,
176
173
  write: false,
177
174
  minify: false
@@ -193,8 +190,7 @@ class ProjectCommand extends import_global_command.GlobalCommand {
193
190
  }
194
191
  const bpLintDisabled = await this._isBpLintDisabled(abs.pluginDefinition);
195
192
  const { outputFiles } = await utils.esbuild.buildEntrypoint({
196
- cwd: abs.workDir,
197
- outfile: "",
193
+ absWorkingDir: abs.workDir,
198
194
  entrypoint: rel.pluginDefinition,
199
195
  write: false,
200
196
  minify: false
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/project-command.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatPackageRef, PackageRef } from '../package-ref'\nimport { validateIntegrationDefinition, resolveInterfaces, resolveBotInterfaces, validateBotDefinition } from '../sdk'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { workDir: string }\ntype ConstantProjectPaths = typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype IntegrationInstance = NonNullable<sdk.BotDefinition['integrations']>[string]\ntype RemoteIntegrationInstance = utils.types.Merge<IntegrationInstance, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<IntegrationInstance, { uri?: string }>\ntype BotIntegrationRequest = NonNullable<NonNullable<client.ClientInputs['updateBot']['integrations']>[string]>\n\ntype LintIgnoredConfig = { bpLintDisabled?: boolean }\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition = LintIgnoredConfig &\n (\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDefinition }\n | { type: 'bot'; definition: sdk.BotDefinition }\n | { type: 'plugin'; definition: sdk.PluginDefinition }\n )\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n super({\n workDir: absWorkDir,\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async fetchBotIntegrationInstances(\n botDefinition: sdk.BotDefinition,\n api: ApiClient\n ): Promise<Record<string, BotIntegrationRequest>> {\n const integrationList = _(botDefinition.integrations).values().filter(utils.guards.is.defined).value()\n\n const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: RemoteIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: PackageRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatPackageRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return _([...fetchedInstances, ...remoteInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configurationType, configuration }) => ({\n enabled,\n configurationType: configurationType ?? null,\n configuration,\n }))\n .value()\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: IntegrationInstance[]): {\n remoteInstances: RemoteIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const remoteInstances: RemoteIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const instance of instances) {\n const { id } = instance\n if (id) {\n remoteInstances.push({ ...instance, id })\n } else {\n localInstances.push(instance)\n }\n }\n\n return { remoteInstances, localInstances }\n }\n\n protected async readProjectDefinitionFromFS(): Promise<ProjectDefinition> {\n const projectPaths = this.projectPaths\n try {\n const integrationDefinition = await this._readIntegrationDefinitionFromFS(projectPaths)\n if (integrationDefinition) {\n return { type: 'integration', ...integrationDefinition }\n }\n const interfaceDefinition = await this._readInterfaceDefinitionFromFS(projectPaths)\n if (interfaceDefinition) {\n return { type: 'interface', ...interfaceDefinition }\n }\n const botDefinition = await this._readBotDefinitionFromFS(projectPaths)\n if (botDefinition) {\n return { type: 'bot', ...botDefinition }\n }\n const pluginDefinition = await this._readPluginDefinitionFromFS(projectPaths)\n if (pluginDefinition) {\n return { type: 'plugin', ...pluginDefinition }\n }\n } catch (thrown: unknown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Error while reading project definition')\n }\n\n throw new errors.ProjectDefinitionNotFoundError(this.projectPaths.abs.workDir)\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'>\n ): Promise<({ definition: sdk.IntegrationDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.integrationDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.integrationDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n let { default: definition } = utils.require.requireJsCode<{ default: sdk.IntegrationDefinition }>(artifact.text)\n definition = resolveInterfaces(definition)\n validateIntegrationDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'>\n ): Promise<({ definition: sdk.InterfaceDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.interfaceDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.interfaceDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.InterfaceDefinition }>(artifact.text)\n\n return { definition, bpLintDisabled }\n }\n\n private async _readBotDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'botDefinition'>\n ): Promise<({ definition: sdk.BotDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.botDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.botDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.botDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n let { default: definition } = utils.require.requireJsCode<{ default: sdk.BotDefinition }>(artifact.text)\n definition = resolveBotInterfaces(definition)\n validateBotDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readPluginDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'pluginDefinition'>\n ): Promise<({ definition: sdk.PluginDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.pluginDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.pluginDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.pluginDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.PluginDefinition }>(artifact.text)\n // TODO: validate plugin definition\n return { definition, bpLintDisabled }\n }\n\n private async _isBpLintDisabled(definitionPath: string): Promise<boolean> {\n const tsContent = await fs.promises.readFile(definitionPath, 'utf-8')\n const regex = /\\/\\* bplint-disable \\*\\//\n return regex.test(tsContent)\n }\n\n protected displayWebhookUrls(bot: client.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: sdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = integrationDef\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n protected async readIntegrationConfigDefinition<C extends client.ClientInputs['createIntegration']['configuration']>(\n config: C\n ): Promise<C> {\n if (!config?.identifier) {\n return config\n }\n return {\n ...config,\n identifier: {\n ...config.identifier,\n linkTemplateScript: await this.readProjectFile(config.identifier.linkTemplateScript),\n },\n }\n }\n\n protected readProjectFile = async (filePath: string | undefined): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'utf-8').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = utils.string.splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if sdk is up to date: ${err.message}`)\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAqB;AACrB,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,oBAAmB;AAEnB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,yBAA6C;AAC7C,iBAA8G;AAE9G,YAAuB;AACvB,4BAA8B;AAyB9B,MAAM,qBAAqB,MAAM,KAAK,UAAiC;AAAA,EAC9D,YAAY,MAA6C;AAC9D,UAAM,aAAa,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,OAAO;AACzE,UAAM;AAAA,MACJ,SAAS;AAAA,MACT,GAAG,cAAAA,QAAE,UAAU,OAAO,aAAa,CAAC,MA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B,aAAK,OAAO,MAAM,wBAAwB,2CAA2C;AACrF;AAAA,MACF;AAEA,YAAM,aAAa,MAAM,KAAK,YAAY;AAC1C,YAAM,qBAAqB,MAAM,QAAQ,eAAe,YAAY,cAAc;AAClF,UAAI,CAAC,oBAAoB;AACvB,aAAK,OAAO,MAAM,8BAA8B,qCAAqC;AACrF;AAAA,MACF;AAEA,YAAM,4BAA4B,cAAAA,QAAO,MAAM,cAAAA,QAAO,OAAO,kBAAkB,CAAC;AAChF,UAAI,CAAC,2BAA2B;AAC9B,aAAK,OAAO,MAAM,wBAAwB,yCAAyC;AACnF;AAAA,MACF;AAEA,UAAI,cAAAA,QAAO,GAAG,yBAAyB,yBAAyB,GAAG;AACjE;AAAA,MACF;AAEA,YAAM,OAAO,cAAAA,QAAO,KAAK,yBAAyB,yBAAyB;AAC3E,UAAI,CAAC,MAAM;AACT,aAAK,OAAO,MAAM,+BAA+B,iCAAiC,4BAA4B;AAC9G;AAAA,MACF;AAEA,YAAM,WAAW,2BAA2B,2CAA2C;AACvF,UAAI,MAAM,OAAO,SAAS,GAAG,MAAM,OAAO,GAAG;AAC3C,aAAK,OAAO,MAAM,GAAG,gDAAgD;AACrE;AAAA,MACF;AAEA,WAAK,OAAO,KAAK,aAAAD,QAAM,KAAK,GAAG,iDAAiD,CAAC;AAAA,IACnF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatPackageRef, PackageRef } from '../package-ref'\nimport { validateIntegrationDefinition, resolveInterfaces, resolveBotInterfaces, validateBotDefinition } from '../sdk'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { workDir: string }\ntype ConstantProjectPaths = typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype IntegrationInstance = NonNullable<sdk.BotDefinition['integrations']>[string]\ntype RemoteIntegrationInstance = utils.types.Merge<IntegrationInstance, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<IntegrationInstance, { uri?: string }>\ntype BotIntegrationRequest = NonNullable<NonNullable<client.ClientInputs['updateBot']['integrations']>[string]>\n\ntype LintIgnoredConfig = { bpLintDisabled?: boolean }\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition = LintIgnoredConfig &\n (\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDefinition }\n | { type: 'bot'; definition: sdk.BotDefinition }\n | { type: 'plugin'; definition: sdk.PluginDefinition }\n )\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n super({\n workDir: absWorkDir,\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async fetchBotIntegrationInstances(\n botDefinition: sdk.BotDefinition,\n api: ApiClient\n ): Promise<Record<string, BotIntegrationRequest>> {\n const integrationList = _(botDefinition.integrations).values().filter(utils.guards.is.defined).value()\n\n const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: RemoteIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: PackageRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatPackageRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return _([...fetchedInstances, ...remoteInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configurationType, configuration }) => ({\n enabled,\n configurationType: configurationType ?? null,\n configuration,\n }))\n .value()\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: IntegrationInstance[]): {\n remoteInstances: RemoteIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const remoteInstances: RemoteIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const instance of instances) {\n const { id } = instance\n if (id) {\n remoteInstances.push({ ...instance, id })\n } else {\n localInstances.push(instance)\n }\n }\n\n return { remoteInstances, localInstances }\n }\n\n protected async readProjectDefinitionFromFS(): Promise<ProjectDefinition> {\n const projectPaths = this.projectPaths\n try {\n const integrationDefinition = await this._readIntegrationDefinitionFromFS(projectPaths)\n if (integrationDefinition) {\n return { type: 'integration', ...integrationDefinition }\n }\n const interfaceDefinition = await this._readInterfaceDefinitionFromFS(projectPaths)\n if (interfaceDefinition) {\n return { type: 'interface', ...interfaceDefinition }\n }\n const botDefinition = await this._readBotDefinitionFromFS(projectPaths)\n if (botDefinition) {\n return { type: 'bot', ...botDefinition }\n }\n const pluginDefinition = await this._readPluginDefinitionFromFS(projectPaths)\n if (pluginDefinition) {\n return { type: 'plugin', ...pluginDefinition }\n }\n } catch (thrown: unknown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Error while reading project definition')\n }\n\n throw new errors.ProjectDefinitionNotFoundError(this.projectPaths.abs.workDir)\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'>\n ): Promise<({ definition: sdk.IntegrationDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.integrationDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.integrationDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n let { default: definition } = utils.require.requireJsCode<{ default: sdk.IntegrationDefinition }>(artifact.text)\n definition = resolveInterfaces(definition)\n validateIntegrationDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'>\n ): Promise<({ definition: sdk.InterfaceDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.interfaceDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.interfaceDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.InterfaceDefinition }>(artifact.text)\n\n return { definition, bpLintDisabled }\n }\n\n private async _readBotDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'botDefinition'>\n ): Promise<({ definition: sdk.BotDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.botDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.botDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.botDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n let { default: definition } = utils.require.requireJsCode<{ default: sdk.BotDefinition }>(artifact.text)\n definition = resolveBotInterfaces(definition)\n validateBotDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readPluginDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'pluginDefinition'>\n ): Promise<({ definition: sdk.PluginDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.pluginDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.pluginDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.pluginDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.PluginDefinition }>(artifact.text)\n // TODO: validate plugin definition\n return { definition, bpLintDisabled }\n }\n\n private async _isBpLintDisabled(definitionPath: string): Promise<boolean> {\n const tsContent = await fs.promises.readFile(definitionPath, 'utf-8')\n const regex = /\\/\\* bplint-disable \\*\\//\n return regex.test(tsContent)\n }\n\n protected displayWebhookUrls(bot: client.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: sdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = integrationDef\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n protected async readIntegrationConfigDefinition<C extends client.ClientInputs['createIntegration']['configuration']>(\n config: C\n ): Promise<C> {\n if (!config?.identifier) {\n return config\n }\n return {\n ...config,\n identifier: {\n ...config.identifier,\n linkTemplateScript: await this.readProjectFile(config.identifier.linkTemplateScript),\n },\n }\n }\n\n protected readProjectFile = async (filePath: string | undefined): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'utf-8').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = utils.string.splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if sdk is up to date: ${err.message}`)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAqB;AACrB,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,oBAAmB;AAEnB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,yBAA6C;AAC7C,iBAA8G;AAE9G,YAAuB;AACvB,4BAA8B;AAyB9B,MAAM,qBAAqB,MAAM,KAAK,UAAiC;AAAA,EAC9D,YAAY,MAA6C;AAC9D,UAAM,aAAa,MAAM,KAAK,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cAAAA,QAAO,OAAO,gBAAgB,CAAC;AAC5E,UAAI,CAAC,yBAAyB;AAC5B,aAAK,OAAO,MAAM,wBAAwB,2CAA2C;AACrF;AAAA,MACF;AAEA,YAAM,aAAa,MAAM,KAAK,YAAY;AAC1C,YAAM,qBAAqB,MAAM,QAAQ,eAAe,YAAY,cAAc;AAClF,UAAI,CAAC,oBAAoB;AACvB,aAAK,OAAO,MAAM,8BAA8B,qCAAqC;AACrF;AAAA,MACF;AAEA,YAAM,4BAA4B,cAAAA,QAAO,MAAM,cAAAA,QAAO,OAAO,kBAAkB,CAAC;AAChF,UAAI,CAAC,2BAA2B;AAC9B,aAAK,OAAO,MAAM,wBAAwB,yCAAyC;AACnF;AAAA,MACF;AAEA,UAAI,cAAAA,QAAO,GAAG,yBAAyB,yBAAyB,GAAG;AACjE;AAAA,MACF;AAEA,YAAM,OAAO,cAAAA,QAAO,KAAK,yBAAyB,yBAAyB;AAC3E,UAAI,CAAC,MAAM;AACT,aAAK,OAAO,MAAM,+BAA+B,iCAAiC,4BAA4B;AAC9G;AAAA,MACF;AAEA,YAAM,WAAW,2BAA2B,2CAA2C;AACvF,UAAI,MAAM,OAAO,SAAS,GAAG,MAAM,OAAO,GAAG;AAC3C,aAAK,OAAO,MAAM,GAAG,gDAAgD;AACrE;AAAA,MACF;AAEA,WAAK,OAAO,KAAK,aAAAD,QAAM,KAAK,GAAG,iDAAiD,CAAC;AAAA,IACnF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AACF;",
6
6
  "names": ["_", "bluebird", "fs", "chalk", "semver"]
7
7
  }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,15 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
18
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
30
  var esbuild_utils_exports = {};
20
31
  __export(esbuild_utils_exports, {
@@ -22,66 +33,38 @@ __export(esbuild_utils_exports, {
22
33
  buildEntrypoint: () => buildEntrypoint
23
34
  });
24
35
  module.exports = __toCommonJS(esbuild_utils_exports);
25
- var import_esbuild = require("esbuild");
26
- const keepNames = true;
27
- function buildCode({
28
- cwd,
29
- minify = true,
30
- bundle = true,
31
- sourcemap = false,
32
- logLevel = "silent",
33
- outfile,
34
- code,
35
- write,
36
- platform = "node"
37
- }) {
38
- return (0, import_esbuild.build)({
36
+ var esb = __toESM(require("esbuild"));
37
+ __reExport(esbuild_utils_exports, require("esbuild"), module.exports);
38
+ const DEFAULT_OPTIONS = {
39
+ bundle: true,
40
+ sourcemap: false,
41
+ logLevel: "silent",
42
+ platform: "node",
43
+ target: "es2020",
44
+ legalComments: "none",
45
+ logOverride: { "equals-negative-zero": "silent" },
46
+ keepNames: true
47
+ // important : https://github.com/node-fetch/node-fetch/issues/784#issuecomment-1014768204
48
+ };
49
+ function buildCode(p) {
50
+ const { code, ...props } = p;
51
+ return esb.build({
52
+ ...DEFAULT_OPTIONS,
53
+ ...props,
39
54
  stdin: {
40
55
  contents: code,
41
- resolveDir: cwd,
56
+ resolveDir: props.absWorkingDir,
42
57
  loader: "ts"
43
- },
44
- logOverride: {
45
- "equals-negative-zero": "silent"
46
- },
47
- platform,
48
- target: "es2020",
49
- sourcemap,
50
- minify,
51
- bundle,
52
- outfile,
53
- absWorkingDir: cwd,
54
- logLevel,
55
- keepNames,
56
- write,
57
- legalComments: "none"
58
+ }
58
59
  });
59
60
  }
60
- function buildEntrypoint({
61
- cwd,
62
- minify = true,
63
- bundle = true,
64
- sourcemap = false,
65
- logLevel = "silent",
66
- outfile,
67
- entrypoint,
68
- write
69
- }) {
70
- return (0, import_esbuild.build)({
71
- entryPoints: [entrypoint],
72
- logOverride: {
73
- "equals-negative-zero": "silent"
74
- },
75
- platform: "node",
76
- target: "es2020",
77
- sourcemap,
78
- minify,
79
- bundle,
80
- outfile,
81
- absWorkingDir: cwd,
82
- logLevel,
83
- keepNames,
84
- write
61
+ function buildEntrypoint(p) {
62
+ const { entrypoint, ...props } = p;
63
+ return esb.build({
64
+ ...DEFAULT_OPTIONS,
65
+ ...props,
66
+ outfile: void 0,
67
+ entryPoints: [entrypoint]
85
68
  });
86
69
  }
87
70
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/esbuild-utils.ts"],
4
- "sourcesContent": ["import { build as esbuild, LogLevel, Platform, BuildResult, OutputFile } from 'esbuild'\n\ntype BaseProps<W extends boolean = true> = {\n cwd: string\n outfile: string\n minify?: boolean\n sourcemap?: boolean\n bundle?: boolean\n logLevel?: LogLevel\n write: W\n platform?: Platform\n}\n\nexport type BuildCodeProps<W extends boolean = true> = BaseProps<W> & {\n code: string\n}\n\nexport type BuildEntrypointProps<W extends boolean = true> = BaseProps<W> & {\n entrypoint: string\n}\n\nconst keepNames = true // important : https://github.com/node-fetch/node-fetch/issues/784#issuecomment-1014768204\n\nexport function buildCode(p: BuildCodeProps<true>): Promise<BuildResult>\nexport function buildCode(p: BuildCodeProps<false>): Promise<BuildResult & { outputFiles: OutputFile[] }>\nexport function buildCode<W extends boolean>({\n cwd,\n minify = true,\n bundle = true,\n sourcemap = false,\n logLevel = 'silent',\n outfile,\n code,\n write,\n platform = 'node',\n}: BuildCodeProps<W>) {\n return esbuild({\n stdin: {\n contents: code,\n resolveDir: cwd,\n loader: 'ts',\n },\n logOverride: {\n 'equals-negative-zero': 'silent',\n },\n platform,\n target: 'es2020',\n sourcemap,\n minify,\n bundle,\n outfile,\n absWorkingDir: cwd,\n logLevel,\n keepNames,\n write,\n legalComments: 'none',\n })\n}\n\nexport function buildEntrypoint(p: BuildEntrypointProps<true>): Promise<BuildResult>\nexport function buildEntrypoint(p: BuildEntrypointProps<false>): Promise<BuildResult & { outputFiles: OutputFile[] }>\nexport function buildEntrypoint<W extends boolean>({\n cwd,\n minify = true,\n bundle = true,\n sourcemap = false,\n logLevel = 'silent',\n outfile,\n entrypoint,\n write,\n}: BuildEntrypointProps<W>) {\n return esbuild({\n entryPoints: [entrypoint],\n logOverride: {\n 'equals-negative-zero': 'silent',\n },\n platform: 'node',\n target: 'es2020',\n sourcemap,\n minify,\n bundle,\n outfile,\n absWorkingDir: cwd,\n logLevel,\n keepNames,\n write,\n })\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8E;AAqB9E,MAAM,YAAY;AAIX,SAAS,UAA6B;AAAA,EAC3C;AAAA,EACA,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACb,GAAsB;AACpB,aAAO,eAAAA,OAAQ;AAAA,IACb,OAAO;AAAA,MACL,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,IACV;AAAA,IACA,aAAa;AAAA,MACX,wBAAwB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,EACjB,CAAC;AACH;AAIO,SAAS,gBAAmC;AAAA,EACjD;AAAA,EACA,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AACF,GAA4B;AAC1B,aAAO,eAAAA,OAAQ;AAAA,IACb,aAAa,CAAC,UAAU;AAAA,IACxB,aAAa;AAAA,MACX,wBAAwB;AAAA,IAC1B;AAAA,IACA,UAAU;AAAA,IACV,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
6
- "names": ["esbuild"]
4
+ "sourcesContent": ["import * as esb from 'esbuild'\n\nexport * from 'esbuild'\n\ntype BaseProps = esb.BuildOptions & {\n absWorkingDir: string\n}\n\nexport type BuildCodeProps = BaseProps & {\n code: string\n write: true\n outfile: string\n}\n\nexport type BuildEntrypointProps = BaseProps & {\n entrypoint: string\n write: false\n}\n\nconst DEFAULT_OPTIONS: esb.BuildOptions = {\n bundle: true,\n sourcemap: false,\n logLevel: 'silent',\n platform: 'node',\n target: 'es2020',\n legalComments: 'none',\n logOverride: { 'equals-negative-zero': 'silent' },\n keepNames: true, // important : https://github.com/node-fetch/node-fetch/issues/784#issuecomment-1014768204\n}\n\n/**\n * Bundles a string of typescript code and writes the output to a file\n */\nexport function buildCode(p: BuildCodeProps): Promise<esb.BuildResult> {\n const { code, ...props } = p\n return esb.build({\n ...DEFAULT_OPTIONS,\n ...props,\n stdin: {\n contents: code,\n resolveDir: props.absWorkingDir,\n loader: 'ts',\n },\n })\n}\n\n/**\n * Bundles a typescript file and returns the output as a string\n */\nexport function buildEntrypoint(p: BuildEntrypointProps): Promise<esb.BuildResult & { outputFiles: esb.OutputFile[] }> {\n const { entrypoint, ...props } = p\n return esb.build({\n ...DEFAULT_OPTIONS,\n ...props,\n outfile: undefined,\n entryPoints: [entrypoint],\n })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,kCAAc,oBAFd;AAmBA,MAAM,kBAAoC;AAAA,EACxC,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,aAAa,EAAE,wBAAwB,SAAS;AAAA,EAChD,WAAW;AAAA;AACb;AAKO,SAAS,UAAU,GAA6C;AACrE,QAAM,EAAE,MAAM,GAAG,MAAM,IAAI;AAC3B,SAAO,IAAI,MAAM;AAAA,IACf,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO;AAAA,MACL,UAAU;AAAA,MACV,YAAY,MAAM;AAAA,MAClB,QAAQ;AAAA,IACV;AAAA,EACF,CAAC;AACH;AAKO,SAAS,gBAAgB,GAAuF;AACrH,QAAM,EAAE,YAAY,GAAG,MAAM,IAAI;AACjC,SAAO,IAAI,MAAM;AAAA,IACf,GAAG;AAAA,IACH,GAAG;AAAA,IACH,SAAS;AAAA,IACT,aAAa,CAAC,UAAU;AAAA,EAC1B,CAAC;AACH;",
6
+ "names": []
7
7
  }
@@ -31,12 +31,14 @@ __export(path_utils_exports, {
31
31
  PathStore: () => PathStore,
32
32
  absoluteFrom: () => absoluteFrom,
33
33
  cwd: () => cwd,
34
- isAbsolutePath: () => isAbsolutePath,
35
34
  isPath: () => isPath,
35
+ isPlatformSpecificAbsolutePath: () => isPlatformSpecificAbsolutePath,
36
+ isPlatformSpecificPath: () => isPlatformSpecificPath,
36
37
  join: () => join,
37
38
  posix: () => posix,
38
39
  relativeFrom: () => relativeFrom,
39
40
  rmExtension: () => rmExtension,
41
+ toNormalizedPosixPath: () => toNormalizedPosixPath,
40
42
  toUnix: () => toUnix,
41
43
  win32: () => win32
42
44
  });
@@ -55,10 +57,10 @@ var win32;
55
57
  win322.isPath = (path) => (0, win322.isAbsolutePath)(path) || (0, win322.isRelativePath)(path);
56
58
  win322.isRelativePath = (path) => path.startsWith(".\\") || path.startsWith("..\\");
57
59
  win322.isAbsolutePath = (path) => /^[a-zA-Z]:\\/.test(path);
58
- win322.escapeBackslashes = (path) => path.includes("\\\\") ? path : path.replaceAll("\\", "\\\\");
59
60
  })(win32 || (win32 = {}));
60
- const isPath = (path) => import_os.default.platform() === "win32" ? win32.isPath(path) : posix.isPath(path);
61
- const isAbsolutePath = (path) => import_os.default.platform() === "win32" ? win32.isAbsolutePath(path) : posix.isAbsolutePath(path);
61
+ const isPath = (path) => win32.isPath(path) || posix.isPath(path);
62
+ const isPlatformSpecificPath = (path) => import_os.default.platform() === "win32" ? win32.isPath(path) : posix.isPath(path);
63
+ const isPlatformSpecificAbsolutePath = (path) => import_os.default.platform() === "win32" ? win32.isAbsolutePath(path) : posix.isAbsolutePath(path);
62
64
  const cwd = () => process.cwd();
63
65
  const join = (abs, ...paths) => {
64
66
  const joined = import_path.default.join(abs, ...paths);
@@ -66,15 +68,16 @@ const join = (abs, ...paths) => {
66
68
  };
67
69
  const rmExtension = (filename) => filename.replace(/\.[^/.]+$/, "");
68
70
  const toUnix = (path) => path.split(import_path.default.sep).join(import_path.default.posix.sep);
71
+ const toNormalizedPosixPath = (path) => (path.startsWith("./") ? "./" : "") + import_path.default.posix.normalize(path.replaceAll(/\\/g, "/")).replace(/\/\.$/, "");
69
72
  const absoluteFrom = (rootdir, target) => {
70
- if (isAbsolutePath(target)) {
73
+ if (isPlatformSpecificAbsolutePath(target)) {
71
74
  return target;
72
75
  }
73
76
  return import_path.default.join(rootdir, target);
74
77
  };
75
78
  const relativeFrom = (rootdir, target) => {
76
79
  let absPath;
77
- if (isAbsolutePath(target)) {
80
+ if (isPlatformSpecificAbsolutePath(target)) {
78
81
  absPath = target;
79
82
  } else {
80
83
  absPath = import_path.default.resolve(import_path.default.join(rootdir, target));
@@ -94,12 +97,14 @@ class PathStore {
94
97
  PathStore,
95
98
  absoluteFrom,
96
99
  cwd,
97
- isAbsolutePath,
98
100
  isPath,
101
+ isPlatformSpecificAbsolutePath,
102
+ isPlatformSpecificPath,
99
103
  join,
100
104
  posix,
101
105
  relativeFrom,
102
106
  rmExtension,
107
+ toNormalizedPosixPath,
103
108
  toUnix,
104
109
  win32
105
110
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/path-utils.ts"],
4
- "sourcesContent": ["import _ from 'lodash'\nimport oslib from 'os'\nimport pathlib from 'path'\n\nexport namespace posix {\n export type AbsolutePath = `/${string}`\n export const isPath = (path: string) => isAbsolutePath(path) || isRelativePath(path)\n export const isRelativePath = (path: string) => path.startsWith('./') || path.startsWith('../')\n export const isAbsolutePath = (path: string): path is AbsolutePath => pathlib.posix.isAbsolute(path)\n}\n\nexport namespace win32 {\n export type AbsolutePath = `${string}:\\\\${string}` // C:\\path\n export const isPath = (path: string) => isAbsolutePath(path) || isRelativePath(path)\n export const isRelativePath = (path: string) => path.startsWith('.\\\\') || path.startsWith('..\\\\')\n export const isAbsolutePath = (path: string): path is AbsolutePath => /^[a-zA-Z]:\\\\/.test(path) // bp cli does not allow omitting the drive letter\n export const escapeBackslashes = (path: string) => (path.includes('\\\\\\\\') ? path : path.replaceAll('\\\\', '\\\\\\\\')) // idempotent function\n}\n\nexport type AbsolutePath = posix.AbsolutePath | win32.AbsolutePath\nexport const isPath = (path: string) => (oslib.platform() === 'win32' ? win32.isPath(path) : posix.isPath(path))\nexport const isAbsolutePath = (path: string): path is AbsolutePath =>\n oslib.platform() === 'win32' ? win32.isAbsolutePath(path) : posix.isAbsolutePath(path)\n\nexport const cwd = (): AbsolutePath => process.cwd() as AbsolutePath\nexport const join = (abs: AbsolutePath, ...paths: string[]): AbsolutePath => {\n const joined = pathlib.join(abs, ...paths)\n return pathlib.normalize(joined) as AbsolutePath\n}\n\nexport const rmExtension = (filename: string) => filename.replace(/\\.[^/.]+$/, '')\n\nexport const toUnix = (path: string) => path.split(pathlib.sep).join(pathlib.posix.sep)\n\nexport const absoluteFrom = (rootdir: AbsolutePath, target: string): AbsolutePath => {\n if (isAbsolutePath(target)) {\n return target\n }\n return pathlib.join(rootdir, target) as AbsolutePath\n}\n\nexport const relativeFrom = (rootdir: AbsolutePath, target: string) => {\n let absPath: string\n\n if (isAbsolutePath(target)) {\n absPath = target\n } else {\n absPath = pathlib.resolve(pathlib.join(rootdir, target))\n }\n\n return pathlib.relative(rootdir, absPath)\n}\n\nexport class PathStore<P extends string> {\n public constructor(public readonly abs: Record<P, AbsolutePath>) {}\n public rel(from: Extract<P, `${string}Dir`>) {\n return _.mapValues(this.abs, (to) => relativeFrom(this.abs[from], to))\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc;AACd,gBAAkB;AAClB,kBAAoB;AAEb,IAAU;AAAA,CAAV,CAAUA,WAAV;AAEE,EAAMA,OAAA,SAAS,CAAC,aAAiBA,OAAA,gBAAe,IAAI,SAAKA,OAAA,gBAAe,IAAI;AAC5E,EAAMA,OAAA,iBAAiB,CAAC,SAAiB,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK;AACvF,EAAMA,OAAA,iBAAiB,CAAC,SAAuC,YAAAC,QAAQ,MAAM,WAAW,IAAI;AAAA,GAJpF;AAOV,IAAU;AAAA,CAAV,CAAUC,WAAV;AAEE,EAAMA,OAAA,SAAS,CAAC,aAAiBA,OAAA,gBAAe,IAAI,SAAKA,OAAA,gBAAe,IAAI;AAC5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B;AAA9B;AAAA,EAA+B;AAAA,EAC3D,IAAI,MAAkC;AAC3C,WAAO,cAAAG,QAAE,UAAU,KAAK,KAAK,CAAC,OAAO,aAAa,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC;AAAA,EACvE;AACF;",
4
+ "sourcesContent": ["import _ from 'lodash'\nimport oslib from 'os'\nimport pathlib from 'path'\n\nexport namespace posix {\n export type AbsolutePath = `/${string}`\n export const isPath = (path: string) => isAbsolutePath(path) || isRelativePath(path)\n export const isRelativePath = (path: string) => path.startsWith('./') || path.startsWith('../')\n export const isAbsolutePath = (path: string): path is AbsolutePath => pathlib.posix.isAbsolute(path)\n}\n\nexport namespace win32 {\n export type AbsolutePath = `${string}:\\\\${string}` // C:\\path\n export const isPath = (path: string) => isAbsolutePath(path) || isRelativePath(path)\n export const isRelativePath = (path: string) => path.startsWith('.\\\\') || path.startsWith('..\\\\')\n export const isAbsolutePath = (path: string): path is AbsolutePath => /^[a-zA-Z]:\\\\/.test(path) // bp cli does not allow omitting the drive letter\n}\n\nexport type AbsolutePath = posix.AbsolutePath | win32.AbsolutePath\nexport const isPath = (path: string) => win32.isPath(path) || posix.isPath(path)\nexport const isPlatformSpecificPath = (path: string) =>\n oslib.platform() === 'win32' ? win32.isPath(path) : posix.isPath(path)\nexport const isPlatformSpecificAbsolutePath = (path: string): path is AbsolutePath =>\n oslib.platform() === 'win32' ? win32.isAbsolutePath(path) : posix.isAbsolutePath(path)\n\nexport const cwd = (): AbsolutePath => process.cwd() as AbsolutePath\nexport const join = (abs: AbsolutePath, ...paths: string[]): AbsolutePath => {\n const joined = pathlib.join(abs, ...paths)\n return pathlib.normalize(joined) as AbsolutePath\n}\n\nexport const rmExtension = (filename: string) => filename.replace(/\\.[^/.]+$/, '')\n\nexport const toUnix = (path: string) => path.split(pathlib.sep).join(pathlib.posix.sep)\n\nexport const toNormalizedPosixPath = (path: string) =>\n (path.startsWith('./') ? './' : '') + pathlib.posix.normalize(path.replaceAll(/\\\\/g, '/')).replace(/\\/\\.$/, '')\n\nexport const absoluteFrom = (rootdir: AbsolutePath, target: string): AbsolutePath => {\n if (isPlatformSpecificAbsolutePath(target)) {\n return target\n }\n return pathlib.join(rootdir, target) as AbsolutePath\n}\n\nexport const relativeFrom = (rootdir: AbsolutePath, target: string) => {\n let absPath: string\n\n if (isPlatformSpecificAbsolutePath(target)) {\n absPath = target\n } else {\n absPath = pathlib.resolve(pathlib.join(rootdir, target))\n }\n\n return pathlib.relative(rootdir, absPath)\n}\n\nexport class PathStore<P extends string> {\n public constructor(public readonly abs: Record<P, AbsolutePath>) {}\n public rel(from: Extract<P, `${string}Dir`>) {\n return _.mapValues(this.abs, (to) => relativeFrom(this.abs[from], to))\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc;AACd,gBAAkB;AAClB,kBAAoB;AAEb,IAAU;AAAA,CAAV,CAAUA,WAAV;AAEE,EAAMA,OAAA,SAAS,CAAC,aAAiBA,OAAA,gBAAe,IAAI,SAAKA,OAAA,gBAAe,IAAI;AAC5E,EAAMA,OAAA,iBAAiB,CAAC,SAAiB,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK;AACvF,EAAMA,OAAA,iBAAiB,CAAC,SAAuC,YAAAC,QAAQ,MAAM,WAAW,IAAI;AAAA,GAJpF;AAOV,IAAU;AAAA,CAAV,CAAUC,WAAV;AAEE,EAAMA,OAAA,SAAS,CAAC,aAAiBA,OAAA,gBAAe,IAAI,SAAKA,OAAA,gBAAe,IAAI;AAC5E,EAAMA,OAAA,iBAAiB,CAAC,SAAiB,KAAK,WAAW,KAAK,KAAK,KAAK,WAAW,MAAM;AACzF,EAAMA,OAAA,iBAAiB,CAAC,SAAuC,eAAe,KAAK,IAAI;AAAA,GAJ/E;AAQV,MAAM,SAAS,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C3D,IAAI,MAAkC;AAC3C,WAAO,cAAAG,QAAE,UAAU,KAAK,KAAK,CAAC,OAAO,aAAa,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC;AAAA,EACvE;AACF;",
6
6
  "names": ["posix", "pathlib", "win32", "oslib", "_"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -22,7 +22,7 @@
22
22
  "@apidevtools/json-schema-ref-parser": "^11.7.0",
23
23
  "@botpress/chat": "0.4.7",
24
24
  "@botpress/client": "0.41.0",
25
- "@botpress/sdk": "2.4.2",
25
+ "@botpress/sdk": "2.5.0",
26
26
  "@bpinternal/const": "^0.0.20",
27
27
  "@bpinternal/tunnel": "^0.1.1",
28
28
  "@bpinternal/yargs-extra": "^0.0.3",
@@ -6,7 +6,7 @@
6
6
  "private": true,
7
7
  "dependencies": {
8
8
  "@botpress/client": "0.41.0",
9
- "@botpress/sdk": "2.4.2"
9
+ "@botpress/sdk": "2.5.0"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.19.67",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.41.0",
10
- "@botpress/sdk": "2.4.2"
10
+ "@botpress/sdk": "2.5.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.19.67",
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/sdk": "2.4.2"
9
+ "@botpress/sdk": "2.5.0"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.19.67",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.41.0",
10
- "@botpress/sdk": "2.4.2"
10
+ "@botpress/sdk": "2.5.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.19.67",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.41.0",
10
- "@botpress/sdk": "2.4.2",
10
+ "@botpress/sdk": "2.5.0",
11
11
  "axios": "^1.6.8"
12
12
  },
13
13
  "devDependencies": {