@botonic/nx-plugin 2.30.0 → 2.31.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 +13 -0
- package/executors.json +0 -5
- package/package.json +1 -1
- package/src/executors/delete-bot/executor.js +0 -2
- package/src/executors/deploy-to-hubtype/executor.js +24 -160
- package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +7 -11
- package/src/executors/integrate-provider/executor.js +0 -2
- package/src/executors/login-to-hubtype/executor.js +0 -2
- package/src/executors/logout-from-hubtype/executor.js +2 -2
- package/src/executors/serve-bot/executor.js +142 -24
- package/src/executors/serve-bot/schema.json +13 -5
- package/src/generators/bot-app/files/vite/node.config.ts.template +2 -7
- package/src/lib/api-service.d.ts +19 -20
- package/src/lib/api-service.js +150 -82
- package/src/lib/constants.d.ts +2 -3
- package/src/lib/constants.js +6 -9
- package/src/lib/credentials-handler.d.ts +9 -18
- package/src/lib/credentials-handler.js +42 -24
- package/src/lib/interfaces.d.ts +10 -13
- package/src/lib/util/executor-helpers.d.ts +52 -23
- package/src/lib/util/executor-helpers.js +494 -106
- package/src/plugin.js +5 -14
- 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.d.js +0 -16
- package/src/executors/deploy-local-runtime/schema.json +0 -34
- package/src/generators/bot-app/files/vite/botonic-ssr-deps.ts.template +0 -56
- package/src/generators/preset/files/package.json +0 -26
package/src/plugin.js
CHANGED
|
@@ -140,34 +140,29 @@ async function createBotonicTargets(projectRoot, options, context) {
|
|
|
140
140
|
targets[options.serveTargetName] = {
|
|
141
141
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
142
142
|
options: {},
|
|
143
|
-
configurations
|
|
144
|
-
continuous: true
|
|
143
|
+
configurations
|
|
145
144
|
};
|
|
146
145
|
targets["serve:webchat"] = {
|
|
147
146
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
148
147
|
options: {
|
|
149
148
|
skipWebviews: true
|
|
150
149
|
},
|
|
151
|
-
configurations
|
|
152
|
-
continuous: true
|
|
150
|
+
configurations
|
|
153
151
|
};
|
|
154
152
|
targets["serve:webview"] = {
|
|
155
153
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
156
154
|
options: {},
|
|
157
|
-
configurations
|
|
158
|
-
continuous: true
|
|
155
|
+
configurations
|
|
159
156
|
};
|
|
160
157
|
targets["serve-dev"] = {
|
|
161
158
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
162
159
|
options: {},
|
|
163
|
-
configurations
|
|
164
|
-
continuous: true
|
|
160
|
+
configurations
|
|
165
161
|
};
|
|
166
162
|
targets["serve-dev-tunnel"] = {
|
|
167
163
|
executor: "@botonic/nx-plugin:serve-bot",
|
|
168
164
|
options: {},
|
|
169
|
-
configurations
|
|
170
|
-
continuous: true
|
|
165
|
+
configurations
|
|
171
166
|
};
|
|
172
167
|
targets["build-node-app"] = {
|
|
173
168
|
executor: "nx:run-commands",
|
|
@@ -213,10 +208,6 @@ async function createBotonicTargets(projectRoot, options, context) {
|
|
|
213
208
|
executor: "@botonic/nx-plugin:deploy-to-hubtype",
|
|
214
209
|
configurations
|
|
215
210
|
};
|
|
216
|
-
targets["deploy-local-runtime"] = {
|
|
217
|
-
executor: "@botonic/nx-plugin:deploy-local-runtime",
|
|
218
|
-
configurations
|
|
219
|
-
};
|
|
220
211
|
targets["integrate-provider"] = {
|
|
221
212
|
executor: "@botonic/nx-plugin:integrate-provider",
|
|
222
213
|
configurations
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import type { DeployLocalRuntimeExecutorSchema } from './schema';
|
|
3
|
-
export default function deployLocalRuntimeExecutor(options: DeployLocalRuntimeExecutorSchema, context: ExecutorContext): Promise<{
|
|
4
|
-
success: boolean;
|
|
5
|
-
}>;
|
|
@@ -1,148 +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
|
-
// 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 executor_exports = {};
|
|
30
|
-
__export(executor_exports, {
|
|
31
|
-
default: () => deployLocalRuntimeExecutor
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(executor_exports);
|
|
34
|
-
var import_enquirer = require("enquirer");
|
|
35
|
-
var fs = __toESM(require("fs"));
|
|
36
|
-
var path = __toESM(require("path"));
|
|
37
|
-
var import_lib = require("../../lib");
|
|
38
|
-
var import_api_service = require("../../lib/api-service");
|
|
39
|
-
var import_executor_helpers = require("../../lib/util/executor-helpers");
|
|
40
|
-
async function deployLocalRuntimeExecutor(options, context) {
|
|
41
|
-
const projectRoot = (0, import_executor_helpers.resolveProjectPath)(context);
|
|
42
|
-
try {
|
|
43
|
-
const { targetEnvironment, environmentVariables } = (0, import_executor_helpers.resolveHubtypeEnvironment)(context, options);
|
|
44
|
-
const botonicApiService = new import_api_service.BotonicAPIService({
|
|
45
|
-
isLocalRuntimeDeployment: true,
|
|
46
|
-
projectRoot,
|
|
47
|
-
workspaceRoot: path.resolve(context.root),
|
|
48
|
-
environmentVariables,
|
|
49
|
-
targetEnvironment
|
|
50
|
-
});
|
|
51
|
-
if (!botonicApiService.oauth) {
|
|
52
|
-
if (options.email && options.password) {
|
|
53
|
-
await botonicApiService.login(options.email, options.password);
|
|
54
|
-
botonicApiService.saveAllCredentials();
|
|
55
|
-
} else {
|
|
56
|
-
await (0, import_executor_helpers.handleAuthentication)(botonicApiService);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
await (0, import_executor_helpers.logWorkingAsAndEnvironment)(botonicApiService);
|
|
60
|
-
console.log(
|
|
61
|
-
`\u{1F680} Deploying to Hubtype Local Runtime...[${environmentVariables["VITE_HUBTYPE_API_URL"]}]
|
|
62
|
-
`
|
|
63
|
-
);
|
|
64
|
-
await (0, import_executor_helpers.ensureLocalRuntimeBot)(botonicApiService);
|
|
65
|
-
const lambdaFunctionName = options.lambdaFunctionName || environmentVariables["VITE_HUBTYPE_LAMBDA_FUNCTION_NAME"];
|
|
66
|
-
const lambdaEndpoint = options.lambdaEndpoint || environmentVariables["VITE_HUBTYPE_LOCAL_LAMBDA_ENDPOINT"];
|
|
67
|
-
await deployLocalRuntime(botonicApiService, projectRoot, {
|
|
68
|
-
lambdaFunctionName,
|
|
69
|
-
lambdaEndpoint
|
|
70
|
-
});
|
|
71
|
-
return { success: true };
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return (0, import_executor_helpers.handleExecutorError)(error, "Local runtime deployment");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function updateEnvLocal(projectRoot, appId) {
|
|
77
|
-
const envLocalPath = path.join(projectRoot, ".env.local");
|
|
78
|
-
const envKey = "VITE_HUBTYPE_APP_ID";
|
|
79
|
-
try {
|
|
80
|
-
if (fs.existsSync(envLocalPath)) {
|
|
81
|
-
let content = fs.readFileSync(envLocalPath, "utf-8");
|
|
82
|
-
const regex = new RegExp(`^${envKey}=.*$`, "m");
|
|
83
|
-
if (regex.test(content)) {
|
|
84
|
-
content = content.replace(regex, `${envKey}=${appId}`);
|
|
85
|
-
console.log(`\u{1F4DD} Updated ${envKey} in .env.local`);
|
|
86
|
-
} else {
|
|
87
|
-
content = content.trimEnd() + `
|
|
88
|
-
${envKey}=${appId}
|
|
89
|
-
`;
|
|
90
|
-
console.log(`\u{1F4DD} Added ${envKey} to .env.local`);
|
|
91
|
-
}
|
|
92
|
-
fs.writeFileSync(envLocalPath, content);
|
|
93
|
-
} else {
|
|
94
|
-
const content = `# HUBTYPE
|
|
95
|
-
${envKey}=${appId}
|
|
96
|
-
`;
|
|
97
|
-
fs.writeFileSync(envLocalPath, content);
|
|
98
|
-
console.log(`\u{1F4DD} Created .env.local with ${envKey}`);
|
|
99
|
-
}
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.warn(`\u26A0\uFE0F Could not update .env.local: ${error}`);
|
|
102
|
-
console.log(`\u{1F194} Manually add to .env.local: ${envKey}=${appId}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async function deployLocalRuntime(botonicApiService, projectRoot, params) {
|
|
106
|
-
console.log("\u{1F528} Generating bot config for local runtime deployment...\n");
|
|
107
|
-
const botConfigJson = await import_lib.BotConfig.get(projectRoot);
|
|
108
|
-
let { lambdaEndpoint } = params;
|
|
109
|
-
if (!lambdaEndpoint) {
|
|
110
|
-
const response = await (0, import_enquirer.prompt)({
|
|
111
|
-
type: "input",
|
|
112
|
-
name: "lambda_endpoint",
|
|
113
|
-
message: "\u{1F310} Local runtime URL (e.g. http://localhost:3001):",
|
|
114
|
-
validate: (input) => {
|
|
115
|
-
try {
|
|
116
|
-
new URL(input);
|
|
117
|
-
return true;
|
|
118
|
-
} catch {
|
|
119
|
-
return "Please enter a valid URL";
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
lambdaEndpoint = response.lambda_endpoint;
|
|
124
|
-
}
|
|
125
|
-
console.log("\u{1F680} Deploying to Hubtype Local Runtime...");
|
|
126
|
-
try {
|
|
127
|
-
await botonicApiService.deployLocalRuntime({
|
|
128
|
-
botConfigJson,
|
|
129
|
-
lambdaFunctionName: params.lambdaFunctionName,
|
|
130
|
-
lambdaEndpoint
|
|
131
|
-
});
|
|
132
|
-
const allProviders = await botonicApiService.getProviders();
|
|
133
|
-
const appId = (0, import_executor_helpers.getActiveTestWebchatProviderAppId)(allProviders.data?.results);
|
|
134
|
-
if (!appId) {
|
|
135
|
-
console.error(
|
|
136
|
-
"\u274C No active test webchat provider found. Local runtime needs a webchat test provider on this bot."
|
|
137
|
-
);
|
|
138
|
-
} else {
|
|
139
|
-
console.log("\u2705 Local runtime deployment completed!");
|
|
140
|
-
updateEnvLocal(projectRoot, appId);
|
|
141
|
-
console.log(`\u{1F194} APP_ID: ${appId}`);
|
|
142
|
-
}
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error("\u274C Local runtime deployment failed");
|
|
145
|
-
console.error(`${String(error)}`);
|
|
146
|
-
}
|
|
147
|
-
botonicApiService.saveAllCredentials();
|
|
148
|
-
}
|
|
@@ -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,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "DeployLocalRuntimeExecutor",
|
|
4
|
-
"title": "Deploy to Hubtype Local Runtime executor",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"configuration": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"enum": ["local"],
|
|
10
|
-
"description": "Environment to deploy to"
|
|
11
|
-
},
|
|
12
|
-
"command": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"description": "Command to execute from the package scripts object"
|
|
15
|
-
},
|
|
16
|
-
"email": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "Email from Hubtype Organization"
|
|
19
|
-
},
|
|
20
|
-
"password": {
|
|
21
|
-
"type": "string",
|
|
22
|
-
"description": "Password from Hubtype Organization"
|
|
23
|
-
},
|
|
24
|
-
"lambdaFunctionName": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"description": "Name of the Lambda function for the local runtime. Falls back to VITE_HUBTYPE_LAMBDA_FUNCTION_NAME or prompts if missing."
|
|
27
|
-
},
|
|
28
|
-
"lambdaEndpoint": {
|
|
29
|
-
"type": "string",
|
|
30
|
-
"description": "URL where the local runtime is reachable (e.g. http://localhost:3001). Falls back to VITE_HUBTYPE_LOCAL_LAMBDA_ENDPOINT env or prompts if missing."
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"additionalProperties": false
|
|
34
|
-
}
|
|
@@ -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,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
|
-
}
|