@botonic/nx-plugin 2.23.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 +420 -0
- package/README.md +279 -0
- package/executors.json +55 -0
- package/generators.json +61 -0
- package/migrations.json +40 -0
- package/package.json +54 -0
- package/src/cursor-commands/update-bot.md +114 -0
- package/src/cursor-commands/update-botonic.md +63 -0
- package/src/executors/build-node-app/executor.d.ts +5 -0
- package/src/executors/build-node-app/executor.js +65 -0
- package/src/executors/build-node-app/schema.d.js +16 -0
- package/src/executors/build-node-app/schema.json +25 -0
- package/src/executors/delete-bot/executor.d.ts +5 -0
- package/src/executors/delete-bot/executor.js +112 -0
- package/src/executors/delete-bot/schema.d.js +16 -0
- package/src/executors/delete-bot/schema.json +35 -0
- package/src/executors/deploy-local-runtime/executor.d.ts +5 -0
- package/src/executors/deploy-local-runtime/executor.js +144 -0
- package/src/executors/deploy-local-runtime/schema.d.js +16 -0
- package/src/executors/deploy-local-runtime/schema.json +34 -0
- package/src/executors/deploy-netlify-snapshot/executor.d.ts +8 -0
- package/src/executors/deploy-netlify-snapshot/executor.js +79 -0
- package/src/executors/deploy-netlify-snapshot/schema.d.js +16 -0
- package/src/executors/deploy-netlify-snapshot/schema.json +31 -0
- package/src/executors/deploy-to-hubtype/executor.d.ts +5 -0
- package/src/executors/deploy-to-hubtype/executor.js +308 -0
- package/src/executors/deploy-to-hubtype/schema.d.js +16 -0
- package/src/executors/deploy-to-hubtype/schema.json +31 -0
- package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +84 -0
- package/src/executors/e2e-webchat/executor.d.ts +5 -0
- package/src/executors/e2e-webchat/executor.js +134 -0
- package/src/executors/e2e-webchat/schema.d.js +16 -0
- package/src/executors/e2e-webchat/schema.json +35 -0
- package/src/executors/integrate-provider/executor.d.ts +5 -0
- package/src/executors/integrate-provider/executor.js +155 -0
- package/src/executors/integrate-provider/schema.d.js +16 -0
- package/src/executors/integrate-provider/schema.json +30 -0
- package/src/executors/login-to-hubtype/executor.d.ts +5 -0
- package/src/executors/login-to-hubtype/executor.js +79 -0
- package/src/executors/login-to-hubtype/schema.d.js +16 -0
- package/src/executors/login-to-hubtype/schema.json +25 -0
- package/src/executors/logout-from-hubtype/executor.d.ts +3 -0
- package/src/executors/logout-from-hubtype/executor.js +54 -0
- package/src/executors/logout-from-hubtype/schema.d.js +16 -0
- package/src/executors/logout-from-hubtype/schema.json +9 -0
- package/src/executors/run-lambda/executor.d.ts +5 -0
- package/src/executors/run-lambda/executor.js +65 -0
- package/src/executors/run-lambda/schema.d.js +16 -0
- package/src/executors/run-lambda/schema.json +20 -0
- package/src/executors/serve-bot/executor.d.ts +5 -0
- package/src/executors/serve-bot/executor.js +330 -0
- package/src/executors/serve-bot/schema.d.js +16 -0
- package/src/executors/serve-bot/schema.json +40 -0
- package/src/generators/action/files/__name__.spec.ts.template +15 -0
- package/src/generators/action/files/__name__.ts.template +15 -0
- package/src/generators/action/generator.d.ts +4 -0
- package/src/generators/action/generator.js +112 -0
- package/src/generators/action/schema.d.ts +7 -0
- package/src/generators/action/schema.js +16 -0
- package/src/generators/action/schema.json +43 -0
- package/src/generators/bot-app/files/.eslintrc.json.template +18 -0
- package/src/generators/bot-app/files/README.md.template +148 -0
- package/src/generators/bot-app/files/src/client/custom-messages/index.ts.template +2 -0
- package/src/generators/bot-app/files/src/client/webchat/index.html.template +35 -0
- package/src/generators/bot-app/files/src/client/webchat/index.tsx.template +107 -0
- package/src/generators/bot-app/files/src/client/webchat/styles.css.template +17 -0
- package/src/generators/bot-app/files/src/client/webchat/webchat-tokens-overrides.css.template +2 -0
- package/src/generators/bot-app/files/src/client/webviews/app.tsx.template +8 -0
- package/src/generators/bot-app/files/src/client/webviews/index.html.template +32 -0
- package/src/generators/bot-app/files/src/client/webviews/index.tsx.template +18 -0
- package/src/generators/bot-app/files/src/server/bot/actions/index.ts.template +2 -0
- package/src/generators/bot-app/files/src/server/bot/actions/not-found.ts.template +13 -0
- package/src/generators/bot-app/files/src/server/bot/actions/welcome.ts.template +13 -0
- package/src/generators/bot-app/files/src/server/bot/index.ts.template +43 -0
- package/src/generators/bot-app/files/src/server/bot/plugins/ai-agents/index.ts.template +30 -0
- package/src/generators/bot-app/files/src/server/bot/plugins/flow-builder/index.ts.template +28 -0
- package/src/generators/bot-app/files/src/server/bot/plugins/index.ts.template +11 -0
- package/src/generators/bot-app/files/src/server/bot/routes.ts.template +23 -0
- package/src/generators/bot-app/files/src/server/bot/tools/index.ts.template +5 -0
- package/src/generators/bot-app/files/src/server/bot/tracking.ts.template +35 -0
- package/src/generators/bot-app/files/src/server/bot/types.ts.template +4 -0
- package/src/generators/bot-app/files/src/server/bot/utils.ts.template +9 -0
- package/src/generators/bot-app/files/src/server/lambda/handler.js.template +24 -0
- package/src/generators/bot-app/files/src/server/lambda/package.json +20 -0
- package/src/generators/bot-app/files/src/server/lambda/template.yaml.template +20 -0
- package/src/generators/bot-app/files/src/shared/constants.ts.template +12 -0
- package/src/generators/bot-app/files/vite/base-client.config.ts.template +14 -0
- package/src/generators/bot-app/files/vite/base.config.ts.template +20 -0
- package/src/generators/bot-app/files/vite/build.config.ts.template +65 -0
- package/src/generators/bot-app/files/vite/node.config.ts.template +41 -0
- package/src/generators/bot-app/files/vite/plugins/move-html.plugin.ts.template +36 -0
- package/src/generators/bot-app/files/vite/webchat.config.ts.template +58 -0
- package/src/generators/bot-app/files/vite/webviews.config.ts.template +57 -0
- package/src/generators/bot-app/files/vite.config.ts.template +36 -0
- package/src/generators/bot-app/generator.d.ts +4 -0
- package/src/generators/bot-app/generator.js +294 -0
- package/src/generators/bot-app/schema.d.ts +6 -0
- package/src/generators/bot-app/schema.js +16 -0
- package/src/generators/bot-app/schema.json +36 -0
- package/src/generators/bot-app-migrations/migrate-fix-css-code-split/generator.d.ts +5 -0
- package/src/generators/bot-app-migrations/migrate-fix-css-code-split/generator.js +92 -0
- package/src/generators/bot-app-migrations/migrate-fix-css-code-split/schema.json +15 -0
- package/src/generators/bot-app-migrations/migrate-pnpm-compat/generator.d.ts +5 -0
- package/src/generators/bot-app-migrations/migrate-pnpm-compat/generator.js +97 -0
- package/src/generators/bot-app-migrations/migrate-pnpm-compat/schema.json +15 -0
- package/src/generators/bot-app-migrations/migrate-webchat-trigger/generator.d.ts +5 -0
- package/src/generators/bot-app-migrations/migrate-webchat-trigger/generator.js +165 -0
- package/src/generators/bot-app-migrations/migrate-webchat-trigger/schema.json +15 -0
- package/src/generators/custom-message/files/__name__-output.ts.template +21 -0
- package/src/generators/custom-message/files/__name__.spec.tsx.template +27 -0
- package/src/generators/custom-message/files/__name__.tsx.template +18 -0
- package/src/generators/custom-message/generator.d.ts +4 -0
- package/src/generators/custom-message/generator.js +235 -0
- package/src/generators/custom-message/schema.d.ts +7 -0
- package/src/generators/custom-message/schema.js +16 -0
- package/src/generators/custom-message/schema.json +44 -0
- package/src/generators/preset/files/.cursor/commands/update-bot.md +5 -0
- package/src/generators/preset/files/.cursor/commands/update-botonic.md +5 -0
- package/src/generators/preset/files/.cursor/scripts/update-bot/discover-bots.sh +67 -0
- package/src/generators/preset/files/.cursor/scripts/update-bot/find-migration-guides.sh +70 -0
- package/src/generators/preset/files/.cursor/skills/botonic-action/SKILL.md +167 -0
- package/src/generators/preset/files/.cursor/skills/botonic-custom-message/SKILL.md +231 -0
- package/src/generators/preset/files/.cursor/skills/botonic-webview/SKILL.md +179 -0
- package/src/generators/preset/files/.env.prod.template +2 -0
- package/src/generators/preset/files/.env.template +2 -0
- package/src/generators/preset/files/.npmrc.template +1 -0
- package/src/generators/preset/files/README.md.template +174 -0
- package/src/generators/preset/files/nx.json +66 -0
- package/src/generators/preset/files/package.json +26 -0
- package/src/generators/preset/files/tsconfig.base.json +27 -0
- package/src/generators/preset/files/tsconfig.base.json.template +27 -0
- package/src/generators/preset/files/tsconfig.json +9 -0
- package/src/generators/preset/generator.d.ts +4 -0
- package/src/generators/preset/generator.js +127 -0
- package/src/generators/preset/schema.d.ts +6 -0
- package/src/generators/preset/schema.js +16 -0
- package/src/generators/preset/schema.json +50 -0
- package/src/generators/remove-custom-message/generator.d.ts +4 -0
- package/src/generators/remove-custom-message/generator.js +259 -0
- package/src/generators/remove-custom-message/schema.d.ts +6 -0
- package/src/generators/remove-custom-message/schema.js +16 -0
- package/src/generators/remove-custom-message/schema.json +39 -0
- package/src/generators/shared/bot-app-utils.d.ts +25 -0
- package/src/generators/shared/bot-app-utils.js +209 -0
- package/src/generators/webview/files/__name__.spec.tsx.template +20 -0
- package/src/generators/webview/files/__name__.tsx.template +19 -0
- package/src/generators/webview/generator.d.ts +4 -0
- package/src/generators/webview/generator.js +179 -0
- package/src/generators/webview/schema.d.ts +5 -0
- package/src/generators/webview/schema.js +16 -0
- package/src/generators/webview/schema.json +34 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +56 -0
- package/src/lib/api-service.d.ts +110 -0
- package/src/lib/api-service.js +591 -0
- package/src/lib/bot-config.d.ts +30 -0
- package/src/lib/bot-config.js +203 -0
- package/src/lib/cloudflared-tunnel.d.ts +29 -0
- package/src/lib/cloudflared-tunnel.js +95 -0
- package/src/lib/constants.d.ts +13 -0
- package/src/lib/constants.js +60 -0
- package/src/lib/credentials-handler.d.ts +40 -0
- package/src/lib/credentials-handler.js +115 -0
- package/src/lib/index.d.ts +10 -0
- package/src/lib/index.js +47 -0
- package/src/lib/interfaces.d.ts +49 -0
- package/src/lib/interfaces.js +16 -0
- package/src/lib/util/executor-helpers.d.ts +97 -0
- package/src/lib/util/executor-helpers.js +574 -0
- package/src/lib/util/file-system.d.ts +8 -0
- package/src/lib/util/file-system.js +65 -0
- package/src/lib/util/sam-container-cleanup.d.ts +11 -0
- package/src/lib/util/sam-container-cleanup.js +55 -0
- package/src/lib/util/sam-template.d.ts +9 -0
- package/src/lib/util/sam-template.js +71 -0
- package/src/lib/util/system.d.ts +1 -0
- package/src/lib/util/system.js +30 -0
- package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.d.ts +2 -0
- package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.js +52 -0
- package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.md +23 -0
- package/src/migrations/add-botonic-update-bots-skill/files/.cursor/commands/update-bot.md +5 -0
- package/src/migrations/add-botonic-update-bots-skill/files/.cursor/commands/update-botonic.md +5 -0
- package/src/migrations/add-botonic-update-bots-skill/files/.cursor/scripts/update-bot/discover-bots.sh +67 -0
- package/src/migrations/add-botonic-update-bots-skill/files/.cursor/scripts/update-bot/find-migration-guides.sh +70 -0
- package/src/migrations/add-botonic-update-bots-skill/schema.json +5 -0
- package/src/migrations/add-lilara-registry/add-lilara-registry.migration.d.ts +2 -0
- package/src/migrations/add-lilara-registry/add-lilara-registry.migration.js +49 -0
- package/src/migrations/add-lilara-registry/schema.json +5 -0
- package/src/migrations/fix-css-code-split/fix-css-code-split.migration.md +45 -0
- package/src/migrations/remove-codeartifact-registry/remove-codeartifact-registry.migration.d.ts +2 -0
- package/src/migrations/remove-codeartifact-registry/remove-codeartifact-registry.migration.js +59 -0
- package/src/migrations/remove-codeartifact-registry/schema.json +5 -0
- package/src/migrations/sync-pending-bot-migrations/schema.json +5 -0
- package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.d.ts +2 -0
- package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.js +137 -0
- package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.md +19 -0
- package/src/migrations/update-cursor-commands-to-stubs/schema.json +5 -0
- package/src/migrations/update-cursor-commands-to-stubs/update-cursor-commands-to-stubs.migration.d.ts +2 -0
- package/src/migrations/update-cursor-commands-to-stubs/update-cursor-commands-to-stubs.migration.js +61 -0
- package/src/migrations/update-pnpm-workspace-scripts/schema.json +4 -0
- package/src/migrations/update-pnpm-workspace-scripts/update-pnpm-workspace-scripts.migration.d.ts +2 -0
- package/src/migrations/update-pnpm-workspace-scripts/update-pnpm-workspace-scripts.migration.js +47 -0
- package/src/migrations/utils/migration-utils.d.ts +109 -0
- package/src/migrations/utils/migration-utils.js +448 -0
- package/src/plugin.d.ts +15 -0
- package/src/plugin.js +246 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "BotApp",
|
|
5
|
+
"title": "Create a Botonic bot application",
|
|
6
|
+
"description": "Create a Botonic bot application with webchat, webviews, and lambda support.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the bot application.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use for the bot application?",
|
|
17
|
+
"pattern": "^[a-zA-Z].*$"
|
|
18
|
+
},
|
|
19
|
+
"directory": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The directory of the new application.",
|
|
22
|
+
"alias": "dir"
|
|
23
|
+
},
|
|
24
|
+
"packageManager": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "The package manager to use.",
|
|
27
|
+
"enum": ["npm", "pnpm"],
|
|
28
|
+
"default": "pnpm"
|
|
29
|
+
},
|
|
30
|
+
"botonicVersion": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Botonic packages version. Leave empty to use the same version as the installed @botonic/nx-plugin."
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": ["name"]
|
|
36
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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 generator_exports = {};
|
|
20
|
+
__export(generator_exports, {
|
|
21
|
+
default: () => migrateFixCssCodeSplitGenerator
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(generator_exports);
|
|
24
|
+
var import_devkit = require("@nx/devkit");
|
|
25
|
+
var import_migration_utils = require("../../../migrations/utils/migration-utils");
|
|
26
|
+
const MODULE_DIR = __dirname;
|
|
27
|
+
const WEBCHAT_CONFIG = "vite/webchat.config.ts";
|
|
28
|
+
const WEBVIEWS_CONFIG = "vite/webviews.config.ts";
|
|
29
|
+
function addCssCodeSplit(content) {
|
|
30
|
+
if (content.includes("cssCodeSplit")) {
|
|
31
|
+
return content;
|
|
32
|
+
}
|
|
33
|
+
return content.replace(
|
|
34
|
+
/(reportCompressedSize:\s*true,)\s*\n(\s+)(commonjsOptions)/,
|
|
35
|
+
"$1\n$2cssCodeSplit: false,\n$2$3"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function processConfigFile(content, filePath) {
|
|
39
|
+
if (content.includes("cssCodeSplit")) {
|
|
40
|
+
return { transformed: false, newContent: content };
|
|
41
|
+
}
|
|
42
|
+
if (!content.includes("reportCompressedSize:")) {
|
|
43
|
+
return { transformed: false, newContent: content };
|
|
44
|
+
}
|
|
45
|
+
const newContent = addCssCodeSplit(content);
|
|
46
|
+
if (newContent === content) {
|
|
47
|
+
return { transformed: false, newContent: content };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
transformed: true,
|
|
51
|
+
newContent,
|
|
52
|
+
logMessage: `${filePath} updated with cssCodeSplit: false`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function migrateFixCssCodeSplitGenerator(tree, options) {
|
|
56
|
+
const projectPath = options.project.startsWith("apps/") ? options.project : `apps/${options.project}`;
|
|
57
|
+
const targetVersion = (0, import_migration_utils.getPluginVersion)(MODULE_DIR);
|
|
58
|
+
import_devkit.logger.info(
|
|
59
|
+
`\u{1F504} Adding cssCodeSplit: false to ${options.project} vite configs...`
|
|
60
|
+
);
|
|
61
|
+
const fileProcessor = (0, import_migration_utils.createFileProcessor)([
|
|
62
|
+
{
|
|
63
|
+
filePath: (p) => `${p}/${WEBCHAT_CONFIG}`,
|
|
64
|
+
shouldProcess: (t, filePath) => {
|
|
65
|
+
if (!t.exists(filePath)) return false;
|
|
66
|
+
const content = t.read(filePath, "utf-8");
|
|
67
|
+
return !!content && !content.includes("cssCodeSplit");
|
|
68
|
+
},
|
|
69
|
+
processFile: (_t, filePath, content) => processConfigFile(content, filePath)
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
filePath: (p) => `${p}/${WEBVIEWS_CONFIG}`,
|
|
73
|
+
shouldProcess: (t, filePath) => {
|
|
74
|
+
if (!t.exists(filePath)) return false;
|
|
75
|
+
const content = t.read(filePath, "utf-8");
|
|
76
|
+
return !!content && !content.includes("cssCodeSplit");
|
|
77
|
+
},
|
|
78
|
+
processFile: (_t, filePath, content) => processConfigFile(content, filePath)
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
const result = await fileProcessor(tree, projectPath, targetVersion);
|
|
82
|
+
if (result.transformed) {
|
|
83
|
+
(0, import_migration_utils.updateBotonicDependencies)(tree, targetVersion, projectPath);
|
|
84
|
+
import_devkit.logger.info(
|
|
85
|
+
`\u2705 ${options.project} vite configs updated with cssCodeSplit: false`
|
|
86
|
+
);
|
|
87
|
+
import_devkit.logger.info(` See migrate-fix-css-code-split.md for verification steps`);
|
|
88
|
+
} else {
|
|
89
|
+
import_devkit.logger.info(`\u2139\uFE0F ${options.project} already up to date \u2013 skipping`);
|
|
90
|
+
}
|
|
91
|
+
await (0, import_devkit.formatFiles)(tree);
|
|
92
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "MigrateFixCssCodeSplit",
|
|
4
|
+
"title": "Add cssCodeSplit: false to vite configs",
|
|
5
|
+
"description": "Adds cssCodeSplit: false to vite webchat and webviews configs to prevent split CSS missing from index.html",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The bot project to migrate",
|
|
11
|
+
"$default": { "$source": "argv", "index": 0 }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": ["project"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 generator_exports = {};
|
|
20
|
+
__export(generator_exports, {
|
|
21
|
+
default: () => migratePnpmCompatGenerator
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(generator_exports);
|
|
24
|
+
var import_devkit = require("@nx/devkit");
|
|
25
|
+
var import_migration_utils = require("../../../migrations/utils/migration-utils");
|
|
26
|
+
const MODULE_DIR = __dirname;
|
|
27
|
+
const ESLINTRC_FILE = ".eslintrc.json";
|
|
28
|
+
const README_FILE = "README.md";
|
|
29
|
+
function addNodeModulesIgnore(content) {
|
|
30
|
+
if (content.includes("**/node_modules/**")) {
|
|
31
|
+
return { transformed: false, newContent: content };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const json = JSON.parse(content);
|
|
35
|
+
const patterns = json.ignorePatterns || [];
|
|
36
|
+
const insertIdx = patterns.indexOf("!**/*");
|
|
37
|
+
patterns.splice(insertIdx + 1, 0, "**/node_modules/**");
|
|
38
|
+
json.ignorePatterns = patterns;
|
|
39
|
+
return {
|
|
40
|
+
transformed: true,
|
|
41
|
+
newContent: JSON.stringify(json, null, 2),
|
|
42
|
+
logMessage: `${ESLINTRC_FILE} updated with **/node_modules/** ignorePattern`
|
|
43
|
+
};
|
|
44
|
+
} catch {
|
|
45
|
+
return { transformed: false, newContent: content };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function migrateReadmeNpmToPnpm(content) {
|
|
49
|
+
if (!/(?<![p])npm run\b/.test(content) && !/(?<![p])npm install\b/.test(content)) {
|
|
50
|
+
return { transformed: false, newContent: content };
|
|
51
|
+
}
|
|
52
|
+
let result = content;
|
|
53
|
+
result = result.replace(/\bnpm run\b/g, "pnpm run");
|
|
54
|
+
result = result.replace(/\bnpm install\b/g, "pnpm install");
|
|
55
|
+
if (result === content) {
|
|
56
|
+
return { transformed: false, newContent: content };
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
transformed: true,
|
|
60
|
+
newContent: result,
|
|
61
|
+
logMessage: `${README_FILE} updated npm references to pnpm`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function migratePnpmCompatGenerator(tree, options) {
|
|
65
|
+
const projectPath = options.project.startsWith("apps/") ? options.project : `apps/${options.project}`;
|
|
66
|
+
const targetVersion = (0, import_migration_utils.getPluginVersion)(MODULE_DIR);
|
|
67
|
+
import_devkit.logger.info(`\u{1F504} Migrating ${options.project} for pnpm compatibility...`);
|
|
68
|
+
const fileProcessor = (0, import_migration_utils.createFileProcessor)([
|
|
69
|
+
{
|
|
70
|
+
filePath: (p) => `${p}/${ESLINTRC_FILE}`,
|
|
71
|
+
shouldProcess: (t, filePath) => {
|
|
72
|
+
if (!t.exists(filePath)) return false;
|
|
73
|
+
const content = t.read(filePath, "utf-8");
|
|
74
|
+
return !!content && !content.includes("**/node_modules/**");
|
|
75
|
+
},
|
|
76
|
+
processFile: (_t, _filePath, content) => addNodeModulesIgnore(content)
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
filePath: (p) => `${p}/${README_FILE}`,
|
|
80
|
+
shouldProcess: (t, filePath) => {
|
|
81
|
+
if (!t.exists(filePath)) return false;
|
|
82
|
+
const content = t.read(filePath, "utf-8");
|
|
83
|
+
return !!content && (/(?<![p])npm run\b/.test(content) || /(?<![p])npm install\b/.test(content));
|
|
84
|
+
},
|
|
85
|
+
processFile: (_t, _filePath, content) => migrateReadmeNpmToPnpm(content)
|
|
86
|
+
}
|
|
87
|
+
]);
|
|
88
|
+
const result = await fileProcessor(tree, projectPath, targetVersion);
|
|
89
|
+
if (result.transformed) {
|
|
90
|
+
(0, import_migration_utils.updateBotonicDependencies)(tree, targetVersion, projectPath);
|
|
91
|
+
import_devkit.logger.info(`\u2705 ${options.project} updated for pnpm compatibility`);
|
|
92
|
+
import_devkit.logger.info(` See migrate-pnpm-compat.md for verification steps`);
|
|
93
|
+
} else {
|
|
94
|
+
import_devkit.logger.info(`\u2139\uFE0F ${options.project} already up to date \u2013 skipping`);
|
|
95
|
+
}
|
|
96
|
+
await (0, import_devkit.formatFiles)(tree);
|
|
97
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "MigratePnpmCompat",
|
|
4
|
+
"title": "Migrate bot app for pnpm compatibility",
|
|
5
|
+
"description": "Add **/node_modules/** to eslint ignorePatterns and update README npm references to pnpm",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The bot project to migrate",
|
|
11
|
+
"$default": { "$source": "argv", "index": 0 }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": ["project"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
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 generator_exports = {};
|
|
20
|
+
__export(generator_exports, {
|
|
21
|
+
default: () => migrateWebchatTriggerGenerator
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(generator_exports);
|
|
24
|
+
var import_devkit = require("@nx/devkit");
|
|
25
|
+
var import_migration_utils = require("../../../migrations/utils/migration-utils");
|
|
26
|
+
const MODULE_DIR = __dirname;
|
|
27
|
+
const WEBCHAT_FILE = "src/client/webchat/index.tsx";
|
|
28
|
+
const REMOVED_SYMBOLS = /* @__PURE__ */ new Set([
|
|
29
|
+
"WebchatTrigger",
|
|
30
|
+
"WebchatProvider",
|
|
31
|
+
"WebchatContainer",
|
|
32
|
+
"WebchatHeader",
|
|
33
|
+
"WebchatInput",
|
|
34
|
+
"WebchatMessages",
|
|
35
|
+
"useWebchatContext"
|
|
36
|
+
]);
|
|
37
|
+
function rewriteImports(content) {
|
|
38
|
+
const triggerImports = "import type { WebchatTriggerProps } from '@botonic/webchat-react/trigger'\nimport { WebchatTrigger } from '@botonic/webchat-react/trigger'";
|
|
39
|
+
const mainImportRegex = /import\s*\{([^}]*)\}\s*from\s*['"]@botonic\/webchat-react['"]\s*;?\s*\n?/g;
|
|
40
|
+
return content.replace(mainImportRegex, (_, inner) => {
|
|
41
|
+
const symbols = inner.split(",").map(
|
|
42
|
+
(s) => s.trim().replace(/\s+as\s+\w+$/, "").split(":")[0].trim()
|
|
43
|
+
).filter((s) => s && !REMOVED_SYMBOLS.has(s));
|
|
44
|
+
if (symbols.length === 0) {
|
|
45
|
+
return triggerImports + "\n";
|
|
46
|
+
}
|
|
47
|
+
return `import { ${symbols.join(", ")} } from '@botonic/webchat-react'
|
|
48
|
+
${triggerImports}
|
|
49
|
+
`;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function removeWebchatAppComponent(content) {
|
|
53
|
+
const webchatAppRegex = /function\s+WebchatApp\s*\([\s\S]*?\)\s*\{[\s\S]*?\}(?=\s*\n\s*(?:function|const)\s+(?:App|renderWebchat)\b)/m;
|
|
54
|
+
return content.replace(webchatAppRegex, "");
|
|
55
|
+
}
|
|
56
|
+
function replaceWebchatProviderWithTrigger(content) {
|
|
57
|
+
const hasCoverComponents = /COVER_COMPONENTS/.test(content);
|
|
58
|
+
const coverRegistryLine = hasCoverComponents ? " coverRegistry: COVER_COMPONENTS,\n" : "";
|
|
59
|
+
const webchatTriggerBlock = `<WebchatTrigger
|
|
60
|
+
appId={webchatConfig.appId}
|
|
61
|
+
position='bottom-right'
|
|
62
|
+
onReady={handleReady}
|
|
63
|
+
webchatConfig={{
|
|
64
|
+
avatarConfig,
|
|
65
|
+
customMessages,
|
|
66
|
+
${coverRegistryLine} title: options.title || 'Demo Bot',
|
|
67
|
+
placeholder: options.placeholder || 'Message...',
|
|
68
|
+
}}
|
|
69
|
+
/>`;
|
|
70
|
+
const providerRegex = /<WebchatProvider\s[^>]*>[\s\S]*?<\/WebchatProvider>/g;
|
|
71
|
+
let result = content;
|
|
72
|
+
const match = result.match(providerRegex);
|
|
73
|
+
if (match) {
|
|
74
|
+
for (const m of match) {
|
|
75
|
+
result = result.replace(m, webchatTriggerBlock);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function addHandleReady(content) {
|
|
81
|
+
if (content.includes("handleReady")) {
|
|
82
|
+
return content;
|
|
83
|
+
}
|
|
84
|
+
const handleReadySnippet = ` // Handle webchat ready \u2013 full control over when/how to open
|
|
85
|
+
const handleReady = React.useCallback<
|
|
86
|
+
NonNullable<WebchatTriggerProps['onReady']>
|
|
87
|
+
>(controller => {
|
|
88
|
+
controller.open()
|
|
89
|
+
}, [])
|
|
90
|
+
|
|
91
|
+
`;
|
|
92
|
+
const returnWithProvider = content.match(
|
|
93
|
+
/(\s+)(return\s*\(\s*\n\s*)<WebchatProvider/
|
|
94
|
+
);
|
|
95
|
+
if (returnWithProvider) {
|
|
96
|
+
return content.replace(
|
|
97
|
+
returnWithProvider[0],
|
|
98
|
+
returnWithProvider[1] + handleReadySnippet + returnWithProvider[2] + "<WebchatProvider"
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const appReturnRegex = /(function App\s*\([\s\S]*?\)\s*\{[\s\S]*?)(return \()/m;
|
|
102
|
+
return content.replace(appReturnRegex, `$1${handleReadySnippet}$2`);
|
|
103
|
+
}
|
|
104
|
+
function updateWindowBotonicType(content) {
|
|
105
|
+
if (content.includes("ready: Promise<void>")) {
|
|
106
|
+
return content;
|
|
107
|
+
}
|
|
108
|
+
const readySnippet = `
|
|
109
|
+
// Ready state
|
|
110
|
+
ready: Promise<void>
|
|
111
|
+
isReady: () => boolean`;
|
|
112
|
+
return content.replace(
|
|
113
|
+
/(render:\s*\([\s\S]*?\)\s*=>\s*void)(\s*\n)/,
|
|
114
|
+
`$1${readySnippet}$2`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function processWebchatFile(content) {
|
|
118
|
+
if (!content.includes("WebchatTrigger") || content.includes("from '@botonic/webchat-react/trigger'")) {
|
|
119
|
+
return { transformed: false, newContent: content };
|
|
120
|
+
}
|
|
121
|
+
if (!content.includes("WebchatProvider")) {
|
|
122
|
+
return { transformed: false, newContent: content };
|
|
123
|
+
}
|
|
124
|
+
let result = content;
|
|
125
|
+
result = rewriteImports(result);
|
|
126
|
+
result = removeWebchatAppComponent(result);
|
|
127
|
+
result = addHandleReady(result);
|
|
128
|
+
result = replaceWebchatProviderWithTrigger(result);
|
|
129
|
+
result = updateWindowBotonicType(result);
|
|
130
|
+
if (result === content) {
|
|
131
|
+
return { transformed: false, newContent: content };
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
transformed: true,
|
|
135
|
+
newContent: result,
|
|
136
|
+
logMessage: `${WEBCHAT_FILE} migrated to lazy-loading WebchatTrigger`
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async function migrateWebchatTriggerGenerator(tree, options) {
|
|
140
|
+
const projectPath = options.project.startsWith("apps/") ? options.project : `apps/${options.project}`;
|
|
141
|
+
const targetVersion = (0, import_migration_utils.getPluginVersion)(MODULE_DIR);
|
|
142
|
+
import_devkit.logger.info(
|
|
143
|
+
`\u{1F504} Migrating ${options.project} to lazy-loading WebchatTrigger...`
|
|
144
|
+
);
|
|
145
|
+
const fileProcessor = (0, import_migration_utils.createFileProcessor)([
|
|
146
|
+
{
|
|
147
|
+
filePath: (p) => `${p}/${WEBCHAT_FILE}`,
|
|
148
|
+
shouldProcess: (t, filePath) => {
|
|
149
|
+
if (!t.exists(filePath)) return false;
|
|
150
|
+
const content = t.read(filePath, "utf-8");
|
|
151
|
+
return !!content && content.includes("WebchatTrigger") && !content.includes("from '@botonic/webchat-react/trigger'") && content.includes("WebchatProvider");
|
|
152
|
+
},
|
|
153
|
+
processFile: (_t, _filePath, content) => processWebchatFile(content)
|
|
154
|
+
}
|
|
155
|
+
]);
|
|
156
|
+
const result = await fileProcessor(tree, projectPath, targetVersion);
|
|
157
|
+
if (result.transformed) {
|
|
158
|
+
(0, import_migration_utils.updateBotonicDependencies)(tree, targetVersion, projectPath);
|
|
159
|
+
import_devkit.logger.info(`\u2705 ${options.project} migrated to lazy-loading WebchatTrigger`);
|
|
160
|
+
import_devkit.logger.info(` See migrate-webchat-trigger.md for verification steps`);
|
|
161
|
+
} else {
|
|
162
|
+
import_devkit.logger.info(`\u2139\uFE0F ${options.project} already up to date \u2013 skipping`);
|
|
163
|
+
}
|
|
164
|
+
await (0, import_devkit.formatFiles)(tree);
|
|
165
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "MigrateWebchatTrigger",
|
|
4
|
+
"title": "Migrate WebchatTrigger to lazy-loading entry point",
|
|
5
|
+
"description": "Migrates a bot app to use @botonic/webchat-react/trigger lazy-loading entry point",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The bot project to migrate",
|
|
11
|
+
"$default": { "$source": "argv", "index": 0 }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": ["project"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BotContext } from '@botonic/core'
|
|
2
|
+
import { MessageType } from '@botonic/shared'
|
|
3
|
+
|
|
4
|
+
import { CUSTOM_MESSAGE_TYPES } from '../../../shared/constants'
|
|
5
|
+
|
|
6
|
+
export async function <%= propertyName %>Output({ sendMessage }: BotContext) {
|
|
7
|
+
await sendMessage({
|
|
8
|
+
type: MessageType.Custom,
|
|
9
|
+
data: {
|
|
10
|
+
name: CUSTOM_MESSAGE_TYPES.<%= constantName %>,
|
|
11
|
+
props: {
|
|
12
|
+
// Add your custom props here
|
|
13
|
+
// Example: title: 'Hello from <%= className %>!'
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
return {
|
|
18
|
+
status: 200,
|
|
19
|
+
response: 'OK',
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { <%= className %> } from './<%= fileName %>'
|
|
5
|
+
|
|
6
|
+
describe('<%= className %>', () => {
|
|
7
|
+
it('should render successfully', () => {
|
|
8
|
+
render(<<%= className %> />)
|
|
9
|
+
expect(screen.getByText('<%= className %> Component')).toBeInTheDocument()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('should render children when provided', () => {
|
|
13
|
+
const childText = 'Test child content'
|
|
14
|
+
render(<<%= className %>>{childText}</<%= className %>>)
|
|
15
|
+
expect(screen.getByText(childText)).toBeInTheDocument()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should apply custom props', () => {
|
|
19
|
+
const customProps = {
|
|
20
|
+
// Add test for your custom props here
|
|
21
|
+
// Example: title: 'Custom Title'
|
|
22
|
+
}
|
|
23
|
+
render(<<%= className %> {...customProps} />)
|
|
24
|
+
// Add assertions for your custom props
|
|
25
|
+
expect(screen.getByText('<%= className %> Component')).toBeInTheDocument()
|
|
26
|
+
})
|
|
27
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Message } from '@botonic/webchat-react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export interface <%= className %>Props {
|
|
5
|
+
// Add your custom props here
|
|
6
|
+
children?: React.ReactNode
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const <%= className %>: React.FC<<%= className %>Props> = (props: any) => {
|
|
10
|
+
return (
|
|
11
|
+
<Message>
|
|
12
|
+
<div>
|
|
13
|
+
<p><%= className %> — customize this component</p>
|
|
14
|
+
{props.children}
|
|
15
|
+
</div>
|
|
16
|
+
</Message>
|
|
17
|
+
)
|
|
18
|
+
}
|