@botpress/cli 4.15.1 → 4.16.0
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-definitions.js +15 -1
- package/dist/command-definitions.js.map +2 -2
- package/dist/command-implementations/global-command.js +27 -9
- package/dist/command-implementations/global-command.js.map +2 -2
- package/dist/command-implementations/index.js +9 -1
- package/dist/command-implementations/index.js.map +2 -2
- package/dist/command-implementations/init-command.js +1 -1
- package/dist/command-implementations/init-command.js.map +2 -2
- package/dist/command-implementations/login-command.js +28 -0
- package/dist/command-implementations/login-command.js.map +2 -2
- package/dist/command-implementations/profile-commands.js +104 -0
- package/dist/command-implementations/profile-commands.js.map +7 -0
- package/dist/config.js +21 -2
- package/dist/config.js.map +2 -2
- package/dist/consts.js +3 -0
- package/dist/consts.js.map +2 -2
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@4.
|
|
2
|
+
> @botpress/cli@4.16.0 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.
|
|
6
|
+
> @botpress/cli@4.16.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@4.
|
|
10
|
+
> @botpress/cli@4.16.0 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.
|
|
14
|
-
🤖 Botpress CLI v4.
|
|
15
|
-
🤖 Botpress CLI v4.
|
|
16
|
-
🤖 Botpress CLI v4.
|
|
13
|
+
🤖 Botpress CLI v4.16.0
|
|
14
|
+
🤖 Botpress CLI v4.16.0
|
|
15
|
+
🤖 Botpress CLI v4.16.0
|
|
16
|
+
🤖 Botpress CLI v4.16.0
|
|
17
|
+
○ Generating typings for plugin empty-plugin...
|
|
18
|
+
✓ Typings available at .botpress
|
|
19
|
+
|
|
17
20
|
○ Generating typings for bot...
|
|
18
21
|
✓ Typings available at .botpress
|
|
19
22
|
|
|
@@ -21,12 +24,9 @@
|
|
|
21
24
|
○ Generating typings for integration empty-integration...
|
|
22
25
|
✓ Typings available at .botpress
|
|
23
26
|
|
|
24
|
-
○ Generating typings for plugin empty-plugin...
|
|
25
|
-
✓ Typings available at .botpress
|
|
26
|
-
|
|
27
27
|
✓ Typings available at .botpress
|
|
28
28
|
|
|
29
|
-
🤖 Botpress CLI v4.
|
|
29
|
+
🤖 Botpress CLI v4.16.0
|
|
30
30
|
○ Generating typings for integration webhook-message...
|
|
31
31
|
✓ Typings available at .botpress
|
|
32
32
|
|
|
@@ -78,7 +78,21 @@ var command_definitions_default = {
|
|
|
78
78
|
add: { description: "Install a package; could be an integration or an interface", schema: config.schemas.add },
|
|
79
79
|
dev: { description: "Run your project in dev mode", schema: config.schemas.dev },
|
|
80
80
|
lint: { description: "EXPERIMENTAL: Lint an integration definition", schema: config.schemas.lint },
|
|
81
|
-
chat: { description: "EXPERIMENTAL: Chat with a bot directly from the CLI", schema: config.schemas.chat }
|
|
81
|
+
chat: { description: "EXPERIMENTAL: Chat with a bot directly from the CLI", schema: config.schemas.chat },
|
|
82
|
+
profiles: {
|
|
83
|
+
description: "Commands for using CLI profiles",
|
|
84
|
+
subcommands: {
|
|
85
|
+
list: { description: "List all available profiles", schema: config.schemas.listProfiles, alias: "ls" },
|
|
86
|
+
active: {
|
|
87
|
+
description: "Get the profile properties you are currently using",
|
|
88
|
+
schema: config.schemas.activeProfile
|
|
89
|
+
},
|
|
90
|
+
use: {
|
|
91
|
+
description: "Set the current profile",
|
|
92
|
+
schema: config.schemas.useProfile
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
82
96
|
};
|
|
83
97
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
98
|
0 && (module.exports = {});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/command-definitions.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DefinitionTree } from './command-tree'\nimport * as config from './config'\n\nexport default {\n login: { description: 'Login to Botpress Cloud', schema: config.schemas.login },\n logout: { description: 'Logout of Botpress Cloud', schema: config.schemas.logout },\n bots: {\n description: 'Bot related commands',\n subcommands: {\n create: { description: 'Create new bot', schema: config.schemas.createBot, alias: 'new' },\n get: { description: 'Get bot', schema: config.schemas.getBot },\n delete: { description: 'Delete bot', schema: config.schemas.deleteBot, alias: 'rm' },\n list: { description: 'List bots', schema: config.schemas.listBots, alias: 'ls' },\n },\n },\n integrations: {\n description: 'Integration related commands',\n subcommands: {\n get: { description: 'Get integration', schema: config.schemas.getIntegration },\n delete: { description: 'Delete integration', schema: config.schemas.deleteIntegration, alias: 'rm' },\n list: { description: 'List integrations', schema: config.schemas.listIntegrations, alias: 'ls' },\n },\n },\n interfaces: {\n description: 'Interface related commands',\n subcommands: {\n get: { description: 'Get interface', schema: config.schemas.getInterface },\n delete: { description: 'Delete interface', schema: config.schemas.deleteInterface, alias: 'rm' },\n list: { description: 'List interfaces', schema: config.schemas.listInterfaces, alias: 'ls' },\n },\n },\n plugins: {\n description: 'Plugin related commands',\n subcommands: {\n get: { description: 'Get plugin', schema: config.schemas.getPlugin },\n delete: { description: 'Delete plugin', schema: config.schemas.deletePlugin, alias: 'rm' },\n list: { description: 'List plugins', schema: config.schemas.listPlugins, alias: 'ls' },\n },\n },\n init: { description: 'Initialize a new project', schema: config.schemas.init },\n generate: { description: 'Generate typings for intellisense', schema: config.schemas.generate, alias: 'gen' },\n bundle: { description: 'Bundle a botpress project', schema: config.schemas.bundle },\n build: { description: 'Generate typings and bundle a botpress project', schema: config.schemas.build },\n read: { description: 'Read and parse an integration definition', schema: config.schemas.read },\n serve: { description: 'Serve your project locally', schema: config.schemas.serve },\n deploy: { description: 'Deploy your project to the cloud', schema: config.schemas.deploy },\n add: { description: 'Install a package; could be an integration or an interface', schema: config.schemas.add },\n dev: { description: 'Run your project in dev mode', schema: config.schemas.dev },\n lint: { description: 'EXPERIMENTAL: Lint an integration definition', schema: config.schemas.lint },\n chat: { description: 'EXPERIMENTAL: Chat with a bot directly from the CLI', schema: config.schemas.chat },\n} satisfies DefinitionTree\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,IAAO,8BAAQ;AAAA,EACb,OAAO,EAAE,aAAa,2BAA2B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EAC9E,QAAQ,EAAE,aAAa,4BAA4B,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACjF,MAAM;AAAA,IACJ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,QAAQ,EAAE,aAAa,kBAAkB,QAAQ,OAAO,QAAQ,WAAW,OAAO,MAAM;AAAA,MACxF,KAAK,EAAE,aAAa,WAAW,QAAQ,OAAO,QAAQ,OAAO;AAAA,MAC7D,QAAQ,EAAE,aAAa,cAAc,QAAQ,OAAO,QAAQ,WAAW,OAAO,KAAK;AAAA,MACnF,MAAM,EAAE,aAAa,aAAa,QAAQ,OAAO,QAAQ,UAAU,OAAO,KAAK;AAAA,IACjF;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,KAAK,EAAE,aAAa,mBAAmB,QAAQ,OAAO,QAAQ,eAAe;AAAA,MAC7E,QAAQ,EAAE,aAAa,sBAAsB,QAAQ,OAAO,QAAQ,mBAAmB,OAAO,KAAK;AAAA,MACnG,MAAM,EAAE,aAAa,qBAAqB,QAAQ,OAAO,QAAQ,kBAAkB,OAAO,KAAK;AAAA,IACjG;AAAA,EACF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,QAAQ,OAAO,QAAQ,KAAK;AAAA,EACjG,MAAM,EAAE,aAAa,uDAAuD,QAAQ,OAAO,QAAQ,KAAK;
|
|
4
|
+
"sourcesContent": ["import type { DefinitionTree } from './command-tree'\nimport * as config from './config'\n\nexport default {\n login: { description: 'Login to Botpress Cloud', schema: config.schemas.login },\n logout: { description: 'Logout of Botpress Cloud', schema: config.schemas.logout },\n bots: {\n description: 'Bot related commands',\n subcommands: {\n create: { description: 'Create new bot', schema: config.schemas.createBot, alias: 'new' },\n get: { description: 'Get bot', schema: config.schemas.getBot },\n delete: { description: 'Delete bot', schema: config.schemas.deleteBot, alias: 'rm' },\n list: { description: 'List bots', schema: config.schemas.listBots, alias: 'ls' },\n },\n },\n integrations: {\n description: 'Integration related commands',\n subcommands: {\n get: { description: 'Get integration', schema: config.schemas.getIntegration },\n delete: { description: 'Delete integration', schema: config.schemas.deleteIntegration, alias: 'rm' },\n list: { description: 'List integrations', schema: config.schemas.listIntegrations, alias: 'ls' },\n },\n },\n interfaces: {\n description: 'Interface related commands',\n subcommands: {\n get: { description: 'Get interface', schema: config.schemas.getInterface },\n delete: { description: 'Delete interface', schema: config.schemas.deleteInterface, alias: 'rm' },\n list: { description: 'List interfaces', schema: config.schemas.listInterfaces, alias: 'ls' },\n },\n },\n plugins: {\n description: 'Plugin related commands',\n subcommands: {\n get: { description: 'Get plugin', schema: config.schemas.getPlugin },\n delete: { description: 'Delete plugin', schema: config.schemas.deletePlugin, alias: 'rm' },\n list: { description: 'List plugins', schema: config.schemas.listPlugins, alias: 'ls' },\n },\n },\n init: { description: 'Initialize a new project', schema: config.schemas.init },\n generate: { description: 'Generate typings for intellisense', schema: config.schemas.generate, alias: 'gen' },\n bundle: { description: 'Bundle a botpress project', schema: config.schemas.bundle },\n build: { description: 'Generate typings and bundle a botpress project', schema: config.schemas.build },\n read: { description: 'Read and parse an integration definition', schema: config.schemas.read },\n serve: { description: 'Serve your project locally', schema: config.schemas.serve },\n deploy: { description: 'Deploy your project to the cloud', schema: config.schemas.deploy },\n add: { description: 'Install a package; could be an integration or an interface', schema: config.schemas.add },\n dev: { description: 'Run your project in dev mode', schema: config.schemas.dev },\n lint: { description: 'EXPERIMENTAL: Lint an integration definition', schema: config.schemas.lint },\n chat: { description: 'EXPERIMENTAL: Chat with a bot directly from the CLI', schema: config.schemas.chat },\n profiles: {\n description: 'Commands for using CLI profiles',\n subcommands: {\n list: { description: 'List all available profiles', schema: config.schemas.listProfiles, alias: 'ls' },\n active: {\n description: 'Get the profile properties you are currently using',\n schema: config.schemas.activeProfile,\n },\n use: {\n description: 'Set the current profile',\n schema: config.schemas.useProfile,\n },\n },\n },\n} satisfies DefinitionTree\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,IAAO,8BAAQ;AAAA,EACb,OAAO,EAAE,aAAa,2BAA2B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EAC9E,QAAQ,EAAE,aAAa,4BAA4B,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACjF,MAAM;AAAA,IACJ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,QAAQ,EAAE,aAAa,kBAAkB,QAAQ,OAAO,QAAQ,WAAW,OAAO,MAAM;AAAA,MACxF,KAAK,EAAE,aAAa,WAAW,QAAQ,OAAO,QAAQ,OAAO;AAAA,MAC7D,QAAQ,EAAE,aAAa,cAAc,QAAQ,OAAO,QAAQ,WAAW,OAAO,KAAK;AAAA,MACnF,MAAM,EAAE,aAAa,aAAa,QAAQ,OAAO,QAAQ,UAAU,OAAO,KAAK;AAAA,IACjF;AAAA,EACF;AAAA,EACA,cAAc;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,KAAK,EAAE,aAAa,mBAAmB,QAAQ,OAAO,QAAQ,eAAe;AAAA,MAC7E,QAAQ,EAAE,aAAa,sBAAsB,QAAQ,OAAO,QAAQ,mBAAmB,OAAO,K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;AAAA,EAC7G,KAAK,EAAE,aAAa,gCAAgC,QAAQ,OAAO,QAAQ,IAAI;AAAA,EAC/E,MAAM,EAAE,aAAa,gDAAgD,QAAQ,OAAO,QAAQ,KAAK;AAAA,EACjG,MAAM,EAAE,aAAa,uDAAuD,QAAQ,OAAO,QAAQ,KAAK;AAAA,EACxG,UAAU;AAAA,IACR,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM,EAAE,aAAa,+BAA+B,QAAQ,OAAO,QAAQ,cAAc,OAAO,KAAK;AAAA,MACrG,QAAQ;AAAA,QACN,aAAa;AAAA,QACb,QAAQ,OAAO,QAAQ;AAAA,MACzB;AAAA,MACA,KAAK;AAAA,QACH,aAAa;AAAA,QACb,QAAQ,OAAO,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -94,7 +94,7 @@ class GlobalCommand extends import_base_command.BaseCommand {
|
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
;
|
|
97
|
-
({ token, workspaceId, apiUrl } = await this.
|
|
97
|
+
({ token, workspaceId, apiUrl } = await this.readProfileFromFS(this.argv.profile));
|
|
98
98
|
this.logger.log(`Using profile "${this.argv.profile}"`, { prefix: "\u{1F464}" });
|
|
99
99
|
} else {
|
|
100
100
|
token = credentials.token ?? await cache.get("token");
|
|
@@ -109,23 +109,41 @@ class GlobalCommand extends import_base_command.BaseCommand {
|
|
|
109
109
|
}
|
|
110
110
|
return this.api.newClient({ apiUrl, token, workspaceId }, this.logger);
|
|
111
111
|
}
|
|
112
|
-
async
|
|
112
|
+
async readProfileFromFS(profile) {
|
|
113
|
+
const parsedProfiles = await this.readProfilesFromFS();
|
|
114
|
+
const profileData = parsedProfiles[profile];
|
|
115
|
+
if (!profileData) {
|
|
116
|
+
throw new errors.BotpressCLIError(
|
|
117
|
+
`Profile "${profile}" not found in "${this.globalPaths.abs.profilesPath}". Found profiles '${Object.keys(parsedProfiles).join("', '")}'.`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return profileData;
|
|
121
|
+
}
|
|
122
|
+
async readProfilesFromFS() {
|
|
113
123
|
if (!fs.existsSync(this.globalPaths.abs.profilesPath)) {
|
|
114
124
|
throw new errors.BotpressCLIError(`Profile file not found at "${this.globalPaths.abs.profilesPath}"`);
|
|
115
125
|
}
|
|
116
126
|
const fileContent = await fs.promises.readFile(this.globalPaths.abs.profilesPath, "utf-8");
|
|
117
127
|
const parsedProfiles = JSON.parse(fileContent);
|
|
118
|
-
const zodParseResult = import_sdk.z.record(profileCredentialSchema).safeParse(parsedProfiles
|
|
128
|
+
const zodParseResult = import_sdk.z.record(profileCredentialSchema).safeParse(parsedProfiles);
|
|
119
129
|
if (!zodParseResult.success) {
|
|
120
130
|
throw errors.BotpressCLIError.wrap(zodParseResult.error, "Error parsing profiles: ");
|
|
121
131
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
return zodParseResult.data;
|
|
133
|
+
}
|
|
134
|
+
async writeProfileToFS(profileName, profile) {
|
|
135
|
+
let profiles;
|
|
136
|
+
if (fs.existsSync(this.globalPaths.abs.profilesPath)) {
|
|
137
|
+
profiles = await this.readProfilesFromFS();
|
|
138
|
+
} else {
|
|
139
|
+
profiles = {};
|
|
127
140
|
}
|
|
128
|
-
|
|
141
|
+
profiles[profileName] = profile;
|
|
142
|
+
await fs.promises.writeFile(
|
|
143
|
+
this.globalPaths.abs.profilesPath,
|
|
144
|
+
JSON.stringify({ [consts.defaultProfileName]: profiles.defaultProfileName, ...profiles }, null, 2),
|
|
145
|
+
"utf-8"
|
|
146
|
+
);
|
|
129
147
|
}
|
|
130
148
|
async ensureLoginAndCreateClient(credentials) {
|
|
131
149
|
const client = await this.getAuthenticatedClient(credentials);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/global-command.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport latestVersion from 'latest-version'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport type { ApiClientFactory } from '../api/client'\nimport * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { BaseCommand } from './base-command'\n\nexport type GlobalCommandDefinition = CommandDefinition<typeof config.schemas.global>\nexport type GlobalCache = { apiUrl: string; token: string; workspaceId: string }\n\nexport type ConfigurableGlobalPaths = {\n botpressHomeDir: string\n cliRootDir: utils.path.AbsolutePath\n profilesPath: string\n}\nexport type ConstantGlobalPaths = typeof consts.fromHomeDir & typeof consts.fromCliRootDir\nexport type AllGlobalPaths = ConfigurableGlobalPaths & ConstantGlobalPaths\n\nconst profileCredentialSchema = z.object({ apiUrl: z.string(), workspaceId: z.string(), token: z.string() })\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAElB,mBAAkB;AAClB,SAAoB;AACpB,4BAA0B;AAC1B,oBAAc;AACd,oBAAmB;AAGnB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,0BAA4B;AAa5B,MAAM,0BAA0B,aAAE,OAAO,EAAE,QAAQ,aAAE,OAAO,GAAG,aAAa,aAAE,OAAO,GAAG,OAAO,aAAE,OAAO,EAAE,CAAC;AAG3G,MAAM,oBAAoB,MAAM,KAAK,UAAgC;AAAA,EAC5D,YAAY,MAA4C;AAC7D,UAAM,kBAAkB,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,YAAY;AACnF,UAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,iBAAiB;AAAA,MACjB,cAAc,MAAM,KAAK,aAAa,iB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K,OAAO;AAAA,UACV;AAAA,QACF;AAAA,MACF;AACA;AAAC,OAAC,EAAE,OAAO,aAAa,OAAO,IAAI,MAAM,KAAK,
|
|
4
|
+
"sourcesContent": ["import { z } from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport latestVersion from 'latest-version'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport type { ApiClientFactory } from '../api/client'\nimport * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { BaseCommand } from './base-command'\n\nexport type GlobalCommandDefinition = CommandDefinition<typeof config.schemas.global>\nexport type GlobalCache = { apiUrl: string; token: string; workspaceId: string; activeProfile: string }\n\nexport type ConfigurableGlobalPaths = {\n botpressHomeDir: string\n cliRootDir: utils.path.AbsolutePath\n profilesPath: string\n}\nexport type ConstantGlobalPaths = typeof consts.fromHomeDir & typeof consts.fromCliRootDir\nexport type AllGlobalPaths = ConfigurableGlobalPaths & ConstantGlobalPaths\n\nconst profileCredentialSchema = z.object({ apiUrl: z.string(), workspaceId: z.string(), token: z.string() })\nexport type ProfileCredentials = z.infer<typeof profileCredentialSchema>\n\nclass GlobalPaths extends utils.path.PathStore<keyof AllGlobalPaths> {\n public constructor(argv: CommandArgv<GlobalCommandDefinition>) {\n const absBotpressHome = utils.path.absoluteFrom(utils.path.cwd(), argv.botpressHome)\n super({\n cliRootDir: consts.cliRootDir,\n botpressHomeDir: absBotpressHome,\n profilesPath: utils.path.absoluteFrom(absBotpressHome, consts.profileFileName),\n ..._.mapValues(consts.fromHomeDir, (p) => utils.path.absoluteFrom(absBotpressHome, p)),\n ..._.mapValues(consts.fromCliRootDir, (p) => utils.path.absoluteFrom(consts.cliRootDir, p)),\n })\n }\n}\n\nexport abstract class GlobalCommand<C extends GlobalCommandDefinition> extends BaseCommand<C> {\n protected api: ApiClientFactory\n protected prompt: utils.prompt.CLIPrompt\n private _pkgJson: utils.pkgJson.PackageJson | undefined\n\n public constructor(\n api: ApiClientFactory,\n prompt: utils.prompt.CLIPrompt,\n ...args: ConstructorParameters<typeof BaseCommand<C>>\n ) {\n super(...args)\n this.api = api\n this.prompt = prompt\n }\n\n protected get globalPaths() {\n return new GlobalPaths(this.argv)\n }\n\n protected get globalCache() {\n return new utils.cache.FSKeyValueCache<GlobalCache>(this.globalPaths.abs.globalCacheFile)\n }\n\n protected override async bootstrap() {\n const pkgJson = await this.readPkgJson()\n const versionText = chalk.bold(`v${pkgJson.version}`)\n this.logger.log(`Botpress CLI ${versionText}`, { prefix: '\uD83E\uDD16' })\n\n await this._notifyUpdateCli()\n\n const paths = this.globalPaths\n if (paths.abs.botpressHomeDir !== consts.defaultBotpressHome) {\n this.logger.log(`Using custom botpress home: ${paths.abs.botpressHomeDir}`, { prefix: '\uD83C\uDFE0' })\n }\n }\n\n protected override teardown = async () => {\n this.logger.cleanup()\n }\n\n protected async getAuthenticatedClient(credentials: Partial<YargsConfig<typeof config.schemas.credentials>>) {\n const cache = this.globalCache\n\n let token: string | undefined\n let workspaceId: string | undefined\n let apiUrl: string | undefined\n\n if (this.argv.profile) {\n if (credentials.token || credentials.workspaceId || credentials.apiUrl) {\n this.logger.warn(\n 'You are currently using credential command line arguments or environment variables as well as a profile. Your profile has overwritten the variables'\n )\n }\n ;({ token, workspaceId, apiUrl } = await this.readProfileFromFS(this.argv.profile))\n this.logger.log(`Using profile \"${this.argv.profile}\"`, { prefix: '\uD83D\uDC64' })\n } else {\n token = credentials.token ?? (await cache.get('token'))\n workspaceId = credentials.workspaceId ?? (await cache.get('workspaceId'))\n apiUrl = credentials.apiUrl ?? (await cache.get('apiUrl'))\n }\n\n if (!(token && workspaceId && apiUrl)) {\n return null\n }\n\n if (apiUrl !== consts.defaultBotpressApiUrl) {\n this.logger.log(`Using custom url ${apiUrl}`, { prefix: '\uD83D\uDD17' })\n }\n\n return this.api.newClient({ apiUrl, token, workspaceId }, this.logger)\n }\n\n protected async readProfileFromFS(profile: string): Promise<ProfileCredentials> {\n const parsedProfiles = await this.readProfilesFromFS()\n\n const profileData = parsedProfiles[profile]\n if (!profileData) {\n throw new errors.BotpressCLIError(\n `Profile \"${profile}\" not found in \"${this.globalPaths.abs.profilesPath}\". Found profiles '${Object.keys(parsedProfiles).join(\"', '\")}'.`\n )\n }\n\n return profileData\n }\n\n protected async readProfilesFromFS(): Promise<Record<string, ProfileCredentials>> {\n if (!fs.existsSync(this.globalPaths.abs.profilesPath)) {\n throw new errors.BotpressCLIError(`Profile file not found at \"${this.globalPaths.abs.profilesPath}\"`)\n }\n const fileContent = await fs.promises.readFile(this.globalPaths.abs.profilesPath, 'utf-8')\n const parsedProfiles = JSON.parse(fileContent)\n\n const zodParseResult = z.record(profileCredentialSchema).safeParse(parsedProfiles)\n if (!zodParseResult.success) {\n throw errors.BotpressCLIError.wrap(zodParseResult.error, 'Error parsing profiles: ')\n }\n\n return zodParseResult.data\n }\n\n protected async writeProfileToFS(profileName: string, profile: ProfileCredentials): Promise<void> {\n let profiles: Record<string, ProfileCredentials>\n if (fs.existsSync(this.globalPaths.abs.profilesPath)) {\n profiles = await this.readProfilesFromFS()\n } else {\n profiles = {}\n }\n profiles[profileName] = profile\n\n await fs.promises.writeFile(\n this.globalPaths.abs.profilesPath,\n JSON.stringify({ [consts.defaultProfileName]: profiles.defaultProfileName, ...profiles }, null, 2),\n 'utf-8'\n )\n }\n\n protected async ensureLoginAndCreateClient(credentials: YargsConfig<typeof config.schemas.credentials>) {\n const client = await this.getAuthenticatedClient(credentials)\n\n if (client === null) {\n throw new errors.NotLoggedInError()\n }\n\n return client\n }\n\n private readonly _notifyUpdateCli = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if cli is up to date')\n\n const pkgJson = await this.readPkgJson()\n if (!pkgJson.version) {\n throw new errors.BotpressCLIError('Could not find version in package.json')\n }\n\n const latest = await latestVersion(pkgJson.name)\n const isOutdated = semver.lt(pkgJson.version, latest)\n if (isOutdated) {\n this.logger.box(\n [\n `${chalk.bold('Update available')} ${chalk.dim(pkgJson.version)} \u2192 ${chalk.green(latest)}`,\n '',\n 'To update, run:',\n ` for npm ${chalk.cyan(`npm i -g ${pkgJson.name}`)}`,\n ` for yarn ${chalk.cyan(`yarn global add ${pkgJson.name}`)}`,\n ` for pnpm ${chalk.cyan(`pnpm i -g ${pkgJson.name}`)}`,\n ].join('\\n')\n )\n }\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if cli is up to date: ${err.message}`)\n }\n }\n\n protected async readPkgJson(): Promise<utils.pkgJson.PackageJson> {\n if (this._pkgJson) {\n return this._pkgJson\n }\n const { cliRootDir } = this.globalPaths.abs\n const pkgJson = await utils.pkgJson.readPackageJson(cliRootDir)\n if (!pkgJson) {\n throw new errors.BotpressCLIError(`Could not find package.json at \"${cliRootDir}\"`)\n }\n\n this._pkgJson = pkgJson\n return pkgJson\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAElB,mBAAkB;AAClB,SAAoB;AACpB,4BAA0B;AAC1B,oBAAc;AACd,oBAAmB;AAGnB,aAAwB;AACxB,aAAwB;AAExB,YAAuB;AACvB,0BAA4B;AAa5B,MAAM,0BAA0B,aAAE,OAAO,EAAE,QAAQ,aAAE,OAAO,GAAG,aAAa,aAAE,OAAO,GAAG,OAAO,aAAE,OAAO,EAAE,CAAC;AAG3G,MAAM,oBAAoB,MAAM,KAAK,UAAgC;AAAA,EAC5D,YAAY,MAA4C;AAC7D,UAAM,kBAAkB,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,YAAY;AACnF,UAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,iBAAiB;AAAA,MACjB,cAAc,MAAM,KAAK,aAAa,iBAAiB,OAAO,eAAe;AAAA,MAC7E,GAAG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AAM;AAAA,YACnD,cAAc,aAAAA,QAAM,KAAK,mBAAmB,QAAQ,MAAM;AAAA,YAC1D,cAAc,aAAAA,QAAM,KAAK,aAAa,QAAQ,MAAM;AAAA,UACtD,EAAE,KAAK,IAAI;AAAA,QACb;AAAA,MACF;AAAA,IACF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AAAA,EAEA,MAAgB,cAAkD;AAChE,QAAI,KAAK,UAAU;AACjB,aAAO,KAAK;AAAA,IACd;AACA,UAAM,EAAE,WAAW,IAAI,KAAK,YAAY;AACxC,UAAM,UAAU,MAAM,MAAM,QAAQ,gBAAgB,UAAU;AAC9D,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,OAAO,iBAAiB,mCAAmC,aAAa;AAAA,IACpF;AAEA,SAAK,WAAW;AAChB,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["_", "chalk", "latestVersion", "semver"]
|
|
7
7
|
}
|
|
@@ -49,6 +49,7 @@ var import_lint_command = require("./lint-command");
|
|
|
49
49
|
var import_login_command = require("./login-command");
|
|
50
50
|
var import_logout_command = require("./logout-command");
|
|
51
51
|
var plugins = __toESM(require("./plugin-commands"));
|
|
52
|
+
var profiles = __toESM(require("./profile-commands"));
|
|
52
53
|
var import_read_command = require("./read-command");
|
|
53
54
|
var import_serve_command = require("./serve-command");
|
|
54
55
|
const getHandler = (cls) => async (argv) => {
|
|
@@ -98,7 +99,14 @@ var command_implementations_default = {
|
|
|
98
99
|
add: getHandler(import_add_command.AddCommand),
|
|
99
100
|
dev: getHandler(import_dev_command.DevCommand),
|
|
100
101
|
lint: getHandler(import_lint_command.LintCommand),
|
|
101
|
-
chat: getHandler(import_chat_command.ChatCommand)
|
|
102
|
+
chat: getHandler(import_chat_command.ChatCommand),
|
|
103
|
+
profiles: {
|
|
104
|
+
subcommands: {
|
|
105
|
+
list: getHandler(profiles.ListProfilesCommand),
|
|
106
|
+
active: getHandler(profiles.ActiveProfileCommand),
|
|
107
|
+
use: getHandler(profiles.UseProfileCommand)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
102
110
|
};
|
|
103
111
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
112
|
0 && (module.exports = {});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { ApiClient } from '../api/client'\nimport type commandDefinitions from '../command-definitions'\nimport type { ImplementationTree } from '../command-tree'\nimport { Logger } from '../logger'\nimport type { CommandArgv } from '../typings'\nimport * as utils from '../utils'\nimport { AddCommand } from './add-command'\nimport type { BaseCommand } from './base-command'\nimport * as bots from './bot-commands'\nimport { BuildCommand } from './build-command'\nimport { BundleCommand } from './bundle-command'\nimport { ChatCommand } from './chat-command'\nimport { DeployCommand } from './deploy-command'\nimport { DevCommand } from './dev-command'\nimport { GenerateCommand } from './gen-command'\nimport type { GlobalCommand, GlobalCommandDefinition } from './global-command'\nimport { InitCommand } from './init-command'\nimport * as integrations from './integration-commands'\nimport * as interfaces from './interface-commands'\nimport { LintCommand } from './lint-command'\nimport { LoginCommand } from './login-command'\nimport { LogoutCommand } from './logout-command'\nimport * as plugins from './plugin-commands'\nimport { ReadCommand } from './read-command'\nimport { ServeCommand } from './serve-command'\n\ntype GlobalCtor<C extends GlobalCommandDefinition> = new (\n ...args: ConstructorParameters<typeof GlobalCommand<C>>\n) => BaseCommand<C>\n\nconst getHandler =\n <C extends GlobalCommandDefinition>(cls: GlobalCtor<C>) =>\n async (argv: CommandArgv<C>) => {\n const logger = new Logger(argv)\n const prompt = new utils.prompt.CLIPrompt(argv, logger)\n return new cls(ApiClient, prompt, logger, argv).handler()\n }\n\nexport default {\n login: getHandler(LoginCommand),\n logout: getHandler(LogoutCommand),\n bots: {\n subcommands: {\n create: getHandler(bots.CreateBotCommand),\n get: getHandler(bots.GetBotCommand),\n delete: getHandler(bots.DeleteBotCommand),\n list: getHandler(bots.ListBotsCommand),\n },\n },\n integrations: {\n subcommands: {\n get: getHandler(integrations.GetIntegrationCommand),\n list: getHandler(integrations.ListIntegrationsCommand),\n delete: getHandler(integrations.DeleteIntegrationCommand),\n },\n },\n interfaces: {\n subcommands: {\n get: getHandler(interfaces.GetInterfaceCommand),\n list: getHandler(interfaces.ListInterfacesCommand),\n delete: getHandler(interfaces.DeleteInterfaceCommand),\n },\n },\n plugins: {\n subcommands: {\n get: getHandler(plugins.GetPluginCommand),\n list: getHandler(plugins.ListPluginsCommand),\n delete: getHandler(plugins.DeletePluginCommand),\n },\n },\n init: getHandler(InitCommand),\n generate: getHandler(GenerateCommand),\n bundle: getHandler(BundleCommand),\n build: getHandler(BuildCommand),\n read: getHandler(ReadCommand),\n serve: getHandler(ServeCommand),\n deploy: getHandler(DeployCommand),\n add: getHandler(AddCommand),\n dev: getHandler(DevCommand),\n lint: getHandler(LintCommand),\n chat: getHandler(ChatCommand),\n} satisfies ImplementationTree<typeof commandDefinitions>\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAG1B,oBAAuB;AAEvB,YAAuB;AACvB,yBAA2B;AAE3B,WAAsB;AACtB,2BAA6B;AAC7B,4BAA8B;AAC9B,0BAA4B;AAC5B,4BAA8B;AAC9B,yBAA2B;AAC3B,yBAAgC;AAEhC,0BAA4B;AAC5B,mBAA8B;AAC9B,iBAA4B;AAC5B,0BAA4B;AAC5B,2BAA6B;AAC7B,4BAA8B;AAC9B,cAAyB;AACzB,0BAA4B;AAC5B,2BAA6B;AAM7B,MAAM,aACJ,CAAoC,QACpC,OAAO,SAAyB;AAC9B,QAAM,SAAS,IAAI,qBAAO,IAAI;AAC9B,QAAM,SAAS,IAAI,MAAM,OAAO,UAAU,MAAM,MAAM;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AAW,+BAAW;
|
|
4
|
+
"sourcesContent": ["import { ApiClient } from '../api/client'\nimport type commandDefinitions from '../command-definitions'\nimport type { ImplementationTree } from '../command-tree'\nimport { Logger } from '../logger'\nimport type { CommandArgv } from '../typings'\nimport * as utils from '../utils'\nimport { AddCommand } from './add-command'\nimport type { BaseCommand } from './base-command'\nimport * as bots from './bot-commands'\nimport { BuildCommand } from './build-command'\nimport { BundleCommand } from './bundle-command'\nimport { ChatCommand } from './chat-command'\nimport { DeployCommand } from './deploy-command'\nimport { DevCommand } from './dev-command'\nimport { GenerateCommand } from './gen-command'\nimport type { GlobalCommand, GlobalCommandDefinition } from './global-command'\nimport { InitCommand } from './init-command'\nimport * as integrations from './integration-commands'\nimport * as interfaces from './interface-commands'\nimport { LintCommand } from './lint-command'\nimport { LoginCommand } from './login-command'\nimport { LogoutCommand } from './logout-command'\nimport * as plugins from './plugin-commands'\nimport * as profiles from './profile-commands'\nimport { ReadCommand } from './read-command'\nimport { ServeCommand } from './serve-command'\n\ntype GlobalCtor<C extends GlobalCommandDefinition> = new (\n ...args: ConstructorParameters<typeof GlobalCommand<C>>\n) => BaseCommand<C>\n\nconst getHandler =\n <C extends GlobalCommandDefinition>(cls: GlobalCtor<C>) =>\n async (argv: CommandArgv<C>) => {\n const logger = new Logger(argv)\n const prompt = new utils.prompt.CLIPrompt(argv, logger)\n return new cls(ApiClient, prompt, logger, argv).handler()\n }\n\nexport default {\n login: getHandler(LoginCommand),\n logout: getHandler(LogoutCommand),\n bots: {\n subcommands: {\n create: getHandler(bots.CreateBotCommand),\n get: getHandler(bots.GetBotCommand),\n delete: getHandler(bots.DeleteBotCommand),\n list: getHandler(bots.ListBotsCommand),\n },\n },\n integrations: {\n subcommands: {\n get: getHandler(integrations.GetIntegrationCommand),\n list: getHandler(integrations.ListIntegrationsCommand),\n delete: getHandler(integrations.DeleteIntegrationCommand),\n },\n },\n interfaces: {\n subcommands: {\n get: getHandler(interfaces.GetInterfaceCommand),\n list: getHandler(interfaces.ListInterfacesCommand),\n delete: getHandler(interfaces.DeleteInterfaceCommand),\n },\n },\n plugins: {\n subcommands: {\n get: getHandler(plugins.GetPluginCommand),\n list: getHandler(plugins.ListPluginsCommand),\n delete: getHandler(plugins.DeletePluginCommand),\n },\n },\n init: getHandler(InitCommand),\n generate: getHandler(GenerateCommand),\n bundle: getHandler(BundleCommand),\n build: getHandler(BuildCommand),\n read: getHandler(ReadCommand),\n serve: getHandler(ServeCommand),\n deploy: getHandler(DeployCommand),\n add: getHandler(AddCommand),\n dev: getHandler(DevCommand),\n lint: getHandler(LintCommand),\n chat: getHandler(ChatCommand),\n profiles: {\n subcommands: {\n list: getHandler(profiles.ListProfilesCommand),\n active: getHandler(profiles.ActiveProfileCommand),\n use: getHandler(profiles.UseProfileCommand),\n },\n },\n} satisfies ImplementationTree<typeof commandDefinitions>\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAG1B,oBAAuB;AAEvB,YAAuB;AACvB,yBAA2B;AAE3B,WAAsB;AACtB,2BAA6B;AAC7B,4BAA8B;AAC9B,0BAA4B;AAC5B,4BAA8B;AAC9B,yBAA2B;AAC3B,yBAAgC;AAEhC,0BAA4B;AAC5B,mBAA8B;AAC9B,iBAA4B;AAC5B,0BAA4B;AAC5B,2BAA6B;AAC7B,4BAA8B;AAC9B,cAAyB;AACzB,eAA0B;AAC1B,0BAA4B;AAC5B,2BAA6B;AAM7B,MAAM,aACJ,CAAoC,QACpC,OAAO,SAAyB;AAC9B,QAAM,SAAS,IAAI,qBAAO,IAAI;AAC9B,QAAM,SAAS,IAAI,MAAM,OAAO,UAAU,MAAM,MAAM;AACtD,SAAO,IAAI,IAAI,yBAAW,QAAQ,QAAQ,IAAI,EAAE,QAAQ;AAC1D;AAEF,IAAO,kCAAQ;AAAA,EACb,OAAO,WAAW,iCAAY;AAAA,EAC9B,QAAQ,WAAW,mCAAa;AAAA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iB;AAAA,IAC5C;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -183,7 +183,7 @@ class InitCommand extends import_global_command.GlobalCommand {
|
|
|
183
183
|
if (!destinationCanBeUsed) {
|
|
184
184
|
throw new errors.AbortedOperationError();
|
|
185
185
|
}
|
|
186
|
-
await fs.promises.cp(srcDir, destination, { recursive: true
|
|
186
|
+
await fs.promises.cp(srcDir, destination, { recursive: true });
|
|
187
187
|
const pkgJsonPath = pathlib.join(destination, "package.json");
|
|
188
188
|
const strContent = await fs.promises.readFile(pkgJsonPath, "utf-8");
|
|
189
189
|
const json = JSON.parse(strContent);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/init-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from 'src/api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { Logger } from '../logger'\nimport { ProjectTemplates } from '../project-templates'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nconst projectTypes = ['bot', 'integration', 'plugin'] as const\ntype ProjectType = (typeof projectTypes)[number]\n\ntype CopyProps = { srcDir: string; destDir: string; name: string; pkgJson: Record<string, unknown> }\n\nexport type InitCommandDefinition = typeof commandDefinitions.init\nexport class InitCommand extends GlobalCommand<InitCommandDefinition> {\n public async run(): Promise<void> {\n const projectType = await this._promptProjectType()\n const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir)\n\n if (projectType === 'bot') {\n await this._initBot({ workDir })\n return\n }\n\n if (projectType === 'integration') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initIntegration({ workDir, workspaceHandle })\n return\n }\n\n if (projectType === 'plugin') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initPlugin({ workDir, workspaceHandle })\n return\n }\n\n type _assertion = utils.types.AssertNever<typeof projectType>\n throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`)\n }\n\n private async _promptWorkspaceHandle() {\n const client = (await this.getAuthenticatedClient({})) ?? undefined\n\n const nameParts = this.argv.name?.split('/', 2) ?? []\n const workspaceHandle = nameParts.length > 1 ? nameParts[0] : undefined\n\n const resolver = await WorkspaceResolver.from({\n client,\n workspaceHandle,\n prompt: this.prompt,\n logger: this.logger,\n })\n\n return await resolver.getWorkspaceHandle()\n }\n\n private async _promptProjectType() {\n if (this.argv.type) {\n return this.argv.type\n }\n\n const promptedType = await this.prompt.select('What type of project do you wish to initialize?', {\n choices: projectTypes.map((t) => ({ title: t, value: t })),\n })\n\n if (!promptedType) {\n throw new errors.ParamRequiredError('Project Type')\n }\n\n return promptedType\n }\n\n private _initPlugin = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('plugin')\n const name = await this._getName('plugin', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n try {\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n pluginName: fullName,\n },\n })\n } catch (error) {\n if (error instanceof errors.AbortedOperationError) {\n this.logger.log('Aborted')\n return\n }\n throw error\n }\n this.logger.success(`Plugin project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n }\n\n private async _getOrPromptForTemplate(type: ProjectType): Promise<ProjectTemplates.Template> {\n const availableTemplates = ProjectTemplates.templates[type]\n\n if (this.argv.template) {\n const template = availableTemplates.find((t) => t.identifier === this.argv.template)\n if (!template) {\n throw new errors.BotpressCLIError(`No ${type} template found for identifier \"${this.argv.template}\"`)\n }\n return template\n }\n\n if (availableTemplates.length === 1) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return await this._promptForTemplate(availableTemplates)\n }\n\n private async _promptForTemplate(\n availableTemplates: ProjectTemplates.TemplateArray\n ): Promise<ProjectTemplates.Template> {\n const templateIndex = await this.prompt.select<number>('Which template do you want to use?', {\n choices: availableTemplates.map((template, index) => ({\n title: template.fullName,\n value: index,\n })),\n default: 0,\n })\n\n if (templateIndex === undefined || templateIndex < 0 || templateIndex >= availableTemplates.length) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return availableTemplates[templateIndex]!\n }\n\n private _getFullNameAndShortName(args: { workspaceHandle: string; name: string }) {\n const [workspaceOrName, projectName] = args.name.split('/', 2)\n const shortName = projectName ?? workspaceOrName!\n const fullName = `${args.workspaceHandle}/${shortName}`\n\n return { shortName, fullName }\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const template = await this._getOrPromptForTemplate('bot')\n const name = await this._getName('bot', template.defaultProjectName)\n\n await this._copy({ srcDir: template.absolutePath, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(pathlib.join(workDir, name))}`)\n }\n\n private _initIntegration = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('integration')\n const name = await this._getName('integration', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n integrationName: fullName,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n return\n }\n\n private _getName = async (projectType: ProjectType, defaultName: string): Promise<string> => {\n if (this.argv.name) {\n return this.argv.name\n }\n const promptMessage = `What is the name of your ${projectType}?`\n const promptedName = await this.prompt.text(promptMessage, { initial: defaultName })\n if (!promptedName) {\n throw new errors.ParamRequiredError('Project Name')\n }\n return promptedName\n }\n\n private _copy = async (props: CopyProps) => {\n const { srcDir, destDir, name, pkgJson } = props\n\n const dirName = utils.casing.to.kebabCase(name)\n const destination = pathlib.join(destDir, dirName)\n\n const destinationCanBeUsed = await this._checkIfDestinationCanBeUsed(destination)\n if (!destinationCanBeUsed) {\n throw new errors.AbortedOperationError()\n }\n\n await fs.promises.cp(srcDir, destination, { recursive: true, filter: (src) => !src.includes('node_modules') })\n\n const pkgJsonPath = pathlib.join(destination, 'package.json')\n const strContent = await fs.promises.readFile(pkgJsonPath, 'utf-8')\n const json = JSON.parse(strContent)\n\n const pkgJsonName = utils.casing.to.snakeCase(name)\n const updatedJson = { name: pkgJsonName, ...json, ...pkgJson }\n await fs.promises.writeFile(pkgJsonPath, JSON.stringify(updatedJson, null, 2))\n }\n\n private _checkIfDestinationCanBeUsed = async (destination: string) => {\n if (fs.existsSync(destination)) {\n const override = await this.prompt.confirm(\n `Directory ${chalk.bold(destination)} already exists. Do you want to overwrite it?`\n )\n if (!override) {\n return false\n }\n }\n return true\n }\n}\n\nclass WorkspaceResolver {\n private _workspaces: client.Workspace[] = []\n private _currentWorkspace?: client.Workspace\n\n private constructor(\n private readonly _client: ApiClient | undefined,\n private readonly _workspaceHandle: string | undefined,\n private readonly _prompt: utils.prompt.CLIPrompt,\n private readonly _logger: Logger\n ) {}\n\n public static async from({\n client,\n workspaceHandle,\n prompt,\n logger,\n }: {\n client?: ApiClient\n workspaceHandle?: string\n prompt: utils.prompt.CLIPrompt\n logger: Logger\n }): Promise<WorkspaceResolver> {\n const resolver = new WorkspaceResolver(client, workspaceHandle, prompt, logger)\n await resolver._fetchWorkspaces()\n return resolver\n }\n\n public async getWorkspaceHandle(): Promise<string> {\n if (this._hasNoWorkspaces()) {\n return this._promptForArbitraryWorkspaceHandle()\n }\n\n const workspace = await this._promptUserToSelectWorkspace()\n return workspace.handle || (await this._assignHandleToWorkspace(workspace))\n }\n\n private async _fetchWorkspaces(): Promise<void> {\n if (!this._isAuthenticated()) {\n return\n }\n\n const workspaces = await this._getClient()\n .client.list.workspaces({})\n .collect({})\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Unable to list your workspaces')\n })\n const currentWorkspace = workspaces.find((ws) => ws.id === this._getClient().workspaceId)\n\n this._workspaces = workspaces\n this._currentWorkspace = currentWorkspace\n }\n\n private _isAuthenticated(): boolean {\n return !!this._client\n }\n\n private _hasNoWorkspaces(): boolean {\n return !this._isAuthenticated() || this._workspaces.length === 0 || !this._currentWorkspace\n }\n\n private async _promptForArbitraryWorkspaceHandle(): Promise<string> {\n if (this._workspaceHandle) {\n return this._workspaceHandle\n }\n\n const handle = await this._prompt.text('Enter your workspace handle')\n\n if (!handle) {\n throw new errors.ParamRequiredError('Workspace handle')\n }\n\n return handle\n }\n\n private async _promptUserToSelectWorkspace(): Promise<client.Workspace> {\n const workspaceChoices = this._workspaces.map((ws) => ({\n title: ws.name,\n value: ws.id,\n }))\n\n const initialChoice = {\n title: this._currentWorkspace!.name,\n value: this._currentWorkspace!.id,\n }\n\n const workspaceId = await this._prompt.select('Which workspace do you want to use?', {\n initial: initialChoice,\n choices: workspaceChoices,\n })\n\n if (!workspaceId) {\n throw new errors.ParamRequiredError('Workspace')\n }\n\n return this._workspaces.find((ws) => ws.id === workspaceId)!\n }\n\n private async _assignHandleToWorkspace(workspace: client.Workspace): Promise<string> {\n this._logger.warn(\"It seems you don't have a workspace handle yet.\")\n\n let claimedHandle: string | undefined\n\n do {\n const desiredHandle = await this._promptForDesiredHandle()\n const isAvailable = await this._checkHandleAvailability(desiredHandle)\n\n if (isAvailable) {\n claimedHandle = desiredHandle\n await this._updateWorkspaceWithHandle(workspace.id, claimedHandle)\n }\n } while (!claimedHandle)\n\n this._logger.success(`Handle \"${claimedHandle}\" is yours!`)\n return claimedHandle\n }\n\n private async _promptForDesiredHandle(): Promise<string> {\n const desiredHandle = await this._prompt.text('Please enter a workspace handle')\n\n if (!desiredHandle) {\n throw new errors.BotpressCLIError('Workspace handle is required')\n }\n\n return desiredHandle\n }\n\n private async _checkHandleAvailability(handle: string): Promise<boolean> {\n const { available, suggestions } = await this._getClient().client.checkHandleAvailability({ handle })\n\n if (!available) {\n this._logger.warn(`Handle \"${handle}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n return false\n }\n\n return true\n }\n\n private async _updateWorkspaceWithHandle(workspaceId: string, handle: string): Promise<void> {\n try {\n await this._getClient().switchWorkspace(workspaceId).updateWorkspace({ handle })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${handle}\"`)\n }\n }\n\n private _getClient(): ApiClient {\n if (!this._client) {\n throw new errors.BotpressCLIError('Could not authenticate')\n }\n return this._client\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AAGzB,aAAwB;AAExB,+BAAiC;AACjC,YAAuB;AACvB,4BAA8B;AAE9B,MAAM,eAAe,CAAC,OAAO,eAAe,QAAQ;AAM7C,MAAM,oBAAoB,oCAAqC;AAAA,EACpE,MAAa,MAAqB;AAChC,UAAM,cAAc,MAAM,KAAK,mBAAmB;AAClD,UAAM,UAAU,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,KAAK,OAAO;AAE3E,QAAI,gBAAgB,OAAO;AACzB,YAAM,KAAK,SAAS,EAAE,QAAQ,CAAC;AAC/B;AAAA,IACF;AAEA,QAAI,gBAAgB,eAAe;AACjC,YAAM,kBAAkB,MAAM,KAAK,uBAAuB;AAC1D,YAAM,KAAK,iBAAiB,EAAE,SAAS,gBAAgB,CAAC;AACxD;AAAA,IACF;AAEA,QAAI,gBAAgB,UAAU;AAC5B,YAAM,kBAAkB,MAAM,KAAK,uBAAuB;AAC1D,YAAM,KAAK,YAAY,EAAE,SAAS,gBAAgB,CAAC;AACnD;AAAA,IACF;AAGA,UAAM,IAAI,OAAO,iBAAiB,yBAAyB,aAAa;AAAA,EAC1E;AAAA,EAEA,MAAc,yBAAyB;AACrC,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,UAAqB;AAC1C,UAAM,EAAE,QAAQ,SAAS,MAAM,QAAQ,IAAI;AAE3C,UAAM,UAAU,MAAM,OAAO,GAAG,UAAU,IAAI;AAC9C,UAAM,cAAc,QAAQ,KAAK,SAAS,OAAO;AAEjD,UAAM,uBAAuB,MAAM,KAAK,6BAA6B,WAAW;AAChF,QAAI,CAAC,sBAAsB;AACzB,YAAM,IAAI,OAAO,sBAAsB;AAAA,IACzC;AAEA,UAAM,GAAG,SAAS,GAAG,QAAQ,aAAa,EAAE,WAAW,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport { ApiClient } from 'src/api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { Logger } from '../logger'\nimport { ProjectTemplates } from '../project-templates'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nconst projectTypes = ['bot', 'integration', 'plugin'] as const\ntype ProjectType = (typeof projectTypes)[number]\n\ntype CopyProps = { srcDir: string; destDir: string; name: string; pkgJson: Record<string, unknown> }\n\nexport type InitCommandDefinition = typeof commandDefinitions.init\nexport class InitCommand extends GlobalCommand<InitCommandDefinition> {\n public async run(): Promise<void> {\n const projectType = await this._promptProjectType()\n const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir)\n\n if (projectType === 'bot') {\n await this._initBot({ workDir })\n return\n }\n\n if (projectType === 'integration') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initIntegration({ workDir, workspaceHandle })\n return\n }\n\n if (projectType === 'plugin') {\n const workspaceHandle = await this._promptWorkspaceHandle()\n await this._initPlugin({ workDir, workspaceHandle })\n return\n }\n\n type _assertion = utils.types.AssertNever<typeof projectType>\n throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`)\n }\n\n private async _promptWorkspaceHandle() {\n const client = (await this.getAuthenticatedClient({})) ?? undefined\n\n const nameParts = this.argv.name?.split('/', 2) ?? []\n const workspaceHandle = nameParts.length > 1 ? nameParts[0] : undefined\n\n const resolver = await WorkspaceResolver.from({\n client,\n workspaceHandle,\n prompt: this.prompt,\n logger: this.logger,\n })\n\n return await resolver.getWorkspaceHandle()\n }\n\n private async _promptProjectType() {\n if (this.argv.type) {\n return this.argv.type\n }\n\n const promptedType = await this.prompt.select('What type of project do you wish to initialize?', {\n choices: projectTypes.map((t) => ({ title: t, value: t })),\n })\n\n if (!promptedType) {\n throw new errors.ParamRequiredError('Project Type')\n }\n\n return promptedType\n }\n\n private _initPlugin = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('plugin')\n const name = await this._getName('plugin', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n try {\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n pluginName: fullName,\n },\n })\n } catch (error) {\n if (error instanceof errors.AbortedOperationError) {\n this.logger.log('Aborted')\n return\n }\n throw error\n }\n this.logger.success(`Plugin project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n }\n\n private async _getOrPromptForTemplate(type: ProjectType): Promise<ProjectTemplates.Template> {\n const availableTemplates = ProjectTemplates.templates[type]\n\n if (this.argv.template) {\n const template = availableTemplates.find((t) => t.identifier === this.argv.template)\n if (!template) {\n throw new errors.BotpressCLIError(`No ${type} template found for identifier \"${this.argv.template}\"`)\n }\n return template\n }\n\n if (availableTemplates.length === 1) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return await this._promptForTemplate(availableTemplates)\n }\n\n private async _promptForTemplate(\n availableTemplates: ProjectTemplates.TemplateArray\n ): Promise<ProjectTemplates.Template> {\n const templateIndex = await this.prompt.select<number>('Which template do you want to use?', {\n choices: availableTemplates.map((template, index) => ({\n title: template.fullName,\n value: index,\n })),\n default: 0,\n })\n\n if (templateIndex === undefined || templateIndex < 0 || templateIndex >= availableTemplates.length) {\n this.logger.log(`Using default template: ${chalk.bold(availableTemplates[0].fullName)}`)\n return availableTemplates[0]\n }\n\n return availableTemplates[templateIndex]!\n }\n\n private _getFullNameAndShortName(args: { workspaceHandle: string; name: string }) {\n const [workspaceOrName, projectName] = args.name.split('/', 2)\n const shortName = projectName ?? workspaceOrName!\n const fullName = `${args.workspaceHandle}/${shortName}`\n\n return { shortName, fullName }\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const template = await this._getOrPromptForTemplate('bot')\n const name = await this._getName('bot', template.defaultProjectName)\n\n await this._copy({ srcDir: template.absolutePath, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(pathlib.join(workDir, name))}`)\n }\n\n private _initIntegration = async (args: { workDir: string; workspaceHandle: string }) => {\n const { workDir, workspaceHandle } = args\n const template = await this._getOrPromptForTemplate('integration')\n const name = await this._getName('integration', template.defaultProjectName)\n const { fullName, shortName } = this._getFullNameAndShortName({ workspaceHandle, name })\n\n await this._copy({\n srcDir: template.absolutePath,\n destDir: workDir,\n name: shortName,\n pkgJson: {\n integrationName: fullName,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(pathlib.join(workDir, shortName))}`)\n return\n }\n\n private _getName = async (projectType: ProjectType, defaultName: string): Promise<string> => {\n if (this.argv.name) {\n return this.argv.name\n }\n const promptMessage = `What is the name of your ${projectType}?`\n const promptedName = await this.prompt.text(promptMessage, { initial: defaultName })\n if (!promptedName) {\n throw new errors.ParamRequiredError('Project Name')\n }\n return promptedName\n }\n\n private _copy = async (props: CopyProps) => {\n const { srcDir, destDir, name, pkgJson } = props\n\n const dirName = utils.casing.to.kebabCase(name)\n const destination = pathlib.join(destDir, dirName)\n\n const destinationCanBeUsed = await this._checkIfDestinationCanBeUsed(destination)\n if (!destinationCanBeUsed) {\n throw new errors.AbortedOperationError()\n }\n\n await fs.promises.cp(srcDir, destination, { recursive: true })\n\n const pkgJsonPath = pathlib.join(destination, 'package.json')\n const strContent = await fs.promises.readFile(pkgJsonPath, 'utf-8')\n const json = JSON.parse(strContent)\n\n const pkgJsonName = utils.casing.to.snakeCase(name)\n const updatedJson = { name: pkgJsonName, ...json, ...pkgJson }\n await fs.promises.writeFile(pkgJsonPath, JSON.stringify(updatedJson, null, 2))\n }\n\n private _checkIfDestinationCanBeUsed = async (destination: string) => {\n if (fs.existsSync(destination)) {\n const override = await this.prompt.confirm(\n `Directory ${chalk.bold(destination)} already exists. Do you want to overwrite it?`\n )\n if (!override) {\n return false\n }\n }\n return true\n }\n}\n\nclass WorkspaceResolver {\n private _workspaces: client.Workspace[] = []\n private _currentWorkspace?: client.Workspace\n\n private constructor(\n private readonly _client: ApiClient | undefined,\n private readonly _workspaceHandle: string | undefined,\n private readonly _prompt: utils.prompt.CLIPrompt,\n private readonly _logger: Logger\n ) {}\n\n public static async from({\n client,\n workspaceHandle,\n prompt,\n logger,\n }: {\n client?: ApiClient\n workspaceHandle?: string\n prompt: utils.prompt.CLIPrompt\n logger: Logger\n }): Promise<WorkspaceResolver> {\n const resolver = new WorkspaceResolver(client, workspaceHandle, prompt, logger)\n await resolver._fetchWorkspaces()\n return resolver\n }\n\n public async getWorkspaceHandle(): Promise<string> {\n if (this._hasNoWorkspaces()) {\n return this._promptForArbitraryWorkspaceHandle()\n }\n\n const workspace = await this._promptUserToSelectWorkspace()\n return workspace.handle || (await this._assignHandleToWorkspace(workspace))\n }\n\n private async _fetchWorkspaces(): Promise<void> {\n if (!this._isAuthenticated()) {\n return\n }\n\n const workspaces = await this._getClient()\n .client.list.workspaces({})\n .collect({})\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Unable to list your workspaces')\n })\n const currentWorkspace = workspaces.find((ws) => ws.id === this._getClient().workspaceId)\n\n this._workspaces = workspaces\n this._currentWorkspace = currentWorkspace\n }\n\n private _isAuthenticated(): boolean {\n return !!this._client\n }\n\n private _hasNoWorkspaces(): boolean {\n return !this._isAuthenticated() || this._workspaces.length === 0 || !this._currentWorkspace\n }\n\n private async _promptForArbitraryWorkspaceHandle(): Promise<string> {\n if (this._workspaceHandle) {\n return this._workspaceHandle\n }\n\n const handle = await this._prompt.text('Enter your workspace handle')\n\n if (!handle) {\n throw new errors.ParamRequiredError('Workspace handle')\n }\n\n return handle\n }\n\n private async _promptUserToSelectWorkspace(): Promise<client.Workspace> {\n const workspaceChoices = this._workspaces.map((ws) => ({\n title: ws.name,\n value: ws.id,\n }))\n\n const initialChoice = {\n title: this._currentWorkspace!.name,\n value: this._currentWorkspace!.id,\n }\n\n const workspaceId = await this._prompt.select('Which workspace do you want to use?', {\n initial: initialChoice,\n choices: workspaceChoices,\n })\n\n if (!workspaceId) {\n throw new errors.ParamRequiredError('Workspace')\n }\n\n return this._workspaces.find((ws) => ws.id === workspaceId)!\n }\n\n private async _assignHandleToWorkspace(workspace: client.Workspace): Promise<string> {\n this._logger.warn(\"It seems you don't have a workspace handle yet.\")\n\n let claimedHandle: string | undefined\n\n do {\n const desiredHandle = await this._promptForDesiredHandle()\n const isAvailable = await this._checkHandleAvailability(desiredHandle)\n\n if (isAvailable) {\n claimedHandle = desiredHandle\n await this._updateWorkspaceWithHandle(workspace.id, claimedHandle)\n }\n } while (!claimedHandle)\n\n this._logger.success(`Handle \"${claimedHandle}\" is yours!`)\n return claimedHandle\n }\n\n private async _promptForDesiredHandle(): Promise<string> {\n const desiredHandle = await this._prompt.text('Please enter a workspace handle')\n\n if (!desiredHandle) {\n throw new errors.BotpressCLIError('Workspace handle is required')\n }\n\n return desiredHandle\n }\n\n private async _checkHandleAvailability(handle: string): Promise<boolean> {\n const { available, suggestions } = await this._getClient().client.checkHandleAvailability({ handle })\n\n if (!available) {\n this._logger.warn(`Handle \"${handle}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n return false\n }\n\n return true\n }\n\n private async _updateWorkspaceWithHandle(workspaceId: string, handle: string): Promise<void> {\n try {\n await this._getClient().switchWorkspace(workspaceId).updateWorkspace({ handle })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${handle}\"`)\n }\n }\n\n private _getClient(): ApiClient {\n if (!this._client) {\n throw new errors.BotpressCLIError('Could not authenticate')\n }\n return this._client\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AAGzB,aAAwB;AAExB,+BAAiC;AACjC,YAAuB;AACvB,4BAA8B;AAE9B,MAAM,eAAe,CAAC,OAAO,eAAe,QAAQ;AAM7C,MAAM,oBAAoB,oCAAqC;AAAA,EACpE,MAAa,MAAqB;AAChC,UAAM,cAAc,MAAM,KAAK,mBAAmB;AAClD,UAAM,UAAU,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,KAAK,OAAO;AAE3E,QAAI,gBAAgB,OAAO;AACzB,YAAM,KAAK,SAAS,EAAE,QAAQ,CAAC;AAC/B;AAAA,IACF;AAEA,QAAI,gBAAgB,eAAe;AACjC,YAAM,kBAAkB,MAAM,KAAK,uBAAuB;AAC1D,YAAM,KAAK,iBAAiB,EAAE,SAAS,gBAAgB,CAAC;AACxD;AAAA,IACF;AAEA,QAAI,gBAAgB,UAAU;AAC5B,YAAM,kBAAkB,MAAM,KAAK,uBAAuB;AAC1D,YAAM,KAAK,YAAY,EAAE,SAAS,gBAAgB,CAAC;AACnD;AAAA,IACF;AAGA,UAAM,IAAI,OAAO,iBAAiB,yBAAyB,aAAa;AAAA,EAC1E;AAAA,EAEA,MAAc,yBAAyB;AACrC,UAAM,SAAU,MAAM,KAAK,uBAAuB,CAAC,CAAC,KAAM;AAE1D,UAAM,YAAY,KAAK,KAAK,MAAM,MAAM,KAAK,CAAC,KAAK,CAAC;AACpD,UAAM,kBAAkB,UAAU,SAAS,IAAI,UAAU,CAAC,IAAI;AAE9D,UAAM,WAAW,MAAM,kBAA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AAAA,EACd;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -32,11 +32,31 @@ __export(login_command_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(login_command_exports);
|
|
34
34
|
var client = __toESM(require("@botpress/client"));
|
|
35
|
+
var fs = __toESM(require("fs"));
|
|
35
36
|
var paging = __toESM(require("../api/paging"));
|
|
37
|
+
var consts = __toESM(require("../consts"));
|
|
36
38
|
var errors = __toESM(require("../errors"));
|
|
37
39
|
var import_global_command = require("./global-command");
|
|
38
40
|
class LoginCommand extends import_global_command.GlobalCommand {
|
|
39
41
|
async run() {
|
|
42
|
+
let profileName = consts.defaultProfileName;
|
|
43
|
+
if (this.argv.profile) {
|
|
44
|
+
let profileExists = false;
|
|
45
|
+
if (fs.existsSync(this.globalPaths.abs.profilesPath)) {
|
|
46
|
+
const profiles = await this.readProfilesFromFS();
|
|
47
|
+
profileExists = profiles[this.argv.profile] !== void 0;
|
|
48
|
+
}
|
|
49
|
+
if (profileExists) {
|
|
50
|
+
const overwrite = await this.prompt.confirm(
|
|
51
|
+
`This command will overwrite the existing profile '${this.argv.profile}'. Do you want to continue?`
|
|
52
|
+
);
|
|
53
|
+
if (!overwrite)
|
|
54
|
+
throw new errors.AbortedOperationError();
|
|
55
|
+
} else {
|
|
56
|
+
this.logger.log(`This command will create new profile '${this.argv.profile}'`, { prefix: "\u2139\uFE0E" });
|
|
57
|
+
}
|
|
58
|
+
profileName = this.argv.profile;
|
|
59
|
+
}
|
|
40
60
|
const promptedToken = await this.globalCache.sync("token", this.argv.token, async (previousToken) => {
|
|
41
61
|
const prompted = await this.prompt.text("Enter your Personal Access Token", {
|
|
42
62
|
initial: previousToken
|
|
@@ -46,6 +66,9 @@ class LoginCommand extends import_global_command.GlobalCommand {
|
|
|
46
66
|
}
|
|
47
67
|
return prompted;
|
|
48
68
|
});
|
|
69
|
+
if (this.argv.apiUrl !== consts.defaultBotpressApiUrl) {
|
|
70
|
+
this.logger.log(`Using custom api url ${this.argv.apiUrl} to try fetching workspaces`, { prefix: "\u{1F517}" });
|
|
71
|
+
}
|
|
49
72
|
const promptedWorkspaceId = await this.globalCache.sync("workspaceId", this.argv.workspaceId, async (defaultId) => {
|
|
50
73
|
const tmpClient = new client.Client({ apiUrl: this.argv.apiUrl, token: promptedToken });
|
|
51
74
|
const userWorkspaces = await paging.listAllPages(tmpClient.listWorkspaces, (r) => r.workspaces).catch((thrown) => {
|
|
@@ -72,6 +95,11 @@ class LoginCommand extends import_global_command.GlobalCommand {
|
|
|
72
95
|
await api.testLogin().catch((thrown) => {
|
|
73
96
|
throw errors.BotpressCLIError.wrap(thrown, "Login failed. Please check your credentials");
|
|
74
97
|
});
|
|
98
|
+
await this.writeProfileToFS(profileName, {
|
|
99
|
+
apiUrl: this.argv.apiUrl,
|
|
100
|
+
token: promptedToken,
|
|
101
|
+
workspaceId: promptedWorkspaceId
|
|
102
|
+
});
|
|
75
103
|
this.logger.success("Logged In");
|
|
76
104
|
}
|
|
77
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/login-command.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as paging from '../api/paging'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { GlobalCommand } from './global-command'\n\nexport type LoginCommandDefinition = typeof commandDefinitions.login\nexport class LoginCommand extends GlobalCommand<LoginCommandDefinition> {\n public async run(): Promise<void> {\n const promptedToken = await this.globalCache.sync('token', this.argv.token, async (previousToken) => {\n const prompted = await this.prompt.text('Enter your Personal Access Token', {\n initial: previousToken,\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Personal Access Token')\n }\n\n return prompted\n })\n\n const promptedWorkspaceId = await this.globalCache.sync('workspaceId', this.argv.workspaceId, async (defaultId) => {\n const tmpClient = new client.Client({ apiUrl: this.argv.apiUrl, token: promptedToken }) // no workspaceId yet\n const userWorkspaces = await paging\n .listAllPages(tmpClient.listWorkspaces, (r) => r.workspaces)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n\n if (userWorkspaces.length === 0) {\n throw new errors.NoWorkspacesFoundError()\n }\n\n const initial = userWorkspaces.find((ws) => ws.id === defaultId)\n\n const prompted = await this.prompt.select('Which workspace do you want to login to?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userWorkspaces.map((ws) => ({ title: ws.name, value: ws.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Workspace Id')\n }\n\n return prompted\n })\n\n await this.globalCache.set('apiUrl', this.argv.apiUrl)\n\n const api = this.api.newClient(\n { apiUrl: this.argv.apiUrl, token: promptedToken, workspaceId: promptedWorkspaceId },\n this.logger\n )\n\n await api.testLogin().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Login failed. Please check your credentials')\n })\n\n this.logger.success('Logged In')\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,aAAwB;AAExB,aAAwB;AACxB,4BAA8B;AAGvB,MAAM,qBAAqB,oCAAsC;AAAA,EACtE,MAAa,MAAqB;AAChC,UAAM,gBAAgB,MAAM,KAAK,YAAY,KAAK,SAAS,KAAK,KAAK,OAAO,OAAO,kBAAkB;AACnG,YAAM,WAAW,MAAM,KAAK,OAAO,KAAK,oCAAoC;AAAA,QAC1E,SAAS;AAAA,MACX,CAAC;AAED,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,mBAAmB,uBAAuB;AAAA,MAC7D;AAEA,aAAO;AAAA,IACT,CAAC;
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as fs from 'fs'\nimport * as paging from '../api/paging'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { GlobalCommand } from './global-command'\n\nexport type LoginCommandDefinition = typeof commandDefinitions.login\nexport class LoginCommand extends GlobalCommand<LoginCommandDefinition> {\n public async run(): Promise<void> {\n let profileName = consts.defaultProfileName\n if (this.argv.profile) {\n let profileExists: boolean = false\n if (fs.existsSync(this.globalPaths.abs.profilesPath)) {\n const profiles = await this.readProfilesFromFS()\n profileExists = profiles[this.argv.profile] !== undefined\n }\n if (profileExists) {\n const overwrite = await this.prompt.confirm(\n `This command will overwrite the existing profile '${this.argv.profile}'. Do you want to continue?`\n )\n if (!overwrite) throw new errors.AbortedOperationError()\n } else {\n this.logger.log(`This command will create new profile '${this.argv.profile}'`, { prefix: '\u2139\uFE0E' })\n }\n profileName = this.argv.profile\n }\n\n const promptedToken = await this.globalCache.sync('token', this.argv.token, async (previousToken) => {\n const prompted = await this.prompt.text('Enter your Personal Access Token', {\n initial: previousToken,\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Personal Access Token')\n }\n\n return prompted\n })\n if (this.argv.apiUrl !== consts.defaultBotpressApiUrl) {\n this.logger.log(`Using custom api url ${this.argv.apiUrl} to try fetching workspaces`, { prefix: '\uD83D\uDD17' })\n }\n const promptedWorkspaceId = await this.globalCache.sync('workspaceId', this.argv.workspaceId, async (defaultId) => {\n const tmpClient = new client.Client({ apiUrl: this.argv.apiUrl, token: promptedToken }) // no workspaceId yet\n const userWorkspaces = await paging\n .listAllPages(tmpClient.listWorkspaces, (r) => r.workspaces)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n\n if (userWorkspaces.length === 0) {\n throw new errors.NoWorkspacesFoundError()\n }\n\n const initial = userWorkspaces.find((ws) => ws.id === defaultId)\n\n const prompted = await this.prompt.select('Which workspace do you want to login to?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userWorkspaces.map((ws) => ({ title: ws.name, value: ws.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Workspace Id')\n }\n\n return prompted\n })\n\n await this.globalCache.set('apiUrl', this.argv.apiUrl)\n\n const api = this.api.newClient(\n { apiUrl: this.argv.apiUrl, token: promptedToken, workspaceId: promptedWorkspaceId },\n this.logger\n )\n\n await api.testLogin().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Login failed. Please check your credentials')\n })\n\n await this.writeProfileToFS(profileName, {\n apiUrl: this.argv.apiUrl,\n token: promptedToken,\n workspaceId: promptedWorkspaceId,\n })\n\n this.logger.success('Logged In')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,SAAoB;AACpB,aAAwB;AAExB,aAAwB;AACxB,aAAwB;AACxB,4BAA8B;AAGvB,MAAM,qBAAqB,oCAAsC;AAAA,EACtE,MAAa,MAAqB;AAChC,QAAI,cAAc,OAAO;AACzB,QAAI,KAAK,KAAK,SAAS;AACrB,UAAI,gBAAyB;AAC7B,UAAI,GAAG,WAAW,KAAK,YAAY,IAAI,YAAY,GAAG;AACpD,cAAM,WAAW,MAAM,KAAK,mBAAmB;AAC/C,wBAAgB,SAAS,KAAK,KAAK,OAAO,MAAM;AAAA,MAClD;AACA,UAAI,eAAe;AACjB,cAAM,YAAY,MAAM,KAAK,OAAO;AAAA,UAClC,qDAAqD,KAAK,KAAK;AAAA,QACjE;AACA,YAAI,CAAC;AAAW,gBAAM,IAAI,OAAO,sBAAsB;AAAA,MACzD,OAAO;AACL,aAAK,OAAO,IAAI,yCAAyC,KAAK,KAAK,YAAY,EAAE,QAAQ,eAAK,CAAC;AAAA,MACjG;AACA,oBAAc,KAAK,KAAK;AAAA,IAC1B;AAEA,UAAM,gBAAgB,MAAM,KAAK,YAAY,KAAK,SAAS,KAAK,KAAK,OAAO,OAAO,kBAAkB;AACnG,YAAM,WAAW,MAAM,KAAK,OAAO,KAAK,oCAAoC;AAAA,QAC1E,SAAS;AAAA,MACX,CAAC;AAED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M,IAAI,UAAU,EAAE,MAAM,CAAC,WAAW;AACtC,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6CAA6C;AAAA,IAC1F,CAAC;AAED,UAAM,KAAK,iBAAiB,aAAa;AAAA,MACvC,QAAQ,KAAK,KAAK;AAAA,MAClB,OAAO;AAAA,MACP,aAAa;AAAA,IACf,CAAC;AAED,SAAK,OAAO,QAAQ,WAAW;AAAA,EACjC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var profile_commands_exports = {};
|
|
30
|
+
__export(profile_commands_exports, {
|
|
31
|
+
ActiveProfileCommand: () => ActiveProfileCommand,
|
|
32
|
+
ListProfilesCommand: () => ListProfilesCommand,
|
|
33
|
+
UseProfileCommand: () => UseProfileCommand
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(profile_commands_exports);
|
|
36
|
+
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
var consts = __toESM(require("../consts"));
|
|
38
|
+
var errors = __toESM(require("../errors"));
|
|
39
|
+
var import_global_command = require("./global-command");
|
|
40
|
+
class ActiveProfileCommand extends import_global_command.GlobalCommand {
|
|
41
|
+
async run() {
|
|
42
|
+
let activeProfileName = await this.globalCache.get("activeProfile");
|
|
43
|
+
if (!activeProfileName) {
|
|
44
|
+
this.logger.log(`No active profile set, defaulting to ${consts.defaultProfileName}`);
|
|
45
|
+
activeProfileName = consts.defaultProfileName;
|
|
46
|
+
await this.globalCache.set("activeProfile", activeProfileName);
|
|
47
|
+
}
|
|
48
|
+
const profile = await this.readProfileFromFS(activeProfileName);
|
|
49
|
+
this.logger.log("Active profile:");
|
|
50
|
+
this.logger.json({ [activeProfileName]: profile });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class ListProfilesCommand extends import_global_command.GlobalCommand {
|
|
54
|
+
async run() {
|
|
55
|
+
const profiles = await this.readProfilesFromFS();
|
|
56
|
+
if (Object.keys(profiles).length === 0) {
|
|
57
|
+
this.logger.log("No profiles found");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const activeProfileName = await this.globalCache.get("activeProfile");
|
|
61
|
+
const profileNames = Object.keys(profiles);
|
|
62
|
+
this.logger.log(`Active profile: '${import_chalk.default.bold(activeProfileName)}'`);
|
|
63
|
+
this.logger.json(profileNames);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class UseProfileCommand extends import_global_command.GlobalCommand {
|
|
67
|
+
async run() {
|
|
68
|
+
if (this.argv.profileToUse) {
|
|
69
|
+
const profile2 = await this.readProfileFromFS(this.argv.profileToUse);
|
|
70
|
+
await this.globalCache.set("activeProfile", this.argv.profileToUse);
|
|
71
|
+
await _updateGlobalCache({ globalCache: this.globalCache, profileName: this.argv.profileToUse, profile: profile2 });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const profiles = await this.readProfilesFromFS();
|
|
75
|
+
const choices = Object.entries(profiles).map(([profileName, _]) => ({
|
|
76
|
+
title: profileName,
|
|
77
|
+
description: "",
|
|
78
|
+
value: profileName
|
|
79
|
+
}));
|
|
80
|
+
const selectedProfile = await this.prompt.select("Select the profile you want to use.", { choices });
|
|
81
|
+
if (!selectedProfile) {
|
|
82
|
+
this.logger.log("No profile selected, aborting.");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const profile = profiles[selectedProfile];
|
|
86
|
+
if (!profile)
|
|
87
|
+
throw new errors.BotpressCLIError("The selected profile could not be read");
|
|
88
|
+
await this.globalCache.set("activeProfile", selectedProfile);
|
|
89
|
+
await _updateGlobalCache({ globalCache: this.globalCache, profileName: selectedProfile, profile });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const _updateGlobalCache = async (props) => {
|
|
93
|
+
await props.globalCache.set("activeProfile", props.profileName);
|
|
94
|
+
await props.globalCache.set("apiUrl", props.profile.apiUrl);
|
|
95
|
+
await props.globalCache.set("token", props.profile.token);
|
|
96
|
+
await props.globalCache.set("workspaceId", props.profile.workspaceId);
|
|
97
|
+
};
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
ActiveProfileCommand,
|
|
101
|
+
ListProfilesCommand,
|
|
102
|
+
UseProfileCommand
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=profile-commands.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/profile-commands.ts"],
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { GlobalCache, GlobalCommand, ProfileCredentials } from './global-command'\n\nexport type ActiveProfileCommandDefinition = typeof commandDefinitions.profiles.subcommands.active\nexport class ActiveProfileCommand extends GlobalCommand<ActiveProfileCommandDefinition> {\n public async run(): Promise<void> {\n let activeProfileName = await this.globalCache.get('activeProfile')\n\n if (!activeProfileName) {\n this.logger.log(`No active profile set, defaulting to ${consts.defaultProfileName}`)\n activeProfileName = consts.defaultProfileName\n await this.globalCache.set('activeProfile', activeProfileName)\n }\n\n const profile = await this.readProfileFromFS(activeProfileName)\n this.logger.log('Active profile:')\n this.logger.json({ [activeProfileName]: profile })\n }\n}\n\nexport type ListProfilesCommandDefinition = typeof commandDefinitions.profiles.subcommands.list\nexport class ListProfilesCommand extends GlobalCommand<ListProfilesCommandDefinition> {\n public async run(): Promise<void> {\n const profiles = await this.readProfilesFromFS()\n if (Object.keys(profiles).length === 0) {\n this.logger.log('No profiles found')\n return\n }\n const activeProfileName = await this.globalCache.get('activeProfile')\n const profileNames = Object.keys(profiles)\n this.logger.log(`Active profile: '${chalk.bold(activeProfileName)}'`)\n this.logger.json(profileNames)\n }\n}\n\nexport type UseProfileCommandDefinition = typeof commandDefinitions.profiles.subcommands.use\nexport class UseProfileCommand extends GlobalCommand<UseProfileCommandDefinition> {\n public async run(): Promise<void> {\n if (this.argv.profileToUse) {\n const profile = await this.readProfileFromFS(this.argv.profileToUse)\n await this.globalCache.set('activeProfile', this.argv.profileToUse)\n await _updateGlobalCache({ globalCache: this.globalCache, profileName: this.argv.profileToUse, profile })\n return\n }\n const profiles = await this.readProfilesFromFS()\n const choices = Object.entries(profiles).map(([profileName, _]) => ({\n title: profileName,\n description: '',\n value: profileName,\n }))\n const selectedProfile = await this.prompt.select('Select the profile you want to use.', { choices })\n\n if (!selectedProfile) {\n this.logger.log('No profile selected, aborting.')\n return\n }\n\n const profile = profiles[selectedProfile]\n if (!profile) throw new errors.BotpressCLIError('The selected profile could not be read')\n await this.globalCache.set('activeProfile', selectedProfile)\n await _updateGlobalCache({ globalCache: this.globalCache, profileName: selectedProfile, profile })\n }\n}\n\nconst _updateGlobalCache = async (props: {\n globalCache: utils.cache.FSKeyValueCache<GlobalCache>\n profileName: string\n profile: ProfileCredentials\n}): Promise<void> => {\n await props.globalCache.set('activeProfile', props.profileName)\n await props.globalCache.set('apiUrl', props.profile.apiUrl)\n await props.globalCache.set('token', props.profile.token)\n await props.globalCache.set('workspaceId', props.profile.workspaceId)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,aAAwB;AACxB,aAAwB;AAExB,4BAA+D;AAGxD,MAAM,6BAA6B,oCAA8C;AAAA,EACtF,MAAa,MAAqB;AAChC,QAAI,oBAAoB,MAAM,KAAK,YAAY,IAAI,eAAe;AAElE,QAAI,CAAC,mBAAmB;AACtB,WAAK,OAAO,IAAI,wCAAwC,OAAO,oBAAoB;AACnF,0BAAoB,OAAO;AAC3B,YAAM,KAAK,YAAY,IAAI,iBAAiB,iBAAiB;AAAA,IAC/D;AAEA,UAAM,UAAU,MAAM,KAAK,kBAAkB,iBAAiB;AAC9D,SAAK,OAAO,IAAI,iBAAiB;AACjC,SAAK,OAAO,KAAK,EAAE,CAAC,iBAAiB,GAAG,QAAQ,CAAC;AAAA,EACnD;AACF;AAGO,MAAM,4BAA4B,oCAA6C;AAAA,EACpF,MAAa,MAAqB;AAChC,UAAM,WAAW,MAAM,KAAK,mBAAmB;AAC/C,QAAI,OAAO,KAAK,QAA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,MAAM,YAAY,IAAI,UAAU,MAAM,QAAQ,MAAM;AAC1D,QAAM,MAAM,YAAY,IAAI,SAAS,MAAM,QAAQ,KAAK;AACxD,QAAM,MAAM,YAAY,IAAI,eAAe,MAAM,QAAQ,WAAW;AACtE;",
|
|
6
|
+
"names": ["chalk", "profile"]
|
|
7
|
+
}
|
package/dist/config.js
CHANGED
|
@@ -135,7 +135,8 @@ const globalSchema = {
|
|
|
135
135
|
},
|
|
136
136
|
profile: {
|
|
137
137
|
type: "string",
|
|
138
|
-
description: "The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json
|
|
138
|
+
description: "The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json",
|
|
139
|
+
alias: "p"
|
|
139
140
|
}
|
|
140
141
|
};
|
|
141
142
|
const projectSchema = {
|
|
@@ -337,6 +338,21 @@ const chatSchema = {
|
|
|
337
338
|
description: "The bot ID to chat with"
|
|
338
339
|
}
|
|
339
340
|
};
|
|
341
|
+
const listProfilesSchema = {
|
|
342
|
+
...globalSchema
|
|
343
|
+
};
|
|
344
|
+
const activeProfileSchema = {
|
|
345
|
+
...globalSchema
|
|
346
|
+
};
|
|
347
|
+
const useProfileSchema = {
|
|
348
|
+
...globalSchema,
|
|
349
|
+
profileToUse: {
|
|
350
|
+
type: "string",
|
|
351
|
+
description: "The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json",
|
|
352
|
+
positional: true,
|
|
353
|
+
idx: 0
|
|
354
|
+
}
|
|
355
|
+
};
|
|
340
356
|
const schemas = {
|
|
341
357
|
global: globalSchema,
|
|
342
358
|
project: projectSchema,
|
|
@@ -367,7 +383,10 @@ const schemas = {
|
|
|
367
383
|
add: addSchema,
|
|
368
384
|
dev: devSchema,
|
|
369
385
|
lint: lintSchema,
|
|
370
|
-
chat: chatSchema
|
|
386
|
+
chat: chatSchema,
|
|
387
|
+
listProfiles: listProfilesSchema,
|
|
388
|
+
activeProfile: activeProfileSchema,
|
|
389
|
+
useProfile: useProfileSchema
|
|
371
390
|
};
|
|
372
391
|
// Annotate the CommonJS export names for ESM import in node:
|
|
373
392
|
0 && (module.exports = {
|
package/dist/config.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/config.ts"],
|
|
4
|
-
"sourcesContent": ["import * as consts from './consts'\nimport { ProjectTemplates } from './project-templates'\nimport type { CommandOption, CommandSchema } from './typings'\n\n// command options\n\nconst port = {\n type: 'number',\n description: 'The port to use',\n} satisfies CommandOption\n\nconst workDir = {\n type: 'string',\n description: 'The path to the project',\n default: consts.defaultWorkDir,\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} satisfies CommandOption\n\nconst dryRun = {\n type: 'boolean',\n description: 'Ask the API not to perform the actual operation',\n default: false,\n} as const satisfies CommandOption\n\nconst apiUrl = {\n type: 'string',\n description: 'The URL of the Botpress server',\n} satisfies CommandOption\n\nconst token = {\n type: 'string',\n description: 'You Personal Access Token ',\n} satisfies CommandOption\n\nconst workspaceId = {\n type: 'string',\n description: 'The Workspace Id to deploy to',\n} satisfies CommandOption\n\nconst secrets = {\n type: 'string',\n description: 'Values for the integration secrets',\n array: true,\n default: [],\n} satisfies CommandOption\n\nconst botRef = {\n type: 'string',\n description: 'The bot ID. Bot Name is not supported.',\n demandOption: true,\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst packageType = {\n type: 'string',\n description:\n 'Either an integration or an interface; helps disambiguate the package type in case both an integration and an interface have the same reference.',\n choices: ['integration', 'interface', 'plugin'] as const,\n} satisfies CommandOption\n\nconst packageRef = {\n type: 'string',\n description:\n 'The package ID or name with optional version. The package can be either an integration or an interface. Ex: teams, teams@0.2.0, llm@5.1.0',\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst integrationRef = {\n ...packageRef,\n demandOption: true,\n description: 'The integration ID or name with optional version. Ex: teams or teams@0.2.0',\n} satisfies CommandOption\n\nconst interfaceRef = {\n ...packageRef,\n demandOption: true,\n description: 'The interface ID or name and version. Ex: llm@5.1.0',\n} satisfies CommandOption\n\nconst pluginRef = {\n ...packageRef,\n demandOption: true,\n description: 'The plugin ID or name and version. Ex: knowledge@0.0.1',\n} satisfies CommandOption\n\nconst sourceMap = { type: 'boolean', description: 'Generate sourcemaps', default: false } satisfies CommandOption\n\nconst minify = { type: 'boolean', description: 'Minify the bundled code', default: true } satisfies CommandOption\n\nconst dev = {\n type: 'boolean',\n description: 'List only dev bots / dev integrations',\n default: false,\n} satisfies CommandOption\n\n// base schemas\n\nconst globalSchema = {\n verbose: {\n type: 'boolean',\n description: 'Enable verbose logging',\n alias: 'v',\n default: false,\n },\n confirm: {\n type: 'boolean',\n description: 'Confirm all prompts',\n alias: 'y',\n default: false,\n },\n json: {\n type: 'boolean',\n description: 'Prevent logging anything else than raw json in stdout. Useful for piping output to other tools',\n default: false,\n },\n botpressHome: {\n type: 'string',\n description: 'The path to the Botpress home directory',\n default: consts.defaultBotpressHome,\n },\n profile: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json json format file',\n },\n} satisfies CommandSchema\n\nconst projectSchema = {\n ...globalSchema,\n workDir,\n} satisfies CommandSchema\n\nconst credentialsSchema = {\n apiUrl,\n workspaceId,\n token,\n} satisfies CommandSchema\n\nconst secretsSchema = {\n secrets,\n} satisfies CommandSchema\n\n// command schemas\n\nconst generateSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst bundleSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst buildSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst readSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst serveSchema = {\n ...projectSchema,\n ...secretsSchema,\n port,\n} satisfies CommandSchema\n\nconst deploySchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n botId: { type: 'string', description: 'The bot ID to deploy. Only used when deploying a bot' },\n noBuild,\n dryRun,\n createNewBot: { type: 'boolean', description: 'Create a new bot when deploying. Only used when deploying a bot' },\n sourceMap,\n minify,\n visibility: {\n type: 'string',\n choices: ['public', 'private', 'unlisted'] as const,\n description:\n 'The visibility of the project. By default, projects are always private. Unlisted visibility is only supported for integrations.',\n default: 'private',\n },\n public: {\n type: 'boolean',\n description: 'DEPRECATED: Please use \"--visibility public\" instead.',\n default: false,\n deprecated: true,\n } satisfies CommandOption,\n allowDeprecated: {\n type: 'boolean',\n description: 'Allow deprecated features in the project',\n default: false,\n },\n} as const satisfies CommandSchema\n\nconst devSchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n sourceMap,\n minify,\n port,\n tunnelUrl: {\n type: 'string',\n description: 'The tunnel HTTP URL to use',\n default: consts.defaultTunnelUrl,\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\n packageType,\n installPath: {\n type: 'string',\n description: 'The path where to install the package',\n default: consts.defaultInstallPath,\n },\n useDev: {\n type: 'boolean',\n description: 'If a dev version of the package is found, use it',\n default: false,\n },\n} satisfies CommandSchema\n\nconst loginSchema = {\n ...globalSchema,\n token,\n workspaceId,\n apiUrl: { ...apiUrl, default: consts.defaultBotpressApiUrl },\n} satisfies CommandSchema\n\nconst logoutSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst createBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name of the bot to create' },\n ifNotExists: {\n type: 'boolean',\n description: 'Do not create if a bot with the same name already exists',\n default: false,\n },\n} satisfies CommandSchema\n\nconst getBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst deleteBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst listBotsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n dev,\n} satisfies CommandSchema\n\nconst getIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst listIntegrationsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing integrations' },\n versionNumber: { type: 'string', description: 'The version filter when listing integrations' },\n dev,\n} satisfies CommandSchema\n\nconst deleteIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst getInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst listInterfacesSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deleteInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst getPluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst listPluginsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing plugins' },\n versionNumber: { type: 'string', description: 'The version filter when listing plugins' },\n} satisfies CommandSchema\n\nconst deletePluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst initSchema = {\n ...globalSchema,\n workDir,\n type: { type: 'string', choices: ['bot', 'integration', 'plugin'] as const },\n template: {\n type: 'string',\n choices: ProjectTemplates.getAllChoices(),\n description: 'The template to use',\n },\n name: { type: 'string', description: 'The name of the project' },\n} satisfies CommandSchema\n\nconst lintSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst chatSchema = {\n ...globalSchema,\n ...credentialsSchema,\n chatApiUrl: {\n type: 'string',\n description: 'The URL of the chat server',\n },\n botId: {\n type: 'string',\n positional: true,\n idx: 0,\n description: 'The bot ID to chat with',\n },\n} satisfies CommandSchema\n\n// exports\n\nexport const schemas = {\n global: globalSchema,\n project: projectSchema,\n credentials: credentialsSchema,\n secrets: secretsSchema,\n login: loginSchema,\n logout: logoutSchema,\n createBot: createBotSchema,\n getBot: getBotSchema,\n deleteBot: deleteBotSchema,\n listBots: listBotsSchema,\n getIntegration: getIntegrationSchema,\n listIntegrations: listIntegrationsSchema,\n deleteIntegration: deleteIntegrationSchema,\n getInterface: getInterfaceSchema,\n listInterfaces: listInterfacesSchema,\n deleteInterface: deleteInterfaceSchema,\n getPlugin: getPluginSchema,\n listPlugins: listPluginsSchema,\n deletePlugin: deletePluginSchema,\n init: initSchema,\n generate: generateSchema,\n bundle: bundleSchema,\n build: buildSchema,\n read: readSchema,\n serve: serveSchema,\n deploy: deploySchema,\n add: addSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n} as const\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,+BAAiC;AAKjC,MAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS,OAAO;AAClB;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,QAAQ;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,SAAS,CAAC;AACZ;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,KAAK;AACP;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,aACE;AAAA,EACF,SAAS,CAAC,eAAe,aAAa,QAAQ;AAChD;AAEA,MAAM,aAAa;AAAA,EACjB,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY;AAAA,EACZ,KAAK;AACP;AAEA,MAAM,iBAAiB;AAAA,EACrB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,aAAa;AACf;AAEA,MAAM,eAAe;AAAA,EACnB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,aAAa;AACf;AAEA,MAAM,YAAY;AAAA,EAChB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,aAAa;AACf;AAEA,MAAM,YAAY,EAAE,MAAM,WAAW,aAAa,uBAAuB,SAAS,MAAM;AAExF,MAAM,SAAS,EAAE,MAAM,WAAW,aAAa,2BAA2B,SAAS,KAAK;AAExF,MAAM,MAAM;AAAA,EACV,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAIA,MAAM,eAAe;AAAA,EACnB,SAAS;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS,OAAO;AAAA,EAClB;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as consts from './consts'\nimport { ProjectTemplates } from './project-templates'\nimport type { CommandOption, CommandSchema } from './typings'\n\n// command options\n\nconst port = {\n type: 'number',\n description: 'The port to use',\n} satisfies CommandOption\n\nconst workDir = {\n type: 'string',\n description: 'The path to the project',\n default: consts.defaultWorkDir,\n} satisfies CommandOption\n\nconst noBuild = {\n type: 'boolean',\n description: 'Skip the build step',\n default: false,\n} satisfies CommandOption\n\nconst dryRun = {\n type: 'boolean',\n description: 'Ask the API not to perform the actual operation',\n default: false,\n} as const satisfies CommandOption\n\nconst apiUrl = {\n type: 'string',\n description: 'The URL of the Botpress server',\n} satisfies CommandOption\n\nconst token = {\n type: 'string',\n description: 'You Personal Access Token ',\n} satisfies CommandOption\n\nconst workspaceId = {\n type: 'string',\n description: 'The Workspace Id to deploy to',\n} satisfies CommandOption\n\nconst secrets = {\n type: 'string',\n description: 'Values for the integration secrets',\n array: true,\n default: [],\n} satisfies CommandOption\n\nconst botRef = {\n type: 'string',\n description: 'The bot ID. Bot Name is not supported.',\n demandOption: true,\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst packageType = {\n type: 'string',\n description:\n 'Either an integration or an interface; helps disambiguate the package type in case both an integration and an interface have the same reference.',\n choices: ['integration', 'interface', 'plugin'] as const,\n} satisfies CommandOption\n\nconst packageRef = {\n type: 'string',\n description:\n 'The package ID or name with optional version. The package can be either an integration or an interface. Ex: teams, teams@0.2.0, llm@5.1.0',\n positional: true,\n idx: 0,\n} satisfies CommandOption\n\nconst integrationRef = {\n ...packageRef,\n demandOption: true,\n description: 'The integration ID or name with optional version. Ex: teams or teams@0.2.0',\n} satisfies CommandOption\n\nconst interfaceRef = {\n ...packageRef,\n demandOption: true,\n description: 'The interface ID or name and version. Ex: llm@5.1.0',\n} satisfies CommandOption\n\nconst pluginRef = {\n ...packageRef,\n demandOption: true,\n description: 'The plugin ID or name and version. Ex: knowledge@0.0.1',\n} satisfies CommandOption\n\nconst sourceMap = { type: 'boolean', description: 'Generate sourcemaps', default: false } satisfies CommandOption\n\nconst minify = { type: 'boolean', description: 'Minify the bundled code', default: true } satisfies CommandOption\n\nconst dev = {\n type: 'boolean',\n description: 'List only dev bots / dev integrations',\n default: false,\n} satisfies CommandOption\n\n// base schemas\n\nconst globalSchema = {\n verbose: {\n type: 'boolean',\n description: 'Enable verbose logging',\n alias: 'v',\n default: false,\n },\n confirm: {\n type: 'boolean',\n description: 'Confirm all prompts',\n alias: 'y',\n default: false,\n },\n json: {\n type: 'boolean',\n description: 'Prevent logging anything else than raw json in stdout. Useful for piping output to other tools',\n default: false,\n },\n botpressHome: {\n type: 'string',\n description: 'The path to the Botpress home directory',\n default: consts.defaultBotpressHome,\n },\n profile: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n alias: 'p',\n },\n} satisfies CommandSchema\n\nconst projectSchema = {\n ...globalSchema,\n workDir,\n} satisfies CommandSchema\n\nconst credentialsSchema = {\n apiUrl,\n workspaceId,\n token,\n} satisfies CommandSchema\n\nconst secretsSchema = {\n secrets,\n} satisfies CommandSchema\n\n// command schemas\n\nconst generateSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst bundleSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst buildSchema = {\n ...projectSchema,\n sourceMap,\n minify,\n} satisfies CommandSchema\n\nconst readSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst serveSchema = {\n ...projectSchema,\n ...secretsSchema,\n port,\n} satisfies CommandSchema\n\nconst deploySchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n botId: { type: 'string', description: 'The bot ID to deploy. Only used when deploying a bot' },\n noBuild,\n dryRun,\n createNewBot: { type: 'boolean', description: 'Create a new bot when deploying. Only used when deploying a bot' },\n sourceMap,\n minify,\n visibility: {\n type: 'string',\n choices: ['public', 'private', 'unlisted'] as const,\n description:\n 'The visibility of the project. By default, projects are always private. Unlisted visibility is only supported for integrations.',\n default: 'private',\n },\n public: {\n type: 'boolean',\n description: 'DEPRECATED: Please use \"--visibility public\" instead.',\n default: false,\n deprecated: true,\n } satisfies CommandOption,\n allowDeprecated: {\n type: 'boolean',\n description: 'Allow deprecated features in the project',\n default: false,\n },\n} as const satisfies CommandSchema\n\nconst devSchema = {\n ...projectSchema,\n ...credentialsSchema,\n ...secretsSchema,\n sourceMap,\n minify,\n port,\n tunnelUrl: {\n type: 'string',\n description: 'The tunnel HTTP URL to use',\n default: consts.defaultTunnelUrl,\n },\n} satisfies CommandSchema\n\nconst addSchema = {\n ...globalSchema,\n ...credentialsSchema,\n packageRef,\n packageType,\n installPath: {\n type: 'string',\n description: 'The path where to install the package',\n default: consts.defaultInstallPath,\n },\n useDev: {\n type: 'boolean',\n description: 'If a dev version of the package is found, use it',\n default: false,\n },\n} satisfies CommandSchema\n\nconst loginSchema = {\n ...globalSchema,\n token,\n workspaceId,\n apiUrl: { ...apiUrl, default: consts.defaultBotpressApiUrl },\n} satisfies CommandSchema\n\nconst logoutSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst createBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name of the bot to create' },\n ifNotExists: {\n type: 'boolean',\n description: 'Do not create if a bot with the same name already exists',\n default: false,\n },\n} satisfies CommandSchema\n\nconst getBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst deleteBotSchema = {\n ...globalSchema,\n ...credentialsSchema,\n botRef,\n} satisfies CommandSchema\n\nconst listBotsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n dev,\n} satisfies CommandSchema\n\nconst getIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst listIntegrationsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing integrations' },\n versionNumber: { type: 'string', description: 'The version filter when listing integrations' },\n dev,\n} satisfies CommandSchema\n\nconst deleteIntegrationSchema = {\n ...globalSchema,\n ...credentialsSchema,\n integrationRef,\n} satisfies CommandSchema\n\nconst getInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst listInterfacesSchema = {\n ...globalSchema,\n ...credentialsSchema,\n} satisfies CommandSchema\n\nconst deleteInterfaceSchema = {\n ...globalSchema,\n ...credentialsSchema,\n interfaceRef,\n} satisfies CommandSchema\n\nconst getPluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst listPluginsSchema = {\n ...globalSchema,\n ...credentialsSchema,\n name: { type: 'string', description: 'The name filter when listing plugins' },\n versionNumber: { type: 'string', description: 'The version filter when listing plugins' },\n} satisfies CommandSchema\n\nconst deletePluginSchema = {\n ...globalSchema,\n ...credentialsSchema,\n pluginRef,\n} satisfies CommandSchema\n\nconst initSchema = {\n ...globalSchema,\n workDir,\n type: { type: 'string', choices: ['bot', 'integration', 'plugin'] as const },\n template: {\n type: 'string',\n choices: ProjectTemplates.getAllChoices(),\n description: 'The template to use',\n },\n name: { type: 'string', description: 'The name of the project' },\n} satisfies CommandSchema\n\nconst lintSchema = {\n ...projectSchema,\n} satisfies CommandSchema\n\nconst chatSchema = {\n ...globalSchema,\n ...credentialsSchema,\n chatApiUrl: {\n type: 'string',\n description: 'The URL of the chat server',\n },\n botId: {\n type: 'string',\n positional: true,\n idx: 0,\n description: 'The bot ID to chat with',\n },\n} satisfies CommandSchema\n\nconst listProfilesSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst activeProfileSchema = {\n ...globalSchema,\n} satisfies CommandSchema\n\nconst useProfileSchema = {\n ...globalSchema,\n profileToUse: {\n type: 'string',\n description: 'The CLI profile defined in the $BP_BOTPRESS_HOME/profiles.json',\n positional: true,\n idx: 0,\n },\n} satisfies CommandSchema\n\n// exports\n\nexport const schemas = {\n global: globalSchema,\n project: projectSchema,\n credentials: credentialsSchema,\n secrets: secretsSchema,\n login: loginSchema,\n logout: logoutSchema,\n createBot: createBotSchema,\n getBot: getBotSchema,\n deleteBot: deleteBotSchema,\n listBots: listBotsSchema,\n getIntegration: getIntegrationSchema,\n listIntegrations: listIntegrationsSchema,\n deleteIntegration: deleteIntegrationSchema,\n getInterface: getInterfaceSchema,\n listInterfaces: listInterfacesSchema,\n deleteInterface: deleteInterfaceSchema,\n getPlugin: getPluginSchema,\n listPlugins: listPluginsSchema,\n deletePlugin: deletePluginSchema,\n init: initSchema,\n generate: generateSchema,\n bundle: bundleSchema,\n build: buildSchema,\n read: readSchema,\n serve: serveSchema,\n deploy: deploySchema,\n add: addSchema,\n dev: devSchema,\n lint: lintSchema,\n chat: chatSchema,\n listProfiles: listProfilesSchema,\n activeProfile: activeProfileSchema,\n useProfile: useProfileSchema,\n} as const\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,+BAAiC;AAKjC,MAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS,OAAO;AAClB;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,QAAQ;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,aAAa;AACf;AAEA,MAAM,UAAU;AAAA,EACd,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,SAAS,CAAC;AACZ;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,KAAK;AACP;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AAAA,EACN,aACE;AAAA,EACF,SAAS,CAAC,eAAe,aAAa,QAAQ;AAChD;AAEA,MAAM,aAAa;AA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;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AACd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/consts.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(consts_exports, {
|
|
|
34
34
|
defaultBotpressHome: () => defaultBotpressHome,
|
|
35
35
|
defaultChatApiUrl: () => defaultChatApiUrl,
|
|
36
36
|
defaultInstallPath: () => defaultInstallPath,
|
|
37
|
+
defaultProfileName: () => defaultProfileName,
|
|
37
38
|
defaultTunnelUrl: () => defaultTunnelUrl,
|
|
38
39
|
defaultWorkDir: () => defaultWorkDir,
|
|
39
40
|
distDirName: () => distDirName,
|
|
@@ -61,6 +62,7 @@ const installDirName = "bp_modules";
|
|
|
61
62
|
const outDirName = ".botpress";
|
|
62
63
|
const distDirName = "dist";
|
|
63
64
|
const profileFileName = "profiles.json";
|
|
65
|
+
const defaultProfileName = "default";
|
|
64
66
|
const fromCliRootDir = {};
|
|
65
67
|
const fromHomeDir = {
|
|
66
68
|
globalCacheFile: "global.cache.json"
|
|
@@ -97,6 +99,7 @@ const fromWorkDir = {
|
|
|
97
99
|
defaultBotpressHome,
|
|
98
100
|
defaultChatApiUrl,
|
|
99
101
|
defaultInstallPath,
|
|
102
|
+
defaultProfileName,
|
|
100
103
|
defaultTunnelUrl,
|
|
101
104
|
defaultWorkDir,
|
|
102
105
|
distDirName,
|
package/dist/consts.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/consts.ts"],
|
|
4
|
-
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\nimport { CLI_ROOT_DIR } from './root'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\nexport const defaultWorkDir = process.cwd()\nexport const defaultInstallPath = process.cwd()\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\nexport const defaultChatApiUrl = 'https://chat.botpress.cloud'\n\n// not configurable\n\nexport const cliRootDir = CLI_ROOT_DIR\nexport const installDirName = 'bp_modules'\nexport const outDirName = '.botpress'\nexport const distDirName = 'dist'\nexport const profileFileName = 'profiles.json'\n\nexport const fromCliRootDir = {}\n\nexport const fromHomeDir = {\n globalCacheFile: 'global.cache.json',\n}\n\nexport const fromOutDir = {\n distDir: distDirName,\n outFileCJS: pathlib.join(distDirName, 'index.cjs'),\n outFileESM: pathlib.join(distDirName, 'index.mjs'),\n implementationDir: 'implementation',\n pluginsDir: 'plugins',\n secretsDir: 'secrets',\n projectCacheFile: 'project.cache.json',\n}\n\nexport const fromWorkDir = {\n integrationDefinition: 'integration.definition.ts',\n interfaceDefinition: 'interface.definition.ts',\n botDefinition: 'bot.definition.ts',\n pluginDefinition: 'plugin.definition.ts',\n entryPoint: pathlib.join('src', 'index.ts'),\n outDir: outDirName,\n distDir: pathlib.join(outDirName, fromOutDir.distDir),\n outFileCJS: pathlib.join(outDirName, fromOutDir.outFileCJS),\n outFileESM: pathlib.join(outDirName, fromOutDir.outFileESM),\n implementationDir: pathlib.join(outDirName, fromOutDir.implementationDir),\n pluginsDir: pathlib.join(outDirName, fromOutDir.pluginsDir),\n secretsDir: pathlib.join(outDirName, fromOutDir.secretsDir),\n projectCacheFile: pathlib.join(outDirName, fromOutDir.projectCacheFile),\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;AACpB,kBAA6B;AAItB,MAAM,sBAAsB,YAAAA,QAAQ,KAAK,UAAAC,QAAG,QAAQ,GAAG,WAAW;AAClE,MAAM,iBAAiB,QAAQ,IAAI;AACnC,MAAM,qBAAqB,QAAQ,IAAI;AACvC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAI1B,MAAM,aAAa;AACnB,MAAM,iBAAiB;AACvB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import os from 'os'\nimport pathlib from 'path'\nimport { CLI_ROOT_DIR } from './root'\n\n// configurable\n\nexport const defaultBotpressHome = pathlib.join(os.homedir(), '.botpress')\nexport const defaultWorkDir = process.cwd()\nexport const defaultInstallPath = process.cwd()\nexport const defaultBotpressApiUrl = 'https://api.botpress.cloud'\nexport const defaultBotpressAppUrl = 'https://app.botpress.cloud'\nexport const defaultTunnelUrl = 'https://tunnel.botpress.cloud'\nexport const defaultChatApiUrl = 'https://chat.botpress.cloud'\n\n// not configurable\n\nexport const cliRootDir = CLI_ROOT_DIR\nexport const installDirName = 'bp_modules'\nexport const outDirName = '.botpress'\nexport const distDirName = 'dist'\nexport const profileFileName = 'profiles.json'\nexport const defaultProfileName = 'default'\n\nexport const fromCliRootDir = {}\n\nexport const fromHomeDir = {\n globalCacheFile: 'global.cache.json',\n}\n\nexport const fromOutDir = {\n distDir: distDirName,\n outFileCJS: pathlib.join(distDirName, 'index.cjs'),\n outFileESM: pathlib.join(distDirName, 'index.mjs'),\n implementationDir: 'implementation',\n pluginsDir: 'plugins',\n secretsDir: 'secrets',\n projectCacheFile: 'project.cache.json',\n}\n\nexport const fromWorkDir = {\n integrationDefinition: 'integration.definition.ts',\n interfaceDefinition: 'interface.definition.ts',\n botDefinition: 'bot.definition.ts',\n pluginDefinition: 'plugin.definition.ts',\n entryPoint: pathlib.join('src', 'index.ts'),\n outDir: outDirName,\n distDir: pathlib.join(outDirName, fromOutDir.distDir),\n outFileCJS: pathlib.join(outDirName, fromOutDir.outFileCJS),\n outFileESM: pathlib.join(outDirName, fromOutDir.outFileESM),\n implementationDir: pathlib.join(outDirName, fromOutDir.implementationDir),\n pluginsDir: pathlib.join(outDirName, fromOutDir.pluginsDir),\n secretsDir: pathlib.join(outDirName, fromOutDir.secretsDir),\n projectCacheFile: pathlib.join(outDirName, fromOutDir.projectCacheFile),\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;AACpB,kBAA6B;AAItB,MAAM,sBAAsB,YAAAA,QAAQ,KAAK,UAAAC,QAAG,QAAQ,GAAG,WAAW;AAClE,MAAM,iBAAiB,QAAQ,IAAI;AACnC,MAAM,qBAAqB,QAAQ,IAAI;AACvC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAI1B,MAAM,aAAa;AACnB,MAAM,iBAAiB;AACvB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAE3B,MAAM,iBAAiB,CAAC;AAExB,MAAM,cAAc;AAAA,EACzB,iBAAiB;AACnB;AAEO,MAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,YAAY,YAAAD,QAAQ,KAAK,aAAa,WAAW;AAAA,EACjD,YAAY,YAAAA,QAAQ,KAAK,aAAa,WAAW;AAAA,EACjD,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,kBAAkB;AACpB;AAEO,MAAM,cAAc;AAAA,EACzB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,YAAY,YAAAA,QA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