@botonic/nx-plugin 2.31.0 → 2.32.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +1 -8
- package/package.json +7 -4
- package/src/executors/build-node-app/executor-impl.d.ts +5 -0
- package/src/executors/build-node-app/executor-impl.js +65 -0
- package/src/executors/build-node-app/executor.d.ts +4 -2
- package/src/executors/build-node-app/executor.js +3 -41
- package/src/executors/delete-bot/executor-impl.d.ts +5 -0
- package/src/executors/delete-bot/executor-impl.js +110 -0
- package/src/executors/delete-bot/executor.d.ts +4 -2
- package/src/executors/delete-bot/executor.js +3 -86
- package/src/executors/deploy-netlify-snapshot/executor-impl.d.ts +8 -0
- package/src/executors/deploy-netlify-snapshot/executor-impl.js +79 -0
- package/src/executors/deploy-netlify-snapshot/executor.d.ts +4 -5
- package/src/executors/deploy-netlify-snapshot/executor.js +3 -55
- package/src/executors/deploy-to-hubtype/executor-impl.d.ts +5 -0
- package/src/executors/deploy-to-hubtype/executor-impl.js +172 -0
- package/src/executors/deploy-to-hubtype/executor.d.ts +4 -2
- package/src/executors/deploy-to-hubtype/executor.js +3 -148
- package/src/executors/e2e-webchat/executor-impl.d.ts +5 -0
- package/src/executors/e2e-webchat/executor-impl.js +134 -0
- package/src/executors/e2e-webchat/executor.d.ts +4 -2
- package/src/executors/e2e-webchat/executor.js +4 -111
- package/src/executors/integrate-provider/executor-impl.d.ts +5 -0
- package/src/executors/integrate-provider/executor-impl.js +153 -0
- package/src/executors/integrate-provider/executor.d.ts +4 -2
- package/src/executors/integrate-provider/executor.js +3 -129
- package/src/executors/login-to-hubtype/executor-impl.d.ts +5 -0
- package/src/executors/login-to-hubtype/executor-impl.js +77 -0
- package/src/executors/login-to-hubtype/executor.d.ts +4 -2
- package/src/executors/login-to-hubtype/executor.js +3 -53
- package/src/executors/logout-from-hubtype/executor-impl.d.ts +3 -0
- package/src/executors/logout-from-hubtype/executor-impl.js +54 -0
- package/src/executors/logout-from-hubtype/executor.d.ts +5 -1
- package/src/executors/logout-from-hubtype/executor.js +3 -30
- package/src/executors/run-lambda/executor-impl.d.ts +5 -0
- package/src/executors/run-lambda/executor-impl.js +65 -0
- package/src/executors/run-lambda/executor.d.ts +4 -2
- package/src/executors/run-lambda/executor.js +3 -41
- package/src/executors/serve-bot/executor-impl.d.ts +5 -0
- package/src/executors/serve-bot/executor-impl.js +530 -0
- package/src/executors/serve-bot/executor.d.ts +4 -2
- package/src/executors/serve-bot/executor.js +3 -506
- package/src/generators/action/generator-impl.d.ts +4 -0
- package/src/generators/action/generator-impl.js +112 -0
- package/src/generators/action/generator.d.ts +2 -3
- package/src/generators/action/generator.js +2 -87
- package/src/generators/bot-app/files/vite/webchat.config.ts.template +10 -2
- package/src/generators/bot-app/generator-impl.d.ts +4 -0
- package/src/generators/bot-app/generator-impl.js +328 -0
- package/src/generators/bot-app/generator.d.ts +2 -4
- package/src/generators/bot-app/generator.js +2 -295
- package/src/generators/custom-message/generator-impl.d.ts +4 -0
- package/src/generators/custom-message/generator-impl.js +235 -0
- package/src/generators/custom-message/generator.d.ts +2 -3
- package/src/generators/custom-message/generator.js +2 -210
- package/src/generators/preset/generator-impl.d.ts +4 -0
- package/src/generators/preset/generator-impl.js +127 -0
- package/src/generators/preset/generator.d.ts +2 -4
- package/src/generators/preset/generator.js +2 -95
- package/src/generators/remove-custom-message/generator-impl.d.ts +4 -0
- package/src/generators/remove-custom-message/generator-impl.js +259 -0
- package/src/generators/remove-custom-message/generator.d.ts +2 -3
- package/src/generators/remove-custom-message/generator.js +2 -234
- package/src/generators/webview/generator-impl.d.ts +4 -0
- package/src/generators/webview/generator-impl.js +179 -0
- package/src/generators/webview/generator.d.ts +2 -3
- package/src/generators/webview/generator.js +2 -154
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/lib/delegate/delegate-executor.d.ts +6 -0
- package/src/lib/delegate/delegate-executor.js +119 -0
- package/src/lib/delegate/delegate-generator.d.ts +2 -0
- package/src/lib/delegate/delegate-generator.js +128 -0
- package/src/lib/serve-mode/index.d.ts +25 -0
- package/src/lib/serve-mode/index.js +183 -0
- package/src/generators/bot-app/files/vite/plugins/dev-log-viewer-html.plugin.ts.template +0 -65
- package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.d.ts +0 -2
- package/src/migrations/install-claude-update-skills/install-claude-update-skills.migration.js +0 -290
|
@@ -21,215 +21,7 @@ __export(generator_exports, {
|
|
|
21
21
|
default: () => generator_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(generator_exports);
|
|
24
|
-
var
|
|
25
|
-
var import_bot_app_utils = require("../shared/bot-app-utils");
|
|
26
|
-
const MODULE_DIR = __dirname;
|
|
27
|
-
function normalizeOptions(tree, options) {
|
|
28
|
-
const { projectRoot, sourceRoot } = (0, import_bot_app_utils.validateBotAppProject)(
|
|
29
|
-
tree,
|
|
30
|
-
options.project
|
|
31
|
-
);
|
|
32
|
-
const paths = (0, import_bot_app_utils.resolveStandardPaths)(sourceRoot);
|
|
33
|
-
const name = (0, import_devkit.names)(options.name);
|
|
34
|
-
const fileName = name.fileName;
|
|
35
|
-
const className = name.className;
|
|
36
|
-
const propertyName = name.propertyName;
|
|
37
|
-
const constantName = name.constantName.toUpperCase();
|
|
38
|
-
const customMessagesPath = options.directory ? `${sourceRoot}/client/custom-messages/${options.directory}` : `${sourceRoot}/client/custom-messages`;
|
|
39
|
-
return {
|
|
40
|
-
...options,
|
|
41
|
-
projectName: options.project,
|
|
42
|
-
projectRoot,
|
|
43
|
-
fileName,
|
|
44
|
-
className,
|
|
45
|
-
propertyName,
|
|
46
|
-
constantName,
|
|
47
|
-
customMessagesPath,
|
|
48
|
-
constantsPath: paths.constantsPath,
|
|
49
|
-
actionsPath: paths.actionsPath,
|
|
50
|
-
routesPath: paths.routesPath
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function addFilesToProject(tree, options) {
|
|
54
|
-
const name = (0, import_devkit.names)(options.name);
|
|
55
|
-
const templateOptions = {
|
|
56
|
-
...options,
|
|
57
|
-
...name,
|
|
58
|
-
name: name.fileName
|
|
59
|
-
// __name__ in filenames must be kebab-case
|
|
60
|
-
};
|
|
61
|
-
(0, import_devkit.generateFiles)(
|
|
62
|
-
tree,
|
|
63
|
-
(0, import_devkit.joinPathFragments)(MODULE_DIR, "files"),
|
|
64
|
-
options.customMessagesPath,
|
|
65
|
-
templateOptions
|
|
66
|
-
);
|
|
67
|
-
if (options.skipTests) {
|
|
68
|
-
const testFilePath = `${options.customMessagesPath}/${options.fileName}.spec.tsx`;
|
|
69
|
-
if (tree.exists(testFilePath)) {
|
|
70
|
-
tree.delete(testFilePath);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (options.skipAction) {
|
|
74
|
-
const actionPath = `${options.customMessagesPath}/${options.fileName}-output.ts`;
|
|
75
|
-
if (tree.exists(actionPath)) {
|
|
76
|
-
tree.delete(actionPath);
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
const sourceActionPath = `${options.customMessagesPath}/${options.fileName}-output.ts`;
|
|
80
|
-
const targetActionPath = `${options.actionsPath}/${options.fileName}.ts`;
|
|
81
|
-
if (tree.exists(sourceActionPath)) {
|
|
82
|
-
const content = tree.read(sourceActionPath, "utf-8");
|
|
83
|
-
tree.write(targetActionPath, content);
|
|
84
|
-
tree.delete(sourceActionPath);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function updateCustomMessagesIndex(tree, options) {
|
|
89
|
-
const indexPath = `${options.customMessagesPath}/index.ts`;
|
|
90
|
-
if (!tree.exists(indexPath)) {
|
|
91
|
-
tree.write(
|
|
92
|
-
indexPath,
|
|
93
|
-
`import { CUSTOM_MESSAGE_TYPES } from '../../shared/constants'
|
|
94
|
-
|
|
95
|
-
export const customMessages = {
|
|
96
|
-
[CUSTOM_MESSAGE_TYPES.${options.constantName}]: ${options.className},
|
|
97
|
-
}
|
|
98
|
-
`
|
|
99
|
-
);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const content = tree.read(indexPath, "utf-8");
|
|
103
|
-
const lines = content.split("\n");
|
|
104
|
-
const importStatement = `import { ${options.className} } from './${options.directory ? options.directory + "/" : ""}${options.fileName}'`;
|
|
105
|
-
let importInsertIndex = 0;
|
|
106
|
-
for (let i = 0; i < lines.length; i++) {
|
|
107
|
-
if (lines[i].startsWith("import")) {
|
|
108
|
-
importInsertIndex = i + 1;
|
|
109
|
-
} else if (lines[i].trim() === "" && importInsertIndex > 0) {
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
lines.splice(importInsertIndex, 0, importStatement);
|
|
114
|
-
const exportLineIndex = lines.findIndex(
|
|
115
|
-
(line) => line.includes("export const customMessages")
|
|
116
|
-
);
|
|
117
|
-
if (exportLineIndex !== -1) {
|
|
118
|
-
let braceIndex = exportLineIndex;
|
|
119
|
-
while (braceIndex < lines.length && !lines[braceIndex].includes("{")) {
|
|
120
|
-
braceIndex++;
|
|
121
|
-
}
|
|
122
|
-
if (braceIndex < lines.length) {
|
|
123
|
-
const braceLine = lines[braceIndex];
|
|
124
|
-
if (braceLine.trim() === "{" || braceLine.includes("{}")) {
|
|
125
|
-
const newEntry = ` [CUSTOM_MESSAGE_TYPES.${options.constantName}]: ${options.className},`;
|
|
126
|
-
if (braceLine.includes("{}")) {
|
|
127
|
-
lines[braceIndex] = braceLine.replace("{}", `{
|
|
128
|
-
${newEntry}
|
|
129
|
-
}`);
|
|
130
|
-
} else {
|
|
131
|
-
lines.splice(braceIndex + 1, 0, newEntry);
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
let closingBraceIndex = braceIndex;
|
|
135
|
-
let braceCount = 0;
|
|
136
|
-
for (let i = braceIndex; i < lines.length; i++) {
|
|
137
|
-
for (const char of lines[i]) {
|
|
138
|
-
if (char === "{") braceCount++;
|
|
139
|
-
if (char === "}") braceCount--;
|
|
140
|
-
}
|
|
141
|
-
if (braceCount === 0) {
|
|
142
|
-
closingBraceIndex = i;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const newEntry = ` [CUSTOM_MESSAGE_TYPES.${options.constantName}]: ${options.className},`;
|
|
147
|
-
lines.splice(closingBraceIndex, 0, newEntry);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
tree.write(indexPath, lines.join("\n"));
|
|
152
|
-
}
|
|
153
|
-
function updateConstantsFile(tree, options) {
|
|
154
|
-
if (!tree.exists(options.constantsPath)) {
|
|
155
|
-
tree.write(
|
|
156
|
-
options.constantsPath,
|
|
157
|
-
`export const CUSTOM_MESSAGE_TYPES = {
|
|
158
|
-
${options.constantName}: '${options.fileName}',
|
|
159
|
-
} as const
|
|
160
|
-
|
|
161
|
-
export const WEBVIEWS = {
|
|
162
|
-
// Add your webviews here
|
|
163
|
-
} as const
|
|
164
|
-
|
|
165
|
-
export const PAYLOADS = {
|
|
166
|
-
// Add your payloads here
|
|
167
|
-
} as const
|
|
168
|
-
`
|
|
169
|
-
);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
(0, import_bot_app_utils.addConstEntry)(
|
|
173
|
-
tree,
|
|
174
|
-
options.constantsPath,
|
|
175
|
-
"CUSTOM_MESSAGE_TYPES",
|
|
176
|
-
options.constantName,
|
|
177
|
-
options.fileName
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
function updateActionsIndex(tree, options) {
|
|
181
|
-
if (options.skipAction) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
(0, import_bot_app_utils.addExportToIndex)(
|
|
185
|
-
tree,
|
|
186
|
-
`${options.actionsPath}/index.ts`,
|
|
187
|
-
`export * from './${options.fileName}'`
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
function updateRoutes(tree, options) {
|
|
191
|
-
if (options.skipAction) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const actionImport = `${options.propertyName}Output`;
|
|
195
|
-
(0, import_bot_app_utils.addActionImportToRoutes)(tree, options.routesPath, actionImport);
|
|
196
|
-
(0, import_bot_app_utils.insertRouteBeforeFlowBuilder)(tree, options.routesPath, [
|
|
197
|
-
` {`,
|
|
198
|
-
` text: '${options.fileName}',`,
|
|
199
|
-
` action: async () => await ${actionImport}(botonicContext),`,
|
|
200
|
-
` },`
|
|
201
|
-
]);
|
|
202
|
-
}
|
|
24
|
+
var import_delegate_generator = require("../../lib/delegate/delegate-generator");
|
|
203
25
|
async function generator_default(tree, options) {
|
|
204
|
-
|
|
205
|
-
const normalizedOptions = normalizeOptions(tree, options);
|
|
206
|
-
console.log(`Project: ${normalizedOptions.projectName}`);
|
|
207
|
-
console.log(`Location: ${normalizedOptions.customMessagesPath}`);
|
|
208
|
-
addFilesToProject(tree, normalizedOptions);
|
|
209
|
-
updateConstantsFile(tree, normalizedOptions);
|
|
210
|
-
updateCustomMessagesIndex(tree, normalizedOptions);
|
|
211
|
-
updateActionsIndex(tree, normalizedOptions);
|
|
212
|
-
updateRoutes(tree, normalizedOptions);
|
|
213
|
-
await (0, import_devkit.formatFiles)(tree);
|
|
214
|
-
console.log(
|
|
215
|
-
`
|
|
216
|
-
Successfully created custom message: ${normalizedOptions.className}`
|
|
217
|
-
);
|
|
218
|
-
console.log(`Next steps:`);
|
|
219
|
-
console.log(
|
|
220
|
-
` 1. Customize the component in: ${normalizedOptions.customMessagesPath}/${normalizedOptions.fileName}.tsx`
|
|
221
|
-
);
|
|
222
|
-
if (!options.skipAction) {
|
|
223
|
-
console.log(
|
|
224
|
-
` 2. Update the action in: ${normalizedOptions.actionsPath}/${normalizedOptions.fileName}.ts`
|
|
225
|
-
);
|
|
226
|
-
console.log(
|
|
227
|
-
` 3. Test by typing '${normalizedOptions.fileName}' in the webchat`
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
if (!options.skipTests) {
|
|
231
|
-
console.log(
|
|
232
|
-
` 4. Update the tests in: ${normalizedOptions.customMessagesPath}/${normalizedOptions.fileName}.spec.tsx`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
26
|
+
return (0, import_delegate_generator.runLocalGenerator)(__filename, "custom-message", tree, options);
|
|
235
27
|
}
|
|
@@ -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_impl_exports = {};
|
|
30
|
+
__export(generator_impl_exports, {
|
|
31
|
+
default: () => generator_impl_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(generator_impl_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_impl_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
|
+
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default function (tree: Tree, options: PresetGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
|
-
export { PresetGeneratorSchema };
|
|
1
|
+
export { default } from './generator-impl';
|
|
2
|
+
export type { PresetGeneratorSchema } from './schema';
|
|
@@ -28,100 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var generator_exports = {};
|
|
30
30
|
__export(generator_exports, {
|
|
31
|
-
default: () =>
|
|
31
|
+
default: () => import_generator_impl.default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(generator_exports);
|
|
34
|
-
var
|
|
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
|
-
}
|
|
34
|
+
var import_generator_impl = __toESM(require("./generator-impl"));
|