@ucdjs/pipelines-loader 0.0.1-beta.6 → 0.0.1-beta.8
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/README.md +0 -3
- package/dist/discover-C_YruvBu.d.mts +69 -0
- package/dist/discover.d.mts +2 -0
- package/dist/discover.mjs +53 -0
- package/dist/index.d.mts +119 -10
- package/dist/index.mjs +572 -50
- package/package.json +13 -15
- package/dist/chunk-DQk6qfdC.mjs +0 -18
- package/dist/insecure-lzOoh_sk.mjs +0 -346
- package/dist/insecure.d.mts +0 -10
- package/dist/insecure.mjs +0 -3
- package/dist/remote-PQ_FXnt1.d.mts +0 -46
- package/dist/remote.d.mts +0 -3
- package/dist/remote.mjs +0 -76
- package/dist/types-Br8gGmsN.d.mts +0 -41
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[![npm version][npm-version-src]][npm-version-href]
|
|
4
4
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
-
[![codecov][codecov-src]][codecov-href]
|
|
6
5
|
|
|
7
6
|
> [!IMPORTANT]
|
|
8
7
|
> This is an internal package. It may change without warning and is not subject to semantic versioning. Use at your own risk.
|
|
@@ -23,5 +22,3 @@ Published under [MIT License](./LICENSE).
|
|
|
23
22
|
[npm-version-href]: https://npmjs.com/package/@ucdjs/pipelines-loader
|
|
24
23
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@ucdjs/pipelines-loader?style=flat&colorA=18181B&colorB=4169E1
|
|
25
24
|
[npm-downloads-href]: https://npmjs.com/package/@ucdjs/pipelines-loader
|
|
26
|
-
[codecov-src]: https://img.shields.io/codecov/c/gh/ucdjs/ucd?style=flat&colorA=18181B&colorB=4169E1
|
|
27
|
-
[codecov-href]: https://codecov.io/gh/ucdjs/ucd
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
declare const PIPELINE_LOADER_ISSUE_CODES: readonly ["INVALID_LOCATOR", "CACHE_MISS", "REF_RESOLUTION_FAILED", "DOWNLOAD_FAILED", "MATERIALIZE_FAILED", "DISCOVERY_FAILED", "BUNDLE_RESOLVE_FAILED", "BUNDLE_TRANSFORM_FAILED", "IMPORT_FAILED", "INVALID_EXPORT"];
|
|
3
|
+
type PipelineLoaderIssueCode = (typeof PIPELINE_LOADER_ISSUE_CODES)[number];
|
|
4
|
+
type PipelineLoaderIssueScope = "locator" | "repository" | "discovery" | "file" | "bundle" | "import";
|
|
5
|
+
interface PipelineLoaderIssue {
|
|
6
|
+
code: PipelineLoaderIssueCode;
|
|
7
|
+
scope: PipelineLoaderIssueScope;
|
|
8
|
+
message: string;
|
|
9
|
+
locator?: unknown;
|
|
10
|
+
repositoryPath?: string;
|
|
11
|
+
filePath?: string;
|
|
12
|
+
relativePath?: string;
|
|
13
|
+
cause?: Error;
|
|
14
|
+
meta?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
declare class PipelineLoaderError extends Error {
|
|
17
|
+
readonly code: PipelineLoaderIssueCode;
|
|
18
|
+
constructor(code: PipelineLoaderIssueCode, message: string, options?: ErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
declare class CacheMissError extends PipelineLoaderError {
|
|
21
|
+
readonly provider: string;
|
|
22
|
+
readonly owner: string;
|
|
23
|
+
readonly repo: string;
|
|
24
|
+
readonly ref: string;
|
|
25
|
+
constructor(provider: string, owner: string, repo: string, ref: string);
|
|
26
|
+
}
|
|
27
|
+
declare class BundleError extends PipelineLoaderError {
|
|
28
|
+
readonly entryPath: string;
|
|
29
|
+
constructor(entryPath: string, message: string, options?: ErrorOptions);
|
|
30
|
+
}
|
|
31
|
+
declare class BundleResolveError extends PipelineLoaderError {
|
|
32
|
+
readonly entryPath: string;
|
|
33
|
+
readonly importPath: string;
|
|
34
|
+
constructor(entryPath: string, importPath: string, options?: ErrorOptions);
|
|
35
|
+
}
|
|
36
|
+
declare class BundleTransformError extends PipelineLoaderError {
|
|
37
|
+
readonly entryPath: string;
|
|
38
|
+
readonly line?: number;
|
|
39
|
+
readonly column?: number;
|
|
40
|
+
constructor(entryPath: string, options?: ErrorOptions & {
|
|
41
|
+
line?: number;
|
|
42
|
+
column?: number;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/discover.d.ts
|
|
47
|
+
interface RemoteOriginMeta {
|
|
48
|
+
provider: "github" | "gitlab";
|
|
49
|
+
owner: string;
|
|
50
|
+
repo: string;
|
|
51
|
+
ref: string;
|
|
52
|
+
path?: string;
|
|
53
|
+
}
|
|
54
|
+
interface DiscoverPipelineFilesOptions {
|
|
55
|
+
repositoryPath: string;
|
|
56
|
+
patterns?: string | string[];
|
|
57
|
+
origin?: RemoteOriginMeta;
|
|
58
|
+
}
|
|
59
|
+
interface DiscoverPipelineFilesResult {
|
|
60
|
+
files: Array<{
|
|
61
|
+
filePath: string;
|
|
62
|
+
relativePath: string;
|
|
63
|
+
origin?: RemoteOriginMeta;
|
|
64
|
+
}>;
|
|
65
|
+
issues: PipelineLoaderIssue[];
|
|
66
|
+
}
|
|
67
|
+
declare function discoverPipelineFiles(options: DiscoverPipelineFilesOptions): Promise<DiscoverPipelineFilesResult>;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { BundleError as a, CacheMissError as c, discoverPipelineFiles as i, PipelineLoaderError as l, DiscoverPipelineFilesResult as n, BundleResolveError as o, RemoteOriginMeta as r, BundleTransformError as s, DiscoverPipelineFilesOptions as t, PipelineLoaderIssue as u };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { glob } from "tinyglobby";
|
|
3
|
+
//#region src/discover.ts
|
|
4
|
+
const TRAILING_SLASH_RE = /\/$/;
|
|
5
|
+
const BACKSLASH_RE = /\\/g;
|
|
6
|
+
function joinOriginPath(origin, relativePath) {
|
|
7
|
+
if (!origin) return void 0;
|
|
8
|
+
return {
|
|
9
|
+
...origin,
|
|
10
|
+
path: origin.path ? `${origin.path.replace(TRAILING_SLASH_RE, "")}/${relativePath}` : relativePath
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
async function discoverPipelineFiles(options) {
|
|
14
|
+
const patterns = options.patterns ? Array.isArray(options.patterns) ? options.patterns : [options.patterns] : ["**/*.ucd-pipeline.ts"];
|
|
15
|
+
try {
|
|
16
|
+
return {
|
|
17
|
+
files: (await glob(patterns, {
|
|
18
|
+
cwd: options.repositoryPath,
|
|
19
|
+
ignore: [
|
|
20
|
+
"node_modules/**",
|
|
21
|
+
"**/node_modules/**",
|
|
22
|
+
"**/dist/**",
|
|
23
|
+
"**/build/**",
|
|
24
|
+
"**/.git/**"
|
|
25
|
+
],
|
|
26
|
+
absolute: true,
|
|
27
|
+
onlyFiles: true
|
|
28
|
+
})).map((filePath) => {
|
|
29
|
+
const relativePath = relative(options.repositoryPath, filePath).replace(BACKSLASH_RE, "/");
|
|
30
|
+
return {
|
|
31
|
+
filePath,
|
|
32
|
+
relativePath,
|
|
33
|
+
origin: joinOriginPath(options.origin, relativePath)
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
issues: []
|
|
37
|
+
};
|
|
38
|
+
} catch (err) {
|
|
39
|
+
const cause = err instanceof Error ? err : new Error(String(err));
|
|
40
|
+
return {
|
|
41
|
+
files: [],
|
|
42
|
+
issues: [{
|
|
43
|
+
code: "DISCOVERY_FAILED",
|
|
44
|
+
scope: "discovery",
|
|
45
|
+
message: cause.message,
|
|
46
|
+
repositoryPath: options.repositoryPath,
|
|
47
|
+
cause
|
|
48
|
+
}]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { discoverPipelineFiles };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,125 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
1
|
+
import { a as BundleError, c as CacheMissError, l as PipelineLoaderError, o as BundleResolveError, r as RemoteOriginMeta, s as BundleTransformError, u as PipelineLoaderIssue } from "./discover-C_YruvBu.mjs";
|
|
2
|
+
import { PipelineDefinition } from "@ucdjs/pipelines-core";
|
|
3
3
|
|
|
4
|
+
//#region src/cache.d.ts
|
|
5
|
+
type RemoteProvider = "github" | "gitlab";
|
|
6
|
+
interface RemoteCacheStatus {
|
|
7
|
+
provider: RemoteProvider;
|
|
8
|
+
owner: string;
|
|
9
|
+
repo: string;
|
|
10
|
+
ref: string;
|
|
11
|
+
commitSha: string;
|
|
12
|
+
cacheDir: string;
|
|
13
|
+
markerPath: string;
|
|
14
|
+
cached: boolean;
|
|
15
|
+
syncedAt: string | null;
|
|
16
|
+
}
|
|
17
|
+
declare function getRemoteSourceCacheStatus(input: {
|
|
18
|
+
provider: RemoteProvider;
|
|
19
|
+
owner: string;
|
|
20
|
+
repo: string;
|
|
21
|
+
ref?: string;
|
|
22
|
+
}): Promise<RemoteCacheStatus>;
|
|
23
|
+
/**
|
|
24
|
+
* Write a cache marker for a remote source.
|
|
25
|
+
* Call this after downloading and extracting the archive.
|
|
26
|
+
*/
|
|
27
|
+
declare function writeCacheMarker(input: {
|
|
28
|
+
provider: RemoteProvider;
|
|
29
|
+
owner: string;
|
|
30
|
+
repo: string;
|
|
31
|
+
ref: string;
|
|
32
|
+
commitSha: string;
|
|
33
|
+
cacheDir: string;
|
|
34
|
+
markerPath: string;
|
|
35
|
+
}): Promise<void>;
|
|
36
|
+
declare function clearRemoteSourceCache(input: {
|
|
37
|
+
provider: RemoteProvider;
|
|
38
|
+
owner: string;
|
|
39
|
+
repo: string;
|
|
40
|
+
ref?: string;
|
|
41
|
+
}): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* List all cached remote sources.
|
|
44
|
+
*/
|
|
45
|
+
declare function listCachedSources(): Promise<Array<{
|
|
46
|
+
source: string;
|
|
47
|
+
owner: string;
|
|
48
|
+
repo: string;
|
|
49
|
+
ref: string;
|
|
50
|
+
commitSha: string;
|
|
51
|
+
syncedAt: string;
|
|
52
|
+
cacheDir: string;
|
|
53
|
+
}>>;
|
|
54
|
+
//#endregion
|
|
4
55
|
//#region src/loader.d.ts
|
|
56
|
+
interface LoadedPipelineFile {
|
|
57
|
+
filePath: string;
|
|
58
|
+
pipelines: PipelineDefinition[];
|
|
59
|
+
exportNames: string[];
|
|
60
|
+
}
|
|
61
|
+
interface LoadPipelinesResult {
|
|
62
|
+
pipelines: PipelineDefinition[];
|
|
63
|
+
files: LoadedPipelineFile[];
|
|
64
|
+
issues: PipelineLoaderIssue[];
|
|
65
|
+
}
|
|
5
66
|
declare function loadPipelineFile(filePath: string): Promise<LoadedPipelineFile>;
|
|
6
|
-
|
|
7
|
-
|
|
67
|
+
declare function loadPipelinesFromPaths(filePaths: string[]): Promise<LoadPipelinesResult>;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/materialize.d.ts
|
|
70
|
+
interface LocalPipelineLocator {
|
|
71
|
+
kind: "local";
|
|
72
|
+
path: string;
|
|
73
|
+
}
|
|
74
|
+
interface RemotePipelineLocator {
|
|
75
|
+
kind: "remote";
|
|
76
|
+
provider: "github" | "gitlab";
|
|
77
|
+
owner: string;
|
|
78
|
+
repo: string;
|
|
79
|
+
ref?: string;
|
|
80
|
+
path?: string;
|
|
81
|
+
}
|
|
82
|
+
type PipelineLocator = LocalPipelineLocator | RemotePipelineLocator;
|
|
83
|
+
interface MaterializePipelineLocatorResult {
|
|
84
|
+
repositoryPath?: string;
|
|
85
|
+
filePath?: string;
|
|
86
|
+
relativePath?: string;
|
|
87
|
+
origin?: RemoteOriginMeta;
|
|
88
|
+
issues: PipelineLoaderIssue[];
|
|
89
|
+
}
|
|
90
|
+
declare function materializePipelineLocator(locator: PipelineLocator): Promise<MaterializePipelineLocatorResult>;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/locator.d.ts
|
|
93
|
+
declare function parsePipelineLocator(input: string): PipelineLocator;
|
|
94
|
+
declare function parseRemoteSourceUrl(url: string): RemotePipelineLocator | null;
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/remote.d.ts
|
|
97
|
+
interface UpdateCheckResult {
|
|
98
|
+
hasUpdate: boolean;
|
|
99
|
+
currentSha: string | null;
|
|
100
|
+
remoteSha: string;
|
|
101
|
+
error?: Error;
|
|
8
102
|
}
|
|
9
|
-
declare function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
103
|
+
declare function checkRemoteLocatorUpdates(input: {
|
|
104
|
+
provider: "github" | "gitlab";
|
|
105
|
+
owner: string;
|
|
106
|
+
repo: string;
|
|
107
|
+
ref?: string;
|
|
108
|
+
}): Promise<UpdateCheckResult>;
|
|
109
|
+
interface SyncResult {
|
|
110
|
+
success: boolean;
|
|
111
|
+
updated: boolean;
|
|
112
|
+
previousSha: string | null;
|
|
113
|
+
newSha: string;
|
|
114
|
+
cacheDir: string;
|
|
115
|
+
error?: Error;
|
|
13
116
|
}
|
|
14
|
-
declare function
|
|
117
|
+
declare function ensureRemoteLocator(input: {
|
|
118
|
+
provider: "github" | "gitlab";
|
|
119
|
+
owner: string;
|
|
120
|
+
repo: string;
|
|
121
|
+
ref?: string;
|
|
122
|
+
force?: boolean;
|
|
123
|
+
}): Promise<SyncResult>;
|
|
15
124
|
//#endregion
|
|
16
|
-
export {
|
|
125
|
+
export { BundleError, BundleResolveError, BundleTransformError, CacheMissError, type LoadedPipelineFile, type LocalPipelineLocator, PipelineLoaderError, type PipelineLoaderIssue, type PipelineLocator, type RemoteCacheStatus, type RemoteOriginMeta, type RemotePipelineLocator, type SyncResult, type UpdateCheckResult, checkRemoteLocatorUpdates, clearRemoteSourceCache, ensureRemoteLocator, getRemoteSourceCacheStatus, listCachedSources, loadPipelineFile, loadPipelinesFromPaths, materializePipelineLocator, parsePipelineLocator, parseRemoteSourceUrl, writeCacheMarker };
|