@botpress/cli 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,32 @@
1
1
 
2
- > @botpress/cli@4.0.0 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@4.0.1 build /home/runner/work/botpress/botpress/packages/cli
3
3
  > pnpm run bundle && pnpm run template:gen
4
4
 
5
5
 
6
- > @botpress/cli@4.0.0 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@4.0.1 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@4.0.0 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@4.0.1 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 v4.0.0
14
- 🤖 Botpress CLI v4.0.0
15
- 🤖 Botpress CLI v4.0.0
16
- 🤖 Botpress CLI v4.0.0
13
+ 🤖 Botpress CLI v4.0.1
14
+ 🤖 Botpress CLI v4.0.1
15
+ 🤖 Botpress CLI v4.0.1
16
+ 🤖 Botpress CLI v4.0.1
17
+ ○ Generating typings for bot...
17
18
  ○ Generating typings for integration hello-world...
18
- ○ Generating typings for integration empty-integration...
19
19
  ✓ Typings available at .botpress
20
20
 
21
21
  ○ Generating typings for plugin empty-plugin...
22
22
  ✓ Typings available at .botpress
23
23
 
24
+ ○ Generating typings for integration empty-integration...
24
25
  ✓ Typings available at .botpress
25
26
 
26
- ○ Generating typings for bot...
27
27
  ✓ Typings available at .botpress
28
28
 
29
- 🤖 Botpress CLI v4.0.0
29
+ 🤖 Botpress CLI v4.0.1
30
30
  ○ Generating typings for integration webhook-message...
31
31
  ✓ Typings available at .botpress
32
32
 
@@ -45,7 +45,7 @@ class BotIntegrationsModule extends import_module.ReExportTypeModule {
45
45
  exportName: "Integrations"
46
46
  });
47
47
  for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {
48
- const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition);
48
+ const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition).setCustomTypeName(alias);
49
49
  integrationModule.unshift(alias);
50
50
  this.pushDep(integrationModule);
51
51
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/code-generation/bot-implementation/bot-typings/index.ts"],
4
- "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { Module, ReExportTypeModule } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\nimport { TablesModule } from './tables-module'\nimport { WorkflowsModule } from './workflows-module'\n\nclass BotIntegrationsModule extends ReExportTypeModule {\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\ntype BotTypingsIndexDependencies = {\n integrationsModule: BotIntegrationsModule\n eventsModule: EventsModule\n statesModule: StatesModule\n actionsModule: ActionsModule\n tablesModule: TablesModule\n workflowsModule: WorkflowsModule\n}\n\nexport class BotTypingsModule extends Module {\n private _dependencies: BotTypingsIndexDependencies\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'TBot',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = new BotIntegrationsModule(bot)\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const eventsModule = new EventsModule(bot.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(bot.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n const tablesModule = new TablesModule(bot.tables ?? {})\n tablesModule.unshift('tables')\n this.pushDep(tablesModule)\n\n const actionsModule = new ActionsModule(bot.actions ?? {})\n actionsModule.unshift('actions')\n this.pushDep(actionsModule)\n\n const workflowsModule = new WorkflowsModule(bot.workflows ?? {})\n workflowsModule.unshift('workflows')\n this.pushDep(workflowsModule)\n\n this._dependencies = {\n integrationsModule,\n eventsModule,\n statesModule,\n actionsModule,\n tablesModule,\n workflowsModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule, workflowsModule } =\n this._dependencies\n\n const integrationsImport = integrationsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const actionsImport = actionsModule\n const tablesImport = tablesModule.import(this)\n const workflowsImport = workflowsModule\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${integrationsModule.name} from './${integrationsImport}'`,\n `import * as ${eventsModule.name} from './${eventsModule.name}'`,\n `import * as ${statesModule.name} from './${statesModule.name}'`,\n `import * as ${actionsModule.name} from './${actionsImport.name}'`,\n `import * as ${tablesModule.name} from './${tablesImport}'`,\n `import * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n `export * as ${integrationsModule.name} from './${integrationsImport}'`,\n `export * as ${eventsModule.name} from './${eventsImport}'`,\n `export * as ${statesModule.name} from './${statesImport}'`,\n `export * as ${actionsModule.name} from './${actionsImport.name}'`,\n `export * as ${tablesModule.name} from './${tablesImport}'`,\n `export * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n 'export type TBot = {',\n ` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,\n ` events: ${eventsModule.name}.${eventsModule.exportName}`,\n ` states: ${statesModule.name}.${statesModule.exportName}`,\n ` actions: ${actionsModule.name}.${actionsModule.exportName}`,\n ` tables: ${tablesModule.name}.${tablesModule.exportName}`,\n ` workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n"],
5
- "mappings": ";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,KAAK,IAAI;AAAA,EACb;AACF;",
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { Module, ReExportTypeModule } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\nimport { TablesModule } from './tables-module'\nimport { WorkflowsModule } from './workflows-module'\n\nclass BotIntegrationsModule extends ReExportTypeModule {\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition).setCustomTypeName(alias)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\ntype BotTypingsIndexDependencies = {\n integrationsModule: BotIntegrationsModule\n eventsModule: EventsModule\n statesModule: StatesModule\n actionsModule: ActionsModule\n tablesModule: TablesModule\n workflowsModule: WorkflowsModule\n}\n\nexport class BotTypingsModule extends Module {\n private _dependencies: BotTypingsIndexDependencies\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'TBot',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = new BotIntegrationsModule(bot)\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const eventsModule = new EventsModule(bot.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(bot.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n const tablesModule = new TablesModule(bot.tables ?? {})\n tablesModule.unshift('tables')\n this.pushDep(tablesModule)\n\n const actionsModule = new ActionsModule(bot.actions ?? {})\n actionsModule.unshift('actions')\n this.pushDep(actionsModule)\n\n const workflowsModule = new WorkflowsModule(bot.workflows ?? {})\n workflowsModule.unshift('workflows')\n this.pushDep(workflowsModule)\n\n this._dependencies = {\n integrationsModule,\n eventsModule,\n statesModule,\n actionsModule,\n tablesModule,\n workflowsModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule, workflowsModule } =\n this._dependencies\n\n const integrationsImport = integrationsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const actionsImport = actionsModule\n const tablesImport = tablesModule.import(this)\n const workflowsImport = workflowsModule\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${integrationsModule.name} from './${integrationsImport}'`,\n `import * as ${eventsModule.name} from './${eventsModule.name}'`,\n `import * as ${statesModule.name} from './${statesModule.name}'`,\n `import * as ${actionsModule.name} from './${actionsImport.name}'`,\n `import * as ${tablesModule.name} from './${tablesImport}'`,\n `import * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n `export * as ${integrationsModule.name} from './${integrationsImport}'`,\n `export * as ${eventsModule.name} from './${eventsImport}'`,\n `export * as ${statesModule.name} from './${statesImport}'`,\n `export * as ${actionsModule.name} from './${actionsImport.name}'`,\n `export * as ${tablesModule.name} from './${tablesImport}'`,\n `export * as ${workflowsModule.name} from './${workflowsImport.name}'`,\n '',\n 'export type TBot = {',\n ` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,\n ` events: ${eventsModule.name}.${eventsModule.exportName}`,\n ` states: ${statesModule.name}.${statesModule.exportName}`,\n ` actions: ${actionsModule.name}.${actionsModule.exportName}`,\n ` tables: ${tablesModule.name}.${tablesModule.exportName}`,\n ` workflows: ${workflowsModule.name}.${workflowsModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,iCAAyC;AACzC,oBAA2C;AAC3C,4BAA8B;AAC9B,2BAA6B;AAC7B,2BAA6B;AAC7B,2BAA6B;AAC7B,8BAAgC;AAEhC,MAAM,8BAA8B,iCAAmB;AAAA,EAC9C,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ,YAAY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ACnG,KAAK;AAEP,UAAM,qBAAqB,mBAAmB,OAAO,IAAI;AACzD,UAAM,eAAe,aAAa,OAAO,IAAI;AAC7C,UAAM,eAAe,aAAa,OAAO,IAAI;AAC7C,UAAM,gBAAgB;AACtB,UAAM,eAAe,aAAa,OAAO,IAAI;AAC7C,UAAM,kBAAkB;AAExB,WAAO;AAAA,MACL,OAAO;AAAA,MACP,eAAe,mBAAmB,gBAAgB;AAAA,MAClD,eAAe,aAAa,gBAAgB,aAAa;AAAA,MACzD,eAAe,aAAa,gBAAgB,aAAa;AAAA,MACzD,eAAe,cAAc,gBAAgB,cAAc;AAAA,MAC3D,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,gBAAgB,gBAAgB,gBAAgB;AAAA,MAC/D;AAAA,MACA,eAAe,mBAAmB,gBAAgB;AAAA,MAClD,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,cAAc,gBAAgB,cAAc;AAAA,MAC3D,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,gBAAgB,gBAAgB,gBAAgB;AAAA,MAC/D;AAAA,MACA;AAAA,MACA,mBAAmB,mBAAmB,QAAQ,mBAAmB;AAAA,MACjE,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,cAAc,cAAc,QAAQ,cAAc;AAAA,MAClD,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,gBAAgB,gBAAgB,QAAQ,gBAAgB;AAAA,MACxD;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
6
6
  "names": []
7
7
  }
@@ -43,6 +43,7 @@ class Module {
43
43
  this._def = _def;
44
44
  }
45
45
  _localDependencies = [];
46
+ _customTypeName;
46
47
  get path() {
47
48
  return this._def.path.split(import_path.posix.sep).map(strings.fileName).join(import_path.posix.sep);
48
49
  }
@@ -69,6 +70,16 @@ class Module {
69
70
  get deps() {
70
71
  return [...this._localDependencies];
71
72
  }
73
+ get typeName() {
74
+ return this._customTypeName ?? this.name;
75
+ }
76
+ get importAlias() {
77
+ return this.typeName.split(import_path.posix.sep).map(strings.importAlias).join("__");
78
+ }
79
+ setCustomTypeName(alias) {
80
+ this._customTypeName = alias;
81
+ return this;
82
+ }
72
83
  pushDep(...dependencies) {
73
84
  this._localDependencies.push(...dependencies);
74
85
  return this;
@@ -112,8 +123,7 @@ class ReExportTypeModule extends Module {
112
123
  async getContent() {
113
124
  let content = consts.GENERATED_HEADER;
114
125
  for (const m of this.deps) {
115
- const { name } = m;
116
- const importAlias = strings.importAlias(name);
126
+ const { importAlias } = m;
117
127
  const importFrom = m.import(this);
118
128
  content += `import * as ${importAlias} from "./${importFrom}";
119
129
  `;
@@ -123,9 +133,8 @@ class ReExportTypeModule extends Module {
123
133
  content += "\n";
124
134
  content += `export type ${this.exportName} = {
125
135
  `;
126
- for (const { name, exportName: exports } of this.deps) {
127
- const importAlias = strings.importAlias(name);
128
- content += ` "${name}": ${importAlias}.${exports};
136
+ for (const { importAlias, typeName, exportName: exports } of this.deps) {
137
+ content += ` "${typeName}": ${importAlias}.${exports};
129
138
  `;
130
139
  }
131
140
  content += "}";
@@ -145,8 +154,7 @@ class ReExportVariableModule extends Module {
145
154
  async getContent() {
146
155
  let content = consts.GENERATED_HEADER;
147
156
  for (const m of this.deps) {
148
- const { name } = m;
149
- const importAlias = strings.importAlias(name);
157
+ const { importAlias } = m;
150
158
  const importFrom = m.import(this);
151
159
  content += `import * as ${importAlias} from "./${importFrom}";
152
160
  `;
@@ -155,7 +163,7 @@ class ReExportVariableModule extends Module {
155
163
  }
156
164
  content += "\n";
157
165
  const depProps = Object.fromEntries(
158
- this.deps.map(({ name, exportName }) => [name, `${strings.importAlias(name)}.${exportName}`])
166
+ this.deps.map(({ name, exportName, importAlias }) => [name, `${importAlias}.${exportName}`])
159
167
  );
160
168
  const allProps = { ...depProps, ...this._extraProps };
161
169
  content += `export const ${this.exportName} = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/module.ts"],
4
- "sourcesContent": ["import { posix as pathlib } from 'path'\nimport * as utils from '../utils'\nimport * as consts from './consts'\nimport * as strings from './strings'\nimport { File } from './typings'\n\nexport type ModuleProps = {\n path: string\n exportName: string\n}\n\nexport abstract class Module {\n private _localDependencies: Module[] = []\n\n public get path(): string {\n return this._def.path.split(pathlib.sep).map(strings.fileName).join(pathlib.sep)\n }\n\n /**\n * @returns module name (equivalent to unescaped file name without extension)\n */\n public get name(): string {\n const path = this._def.path\n const basename = pathlib.basename(path)\n if (basename === consts.INDEX_FILE || basename === consts.INDEX_DECLARATION_FILE) {\n const dirPath = pathlib.dirname(path)\n const dirname = pathlib.basename(dirPath)\n return dirname\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return withoutExtension\n }\n\n public get isDefaultExport(): boolean {\n return this._def.exportName === consts.DEFAULT_EXPORT_NAME\n }\n\n public get exportName(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n protected constructor(private _def: ModuleProps) {}\n\n public abstract getContent(): Promise<string>\n\n public pushDep(...dependencies: Module[]): this {\n this._localDependencies.push(...dependencies)\n return this\n }\n\n public unshift(...basePath: string[]): this {\n this._def = {\n ...this._def,\n path: pathlib.join(...basePath, this._def.path),\n }\n this._localDependencies = this._localDependencies.map((d) => d.unshift(...basePath))\n return this\n }\n\n public async toFile(): Promise<File> {\n return {\n path: this.path,\n content: await this.getContent(),\n }\n }\n\n public async flatten(): Promise<File[]> {\n const self = await this.toFile()\n const allFiles: File[] = [self]\n for (const dep of this._localDependencies) {\n const depFiles = await dep.flatten()\n allFiles.push(...depFiles)\n }\n return allFiles\n }\n\n public import(base: Module): string {\n let relativePath = pathlib.relative(pathlib.dirname(base.path), this.path)\n relativePath = pathlib.join('.', relativePath)\n return utils.path.rmExtension(relativePath)\n }\n}\n\nexport class ReExportTypeModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${this.exportName} = {\\n`\n for (const { name, exportName: exports } of this.deps) {\n const importAlias = strings.importAlias(name)\n content += ` \"${name}\": ${importAlias}.${exports};\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class ReExportVariableModule extends Module {\n private _extraProps: Record<string, string> = {}\n\n protected constructor(def: { exportName: string; extraProps?: Record<string, string> }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n this._extraProps = def.extraProps ?? {}\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n const depProps: Record<string, string> = Object.fromEntries(\n this.deps.map(({ name, exportName }) => [name, `${strings.importAlias(name)}.${exportName}`])\n )\n\n const allProps = { ...depProps, ...this._extraProps }\n\n content += `export const ${this.exportName} = {\\n`\n for (const [key, value] of Object.entries(allProps)) {\n content += ` \"${key}\": ${value},\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class SingleFileModule extends Module {\n private _content: string\n public constructor(def: ModuleProps & { content: string }) {\n super(def)\n this._content = def.content\n }\n\n public async getContent(): Promise<string> {\n return this._content\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AAC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kE;AACtF,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,MAAM,OAAO;AAAA,IACf,CAAC;AACD,SAAK,cAAc,IAAI,cAAc,CAAC;AAAA,EACxC;AAAA,EAEA,MAAa,aAA8B;AACzC,QAAI,UAAU,OAAO;AAErB,eAAW,KAAK,KAAK,MAAM;AACzB,YAAM,EAAE,KAAK,IAAI;AACjB,YAAM,cAAc,QAAQ,YAAY,IAAI;AAC5C,YAAM,aAAa,EAAE,OAAO,IAAI;AAChC,iBAAW,eAAe,uBAAuB;AAAA;AACjD,iBAAW,eAAe,uBAAuB;AAAA;AAAA,IACnD;AAEA,eAAW;AAEX,UAAM,WAAmC,OAAO;AAAA,MAC9C,KAAK,KAAK,IAAI,CAAC,EAAE,MAAM,WAAW,MAAM,CAAC,MAAM,GAAG,QAAQ,YAAY,IAAI,KAAK,YAAY,CAAC;AAAA,IAC9F;AAEA,UAAM,WAAW,EAAE,GAAG,UAAU,GAAG,KAAK,YAAY;AAEpD,eAAW,gBAAgB,KAAK;AAAA;AAChC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,iBAAW,MAAM,SAAS;AAAA;AAAA,IAC5B;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;AAEO,MAAM,yBAAyB,OAAO;AAAA,EACnC;AAAA,EACD,YAAY,KAAwC;AACzD,UAAM,GAAG;AACT,SAAK,WAAW,IAAI;AAAA,EACtB;AAAA,EAEA,MAAa,aAA8B;AACzC,WAAO,KAAK;AAAA,EACd;AACF;",
4
+ "sourcesContent": ["import { posix as pathlib } from 'path'\nimport * as utils from '../utils'\nimport * as consts from './consts'\nimport * as strings from './strings'\nimport { File } from './typings'\n\nexport type ModuleProps = {\n path: string\n exportName: string\n}\n\nexport abstract class Module {\n private _localDependencies: Module[] = []\n private _customTypeName: string | undefined\n\n public get path(): string {\n return this._def.path.split(pathlib.sep).map(strings.fileName).join(pathlib.sep)\n }\n\n /**\n * @returns module name (equivalent to unescaped file name without extension)\n */\n public get name(): string {\n const path = this._def.path\n const basename = pathlib.basename(path)\n if (basename === consts.INDEX_FILE || basename === consts.INDEX_DECLARATION_FILE) {\n const dirPath = pathlib.dirname(path)\n const dirname = pathlib.basename(dirPath)\n return dirname\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return withoutExtension\n }\n\n public get isDefaultExport(): boolean {\n return this._def.exportName === consts.DEFAULT_EXPORT_NAME\n }\n\n public get exportName(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n public get typeName(): string {\n return this._customTypeName ?? this.name\n }\n\n public get importAlias(): string {\n return this.typeName.split(pathlib.sep).map(strings.importAlias).join('__')\n }\n\n protected constructor(private _def: ModuleProps) {}\n\n public abstract getContent(): Promise<string>\n\n public setCustomTypeName(alias: string): this {\n this._customTypeName = alias\n return this\n }\n\n public pushDep(...dependencies: Module[]): this {\n this._localDependencies.push(...dependencies)\n return this\n }\n\n public unshift(...basePath: string[]): this {\n this._def = {\n ...this._def,\n path: pathlib.join(...basePath, this._def.path),\n }\n this._localDependencies = this._localDependencies.map((d) => d.unshift(...basePath))\n return this\n }\n\n public async toFile(): Promise<File> {\n return {\n path: this.path,\n content: await this.getContent(),\n }\n }\n\n public async flatten(): Promise<File[]> {\n const self = await this.toFile()\n const allFiles: File[] = [self]\n for (const dep of this._localDependencies) {\n const depFiles = await dep.flatten()\n allFiles.push(...depFiles)\n }\n return allFiles\n }\n\n public import(base: Module): string {\n let relativePath = pathlib.relative(pathlib.dirname(base.path), this.path)\n relativePath = pathlib.join('.', relativePath)\n return utils.path.rmExtension(relativePath)\n }\n}\n\nexport class ReExportTypeModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { importAlias } = m\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${this.exportName} = {\\n`\n for (const { importAlias, typeName, exportName: exports } of this.deps) {\n content += ` \"${typeName}\": ${importAlias}.${exports};\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class ReExportVariableModule extends Module {\n private _extraProps: Record<string, string> = {}\n\n protected constructor(def: { exportName: string; extraProps?: Record<string, string> }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n this._extraProps = def.extraProps ?? {}\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { importAlias } = m\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n const depProps: Record<string, string> = Object.fromEntries(\n this.deps.map(({ name, exportName, importAlias }) => [name, `${importAlias}.${exportName}`])\n )\n\n const allProps = { ...depProps, ...this._extraProps }\n\n content += `export const ${this.exportName} = {\\n`\n for (const [key, value] of Object.entries(allProps)) {\n content += ` \"${key}\": ${value},\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class SingleFileModule extends Module {\n private _content: string\n public constructor(def: ModuleProps & { content: string }) {\n super(def)\n this._content = def.content\n }\n\n public async getContent(): Promise<string> {\n return this._content\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,YAAuB;AACvB,aAAwB;AACxB,cAAyB;AAQlB,MAAe,OAAO;AAAA,EA2CjB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EA1C1C,qBAA+B,CAAC;AAAA,EAChC;AAAA,EAER,IAAW,OAAe;AACxB,WAAO,KAAK,KAAK,KAAK,MAAM,YAAAA,MAAQ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AACtF,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,MAAM,OAAO;AAAA,IACf,CAAC;AACD,SAAK,cAAc,IAAI,cAAc,CAAC;AAAA,EACxC;AAAA,EAEA,MAAa,aAA8B;AACzC,QAAI,UAAU,OAAO;AAErB,eAAW,KAAK,KAAK,MAAM;AACzB,YAAM,EAAE,YAAY,IAAI;AACxB,YAAM,aAAa,EAAE,OAAO,IAAI;AAChC,iBAAW,eAAe,uBAAuB;AAAA;AACjD,iBAAW,eAAe,uBAAuB;AAAA;AAAA,IACnD;AAEA,eAAW;AAEX,UAAM,WAAmC,OAAO;AAAA,MAC9C,KAAK,KAAK,IAAI,CAAC,EAAE,MAAM,YAAY,YAAY,MAAM,CAAC,MAAM,GAAG,eAAe,YAAY,CAAC;AAAA,IAC7F;AAEA,UAAM,WAAW,EAAE,GAAG,UAAU,GAAG,KAAK,YAAY;AAEpD,eAAW,gBAAgB,KAAK;AAAA;AAChC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,iBAAW,MAAM,SAAS;AAAA;AAAA,IAC5B;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;AAEO,MAAM,yBAAyB,OAAO;AAAA,EACnC;AAAA,EACD,YAAY,KAAwC;AACzD,UAAM,GAAG;AACT,SAAK,WAAW,IAAI;AAAA,EACtB;AAAA,EAEA,MAAa,aAA8B;AACzC,WAAO,KAAK;AAAA,EACd;AACF;",
6
6
  "names": ["pathlib"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",