@botpress/cli 0.0.9 → 0.0.11
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/dist/api-client.js +107 -0
- package/dist/app/api-utils.js +9 -3
- package/dist/app/base.js +1 -3
- package/dist/app/errors.js +8 -0
- package/dist/app/file-paths.js +4 -2
- package/dist/app/index.js +17 -12
- package/dist/app/user.js +73 -23
- package/dist/code-generation/action.js +70 -0
- package/dist/code-generation/channel.js +51 -0
- package/dist/code-generation/configuration.js +40 -0
- package/dist/code-generation/const.js +31 -0
- package/dist/code-generation/event.js +41 -0
- package/dist/code-generation/index.js +80 -0
- package/dist/code-generation/integration-impl.js +147 -0
- package/dist/code-generation/integration-instance.js +79 -0
- package/dist/code-generation/message.js +41 -0
- package/dist/code-generation/module.js +115 -0
- package/dist/code-generation/typings.js +16 -0
- package/dist/command-definitions.js +61 -0
- package/dist/command-implementations/add-command.js +124 -0
- package/dist/command-implementations/base-command.js +53 -0
- package/dist/command-implementations/bot-commands.js +89 -0
- package/dist/command-implementations/build-command.js +48 -0
- package/dist/command-implementations/bundle-command.js +58 -0
- package/dist/command-implementations/deploy-command.js +162 -0
- package/dist/command-implementations/dev-command.js +168 -0
- package/dist/command-implementations/gen-command.js +58 -0
- package/dist/command-implementations/global-command.js +111 -0
- package/dist/command-implementations/index.js +78 -0
- package/dist/command-implementations/init-command.js +85 -0
- package/dist/command-implementations/integration-commands.js +107 -0
- package/dist/command-implementations/login-command.js +75 -0
- package/dist/command-implementations/logout-command.js +34 -0
- package/dist/command-implementations/project-command.js +115 -0
- package/dist/command-implementations/serve-command.js +53 -0
- package/dist/command-tree.js +59 -0
- package/dist/config.js +85 -112
- package/dist/consts.js +14 -1
- package/dist/errors.js +156 -0
- package/dist/index.js +13 -243
- package/dist/integration-ref.js +61 -0
- package/dist/logger/base-logger.js +5 -20
- package/dist/logger/index.js +3 -2
- package/dist/path-utils.js +6 -0
- package/dist/register-yargs.js +85 -0
- package/dist/typings.js +16 -0
- package/dist/utils/cache-utils.js +99 -0
- package/dist/utils/esbuild-utils.js +89 -0
- package/dist/utils/event-emitter.js +62 -0
- package/dist/utils/file-watcher.js +68 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/path-utils.js +83 -0
- package/dist/utils/prompt-utils.js +75 -0
- package/dist/utils/require-utils.js +49 -0
- package/dist/utils/string-utils.js +38 -0
- package/dist/worker/child-entrypoint.js +3 -3
- package/package.json +7 -5
- package/templates/echo-bot/.botpress/project.cache.json +1 -0
- package/templates/echo-bot/package.json +22 -0
- package/templates/echo-bot/readme.md +5 -0
- package/templates/echo-bot/src/index.ts +44 -0
- package/templates/echo-bot/tsconfig.json +15 -0
- package/templates/empty-integration/.botpress/implementation/actions/index.ts +7 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/audio.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/card.ts +17 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/carousel.ts +19 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/choice.ts +14 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/dropdown.ts +14 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/file.ts +11 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/image.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/index.ts +40 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/location.ts +11 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/markdown.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/text.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/channel/video.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/channels/index.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/configuration.ts +10 -0
- package/templates/empty-integration/.botpress/implementation/events/index.ts +7 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +17 -0
- package/templates/empty-integration/.botpress/index.ts +1 -0
- package/templates/empty-integration/.botpress/project.cache.json +1 -0
- package/templates/empty-integration/integration.definition.ts +13 -0
- package/templates/empty-integration/package.json +22 -0
- package/templates/empty-integration/readme.md +5 -0
- package/templates/empty-integration/src/index.ts +58 -0
- package/templates/empty-integration/tsconfig.json +15 -0
- package/.ignore.me.github/index.ts +0 -38
- package/dist/github-download.js +0 -159
- package/dist/github-fetch.js +0 -173
package/dist/github-fetch.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
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
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var github_fetch_exports = {};
|
|
26
|
-
__export(github_fetch_exports, {
|
|
27
|
-
GithubFetchError: () => GithubFetchError,
|
|
28
|
-
GithubFetcher: () => GithubFetcher
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(github_fetch_exports);
|
|
31
|
-
var import_git_url_parse = __toESM(require("git-url-parse"));
|
|
32
|
-
var import_octokit = require("octokit");
|
|
33
|
-
var import_path = __toESM(require("path"));
|
|
34
|
-
class GithubFetchError extends Error {
|
|
35
|
-
}
|
|
36
|
-
const GITHUB_HOST = "github.com";
|
|
37
|
-
const DEFAULT_REF = "HEAD";
|
|
38
|
-
const GIT_URI = /^(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$/;
|
|
39
|
-
const GITHUB_TREE_URI = /^https:\/\/(.*?)(\.com)\/.*$/;
|
|
40
|
-
class GithubFetcher {
|
|
41
|
-
constructor(_logger) {
|
|
42
|
-
this._logger = _logger;
|
|
43
|
-
}
|
|
44
|
-
async listFiles(props) {
|
|
45
|
-
const { uri, auth, recursive, pattern } = props;
|
|
46
|
-
if (pattern?.global) {
|
|
47
|
-
throw new GithubFetchError("Pattern must not be global");
|
|
48
|
-
}
|
|
49
|
-
const parsedUri = this._parseUri(uri);
|
|
50
|
-
const octo = new import_octokit.Octokit({ auth });
|
|
51
|
-
const dir = await this._browseTree({
|
|
52
|
-
octo,
|
|
53
|
-
uri: parsedUri,
|
|
54
|
-
recursive: recursive ?? false,
|
|
55
|
-
pattern,
|
|
56
|
-
leafMap: async (entry) => {
|
|
57
|
-
const entryUri = { ...parsedUri, path: entry.path };
|
|
58
|
-
return {
|
|
59
|
-
type: "file",
|
|
60
|
-
uri: this._formatUri(entryUri),
|
|
61
|
-
name: import_path.default.basename(entry.path),
|
|
62
|
-
content: null
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return dir;
|
|
67
|
-
}
|
|
68
|
-
async fetchFiles(props) {
|
|
69
|
-
const { uri, auth, recursive, pattern } = props;
|
|
70
|
-
if (pattern?.global) {
|
|
71
|
-
throw new GithubFetchError("Pattern must not be global");
|
|
72
|
-
}
|
|
73
|
-
const parsedUri = this._parseUri(uri);
|
|
74
|
-
const octo = new import_octokit.Octokit({ auth });
|
|
75
|
-
const dir = await this._browseTree({
|
|
76
|
-
octo,
|
|
77
|
-
uri: parsedUri,
|
|
78
|
-
recursive: recursive ?? false,
|
|
79
|
-
pattern,
|
|
80
|
-
leafMap: async (entry) => {
|
|
81
|
-
const entryUri = { ...parsedUri, path: entry.path };
|
|
82
|
-
const {
|
|
83
|
-
data: { content: blob }
|
|
84
|
-
} = await octo.rest.git.getBlob({ ...entryUri, file_sha: entry.sha });
|
|
85
|
-
return {
|
|
86
|
-
type: "file",
|
|
87
|
-
uri: this._formatUri({ ...parsedUri, path: entry.path }),
|
|
88
|
-
name: import_path.default.basename(entry.path),
|
|
89
|
-
content: Buffer.from(blob, "base64").toString("utf8")
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return dir;
|
|
94
|
-
}
|
|
95
|
-
async _browseTree(props) {
|
|
96
|
-
const { octo, uri, recursive, leafMap, pattern } = props;
|
|
97
|
-
const { data } = await octo.rest.repos.getContent({
|
|
98
|
-
...uri
|
|
99
|
-
});
|
|
100
|
-
if (!Array.isArray(data)) {
|
|
101
|
-
const formattedUri = this._formatUri(uri);
|
|
102
|
-
throw new GithubFetchError(`URI ${formattedUri} is not a directory. Cannot list or fetch a single file.`);
|
|
103
|
-
}
|
|
104
|
-
const allTopLevelEntries = data;
|
|
105
|
-
const supportedEntries = allTopLevelEntries.filter(this._isSupported);
|
|
106
|
-
const dir = {
|
|
107
|
-
type: "dir",
|
|
108
|
-
uri: this._formatUri(uri),
|
|
109
|
-
name: import_path.default.basename(uri.path)
|
|
110
|
-
};
|
|
111
|
-
const content = [];
|
|
112
|
-
for (const entry of supportedEntries) {
|
|
113
|
-
const entryUri = { ...uri, path: entry.path };
|
|
114
|
-
if (entry.type === "file") {
|
|
115
|
-
if (pattern && !pattern.test(entry.path)) {
|
|
116
|
-
this._logger.debug(`Skipping ${entry.path} because it does not match pattern ${pattern}`);
|
|
117
|
-
} else {
|
|
118
|
-
const leaf = await leafMap(entry);
|
|
119
|
-
content.push(leaf);
|
|
120
|
-
}
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (!recursive) {
|
|
124
|
-
content.push({
|
|
125
|
-
type: "dir",
|
|
126
|
-
uri: this._formatUri(entryUri),
|
|
127
|
-
name: entry.name,
|
|
128
|
-
content: []
|
|
129
|
-
});
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
const subDirEntry = await this._browseTree({ octo, uri: entryUri, recursive, leafMap });
|
|
133
|
-
content.push(subDirEntry);
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
...dir,
|
|
137
|
-
content
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
_formatUri(uri) {
|
|
141
|
-
if (uri.protocol === "ssh") {
|
|
142
|
-
return `git@${GITHUB_HOST}:${uri.owner}/${uri.repo}.git`;
|
|
143
|
-
}
|
|
144
|
-
return `https://${GITHUB_HOST}/${uri.owner}/${uri.repo}/tree/${uri.ref}/${uri.path}`;
|
|
145
|
-
}
|
|
146
|
-
_parseUri(uri) {
|
|
147
|
-
const isGit = this._isGitUri(uri);
|
|
148
|
-
if (!isGit) {
|
|
149
|
-
throw new Error("URI is not a valid git repository URI");
|
|
150
|
-
}
|
|
151
|
-
const parsed = (0, import_git_url_parse.default)(uri);
|
|
152
|
-
if (parsed.resource !== GITHUB_HOST) {
|
|
153
|
-
throw new Error(`Unsupported git host: ${parsed.resource}`);
|
|
154
|
-
}
|
|
155
|
-
if (parsed.protocol !== "ssh" && parsed.protocol !== "https") {
|
|
156
|
-
throw new Error(`Unsupported git protocol: ${parsed.protocol}}`);
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
protocol: parsed.protocol,
|
|
160
|
-
owner: parsed.owner,
|
|
161
|
-
repo: parsed.name,
|
|
162
|
-
ref: parsed.ref ? parsed.ref : DEFAULT_REF,
|
|
163
|
-
path: parsed.filepath
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
_isGitUri = (uri) => GITHUB_TREE_URI.test(uri) || GIT_URI.test(uri);
|
|
167
|
-
_isSupported = (file) => file.type === "dir" || file.type === "file";
|
|
168
|
-
}
|
|
169
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
-
0 && (module.exports = {
|
|
171
|
-
GithubFetchError,
|
|
172
|
-
GithubFetcher
|
|
173
|
-
});
|