@motiadev/workbench 0.14.0-beta.165-285707 → 0.15.0-beta.165
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/dist/index.d.ts +189 -10
- package/dist/index.html +1 -1
- package/dist/index.js +1065 -7
- package/dist/middleware.d.ts +66 -8
- package/dist/middleware.js +694 -86
- package/dist/motia-plugin/__tests__/generator.test.ts +129 -0
- package/dist/motia-plugin/__tests__/resolver.test.ts +82 -0
- package/dist/motia-plugin/__tests__/validator.test.ts +71 -0
- package/dist/motia-plugin/{generator.js → generator.ts} +37 -35
- package/dist/motia-plugin/hmr.ts +123 -0
- package/dist/motia-plugin/index.ts +183 -0
- package/dist/motia-plugin/{resolver.d.ts → resolver.ts} +38 -5
- package/dist/motia-plugin/types.ts +198 -0
- package/dist/motia-plugin/{utils.d.ts → utils.ts} +17 -4
- package/dist/motia-plugin/validator.ts +197 -0
- package/dist/src/App.tsx +41 -0
- package/dist/src/components/NotFoundPage.tsx +11 -0
- package/dist/src/components/bottom-panel.tsx +39 -0
- package/dist/src/components/flow/base-edge.tsx +61 -0
- package/dist/src/components/flow/flow-loader.tsx +3 -0
- package/dist/src/components/flow/flow-page.tsx +75 -0
- package/dist/src/components/flow/flow-tab-menu-item.tsx +52 -0
- package/dist/src/components/flow/flow-view.tsx +66 -0
- package/dist/src/components/flow/hooks/use-get-flow-state.tsx +171 -0
- package/dist/src/components/flow/hooks/use-save-workflow-config.ts +25 -0
- package/dist/src/components/flow/node-organizer.tsx +103 -0
- package/dist/src/components/flow/nodes/api-flow-node.tsx +6 -0
- package/dist/src/components/flow/nodes/cron-flow-node.tsx +6 -0
- package/dist/src/components/flow/nodes/event-flow-node.tsx +6 -0
- package/dist/src/components/flow/nodes/noop-flow-node.tsx +6 -0
- package/dist/src/components/header/deploy-button.tsx +110 -0
- package/dist/src/components/header/header.tsx +39 -0
- package/dist/src/components/root-motia.tsx +10 -0
- package/dist/src/components/top-panel.tsx +40 -0
- package/dist/src/components/tutorial/engine/tutorial-engine.ts +26 -0
- package/dist/src/components/tutorial/engine/tutorial-types.ts +26 -0
- package/dist/src/components/tutorial/engine/workbench-xpath.ts +53 -0
- package/dist/src/components/tutorial/hooks/tutorial-utils.ts +26 -0
- package/dist/src/components/tutorial/hooks/use-tutorial-engine.ts +213 -0
- package/dist/src/components/tutorial/hooks/use-tutorial.ts +14 -0
- package/dist/src/components/tutorial/tutorial-button.tsx +46 -0
- package/dist/src/components/tutorial/tutorial-step.tsx +82 -0
- package/dist/src/components/tutorial/tutorial.tsx +59 -0
- package/dist/src/components/ui/json-editor.tsx +68 -0
- package/dist/src/components/ui/table.tsx +75 -0
- package/dist/src/components/ui/theme-toggle.tsx +54 -0
- package/dist/src/components/ui/tooltip.tsx +26 -0
- package/dist/src/hooks/use-debounced.ts +22 -0
- package/dist/src/hooks/use-fetch-flows.ts +33 -0
- package/dist/src/hooks/use-mobile.ts +19 -0
- package/dist/src/hooks/use-update-handle-positions.ts +42 -0
- package/dist/src/index.css +5 -5
- package/dist/src/lib/__tests__/utils.test.ts +110 -0
- package/dist/src/lib/motia-analytics.ts +140 -0
- package/dist/src/lib/plugins.tsx +132 -0
- package/dist/src/lib/utils.ts +37 -0
- package/dist/src/main.tsx +30 -0
- package/dist/src/project-view-mode.tsx +32 -0
- package/dist/src/publicComponents/api-node.tsx +26 -0
- package/dist/src/publicComponents/base-node/base-handle.tsx +50 -0
- package/dist/src/publicComponents/base-node/base-node.tsx +114 -0
- package/dist/src/publicComponents/base-node/code-display.tsx +119 -0
- package/dist/src/publicComponents/base-node/emits.tsx +17 -0
- package/dist/src/publicComponents/base-node/feature-card.tsx +32 -0
- package/dist/src/publicComponents/base-node/language-indicator.tsx +131 -0
- package/dist/src/publicComponents/base-node/node-header.tsx +49 -0
- package/dist/src/publicComponents/base-node/node-sidebar.tsx +41 -0
- package/dist/src/publicComponents/base-node/subscribe.tsx +13 -0
- package/dist/src/publicComponents/cron-node.tsx +24 -0
- package/dist/src/publicComponents/event-node.tsx +20 -0
- package/dist/src/publicComponents/node-props.tsx +15 -0
- package/dist/src/publicComponents/noop-node.tsx +19 -0
- package/dist/src/setupTests.ts +1 -0
- package/dist/src/stores/use-app-tabs-store.ts +49 -0
- package/dist/src/stores/use-flow-store.ts +31 -0
- package/dist/src/stores/use-global-store.ts +24 -0
- package/dist/src/stores/use-motia-config-store.ts +36 -0
- package/dist/src/stores/use-tabs-store.ts +34 -0
- package/dist/src/system-view-mode.tsx +28 -0
- package/dist/src/types/endpoint.ts +12 -0
- package/dist/src/types/file.ts +7 -0
- package/dist/src/types/flow.ts +103 -0
- package/eslint.config.cjs +22 -0
- package/jest.config.cjs +68 -0
- package/package.json +53 -51
- package/dist/motia-plugin/__tests__/generator.test.d.ts +0 -1
- package/dist/motia-plugin/__tests__/generator.test.js +0 -97
- package/dist/motia-plugin/__tests__/resolver.test.d.ts +0 -1
- package/dist/motia-plugin/__tests__/resolver.test.js +0 -64
- package/dist/motia-plugin/__tests__/validator.test.d.ts +0 -1
- package/dist/motia-plugin/__tests__/validator.test.js +0 -59
- package/dist/motia-plugin/generator.d.ts +0 -78
- package/dist/motia-plugin/hmr.d.ts +0 -22
- package/dist/motia-plugin/hmr.js +0 -100
- package/dist/motia-plugin/index.d.ts +0 -3
- package/dist/motia-plugin/index.js +0 -153
- package/dist/motia-plugin/resolver.js +0 -92
- package/dist/motia-plugin/types.d.ts +0 -169
- package/dist/motia-plugin/types.js +0 -36
- package/dist/motia-plugin/utils.js +0 -75
- package/dist/motia-plugin/validator.d.ts +0 -19
- package/dist/motia-plugin/validator.js +0 -163
- package/dist/src/App.d.ts +0 -2
- package/dist/src/App.js +0 -35
- package/dist/src/components/NotFoundPage.d.ts +0 -1
- package/dist/src/components/NotFoundPage.js +0 -3
- package/dist/src/components/bottom-panel.d.ts +0 -1
- package/dist/src/components/bottom-panel.js +0 -15
- package/dist/src/components/flow/base-edge.d.ts +0 -3
- package/dist/src/components/flow/base-edge.js +0 -39
- package/dist/src/components/flow/flow-loader.d.ts +0 -1
- package/dist/src/components/flow/flow-loader.js +0 -4
- package/dist/src/components/flow/flow-page.d.ts +0 -1
- package/dist/src/components/flow/flow-page.js +0 -25
- package/dist/src/components/flow/flow-tab-menu-item.d.ts +0 -1
- package/dist/src/components/flow/flow-tab-menu-item.js +0 -18
- package/dist/src/components/flow/flow-view.d.ts +0 -12
- package/dist/src/components/flow/flow-view.js +0 -22
- package/dist/src/components/flow/hooks/use-get-flow-state.d.ts +0 -10
- package/dist/src/components/flow/hooks/use-get-flow-state.js +0 -133
- package/dist/src/components/flow/hooks/use-save-workflow-config.d.ts +0 -2
- package/dist/src/components/flow/hooks/use-save-workflow-config.js +0 -22
- package/dist/src/components/flow/node-organizer.d.ts +0 -10
- package/dist/src/components/flow/node-organizer.js +0 -82
- package/dist/src/components/flow/nodes/api-flow-node.d.ts +0 -2
- package/dist/src/components/flow/nodes/api-flow-node.js +0 -5
- package/dist/src/components/flow/nodes/cron-flow-node.d.ts +0 -2
- package/dist/src/components/flow/nodes/cron-flow-node.js +0 -5
- package/dist/src/components/flow/nodes/event-flow-node.d.ts +0 -2
- package/dist/src/components/flow/nodes/event-flow-node.js +0 -5
- package/dist/src/components/flow/nodes/noop-flow-node.d.ts +0 -2
- package/dist/src/components/flow/nodes/noop-flow-node.js +0 -5
- package/dist/src/components/header/deploy-button.d.ts +0 -1
- package/dist/src/components/header/deploy-button.js +0 -28
- package/dist/src/components/header/header.d.ts +0 -2
- package/dist/src/components/header/header.js +0 -23
- package/dist/src/components/root-motia.d.ts +0 -2
- package/dist/src/components/root-motia.js +0 -7
- package/dist/src/components/top-panel.d.ts +0 -1
- package/dist/src/components/top-panel.js +0 -15
- package/dist/src/components/tutorial/engine/tutorial-engine.d.ts +0 -12
- package/dist/src/components/tutorial/engine/tutorial-engine.js +0 -36
- package/dist/src/components/tutorial/engine/tutorial-types.d.ts +0 -22
- package/dist/src/components/tutorial/engine/tutorial-types.js +0 -1
- package/dist/src/components/tutorial/engine/workbench-xpath.d.ts +0 -45
- package/dist/src/components/tutorial/engine/workbench-xpath.js +0 -45
- package/dist/src/components/tutorial/hooks/tutorial-utils.d.ts +0 -1
- package/dist/src/components/tutorial/hooks/tutorial-utils.js +0 -17
- package/dist/src/components/tutorial/hooks/use-tutorial-engine.d.ts +0 -15
- package/dist/src/components/tutorial/hooks/use-tutorial-engine.js +0 -183
- package/dist/src/components/tutorial/hooks/use-tutorial.d.ts +0 -5
- package/dist/src/components/tutorial/hooks/use-tutorial.js +0 -10
- package/dist/src/components/tutorial/tutorial-button.d.ts +0 -2
- package/dist/src/components/tutorial/tutorial-button.js +0 -21
- package/dist/src/components/tutorial/tutorial-step.d.ts +0 -14
- package/dist/src/components/tutorial/tutorial-step.js +0 -19
- package/dist/src/components/tutorial/tutorial.d.ts +0 -2
- package/dist/src/components/tutorial/tutorial.js +0 -32
- package/dist/src/components/ui/json-editor.d.ts +0 -12
- package/dist/src/components/ui/json-editor.js +0 -35
- package/dist/src/components/ui/table.d.ts +0 -10
- package/dist/src/components/ui/table.js +0 -20
- package/dist/src/components/ui/theme-toggle.d.ts +0 -2
- package/dist/src/components/ui/theme-toggle.js +0 -19
- package/dist/src/components/ui/tooltip.d.ts +0 -6
- package/dist/src/components/ui/tooltip.js +0 -3
- package/dist/src/hooks/use-debounced.d.ts +0 -1
- package/dist/src/hooks/use-debounced.js +0 -18
- package/dist/src/hooks/use-fetch-flows.d.ts +0 -1
- package/dist/src/hooks/use-fetch-flows.js +0 -26
- package/dist/src/hooks/use-mobile.d.ts +0 -1
- package/dist/src/hooks/use-mobile.js +0 -15
- package/dist/src/hooks/use-update-handle-positions.d.ts +0 -10
- package/dist/src/hooks/use-update-handle-positions.js +0 -35
- package/dist/src/lib/__tests__/utils.test.d.ts +0 -1
- package/dist/src/lib/__tests__/utils.test.js +0 -94
- package/dist/src/lib/motia-analytics.d.ts +0 -38
- package/dist/src/lib/motia-analytics.js +0 -132
- package/dist/src/lib/plugins.d.ts +0 -2
- package/dist/src/lib/plugins.js +0 -105
- package/dist/src/lib/utils.d.ts +0 -7
- package/dist/src/lib/utils.js +0 -34
- package/dist/src/main.d.ts +0 -2
- package/dist/src/main.js +0 -17
- package/dist/src/project-view-mode.d.ts +0 -1
- package/dist/src/project-view-mode.js +0 -20
- package/dist/src/publicComponents/api-node.d.ts +0 -5
- package/dist/src/publicComponents/api-node.js +0 -5
- package/dist/src/publicComponents/base-node/base-handle.d.ts +0 -9
- package/dist/src/publicComponents/base-node/base-handle.js +0 -8
- package/dist/src/publicComponents/base-node/base-node.d.ts +0 -15
- package/dist/src/publicComponents/base-node/base-node.js +0 -30
- package/dist/src/publicComponents/base-node/code-display.d.ts +0 -9
- package/dist/src/publicComponents/base-node/code-display.js +0 -64
- package/dist/src/publicComponents/base-node/emits.d.ts +0 -5
- package/dist/src/publicComponents/base-node/emits.js +0 -5
- package/dist/src/publicComponents/base-node/feature-card.d.ts +0 -10
- package/dist/src/publicComponents/base-node/feature-card.js +0 -5
- package/dist/src/publicComponents/base-node/language-indicator.d.ts +0 -10
- package/dist/src/publicComponents/base-node/language-indicator.js +0 -29
- package/dist/src/publicComponents/base-node/node-header.d.ts +0 -13
- package/dist/src/publicComponents/base-node/node-header.js +0 -30
- package/dist/src/publicComponents/base-node/node-sidebar.d.ts +0 -14
- package/dist/src/publicComponents/base-node/node-sidebar.js +0 -9
- package/dist/src/publicComponents/base-node/subscribe.d.ts +0 -4
- package/dist/src/publicComponents/base-node/subscribe.js +0 -4
- package/dist/src/publicComponents/cron-node.d.ts +0 -4
- package/dist/src/publicComponents/cron-node.js +0 -6
- package/dist/src/publicComponents/event-node.d.ts +0 -4
- package/dist/src/publicComponents/event-node.js +0 -5
- package/dist/src/publicComponents/node-props.d.ts +0 -21
- package/dist/src/publicComponents/node-props.js +0 -1
- package/dist/src/publicComponents/noop-node.d.ts +0 -4
- package/dist/src/publicComponents/noop-node.js +0 -5
- package/dist/src/setupTests.d.ts +0 -1
- package/dist/src/setupTests.js +0 -1
- package/dist/src/stores/use-app-tabs-store.d.ts +0 -16
- package/dist/src/stores/use-app-tabs-store.js +0 -31
- package/dist/src/stores/use-flow-store.d.ts +0 -21
- package/dist/src/stores/use-flow-store.js +0 -16
- package/dist/src/stores/use-global-store.d.ts +0 -18
- package/dist/src/stores/use-global-store.js +0 -12
- package/dist/src/stores/use-motia-config-store.d.ts +0 -12
- package/dist/src/stores/use-motia-config-store.js +0 -24
- package/dist/src/stores/use-tabs-store.d.ts +0 -19
- package/dist/src/stores/use-tabs-store.js +0 -22
- package/dist/src/system-view-mode.d.ts +0 -1
- package/dist/src/system-view-mode.js +0 -10
- package/dist/src/types/endpoint.d.ts +0 -14
- package/dist/src/types/endpoint.js +0 -1
- package/dist/src/types/file.d.ts +0 -7
- package/dist/src/types/file.js +0 -1
- package/dist/src/types/flow.d.ts +0 -115
- package/dist/src/types/flow.js +0 -1
- package/dist/tsconfig.app.tsbuildinfo +0 -1
- package/dist/tsconfig.node.tsbuildinfo +0 -1
package/dist/motia-plugin/hmr.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isConfigFile = isConfigFile;
|
|
7
|
-
exports.shouldInvalidatePlugins = shouldInvalidatePlugins;
|
|
8
|
-
exports.handlePluginHotUpdate = handlePluginHotUpdate;
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const resolver_1 = require("./resolver");
|
|
11
|
-
const types_1 = require("./types");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
const WATCHED_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.css', '.scss', '.less'];
|
|
14
|
-
function isConfigFile(file) {
|
|
15
|
-
const normalizedFile = (0, utils_1.normalizePath)(file);
|
|
16
|
-
return normalizedFile.endsWith('motia.config.ts') || normalizedFile.endsWith('motia.config.js');
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Checks if a file change should trigger HMR for plugins.
|
|
20
|
-
*
|
|
21
|
-
* @param file - The file path that changed
|
|
22
|
-
* @param plugins - Current plugin configurations
|
|
23
|
-
* @returns True if the change affects plugins
|
|
24
|
-
*/
|
|
25
|
-
function shouldInvalidatePlugins(file, plugins) {
|
|
26
|
-
const normalizedFile = (0, utils_1.normalizePath)(file);
|
|
27
|
-
const absoluteFile = path_1.default.isAbsolute(normalizedFile) ? normalizedFile : path_1.default.resolve(process.cwd(), normalizedFile);
|
|
28
|
-
if (isConfigFile(file)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
const hasWatchedExtension = WATCHED_EXTENSIONS.some((ext) => absoluteFile.endsWith(ext));
|
|
32
|
-
if (!hasWatchedExtension) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
for (const plugin of plugins) {
|
|
36
|
-
if ((0, utils_1.isLocalPlugin)(plugin.packageName)) {
|
|
37
|
-
const resolved = (0, resolver_1.resolvePluginPackage)(plugin);
|
|
38
|
-
const pluginAbsolutePath = path_1.default.isAbsolute(resolved.resolvedPath)
|
|
39
|
-
? resolved.resolvedPath
|
|
40
|
-
: path_1.default.resolve(process.cwd(), resolved.resolvedPath);
|
|
41
|
-
const normalizedPluginPath = pluginAbsolutePath.endsWith(path_1.default.sep)
|
|
42
|
-
? pluginAbsolutePath
|
|
43
|
-
: `${pluginAbsolutePath}${path_1.default.sep}`;
|
|
44
|
-
if (absoluteFile.startsWith(normalizedPluginPath) || absoluteFile === pluginAbsolutePath) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Handles hot updates for the plugin system.
|
|
53
|
-
* This function is called by Vite's handleHotUpdate hook.
|
|
54
|
-
*
|
|
55
|
-
* @param ctx - Vite's HMR context
|
|
56
|
-
* @param plugins - Current plugin configurations
|
|
57
|
-
* @param printer - Printer instance for logging
|
|
58
|
-
* @returns Array of modules to update, or undefined to continue with default behavior
|
|
59
|
-
*/
|
|
60
|
-
function handlePluginHotUpdate(ctx, plugins, printer) {
|
|
61
|
-
const { file, server, timestamp } = ctx;
|
|
62
|
-
printer.printPluginLog(`HMR: File changed: ${(0, utils_1.normalizePath)(file)}`);
|
|
63
|
-
if (isConfigFile(file)) {
|
|
64
|
-
printer.printPluginLog('HMR: Config file changed, triggering full page reload');
|
|
65
|
-
printer.printPluginWarn('Configuration changes require a server restart for full effect. Please restart the dev server to apply all changes.');
|
|
66
|
-
server.ws.send({
|
|
67
|
-
type: 'full-reload',
|
|
68
|
-
path: '*',
|
|
69
|
-
});
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!shouldInvalidatePlugins(file, plugins)) {
|
|
73
|
-
printer.printPluginLog('HMR: Change outside plugin scope, delegating to Vite default handling');
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
printer.printPluginLog('HMR: Plugin change detected, invalidating virtual module');
|
|
77
|
-
const virtualModule = server.moduleGraph.getModuleById(types_1.CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID);
|
|
78
|
-
if (!virtualModule) {
|
|
79
|
-
printer.printPluginWarn('HMR: Virtual module not found, triggering full reload as fallback');
|
|
80
|
-
server.ws.send({
|
|
81
|
-
type: 'full-reload',
|
|
82
|
-
path: '*',
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
server.moduleGraph.invalidateModule(virtualModule, new Set(), timestamp);
|
|
87
|
-
printer.printPluginLog('HMR: Virtual module invalidated');
|
|
88
|
-
const modulesToUpdateSet = new Set([virtualModule]);
|
|
89
|
-
const processedModules = new Set([virtualModule]);
|
|
90
|
-
for (const importer of virtualModule.importers) {
|
|
91
|
-
if (!processedModules.has(importer)) {
|
|
92
|
-
processedModules.add(importer);
|
|
93
|
-
modulesToUpdateSet.add(importer);
|
|
94
|
-
server.moduleGraph.invalidateModule(importer, new Set(), timestamp);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const modulesToUpdate = Array.from(modulesToUpdateSet);
|
|
98
|
-
printer.printPluginLog(`HMR: Updated ${modulesToUpdate.length} module(s)`);
|
|
99
|
-
return modulesToUpdate;
|
|
100
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = motiaPluginsPlugin;
|
|
7
|
-
const core_1 = require("@motiadev/core");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const generator_1 = require("./generator");
|
|
10
|
-
const hmr_1 = require("./hmr");
|
|
11
|
-
const resolver_1 = require("./resolver");
|
|
12
|
-
const types_1 = require("./types");
|
|
13
|
-
const utils_1 = require("./utils");
|
|
14
|
-
const validator_1 = require("./validator");
|
|
15
|
-
/**
|
|
16
|
-
* Vite plugin for loading and managing Motia workbench plugins.
|
|
17
|
-
*
|
|
18
|
-
* Features:
|
|
19
|
-
* - Hot Module Replacement (HMR) support
|
|
20
|
-
* - Runtime validation with detailed error messages
|
|
21
|
-
* - Verbose logging for debugging
|
|
22
|
-
* - CSS injection for plugin styles
|
|
23
|
-
*
|
|
24
|
-
* @param plugins - Array of plugin configurations
|
|
25
|
-
* @param options - Optional loader configuration
|
|
26
|
-
* @returns Vite plugin instance
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* export default defineConfig({
|
|
31
|
-
* plugins: [
|
|
32
|
-
* motiaPluginsPlugin([
|
|
33
|
-
* { packageName: '@my-org/plugin', label: 'My Plugin' }
|
|
34
|
-
* ])
|
|
35
|
-
* ]
|
|
36
|
-
* })
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
const printer = new core_1.Printer(process.cwd());
|
|
40
|
-
function motiaPluginsPlugin(plugins) {
|
|
41
|
-
let devServer = null;
|
|
42
|
-
try {
|
|
43
|
-
const validationResult = (0, validator_1.validatePlugins)(plugins, {
|
|
44
|
-
failFast: false,
|
|
45
|
-
});
|
|
46
|
-
if (!validationResult.valid) {
|
|
47
|
-
printer.printPluginError('Plugin configuration validation failed:');
|
|
48
|
-
for (const err of validationResult.errors) {
|
|
49
|
-
printer.printPluginError(` ${err}`);
|
|
50
|
-
}
|
|
51
|
-
throw new Error('Invalid plugin configuration. See errors above.');
|
|
52
|
-
}
|
|
53
|
-
if (validationResult.warnings.length > 0) {
|
|
54
|
-
for (const warning of validationResult.warnings) {
|
|
55
|
-
printer.printPluginWarn(warning);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
printer.printPluginError(`Failed to validate plugins: ${error}`);
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
const alias = (0, resolver_1.createAliasConfig)(plugins);
|
|
64
|
-
printer.printPluginLog(`Initialized with ${plugins.length} plugin(s)`);
|
|
65
|
-
return {
|
|
66
|
-
name: 'vite-plugin-motia-plugins',
|
|
67
|
-
enforce: 'pre',
|
|
68
|
-
buildStart() {
|
|
69
|
-
printer.printPluginLog('Build started');
|
|
70
|
-
},
|
|
71
|
-
config: () => ({
|
|
72
|
-
resolve: {
|
|
73
|
-
alias,
|
|
74
|
-
},
|
|
75
|
-
}),
|
|
76
|
-
configureServer(server) {
|
|
77
|
-
devServer = server;
|
|
78
|
-
printer.printPluginLog('Dev server configured, HMR enabled');
|
|
79
|
-
const configPaths = [path_1.default.join(process.cwd(), 'motia.config.ts'), path_1.default.join(process.cwd(), 'motia.config.js')];
|
|
80
|
-
for (const configPath of configPaths) {
|
|
81
|
-
server.watcher.add(configPath);
|
|
82
|
-
}
|
|
83
|
-
printer.printPluginLog('Watching for config file changes');
|
|
84
|
-
const localPlugins = plugins.filter((p) => (0, utils_1.isLocalPlugin)(p.packageName));
|
|
85
|
-
if (localPlugins.length > 0) {
|
|
86
|
-
printer.printPluginLog(`Watching ${localPlugins.length} local plugin(s)`);
|
|
87
|
-
for (const plugin of localPlugins) {
|
|
88
|
-
const resolved = (0, resolver_1.resolvePluginPackage)(plugin);
|
|
89
|
-
const watchPath = resolved.resolvedPath;
|
|
90
|
-
server.watcher.add(watchPath);
|
|
91
|
-
printer.printPluginLog(`Watching: ${watchPath}`);
|
|
92
|
-
}
|
|
93
|
-
server.watcher.on('change', (file) => {
|
|
94
|
-
const normalizedFile = (0, utils_1.normalizePath)(file);
|
|
95
|
-
printer.printPluginLog(`File watcher detected change: ${normalizedFile}`);
|
|
96
|
-
});
|
|
97
|
-
server.watcher.on('add', (file) => {
|
|
98
|
-
const normalizedFile = (0, utils_1.normalizePath)(file);
|
|
99
|
-
printer.printPluginLog(`File watcher detected new file: ${normalizedFile}`);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
resolveId(id) {
|
|
104
|
-
if (id === types_1.CONSTANTS.VIRTUAL_MODULE_ID) {
|
|
105
|
-
return types_1.CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID;
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
load(id) {
|
|
109
|
-
if (id !== types_1.CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
printer.printPluginLog('Loading plugins virtual module');
|
|
113
|
-
printer.printPluginLog('Generating plugin code...');
|
|
114
|
-
const code = (0, generator_1.generatePluginCode)(plugins);
|
|
115
|
-
if (!(0, generator_1.isValidCode)(code)) {
|
|
116
|
-
printer.printPluginError('Generated code is invalid or empty');
|
|
117
|
-
return 'export const plugins = []';
|
|
118
|
-
}
|
|
119
|
-
printer.printPluginLog('Plugin code generated successfully');
|
|
120
|
-
return code;
|
|
121
|
-
},
|
|
122
|
-
async transform(code, id) {
|
|
123
|
-
const normalizedId = (0, utils_1.normalizePath)(id);
|
|
124
|
-
if (!normalizedId.endsWith('src/index.css')) {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
printer.printPluginLog('Injecting plugin CSS imports');
|
|
128
|
-
const cssImports = (0, generator_1.generateCssImports)(plugins);
|
|
129
|
-
if (!cssImports) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
code: `${cssImports}\n${code}`,
|
|
134
|
-
map: null,
|
|
135
|
-
};
|
|
136
|
-
},
|
|
137
|
-
handleHotUpdate(ctx) {
|
|
138
|
-
if (!devServer) {
|
|
139
|
-
printer.printPluginWarn('HMR: Dev server not available');
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const modulesToUpdate = (0, hmr_1.handlePluginHotUpdate)(ctx, plugins, printer);
|
|
143
|
-
if (modulesToUpdate && modulesToUpdate.length > 0) {
|
|
144
|
-
const merged = Array.from(new Set([...(ctx.modules || []), ...modulesToUpdate]));
|
|
145
|
-
printer.printPluginLog(`HMR: Successfully updated ${merged.length} module(s)`);
|
|
146
|
-
return merged;
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
buildEnd() {
|
|
150
|
-
printer.printPluginLog('Build ended');
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePluginPackage = resolvePluginPackage;
|
|
4
|
-
exports.createAliasConfig = createAliasConfig;
|
|
5
|
-
exports.resolveAllPlugins = resolveAllPlugins;
|
|
6
|
-
exports.getUniquePackageNames = getUniquePackageNames;
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
/**
|
|
9
|
-
* Resolves a plugin package to its absolute path and creates an alias.
|
|
10
|
-
*
|
|
11
|
-
* @param plugin - The plugin configuration to resolve
|
|
12
|
-
* @returns Resolved package information including path and alias
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* // Local plugin
|
|
17
|
-
* resolvePluginPackage({ packageName: '~/plugins/my-plugin' })
|
|
18
|
-
* // Returns: {
|
|
19
|
-
* // packageName: '~/plugins/my-plugin',
|
|
20
|
-
* // resolvedPath: '/Users/project/plugins/my-plugin',
|
|
21
|
-
* // isLocal: true,
|
|
22
|
-
* // alias: '~/plugins/my-plugin'
|
|
23
|
-
* // }
|
|
24
|
-
*
|
|
25
|
-
* // NPM package
|
|
26
|
-
* resolvePluginPackage({ packageName: '@org/plugin' })
|
|
27
|
-
* // Returns: {
|
|
28
|
-
* // packageName: '@org/plugin',
|
|
29
|
-
* // resolvedPath: '/Users/project/node_modules/@org/plugin',
|
|
30
|
-
* // isLocal: false,
|
|
31
|
-
* // alias: '@org/plugin'
|
|
32
|
-
* // }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
function resolvePluginPackage(plugin) {
|
|
36
|
-
const { packageName } = plugin;
|
|
37
|
-
const local = (0, utils_1.isLocalPlugin)(packageName);
|
|
38
|
-
const resolvedPath = local ? (0, utils_1.resolveLocalPath)(packageName) : (0, utils_1.resolveNpmPath)(packageName);
|
|
39
|
-
return {
|
|
40
|
-
packageName,
|
|
41
|
-
resolvedPath: (0, utils_1.normalizePath)(resolvedPath),
|
|
42
|
-
isLocal: local,
|
|
43
|
-
alias: packageName,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Resolves all plugin packages and creates a Vite alias configuration.
|
|
48
|
-
*
|
|
49
|
-
* @param plugins - Array of plugin configurations
|
|
50
|
-
* @returns Vite alias configuration object
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* const plugins = [
|
|
55
|
-
* { packageName: '~/plugins/local' },
|
|
56
|
-
* { packageName: '@org/npm-plugin' }
|
|
57
|
-
* ]
|
|
58
|
-
* const aliases = createAliasConfig(plugins)
|
|
59
|
-
* // Returns: {
|
|
60
|
-
* // '~/plugins/local': '/Users/project/plugins/local',
|
|
61
|
-
* // '@org/npm-plugin': '/Users/project/node_modules/@org/npm-plugin'
|
|
62
|
-
* // }
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
function createAliasConfig(plugins) {
|
|
66
|
-
// Get unique package names to avoid duplicate aliases
|
|
67
|
-
const uniquePackages = Array.from(new Set(plugins.map((p) => p.packageName)));
|
|
68
|
-
const aliases = {};
|
|
69
|
-
for (const packageName of uniquePackages) {
|
|
70
|
-
const resolved = resolvePluginPackage({ packageName });
|
|
71
|
-
aliases[packageName] = resolved.resolvedPath;
|
|
72
|
-
}
|
|
73
|
-
return aliases;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Resolves all plugins and returns their resolved package information.
|
|
77
|
-
*
|
|
78
|
-
* @param plugins - Array of plugin configurations
|
|
79
|
-
* @returns Array of resolved package information
|
|
80
|
-
*/
|
|
81
|
-
function resolveAllPlugins(plugins) {
|
|
82
|
-
return plugins.map((plugin) => resolvePluginPackage(plugin));
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Gets the unique set of package names from plugins.
|
|
86
|
-
*
|
|
87
|
-
* @param plugins - Array of plugin configurations
|
|
88
|
-
* @returns Array of unique package names
|
|
89
|
-
*/
|
|
90
|
-
function getUniquePackageNames(plugins) {
|
|
91
|
-
return Array.from(new Set(plugins.map((p) => p.packageName)));
|
|
92
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for a single workbench plugin.
|
|
3
|
-
* This interface defines how plugins are registered and configured in the Motia workbench.
|
|
4
|
-
*/
|
|
5
|
-
export interface WorkbenchPlugin {
|
|
6
|
-
/**
|
|
7
|
-
* The package name or local path to the plugin.
|
|
8
|
-
* - For npm packages: use the package name (e.g., '@my-org/my-plugin')
|
|
9
|
-
* - For local plugins: use the tilde prefix (e.g., '~/plugins/my-plugin')
|
|
10
|
-
*/
|
|
11
|
-
packageName: string;
|
|
12
|
-
/**
|
|
13
|
-
* Optional named export to use from the plugin package.
|
|
14
|
-
* If not specified, the default export will be used.
|
|
15
|
-
* Can be overridden by the plugin's own config.
|
|
16
|
-
*/
|
|
17
|
-
componentName?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Position where the plugin tab should appear in the workbench.
|
|
20
|
-
* - 'top': Display in the top tab bar
|
|
21
|
-
* - 'bottom': Display in the bottom tab bar
|
|
22
|
-
* @default 'top'
|
|
23
|
-
*/
|
|
24
|
-
position?: 'top' | 'bottom';
|
|
25
|
-
/**
|
|
26
|
-
* Display label for the plugin tab.
|
|
27
|
-
* Can be overridden by the plugin's own config.
|
|
28
|
-
*/
|
|
29
|
-
label?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Icon name from lucide-react to display next to the label.
|
|
32
|
-
* Can be overridden by the plugin's own config.
|
|
33
|
-
* @default 'toy-brick'
|
|
34
|
-
*/
|
|
35
|
-
labelIcon?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Array of CSS package imports to inject into the workbench.
|
|
38
|
-
* These will be added to the main index.css file.
|
|
39
|
-
* Example: ['@my-org/my-plugin/styles.css']
|
|
40
|
-
*/
|
|
41
|
-
cssImports?: string[];
|
|
42
|
-
/**
|
|
43
|
-
* Props to pass to the plugin component when it's rendered.
|
|
44
|
-
* Can be overridden by the plugin's own config.
|
|
45
|
-
*/
|
|
46
|
-
props?: Record<string, any>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Result of validating a plugin configuration.
|
|
50
|
-
*/
|
|
51
|
-
export interface ValidationResult {
|
|
52
|
-
/**
|
|
53
|
-
* Whether the validation passed
|
|
54
|
-
*/
|
|
55
|
-
valid: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Array of error messages if validation failed
|
|
58
|
-
*/
|
|
59
|
-
errors: string[];
|
|
60
|
-
/**
|
|
61
|
-
* Array of warning messages for non-critical issues
|
|
62
|
-
*/
|
|
63
|
-
warnings: string[];
|
|
64
|
-
/**
|
|
65
|
-
* The validated and normalized plugin configuration (if valid)
|
|
66
|
-
*/
|
|
67
|
-
plugin?: WorkbenchPlugin;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Context object passed to various plugin internals functions.
|
|
71
|
-
* Contains shared state and configuration.
|
|
72
|
-
*/
|
|
73
|
-
export interface PluginContext {
|
|
74
|
-
/**
|
|
75
|
-
* Array of plugin configurations
|
|
76
|
-
*/
|
|
77
|
-
plugins: WorkbenchPlugin[];
|
|
78
|
-
/**
|
|
79
|
-
* Vite dev server instance (only available in dev mode)
|
|
80
|
-
*/
|
|
81
|
-
server?: any;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Package resolution result.
|
|
85
|
-
*/
|
|
86
|
-
export interface ResolvedPackage {
|
|
87
|
-
/**
|
|
88
|
-
* The original package name from the configuration
|
|
89
|
-
*/
|
|
90
|
-
packageName: string;
|
|
91
|
-
/**
|
|
92
|
-
* Resolved absolute path to the package
|
|
93
|
-
*/
|
|
94
|
-
resolvedPath: string;
|
|
95
|
-
/**
|
|
96
|
-
* Whether this is a local plugin (starts with ~/)
|
|
97
|
-
*/
|
|
98
|
-
isLocal: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Alias to use for imports
|
|
101
|
-
*/
|
|
102
|
-
alias: string;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Generated virtual module exports interface.
|
|
106
|
-
* This is what consumers will import from 'virtual:motia-plugins'.
|
|
107
|
-
*/
|
|
108
|
-
export interface VirtualModuleExports {
|
|
109
|
-
/**
|
|
110
|
-
* Array of processed plugin configurations ready to be registered
|
|
111
|
-
*/
|
|
112
|
-
plugins: ProcessedPlugin[];
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* A plugin configuration after processing and normalization.
|
|
116
|
-
* This is the format used by the workbench to register tabs.
|
|
117
|
-
*/
|
|
118
|
-
export interface ProcessedPlugin {
|
|
119
|
-
/**
|
|
120
|
-
* Display label for the plugin tab
|
|
121
|
-
*/
|
|
122
|
-
label: string;
|
|
123
|
-
/**
|
|
124
|
-
* Icon name from lucide-react
|
|
125
|
-
*/
|
|
126
|
-
labelIcon: string;
|
|
127
|
-
/**
|
|
128
|
-
* Position in the workbench ('top' or 'bottom')
|
|
129
|
-
*/
|
|
130
|
-
position: 'top' | 'bottom';
|
|
131
|
-
/**
|
|
132
|
-
* Props to pass to the component
|
|
133
|
-
*/
|
|
134
|
-
props: Record<string, any>;
|
|
135
|
-
/**
|
|
136
|
-
* The React component to render
|
|
137
|
-
*/
|
|
138
|
-
component: any;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Type guard to check if position is valid.
|
|
142
|
-
*/
|
|
143
|
-
export declare function isValidPosition(position: any): position is 'top' | 'bottom';
|
|
144
|
-
/**
|
|
145
|
-
* Constants used throughout the plugin system.
|
|
146
|
-
*/
|
|
147
|
-
export declare const CONSTANTS: {
|
|
148
|
-
/**
|
|
149
|
-
* Virtual module ID for importing plugins
|
|
150
|
-
*/
|
|
151
|
-
readonly VIRTUAL_MODULE_ID: "virtual:motia-plugins";
|
|
152
|
-
/**
|
|
153
|
-
* Resolved virtual module ID (with null byte prefix for Vite)
|
|
154
|
-
*/
|
|
155
|
-
readonly RESOLVED_VIRTUAL_MODULE_ID: "\0virtual:motia-plugins";
|
|
156
|
-
/**
|
|
157
|
-
* Log prefix for all plugin messages
|
|
158
|
-
*/
|
|
159
|
-
readonly LOG_PREFIX: "[motia-plugins]";
|
|
160
|
-
/**
|
|
161
|
-
* Default values for optional plugin fields
|
|
162
|
-
*/
|
|
163
|
-
readonly DEFAULTS: {
|
|
164
|
-
readonly POSITION: "top";
|
|
165
|
-
readonly LABEL: "Plugin label";
|
|
166
|
-
readonly ICON: "toy-brick";
|
|
167
|
-
readonly PROPS: {};
|
|
168
|
-
};
|
|
169
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONSTANTS = void 0;
|
|
4
|
-
exports.isValidPosition = isValidPosition;
|
|
5
|
-
/**
|
|
6
|
-
* Type guard to check if position is valid.
|
|
7
|
-
*/
|
|
8
|
-
function isValidPosition(position) {
|
|
9
|
-
return position === 'top' || position === 'bottom';
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Constants used throughout the plugin system.
|
|
13
|
-
*/
|
|
14
|
-
exports.CONSTANTS = {
|
|
15
|
-
/**
|
|
16
|
-
* Virtual module ID for importing plugins
|
|
17
|
-
*/
|
|
18
|
-
VIRTUAL_MODULE_ID: 'virtual:motia-plugins',
|
|
19
|
-
/**
|
|
20
|
-
* Resolved virtual module ID (with null byte prefix for Vite)
|
|
21
|
-
*/
|
|
22
|
-
RESOLVED_VIRTUAL_MODULE_ID: '\0virtual:motia-plugins',
|
|
23
|
-
/**
|
|
24
|
-
* Log prefix for all plugin messages
|
|
25
|
-
*/
|
|
26
|
-
LOG_PREFIX: '[motia-plugins]',
|
|
27
|
-
/**
|
|
28
|
-
* Default values for optional plugin fields
|
|
29
|
-
*/
|
|
30
|
-
DEFAULTS: {
|
|
31
|
-
POSITION: 'top',
|
|
32
|
-
LABEL: 'Plugin label',
|
|
33
|
-
ICON: 'toy-brick',
|
|
34
|
-
PROPS: {},
|
|
35
|
-
},
|
|
36
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizePath = normalizePath;
|
|
7
|
-
exports.isLocalPlugin = isLocalPlugin;
|
|
8
|
-
exports.resolveLocalPath = resolveLocalPath;
|
|
9
|
-
exports.resolveNpmPath = resolveNpmPath;
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
/**
|
|
12
|
-
* Normalizes a file path by replacing backslashes with forward slashes.
|
|
13
|
-
* This is useful for consistent path comparisons across different operating systems.
|
|
14
|
-
*
|
|
15
|
-
* @param filePath - The file path to normalize
|
|
16
|
-
* @returns The normalized file path with forward slashes
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* normalizePath('C:\\Users\\file.ts') // Returns: 'C:/Users/file.ts'
|
|
21
|
-
* normalizePath('/Users/file.ts') // Returns: '/Users/file.ts'
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
function normalizePath(filePath) {
|
|
25
|
-
return filePath.replace(/\\/g, '/');
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Checks if a package name represents a local plugin (starts with ~/).
|
|
29
|
-
*
|
|
30
|
-
* @param packageName - The package name to check
|
|
31
|
-
* @returns True if the package is a local plugin
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* isLocalPlugin('~/plugins/my-plugin') // Returns: true
|
|
36
|
-
* isLocalPlugin('@my-org/my-plugin') // Returns: false
|
|
37
|
-
* isLocalPlugin('my-plugin') // Returns: false
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
function isLocalPlugin(packageName) {
|
|
41
|
-
return packageName.startsWith('~/');
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Resolves a local plugin path to an absolute path.
|
|
45
|
-
* Strips the ~/ prefix and joins with the current working directory.
|
|
46
|
-
*
|
|
47
|
-
* @param packageName - The local plugin package name (must start with ~/)
|
|
48
|
-
* @returns The absolute path to the local plugin
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* // If cwd is /Users/project
|
|
53
|
-
* resolveLocalPath('~/plugins/my-plugin')
|
|
54
|
-
* // Returns: '/Users/project/plugins/my-plugin'
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
function resolveLocalPath(packageName) {
|
|
58
|
-
return path_1.default.join(process.cwd(), packageName.replace('~/', ''));
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Resolves an npm package path to the node_modules directory.
|
|
62
|
-
*
|
|
63
|
-
* @param packageName - The npm package name
|
|
64
|
-
* @returns The absolute path to the package in node_modules
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* // If cwd is /Users/project
|
|
69
|
-
* resolveNpmPath('@my-org/my-plugin')
|
|
70
|
-
* // Returns: '/Users/project/node_modules/@my-org/my-plugin'
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
function resolveNpmPath(packageName) {
|
|
74
|
-
return path_1.default.join(process.cwd(), 'node_modules', packageName);
|
|
75
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ValidationResult } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Validates a single plugin configuration.
|
|
4
|
-
*
|
|
5
|
-
* @param plugin - The plugin configuration to validate
|
|
6
|
-
* @param index - The index of the plugin in the array (for error messages)
|
|
7
|
-
* @returns A validation result with errors, warnings, and normalized plugin
|
|
8
|
-
*/
|
|
9
|
-
export declare function validatePluginConfig(plugin: any, index: number): ValidationResult;
|
|
10
|
-
/**
|
|
11
|
-
* Validates an array of plugin configurations.
|
|
12
|
-
*
|
|
13
|
-
* @param plugins - Array of plugin configurations to validate
|
|
14
|
-
* @param options - Validation options
|
|
15
|
-
* @returns Combined validation result for all plugins
|
|
16
|
-
*/
|
|
17
|
-
export declare function validatePlugins(plugins: any[], options?: {
|
|
18
|
-
failFast?: boolean;
|
|
19
|
-
}): ValidationResult;
|