@botpress/cli 0.2.5 → 0.2.7
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/e2e/index.ts +14 -1
- package/e2e/tests/create-deploy-bot.ts +2 -1
- package/e2e/tests/create-deploy-integration.ts +2 -1
- package/e2e/tests/dev-bot.ts +2 -1
- package/e2e/typings.ts +1 -0
- package/e2e/utils.ts +31 -0
- package/package.json +3 -3
- package/templates/echo-bot/package.json +2 -2
- package/templates/echo-bot/src/index.ts +1 -1
- package/templates/empty-integration/package.json +2 -2
package/e2e/index.ts
CHANGED
|
@@ -45,6 +45,14 @@ const configSchema = {
|
|
|
45
45
|
type: 'string',
|
|
46
46
|
default: consts.defaultTunnelUrl,
|
|
47
47
|
},
|
|
48
|
+
sdkPath: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Path to the Botpress SDK to install; Allows using a version not released on NPM yet.',
|
|
51
|
+
},
|
|
52
|
+
clientPath: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Path to the Botpress Client to install; Allows using a version not released on NPM yet.',
|
|
55
|
+
},
|
|
48
56
|
} satisfies YargsSchema
|
|
49
57
|
|
|
50
58
|
const main = async (argv: YargsConfig<typeof configSchema>): Promise<never> => {
|
|
@@ -54,6 +62,11 @@ const main = async (argv: YargsConfig<typeof configSchema>): Promise<never> => {
|
|
|
54
62
|
const filteredTests = tests.filter(({ name }) => (filterRegex ? filterRegex.test(name) : true))
|
|
55
63
|
logger.info(`Running ${filteredTests.length} / ${tests.length} tests`)
|
|
56
64
|
|
|
65
|
+
const dependencies = { '@botpress/sdk': argv.sdkPath, '@botpress/client': argv.clientPath } satisfies Record<
|
|
66
|
+
string,
|
|
67
|
+
string | undefined
|
|
68
|
+
>
|
|
69
|
+
|
|
57
70
|
for (const { name, handler } of filteredTests) {
|
|
58
71
|
const logLine = `### Running test: "${name}" ###`
|
|
59
72
|
const logPad = '#'.repeat(logLine.length)
|
|
@@ -64,7 +77,7 @@ const main = async (argv: YargsConfig<typeof configSchema>): Promise<never> => {
|
|
|
64
77
|
const tmpDir = TmpDirectory.create()
|
|
65
78
|
try {
|
|
66
79
|
const t0 = Date.now()
|
|
67
|
-
await Promise.race([handler({ tmpDir: tmpDir.path, ...argv }), timeout(argv.timeout)])
|
|
80
|
+
await Promise.race([handler({ tmpDir: tmpDir.path, dependencies, ...argv }), timeout(argv.timeout)])
|
|
68
81
|
const t1 = Date.now()
|
|
69
82
|
logger.info(`SUCCESS: "${name}" (${t1 - t0}ms)`)
|
|
70
83
|
} catch (thrown) {
|
|
@@ -14,7 +14,7 @@ const fetchBot = async (client: Client, botName: string): Promise<ApiBot | undef
|
|
|
14
14
|
|
|
15
15
|
export const createDeployBot: Test = {
|
|
16
16
|
name: 'cli should allow creating, building, deploying and mannaging a bot',
|
|
17
|
-
handler: async ({ tmpDir, ...creds }) => {
|
|
17
|
+
handler: async ({ tmpDir, dependencies, ...creds }) => {
|
|
18
18
|
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
19
19
|
const baseDir = pathlib.join(tmpDir, 'bots')
|
|
20
20
|
const botName = uuid.v4()
|
|
@@ -30,6 +30,7 @@ export const createDeployBot: Test = {
|
|
|
30
30
|
const client = new Client({ host: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
|
|
31
31
|
|
|
32
32
|
await impl.init({ ...argv, workDir: baseDir, name: botName, type: 'bot' }).then(utils.handleExitCode)
|
|
33
|
+
await utils.fixBotpressDependencies({ workDir: botDir, target: dependencies })
|
|
33
34
|
await utils.npmInstall({ workDir: botDir }).then(utils.handleExitCode)
|
|
34
35
|
await impl.build({ ...argv, workDir: botDir }).then(utils.handleExitCode)
|
|
35
36
|
await impl.login({ ...argv }).then(utils.handleExitCode)
|
|
@@ -15,7 +15,7 @@ const fetchIntegration = async (client: Client, integrationName: string): Promis
|
|
|
15
15
|
|
|
16
16
|
export const createDeployIntegration: Test = {
|
|
17
17
|
name: 'cli should allow creating, building, deploying and mannaging an integration',
|
|
18
|
-
handler: async ({ tmpDir, ...creds }) => {
|
|
18
|
+
handler: async ({ tmpDir, dependencies, ...creds }) => {
|
|
19
19
|
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
20
20
|
const baseDir = pathlib.join(tmpDir, 'integrations')
|
|
21
21
|
const integrationName = `myintegration-${uuid.v4()}`.replace(/-/g, '')
|
|
@@ -33,6 +33,7 @@ export const createDeployIntegration: Test = {
|
|
|
33
33
|
await impl
|
|
34
34
|
.init({ ...argv, workDir: baseDir, name: integrationName, type: 'integration' })
|
|
35
35
|
.then(utils.handleExitCode)
|
|
36
|
+
await utils.fixBotpressDependencies({ workDir: integrationDir, target: dependencies })
|
|
36
37
|
await utils.npmInstall({ workDir: integrationDir }).then(utils.handleExitCode)
|
|
37
38
|
await impl.build({ ...argv, workDir: integrationDir }).then(utils.handleExitCode)
|
|
38
39
|
await impl.login({ ...argv }).then(utils.handleExitCode)
|
package/e2e/tests/dev-bot.ts
CHANGED
|
@@ -16,7 +16,7 @@ const PORT = 8075
|
|
|
16
16
|
|
|
17
17
|
export const devBot: Test = {
|
|
18
18
|
name: 'cli should allow creating and running a bot locally',
|
|
19
|
-
handler: async ({ tmpDir, tunnelUrl, ...creds }) => {
|
|
19
|
+
handler: async ({ tmpDir, tunnelUrl, dependencies, ...creds }) => {
|
|
20
20
|
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
21
21
|
const baseDir = pathlib.join(tmpDir, 'bots')
|
|
22
22
|
const botName = uuid.v4()
|
|
@@ -30,6 +30,7 @@ export const devBot: Test = {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
await impl.init({ ...argv, workDir: baseDir, name: botName, type: 'bot' }).then(handleExitCode)
|
|
33
|
+
await utils.fixBotpressDependencies({ workDir: botDir, target: dependencies })
|
|
33
34
|
await utils.npmInstall({ workDir: botDir }).then(handleExitCode)
|
|
34
35
|
await impl.login({ ...argv }).then(handleExitCode)
|
|
35
36
|
|
package/e2e/typings.ts
CHANGED
package/e2e/utils.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import childprocess from 'child_process'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import _ from 'lodash'
|
|
4
|
+
import pathlib from 'path'
|
|
2
5
|
import tmp from 'tmp'
|
|
3
6
|
|
|
7
|
+
type PackageJson = {
|
|
8
|
+
name: string
|
|
9
|
+
version?: string
|
|
10
|
+
description?: string
|
|
11
|
+
scripts?: Record<string, string>
|
|
12
|
+
dependencies?: Record<string, string>
|
|
13
|
+
devDependencies?: Record<string, string>
|
|
14
|
+
peerDependencies?: Record<string, string>
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
export const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))
|
|
5
18
|
|
|
6
19
|
export class TmpDirectory {
|
|
@@ -35,6 +48,24 @@ export const npmInstall = async ({ workDir }: { workDir: string }) => {
|
|
|
35
48
|
return { exitCode: status ?? 0 }
|
|
36
49
|
}
|
|
37
50
|
|
|
51
|
+
export const fixBotpressDependencies = async ({
|
|
52
|
+
workDir,
|
|
53
|
+
target,
|
|
54
|
+
}: {
|
|
55
|
+
workDir: string
|
|
56
|
+
target: Record<string, string | undefined>
|
|
57
|
+
}) => {
|
|
58
|
+
const packageJsonPath = pathlib.join(workDir, 'package.json')
|
|
59
|
+
const originalPackageJson: PackageJson = require(packageJsonPath)
|
|
60
|
+
|
|
61
|
+
const newPackageJson = {
|
|
62
|
+
...originalPackageJson,
|
|
63
|
+
dependencies: _.mapValues(originalPackageJson.dependencies ?? {}, (version, name) => target[name] ?? version),
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(newPackageJson, null, 2))
|
|
67
|
+
}
|
|
68
|
+
|
|
38
69
|
export const handleExitCode = ({ exitCode }: { exitCode: number }) => {
|
|
39
70
|
if (exitCode !== 0) {
|
|
40
71
|
throw new Error(`Command exited with code ${exitCode}`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run bundle && pnpm run template:gen",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"main": "dist/index.js",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@botpress/client": "0.
|
|
23
|
+
"@botpress/client": "0.3.0",
|
|
24
24
|
"@bpinternal/tunnel": "^0.1.0",
|
|
25
25
|
"@bpinternal/yargs-extra": "^0.0.3",
|
|
26
26
|
"@parcel/watcher": "^2.1.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"zod-to-json-schema": "^3.20.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@botpress/sdk": "0.1
|
|
50
|
+
"@botpress/sdk": "0.2.1",
|
|
51
51
|
"@bpinternal/log4bot": "^0.0.4",
|
|
52
52
|
"@types/bluebird": "^3.5.38",
|
|
53
53
|
"@types/prompts": "^2.0.14",
|