@telorun/kernel 0.2.8 → 0.2.9
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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest-adapters/local-file-adapter.d.ts +2 -0
- package/dist/manifest-adapters/local-file-adapter.d.ts.map +1 -1
- package/dist/manifest-adapters/local-file-adapter.js +52 -13
- package/dist/manifest-adapters/local-file-adapter.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +1 -0
- package/src/manifest-adapters/local-file-adapter.ts +54 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ControllerRegistry } from "./controller-registry.js";
|
|
2
2
|
export { EvaluationContext } from "./evaluation-context.js";
|
|
3
|
+
export { LocalFileAdapter } from "./manifest-adapters/local-file-adapter.js";
|
|
3
4
|
export { EventStream } from "./event-stream.js";
|
|
4
5
|
export { ExecutionContext } from "./execution-context.js";
|
|
5
6
|
export { Kernel, type KernelOptions } from "./kernel.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ControllerRegistry } from "./controller-registry.js";
|
|
2
2
|
export { EvaluationContext } from "./evaluation-context.js";
|
|
3
|
+
export { LocalFileAdapter } from "./manifest-adapters/local-file-adapter.js";
|
|
3
4
|
export { EventStream } from "./event-stream.js";
|
|
4
5
|
export { ExecutionContext } from "./execution-context.js";
|
|
5
6
|
export { Kernel } from "./kernel.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -7,6 +7,8 @@ export declare class LocalFileAdapter implements ManifestAdapter {
|
|
|
7
7
|
}>;
|
|
8
8
|
readAll(pathOrUrl: string): Promise<string[]>;
|
|
9
9
|
resolveRelative(base: string, relative: string): string;
|
|
10
|
+
expandGlob(base: string, patterns: string[]): Promise<string[]>;
|
|
11
|
+
resolveOwnerOf(fileUrl: string): Promise<string | null>;
|
|
10
12
|
private collectYamlSources;
|
|
11
13
|
private isYamlFile;
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-file-adapter.d.ts","sourceRoot":"","sources":["../../src/manifest-adapters/local-file-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"local-file-adapter.d.ts","sourceRoot":"","sources":["../../src/manifest-adapters/local-file-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAcpF,qBAAa,gBAAiB,YAAW,eAAe;IACtD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAU9B,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAQlE,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IASnD,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAMjD,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgB/D,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAqB/C,kBAAkB;IAchC,OAAO,CAAC,UAAU;CAGnB"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_MANIFEST_FILENAME } from "@telorun/analyzer";
|
|
2
2
|
import * as fs from "fs/promises";
|
|
3
3
|
import * as path from "path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
5
|
+
import { minimatch } from "minimatch";
|
|
6
|
+
function toFilePath(pathOrUrl) {
|
|
7
|
+
return pathOrUrl.startsWith("file://") ? fileURLToPath(pathOrUrl) : pathOrUrl;
|
|
8
|
+
}
|
|
9
|
+
function toFileUrl(filePath) {
|
|
10
|
+
return pathToFileURL(filePath).href;
|
|
11
|
+
}
|
|
4
12
|
export class LocalFileAdapter {
|
|
5
13
|
supports(pathOrUrl) {
|
|
6
14
|
return (pathOrUrl.startsWith("file://") ||
|
|
@@ -10,30 +18,61 @@ export class LocalFileAdapter {
|
|
|
10
18
|
(!pathOrUrl.includes("://") && !pathOrUrl.includes("@")));
|
|
11
19
|
}
|
|
12
20
|
async read(pathOrUrl) {
|
|
13
|
-
const
|
|
14
|
-
? new URL(pathOrUrl).pathname
|
|
15
|
-
: pathOrUrl;
|
|
16
|
-
const resolvedPath = path.resolve(normalizedPath);
|
|
21
|
+
const resolvedPath = path.resolve(toFilePath(pathOrUrl));
|
|
17
22
|
const stat = await fs.stat(resolvedPath);
|
|
18
23
|
const filePath = stat.isDirectory() ? path.join(resolvedPath, DEFAULT_MANIFEST_FILENAME) : resolvedPath;
|
|
19
24
|
const text = await fs.readFile(filePath, "utf-8");
|
|
20
|
-
return { text, source:
|
|
25
|
+
return { text, source: toFileUrl(filePath) };
|
|
21
26
|
}
|
|
22
27
|
async readAll(pathOrUrl) {
|
|
23
|
-
const
|
|
24
|
-
? new URL(pathOrUrl).pathname
|
|
25
|
-
: pathOrUrl;
|
|
26
|
-
const resolvedPath = path.resolve(normalizedPath);
|
|
28
|
+
const resolvedPath = path.resolve(toFilePath(pathOrUrl));
|
|
27
29
|
const stat = await fs.stat(resolvedPath);
|
|
28
30
|
if (stat.isDirectory()) {
|
|
29
31
|
return this.collectYamlSources(resolvedPath);
|
|
30
32
|
}
|
|
31
|
-
return [
|
|
33
|
+
return [toFileUrl(resolvedPath)];
|
|
32
34
|
}
|
|
33
35
|
resolveRelative(base, relative) {
|
|
34
|
-
const basePath =
|
|
36
|
+
const basePath = toFilePath(base);
|
|
35
37
|
const baseDir = basePath.endsWith("/") ? basePath : path.dirname(basePath);
|
|
36
|
-
return
|
|
38
|
+
return toFileUrl(path.resolve(baseDir, relative));
|
|
39
|
+
}
|
|
40
|
+
async expandGlob(base, patterns) {
|
|
41
|
+
const baseDir = path.dirname(path.resolve(toFilePath(base)));
|
|
42
|
+
const entries = await fs.readdir(baseDir, { recursive: true, withFileTypes: true });
|
|
43
|
+
const normalizedPatterns = patterns.map((p) => p.replace(/\\/g, "/").replace(/^\.\//, ""));
|
|
44
|
+
const matched = [];
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
if (!entry.isFile())
|
|
47
|
+
continue;
|
|
48
|
+
const relative = path.relative(baseDir, path.join(entry.parentPath, entry.name));
|
|
49
|
+
const normalized = relative.replace(/\\/g, "/");
|
|
50
|
+
if (normalizedPatterns.some((p) => minimatch(normalized, p))) {
|
|
51
|
+
matched.push(toFileUrl(path.resolve(baseDir, relative)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return matched.sort();
|
|
55
|
+
}
|
|
56
|
+
async resolveOwnerOf(fileUrl) {
|
|
57
|
+
const resolved = path.resolve(toFilePath(fileUrl));
|
|
58
|
+
let dir = path.dirname(resolved);
|
|
59
|
+
while (true) {
|
|
60
|
+
const candidate = path.join(dir, DEFAULT_MANIFEST_FILENAME);
|
|
61
|
+
if (candidate !== resolved) {
|
|
62
|
+
try {
|
|
63
|
+
await fs.access(candidate);
|
|
64
|
+
return toFileUrl(candidate);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// telo.yaml not found at this level
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const parent = path.dirname(dir);
|
|
71
|
+
if (parent === dir)
|
|
72
|
+
break;
|
|
73
|
+
dir = parent;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
37
76
|
}
|
|
38
77
|
async collectYamlSources(dirPath) {
|
|
39
78
|
const sources = [];
|
|
@@ -44,7 +83,7 @@ export class LocalFileAdapter {
|
|
|
44
83
|
sources.push(...(await this.collectYamlSources(fullPath)));
|
|
45
84
|
}
|
|
46
85
|
else if (entry.isFile() && this.isYamlFile(entry.name)) {
|
|
47
|
-
sources.push(
|
|
86
|
+
sources.push(toFileUrl(fullPath));
|
|
48
87
|
}
|
|
49
88
|
}
|
|
50
89
|
return sources;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-file-adapter.js","sourceRoot":"","sources":["../../src/manifest-adapters/local-file-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAwB,MAAM,mBAAmB,CAAC;AACpF,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"local-file-adapter.js","sourceRoot":"","sources":["../../src/manifest-adapters/local-file-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAwB,MAAM,mBAAmB,CAAC;AACpF,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,SAAS,UAAU,CAAC,SAAiB;IACnC,OAAO,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAED,SAAS,SAAS,CAAC,QAAgB;IACjC,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC;AAED,MAAM,OAAO,gBAAgB;IAC3B,QAAQ,CAAC,SAAiB;QACxB,OAAO,CACL,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC;YAC/B,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;YACzB,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;YAC1B,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,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AAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,UAAU,CAAC,QAAgB;QACjC,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/kernel",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Telo Runtime - A lightweight, polyglot execution host.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"digly",
|
|
@@ -35,12 +35,13 @@
|
|
|
35
35
|
"src/**"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@marcbachmann/cel-js": "^7.5.3",
|
|
38
39
|
"@sinclair/typebox": "^0.34.48",
|
|
39
40
|
"ajv": "^8.17.1",
|
|
40
41
|
"ajv-formats": "^3.0.1",
|
|
41
|
-
"
|
|
42
|
+
"minimatch": "^10.2.5",
|
|
42
43
|
"packageurl-js": "^2.0.1",
|
|
43
|
-
"@telorun/analyzer": "0.1.
|
|
44
|
+
"@telorun/analyzer": "0.1.4",
|
|
44
45
|
"@telorun/sdk": "0.2.8",
|
|
45
46
|
"@telorun/yaml-cel-templating": "1.0.4"
|
|
46
47
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ControllerRegistry } from "./controller-registry.js";
|
|
2
2
|
export { EvaluationContext } from "./evaluation-context.js";
|
|
3
|
+
export { LocalFileAdapter } from "./manifest-adapters/local-file-adapter.js";
|
|
3
4
|
export { EventStream } from "./event-stream.js";
|
|
4
5
|
export { ExecutionContext } from "./execution-context.js";
|
|
5
6
|
export { Kernel, type KernelOptions } from "./kernel.js";
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { DEFAULT_MANIFEST_FILENAME, type ManifestAdapter } from "@telorun/analyzer";
|
|
2
2
|
import * as fs from "fs/promises";
|
|
3
3
|
import * as path from "path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
5
|
+
import { minimatch } from "minimatch";
|
|
6
|
+
|
|
7
|
+
function toFilePath(pathOrUrl: string): string {
|
|
8
|
+
return pathOrUrl.startsWith("file://") ? fileURLToPath(pathOrUrl) : pathOrUrl;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function toFileUrl(filePath: string): string {
|
|
12
|
+
return pathToFileURL(filePath).href;
|
|
13
|
+
}
|
|
4
14
|
|
|
5
15
|
export class LocalFileAdapter implements ManifestAdapter {
|
|
6
16
|
supports(pathOrUrl: string): boolean {
|
|
@@ -14,32 +24,63 @@ export class LocalFileAdapter implements ManifestAdapter {
|
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
async read(pathOrUrl: string): Promise<{ text: string; source: string }> {
|
|
17
|
-
const
|
|
18
|
-
? new URL(pathOrUrl).pathname
|
|
19
|
-
: pathOrUrl;
|
|
20
|
-
const resolvedPath = path.resolve(normalizedPath);
|
|
27
|
+
const resolvedPath = path.resolve(toFilePath(pathOrUrl));
|
|
21
28
|
const stat = await fs.stat(resolvedPath);
|
|
22
29
|
const filePath = stat.isDirectory() ? path.join(resolvedPath, DEFAULT_MANIFEST_FILENAME) : resolvedPath;
|
|
23
30
|
const text = await fs.readFile(filePath, "utf-8");
|
|
24
|
-
return { text, source:
|
|
31
|
+
return { text, source: toFileUrl(filePath) };
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
async readAll(pathOrUrl: string): Promise<string[]> {
|
|
28
|
-
const
|
|
29
|
-
? new URL(pathOrUrl).pathname
|
|
30
|
-
: pathOrUrl;
|
|
31
|
-
const resolvedPath = path.resolve(normalizedPath);
|
|
35
|
+
const resolvedPath = path.resolve(toFilePath(pathOrUrl));
|
|
32
36
|
const stat = await fs.stat(resolvedPath);
|
|
33
37
|
if (stat.isDirectory()) {
|
|
34
38
|
return this.collectYamlSources(resolvedPath);
|
|
35
39
|
}
|
|
36
|
-
return [
|
|
40
|
+
return [toFileUrl(resolvedPath)];
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
resolveRelative(base: string, relative: string): string {
|
|
40
|
-
const basePath =
|
|
44
|
+
const basePath = toFilePath(base);
|
|
41
45
|
const baseDir = basePath.endsWith("/") ? basePath : path.dirname(basePath);
|
|
42
|
-
return
|
|
46
|
+
return toFileUrl(path.resolve(baseDir, relative));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async expandGlob(base: string, patterns: string[]): Promise<string[]> {
|
|
50
|
+
const baseDir = path.dirname(path.resolve(toFilePath(base)));
|
|
51
|
+
const entries = await fs.readdir(baseDir, { recursive: true, withFileTypes: true });
|
|
52
|
+
const normalizedPatterns = patterns.map((p) => p.replace(/\\/g, "/").replace(/^\.\//, ""));
|
|
53
|
+
const matched: string[] = [];
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
if (!entry.isFile()) continue;
|
|
56
|
+
const relative = path.relative(baseDir, path.join(entry.parentPath, entry.name));
|
|
57
|
+
const normalized = relative.replace(/\\/g, "/");
|
|
58
|
+
if (normalizedPatterns.some((p) => minimatch(normalized, p))) {
|
|
59
|
+
matched.push(toFileUrl(path.resolve(baseDir, relative)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return matched.sort();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async resolveOwnerOf(fileUrl: string): Promise<string | null> {
|
|
66
|
+
const resolved = path.resolve(toFilePath(fileUrl));
|
|
67
|
+
let dir = path.dirname(resolved);
|
|
68
|
+
|
|
69
|
+
while (true) {
|
|
70
|
+
const candidate = path.join(dir, DEFAULT_MANIFEST_FILENAME);
|
|
71
|
+
if (candidate !== resolved) {
|
|
72
|
+
try {
|
|
73
|
+
await fs.access(candidate);
|
|
74
|
+
return toFileUrl(candidate);
|
|
75
|
+
} catch {
|
|
76
|
+
// telo.yaml not found at this level
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const parent = path.dirname(dir);
|
|
80
|
+
if (parent === dir) break;
|
|
81
|
+
dir = parent;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
43
84
|
}
|
|
44
85
|
|
|
45
86
|
private async collectYamlSources(dirPath: string): Promise<string[]> {
|
|
@@ -50,7 +91,7 @@ export class LocalFileAdapter implements ManifestAdapter {
|
|
|
50
91
|
if (entry.isDirectory()) {
|
|
51
92
|
sources.push(...(await this.collectYamlSources(fullPath)));
|
|
52
93
|
} else if (entry.isFile() && this.isYamlFile(entry.name)) {
|
|
53
|
-
sources.push(
|
|
94
|
+
sources.push(toFileUrl(fullPath));
|
|
54
95
|
}
|
|
55
96
|
}
|
|
56
97
|
return sources;
|