@botpress/cli 6.3.2 → 6.3.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.
- package/.turbo/turbo-build.log +11 -11
- package/dist/command-implementations/add-command.js +15 -4
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/utils/path-utils.d.ts +7 -0
- package/dist/utils/path-utils.js +10 -0
- package/dist/utils/path-utils.js.map +2 -2
- package/package.json +3 -3
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@6.3.
|
|
2
|
+
> @botpress/cli@6.3.4 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run build:types && pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@6.3.
|
|
6
|
+
> @botpress/cli@6.3.4 build:types /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> tsc -p ./tsconfig.build.json
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@6.3.
|
|
10
|
+
> @botpress/cli@6.3.4 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> ts-node -T build.ts
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
> @botpress/cli@6.3.
|
|
14
|
+
> @botpress/cli@6.3.4 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
15
15
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
16
16
|
|
|
17
|
-
🤖 Botpress CLI v6.3.
|
|
17
|
+
🤖 Botpress CLI v6.3.4
|
|
18
|
+
🤖 Botpress CLI v6.3.4
|
|
18
19
|
● Checking if cli is up to date
|
|
19
|
-
🤖 Botpress CLI v6.3.2
|
|
20
20
|
● Checking if cli is up to date
|
|
21
|
-
🤖 Botpress CLI v6.3.
|
|
22
|
-
🤖 Botpress CLI v6.3.2
|
|
21
|
+
🤖 Botpress CLI v6.3.4
|
|
23
22
|
● Checking if cli is up to date
|
|
23
|
+
🤖 Botpress CLI v6.3.4
|
|
24
24
|
● Checking if cli is up to date
|
|
25
25
|
● Checking if sdk is up to date
|
|
26
26
|
● Checking if sdk is up to date
|
|
27
27
|
● Checking if sdk is up to date
|
|
28
28
|
● Checking if sdk is up to date
|
|
29
|
+
○ Generating typings for integration hello-world...
|
|
30
|
+
○ Generating typings for plugin empty-plugin...
|
|
29
31
|
○ Generating typings for integration empty-integration...
|
|
30
32
|
✓ Typings available at .botpress
|
|
31
33
|
|
|
32
|
-
○ Generating typings for integration hello-world...
|
|
33
34
|
○ Generating typings for bot...
|
|
34
|
-
○ Generating typings for plugin empty-plugin...
|
|
35
35
|
✓ Typings available at .botpress
|
|
36
36
|
|
|
37
37
|
✓ Typings available at .botpress
|
|
38
38
|
|
|
39
39
|
✓ Typings available at .botpress
|
|
40
40
|
|
|
41
|
-
🤖 Botpress CLI v6.3.
|
|
41
|
+
🤖 Botpress CLI v6.3.4
|
|
42
42
|
● Checking if cli is up to date
|
|
43
43
|
● Checking if sdk is up to date
|
|
44
44
|
○ Generating typings for integration webhook-message...
|
|
@@ -74,7 +74,8 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
74
74
|
if (!parsed) {
|
|
75
75
|
throw new errors.InvalidPackageReferenceError(pkgRefStr);
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const normalized = parsed.type === "path" ? { ...parsed, path: utils.path.absoluteFrom(baseInstallPath, parsed.path) } : parsed;
|
|
78
|
+
const refWithAlias = { ...normalized, alias: pkgAlias };
|
|
78
79
|
const foundPkg = await this._findPackage(refWithAlias);
|
|
79
80
|
await this._addSinglePackage(refWithAlias, foundPkg);
|
|
80
81
|
}
|
|
@@ -142,7 +143,14 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
142
143
|
async _addNewSinglePackage(ref) {
|
|
143
144
|
const foundPackage = await this._findPackage(ref);
|
|
144
145
|
const targetPackage = foundPackage.targetPackage;
|
|
145
|
-
const
|
|
146
|
+
const isDevPackage = targetPackage.type === "integration" && !!targetPackage.pkg.devId;
|
|
147
|
+
let packageName;
|
|
148
|
+
if (isDevPackage) {
|
|
149
|
+
this.logger.debug("Skipping bpDependencies update for dev integration");
|
|
150
|
+
packageName = foundPackage.packageName;
|
|
151
|
+
} else {
|
|
152
|
+
packageName = await this._addDependencyToPackage(ref, foundPackage.packageName, targetPackage);
|
|
153
|
+
}
|
|
146
154
|
await this._addSinglePackage(ref, { packageName, targetPackage });
|
|
147
155
|
}
|
|
148
156
|
async _findPackage(ref) {
|
|
@@ -313,7 +321,7 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
313
321
|
workDir
|
|
314
322
|
});
|
|
315
323
|
}
|
|
316
|
-
async _addDependencyToPackage(packageName, targetPackage) {
|
|
324
|
+
async _addDependencyToPackage(ref, packageName, targetPackage) {
|
|
317
325
|
const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath).catch((thrown) => {
|
|
318
326
|
throw errors.BotpressCLIError.wrap(thrown, "Failed to read package.json file");
|
|
319
327
|
});
|
|
@@ -321,7 +329,10 @@ class AddCommand extends import_global_command.GlobalCommand {
|
|
|
321
329
|
this.logger.warn("No package.json found in the install path");
|
|
322
330
|
return packageName;
|
|
323
331
|
}
|
|
324
|
-
const version =
|
|
332
|
+
const version = ref.type === "path" ? utils.path.relativePathFrom(
|
|
333
|
+
utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath),
|
|
334
|
+
utils.path.absoluteFrom(utils.path.cwd(), ref.path)
|
|
335
|
+
) : `${targetPackage.type}:${targetPackage.pkg.name}@${targetPackage.pkg.version}`;
|
|
325
336
|
const { bpDependencies } = pkgJson;
|
|
326
337
|
if (!bpDependencies) {
|
|
327
338
|
pkgJson.bpDependencies = { [packageName]: version };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/add-command.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as fslib from 'fs'\nimport * as pathlib from 'path'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as pkgRef from '../package-ref'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\nimport {\n ProjectCache,\n ProjectCommand,\n ProjectCommandDefinition,\n ProjectDefinitionLazy,\n ProjectDefinition,\n} from './project-command'\n\ntype InstallablePackage =\n | {\n type: 'integration'\n pkg: codegen.IntegrationInstallablePackage\n }\n | {\n type: 'interface'\n pkg: codegen.InterfaceInstallablePackage\n }\n | {\n type: 'plugin'\n pkg: codegen.PluginInstallablePackage\n }\n\ntype RefWithAlias = pkgRef.PackageRef & { alias?: string }\n\nexport type AddCommandDefinition = typeof commandDefinitions.add\nexport class AddCommand extends GlobalCommand<AddCommandDefinition> {\n public async run(): Promise<void> {\n const ref = this._parseArgvRef()\n if (ref) {\n return await this._addNewSinglePackage({ ...ref, alias: this.argv.alias })\n }\n\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to read package.json file')\n })\n\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return\n }\n\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n this.logger.log('No bp dependencies found in package.json')\n return\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResults = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResults.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath)\n const modulesPath = utils.path.join(baseInstallPath, consts.installDirName)\n fslib.rmSync(modulesPath, { force: true, recursive: true })\n fslib.mkdirSync(modulesPath)\n\n for (const [pkgAlias, pkgRefStr] of Object.entries(parseResults.data)) {\n const parsed = pkgRef.parsePackageRef(pkgRefStr)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(pkgRefStr)\n }\n\n const refWithAlias = { ...parsed, alias: pkgAlias }\n const foundPkg = await this._findPackage(refWithAlias)\n await this._addSinglePackage(refWithAlias, foundPkg)\n }\n }\n\n private _parseArgvRef = (): pkgRef.PackageRef | undefined => {\n if (!this.argv.packageRef) {\n return\n }\n\n const parsed = pkgRef.parsePackageRef(this.argv.packageRef)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(this.argv.packageRef)\n }\n\n return parsed\n }\n\n private async _addSinglePackage(\n ref: RefWithAlias,\n props: { packageName: string; targetPackage: InstallablePackage }\n ) {\n const { packageName, targetPackage } = props\n\n const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath)\n const packageDirName = utils.casing.to.kebabCase(packageName)\n const installPath = utils.path.join(baseInstallPath, consts.installDirName, packageDirName)\n\n const alreadyInstalled = fslib.existsSync(installPath)\n if (alreadyInstalled) {\n await this._uninstall(installPath)\n }\n\n if (ref.type === 'name') {\n targetPackage.pkg.version = ref.version\n }\n\n let files: codegen.File[]\n if (targetPackage.type === 'integration') {\n files = await codegen.generateIntegrationPackage(targetPackage.pkg)\n } else if (targetPackage.type === 'interface') {\n files = await codegen.generateInterfacePackage(targetPackage.pkg)\n } else if (targetPackage.type === 'plugin') {\n files = await codegen.generatePluginPackage(targetPackage.pkg)\n } else {\n type _assertion = utils.types.AssertNever<typeof targetPackage>\n throw new errors.BotpressCLIError('Invalid package type')\n }\n\n await this._install(installPath, files)\n }\n private async _chooseNewAlias(existingPackages: Record<string, string>) {\n const setAliasConfirmation = await this.prompt.confirm(\n 'Do you want to set an alias to the package you are installing?'\n )\n if (!setAliasConfirmation) {\n throw new errors.AbortedOperationError()\n }\n\n const alias = this._chooseUnusedAlias(existingPackages)\n\n return alias\n }\n\n private async _chooseUnusedAlias(existingPackages: Record<string, string>): Promise<string> {\n const alias = await this.prompt.text('Enter the new alias')\n const existingAlias = Object.entries(existingPackages).find(([dep, _]) => dep === alias)\n\n if (!alias) {\n throw new errors.BotpressCLIError('You cannot set an empty alias')\n }\n if (!existingAlias) {\n return alias\n }\n\n if (\n await this.prompt.confirm(\n `The alias ${alias} is already used for dependency ${existingAlias[1]}. Do you want to overwrite it?`\n )\n ) {\n return alias\n }\n return this._chooseUnusedAlias(existingPackages)\n }\n\n private async _addNewSinglePackage(ref: RefWithAlias) {\n const foundPackage = await this._findPackage(ref)\n const targetPackage = foundPackage.targetPackage\n const packageName = await this._addDependencyToPackage(foundPackage.packageName, targetPackage)\n await this._addSinglePackage(ref, { packageName, targetPackage })\n }\n\n private async _findPackage(ref: RefWithAlias): Promise<{ packageName: string; targetPackage: InstallablePackage }> {\n const targetPackage = ref.type === 'path' ? await this._findLocalPackage(ref) : await this._findRemotePackage(ref)\n if (!targetPackage) {\n const strRef = pkgRef.formatPackageRef(ref)\n throw new errors.BotpressCLIError(`Could not find package \"${strRef}\"`)\n }\n const packageName = ref.alias ?? targetPackage.pkg.name\n\n return { packageName, targetPackage }\n }\n\n private async _findRemotePackage(ref: pkgRef.ApiPackageRef): Promise<InstallablePackage | undefined> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n if (this._pkgCouldBe(ref, 'integration')) {\n const integration = await api.findPublicOrPrivateIntegration(ref)\n if (integration) {\n const { name, version } = integration\n return { type: 'integration', pkg: { integration, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'interface')) {\n const intrface = await api.findPublicOrPrivateInterface(ref)\n if (intrface) {\n const { name, version } = intrface\n return { type: 'interface', pkg: { interface: intrface, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'plugin')) {\n const plugin = await api.findPublicOrPrivatePlugin(ref)\n if (plugin) {\n const { code } = plugin.public\n ? await api.client.getPublicPluginCode({ id: plugin.id, platform: 'node' })\n : await api.client.getPluginCode({ id: plugin.id, platform: 'node' })\n const { name, version } = plugin\n return {\n type: 'plugin',\n pkg: {\n name,\n version,\n plugin,\n code,\n },\n }\n }\n }\n return\n }\n\n private async _findLocalPackage(ref: pkgRef.LocalPackageRef): Promise<InstallablePackage | undefined> {\n const absPath = utils.path.absoluteFrom(utils.path.cwd(), ref.path)\n const {\n definition: projectDefinition,\n implementation: projectImplementation,\n devId: projectDevId,\n } = await this._readProject(absPath)\n\n if (projectDefinition?.type === 'integration') {\n const { name, version } = projectDefinition.definition\n let devId: string | undefined\n if (this.argv.useDev && projectDevId) {\n this.logger.warn(`Installing integration \"${name}\" with dev version \"${projectDevId}\"`)\n devId = projectDevId\n }\n\n let createIntegrationReqBody = await this._getProjectCmd(ref.path).prepareCreateIntegrationBody(\n projectDefinition.definition\n )\n createIntegrationReqBody = {\n ...createIntegrationReqBody,\n interfaces: utils.records.mapValues(projectDefinition.definition.interfaces ?? {}, (i) => ({\n id: '', // TODO: do this better\n ...i,\n })),\n }\n return {\n type: 'integration',\n pkg: { path: absPath, devId, name, version, integration: createIntegrationReqBody },\n }\n }\n\n if (projectDefinition?.type === 'interface') {\n const { name, version } = projectDefinition.definition\n const createInterfaceReqBody = await apiUtils.prepareCreateInterfaceBody(projectDefinition.definition)\n return {\n type: 'interface',\n pkg: { path: absPath, name, version, interface: createInterfaceReqBody },\n }\n }\n\n if (projectDefinition?.type === 'plugin') {\n if (!projectImplementation) {\n throw new errors.BotpressCLIError(\n 'Plugin implementation not found; Please build the plugin project before installing'\n )\n }\n\n const pluginDefinition = projectDefinition.definition\n const { name, version } = pluginDefinition\n const code = projectImplementation\n\n const createPluginReqBody = await apiUtils.prepareCreatePluginBody(pluginDefinition)\n return {\n type: 'plugin',\n pkg: {\n path: absPath,\n name,\n version,\n code,\n plugin: {\n ...createPluginReqBody,\n dependencies: {\n interfaces: pluginDefinition.interfaces,\n integrations: pluginDefinition.integrations,\n },\n recurringEvents: pluginDefinition.recurringEvents,\n },\n },\n }\n }\n\n if (projectDefinition?.type === 'bot') {\n throw new errors.BotpressCLIError('Cannot install a bot as a package')\n }\n return\n }\n\n private async _install(installPath: utils.path.AbsolutePath, files: codegen.File[]): Promise<void> {\n const line = this.logger.line()\n line.started(`Installing ${files.length} files to \"${installPath}\"`)\n try {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(installPath, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fslib.promises.mkdir(dirPath, { recursive: true })\n await fslib.promises.writeFile(filePath, file.content)\n }\n line.success(`Installed ${files.length} files to \"${installPath}\"`)\n } finally {\n line.commit()\n }\n }\n\n private async _uninstall(installPath: utils.path.AbsolutePath): Promise<void> {\n await fslib.promises.rm(installPath, { recursive: true })\n }\n\n private async _readProject(workDir: utils.path.AbsolutePath): Promise<{\n definition?: ProjectDefinition\n implementation?: string\n devId?: string\n }> {\n const cmd = this._getProjectCmd(workDir)\n\n const { resolveProjectDefinition } = cmd.readProjectDefinitionFromFS()\n const definition = await resolveProjectDefinition().catch((thrown) => {\n if (thrown instanceof errors.ProjectDefinitionNotFoundError) {\n return undefined\n }\n throw thrown\n })\n\n const devId = await cmd.projectCache.get('devId').catch((thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, 'Failed to read project dev ID from cache')\n this.logger.debug(err.message)\n return undefined\n })\n\n const implementationAbsPath = utils.path.join(workDir, consts.fromWorkDir.outFileCJS)\n if (!fslib.existsSync(implementationAbsPath)) {\n return { definition, devId }\n }\n\n const implementation = await fslib.promises.readFile(implementationAbsPath, 'utf8')\n return { definition, implementation, devId }\n }\n\n private _pkgCouldBe = (ref: pkgRef.ApiPackageRef, pkgType: InstallablePackage['type']) => {\n if (ref.type === 'id') {\n // TODO: use ULID prefixes to determine the type of the package\n return true\n }\n if (!ref.pkg) {\n return true // ref does not specify the package type\n }\n return ref.pkg === pkgType\n }\n\n private _getProjectCmd(workDir: string): _AnyProjectCommand {\n return new _AnyProjectCommand(apiUtils.ApiClient, this.prompt, this.logger, {\n ...this.argv,\n workDir,\n })\n }\n\n private async _addDependencyToPackage(packageName: string, targetPackage: InstallablePackage): Promise<string> {\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to read package.json file')\n })\n\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return packageName\n }\n\n const version =\n targetPackage.pkg.path ?? `${targetPackage.type}:${targetPackage.pkg.name}@${targetPackage.pkg.version}`\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n pkgJson.bpDependencies = { [packageName]: version }\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n return packageName\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResult = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResult.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n const { data: validatedBpDeps } = parseResult\n\n const alreadyPresentDep = Object.entries(validatedBpDeps).find(([key]) => key === packageName)\n if (alreadyPresentDep) {\n const alreadyPresentVersion = alreadyPresentDep[1]\n if (alreadyPresentVersion !== version) {\n this.logger.warn(\n `The dependency with alias ${packageName} is already present in the bpDependencies of package.json, but with version ${alreadyPresentVersion}.`\n )\n const res = await this.prompt.confirm(`Do you want to overwrite the dependency with version ${version}?`)\n if (!res) {\n const newAlias = await this._chooseNewAlias(validatedBpDeps)\n packageName = newAlias\n }\n }\n }\n\n pkgJson.bpDependencies = {\n ...validatedBpDeps,\n [packageName]: version,\n }\n\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n return packageName\n }\n}\n\n// this is a hack to avoid refactoring the project command class\nclass _AnyProjectCommand extends ProjectCommand<ProjectCommandDefinition> {\n public async run(): Promise<void> {\n throw new errors.BotpressCLIError('Not implemented')\n }\n\n public readProjectDefinitionFromFS(): ProjectDefinitionLazy {\n return super.readProjectDefinitionFromFS()\n }\n\n public async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n return super.prepareCreateIntegrationBody(integrationDef)\n }\n\n public get projectCache(): utils.cache.FSKeyValueCache<ProjectCache> {\n return super.projectCache\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AACrB,YAAuB;AACvB,cAAyB;AACzB,eAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAC9B,6BAMO;AAmBA,MAAM,mBAAmB,oCAAoC;AAAA,EAClE,MAAa,MAAqB;AAChC,UAAM,MAAM,KAAK,cAAc;AAC/B,QAAI,KAAK;AACP,aAAO,MAAM,KAAK,qBAAqB,EAAE,GAAG,KAAK,OAAO,KAAK,KAAK,MAAM,CAAC;AAAA,IAC3E;AAEA,UAAM,UAAU,MAAM,MAAM,QAAQ,gBAAgB,KAAK,KAAK,WAAW,EAAE,MAAM,CAAC,WAAW;AAC3F,YAAM,OAAO,iBAAiB,KAAK,QAAQ,kCAAkC;AAAA,IAC/E,CAAC;AAED,QAAI,CAAC,SAAS;AACZ,WAAK,OAAO,KAAK,2CAA2C;AAC5D;AAAA,IACF;AAEA,UAAM,EAAE,eAAe,IAAI;AAC3B,QAAI,CAAC,gBAAgB;AACnB,WAAK,OAAO,IAAI,0CAA0C;AAC1D;AAAA,IACF;AAEA,UAAM,uBAAuB,IAAI,EAAE,OAAO,IAAI,EAAE,OAAO,CAAC;AACxD,UAAM,eAAe,qBAAqB,UAAU,cAAc;AAClE,QAAI,CAAC,aAAa,SAAS;AACzB,YAAM,IAAI,OAAO,iBAAiB,8CAA8C;AAAA,IAClF;AAEA,UAAM,kBAAkB,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,KAAK,WAAW;AACvF,UAAM,cAAc,MAAM,KAAK,KAAK,iBAAiB,OAAO,cAAc;AAC1E,UAAM,OAAO,aAAa,EAAE,OAAO,MAAM,WAAW,KAAK,CAAC;AAC1D,UAAM,UAAU,WAAW;AAE3B,eAAW,CAAC,UAAU,SAAS,KAAK,OAAO,QAAQ,aAAa,IAAI,GAAG;AACrE,YAAM,SAAS,OAAO,gBAAgB,SAAS;AAC/C,UAAI,CAAC,QAAQ;AACX,cAAM,IAAI,OAAO,6BAA6B,SAAS;AAAA,MACzD;
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as fslib from 'fs'\nimport * as pathlib from 'path'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as pkgRef from '../package-ref'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\nimport {\n ProjectCache,\n ProjectCommand,\n ProjectCommandDefinition,\n ProjectDefinitionLazy,\n ProjectDefinition,\n} from './project-command'\n\ntype InstallablePackage =\n | {\n type: 'integration'\n pkg: codegen.IntegrationInstallablePackage\n }\n | {\n type: 'interface'\n pkg: codegen.InterfaceInstallablePackage\n }\n | {\n type: 'plugin'\n pkg: codegen.PluginInstallablePackage\n }\n\ntype RefWithAlias = pkgRef.PackageRef & { alias?: string }\n\nexport type AddCommandDefinition = typeof commandDefinitions.add\nexport class AddCommand extends GlobalCommand<AddCommandDefinition> {\n public async run(): Promise<void> {\n const ref = this._parseArgvRef()\n if (ref) {\n return await this._addNewSinglePackage({ ...ref, alias: this.argv.alias })\n }\n\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to read package.json file')\n })\n\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return\n }\n\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n this.logger.log('No bp dependencies found in package.json')\n return\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResults = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResults.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath)\n const modulesPath = utils.path.join(baseInstallPath, consts.installDirName)\n fslib.rmSync(modulesPath, { force: true, recursive: true })\n fslib.mkdirSync(modulesPath)\n\n for (const [pkgAlias, pkgRefStr] of Object.entries(parseResults.data)) {\n const parsed = pkgRef.parsePackageRef(pkgRefStr)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(pkgRefStr)\n }\n\n // Resolve path refs against installPath so reinstall works regardless of cwd\n const normalized =\n parsed.type === 'path' ? { ...parsed, path: utils.path.absoluteFrom(baseInstallPath, parsed.path) } : parsed\n const refWithAlias = { ...normalized, alias: pkgAlias }\n const foundPkg = await this._findPackage(refWithAlias)\n await this._addSinglePackage(refWithAlias, foundPkg)\n }\n }\n\n private _parseArgvRef = (): pkgRef.PackageRef | undefined => {\n if (!this.argv.packageRef) {\n return\n }\n\n const parsed = pkgRef.parsePackageRef(this.argv.packageRef)\n if (!parsed) {\n throw new errors.InvalidPackageReferenceError(this.argv.packageRef)\n }\n\n return parsed\n }\n\n private async _addSinglePackage(\n ref: RefWithAlias,\n props: { packageName: string; targetPackage: InstallablePackage }\n ) {\n const { packageName, targetPackage } = props\n\n const baseInstallPath = utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath)\n const packageDirName = utils.casing.to.kebabCase(packageName)\n const installPath = utils.path.join(baseInstallPath, consts.installDirName, packageDirName)\n\n const alreadyInstalled = fslib.existsSync(installPath)\n if (alreadyInstalled) {\n await this._uninstall(installPath)\n }\n\n if (ref.type === 'name') {\n targetPackage.pkg.version = ref.version\n }\n\n let files: codegen.File[]\n if (targetPackage.type === 'integration') {\n files = await codegen.generateIntegrationPackage(targetPackage.pkg)\n } else if (targetPackage.type === 'interface') {\n files = await codegen.generateInterfacePackage(targetPackage.pkg)\n } else if (targetPackage.type === 'plugin') {\n files = await codegen.generatePluginPackage(targetPackage.pkg)\n } else {\n type _assertion = utils.types.AssertNever<typeof targetPackage>\n throw new errors.BotpressCLIError('Invalid package type')\n }\n\n await this._install(installPath, files)\n }\n private async _chooseNewAlias(existingPackages: Record<string, string>) {\n const setAliasConfirmation = await this.prompt.confirm(\n 'Do you want to set an alias to the package you are installing?'\n )\n if (!setAliasConfirmation) {\n throw new errors.AbortedOperationError()\n }\n\n const alias = this._chooseUnusedAlias(existingPackages)\n\n return alias\n }\n\n private async _chooseUnusedAlias(existingPackages: Record<string, string>): Promise<string> {\n const alias = await this.prompt.text('Enter the new alias')\n const existingAlias = Object.entries(existingPackages).find(([dep, _]) => dep === alias)\n\n if (!alias) {\n throw new errors.BotpressCLIError('You cannot set an empty alias')\n }\n if (!existingAlias) {\n return alias\n }\n\n if (\n await this.prompt.confirm(\n `The alias ${alias} is already used for dependency ${existingAlias[1]}. Do you want to overwrite it?`\n )\n ) {\n return alias\n }\n return this._chooseUnusedAlias(existingPackages)\n }\n\n private async _addNewSinglePackage(ref: RefWithAlias) {\n const foundPackage = await this._findPackage(ref)\n const targetPackage = foundPackage.targetPackage\n const isDevPackage = targetPackage.type === 'integration' && !!targetPackage.pkg.devId\n let packageName: string\n if (isDevPackage) {\n this.logger.debug('Skipping bpDependencies update for dev integration')\n packageName = foundPackage.packageName\n } else {\n packageName = await this._addDependencyToPackage(ref, foundPackage.packageName, targetPackage)\n }\n await this._addSinglePackage(ref, { packageName, targetPackage })\n }\n\n private async _findPackage(ref: RefWithAlias): Promise<{ packageName: string; targetPackage: InstallablePackage }> {\n const targetPackage = ref.type === 'path' ? await this._findLocalPackage(ref) : await this._findRemotePackage(ref)\n if (!targetPackage) {\n const strRef = pkgRef.formatPackageRef(ref)\n throw new errors.BotpressCLIError(`Could not find package \"${strRef}\"`)\n }\n const packageName = ref.alias ?? targetPackage.pkg.name\n\n return { packageName, targetPackage }\n }\n\n private async _findRemotePackage(ref: pkgRef.ApiPackageRef): Promise<InstallablePackage | undefined> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n if (this._pkgCouldBe(ref, 'integration')) {\n const integration = await api.findPublicOrPrivateIntegration(ref)\n if (integration) {\n const { name, version } = integration\n return { type: 'integration', pkg: { integration, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'interface')) {\n const intrface = await api.findPublicOrPrivateInterface(ref)\n if (intrface) {\n const { name, version } = intrface\n return { type: 'interface', pkg: { interface: intrface, name, version } }\n }\n }\n if (this._pkgCouldBe(ref, 'plugin')) {\n const plugin = await api.findPublicOrPrivatePlugin(ref)\n if (plugin) {\n const { code } = plugin.public\n ? await api.client.getPublicPluginCode({ id: plugin.id, platform: 'node' })\n : await api.client.getPluginCode({ id: plugin.id, platform: 'node' })\n const { name, version } = plugin\n return {\n type: 'plugin',\n pkg: {\n name,\n version,\n plugin,\n code,\n },\n }\n }\n }\n return\n }\n\n private async _findLocalPackage(ref: pkgRef.LocalPackageRef): Promise<InstallablePackage | undefined> {\n const absPath = utils.path.absoluteFrom(utils.path.cwd(), ref.path)\n const {\n definition: projectDefinition,\n implementation: projectImplementation,\n devId: projectDevId,\n } = await this._readProject(absPath)\n\n if (projectDefinition?.type === 'integration') {\n const { name, version } = projectDefinition.definition\n let devId: string | undefined\n if (this.argv.useDev && projectDevId) {\n this.logger.warn(`Installing integration \"${name}\" with dev version \"${projectDevId}\"`)\n devId = projectDevId\n }\n\n let createIntegrationReqBody = await this._getProjectCmd(ref.path).prepareCreateIntegrationBody(\n projectDefinition.definition\n )\n createIntegrationReqBody = {\n ...createIntegrationReqBody,\n interfaces: utils.records.mapValues(projectDefinition.definition.interfaces ?? {}, (i) => ({\n id: '', // TODO: do this better\n ...i,\n })),\n }\n return {\n type: 'integration',\n pkg: { path: absPath, devId, name, version, integration: createIntegrationReqBody },\n }\n }\n\n if (projectDefinition?.type === 'interface') {\n const { name, version } = projectDefinition.definition\n const createInterfaceReqBody = await apiUtils.prepareCreateInterfaceBody(projectDefinition.definition)\n return {\n type: 'interface',\n pkg: { path: absPath, name, version, interface: createInterfaceReqBody },\n }\n }\n\n if (projectDefinition?.type === 'plugin') {\n if (!projectImplementation) {\n throw new errors.BotpressCLIError(\n 'Plugin implementation not found; Please build the plugin project before installing'\n )\n }\n\n const pluginDefinition = projectDefinition.definition\n const { name, version } = pluginDefinition\n const code = projectImplementation\n\n const createPluginReqBody = await apiUtils.prepareCreatePluginBody(pluginDefinition)\n return {\n type: 'plugin',\n pkg: {\n path: absPath,\n name,\n version,\n code,\n plugin: {\n ...createPluginReqBody,\n dependencies: {\n interfaces: pluginDefinition.interfaces,\n integrations: pluginDefinition.integrations,\n },\n recurringEvents: pluginDefinition.recurringEvents,\n },\n },\n }\n }\n\n if (projectDefinition?.type === 'bot') {\n throw new errors.BotpressCLIError('Cannot install a bot as a package')\n }\n return\n }\n\n private async _install(installPath: utils.path.AbsolutePath, files: codegen.File[]): Promise<void> {\n const line = this.logger.line()\n line.started(`Installing ${files.length} files to \"${installPath}\"`)\n try {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(installPath, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fslib.promises.mkdir(dirPath, { recursive: true })\n await fslib.promises.writeFile(filePath, file.content)\n }\n line.success(`Installed ${files.length} files to \"${installPath}\"`)\n } finally {\n line.commit()\n }\n }\n\n private async _uninstall(installPath: utils.path.AbsolutePath): Promise<void> {\n await fslib.promises.rm(installPath, { recursive: true })\n }\n\n private async _readProject(workDir: utils.path.AbsolutePath): Promise<{\n definition?: ProjectDefinition\n implementation?: string\n devId?: string\n }> {\n const cmd = this._getProjectCmd(workDir)\n\n const { resolveProjectDefinition } = cmd.readProjectDefinitionFromFS()\n const definition = await resolveProjectDefinition().catch((thrown) => {\n if (thrown instanceof errors.ProjectDefinitionNotFoundError) {\n return undefined\n }\n throw thrown\n })\n\n const devId = await cmd.projectCache.get('devId').catch((thrown) => {\n const err = errors.BotpressCLIError.wrap(thrown, 'Failed to read project dev ID from cache')\n this.logger.debug(err.message)\n return undefined\n })\n\n const implementationAbsPath = utils.path.join(workDir, consts.fromWorkDir.outFileCJS)\n if (!fslib.existsSync(implementationAbsPath)) {\n return { definition, devId }\n }\n\n const implementation = await fslib.promises.readFile(implementationAbsPath, 'utf8')\n return { definition, implementation, devId }\n }\n\n private _pkgCouldBe = (ref: pkgRef.ApiPackageRef, pkgType: InstallablePackage['type']) => {\n if (ref.type === 'id') {\n // TODO: use ULID prefixes to determine the type of the package\n return true\n }\n if (!ref.pkg) {\n return true // ref does not specify the package type\n }\n return ref.pkg === pkgType\n }\n\n private _getProjectCmd(workDir: string): _AnyProjectCommand {\n return new _AnyProjectCommand(apiUtils.ApiClient, this.prompt, this.logger, {\n ...this.argv,\n workDir,\n })\n }\n\n private async _addDependencyToPackage(\n ref: RefWithAlias,\n packageName: string,\n targetPackage: InstallablePackage\n ): Promise<string> {\n const pkgJson = await utils.pkgJson.readPackageJson(this.argv.installPath).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to read package.json file')\n })\n\n if (!pkgJson) {\n this.logger.warn('No package.json found in the install path')\n return packageName\n }\n\n const version =\n ref.type === 'path'\n ? utils.path.relativePathFrom(\n utils.path.absoluteFrom(utils.path.cwd(), this.argv.installPath),\n utils.path.absoluteFrom(utils.path.cwd(), ref.path)\n )\n : `${targetPackage.type}:${targetPackage.pkg.name}@${targetPackage.pkg.version}`\n const { bpDependencies } = pkgJson\n if (!bpDependencies) {\n pkgJson.bpDependencies = { [packageName]: version }\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n return packageName\n }\n\n const bpDependenciesSchema = sdk.z.record(sdk.z.string())\n const parseResult = bpDependenciesSchema.safeParse(bpDependencies)\n if (!parseResult.success) {\n throw new errors.BotpressCLIError('Invalid bpDependencies found in package.json')\n }\n\n const { data: validatedBpDeps } = parseResult\n\n const alreadyPresentDep = Object.entries(validatedBpDeps).find(([key]) => key === packageName)\n if (alreadyPresentDep) {\n const alreadyPresentVersion = alreadyPresentDep[1]\n if (alreadyPresentVersion !== version) {\n this.logger.warn(\n `The dependency with alias ${packageName} is already present in the bpDependencies of package.json, but with version ${alreadyPresentVersion}.`\n )\n const res = await this.prompt.confirm(`Do you want to overwrite the dependency with version ${version}?`)\n if (!res) {\n const newAlias = await this._chooseNewAlias(validatedBpDeps)\n packageName = newAlias\n }\n }\n }\n\n pkgJson.bpDependencies = {\n ...validatedBpDeps,\n [packageName]: version,\n }\n\n await utils.pkgJson.writePackageJson(this.argv.installPath, pkgJson)\n return packageName\n }\n}\n\n// this is a hack to avoid refactoring the project command class\nclass _AnyProjectCommand extends ProjectCommand<ProjectCommandDefinition> {\n public async run(): Promise<void> {\n throw new errors.BotpressCLIError('Not implemented')\n }\n\n public readProjectDefinitionFromFS(): ProjectDefinitionLazy {\n return super.readProjectDefinitionFromFS()\n }\n\n public async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n return super.prepareCreateIntegrationBody(integrationDef)\n }\n\n public get projectCache(): utils.cache.FSKeyValueCache<ProjectCache> {\n return super.projectCache\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AACrB,YAAuB;AACvB,cAAyB;AACzB,eAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAC9B,6BAMO;AAmBA,MAAM,mBAAmB,oCAAoC;AAAA,EAClE,MAAa,MAAqB;AAChC,UAAM,MAAM,KAAK,cAAc;AAC/B,QAAI,KAAK;AACP,aAAO,MAAM,KAAK,qBAAqB,EAAE,GAAG,KAAK,OAAO,KAAK,KAAK,MAAM,CAAC;AAAA,IAC3E;AAEA,UAAM,UAAU,MAAM,MAAM,QAAQ,gBAAgB,KAAK,KAAK,WAAW,E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AACnE,WAAO,MAAM;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,6 +21,13 @@ export declare const toUnix: (path: string) => string;
|
|
|
21
21
|
export declare const toNormalizedPosixPath: (path: string) => string;
|
|
22
22
|
export declare const absoluteFrom: (rootdir: AbsolutePath, target: string) => AbsolutePath;
|
|
23
23
|
export declare const relativeFrom: (rootdir: AbsolutePath, target: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Same as relativeFrom but ensures the result starts with './' or '../',
|
|
26
|
+
* so it is recognized as a path ref by parsePackageRef.
|
|
27
|
+
* Falls back to the absolute target path when rootdir and target are on
|
|
28
|
+
* different drives (Windows), since no relative path is possible.
|
|
29
|
+
*/
|
|
30
|
+
export declare const relativePathFrom: (rootdir: AbsolutePath, target: string) => string;
|
|
24
31
|
export declare class PathStore<P extends string> {
|
|
25
32
|
readonly abs: Record<P, AbsolutePath>;
|
|
26
33
|
constructor(abs: Record<P, AbsolutePath>);
|
package/dist/utils/path-utils.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(path_utils_exports, {
|
|
|
37
37
|
join: () => join,
|
|
38
38
|
posix: () => posix,
|
|
39
39
|
relativeFrom: () => relativeFrom,
|
|
40
|
+
relativePathFrom: () => relativePathFrom,
|
|
40
41
|
rmExtension: () => rmExtension,
|
|
41
42
|
toNormalizedPosixPath: () => toNormalizedPosixPath,
|
|
42
43
|
toUnix: () => toUnix,
|
|
@@ -84,6 +85,14 @@ const relativeFrom = (rootdir, target) => {
|
|
|
84
85
|
}
|
|
85
86
|
return import_path.default.relative(rootdir, absPath);
|
|
86
87
|
};
|
|
88
|
+
const relativePathFrom = (rootdir, target) => {
|
|
89
|
+
const rel = relativeFrom(rootdir, target);
|
|
90
|
+
if (isPlatformSpecificAbsolutePath(rel)) {
|
|
91
|
+
return rel;
|
|
92
|
+
}
|
|
93
|
+
const unix = toUnix(rel);
|
|
94
|
+
return unix.startsWith("./") || unix.startsWith("../") ? unix : `./${unix}`;
|
|
95
|
+
};
|
|
87
96
|
class PathStore {
|
|
88
97
|
constructor(abs) {
|
|
89
98
|
this.abs = abs;
|
|
@@ -103,6 +112,7 @@ class PathStore {
|
|
|
103
112
|
join,
|
|
104
113
|
posix,
|
|
105
114
|
relativeFrom,
|
|
115
|
+
relativePathFrom,
|
|
106
116
|
rmExtension,
|
|
107
117
|
toNormalizedPosixPath,
|
|
108
118
|
toUnix,
|
|
@@ -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}\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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,OAAO;AACL,cAAU,YAAAA,QAAQ,QAAQ,YAAAA,QAAQ,KAAK,SAAS,MAAM,CAAC;AAAA,EACzD;AAEA,SAAO,YAAAA,QAAQ,SAAS,SAAS,OAAO;AAC1C;AAEO,MAAM,UAA4B;AAAA,EAChC,YAA4B,KAA8B;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\n/**\n * Same as relativeFrom but ensures the result starts with './' or '../',\n * so it is recognized as a path ref by parsePackageRef.\n * Falls back to the absolute target path when rootdir and target are on\n * different drives (Windows), since no relative path is possible.\n */\nexport const relativePathFrom = (rootdir: AbsolutePath, target: string) => {\n const rel = relativeFrom(rootdir, target)\n if (isPlatformSpecificAbsolutePath(rel)) {\n return rel // different drives on Windows \u2014 keep absolute\n }\n const unix = toUnix(rel)\n return unix.startsWith('./') || unix.startsWith('../') ? unix : `./${unix}`\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;AAAA,oBAAc;AACd,gBAAkB;AAClB,kBAAoB;AAEb,IAAU;AAAA,CAAV,CAAUA,WAAV;AAEE,EAAMA,OAAA,SAAS,CAAC,aAAi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AAW,OAAO,GAAG,CAAC,EAAE,QAAQ,SAAS,EAAE;AAEzG,MAAM,eAAe,CAAC,SAAuB,WAAiC;AACnF,MAAI,+BAA+B,MAAM,GAAG;AAC1C,WAAO;AAAA,EACT;AACA,SAAO,YAAAA,QAAQ,KAAK,SAAS,MAAM;AACrC;AAEO,MAAM,eAAe,CAAC,SAAuB,WAAmB;AACrE,MAAI;AAEJ,MAAI,+BAA+B,MAAM,GAAG;AAC1C,cAAU;AAAA,EACZ,OAAO;AACL,cAAU,YAAAA,QAAQ,QAAQ,YAAAA,QAAQ,KAAK,SAAS,MAAM,CAAC;AAAA,EACzD;AAEA,SAAO,YAAAA,QAAQ,SAAS,SAAS,OAAO;AAC1C;AAQO,MAAM,mBAAmB,CAAC,SAAuB,WAAmB;AACzE,QAAM,MAAM,aAAa,SAAS,MAAM;AACxC,MAAI,+BAA+B,GAAG,GAAG;AACvC,WAAO;AAAA,EACT;AACA,QAAM,OAAO,OAAO,GAAG;AACvB,SAAO,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK,IAAI,OAAO,KAAK,IAAI;AAC3E;AAEO,MAAM,UAA4B;AAAA,EAChC,YAA4B,KAA8B;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;",
|
|
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": "6.3.
|
|
3
|
+
"version": "6.3.4",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@apidevtools/json-schema-ref-parser": "^11.7.0",
|
|
29
29
|
"@botpress/chat": "0.5.5",
|
|
30
|
-
"@botpress/client": "1.
|
|
31
|
-
"@botpress/sdk": "6.4.
|
|
30
|
+
"@botpress/client": "1.40.0",
|
|
31
|
+
"@botpress/sdk": "6.4.5",
|
|
32
32
|
"@bpinternal/const": "^0.1.0",
|
|
33
33
|
"@bpinternal/tunnel": "^0.1.1",
|
|
34
34
|
"@bpinternal/verel": "^0.2.0",
|