@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
|
@@ -0,0 +1,119 @@
|
|
|
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 delegate_executor_exports = {};
|
|
20
|
+
__export(delegate_executor_exports, {
|
|
21
|
+
runLocalExecutor: () => runLocalExecutor
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(delegate_executor_exports);
|
|
24
|
+
var import_devkit = require("@nx/devkit");
|
|
25
|
+
var import_fs = require("fs");
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
const DEPTH_VAR = "BOTONIC_NX_PLUGIN_DELEGATION_DEPTH";
|
|
28
|
+
async function runLocalExecutor(wrapperFilename, executorName, options, ctx) {
|
|
29
|
+
const wrapperDir = (0, import_path.dirname)(wrapperFilename);
|
|
30
|
+
const implPath = (0, import_path.join)(wrapperDir, "executor-impl");
|
|
31
|
+
const impl = async () => {
|
|
32
|
+
const mod = await import(
|
|
33
|
+
/* @vite-ignore */
|
|
34
|
+
implPath
|
|
35
|
+
);
|
|
36
|
+
return (mod.default ?? mod)(options, ctx);
|
|
37
|
+
};
|
|
38
|
+
if (process.env[DEPTH_VAR]) return impl();
|
|
39
|
+
const projectRoot = ctx.projectName ? (0, import_path.join)(ctx.root, ctx.projectsConfigurations.projects[ctx.projectName].root) : ctx.root;
|
|
40
|
+
const myPkgJson = resolveSelfPkgJson(wrapperDir);
|
|
41
|
+
if (!myPkgJson) return impl();
|
|
42
|
+
const workspaceVersion = readVersion(myPkgJson);
|
|
43
|
+
let localPkgJson = null;
|
|
44
|
+
try {
|
|
45
|
+
localPkgJson = require.resolve("@botonic/nx-plugin/package.json", {
|
|
46
|
+
paths: [projectRoot]
|
|
47
|
+
});
|
|
48
|
+
} catch {
|
|
49
|
+
import_devkit.logger.info(
|
|
50
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running executor '${executorName}'`
|
|
51
|
+
);
|
|
52
|
+
return impl();
|
|
53
|
+
}
|
|
54
|
+
if ((0, import_fs.realpathSync)(localPkgJson) === (0, import_fs.realpathSync)(myPkgJson)) {
|
|
55
|
+
import_devkit.logger.info(
|
|
56
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running executor '${executorName}'`
|
|
57
|
+
);
|
|
58
|
+
return impl();
|
|
59
|
+
}
|
|
60
|
+
const localRoot = (0, import_path.dirname)(localPkgJson);
|
|
61
|
+
const execJsonPath = (0, import_path.join)(localRoot, "executors.json");
|
|
62
|
+
if (!(0, import_fs.existsSync)(execJsonPath)) {
|
|
63
|
+
import_devkit.logger.info(
|
|
64
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running executor '${executorName}'`
|
|
65
|
+
);
|
|
66
|
+
return impl();
|
|
67
|
+
}
|
|
68
|
+
const execJson = JSON.parse((0, import_fs.readFileSync)(execJsonPath, "utf-8"));
|
|
69
|
+
const entry = execJson?.executors?.[executorName];
|
|
70
|
+
if (!entry?.implementation) {
|
|
71
|
+
import_devkit.logger.info(
|
|
72
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running executor '${executorName}'`
|
|
73
|
+
);
|
|
74
|
+
return impl();
|
|
75
|
+
}
|
|
76
|
+
const implRelative = entry.implementation;
|
|
77
|
+
const implResolved = require.resolve((0, import_path.join)(localRoot, implRelative));
|
|
78
|
+
const localVersion = readVersion(localPkgJson);
|
|
79
|
+
import_devkit.logger.info(
|
|
80
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Delegating executor '${executorName}' to local v${localVersion}`
|
|
81
|
+
);
|
|
82
|
+
process.env[DEPTH_VAR] = "1";
|
|
83
|
+
try {
|
|
84
|
+
const mod = await import(
|
|
85
|
+
/* @vite-ignore */
|
|
86
|
+
implResolved
|
|
87
|
+
);
|
|
88
|
+
return await (mod.default ?? mod)(options, ctx);
|
|
89
|
+
} finally {
|
|
90
|
+
delete process.env[DEPTH_VAR];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function readVersion(pkgJsonPath) {
|
|
94
|
+
try {
|
|
95
|
+
return JSON.parse((0, import_fs.readFileSync)(pkgJsonPath, "utf-8")).version ?? "unknown";
|
|
96
|
+
} catch {
|
|
97
|
+
return "unknown";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function resolveSelfPkgJson(startDir) {
|
|
101
|
+
let dir = startDir;
|
|
102
|
+
while (true) {
|
|
103
|
+
const pkgPath = (0, import_path.join)(dir, "package.json");
|
|
104
|
+
if ((0, import_fs.existsSync)(pkgPath)) {
|
|
105
|
+
try {
|
|
106
|
+
const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf-8"));
|
|
107
|
+
if (pkg.name === "@botonic/nx-plugin") return pkgPath;
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const next = (0, import_path.dirname)(dir);
|
|
112
|
+
if (next === dir) return null;
|
|
113
|
+
dir = next;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
runLocalExecutor
|
|
119
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
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 delegate_generator_exports = {};
|
|
20
|
+
__export(delegate_generator_exports, {
|
|
21
|
+
runLocalGenerator: () => runLocalGenerator
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(delegate_generator_exports);
|
|
24
|
+
var import_devkit = require("@nx/devkit");
|
|
25
|
+
var import_fs = require("fs");
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
const DEPTH_VAR = "BOTONIC_NX_PLUGIN_DELEGATION_DEPTH";
|
|
28
|
+
async function runLocalGenerator(wrapperFilename, generatorName, tree, options) {
|
|
29
|
+
const wrapperDir = (0, import_path.dirname)(wrapperFilename);
|
|
30
|
+
const implPath = (0, import_path.join)(wrapperDir, "generator-impl");
|
|
31
|
+
const impl = async () => {
|
|
32
|
+
const mod = await import(
|
|
33
|
+
/* @vite-ignore */
|
|
34
|
+
implPath
|
|
35
|
+
);
|
|
36
|
+
return (mod.default ?? mod)(tree, options);
|
|
37
|
+
};
|
|
38
|
+
if (process.env[DEPTH_VAR]) return impl();
|
|
39
|
+
let projectRoot = null;
|
|
40
|
+
const projectName = options.project;
|
|
41
|
+
if (typeof projectName === "string") {
|
|
42
|
+
try {
|
|
43
|
+
const config = (0, import_devkit.readProjectConfiguration)(tree, projectName);
|
|
44
|
+
projectRoot = config.root;
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!projectRoot) return impl();
|
|
49
|
+
const myPkgJson = resolveSelfPkgJson(wrapperDir);
|
|
50
|
+
if (!myPkgJson) return impl();
|
|
51
|
+
const workspaceVersion = readVersion(myPkgJson);
|
|
52
|
+
let localPkgJson = null;
|
|
53
|
+
try {
|
|
54
|
+
localPkgJson = require.resolve("@botonic/nx-plugin/package.json", {
|
|
55
|
+
paths: [projectRoot]
|
|
56
|
+
});
|
|
57
|
+
} catch {
|
|
58
|
+
import_devkit.logger.info(
|
|
59
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running generator '${generatorName}'`
|
|
60
|
+
);
|
|
61
|
+
return impl();
|
|
62
|
+
}
|
|
63
|
+
if ((0, import_fs.realpathSync)(localPkgJson) === (0, import_fs.realpathSync)(myPkgJson)) {
|
|
64
|
+
import_devkit.logger.info(
|
|
65
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running generator '${generatorName}'`
|
|
66
|
+
);
|
|
67
|
+
return impl();
|
|
68
|
+
}
|
|
69
|
+
const localRoot = (0, import_path.dirname)(localPkgJson);
|
|
70
|
+
const genJsonPath = (0, import_path.join)(localRoot, "generators.json");
|
|
71
|
+
if (!(0, import_fs.existsSync)(genJsonPath)) {
|
|
72
|
+
import_devkit.logger.info(
|
|
73
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running generator '${generatorName}'`
|
|
74
|
+
);
|
|
75
|
+
return impl();
|
|
76
|
+
}
|
|
77
|
+
const genJson = JSON.parse((0, import_fs.readFileSync)(genJsonPath, "utf-8"));
|
|
78
|
+
const entry = genJson?.generators?.[generatorName];
|
|
79
|
+
if (!entry?.factory) {
|
|
80
|
+
import_devkit.logger.info(
|
|
81
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Running generator '${generatorName}'`
|
|
82
|
+
);
|
|
83
|
+
return impl();
|
|
84
|
+
}
|
|
85
|
+
const factoryRelative = entry.factory;
|
|
86
|
+
const factoryResolved = require.resolve((0, import_path.join)(localRoot, factoryRelative));
|
|
87
|
+
const localVersion = readVersion(localPkgJson);
|
|
88
|
+
import_devkit.logger.info(
|
|
89
|
+
`[@botonic/nx-plugin v${workspaceVersion}] Delegating generator '${generatorName}' to local v${localVersion}`
|
|
90
|
+
);
|
|
91
|
+
process.env[DEPTH_VAR] = "1";
|
|
92
|
+
try {
|
|
93
|
+
const mod = await import(
|
|
94
|
+
/* @vite-ignore */
|
|
95
|
+
factoryResolved
|
|
96
|
+
);
|
|
97
|
+
return await (mod.default ?? mod)(tree, options);
|
|
98
|
+
} finally {
|
|
99
|
+
delete process.env[DEPTH_VAR];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function readVersion(pkgJsonPath) {
|
|
103
|
+
try {
|
|
104
|
+
return JSON.parse((0, import_fs.readFileSync)(pkgJsonPath, "utf-8")).version ?? "unknown";
|
|
105
|
+
} catch {
|
|
106
|
+
return "unknown";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function resolveSelfPkgJson(startDir) {
|
|
110
|
+
let dir = startDir;
|
|
111
|
+
while (true) {
|
|
112
|
+
const pkgPath = (0, import_path.join)(dir, "package.json");
|
|
113
|
+
if ((0, import_fs.existsSync)(pkgPath)) {
|
|
114
|
+
try {
|
|
115
|
+
const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf-8"));
|
|
116
|
+
if (pkg.name === "@botonic/nx-plugin") return pkgPath;
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const next = (0, import_path.dirname)(dir);
|
|
121
|
+
if (next === dir) return null;
|
|
122
|
+
dir = next;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
runLocalGenerator
|
|
128
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
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 serve_mode_exports = {};
|
|
20
|
+
__export(serve_mode_exports, {
|
|
21
|
+
createDevPanelsPlugin: () => createDevPanelsPlugin,
|
|
22
|
+
createLogViewerPlugin: () => createLogViewerPlugin,
|
|
23
|
+
createWebchatPanelPlugin: () => createWebchatPanelPlugin,
|
|
24
|
+
createWhatsappPanelPlugin: () => createWhatsappPanelPlugin
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(serve_mode_exports);
|
|
27
|
+
var import_child_process = require("child_process");
|
|
28
|
+
var import_fs = require("fs");
|
|
29
|
+
var import_path = require("path");
|
|
30
|
+
function resolveServeModePaths() {
|
|
31
|
+
const root = (0, import_path.resolve)(__dirname, "../../../serve-mode");
|
|
32
|
+
if ((0, import_fs.existsSync)((0, import_path.join)(root, "vite.config.ts"))) {
|
|
33
|
+
return { root, bundle: (0, import_path.join)(root, "dist/serve-mode.js"), canBuild: true };
|
|
34
|
+
}
|
|
35
|
+
const bundle = (0, import_path.join)(root, "serve-mode.js");
|
|
36
|
+
return { root: (0, import_path.dirname)(bundle), bundle, canBuild: false };
|
|
37
|
+
}
|
|
38
|
+
const PATHS = resolveServeModePaths();
|
|
39
|
+
const BUNDLE_ROUTE = "/__serve-mode/bundle.js";
|
|
40
|
+
const BUNDLE_SCRIPT_MARKER = "data-botonic-serve-mode";
|
|
41
|
+
const FACTORY_PATH = __filename;
|
|
42
|
+
async function ensureBundleBuilt() {
|
|
43
|
+
if (!PATHS.canBuild) return;
|
|
44
|
+
if ((0, import_fs.existsSync)(PATHS.bundle)) {
|
|
45
|
+
const bundleMtime = (0, import_fs.statSync)(PATHS.bundle).mtimeMs;
|
|
46
|
+
const viteConfigPath = (0, import_path.join)(PATHS.root, "vite.config.ts");
|
|
47
|
+
const configMtime = (0, import_fs.existsSync)(viteConfigPath) ? (0, import_fs.statSync)(viteConfigPath).mtimeMs : 0;
|
|
48
|
+
const factoryMtime = (0, import_fs.existsSync)(FACTORY_PATH) ? (0, import_fs.statSync)(FACTORY_PATH).mtimeMs : 0;
|
|
49
|
+
const srcDir = (0, import_path.join)(PATHS.root, "src");
|
|
50
|
+
if (configMtime <= bundleMtime && factoryMtime <= bundleMtime && !isSrcNewerThan(srcDir, bundleMtime))
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
(0, import_child_process.execSync)(
|
|
55
|
+
`node_modules/.bin/vite build --config ${PATHS.root}/vite.config.ts --mode production`,
|
|
56
|
+
{
|
|
57
|
+
cwd: process.cwd(),
|
|
58
|
+
stdio: "inherit",
|
|
59
|
+
env: { ...process.env, NODE_ENV: "production" }
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.warn(
|
|
64
|
+
"[botonic-serve-mode] Failed to build panel bundle \u2014 panels will not be injected.",
|
|
65
|
+
e
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function isSrcNewerThan(dir, bundleMtime) {
|
|
70
|
+
try {
|
|
71
|
+
const { readdirSync } = require("fs");
|
|
72
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
73
|
+
const full = (0, import_path.resolve)(dir, entry.name);
|
|
74
|
+
if (entry.isDirectory()) {
|
|
75
|
+
if (isSrcNewerThan(full, bundleMtime)) return true;
|
|
76
|
+
} else if ((0, import_fs.statSync)(full).mtimeMs > bundleMtime) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} catch {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
function registerBundleMiddleware(server) {
|
|
86
|
+
const stack = server.middlewares.stack;
|
|
87
|
+
const already = stack.some(
|
|
88
|
+
(layer) => typeof layer.route === "string" && layer.route === BUNDLE_ROUTE
|
|
89
|
+
);
|
|
90
|
+
if (already) return;
|
|
91
|
+
server.middlewares.use(BUNDLE_ROUTE, (_req, res) => {
|
|
92
|
+
if (!(0, import_fs.existsSync)(PATHS.bundle)) {
|
|
93
|
+
res.statusCode = 404;
|
|
94
|
+
res.end("Dev panels bundle not found");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
res.setHeader("Content-Type", "application/javascript");
|
|
98
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
99
|
+
res.end((0, import_fs.readFileSync)(PATHS.bundle));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function injectConfigScript(html, configJson) {
|
|
103
|
+
const configScript = `<script>window.__BOTONIC_DEV__=Object.assign(window.__BOTONIC_DEV__||{},${configJson});</script>`;
|
|
104
|
+
return html.replace("</body>", `${configScript}</body>`);
|
|
105
|
+
}
|
|
106
|
+
function injectBundleScript(html) {
|
|
107
|
+
if (html.includes(BUNDLE_SCRIPT_MARKER)) return html;
|
|
108
|
+
const bundleScript = `<script ${BUNDLE_SCRIPT_MARKER} defer src="${BUNDLE_ROUTE}"></script>`;
|
|
109
|
+
return html.replace("</body>", `${bundleScript}</body>`);
|
|
110
|
+
}
|
|
111
|
+
function credentialsFromEnv(overrides = {}) {
|
|
112
|
+
return {
|
|
113
|
+
botId: overrides.botId ?? process.env.VITE_DEV_BOT_ID ?? "",
|
|
114
|
+
apiUrl: overrides.apiUrl ?? process.env.VITE_DEV_API_URL ?? "https://api.hubtype.com",
|
|
115
|
+
tunnelUrl: overrides.tunnelUrl ?? process.env.VITE_DEV_SESSION_URL ?? "",
|
|
116
|
+
lambdaFn: overrides.lambdaFn ?? process.env.VITE_DEV_LAMBDA_FUNCTION_NAME ?? "BotonicV2LocalLambda",
|
|
117
|
+
accessToken: overrides.accessToken ?? process.env.VITE_DEV_ACCESS_TOKEN ?? "",
|
|
118
|
+
refreshToken: overrides.refreshToken ?? process.env.VITE_DEV_REFRESH_TOKEN ?? "",
|
|
119
|
+
clientId: overrides.clientId ?? process.env.VITE_DEV_CLIENT_ID ?? ""
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function createWhatsappPanelPlugin(opts = {}) {
|
|
123
|
+
return {
|
|
124
|
+
name: "botonic-serve-mode-whatsapp",
|
|
125
|
+
apply: "serve",
|
|
126
|
+
async configureServer(server) {
|
|
127
|
+
await ensureBundleBuilt();
|
|
128
|
+
registerBundleMiddleware(server);
|
|
129
|
+
},
|
|
130
|
+
transformIndexHtml(html) {
|
|
131
|
+
if (!process.env["BOT_HAS_WHATSAPP"]) return html;
|
|
132
|
+
const config = JSON.stringify({
|
|
133
|
+
whatsapp: {
|
|
134
|
+
...credentialsFromEnv(opts),
|
|
135
|
+
registeredPhone: opts.registeredPhone ?? ""
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return injectBundleScript(injectConfigScript(html, config));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function createWebchatPanelPlugin(opts = {}) {
|
|
143
|
+
return {
|
|
144
|
+
name: "botonic-serve-mode-webchat",
|
|
145
|
+
apply: "serve",
|
|
146
|
+
async configureServer(server) {
|
|
147
|
+
await ensureBundleBuilt();
|
|
148
|
+
registerBundleMiddleware(server);
|
|
149
|
+
},
|
|
150
|
+
transformIndexHtml(html) {
|
|
151
|
+
const config = JSON.stringify({ webchat: credentialsFromEnv(opts) });
|
|
152
|
+
return injectBundleScript(injectConfigScript(html, config));
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function createLogViewerPlugin() {
|
|
157
|
+
return {
|
|
158
|
+
name: "botonic-serve-mode-log-viewer",
|
|
159
|
+
apply: "serve",
|
|
160
|
+
async configureServer(server) {
|
|
161
|
+
await ensureBundleBuilt();
|
|
162
|
+
registerBundleMiddleware(server);
|
|
163
|
+
},
|
|
164
|
+
transformIndexHtml(html) {
|
|
165
|
+
const config = JSON.stringify({ logViewer: true });
|
|
166
|
+
return injectBundleScript(injectConfigScript(html, config));
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function createDevPanelsPlugin(opts) {
|
|
171
|
+
const plugins = [];
|
|
172
|
+
if (opts.panels.includes("whatsapp"))
|
|
173
|
+
plugins.push(createWhatsappPanelPlugin(opts));
|
|
174
|
+
if (opts.panels.includes("webchat")) plugins.push(createWebchatPanelPlugin());
|
|
175
|
+
return plugins;
|
|
176
|
+
}
|
|
177
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
178
|
+
0 && (module.exports = {
|
|
179
|
+
createDevPanelsPlugin,
|
|
180
|
+
createLogViewerPlugin,
|
|
181
|
+
createWebchatPanelPlugin,
|
|
182
|
+
createWhatsappPanelPlugin
|
|
183
|
+
});
|