@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,137 @@
|
|
|
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 sync_pending_bot_migrations_migration_exports = {};
|
|
30
|
+
__export(sync_pending_bot_migrations_migration_exports, {
|
|
31
|
+
default: () => syncPendingBotMigrations
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(sync_pending_bot_migrations_migration_exports);
|
|
34
|
+
var import_devkit = require("@nx/devkit");
|
|
35
|
+
var fs = __toESM(require("fs"));
|
|
36
|
+
var path = __toESM(require("path"));
|
|
37
|
+
var import_migration_utils = require("../utils/migration-utils");
|
|
38
|
+
const MODULE_DIR = __dirname;
|
|
39
|
+
const PENDING_FILE = ".botonic/pending-bot-migrations.json";
|
|
40
|
+
function resolveMigrationGuide(relPath) {
|
|
41
|
+
if (!relPath) return null;
|
|
42
|
+
return `node_modules/@botonic/nx-plugin/${relPath}`;
|
|
43
|
+
}
|
|
44
|
+
function semverLt(a, b) {
|
|
45
|
+
const parse = (v) => v.replace(/^[\^~]/, "").split(".").map(Number);
|
|
46
|
+
const [aMaj, aMin, aPatch] = parse(a);
|
|
47
|
+
const [bMaj, bMin, bPatch] = parse(b);
|
|
48
|
+
if (aMaj !== bMaj) return aMaj < bMaj;
|
|
49
|
+
if (aMin !== bMin) return aMin < bMin;
|
|
50
|
+
return aPatch < bPatch;
|
|
51
|
+
}
|
|
52
|
+
function readBotAppGenerators(moduleDir, pluginVersion) {
|
|
53
|
+
try {
|
|
54
|
+
const generatorsJsonPath = path.resolve(
|
|
55
|
+
moduleDir,
|
|
56
|
+
"..",
|
|
57
|
+
"..",
|
|
58
|
+
"..",
|
|
59
|
+
"generators.json"
|
|
60
|
+
);
|
|
61
|
+
const generatorsJson = JSON.parse(
|
|
62
|
+
fs.readFileSync(generatorsJsonPath, "utf-8")
|
|
63
|
+
);
|
|
64
|
+
return Object.entries(generatorsJson.generators).filter(([, entry]) => entry["x-bot-app-migration"] === true).map(([name, entry]) => {
|
|
65
|
+
const rawIntroducedIn = entry["x-introduced-in"];
|
|
66
|
+
const introducedIn = rawIntroducedIn && rawIntroducedIn !== "{{WORKSPACE_VERSION}}" ? rawIntroducedIn : pluginVersion;
|
|
67
|
+
return {
|
|
68
|
+
generator: `@botonic/nx-plugin:${name}`,
|
|
69
|
+
description: entry.description,
|
|
70
|
+
introducedIn,
|
|
71
|
+
migrationGuideRelPath: entry["x-migration-guide"] ?? null
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
} catch {
|
|
75
|
+
import_devkit.logger.warn(
|
|
76
|
+
"\u26A0\uFE0F Could not read generators.json \u2013 no bot-app generators queued."
|
|
77
|
+
);
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function syncPendingBotMigrations(tree) {
|
|
82
|
+
const pluginVersion = (0, import_migration_utils.getPluginVersion)(MODULE_DIR);
|
|
83
|
+
const BOT_APP_GENERATORS = readBotAppGenerators(MODULE_DIR, pluginVersion);
|
|
84
|
+
const botProjects = (0, import_migration_utils.findBotApps)(tree);
|
|
85
|
+
if (botProjects.length === 0) {
|
|
86
|
+
import_devkit.logger.info(
|
|
87
|
+
"\u2139\uFE0F No Botonic bot apps found. Skipping pending migrations setup."
|
|
88
|
+
);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let pendingMigrations = { pending: [] };
|
|
92
|
+
if (tree.exists(PENDING_FILE)) {
|
|
93
|
+
try {
|
|
94
|
+
pendingMigrations = (0, import_devkit.readJson)(tree, PENDING_FILE);
|
|
95
|
+
} catch {
|
|
96
|
+
import_devkit.logger.warn(`\u26A0\uFE0F Could not parse ${PENDING_FILE}, creating fresh.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const generatorDef of BOT_APP_GENERATORS) {
|
|
100
|
+
const botsNeedingGenerator = botProjects.filter((projectPath) => {
|
|
101
|
+
const botVersion = (0, import_migration_utils.getCurrentBotonicCoreVersion)(tree, projectPath);
|
|
102
|
+
if (!botVersion) return true;
|
|
103
|
+
return semverLt(botVersion, generatorDef.introducedIn);
|
|
104
|
+
});
|
|
105
|
+
if (botsNeedingGenerator.length === 0) continue;
|
|
106
|
+
const existing = pendingMigrations.pending.find(
|
|
107
|
+
(e) => e.generator === generatorDef.generator
|
|
108
|
+
);
|
|
109
|
+
if (existing) {
|
|
110
|
+
import_devkit.logger.info(
|
|
111
|
+
`\u2139\uFE0F ${generatorDef.generator} already in pending list \u2013 skipping.`
|
|
112
|
+
);
|
|
113
|
+
} else {
|
|
114
|
+
pendingMigrations.pending.push({
|
|
115
|
+
version: generatorDef.introducedIn,
|
|
116
|
+
generator: generatorDef.generator,
|
|
117
|
+
description: generatorDef.description,
|
|
118
|
+
migrationGuide: resolveMigrationGuide(
|
|
119
|
+
generatorDef.migrationGuideRelPath
|
|
120
|
+
),
|
|
121
|
+
appliedTo: []
|
|
122
|
+
});
|
|
123
|
+
import_devkit.logger.info(
|
|
124
|
+
`\u2705 Queued ${generatorDef.generator} for ${botsNeedingGenerator.length} bot(s)`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (!tree.exists(".botonic/.gitkeep")) {
|
|
129
|
+
tree.write(".botonic/.gitkeep", "");
|
|
130
|
+
}
|
|
131
|
+
tree.write(PENDING_FILE, JSON.stringify(pendingMigrations, null, 2));
|
|
132
|
+
import_devkit.logger.info("");
|
|
133
|
+
import_devkit.logger.info(
|
|
134
|
+
`\u{1F4CB} ${PENDING_FILE} updated with ${pendingMigrations.pending.length} pending generator(s).`
|
|
135
|
+
);
|
|
136
|
+
import_devkit.logger.info(" Run /update-bot in Cursor to apply them per bot.");
|
|
137
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Sync Pending Bot Migrations
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
This migration sets up the per-bot migration tracking system. It writes `.botonic/pending-bot-migrations.json` listing all bot-app code generators that need to be applied to each bot in the workspace.
|
|
6
|
+
|
|
7
|
+
After this migration runs, use the `/update-bot` Cursor command to apply pending generators to individual bots one at a time.
|
|
8
|
+
|
|
9
|
+
## What the automated migration does
|
|
10
|
+
|
|
11
|
+
- Finds all Botonic bot apps in the workspace (projects tagged `botonic:bot-app`)
|
|
12
|
+
- Determines which bots are behind the current plugin version
|
|
13
|
+
- Writes `.botonic/pending-bot-migrations.json` with the list of generators to apply
|
|
14
|
+
- Does not modify any bot code — code transforms happen when you run `/update-bot`
|
|
15
|
+
|
|
16
|
+
## Verification checklist
|
|
17
|
+
|
|
18
|
+
- [ ] `.botonic/pending-bot-migrations.json` exists in the workspace root
|
|
19
|
+
- [ ] Run `/update-bot` in Cursor and follow the prompts to update each bot
|
package/src/migrations/update-cursor-commands-to-stubs/update-cursor-commands-to-stubs.migration.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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 update_cursor_commands_to_stubs_migration_exports = {};
|
|
20
|
+
__export(update_cursor_commands_to_stubs_migration_exports, {
|
|
21
|
+
default: () => updateCursorCommandsToStubs
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(update_cursor_commands_to_stubs_migration_exports);
|
|
24
|
+
var import_devkit = require("@nx/devkit");
|
|
25
|
+
const STUB_UPDATE_BOT = `# Update Botonic Bot
|
|
26
|
+
|
|
27
|
+
Applies pending bot-app migrations from \`.botonic/pending-bot-migrations.json\` to a single bot.
|
|
28
|
+
|
|
29
|
+
Follow the full workflow in: \`node_modules/@botonic/nx-plugin/src/cursor-commands/update-bot.md\`
|
|
30
|
+
`;
|
|
31
|
+
const STUB_UPDATE_BOTONIC = `# Update Botonic Workspace
|
|
32
|
+
|
|
33
|
+
Updates the Botonic plugin to the latest version and queues pending bot-app migrations.
|
|
34
|
+
|
|
35
|
+
Follow the full workflow in: \`node_modules/@botonic/nx-plugin/src/cursor-commands/update-botonic.md\`
|
|
36
|
+
`;
|
|
37
|
+
const UPDATE_BOT_MD = ".cursor/commands/update-bot.md";
|
|
38
|
+
const UPDATE_BOTONIC_MD = ".cursor/commands/update-botonic.md";
|
|
39
|
+
function isAlreadyStub(content, canonicalRef) {
|
|
40
|
+
return content.includes(canonicalRef);
|
|
41
|
+
}
|
|
42
|
+
async function updateCursorCommandsToStubs(tree) {
|
|
43
|
+
if (tree.exists(UPDATE_BOT_MD)) {
|
|
44
|
+
const content = tree.read(UPDATE_BOT_MD, "utf-8") ?? "";
|
|
45
|
+
if (isAlreadyStub(content, "cursor-commands/update-bot.md")) {
|
|
46
|
+
import_devkit.logger.info("\u2139\uFE0F update-bot.md is already a stub \u2013 skipping");
|
|
47
|
+
} else {
|
|
48
|
+
tree.write(UPDATE_BOT_MD, STUB_UPDATE_BOT);
|
|
49
|
+
import_devkit.logger.info("\u2705 Replaced update-bot.md with stable stub");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (tree.exists(UPDATE_BOTONIC_MD)) {
|
|
53
|
+
const content = tree.read(UPDATE_BOTONIC_MD, "utf-8") ?? "";
|
|
54
|
+
if (isAlreadyStub(content, "cursor-commands/update-botonic.md")) {
|
|
55
|
+
import_devkit.logger.info("\u2139\uFE0F update-botonic.md is already a stub \u2013 skipping");
|
|
56
|
+
} else {
|
|
57
|
+
tree.write(UPDATE_BOTONIC_MD, STUB_UPDATE_BOTONIC);
|
|
58
|
+
import_devkit.logger.info("\u2705 Replaced update-botonic.md with stable stub");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/migrations/update-pnpm-workspace-scripts/update-pnpm-workspace-scripts.migration.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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 update_pnpm_workspace_scripts_migration_exports = {};
|
|
20
|
+
__export(update_pnpm_workspace_scripts_migration_exports, {
|
|
21
|
+
default: () => updatePnpmWorkspaceScripts
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(update_pnpm_workspace_scripts_migration_exports);
|
|
24
|
+
var import_devkit = require("@nx/devkit");
|
|
25
|
+
const FIND_MIGRATION_GUIDES = ".cursor/scripts/update-bot/find-migration-guides.sh";
|
|
26
|
+
async function updatePnpmWorkspaceScripts(tree) {
|
|
27
|
+
if (!tree.exists(FIND_MIGRATION_GUIDES)) {
|
|
28
|
+
import_devkit.logger.info(
|
|
29
|
+
`\u2139\uFE0F ${FIND_MIGRATION_GUIDES} not found \u2013 skipping pnpm script update`
|
|
30
|
+
);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const content = tree.read(FIND_MIGRATION_GUIDES, "utf-8");
|
|
34
|
+
if (!content || !content.includes("npm install")) {
|
|
35
|
+
import_devkit.logger.info(
|
|
36
|
+
`\u2139\uFE0F ${FIND_MIGRATION_GUIDES} already references pnpm \u2013 skipping`
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
tree.write(
|
|
41
|
+
FIND_MIGRATION_GUIDES,
|
|
42
|
+
content.replace(/npm install/g, "pnpm install")
|
|
43
|
+
);
|
|
44
|
+
import_devkit.logger.info(
|
|
45
|
+
`\u2705 Updated ${FIND_MIGRATION_GUIDES} to reference pnpm instead of npm`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for file transformation results with renaming support
|
|
4
|
+
* This is a common pattern for migrations that transform files and potentially rename them
|
|
5
|
+
* Nx doesn't provide this pattern, so we create our own reusable interface
|
|
6
|
+
*/
|
|
7
|
+
export interface ActionTransformResult {
|
|
8
|
+
transformed: boolean;
|
|
9
|
+
newContent: string;
|
|
10
|
+
shouldRename?: boolean;
|
|
11
|
+
newFileName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Update Botonic dependencies to a specific version across the workspace or specific project
|
|
15
|
+
* @param tree - The file system tree
|
|
16
|
+
* @param targetVersion - The target version for Botonic dependencies
|
|
17
|
+
* @param projectPath - Optional project path, if not provided updates workspace root
|
|
18
|
+
* @returns GeneratorCallback for the dependency update task
|
|
19
|
+
*/
|
|
20
|
+
export declare function updateBotonicDependencies(tree: Tree, targetVersion: string, projectPath: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get the current @botonic/core version from a project's package.json
|
|
23
|
+
*/
|
|
24
|
+
export declare function getCurrentBotonicCoreVersion(tree: Tree, projectPath: string): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Get the target migration version from migrations.json
|
|
27
|
+
*/
|
|
28
|
+
export declare function getMigrationTargetVersion(tree: Tree, migrationName: string): string | null;
|
|
29
|
+
export declare function findBotApps(tree: Tree): string[];
|
|
30
|
+
export interface ProjectSelectionOptions {
|
|
31
|
+
projects?: string[];
|
|
32
|
+
skipPrompt?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ProjectChoice {
|
|
35
|
+
name: string;
|
|
36
|
+
message: string;
|
|
37
|
+
hint?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Interface for migration-specific project processing functions
|
|
41
|
+
*/
|
|
42
|
+
export interface ProjectProcessor {
|
|
43
|
+
(tree: Tree, projectPath: string, targetBotonicVersion: string): Promise<{
|
|
44
|
+
transformed: boolean;
|
|
45
|
+
filesChanged: number;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration object for runBotonicMigration function
|
|
50
|
+
*/
|
|
51
|
+
export interface BotonicMigrationConfig {
|
|
52
|
+
/** The file system tree */
|
|
53
|
+
tree: Tree;
|
|
54
|
+
/** Project selection options (projects array, skipPrompt flag) */
|
|
55
|
+
options: ProjectSelectionOptions;
|
|
56
|
+
/** Migration key used in migrations.json (e.g., 'modernize-bot-actions') */
|
|
57
|
+
migrationKey: string;
|
|
58
|
+
/** Human-readable migration name for logging */
|
|
59
|
+
migrationName: string;
|
|
60
|
+
/** Function to process each project */
|
|
61
|
+
processProject: ProjectProcessor;
|
|
62
|
+
/** Function to generate success messages */
|
|
63
|
+
getSuccessMessage: (targetVersion: string) => string[];
|
|
64
|
+
/** Optional: Skip dependency updates (defaults to false) */
|
|
65
|
+
skipDependencyUpdates?: boolean;
|
|
66
|
+
/** Optional: Custom success message title (defaults to "Migration completed!") */
|
|
67
|
+
successTitle?: string;
|
|
68
|
+
/** Optional: Additional steps to show in the summary */
|
|
69
|
+
additionalSteps?: string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Helper function to create a BotonicMigrationConfig object with type safety
|
|
73
|
+
*/
|
|
74
|
+
export declare function createBotonicMigrationConfig(config: BotonicMigrationConfig): BotonicMigrationConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Helper function to create a simple project processor for file-based migrations
|
|
77
|
+
*/
|
|
78
|
+
export declare function createFileProcessor(fileProcessors: Array<{
|
|
79
|
+
filePath: (projectPath: string) => string;
|
|
80
|
+
shouldProcess: (tree: Tree, filePath: string) => boolean;
|
|
81
|
+
processFile: (tree: Tree, filePath: string, content: string, targetVersion: string) => {
|
|
82
|
+
transformed: boolean;
|
|
83
|
+
newContent?: string;
|
|
84
|
+
logMessage?: string;
|
|
85
|
+
};
|
|
86
|
+
}>): ProjectProcessor;
|
|
87
|
+
/**
|
|
88
|
+
* Common migration wrapper that handles the standard migration pattern:
|
|
89
|
+
* 1. Project selection
|
|
90
|
+
* 2. Version resolution
|
|
91
|
+
* 3. Project processing with dependency updates
|
|
92
|
+
* 4. Summary and task execution
|
|
93
|
+
*/
|
|
94
|
+
export declare function runBotonicMigration(config: BotonicMigrationConfig): Promise<GeneratorCallback | void>;
|
|
95
|
+
/**
|
|
96
|
+
* Reusable function to select bot projects for migration with interactive prompts
|
|
97
|
+
* @param tree - The file system tree
|
|
98
|
+
* @param options - Project selection options (projects array, skipPrompt flag)
|
|
99
|
+
* @param migrationName - Name of the migration (for logging)
|
|
100
|
+
* @param migrationKey - Key used in migrations.json (e.g., 'modernize-bot-actions')
|
|
101
|
+
* @returns Array of selected project paths
|
|
102
|
+
*/
|
|
103
|
+
export declare function selectBotProjectsForMigration(tree: Tree, options: ProjectSelectionOptions, migrationName: string, migrationKey?: string): Promise<string[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Reads the nx-plugin's own version from its package.json.
|
|
106
|
+
* Pass __dirname (or MODULE_DIR) from the calling file so the path resolves
|
|
107
|
+
* correctly regardless of where in the source tree the caller lives.
|
|
108
|
+
*/
|
|
109
|
+
export declare function getPluginVersion(moduleDir: string): string;
|