motia 0.0.22 → 0.0.23
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.
|
@@ -3,45 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateLockedData =
|
|
6
|
+
exports.generateLockedData = void 0;
|
|
7
7
|
const core_1 = require("@motiadev/core");
|
|
8
8
|
const crypto_1 = require("crypto");
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const yaml_1 = __importDefault(require("yaml"));
|
|
12
11
|
const version = `${(0, crypto_1.randomUUID)()}:${Math.floor(Date.now() / 1000)}`;
|
|
13
|
-
const baseFlowRegex = new RegExp(/flows"?\s?.*\s*\[([^\]]+)\]/);
|
|
14
|
-
// Helper function to read config.yml
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
const readConfig = (configPath) => {
|
|
17
|
-
if (!fs_1.default.existsSync(configPath)) {
|
|
18
|
-
console.warn(`Config file not found at ${configPath}`);
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
const configContent = fs_1.default.readFileSync(configPath, 'utf-8');
|
|
22
|
-
return yaml_1.default.parse(configContent);
|
|
23
|
-
};
|
|
24
|
-
exports.readConfig = readConfig;
|
|
25
12
|
// Helper function to recursively collect flow data
|
|
26
|
-
const collectFlows = async (baseDir) => {
|
|
13
|
+
const collectFlows = async (baseDir, lockedData) => {
|
|
27
14
|
const folderItems = fs_1.default.readdirSync(baseDir, { withFileTypes: true });
|
|
28
15
|
let steps = [];
|
|
29
16
|
for (const item of folderItems) {
|
|
30
17
|
const filePath = path_1.default.join(baseDir, item.name);
|
|
31
18
|
if (item.isDirectory()) {
|
|
32
|
-
steps = steps.concat(await collectFlows(filePath));
|
|
19
|
+
steps = steps.concat(await collectFlows(filePath, lockedData));
|
|
33
20
|
}
|
|
34
21
|
else if (item.name.match(/\.step\.(ts|js|py|rb)$/)) {
|
|
35
|
-
const fileContent = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
36
|
-
const flowMatch = fileContent.match(baseFlowRegex);
|
|
37
22
|
const config = await (0, core_1.getStepConfig)(filePath);
|
|
38
23
|
if (!config) {
|
|
39
24
|
console.warn(`No config found in step ${filePath}, step skipped`);
|
|
40
25
|
continue;
|
|
41
26
|
}
|
|
42
|
-
|
|
43
|
-
steps.push({ filePath, version, config });
|
|
44
|
-
}
|
|
27
|
+
lockedData.createStep({ filePath, version, config });
|
|
45
28
|
}
|
|
46
29
|
}
|
|
47
30
|
return steps;
|
|
@@ -52,9 +35,8 @@ const generateLockedData = async (projectDir) => {
|
|
|
52
35
|
* NOTE: right now for performance and simplicity let's enforce a folder,
|
|
53
36
|
* but we might want to remove this and scan the entire current directory
|
|
54
37
|
*/
|
|
55
|
-
const sourceSteps = await collectFlows(path_1.default.join(projectDir, 'steps'));
|
|
56
38
|
const lockedData = new core_1.LockedData(projectDir);
|
|
57
|
-
|
|
39
|
+
await collectFlows(path_1.default.join(projectDir, 'steps'), lockedData);
|
|
58
40
|
return lockedData;
|
|
59
41
|
}
|
|
60
42
|
catch (error) {
|
package/dist/src/watcher.js
CHANGED
|
@@ -30,9 +30,10 @@ class Watcher {
|
|
|
30
30
|
console.warn(`No step create handler, step skipped`);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const config = await (0, core_1.getStepConfig)(path)
|
|
33
|
+
const config = await (0, core_1.getStepConfig)(path).catch((err) => {
|
|
34
|
+
console.error(err);
|
|
35
|
+
});
|
|
34
36
|
if (!config) {
|
|
35
|
-
console.warn(`No config found in step ${path}, step skipped`);
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
const version = `${(0, crypto_1.randomUUID)()}:${Math.floor(Date.now() / 1000)}`;
|
|
@@ -40,14 +41,11 @@ class Watcher {
|
|
|
40
41
|
this.stepCreateHandler?.(step);
|
|
41
42
|
}
|
|
42
43
|
async onFileChange(path) {
|
|
43
|
-
|
|
44
|
-
console.
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
const config = await (0, core_1.getStepConfig)(path);
|
|
44
|
+
const config = await (0, core_1.getStepConfig)(path).catch((err) => {
|
|
45
|
+
console.error(err);
|
|
46
|
+
});
|
|
48
47
|
const step = this.findStep(path);
|
|
49
48
|
if (!step && !config) {
|
|
50
|
-
console.warn(`Step ${path} not found, step skipped`);
|
|
51
49
|
return;
|
|
52
50
|
}
|
|
53
51
|
// didn't have a step, but now we have a config
|
|
@@ -67,10 +65,6 @@ class Watcher {
|
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
async onFileDelete(path) {
|
|
70
|
-
if (!this.stepDeleteHandler) {
|
|
71
|
-
console.warn(`No step delete handler, step skipped`);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
68
|
const step = this.findStep(path);
|
|
75
69
|
if (!step) {
|
|
76
70
|
console.warn(`Step ${path} not found, step skipped`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motia",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"motia": "dist/src/cli.js"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"inquirer": "^12.4.1",
|
|
15
15
|
"ts-node": "^10.9.2",
|
|
16
16
|
"yaml": "^2.7.0",
|
|
17
|
-
"@motiadev/core": "0.0.
|
|
18
|
-
"@motiadev/workbench": "0.0.
|
|
17
|
+
"@motiadev/core": "0.0.23",
|
|
18
|
+
"@motiadev/workbench": "0.0.23"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/figlet": "^1.7.0",
|