@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,27 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "sourceMap": true,
6
+ "declaration": false,
7
+ "moduleResolution": "node",
8
+ "emitDecoratorMetadata": true,
9
+ "experimentalDecorators": true,
10
+ "importHelpers": true,
11
+ "target": "es2015",
12
+ "module": "esnext",
13
+ "lib": ["es2020", "dom"],
14
+ "skipLibCheck": true,
15
+ "skipDefaultLibCheck": true,
16
+ "baseUrl": ".",
17
+ "strict": true,
18
+ "esModuleInterop": true,
19
+ "allowSyntheticDefaultImports": true,
20
+ "forceConsistentCasingInFileNames": true,
21
+ "resolveJsonModule": true,
22
+ "isolatedModules": true,
23
+ "noEmit": true,
24
+ "jsx": "react-jsx"
25
+ },
26
+ "exclude": ["node_modules", "tmp"]
27
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "sourceMap": true,
6
+ "declaration": false,
7
+ "moduleResolution": "bundler",
8
+ "emitDecoratorMetadata": true,
9
+ "experimentalDecorators": true,
10
+ "importHelpers": true,
11
+ "target": "es2015",
12
+ "module": "esnext",
13
+ "lib": ["es2021", "dom", "dom.iterable"],
14
+ "skipLibCheck": true,
15
+ "skipDefaultLibCheck": true,
16
+ "baseUrl": ".",
17
+ "strict": true,
18
+ "esModuleInterop": true,
19
+ "allowSyntheticDefaultImports": true,
20
+ "forceConsistentCasingInFileNames": true,
21
+ "resolveJsonModule": true,
22
+ "isolatedModules": true,
23
+ "noEmit": true,
24
+ "jsx": "react-jsx"
25
+ },
26
+ "exclude": ["node_modules", "tmp"]
27
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compileOnSave": false,
4
+ "files": [],
5
+ "references": [
6
+ // Project references will be automatically managed by Nx
7
+ // Use 'nx sync' to keep them updated
8
+ ]
9
+ }
@@ -0,0 +1,4 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import type { PresetGeneratorSchema } from './schema';
3
+ export default function (tree: Tree, options: PresetGeneratorSchema): Promise<GeneratorCallback>;
4
+ export { PresetGeneratorSchema };
@@ -0,0 +1,127 @@
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 generator_exports = {};
30
+ __export(generator_exports, {
31
+ default: () => generator_default
32
+ });
33
+ module.exports = __toCommonJS(generator_exports);
34
+ var import_devkit = require("@nx/devkit");
35
+ var fs = __toESM(require("fs"));
36
+ var path = __toESM(require("path"));
37
+ const MODULE_DIR = __dirname;
38
+ function resolveBotonicVersion(providedVersion) {
39
+ if (providedVersion && providedVersion !== "{{WORKSPACE_VERSION}}" && providedVersion !== "latest") {
40
+ return providedVersion.replace(/^[\^~]/, "");
41
+ }
42
+ try {
43
+ const packageJsonPath = path.resolve(
44
+ MODULE_DIR,
45
+ "..",
46
+ "..",
47
+ "..",
48
+ "package.json"
49
+ );
50
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
51
+ return packageJson.version || "latest";
52
+ } catch (error) {
53
+ console.warn("Could not read plugin version, using latest:", error);
54
+ return "latest";
55
+ }
56
+ }
57
+ function normalizeOptions(options) {
58
+ return {
59
+ ...options,
60
+ name: options.name,
61
+ nxWorkspaceRoot: options.nxWorkspaceRoot || ".",
62
+ packageManager: options.packageManager || "pnpm",
63
+ botonicVersion: resolveBotonicVersion(options.botonicVersion)
64
+ };
65
+ }
66
+ async function generator_default(tree, options) {
67
+ const normalizedOptions = normalizeOptions(options);
68
+ const tasks = [];
69
+ console.log("Configuring existing TypeScript workspace with Botonic...");
70
+ (0, import_devkit.generateFiles)(
71
+ tree,
72
+ path.join(MODULE_DIR, "files"),
73
+ normalizedOptions.nxWorkspaceRoot,
74
+ {
75
+ ...normalizedOptions,
76
+ template: ""
77
+ }
78
+ );
79
+ if (normalizedOptions.packageManager === "pnpm") {
80
+ const pnpmWorkspacePath = path.join(
81
+ normalizedOptions.nxWorkspaceRoot,
82
+ "pnpm-workspace.yaml"
83
+ );
84
+ if (tree.exists(pnpmWorkspacePath)) {
85
+ const content = tree.read(pnpmWorkspacePath, "utf-8") ?? "";
86
+ if (!/apps\/\*/.test(content)) {
87
+ const updated = content.replace(
88
+ /([ \t]*- ["']?packages\/\*["']?)/,
89
+ '$1\n - "apps/*"'
90
+ );
91
+ tree.write(pnpmWorkspacePath, updated);
92
+ }
93
+ }
94
+ }
95
+ const gitignorePath = path.join(
96
+ normalizedOptions.nxWorkspaceRoot,
97
+ ".gitignore"
98
+ );
99
+ if (tree.exists(gitignorePath)) {
100
+ const content = tree.read(gitignorePath, "utf-8") ?? "";
101
+ if (!/\.botonic\//.test(content)) {
102
+ const botonicSection = content.trimEnd().length > 0 ? `
103
+
104
+ # Botonic (global credentials)
105
+ .botonic/
106
+ ` : `# Botonic (global credentials)
107
+ .botonic/
108
+ `;
109
+ tree.write(gitignorePath, content.trimEnd() + botonicSection);
110
+ }
111
+ } else {
112
+ tree.write(gitignorePath, "# Botonic (global credentials)\n.botonic/\n");
113
+ }
114
+ (0, import_devkit.updateJson)(
115
+ tree,
116
+ path.join(normalizedOptions.nxWorkspaceRoot, "package.json"),
117
+ (json) => {
118
+ json["dependencies"] ??= {};
119
+ json["devDependencies"] ??= {};
120
+ json["dependencies"]["@nx/react"] = "latest";
121
+ json["devDependencies"]["@botonic/nx-plugin"] = normalizedOptions.botonicVersion;
122
+ return json;
123
+ }
124
+ );
125
+ await (0, import_devkit.formatFiles)(tree);
126
+ return (0, import_devkit.runTasksInSerial)(...tasks);
127
+ }
@@ -0,0 +1,6 @@
1
+ export interface PresetGeneratorSchema {
2
+ name: string;
3
+ packageManager?: 'pnpm' | 'npm';
4
+ nxWorkspaceRoot?: string;
5
+ botonicVersion?: string;
6
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var schema_exports = {};
16
+ module.exports = __toCommonJS(schema_exports);
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema",
3
+ "cli": "nx",
4
+ "$id": "BotonicPreset",
5
+ "title": "Create a Botonic Workspace",
6
+ "description": "Initialize a new workspace for Botonic bot development",
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "type": "string",
11
+ "description": "The name of the workspace",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "What name would you like to use for the workspace?"
17
+ },
18
+ "packageManager": {
19
+ "type": "string",
20
+ "description": "Package manager to use",
21
+ "default": "pnpm",
22
+ "enum": ["npm", "pnpm"],
23
+ "x-prompt": {
24
+ "message": "Which package manager would you like to use?",
25
+ "type": "list",
26
+ "items": [
27
+ {
28
+ "value": "npm",
29
+ "label": "npm"
30
+ },
31
+ {
32
+ "value": "pnpm",
33
+ "label": "pnpm"
34
+ }
35
+ ]
36
+ }
37
+ },
38
+ "nxWorkspaceRoot": {
39
+ "type": "string",
40
+ "description": "Path to the root of the nx workspace",
41
+ "default": "."
42
+ },
43
+ "botonicVersion": {
44
+ "type": "string",
45
+ "description": "Botonic packages version. Leave empty to use the same version as the installed @botonic/nx-plugin."
46
+ }
47
+ },
48
+ "required": ["name"],
49
+ "additionalProperties": true
50
+ }
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import type { RemoveCustomMessageGeneratorSchema } from './schema';
3
+ export default function (tree: Tree, options: RemoveCustomMessageGeneratorSchema): Promise<void>;
4
+ export { RemoveCustomMessageGeneratorSchema };
@@ -0,0 +1,259 @@
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: () => generator_default
22
+ });
23
+ module.exports = __toCommonJS(generator_exports);
24
+ var import_devkit = require("@nx/devkit");
25
+ function normalizeOptions(tree, options) {
26
+ const projects = (0, import_devkit.getProjects)(tree);
27
+ const project = projects.get(options.project);
28
+ if (!project) {
29
+ throw new Error(`Project "${options.project}" not found`);
30
+ }
31
+ if (!project.tags?.includes("botonic:bot-app")) {
32
+ throw new Error(
33
+ `Project "${options.project}" is not a botonic bot application. Make sure it has the "botonic:bot-app" tag.`
34
+ );
35
+ }
36
+ const projectConfig = (0, import_devkit.readProjectConfiguration)(tree, options.project);
37
+ const projectRoot = projectConfig.root;
38
+ const sourceRoot = projectConfig.sourceRoot || `${projectRoot}/src`;
39
+ const name = (0, import_devkit.names)(options.name);
40
+ const fileName = name.fileName;
41
+ const className = name.className;
42
+ const propertyName = name.propertyName;
43
+ const constantName = name.constantName.toUpperCase();
44
+ const customMessagesPath = options.directory ? `${sourceRoot}/client/custom-messages/${options.directory}` : `${sourceRoot}/client/custom-messages`;
45
+ const configPath = `${sourceRoot}/shared/constants.ts`;
46
+ const actionsPath = `${sourceRoot}/server/bot/actions`;
47
+ const routesPath = `${sourceRoot}/server/bot/routes.ts`;
48
+ return {
49
+ ...options,
50
+ projectName: options.project,
51
+ projectRoot,
52
+ fileName,
53
+ className,
54
+ propertyName,
55
+ constantName,
56
+ customMessagesPath,
57
+ configPath,
58
+ actionsPath,
59
+ routesPath
60
+ };
61
+ }
62
+ function removeFiles(tree, options) {
63
+ const filesToRemove = [
64
+ `${options.customMessagesPath}/${options.fileName}.tsx`,
65
+ `${options.customMessagesPath}/${options.fileName}.spec.tsx`,
66
+ `${options.actionsPath}/${options.fileName}.ts`
67
+ ];
68
+ const removedFiles = [];
69
+ const notFoundFiles = [];
70
+ filesToRemove.forEach((filePath) => {
71
+ if (tree.exists(filePath)) {
72
+ tree.delete(filePath);
73
+ removedFiles.push(filePath);
74
+ } else {
75
+ notFoundFiles.push(filePath);
76
+ }
77
+ });
78
+ return { removedFiles, notFoundFiles };
79
+ }
80
+ function removeFromConfig(tree, options) {
81
+ if (!tree.exists(options.configPath)) {
82
+ console.warn(`Config file not found at ${options.configPath}`);
83
+ return false;
84
+ }
85
+ const content = tree.read(options.configPath, "utf-8");
86
+ const lines = content.split("\n");
87
+ const enumValuePattern = new RegExp(
88
+ `\\s*${options.constantName}\\s*[=:]\\s*['"]${options.fileName}['"],?`
89
+ );
90
+ let found = false;
91
+ const updatedLines = lines.filter((line) => {
92
+ if (enumValuePattern.test(line)) {
93
+ found = true;
94
+ return false;
95
+ }
96
+ return true;
97
+ });
98
+ if (found) {
99
+ tree.write(options.configPath, updatedLines.join("\n"));
100
+ }
101
+ return found;
102
+ }
103
+ function removeFromCustomMessagesIndex(tree, options) {
104
+ const indexPath = `${options.customMessagesPath}/index.ts`;
105
+ if (!tree.exists(indexPath)) {
106
+ console.warn(`Custom messages index not found at ${indexPath}`);
107
+ return false;
108
+ }
109
+ const content = tree.read(indexPath, "utf-8");
110
+ const lines = content.split("\n");
111
+ let found = false;
112
+ const updatedLines = lines.filter((line) => {
113
+ if (line.includes(`import { ${options.className} }`) && line.includes(
114
+ `./${options.directory ? options.directory + "/" : ""}${options.fileName}`
115
+ )) {
116
+ found = true;
117
+ return false;
118
+ }
119
+ if (line.includes(
120
+ `[CUSTOM_MESSAGE_TYPES.${options.constantName}]: ${options.className}`
121
+ )) {
122
+ found = true;
123
+ return false;
124
+ }
125
+ return true;
126
+ });
127
+ if (found) {
128
+ tree.write(indexPath, updatedLines.join("\n"));
129
+ }
130
+ return found;
131
+ }
132
+ function removeFromActionsIndex(tree, options) {
133
+ const indexPath = `${options.actionsPath}/index.ts`;
134
+ if (!tree.exists(indexPath)) {
135
+ console.warn(`Actions index not found at ${indexPath}`);
136
+ return false;
137
+ }
138
+ const content = tree.read(indexPath, "utf-8");
139
+ const exportStatement = `export * from './${options.fileName}'`;
140
+ if (content.includes(exportStatement)) {
141
+ const updatedContent = content.replace(exportStatement + "\n", "").replace(exportStatement, "");
142
+ tree.write(indexPath, updatedContent);
143
+ return true;
144
+ }
145
+ return false;
146
+ }
147
+ function removeFromRoutes(tree, options) {
148
+ if (!tree.exists(options.routesPath)) {
149
+ console.warn(`Routes file not found at ${options.routesPath}`);
150
+ return false;
151
+ }
152
+ const content = tree.read(options.routesPath, "utf-8");
153
+ const lines = content.split("\n");
154
+ const actionImport = `${options.propertyName}Output`;
155
+ let found = false;
156
+ let importStartIndex = -1;
157
+ let importEndIndex = -1;
158
+ for (let i = 0; i < lines.length; i++) {
159
+ if (lines[i].includes("import {") && lines.slice(i, i + 10).some((line) => line.includes("from './actions'"))) {
160
+ importStartIndex = i;
161
+ for (let j = i; j < lines.length; j++) {
162
+ if (lines[j].includes("from './actions'")) {
163
+ importEndIndex = j;
164
+ break;
165
+ }
166
+ }
167
+ break;
168
+ }
169
+ }
170
+ if (importStartIndex !== -1 && importEndIndex !== -1) {
171
+ const importSection = lines.slice(importStartIndex, importEndIndex + 1).join("\n");
172
+ if (importSection.includes(actionImport)) {
173
+ for (let i = importStartIndex; i <= importEndIndex; i++) {
174
+ if (lines[i].includes(actionImport)) {
175
+ if (lines[i].trim() === `${actionImport},` || lines[i].trim() === actionImport) {
176
+ lines.splice(i, 1);
177
+ importEndIndex--;
178
+ } else {
179
+ lines[i] = lines[i].replace(`,\\s*${actionImport}`, "").replace(`${actionImport},`, "").replace(actionImport, "");
180
+ }
181
+ found = true;
182
+ break;
183
+ }
184
+ }
185
+ }
186
+ }
187
+ let routeStartIndex = -1;
188
+ let routeEndIndex = -1;
189
+ for (let i = 0; i < lines.length; i++) {
190
+ if (lines[i].includes(`text: '${options.fileName}'`) && lines[i + 1]?.includes(actionImport)) {
191
+ for (let j = i - 1; j >= 0; j--) {
192
+ if (lines[j].trim() === "{") {
193
+ routeStartIndex = j;
194
+ break;
195
+ }
196
+ }
197
+ for (let j = i + 1; j < lines.length; j++) {
198
+ if (lines[j].includes("},")) {
199
+ routeEndIndex = j;
200
+ break;
201
+ }
202
+ }
203
+ break;
204
+ }
205
+ }
206
+ if (routeStartIndex !== -1 && routeEndIndex !== -1) {
207
+ lines.splice(routeStartIndex, routeEndIndex - routeStartIndex + 1);
208
+ found = true;
209
+ }
210
+ if (found) {
211
+ tree.write(options.routesPath, lines.join("\n"));
212
+ }
213
+ return found;
214
+ }
215
+ async function generator_default(tree, options) {
216
+ console.log(`\u{1F5D1}\uFE0F Removing custom message: ${options.name}`);
217
+ const normalizedOptions = normalizeOptions(tree, options);
218
+ console.log(`\u{1F4C1} Project: ${normalizedOptions.projectName}`);
219
+ console.log(`\u{1F4C2} Location: ${normalizedOptions.customMessagesPath}`);
220
+ if (!options.skipConfirmation) {
221
+ console.log(`
222
+ \u26A0\uFE0F This will remove the following:`);
223
+ console.log(` - Component: ${normalizedOptions.fileName}.tsx`);
224
+ console.log(` - Tests: ${normalizedOptions.fileName}.spec.tsx`);
225
+ console.log(` - Action: ${normalizedOptions.fileName}.ts`);
226
+ console.log(
227
+ ` - Config enum: CUSTOM_MESSAGE_TYPES.${normalizedOptions.constantName}`
228
+ );
229
+ console.log(` - Registration in customMessages object`);
230
+ console.log(` - Route in routes.ts`);
231
+ console.log(`
232
+ Continue? This action cannot be undone.`);
233
+ }
234
+ const { removedFiles, notFoundFiles } = removeFiles(tree, normalizedOptions);
235
+ const configUpdated = removeFromConfig(tree, normalizedOptions);
236
+ const indexUpdated = removeFromCustomMessagesIndex(tree, normalizedOptions);
237
+ const actionsUpdated = removeFromActionsIndex(tree, normalizedOptions);
238
+ const routesUpdated = removeFromRoutes(tree, normalizedOptions);
239
+ await (0, import_devkit.formatFiles)(tree);
240
+ console.log(
241
+ `
242
+ \u{1F389} Successfully removed custom message: ${normalizedOptions.className}`
243
+ );
244
+ if (removedFiles.length > 0) {
245
+ console.log(`\u{1F4C1} Removed files:`);
246
+ removedFiles.forEach((file) => console.log(` - ${file}`));
247
+ }
248
+ if (notFoundFiles.length > 0) {
249
+ console.log(`\u26A0\uFE0F Files not found (skipped):`);
250
+ notFoundFiles.forEach((file) => console.log(` - ${file}`));
251
+ }
252
+ console.log(`\u{1F4DD} Updated configurations:`);
253
+ console.log(` - Config enum: ${configUpdated ? "\u2705" : "\u274C"}`);
254
+ console.log(` - Custom messages index: ${indexUpdated ? "\u2705" : "\u274C"}`);
255
+ console.log(` - Actions index: ${actionsUpdated ? "\u2705" : "\u274C"}`);
256
+ console.log(` - Routes: ${routesUpdated ? "\u2705" : "\u274C"}`);
257
+ console.log(`
258
+ \u{1F680} Custom message removal complete!`);
259
+ }
@@ -0,0 +1,6 @@
1
+ export interface RemoveCustomMessageGeneratorSchema {
2
+ name: string;
3
+ project: string;
4
+ directory?: string;
5
+ skipConfirmation?: boolean;
6
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var schema_exports = {};
16
+ module.exports = __toCommonJS(schema_exports);
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "RemoveCustomMessage",
5
+ "title": "Remove a custom message component from Botonic",
6
+ "description": "Remove a custom message component and clean up all related files and registrations.",
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "type": "string",
11
+ "description": "The name of the custom message component to remove.",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "What is the name of the custom message to remove?",
17
+ "pattern": "^[a-zA-Z].*$"
18
+ },
19
+ "project": {
20
+ "type": "string",
21
+ "description": "The name of the botonic project to remove the custom message from.",
22
+ "x-prompt": "Which botonic project should this custom message be removed from?",
23
+ "$default": {
24
+ "$source": "projectName"
25
+ }
26
+ },
27
+ "directory": {
28
+ "type": "string",
29
+ "description": "The directory within custom-messages where the component is located (optional).",
30
+ "alias": "dir"
31
+ },
32
+ "skipConfirmation": {
33
+ "type": "boolean",
34
+ "description": "Skip the confirmation prompt before removing files.",
35
+ "default": false
36
+ }
37
+ },
38
+ "required": ["name", "project"]
39
+ }
@@ -0,0 +1,25 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export interface BotAppProjectInfo {
3
+ projectRoot: string;
4
+ sourceRoot: string;
5
+ }
6
+ export interface StandardPaths {
7
+ constantsPath: string;
8
+ actionsPath: string;
9
+ routesPath: string;
10
+ customMessagesPath: string;
11
+ webviewsPath: string;
12
+ }
13
+ export declare function validateBotAppProject(tree: Tree, projectName: string): BotAppProjectInfo;
14
+ export declare function resolveStandardPaths(sourceRoot: string): StandardPaths;
15
+ export declare function addExportToIndex(tree: Tree, indexPath: string, exportStatement: string): void;
16
+ export declare function addConstEntry(tree: Tree, filePath: string, constName: string, key: string, value: string): void;
17
+ /**
18
+ * Inserts a route block before the flow-builder catch-all route in routes.ts.
19
+ */
20
+ export declare function insertRouteBeforeFlowBuilder(tree: Tree, routesPath: string, routeLines: string[]): void;
21
+ /**
22
+ * Adds an action import to routes.ts import from './actions'.
23
+ * Handles both single-line and multi-line import blocks.
24
+ */
25
+ export declare function addActionImportToRoutes(tree: Tree, routesPath: string, actionName: string): void;