@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.
Files changed (206) hide show
  1. package/CHANGELOG.md +420 -0
  2. package/README.md +279 -0
  3. package/executors.json +55 -0
  4. package/generators.json +61 -0
  5. package/migrations.json +40 -0
  6. package/package.json +54 -0
  7. package/src/cursor-commands/update-bot.md +114 -0
  8. package/src/cursor-commands/update-botonic.md +63 -0
  9. package/src/executors/build-node-app/executor.d.ts +5 -0
  10. package/src/executors/build-node-app/executor.js +65 -0
  11. package/src/executors/build-node-app/schema.d.js +16 -0
  12. package/src/executors/build-node-app/schema.json +25 -0
  13. package/src/executors/delete-bot/executor.d.ts +5 -0
  14. package/src/executors/delete-bot/executor.js +112 -0
  15. package/src/executors/delete-bot/schema.d.js +16 -0
  16. package/src/executors/delete-bot/schema.json +35 -0
  17. package/src/executors/deploy-local-runtime/executor.d.ts +5 -0
  18. package/src/executors/deploy-local-runtime/executor.js +144 -0
  19. package/src/executors/deploy-local-runtime/schema.d.js +16 -0
  20. package/src/executors/deploy-local-runtime/schema.json +34 -0
  21. package/src/executors/deploy-netlify-snapshot/executor.d.ts +8 -0
  22. package/src/executors/deploy-netlify-snapshot/executor.js +79 -0
  23. package/src/executors/deploy-netlify-snapshot/schema.d.js +16 -0
  24. package/src/executors/deploy-netlify-snapshot/schema.json +31 -0
  25. package/src/executors/deploy-to-hubtype/executor.d.ts +5 -0
  26. package/src/executors/deploy-to-hubtype/executor.js +308 -0
  27. package/src/executors/deploy-to-hubtype/schema.d.js +16 -0
  28. package/src/executors/deploy-to-hubtype/schema.json +31 -0
  29. package/src/executors/e2e-webchat/botonic-package-publish.spec.ts +84 -0
  30. package/src/executors/e2e-webchat/executor.d.ts +5 -0
  31. package/src/executors/e2e-webchat/executor.js +134 -0
  32. package/src/executors/e2e-webchat/schema.d.js +16 -0
  33. package/src/executors/e2e-webchat/schema.json +35 -0
  34. package/src/executors/integrate-provider/executor.d.ts +5 -0
  35. package/src/executors/integrate-provider/executor.js +155 -0
  36. package/src/executors/integrate-provider/schema.d.js +16 -0
  37. package/src/executors/integrate-provider/schema.json +30 -0
  38. package/src/executors/login-to-hubtype/executor.d.ts +5 -0
  39. package/src/executors/login-to-hubtype/executor.js +79 -0
  40. package/src/executors/login-to-hubtype/schema.d.js +16 -0
  41. package/src/executors/login-to-hubtype/schema.json +25 -0
  42. package/src/executors/logout-from-hubtype/executor.d.ts +3 -0
  43. package/src/executors/logout-from-hubtype/executor.js +54 -0
  44. package/src/executors/logout-from-hubtype/schema.d.js +16 -0
  45. package/src/executors/logout-from-hubtype/schema.json +9 -0
  46. package/src/executors/run-lambda/executor.d.ts +5 -0
  47. package/src/executors/run-lambda/executor.js +65 -0
  48. package/src/executors/run-lambda/schema.d.js +16 -0
  49. package/src/executors/run-lambda/schema.json +20 -0
  50. package/src/executors/serve-bot/executor.d.ts +5 -0
  51. package/src/executors/serve-bot/executor.js +330 -0
  52. package/src/executors/serve-bot/schema.d.js +16 -0
  53. package/src/executors/serve-bot/schema.json +40 -0
  54. package/src/generators/action/files/__name__.spec.ts.template +15 -0
  55. package/src/generators/action/files/__name__.ts.template +15 -0
  56. package/src/generators/action/generator.d.ts +4 -0
  57. package/src/generators/action/generator.js +112 -0
  58. package/src/generators/action/schema.d.ts +7 -0
  59. package/src/generators/action/schema.js +16 -0
  60. package/src/generators/action/schema.json +43 -0
  61. package/src/generators/bot-app/files/.eslintrc.json.template +18 -0
  62. package/src/generators/bot-app/files/README.md.template +148 -0
  63. package/src/generators/bot-app/files/src/client/custom-messages/index.ts.template +2 -0
  64. package/src/generators/bot-app/files/src/client/webchat/index.html.template +35 -0
  65. package/src/generators/bot-app/files/src/client/webchat/index.tsx.template +107 -0
  66. package/src/generators/bot-app/files/src/client/webchat/styles.css.template +17 -0
  67. package/src/generators/bot-app/files/src/client/webchat/webchat-tokens-overrides.css.template +2 -0
  68. package/src/generators/bot-app/files/src/client/webviews/app.tsx.template +8 -0
  69. package/src/generators/bot-app/files/src/client/webviews/index.html.template +32 -0
  70. package/src/generators/bot-app/files/src/client/webviews/index.tsx.template +18 -0
  71. package/src/generators/bot-app/files/src/server/bot/actions/index.ts.template +2 -0
  72. package/src/generators/bot-app/files/src/server/bot/actions/not-found.ts.template +13 -0
  73. package/src/generators/bot-app/files/src/server/bot/actions/welcome.ts.template +13 -0
  74. package/src/generators/bot-app/files/src/server/bot/index.ts.template +43 -0
  75. package/src/generators/bot-app/files/src/server/bot/plugins/ai-agents/index.ts.template +30 -0
  76. package/src/generators/bot-app/files/src/server/bot/plugins/flow-builder/index.ts.template +28 -0
  77. package/src/generators/bot-app/files/src/server/bot/plugins/index.ts.template +11 -0
  78. package/src/generators/bot-app/files/src/server/bot/routes.ts.template +23 -0
  79. package/src/generators/bot-app/files/src/server/bot/tools/index.ts.template +5 -0
  80. package/src/generators/bot-app/files/src/server/bot/tracking.ts.template +35 -0
  81. package/src/generators/bot-app/files/src/server/bot/types.ts.template +4 -0
  82. package/src/generators/bot-app/files/src/server/bot/utils.ts.template +9 -0
  83. package/src/generators/bot-app/files/src/server/lambda/handler.js.template +24 -0
  84. package/src/generators/bot-app/files/src/server/lambda/package.json +20 -0
  85. package/src/generators/bot-app/files/src/server/lambda/template.yaml.template +20 -0
  86. package/src/generators/bot-app/files/src/shared/constants.ts.template +12 -0
  87. package/src/generators/bot-app/files/vite/base-client.config.ts.template +14 -0
  88. package/src/generators/bot-app/files/vite/base.config.ts.template +20 -0
  89. package/src/generators/bot-app/files/vite/build.config.ts.template +65 -0
  90. package/src/generators/bot-app/files/vite/node.config.ts.template +41 -0
  91. package/src/generators/bot-app/files/vite/plugins/move-html.plugin.ts.template +36 -0
  92. package/src/generators/bot-app/files/vite/webchat.config.ts.template +58 -0
  93. package/src/generators/bot-app/files/vite/webviews.config.ts.template +57 -0
  94. package/src/generators/bot-app/files/vite.config.ts.template +36 -0
  95. package/src/generators/bot-app/generator.d.ts +4 -0
  96. package/src/generators/bot-app/generator.js +294 -0
  97. package/src/generators/bot-app/schema.d.ts +6 -0
  98. package/src/generators/bot-app/schema.js +16 -0
  99. package/src/generators/bot-app/schema.json +36 -0
  100. package/src/generators/bot-app-migrations/migrate-fix-css-code-split/generator.d.ts +5 -0
  101. package/src/generators/bot-app-migrations/migrate-fix-css-code-split/generator.js +92 -0
  102. package/src/generators/bot-app-migrations/migrate-fix-css-code-split/schema.json +15 -0
  103. package/src/generators/bot-app-migrations/migrate-pnpm-compat/generator.d.ts +5 -0
  104. package/src/generators/bot-app-migrations/migrate-pnpm-compat/generator.js +97 -0
  105. package/src/generators/bot-app-migrations/migrate-pnpm-compat/schema.json +15 -0
  106. package/src/generators/bot-app-migrations/migrate-webchat-trigger/generator.d.ts +5 -0
  107. package/src/generators/bot-app-migrations/migrate-webchat-trigger/generator.js +165 -0
  108. package/src/generators/bot-app-migrations/migrate-webchat-trigger/schema.json +15 -0
  109. package/src/generators/custom-message/files/__name__-output.ts.template +21 -0
  110. package/src/generators/custom-message/files/__name__.spec.tsx.template +27 -0
  111. package/src/generators/custom-message/files/__name__.tsx.template +18 -0
  112. package/src/generators/custom-message/generator.d.ts +4 -0
  113. package/src/generators/custom-message/generator.js +235 -0
  114. package/src/generators/custom-message/schema.d.ts +7 -0
  115. package/src/generators/custom-message/schema.js +16 -0
  116. package/src/generators/custom-message/schema.json +44 -0
  117. package/src/generators/preset/files/.cursor/commands/update-bot.md +5 -0
  118. package/src/generators/preset/files/.cursor/commands/update-botonic.md +5 -0
  119. package/src/generators/preset/files/.cursor/scripts/update-bot/discover-bots.sh +67 -0
  120. package/src/generators/preset/files/.cursor/scripts/update-bot/find-migration-guides.sh +70 -0
  121. package/src/generators/preset/files/.cursor/skills/botonic-action/SKILL.md +167 -0
  122. package/src/generators/preset/files/.cursor/skills/botonic-custom-message/SKILL.md +231 -0
  123. package/src/generators/preset/files/.cursor/skills/botonic-webview/SKILL.md +179 -0
  124. package/src/generators/preset/files/.env.prod.template +2 -0
  125. package/src/generators/preset/files/.env.template +2 -0
  126. package/src/generators/preset/files/.npmrc.template +1 -0
  127. package/src/generators/preset/files/README.md.template +174 -0
  128. package/src/generators/preset/files/nx.json +66 -0
  129. package/src/generators/preset/files/package.json +26 -0
  130. package/src/generators/preset/files/tsconfig.base.json +27 -0
  131. package/src/generators/preset/files/tsconfig.base.json.template +27 -0
  132. package/src/generators/preset/files/tsconfig.json +9 -0
  133. package/src/generators/preset/generator.d.ts +4 -0
  134. package/src/generators/preset/generator.js +127 -0
  135. package/src/generators/preset/schema.d.ts +6 -0
  136. package/src/generators/preset/schema.js +16 -0
  137. package/src/generators/preset/schema.json +50 -0
  138. package/src/generators/remove-custom-message/generator.d.ts +4 -0
  139. package/src/generators/remove-custom-message/generator.js +259 -0
  140. package/src/generators/remove-custom-message/schema.d.ts +6 -0
  141. package/src/generators/remove-custom-message/schema.js +16 -0
  142. package/src/generators/remove-custom-message/schema.json +39 -0
  143. package/src/generators/shared/bot-app-utils.d.ts +25 -0
  144. package/src/generators/shared/bot-app-utils.js +209 -0
  145. package/src/generators/webview/files/__name__.spec.tsx.template +20 -0
  146. package/src/generators/webview/files/__name__.tsx.template +19 -0
  147. package/src/generators/webview/generator.d.ts +4 -0
  148. package/src/generators/webview/generator.js +179 -0
  149. package/src/generators/webview/schema.d.ts +5 -0
  150. package/src/generators/webview/schema.js +16 -0
  151. package/src/generators/webview/schema.json +34 -0
  152. package/src/index.d.ts +7 -0
  153. package/src/index.js +56 -0
  154. package/src/lib/api-service.d.ts +110 -0
  155. package/src/lib/api-service.js +591 -0
  156. package/src/lib/bot-config.d.ts +30 -0
  157. package/src/lib/bot-config.js +203 -0
  158. package/src/lib/cloudflared-tunnel.d.ts +29 -0
  159. package/src/lib/cloudflared-tunnel.js +95 -0
  160. package/src/lib/constants.d.ts +13 -0
  161. package/src/lib/constants.js +60 -0
  162. package/src/lib/credentials-handler.d.ts +40 -0
  163. package/src/lib/credentials-handler.js +115 -0
  164. package/src/lib/index.d.ts +10 -0
  165. package/src/lib/index.js +47 -0
  166. package/src/lib/interfaces.d.ts +49 -0
  167. package/src/lib/interfaces.js +16 -0
  168. package/src/lib/util/executor-helpers.d.ts +97 -0
  169. package/src/lib/util/executor-helpers.js +574 -0
  170. package/src/lib/util/file-system.d.ts +8 -0
  171. package/src/lib/util/file-system.js +65 -0
  172. package/src/lib/util/sam-container-cleanup.d.ts +11 -0
  173. package/src/lib/util/sam-container-cleanup.js +55 -0
  174. package/src/lib/util/sam-template.d.ts +9 -0
  175. package/src/lib/util/sam-template.js +71 -0
  176. package/src/lib/util/system.d.ts +1 -0
  177. package/src/lib/util/system.js +30 -0
  178. package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.d.ts +2 -0
  179. package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.js +52 -0
  180. package/src/migrations/add-botonic-update-bots-skill/add-botonic-update-bots-skill.migration.md +23 -0
  181. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/commands/update-bot.md +5 -0
  182. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/commands/update-botonic.md +5 -0
  183. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/scripts/update-bot/discover-bots.sh +67 -0
  184. package/src/migrations/add-botonic-update-bots-skill/files/.cursor/scripts/update-bot/find-migration-guides.sh +70 -0
  185. package/src/migrations/add-botonic-update-bots-skill/schema.json +5 -0
  186. package/src/migrations/add-lilara-registry/add-lilara-registry.migration.d.ts +2 -0
  187. package/src/migrations/add-lilara-registry/add-lilara-registry.migration.js +49 -0
  188. package/src/migrations/add-lilara-registry/schema.json +5 -0
  189. package/src/migrations/fix-css-code-split/fix-css-code-split.migration.md +45 -0
  190. package/src/migrations/remove-codeartifact-registry/remove-codeartifact-registry.migration.d.ts +2 -0
  191. package/src/migrations/remove-codeartifact-registry/remove-codeartifact-registry.migration.js +59 -0
  192. package/src/migrations/remove-codeartifact-registry/schema.json +5 -0
  193. package/src/migrations/sync-pending-bot-migrations/schema.json +5 -0
  194. package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.d.ts +2 -0
  195. package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.js +137 -0
  196. package/src/migrations/sync-pending-bot-migrations/sync-pending-bot-migrations.migration.md +19 -0
  197. package/src/migrations/update-cursor-commands-to-stubs/schema.json +5 -0
  198. package/src/migrations/update-cursor-commands-to-stubs/update-cursor-commands-to-stubs.migration.d.ts +2 -0
  199. package/src/migrations/update-cursor-commands-to-stubs/update-cursor-commands-to-stubs.migration.js +61 -0
  200. package/src/migrations/update-pnpm-workspace-scripts/schema.json +4 -0
  201. package/src/migrations/update-pnpm-workspace-scripts/update-pnpm-workspace-scripts.migration.d.ts +2 -0
  202. package/src/migrations/update-pnpm-workspace-scripts/update-pnpm-workspace-scripts.migration.js +47 -0
  203. package/src/migrations/utils/migration-utils.d.ts +109 -0
  204. package/src/migrations/utils/migration-utils.js +448 -0
  205. package/src/plugin.d.ts +15 -0
  206. package/src/plugin.js +246 -0
@@ -0,0 +1,65 @@
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 file_system_exports = {};
20
+ __export(file_system_exports, {
21
+ copy: () => copy,
22
+ createDir: () => createDir,
23
+ getHomeDirectory: () => getHomeDirectory,
24
+ pathExists: () => pathExists,
25
+ readJSON: () => readJSON,
26
+ removeRecursively: () => removeRecursively,
27
+ writeJSON: () => writeJSON
28
+ });
29
+ module.exports = __toCommonJS(file_system_exports);
30
+ var import_fs = require("fs");
31
+ var import_fs_extra = require("fs-extra");
32
+ var import_os = require("os");
33
+ function pathExists(path) {
34
+ return (0, import_fs.existsSync)(path);
35
+ }
36
+ function readJSON(path) {
37
+ const fileContent = (0, import_fs.readFileSync)(path, "utf8");
38
+ if (!fileContent) return void 0;
39
+ return JSON.parse(fileContent);
40
+ }
41
+ function writeJSON(path, object) {
42
+ (0, import_fs.writeFileSync)(path, JSON.stringify(object));
43
+ }
44
+ function createDir(path) {
45
+ return (0, import_fs.mkdirSync)(path);
46
+ }
47
+ function getHomeDirectory() {
48
+ return (0, import_os.homedir)();
49
+ }
50
+ function copy(from, to) {
51
+ (0, import_fs_extra.copySync)(from, to);
52
+ }
53
+ function removeRecursively(path) {
54
+ (0, import_fs.rmSync)(path, { recursive: true, force: true });
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ copy,
59
+ createDir,
60
+ getHomeDirectory,
61
+ pathExists,
62
+ readJSON,
63
+ removeRecursively,
64
+ writeJSON
65
+ });
@@ -0,0 +1,11 @@
1
+ export type CleanupResult = 'removed' | 'none' | 'skipped';
2
+ /**
3
+ * Remove any existing Lambda container(s) from a previous run by finding containers
4
+ * with the label sam.cli.function.name=<function name from template.yaml>.
5
+ *
6
+ * @param projectRoot - Root path of the bot project (containing src/server/lambda/template.yaml)
7
+ * @returns 'removed' if at least one container was found and removed (or removal attempted),
8
+ * 'none' if no container with that label existed (or docker failed),
9
+ * 'skipped' if the template could not be read (e.g. missing or invalid).
10
+ */
11
+ export declare function cleanupPreviousSamContainersByLabel(projectRoot: string): CleanupResult;
@@ -0,0 +1,55 @@
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 sam_container_cleanup_exports = {};
20
+ __export(sam_container_cleanup_exports, {
21
+ cleanupPreviousSamContainersByLabel: () => cleanupPreviousSamContainersByLabel
22
+ });
23
+ module.exports = __toCommonJS(sam_container_cleanup_exports);
24
+ var import_child_process = require("child_process");
25
+ var import_sam_template = require("./sam-template");
26
+ const SAM_CLI_FUNCTION_LABEL = "sam.cli.function.name";
27
+ function cleanupPreviousSamContainersByLabel(projectRoot) {
28
+ let functionName;
29
+ try {
30
+ functionName = (0, import_sam_template.getLocalLambdaFunctionName)(projectRoot);
31
+ } catch {
32
+ return "skipped";
33
+ }
34
+ try {
35
+ const out = (0, import_child_process.execSync)(
36
+ `docker ps -a -q --filter "label=${SAM_CLI_FUNCTION_LABEL}=${functionName}"`,
37
+ { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }
38
+ );
39
+ const ids = out.trim().split("\n").filter(Boolean);
40
+ if (ids.length === 0) {
41
+ return "none";
42
+ }
43
+ try {
44
+ (0, import_child_process.execSync)(`docker rm -f ${ids.join(" ")}`, { stdio: "pipe" });
45
+ } catch {
46
+ }
47
+ return "removed";
48
+ } catch {
49
+ return "none";
50
+ }
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ cleanupPreviousSamContainersByLabel
55
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Reads the SAM template at projectRoot/src/server/lambda/template.yaml and returns
3
+ * the logical resource name of the first AWS::Serverless::Function (or the single
4
+ * resource key under Resources when there is only one).
5
+ * @param projectRoot - Root path of the bot project
6
+ * @returns The logical function name (e.g. "BotonicV2LocalLambda")
7
+ * @throws Error when the file is missing, unreadable, or has no Lambda resource
8
+ */
9
+ export declare function getLocalLambdaFunctionName(projectRoot: string): string;
@@ -0,0 +1,71 @@
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 sam_template_exports = {};
20
+ __export(sam_template_exports, {
21
+ getLocalLambdaFunctionName: () => getLocalLambdaFunctionName
22
+ });
23
+ module.exports = __toCommonJS(sam_template_exports);
24
+ var import_fs = require("fs");
25
+ var import_path = require("path");
26
+ var import_yaml = require("yaml");
27
+ const TEMPLATE_RELATIVE_PATH = "src/server/lambda/template.yaml";
28
+ function getLocalLambdaFunctionName(projectRoot) {
29
+ const templatePath = (0, import_path.join)(projectRoot, TEMPLATE_RELATIVE_PATH);
30
+ let content;
31
+ try {
32
+ content = (0, import_fs.readFileSync)(templatePath, "utf-8");
33
+ } catch (err) {
34
+ const message = err instanceof Error ? err.message : String(err);
35
+ throw new Error(
36
+ `Could not read SAM template at ${templatePath}: ${message}. Ensure the file exists.`
37
+ );
38
+ }
39
+ let parsed;
40
+ try {
41
+ parsed = (0, import_yaml.parse)(content);
42
+ } catch (err) {
43
+ const message = err instanceof Error ? err.message : String(err);
44
+ throw new Error(
45
+ `Invalid YAML in SAM template at ${templatePath}: ${message}`
46
+ );
47
+ }
48
+ const resources = parsed?.Resources;
49
+ if (!resources || typeof resources !== "object") {
50
+ throw new Error(
51
+ `SAM template at ${templatePath} has no Resources section or it is not an object.`
52
+ );
53
+ }
54
+ const entries = Object.entries(resources);
55
+ const lambdaEntry = entries.find(
56
+ ([, def]) => def && def.Type === "AWS::Serverless::Function"
57
+ );
58
+ if (lambdaEntry) {
59
+ return lambdaEntry[0];
60
+ }
61
+ if (entries.length === 1) {
62
+ return entries[0][0];
63
+ }
64
+ throw new Error(
65
+ `SAM template at ${templatePath} has no AWS::Serverless::Function resource under Resources.`
66
+ );
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ getLocalLambdaFunctionName
71
+ });
@@ -0,0 +1 @@
1
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1,30 @@
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 system_exports = {};
20
+ __export(system_exports, {
21
+ sleep: () => sleep
22
+ });
23
+ module.exports = __toCommonJS(system_exports);
24
+ function sleep(ms) {
25
+ return new Promise((resolve) => setTimeout(resolve, ms));
26
+ }
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ sleep
30
+ });
@@ -0,0 +1,2 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function addBotonicUpdateBotsSkillMigration(tree: Tree): Promise<void>;
@@ -0,0 +1,52 @@
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 add_botonic_update_bots_skill_migration_exports = {};
30
+ __export(add_botonic_update_bots_skill_migration_exports, {
31
+ default: () => addBotonicUpdateBotsSkillMigration
32
+ });
33
+ module.exports = __toCommonJS(add_botonic_update_bots_skill_migration_exports);
34
+ var import_devkit = require("@nx/devkit");
35
+ var path = __toESM(require("path"));
36
+ const MODULE_DIR = __dirname;
37
+ const UPDATE_BOTONIC_MD = ".cursor/commands/update-botonic.md";
38
+ const UPDATE_BOT_MD = ".cursor/commands/update-bot.md";
39
+ async function addBotonicUpdateBotsSkillMigration(tree) {
40
+ const botUpdateExists = tree.exists(UPDATE_BOT_MD);
41
+ const botonicUpdateExists = tree.exists(UPDATE_BOTONIC_MD);
42
+ if (botUpdateExists && botonicUpdateExists) {
43
+ import_devkit.logger.info(
44
+ "update-botonic and update-bot commands already present \u2013 skipping"
45
+ );
46
+ return;
47
+ }
48
+ (0, import_devkit.generateFiles)(tree, path.join(MODULE_DIR, "files"), ".", {});
49
+ if (!botonicUpdateExists) import_devkit.logger.info("Added /update-botonic Cursor command");
50
+ if (!botUpdateExists) import_devkit.logger.info("Added /update-bot Cursor command");
51
+ await (0, import_devkit.formatFiles)(tree);
52
+ }
@@ -0,0 +1,23 @@
1
+ # Add /update-bot Cursor Command Migration
2
+
3
+ ## Summary
4
+
5
+ This migration adds the `/update-bot` Cursor command to your workspace. The command helps you update Botonic bot apps to newer versions using Nx migrations, one bot at a time, with git branch management.
6
+
7
+ ## What the automated migration does
8
+
9
+ - Creates `.cursor/commands/update-bot.md` — workflow and examples
10
+ - Creates `.cursor/scripts/update-bot/discover-bots.sh` — finds bot apps via `nx show projects --projects "tag:botonic:bot-app"`
11
+ - Creates `.cursor/scripts/update-bot/find-migration-guides.sh` — finds `<name>.migration.md` files between versions
12
+
13
+ ## How to use the command
14
+
15
+ 1. In Cursor, type `/update-bot` in the chat input and run it
16
+ 2. The command discovers your bots, lets you pick one, and runs `nx migrate` one version at a time
17
+ 3. For each version step, it reads any migration guide (`<name>.migration.md`) and guides you through verification
18
+
19
+ ## Verification checklist
20
+
21
+ - [ ] `.cursor/commands/update-bot.md` exists
22
+ - [ ] Run `bash .cursor/scripts/update-bot/discover-bots.sh` from workspace root — returns JSON list of bots (or `[]` if none)
23
+ - [ ] Run `bash .cursor/scripts/update-bot/find-migration-guides.sh 0.0.0 999.0.0` — returns JSON array (may be empty)
@@ -0,0 +1,5 @@
1
+ # Update Botonic Bot
2
+
3
+ Applies pending bot-app migrations from `.botonic/pending-bot-migrations.json` to a single bot.
4
+
5
+ Follow the full workflow in: `node_modules/@botonic/nx-plugin/src/cursor-commands/update-bot.md`
@@ -0,0 +1,5 @@
1
+ # Update Botonic Workspace
2
+
3
+ Updates the Botonic plugin to the latest version and queues pending bot-app migrations.
4
+
5
+ Follow the full workflow in: `node_modules/@botonic/nx-plugin/src/cursor-commands/update-botonic.md`
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ # Discovers botonic bot apps and their current versions.
3
+ # Uses nx show projects with tag:botonic:bot-app filter.
4
+ # Run from workspace root. Output: JSON array of { name, path, version }.
5
+ # Usage: bash .cursor/scripts/update-bot/discover-bots.sh
6
+
7
+ set -euo pipefail
8
+
9
+ # Ensure we're in workspace root (contains apps/ or nx.json)
10
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
+ GIT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
12
+ REL_ROOT="$(cd "$SCRIPT_DIR/../../../" && pwd)"
13
+ if [[ -n "$GIT_ROOT" ]] && [[ -f "$GIT_ROOT/nx.json" ]]; then
14
+ ROOT="$GIT_ROOT"
15
+ elif [[ -d "$REL_ROOT/apps" ]] || [[ -f "$REL_ROOT/nx.json" ]]; then
16
+ ROOT="$REL_ROOT"
17
+ else
18
+ ROOT="${GIT_ROOT:-.}"
19
+ fi
20
+ cd "$ROOT"
21
+
22
+ # List bot apps via nx (tag:botonic:bot-app)
23
+ # Nx may print plugin messages to stdout; use tail -1 to get JSON only
24
+ names=$(npx nx show projects --projects "tag:botonic:bot-app" --json 2>/dev/null | tail -1 || echo "[]")
25
+ if [[ "$names" == "[]" ]] || [[ -z "$names" ]]; then
26
+ echo "[]"
27
+ exit 0
28
+ fi
29
+
30
+ bots='[]'
31
+ for name in $(echo "$names" | node -e "
32
+ try {
33
+ const arr = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8'));
34
+ (Array.isArray(arr) ? arr : []).forEach(n => console.log(n));
35
+ } catch {}
36
+ "); do
37
+ [[ -z "$name" ]] && continue
38
+
39
+ path="$name"
40
+ if root=$(npx nx show project "$name" --json 2>/dev/null | tail -1 | node -e "try { const d=JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')); process.stdout.write(d.root||''); } catch {}"); then
41
+ [[ -n "$root" ]] && path="$root"
42
+ else
43
+ path="apps/$name"
44
+ fi
45
+
46
+ version="unknown"
47
+ pkg="$ROOT/$path/package.json"
48
+ if [[ -f "$pkg" ]]; then
49
+ version=$(node -e "
50
+ try {
51
+ const p = require('$pkg');
52
+ const v = p.dependencies?.['@botonic/core']
53
+ || p.dependencies?.['@botonic/webchat-react']
54
+ || 'unknown';
55
+ console.log(String(v).replace(/^[\^~]/, ''));
56
+ } catch { console.log('unknown'); }
57
+ " 2>/dev/null || echo "unknown")
58
+ fi
59
+
60
+ bots=$(echo "$bots" | node -e "
61
+ const b = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8'));
62
+ b.push({ name: process.argv[1], path: process.argv[2], version: process.argv[3] });
63
+ console.log(JSON.stringify(b, null, 2));
64
+ " "$name" "$path" "$version")
65
+ done
66
+
67
+ echo "$bots"
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env bash
2
+ # Finds <name>.migration.md files for migrations between two versions.
3
+ # Reads node_modules/@botonic/nx-plugin/migrations.json (published, real semver).
4
+ # Usage: find-migration-guides.sh <from-version> <to-version>
5
+ # Output: JSON array of { version, migrations: [{ name, migrationGuide }] } grouped by unique version
6
+
7
+ set -euo pipefail
8
+
9
+ FROM_VERSION="${1:?Usage: find-migration-guides.sh <from> <to>}"
10
+ TO_VERSION="${2:?Usage: find-migration-guides.sh <from> <to>}"
11
+
12
+ # Run from workspace root
13
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
+ GIT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
15
+ REL_ROOT="$(cd "$SCRIPT_DIR/../../../" && pwd)"
16
+ if [[ -n "$GIT_ROOT" ]] && [[ -f "$GIT_ROOT/nx.json" ]]; then
17
+ ROOT="$GIT_ROOT"
18
+ elif [[ -f "$REL_ROOT/nx.json" ]] || [[ -f "$REL_ROOT/node_modules/@botonic/nx-plugin/migrations.json" ]]; then
19
+ ROOT="$REL_ROOT"
20
+ else
21
+ ROOT="${GIT_ROOT:-$REL_ROOT}"
22
+ fi
23
+ cd "$ROOT"
24
+
25
+ MIGRATIONS_JSON="node_modules/@botonic/nx-plugin/migrations.json"
26
+ MIGRATIONS_DIR="node_modules/@botonic/nx-plugin/src/migrations"
27
+
28
+ if [ ! -f "$MIGRATIONS_JSON" ]; then
29
+ echo '{"error": "migrations.json not found. Run pnpm install first."}' >&2
30
+ exit 1
31
+ fi
32
+
33
+ node -e "
34
+ const fs = require('fs');
35
+ const path = require('path');
36
+ let semver;
37
+ try { semver = require('semver'); } catch { semver = null; }
38
+
39
+ const mj = JSON.parse(fs.readFileSync('$MIGRATIONS_JSON', 'utf8'));
40
+ const generators = mj.generators || {};
41
+ const from = '$FROM_VERSION';
42
+ const to = '$TO_VERSION';
43
+ const migrationsDir = path.resolve('$MIGRATIONS_DIR');
44
+
45
+ const valid = (v) => semver ? semver.valid(v) : /^\\d+\\.\\d+\\.\\d+$/.test(v);
46
+ const gt = (a, b) => semver ? semver.gt(a, b) : a !== b;
47
+ const lte = (a, b) => semver ? semver.lte(a, b) : true;
48
+ const compare = (a, b) => semver ? semver.compare(a, b) : 0;
49
+
50
+ const entries = Object.entries(generators)
51
+ .filter(([, cfg]) => valid(cfg.version) && gt(cfg.version, from) && lte(cfg.version, to))
52
+ .sort(([, a], [, b]) => compare(a.version, b.version));
53
+
54
+ const byVersion = new Map();
55
+ for (const [name, cfg] of entries) {
56
+ const guideFile = path.join(migrationsDir, name, \`\${name}.migration.md\`);
57
+ const migrationGuide = fs.existsSync(guideFile) ? guideFile : null;
58
+ if (!byVersion.has(cfg.version)) {
59
+ byVersion.set(cfg.version, []);
60
+ }
61
+ byVersion.get(cfg.version).push({ name, migrationGuide });
62
+ }
63
+
64
+ const results = Array.from(byVersion.entries()).map(([version, migrations]) => ({
65
+ version,
66
+ migrations
67
+ }));
68
+
69
+ console.log(JSON.stringify(results, null, 2));
70
+ "
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "type": "object",
4
+ "properties": {}
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function addLilaraRegistry(tree: Tree): Promise<void>;
@@ -0,0 +1,49 @@
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 add_lilara_registry_migration_exports = {};
20
+ __export(add_lilara_registry_migration_exports, {
21
+ default: () => addLilaraRegistry
22
+ });
23
+ module.exports = __toCommonJS(add_lilara_registry_migration_exports);
24
+ var import_devkit = require("@nx/devkit");
25
+ const NPMRC = ".npmrc";
26
+ const BOTONIC_REGISTRY_PREFIX = "@botonic:registry=";
27
+ const LILARA_REGISTRY_LINE = "@lilara:registry=https://hubtype-489822642696.d.codeartifact.eu-west-1.amazonaws.com/npm/hubtype-internal/";
28
+ async function addLilaraRegistry(tree) {
29
+ if (!tree.exists(NPMRC)) {
30
+ import_devkit.logger.info(`\u2139\uFE0F ${NPMRC} not found \u2013 skipping`);
31
+ return;
32
+ }
33
+ const content = tree.read(NPMRC, "utf-8") ?? "";
34
+ if (content.includes("@lilara:registry=")) {
35
+ import_devkit.logger.info("\u2139\uFE0F @lilara:registry already present \u2013 skipping");
36
+ return;
37
+ }
38
+ const lines = content.split("\n");
39
+ const botonicIdx = lines.findIndex((l) => l.startsWith(BOTONIC_REGISTRY_PREFIX));
40
+ let newContent;
41
+ if (botonicIdx !== -1) {
42
+ lines.splice(botonicIdx + 1, 0, LILARA_REGISTRY_LINE);
43
+ newContent = lines.join("\n");
44
+ } else {
45
+ newContent = content + (content.endsWith("\n") ? "" : "\n") + LILARA_REGISTRY_LINE + "\n";
46
+ }
47
+ tree.write(NPMRC, newContent);
48
+ import_devkit.logger.info(`\u2705 Added @lilara:registry to ${NPMRC}`);
49
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "type": "object",
4
+ "properties": {}
5
+ }
@@ -0,0 +1,45 @@
1
+ # Fix CSS Code Split Migration
2
+
3
+ ## Summary
4
+
5
+ Vite generates multiple CSS chunks when code splitting is enabled. Only the main `webchat.botonic.css` (or `webviews.botonic.css`) is injected into `index.html`; secondary chunks like `webchat.botonic-[hash].css` are not referenced, causing styles to fail loading after build.
6
+
7
+ This migration adds `cssCodeSplit: false` to the vite build config so all CSS is merged into a single file that Vite injects correctly.
8
+
9
+ ## What the automated migration does
10
+
11
+ - Adds `cssCodeSplit: false` to `vite/webchat.config.ts` build options
12
+ - Adds `cssCodeSplit: false` to `vite/webviews.config.ts` build options
13
+ - Skips files that already have `cssCodeSplit` configured
14
+
15
+ ## What it cannot handle
16
+
17
+ - Bots with non-standard vite config layout (e.g. config in a different path)
18
+ - Custom build setups that override rollup CSS output
19
+ - Bots that intentionally use multiple CSS entry points
20
+
21
+ ## Manual migration steps
22
+
23
+ If your bot has customized the vite config or the migration skips your project:
24
+
25
+ 1. Open `vite/webchat.config.ts` and `vite/webviews.config.ts`
26
+ 2. In the `build` section, add `cssCodeSplit: false,` after `reportCompressedSize: true,`
27
+ 3. Example:
28
+
29
+ ```ts
30
+ build: {
31
+ outDir: resolve(projectRoot, output.dir),
32
+ emptyOutDir: true,
33
+ reportCompressedSize: true,
34
+ cssCodeSplit: false, // add this line
35
+ commonjsOptions: { ... },
36
+ ...
37
+ }
38
+ ```
39
+
40
+ ## Verification checklist
41
+
42
+ - [ ] Run `nx build <your-bot>` for webchat and webviews
43
+ - [ ] Inspect `dist/webchat/` and `dist/webviews/` — expect single `webchat.botonic.css` and `webviews.botonic.css`
44
+ - [ ] Run `nx serve-bot <your-bot>` and verify styles render correctly
45
+ - [ ] Deploy to staging and confirm no missing CSS in production
@@ -0,0 +1,2 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export default function removeCodeartifactRegistry(tree: Tree): Promise<void>;
@@ -0,0 +1,59 @@
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 remove_codeartifact_registry_migration_exports = {};
20
+ __export(remove_codeartifact_registry_migration_exports, {
21
+ default: () => removeCodeartifactRegistry
22
+ });
23
+ module.exports = __toCommonJS(remove_codeartifact_registry_migration_exports);
24
+ var import_devkit = require("@nx/devkit");
25
+ const NPMRC = ".npmrc";
26
+ function isCodeArtifactScopedRegistryLine(line) {
27
+ const t = line.trim();
28
+ if (!t.startsWith("@botonic:registry=") && !t.startsWith("@hubtype-lilara:registry=")) {
29
+ return false;
30
+ }
31
+ return t.toLowerCase().includes("codeartifact");
32
+ }
33
+ function isCodeArtifactAuthLine(line) {
34
+ const t = line.trim();
35
+ if (!t.toLowerCase().includes("codeartifact")) return false;
36
+ return t.includes(":always-auth=") || t.includes(":_authToken=");
37
+ }
38
+ async function removeCodeartifactRegistry(tree) {
39
+ if (!tree.exists(NPMRC)) {
40
+ import_devkit.logger.info(`\u2139\uFE0F ${NPMRC} not found \u2013 skipping`);
41
+ return;
42
+ }
43
+ const content = tree.read(NPMRC, "utf-8") ?? "";
44
+ const lines = content.split("\n");
45
+ const kept = lines.filter(
46
+ (l) => !isCodeArtifactScopedRegistryLine(l) && !isCodeArtifactAuthLine(l)
47
+ );
48
+ if (kept.length === lines.length) {
49
+ import_devkit.logger.info("\u2139\uFE0F No CodeArtifact entries in .npmrc \u2013 skipping");
50
+ return;
51
+ }
52
+ let newContent = kept.join("\n");
53
+ while (newContent.includes("\n\n\n")) {
54
+ newContent = newContent.replace(/\n\n\n/g, "\n\n");
55
+ }
56
+ if (!newContent.endsWith("\n")) newContent += "\n";
57
+ tree.write(NPMRC, newContent);
58
+ import_devkit.logger.info(`\u2705 Removed CodeArtifact registry lines from ${NPMRC}`);
59
+ }