@containerbase/base 14.43.0 → 14.44.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/README.md +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tool-versions-format.d.ts +24 -0
- package/dist/tool-versions-format.js +35 -0
- package/dist/zod.d.ts +1 -0
- package/dist/zod.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,25 @@ import { ToolVersions } from '@containerbase/base/zod';
|
|
|
55
55
|
import type { ToolVersions as ToolVersionsType } from '@containerbase/base';
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
The format version the schemas describe is exported by both entry points, so a reader doesn't hardcode it:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import {
|
|
62
|
+
isToolVersionsFormat,
|
|
63
|
+
toolVersionsFormat,
|
|
64
|
+
toolVersionsFormatPath,
|
|
65
|
+
} from '@containerbase/base';
|
|
66
|
+
|
|
67
|
+
toolVersionsFormat; // 1
|
|
68
|
+
toolVersionsFormatPath; // 'v1', the folder of the format relative to the site root
|
|
69
|
+
isToolVersionsFormat(
|
|
70
|
+
'https://containerbase.github.io/tool-versions/v1/tool.schema.json',
|
|
71
|
+
); // true
|
|
72
|
+
isToolVersionsFormat(
|
|
73
|
+
'https://containerbase.github.io/tool-versions/v2/tool.schema.json',
|
|
74
|
+
); // false
|
|
75
|
+
```
|
|
76
|
+
|
|
58
77
|
The schemas ignore unknown keys and accept any arch name, so additive changes of the format don't break a reader; readers ignore files of an arch they don't know.
|
|
59
78
|
|
|
60
79
|
## Contents
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { tools } from './data.ts';
|
|
|
2
2
|
import type { DistroCode } from './types.ts';
|
|
3
3
|
export type { DistroCode, InstallToolType, ToolMetadata, ToolType, } from './types.ts';
|
|
4
4
|
export type { FileIntegrity, FileReference, FormatIndex, ToolFile, ToolIndex, ToolVersion, ToolVersions, VersionFiles, VersionIntegrity, } from './tool-versions-types.ts';
|
|
5
|
+
export { isToolVersionsFormat, toolVersionsFormat, toolVersionsFormatPath, } from './tool-versions-format.ts';
|
|
5
6
|
export { tools };
|
|
6
7
|
/**
|
|
7
8
|
* The Ubuntu release the default containerbase image is built from, the
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The major version of the tool-versions format the schemas of this package
|
|
3
|
+
* describe.
|
|
4
|
+
*/
|
|
5
|
+
export declare const toolVersionsFormat = 1;
|
|
6
|
+
/**
|
|
7
|
+
* The folder of the format relative to the root of the published
|
|
8
|
+
* tool-versions site, eg. `v1`, for building urls.
|
|
9
|
+
* To pick the format from the root index, match its `version` against
|
|
10
|
+
* `toolVersionsFormat`; its `path` is `v1/`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const toolVersionsFormatPath = "v1";
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the `$schema` url of a tool-versions file names a schema of the
|
|
15
|
+
* format this package describes, eg.
|
|
16
|
+
* `https://containerbase.github.io/tool-versions/v1/tool.schema.json`.
|
|
17
|
+
* Only the path of the url is checked, its query and fragment are ignored.
|
|
18
|
+
* The protocol and host are not checked, so mirrors work too.
|
|
19
|
+
*
|
|
20
|
+
* @param schemaUrl the `$schema` value of the file
|
|
21
|
+
* @returns `false` for the schema of another format, an invalid url or a
|
|
22
|
+
* missing value
|
|
23
|
+
*/
|
|
24
|
+
export declare function isToolVersionsFormat(schemaUrl: string | undefined): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The major version of the tool-versions format the schemas of this package
|
|
3
|
+
* describe.
|
|
4
|
+
*/
|
|
5
|
+
export const toolVersionsFormat = 1;
|
|
6
|
+
/**
|
|
7
|
+
* The folder of the format relative to the root of the published
|
|
8
|
+
* tool-versions site, eg. `v1`, for building urls.
|
|
9
|
+
* To pick the format from the root index, match its `version` against
|
|
10
|
+
* `toolVersionsFormat`; its `path` is `v1/`.
|
|
11
|
+
*/
|
|
12
|
+
export const toolVersionsFormatPath = `v${toolVersionsFormat}`;
|
|
13
|
+
const schemaUrlPattern = new RegExp(`/${toolVersionsFormatPath}/[^/]+\\.schema\\.json$`);
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the `$schema` url of a tool-versions file names a schema of the
|
|
16
|
+
* format this package describes, eg.
|
|
17
|
+
* `https://containerbase.github.io/tool-versions/v1/tool.schema.json`.
|
|
18
|
+
* Only the path of the url is checked, its query and fragment are ignored.
|
|
19
|
+
* The protocol and host are not checked, so mirrors work too.
|
|
20
|
+
*
|
|
21
|
+
* @param schemaUrl the `$schema` value of the file
|
|
22
|
+
* @returns `false` for the schema of another format, an invalid url or a
|
|
23
|
+
* missing value
|
|
24
|
+
*/
|
|
25
|
+
export function isToolVersionsFormat(schemaUrl) {
|
|
26
|
+
if (schemaUrl === undefined) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
return schemaUrlPattern.test(new URL(schemaUrl).pathname);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/zod.d.ts
CHANGED
package/dist/zod.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { toolNames } from "./index.js";
|
|
3
3
|
export * from "./schema.js";
|
|
4
|
+
export * from "./tool-versions-format.js";
|
|
4
5
|
export * from "./tool-versions-schema.js";
|
|
5
6
|
/**
|
|
6
7
|
* Enum of all tool names supported by the containerbase version this package
|