@botonic/nx-plugin 2.30.0 → 2.31.1-alpha.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/CHANGELOG.md +27 -0
- package/executors.json +0 -5
- package/index.js +44 -0
- package/{src/executors/build-node-app/executor.js → libs/botonic/nx-plugin/src/executors/build-node-app/executor-impl.js} +3 -3
- package/libs/botonic/nx-plugin/src/executors/build-node-app/executor.js +27 -0
- package/{src/executors/delete-bot/executor.js → libs/botonic/nx-plugin/src/executors/delete-bot/executor-impl.js} +3 -5
- package/libs/botonic/nx-plugin/src/executors/delete-bot/executor.js +27 -0
- package/{src/executors/deploy-netlify-snapshot/executor.js → libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot/executor-impl.js} +3 -3
- package/libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot/executor.js +27 -0
- package/libs/botonic/nx-plugin/src/executors/deploy-to-hubtype/executor-impl.js +172 -0
- package/libs/botonic/nx-plugin/src/executors/deploy-to-hubtype/executor.js +27 -0
- package/{src/executors/e2e-webchat/executor.js → libs/botonic/nx-plugin/src/executors/e2e-webchat/executor-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/executors/e2e-webchat/executor.js +27 -0
- package/{src/executors/integrate-provider/executor.js → libs/botonic/nx-plugin/src/executors/integrate-provider/executor-impl.js} +3 -5
- package/libs/botonic/nx-plugin/src/executors/integrate-provider/executor.js +27 -0
- package/{src/executors/login-to-hubtype/executor.js → libs/botonic/nx-plugin/src/executors/login-to-hubtype/executor-impl.js} +3 -5
- package/libs/botonic/nx-plugin/src/executors/login-to-hubtype/executor.js +27 -0
- package/{src/executors/logout-from-hubtype/executor.js → libs/botonic/nx-plugin/src/executors/logout-from-hubtype/executor-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/executors/logout-from-hubtype/executor.js +27 -0
- package/{src/executors/run-lambda/executor.js → libs/botonic/nx-plugin/src/executors/run-lambda/executor-impl.js} +3 -3
- package/libs/botonic/nx-plugin/src/executors/run-lambda/executor.js +27 -0
- package/{src/executors/serve-bot/executor.js → libs/botonic/nx-plugin/src/executors/serve-bot/executor-impl.js} +145 -27
- package/libs/botonic/nx-plugin/src/executors/serve-bot/executor.js +27 -0
- package/{src/generators/action/generator.js → libs/botonic/nx-plugin/src/generators/action/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/action/generator.js +27 -0
- package/{src/generators/bot-app/generator.js → libs/botonic/nx-plugin/src/generators/bot-app/generator-impl.js} +6 -5
- package/libs/botonic/nx-plugin/src/generators/bot-app/generator.js +34 -0
- package/{src/generators/custom-message/generator.js → libs/botonic/nx-plugin/src/generators/custom-message/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/custom-message/generator.js +27 -0
- package/{src/generators/preset/generator.js → libs/botonic/nx-plugin/src/generators/preset/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/preset/generator.js +34 -0
- package/{src/generators/remove-custom-message/generator.js → libs/botonic/nx-plugin/src/generators/remove-custom-message/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/remove-custom-message/generator.js +27 -0
- package/{src/generators/webview/generator.js → libs/botonic/nx-plugin/src/generators/webview/generator-impl.js} +5 -5
- package/libs/botonic/nx-plugin/src/generators/webview/generator.js +27 -0
- package/{src → libs/botonic/nx-plugin/src}/index.js +3 -1
- package/{src → libs/botonic/nx-plugin/src}/lib/api-service.js +150 -82
- package/{src → libs/botonic/nx-plugin/src}/lib/constants.js +6 -9
- package/{src → libs/botonic/nx-plugin/src}/lib/credentials-handler.js +42 -24
- package/libs/botonic/nx-plugin/src/lib/delegate/delegate-executor.js +119 -0
- package/libs/botonic/nx-plugin/src/lib/delegate/delegate-generator.js +128 -0
- package/libs/botonic/nx-plugin/src/lib/serve-mode/index.js +183 -0
- package/{src → libs/botonic/nx-plugin/src}/lib/util/executor-helpers.js +494 -106
- package/{src → libs/botonic/nx-plugin/src}/plugin.js +5 -14
- package/migrations.json +1 -8
- package/package.json +7 -4
- package/src/executors/build-node-app/executor-impl.d.ts +5 -0
- package/src/executors/build-node-app/executor.d.ts +4 -2
- package/src/executors/delete-bot/executor-impl.d.ts +5 -0
- package/src/executors/delete-bot/executor.d.ts +4 -2
- package/src/executors/deploy-netlify-snapshot/executor-impl.d.ts +8 -0
- package/src/executors/deploy-netlify-snapshot/executor.d.ts +4 -5
- package/src/executors/deploy-to-hubtype/executor-impl.d.ts +5 -0
- package/src/executors/deploy-to-hubtype/executor.d.ts +4 -2
- package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +7 -11
- package/src/executors/e2e-webchat/executor-impl.d.ts +5 -0
- package/src/executors/e2e-webchat/executor.d.ts +4 -2
- package/src/executors/integrate-provider/executor-impl.d.ts +5 -0
- package/src/executors/integrate-provider/executor.d.ts +4 -2
- package/src/executors/login-to-hubtype/executor-impl.d.ts +5 -0
- package/src/executors/login-to-hubtype/executor.d.ts +4 -2
- package/src/executors/logout-from-hubtype/executor-impl.d.ts +3 -0
- package/src/executors/logout-from-hubtype/executor.d.ts +5 -1
- package/src/executors/run-lambda/executor-impl.d.ts +5 -0
- package/src/executors/run-lambda/executor.d.ts +4 -2
- package/src/executors/serve-bot/executor-impl.d.ts +5 -0
- package/src/executors/serve-bot/executor.d.ts +4 -2
- package/src/executors/serve-bot/schema.json +13 -5
- package/src/generators/action/generator-impl.d.ts +4 -0
- package/src/generators/action/generator.d.ts +2 -3
- package/src/generators/bot-app/files/vite/node.config.ts.template +2 -7
- package/src/generators/bot-app/files/vite/webchat.config.ts.template +10 -2
- package/src/generators/bot-app/generator-impl.d.ts +4 -0
- package/src/generators/bot-app/generator.d.ts +2 -4
- package/src/generators/custom-message/generator-impl.d.ts +4 -0
- package/src/generators/custom-message/generator.d.ts +2 -3
- package/src/generators/preset/generator-impl.d.ts +4 -0
- package/src/generators/preset/generator.d.ts +2 -4
- package/src/generators/remove-custom-message/generator-impl.d.ts +4 -0
- package/src/generators/remove-custom-message/generator.d.ts +2 -3
- package/src/generators/webview/generator-impl.d.ts +4 -0
- package/src/generators/webview/generator.d.ts +2 -3
- package/src/index.d.ts +1 -0
- package/src/lib/api-service.d.ts +19 -20
- package/src/lib/constants.d.ts +2 -3
- package/src/lib/credentials-handler.d.ts +9 -18
- package/src/lib/delegate/delegate-executor.d.ts +6 -0
- package/src/lib/delegate/delegate-generator.d.ts +2 -0
- package/src/lib/interfaces.d.ts +10 -13
- package/src/lib/serve-mode/index.d.ts +25 -0
- package/src/lib/util/executor-helpers.d.ts +52 -23
- package/src/executors/deploy-local-runtime/executor.d.ts +0 -5
- package/src/executors/deploy-local-runtime/executor.js +0 -148
- package/src/executors/deploy-local-runtime/schema.json +0 -34
- package/src/executors/deploy-to-hubtype/executor.js +0 -308
- package/src/executors/serve-bot/schema.d.js +0 -16
- package/src/generators/bot-app/files/vite/botonic-ssr-deps.ts.template +0 -56
- package/src/generators/bot-app/files/vite/plugins/dev-log-viewer-html.plugin.ts.template +0 -65
- package/src/generators/preset/files/package.json +0 -26
- package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.d.ts +0 -2
- package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.js +0 -290
- /package/{src → libs/botonic/nx-plugin/src}/executors/build-node-app/schema.d.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/executors/delete-bot/schema.d.js +0 -0
- /package/{src/executors/deploy-local-runtime → libs/botonic/nx-plugin/src/executors/deploy-netlify-snapshot}/schema.d.js +0 -0
- /package/{src/executors/deploy-netlify-snapshot → libs/botonic/nx-plugin/src/executors/deploy-to-hubtype}/schema.d.js +0 -0
- /package/{src/executors/deploy-to-hubtype → libs/botonic/nx-plugin/src/executors/e2e-webchat}/schema.d.js +0 -0
- /package/{src/executors/e2e-webchat → libs/botonic/nx-plugin/src/executors/integrate-provider}/schema.d.js +0 -0
- /package/{src/executors/integrate-provider → libs/botonic/nx-plugin/src/executors/login-to-hubtype}/schema.d.js +0 -0
- /package/{src/executors/login-to-hubtype → libs/botonic/nx-plugin/src/executors/logout-from-hubtype}/schema.d.js +0 -0
- /package/{src/executors/logout-from-hubtype → libs/botonic/nx-plugin/src/executors/run-lambda}/schema.d.js +0 -0
- /package/{src/executors/run-lambda → libs/botonic/nx-plugin/src/executors/serve-bot}/schema.d.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/action/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/bot-app/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/custom-message/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/preset/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/remove-custom-message/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/shared/bot-app-utils.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/generators/webview/schema.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/bot-config.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/cloudflared-tunnel.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/index.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/interfaces.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/file-system.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/sam-container-cleanup.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/sam-template.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/lib/util/system.js +0 -0
- /package/{src → libs/botonic/nx-plugin/src}/migrations/utils/migration-utils.js +0 -0
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var executor_exports = {};
|
|
20
|
-
__export(executor_exports, {
|
|
21
|
-
default: () => deployToHubtypeExecutor
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(executor_exports);
|
|
24
|
-
var import_enquirer = require("enquirer");
|
|
25
|
-
var import_fs = require("fs");
|
|
26
|
-
var import_path = require("path");
|
|
27
|
-
var import_zip_a_folder = require("zip-a-folder");
|
|
28
|
-
var import_api_service = require("../../lib/api-service");
|
|
29
|
-
var import_bot_config = require("../../lib/bot-config");
|
|
30
|
-
var import_executor_helpers = require("../../lib/util/executor-helpers");
|
|
31
|
-
var import_file_system = require("../../lib/util/file-system");
|
|
32
|
-
var import_system = require("../../lib/util/system");
|
|
33
|
-
const BOTONIC_BUNDLE_FILE = "botonic_bundle.zip";
|
|
34
|
-
const BOTONIC_TEMP_DIRNAME = "tmp";
|
|
35
|
-
let PROJECT_ROOT;
|
|
36
|
-
async function deployToHubtypeExecutor(options, context) {
|
|
37
|
-
if (!context.projectName) {
|
|
38
|
-
throw new Error("Project name is not defined in executor context");
|
|
39
|
-
}
|
|
40
|
-
PROJECT_ROOT = (0, import_executor_helpers.resolveProjectPath)(context);
|
|
41
|
-
try {
|
|
42
|
-
const { targetEnvironment, environmentVariables } = (0, import_executor_helpers.resolveHubtypeEnvironment)(context, options);
|
|
43
|
-
const botonicApiService = new import_api_service.BotonicAPIService({
|
|
44
|
-
projectRoot: PROJECT_ROOT,
|
|
45
|
-
workspaceRoot: (0, import_path.resolve)(context.root),
|
|
46
|
-
environmentVariables,
|
|
47
|
-
targetEnvironment
|
|
48
|
-
});
|
|
49
|
-
const botName = options.botName;
|
|
50
|
-
if (!botonicApiService.oauth) {
|
|
51
|
-
if (options.email && options.password) {
|
|
52
|
-
await botonicApiService.login(options.email, options.password);
|
|
53
|
-
botonicApiService.saveAllCredentials();
|
|
54
|
-
} else {
|
|
55
|
-
await (0, import_executor_helpers.handleAuthentication)(botonicApiService);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
await (0, import_executor_helpers.logWorkingAsAndEnvironment)(botonicApiService);
|
|
59
|
-
console.log(
|
|
60
|
-
`\u{1F680} Deploying to Hubtype... [${environmentVariables["VITE_HUBTYPE_API_URL"]}]
|
|
61
|
-
`
|
|
62
|
-
);
|
|
63
|
-
if (botName) {
|
|
64
|
-
await handleBotFromFlag(
|
|
65
|
-
botonicApiService,
|
|
66
|
-
botName,
|
|
67
|
-
options.createIfNotExists
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
await handleBotFlow(botonicApiService);
|
|
71
|
-
}
|
|
72
|
-
await deploy(botonicApiService, PROJECT_ROOT, context.projectName);
|
|
73
|
-
return { success: true };
|
|
74
|
-
} catch (error) {
|
|
75
|
-
return (0, import_executor_helpers.handleExecutorError)(error, "Deployment");
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async function handleBotFromFlag(botonicApiService, botName, createIfNotExists) {
|
|
79
|
-
const bots = await (0, import_executor_helpers.getAvailableBots)(botonicApiService);
|
|
80
|
-
const bot = bots.find((b) => b.name === botName);
|
|
81
|
-
if (bot) {
|
|
82
|
-
botonicApiService.setCurrentBot(bot);
|
|
83
|
-
} else {
|
|
84
|
-
if (createIfNotExists) {
|
|
85
|
-
console.log(
|
|
86
|
-
`\u{1F916} Bot "${botName}" doesn't exist. Creating it automatically...`
|
|
87
|
-
);
|
|
88
|
-
await createNewBot(botonicApiService, botName);
|
|
89
|
-
} else {
|
|
90
|
-
const response = await (0, import_enquirer.prompt)({
|
|
91
|
-
type: "confirm",
|
|
92
|
-
name: "create_bot_confirm",
|
|
93
|
-
message: `\u{1F916} Bot "${botName}" doesn't exist. Do you want to create it?`
|
|
94
|
-
});
|
|
95
|
-
if (response.create_bot_confirm) {
|
|
96
|
-
await createNewBot(botonicApiService, botName);
|
|
97
|
-
} else {
|
|
98
|
-
throw new Error(`Bot "${botName}" not found`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async function handleBotFlow(botonicApiService) {
|
|
104
|
-
if (!botonicApiService.bot || !Object.keys(botonicApiService.bot).length) {
|
|
105
|
-
await newBotFlow(botonicApiService);
|
|
106
|
-
} else {
|
|
107
|
-
const resp = await botonicApiService.getBots();
|
|
108
|
-
const bots = resp.data.results;
|
|
109
|
-
const firstId = botonicApiService.bot.id;
|
|
110
|
-
bots.sort(
|
|
111
|
-
(x, y) => x.id === firstId ? -1 : y.id === firstId ? 1 : 0
|
|
112
|
-
);
|
|
113
|
-
await selectExistentBot(botonicApiService, bots);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async function newBotFlow(botonicApiService) {
|
|
117
|
-
const bots = await (0, import_executor_helpers.getAvailableBots)(botonicApiService);
|
|
118
|
-
if (!bots.length) {
|
|
119
|
-
await createNewBot(botonicApiService);
|
|
120
|
-
} else {
|
|
121
|
-
const response = await (0, import_enquirer.prompt)({
|
|
122
|
-
type: "confirm",
|
|
123
|
-
name: "create_bot_confirm",
|
|
124
|
-
message: "\u{1F916} Do you want to create a new bot?"
|
|
125
|
-
});
|
|
126
|
-
if (response.create_bot_confirm) {
|
|
127
|
-
await createNewBot(botonicApiService);
|
|
128
|
-
} else {
|
|
129
|
-
await selectExistentBot(botonicApiService, bots);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
async function createNewBot(botonicApiService, botName) {
|
|
134
|
-
if (botName) {
|
|
135
|
-
await (0, import_executor_helpers.createNewBotWithName)(botonicApiService, botName);
|
|
136
|
-
} else {
|
|
137
|
-
console.log("\u{1F916} Let's create a new bot!\n");
|
|
138
|
-
const response = await (0, import_enquirer.prompt)({
|
|
139
|
-
type: "input",
|
|
140
|
-
name: "bot_name",
|
|
141
|
-
message: "\u{1F916} Bot name:",
|
|
142
|
-
validate: (input) => {
|
|
143
|
-
return input.length > 0 ? true : "Bot name cannot be empty";
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
await (0, import_executor_helpers.createNewBotWithName)(botonicApiService, response.bot_name);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
async function selectExistentBot(botonicApiService, bots) {
|
|
150
|
-
console.log("\u{1F4CB} Select a bot to deploy:\n");
|
|
151
|
-
const providersPromises = bots.map((b) => botonicApiService.getProviders(b.id));
|
|
152
|
-
const providers = await Promise.all(providersPromises);
|
|
153
|
-
const botsWithProviders = bots.map((bot2, index) => ({
|
|
154
|
-
...bot2,
|
|
155
|
-
providers: providers[index].data.results
|
|
156
|
-
}));
|
|
157
|
-
const response = await (0, import_enquirer.prompt)({
|
|
158
|
-
type: "select",
|
|
159
|
-
name: "bot_name",
|
|
160
|
-
message: "\u{1F916} Please select a bot:",
|
|
161
|
-
choices: botsWithProviders.map((bot2) => {
|
|
162
|
-
return {
|
|
163
|
-
name: bot2.name,
|
|
164
|
-
message: bot2.name
|
|
165
|
-
};
|
|
166
|
-
})
|
|
167
|
-
});
|
|
168
|
-
const selectedBotName = response.bot_name;
|
|
169
|
-
const bot = botsWithProviders.find((bot2) => bot2.name === selectedBotName);
|
|
170
|
-
if (bot) {
|
|
171
|
-
botonicApiService.setCurrentBot(bot);
|
|
172
|
-
console.log(`\u2705 Selected bot: ${bot.name}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
async function deploy(botonicApiService, projectRoot, projectName) {
|
|
176
|
-
console.log("\u{1F528} Preparing your bot for deployment...\n");
|
|
177
|
-
const buildOut = await botonicApiService.build({
|
|
178
|
-
projectRoot,
|
|
179
|
-
projectName
|
|
180
|
-
});
|
|
181
|
-
if (!buildOut) {
|
|
182
|
-
throw new Error("Build failed");
|
|
183
|
-
}
|
|
184
|
-
const botConfigJson = await import_bot_config.BotConfig.get(projectRoot);
|
|
185
|
-
await createBundle(projectRoot);
|
|
186
|
-
const { hasDeployErrors } = await deployBundle(
|
|
187
|
-
botonicApiService,
|
|
188
|
-
botConfigJson
|
|
189
|
-
);
|
|
190
|
-
await displayDeployResults(botonicApiService, { hasDeployErrors });
|
|
191
|
-
(0, import_fs.rmSync)((0, import_path.join)(projectRoot, BOTONIC_BUNDLE_FILE));
|
|
192
|
-
(0, import_file_system.removeRecursively)((0, import_path.join)(projectRoot, BOTONIC_TEMP_DIRNAME));
|
|
193
|
-
botonicApiService.saveAllCredentials();
|
|
194
|
-
}
|
|
195
|
-
async function createBundle(projectRoot) {
|
|
196
|
-
console.log("\u{1F4E6} Creating deployment bundle...");
|
|
197
|
-
if ((0, import_file_system.pathExists)((0, import_path.join)(projectRoot, BOTONIC_TEMP_DIRNAME))) {
|
|
198
|
-
(0, import_file_system.removeRecursively)((0, import_path.join)(projectRoot, BOTONIC_TEMP_DIRNAME));
|
|
199
|
-
}
|
|
200
|
-
const webchatHtmlPath = (0, import_path.join)(projectRoot, "dist", "webchat", "webchat.html");
|
|
201
|
-
const webchatIndexPath = (0, import_path.join)(projectRoot, "dist", "webchat", "index.html");
|
|
202
|
-
if ((0, import_file_system.pathExists)(webchatHtmlPath)) {
|
|
203
|
-
(0, import_fs.renameSync)(webchatHtmlPath, webchatIndexPath);
|
|
204
|
-
}
|
|
205
|
-
const webviewsHtmlPath = (0, import_path.join)(
|
|
206
|
-
projectRoot,
|
|
207
|
-
"dist",
|
|
208
|
-
"webviews",
|
|
209
|
-
"webviews.html"
|
|
210
|
-
);
|
|
211
|
-
const webviewsIndexPath = (0, import_path.join)(projectRoot, "dist", "webviews", "index.html");
|
|
212
|
-
if ((0, import_file_system.pathExists)(webviewsHtmlPath)) {
|
|
213
|
-
(0, import_fs.renameSync)(webviewsHtmlPath, webviewsIndexPath);
|
|
214
|
-
}
|
|
215
|
-
(0, import_file_system.createDir)((0, import_path.join)(projectRoot, BOTONIC_TEMP_DIRNAME));
|
|
216
|
-
(0, import_file_system.copy)(
|
|
217
|
-
(0, import_path.join)(projectRoot, "dist"),
|
|
218
|
-
(0, import_path.join)(projectRoot, BOTONIC_TEMP_DIRNAME, "dist")
|
|
219
|
-
);
|
|
220
|
-
const zipRes = await import_zip_a_folder.ZipAFolder.zip(
|
|
221
|
-
(0, import_path.join)(projectRoot, BOTONIC_TEMP_DIRNAME),
|
|
222
|
-
(0, import_path.join)(projectRoot, BOTONIC_BUNDLE_FILE)
|
|
223
|
-
);
|
|
224
|
-
if (zipRes instanceof Error) {
|
|
225
|
-
throw zipRes;
|
|
226
|
-
}
|
|
227
|
-
const zipStats = (0, import_fs.statSync)((0, import_path.join)(projectRoot, BOTONIC_BUNDLE_FILE));
|
|
228
|
-
console.log("\u2705 Bundle created successfully!");
|
|
229
|
-
if (zipStats.size >= 20 * 10 ** 6) {
|
|
230
|
-
throw new Error(
|
|
231
|
-
`Bundle too large: ${(zipStats.size / 1024 / 1024).toFixed(2)}MB (max: 20MB)`
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
async function deployBundle(botonicApiService, botConfigJson) {
|
|
236
|
-
console.log("\u{1F680} Deploying to Hubtype Cloud...");
|
|
237
|
-
try {
|
|
238
|
-
const deploy2 = await botonicApiService.deployBot(
|
|
239
|
-
(0, import_path.join)(PROJECT_ROOT, BOTONIC_BUNDLE_FILE),
|
|
240
|
-
botConfigJson
|
|
241
|
-
);
|
|
242
|
-
if (deploy2.response?.status === 403 || !deploy2.data.deploy_id) {
|
|
243
|
-
throw new Error(
|
|
244
|
-
`Deploy Botonic Error: ${String(deploy2.response?.data?.status)}`
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
console.log("\u23F3 Waiting for deployment to complete...");
|
|
248
|
-
while (true) {
|
|
249
|
-
await (0, import_system.sleep)(500);
|
|
250
|
-
const deployStatus = await botonicApiService.deployStatus(
|
|
251
|
-
deploy2.data.deploy_id
|
|
252
|
-
);
|
|
253
|
-
if (deployStatus.data.is_completed) {
|
|
254
|
-
if (deployStatus.data.status === "deploy_status_completed_ok") {
|
|
255
|
-
console.log("\u2705 Deployment completed successfully!");
|
|
256
|
-
return { hasDeployErrors: false };
|
|
257
|
-
} else {
|
|
258
|
-
throw new Error(deployStatus.data.error);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
} catch (error) {
|
|
263
|
-
console.error("\u274C Deployment failed");
|
|
264
|
-
let reason = String(error);
|
|
265
|
-
if (error.response?.data) {
|
|
266
|
-
reason = error.response.data.join("");
|
|
267
|
-
}
|
|
268
|
-
console.error(`${reason}`);
|
|
269
|
-
return { hasDeployErrors: true };
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
async function displayDeployResults(botonicApiService, { hasDeployErrors }) {
|
|
273
|
-
try {
|
|
274
|
-
const providersRes = await botonicApiService.getProviders();
|
|
275
|
-
const providers = providersRes.data.results;
|
|
276
|
-
if (hasDeployErrors) return false;
|
|
277
|
-
if (!providers.length) {
|
|
278
|
-
const botId = botonicApiService.botInfo().id;
|
|
279
|
-
const accessToken = botonicApiService.getOauth().access_token;
|
|
280
|
-
const links = `Now, you can integrate a channel in:
|
|
281
|
-
https://app.hubtype.com/bots/${botId}/integrations?access_token=${accessToken}`;
|
|
282
|
-
console.log(links);
|
|
283
|
-
} else {
|
|
284
|
-
displayProviders(providers);
|
|
285
|
-
}
|
|
286
|
-
return true;
|
|
287
|
-
} catch (e) {
|
|
288
|
-
console.error(` There was an error getting the providers: ${String(e)}`);
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function displayProviders(providers) {
|
|
293
|
-
console.log("\u{1F389} DEPLOYMENT SUCCESSFUL!");
|
|
294
|
-
console.log("\u{1F680} Your bot is now live and ready to chat!");
|
|
295
|
-
console.log("\u{1F4F1} Your bot is published on:");
|
|
296
|
-
providers.forEach((p) => {
|
|
297
|
-
if (p.provider === "whatsapp")
|
|
298
|
-
console.log(` \u{1F4AC} [WhatsApp] https://wa.me/${p.username}`);
|
|
299
|
-
if (p.provider === "facebook")
|
|
300
|
-
console.log(` \u{1F4AC} [Facebook] https://m.me/${p.username}`);
|
|
301
|
-
if (p.provider === "telegram")
|
|
302
|
-
console.log(` \u{1F4AC} [Telegram] https://t.me/${p.username}`);
|
|
303
|
-
if (p.provider === "twitter")
|
|
304
|
-
console.log(` \u{1F4AC} [Twitter] https://t.me/${p.username}`);
|
|
305
|
-
if (p.provider === "generic")
|
|
306
|
-
console.log(` \u{1F4AC} [Generic] Your app or website`);
|
|
307
|
-
});
|
|
308
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var schema_d_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(schema_d_exports);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { readFileSync, readdirSync } from 'fs'
|
|
2
|
-
import { resolve } from 'path'
|
|
3
|
-
|
|
4
|
-
// Build-only tools — never needed at Lambda runtime.
|
|
5
|
-
const BUILD_ONLY_DEPS = new Set(['tslib', 'vite', 'vitest'])
|
|
6
|
-
|
|
7
|
-
// Browser/UI-only packages pulled in by client-side @botonic/* packages
|
|
8
|
-
// (webchat-react, webchat-core). They are never imported by the server entry.
|
|
9
|
-
const BROWSER_ONLY_DEPS = new Set([
|
|
10
|
-
'react',
|
|
11
|
-
'react-dom',
|
|
12
|
-
'react-aria',
|
|
13
|
-
'@xstate/react',
|
|
14
|
-
'@lilara/foundations',
|
|
15
|
-
'@lilara/ui-web-react',
|
|
16
|
-
'class-variance-authority',
|
|
17
|
-
'react-markdown',
|
|
18
|
-
'rehype-external-links',
|
|
19
|
-
'remark-breaks',
|
|
20
|
-
'remark-gfm',
|
|
21
|
-
])
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Collects all third-party dependencies declared by the @botonic/* packages
|
|
25
|
-
* installed in this app's node_modules. The result is used in the Lambda node
|
|
26
|
-
* build's `ssr.noExternal` so that these packages are bundled into the artifact,
|
|
27
|
-
* where no node_modules are available at runtime.
|
|
28
|
-
*
|
|
29
|
-
* Deriving the list from the installed @botonic/* package.json files keeps it
|
|
30
|
-
* correct as plugins add new dependencies, instead of a hand-maintained array.
|
|
31
|
-
*/
|
|
32
|
-
export function getBotonicThirdPartyDeps(appRoot: string): string[] {
|
|
33
|
-
const botonicDir = resolve(appRoot, 'node_modules/@botonic')
|
|
34
|
-
const thirdParty = new Set<string>()
|
|
35
|
-
for (const name of readdirSync(botonicDir)) {
|
|
36
|
-
try {
|
|
37
|
-
const pkgPath = resolve(botonicDir, name, 'package.json')
|
|
38
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
|
|
39
|
-
for (const dep of Object.keys({
|
|
40
|
-
...pkg.dependencies,
|
|
41
|
-
...pkg.peerDependencies,
|
|
42
|
-
})) {
|
|
43
|
-
if (
|
|
44
|
-
!dep.startsWith('@botonic/') &&
|
|
45
|
-
!BUILD_ONLY_DEPS.has(dep) &&
|
|
46
|
-
!BROWSER_ONLY_DEPS.has(dep)
|
|
47
|
-
) {
|
|
48
|
-
thirdParty.add(dep)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} catch {
|
|
52
|
-
// skip packages without a readable package.json
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return [...thirdParty]
|
|
56
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite'
|
|
2
|
-
|
|
3
|
-
/** Split layout + iframe for serve-bot log viewer (?logs= port). Serve-only — never applied on build. */
|
|
4
|
-
const LAYOUT_STYLE = `
|
|
5
|
-
.dev-layout {
|
|
6
|
-
display: flex;
|
|
7
|
-
height: 100vh;
|
|
8
|
-
margin: 0;
|
|
9
|
-
padding: 0;
|
|
10
|
-
}
|
|
11
|
-
.dev-layout .logs-panel {
|
|
12
|
-
flex: 1;
|
|
13
|
-
border: none;
|
|
14
|
-
border-right: 1px solid #ddd;
|
|
15
|
-
}
|
|
16
|
-
.dev-layout .webchat-panel {
|
|
17
|
-
flex: 1;
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: center;
|
|
20
|
-
justify-content: center;
|
|
21
|
-
background: #f5f5f5;
|
|
22
|
-
}
|
|
23
|
-
`.trim()
|
|
24
|
-
|
|
25
|
-
/** Runs before the inline boot script so #webchat-root exists when render runs. */
|
|
26
|
-
const LAYOUT_SCRIPT = `
|
|
27
|
-
document.addEventListener('DOMContentLoaded', function botonicDevLogViewerLayout() {
|
|
28
|
-
var urlParams = new URLSearchParams(window.location.search)
|
|
29
|
-
var logsPort = urlParams.get('logs')
|
|
30
|
-
if (!logsPort) return
|
|
31
|
-
document.body.innerHTML = ''
|
|
32
|
-
document.body.className = 'dev-layout'
|
|
33
|
-
var logsIframe = document.createElement('iframe')
|
|
34
|
-
logsIframe.className = 'logs-panel'
|
|
35
|
-
logsIframe.src = 'http://localhost:' + logsPort
|
|
36
|
-
var webchatPanel = document.createElement('div')
|
|
37
|
-
webchatPanel.className = 'webchat-panel'
|
|
38
|
-
webchatPanel.id = 'webchat-root'
|
|
39
|
-
document.body.appendChild(logsIframe)
|
|
40
|
-
document.body.appendChild(webchatPanel)
|
|
41
|
-
})
|
|
42
|
-
`.trim()
|
|
43
|
-
|
|
44
|
-
export function devLogViewerIndexHtmlPlugin(): Plugin {
|
|
45
|
-
return {
|
|
46
|
-
name: 'botonic-dev-log-viewer-index-html',
|
|
47
|
-
apply: 'serve',
|
|
48
|
-
transformIndexHtml(html) {
|
|
49
|
-
const marker = '<script type="text/javascript">'
|
|
50
|
-
const pos = html.indexOf(marker)
|
|
51
|
-
if (pos === -1) {
|
|
52
|
-
return html
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const styleTag = `<style data-botonic-dev-log-viewer>${LAYOUT_STYLE}</style>`
|
|
56
|
-
const scriptTag = `<script>${LAYOUT_SCRIPT}</script>`
|
|
57
|
-
const withStyle = html.replace('</head>', `${styleTag}</head>`)
|
|
58
|
-
const pos2 = withStyle.indexOf(marker)
|
|
59
|
-
if (pos2 === -1) {
|
|
60
|
-
return html
|
|
61
|
-
}
|
|
62
|
-
return `${withStyle.slice(0, pos2)}${scriptTag}${withStyle.slice(pos2)}`
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= name %>",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "A Botonic workspace using NPM workspaces and TypeScript project references",
|
|
5
|
-
"private": true,
|
|
6
|
-
"workspaces": [
|
|
7
|
-
"packages/*",
|
|
8
|
-
"apps/*"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "nx run-many --target=build",
|
|
12
|
-
"test": "nx run-many --target=test",
|
|
13
|
-
"lint": "nx run-many --target=lint",
|
|
14
|
-
"typecheck": "nx run-many --target=typecheck"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@nx/js": "21.0.3",
|
|
18
|
-
"@swc-node/register": "~1.9.1",
|
|
19
|
-
"@swc/core": "~1.5.7",
|
|
20
|
-
"@swc/helpers": "~0.5.11",
|
|
21
|
-
"nx": "21.0.3",
|
|
22
|
-
"prettier": "^2.6.2",
|
|
23
|
-
"tslib": "^2.3.0",
|
|
24
|
-
"typescript": "~5.8.2"
|
|
25
|
-
}
|
|
26
|
-
}
|