@containerbase/base 14.56.0 → 14.57.1
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 +21 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/logger.d.ts +30 -0
- package/dist/logger.js +24 -0
- package/dist/min-cb.d.ts +14 -0
- package/dist/min-cb.js +30 -0
- package/dist/tool-versions-schema.d.ts +14 -0
- package/dist/tool-versions-schema.js +21 -0
- package/dist/tool-versions-types.d.ts +32 -0
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ defaultDistro; // 'noble'
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
The format of the published [tool-versions](https://github.com/containerbase/tool-versions/blob/main/docs/format.md) data is exported too, so its readers share one definition.
|
|
51
|
-
The zod schemas (`ToolVersions`, `VersionFiles`, `VersionIntegrity`, `ToolIndex`, `FormatIndex` and their parts) live behind the `zod` entry point, the zod free types behind the main one:
|
|
51
|
+
The zod schemas (`ToolVersions`, `VersionFiles`, `VersionIntegrity`, `ToolIndex`, `FormatIndex`, `ReleaseInfo` and their parts) live behind the `zod` entry point, the zod free types behind the main one:
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
54
|
import { ToolVersions } from '@containerbase/base/zod';
|
|
@@ -134,8 +134,28 @@ declare const data: ToolVersions; // the content of eg. `node.json`
|
|
|
134
134
|
const { versions, needed } = filterByMinCb(data, packageVersion);
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
`minCbByVersion(data)` returns the containerbase version each covered tool version needs as a `Map` by version, the newest `cb` of the ranges covering it.
|
|
138
|
+
A `cb` which isn't valid semver wins over valid ones, as it is never met.
|
|
139
|
+
Versions no range covers aren't listed:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { minCbByVersion } from '@containerbase/base';
|
|
143
|
+
|
|
144
|
+
const needs = minCbByVersion(data); // eg. `needs.get('2.0.0')` is `'14.51.0'`
|
|
145
|
+
```
|
|
146
|
+
|
|
137
147
|
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.
|
|
138
148
|
|
|
149
|
+
The package logs nothing by default.
|
|
150
|
+
`configure({ logger })` sets the logger its functions log to, eg. a pino or Renovate logger, and `configure()` turns logging off again:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { configure } from '@containerbase/base';
|
|
154
|
+
import { logger } from './logger.ts';
|
|
155
|
+
|
|
156
|
+
configure({ logger });
|
|
157
|
+
```
|
|
158
|
+
|
|
139
159
|
## Contents
|
|
140
160
|
|
|
141
161
|
Each entry may carry the following metadata:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { tools } from './data.ts';
|
|
2
2
|
import type { DistroCode } from './types.ts';
|
|
3
3
|
export type { Arch, DistroCode, InstallToolType, ToolMetadata, ToolType, } from './types.ts';
|
|
4
|
-
export type { FileIntegrity, FileReference, FormatIndex, ToolFile, ToolIndex, ToolVersion, ToolVersions, VersionFiles, VersionIntegrity, } from './tool-versions-types.ts';
|
|
4
|
+
export type { FileIntegrity, FileReference, FormatIndex, ReleaseInfo, ToolFile, ToolIndex, ToolVersion, ToolVersions, VersionFiles, VersionIntegrity, } from './tool-versions-types.ts';
|
|
5
5
|
export { containerbaseVersionFile, isCompatibleVersion, isContainerbase, packageVersion, toolVersionsPath, validateContainerbaseVersion, } from './containerbase.ts';
|
|
6
|
-
export {
|
|
6
|
+
export type { ConfigureOptions, LogFn, Logger } from './logger.ts';
|
|
7
|
+
export { configure } from './logger.ts';
|
|
8
|
+
export { filterByMinCb, minCbByVersion } from './min-cb.ts';
|
|
7
9
|
export { isReleaseVersion } from './release-version.ts';
|
|
8
10
|
export { isToolVersionsFormat, toolVersionsFormat, toolVersionsFormatPath, } from './tool-versions-format.ts';
|
|
9
11
|
export type { UrlReplacement, UrlReplacements } from './url.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { tools } from "./data.js";
|
|
2
2
|
export { containerbaseVersionFile, isCompatibleVersion, isContainerbase, packageVersion, toolVersionsPath, validateContainerbaseVersion, } from "./containerbase.js";
|
|
3
|
-
export {
|
|
3
|
+
export { configure } from "./logger.js";
|
|
4
|
+
export { filterByMinCb, minCbByVersion } from "./min-cb.js";
|
|
4
5
|
export { isReleaseVersion } from "./release-version.js";
|
|
5
6
|
export { isToolVersionsFormat, toolVersionsFormat, toolVersionsFormatPath, } from "./tool-versions-format.js";
|
|
6
7
|
export { getUrlReplacements, replaceUrl } from "./url.js";
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A log method, called with a message or with metadata and an optional
|
|
3
|
+
* message, like the methods of a pino or Renovate logger.
|
|
4
|
+
*/
|
|
5
|
+
export interface LogFn {
|
|
6
|
+
(msg: string): void;
|
|
7
|
+
(meta: Record<string, unknown>, msg?: string): void;
|
|
8
|
+
}
|
|
9
|
+
/** The logger the package functions log to, see `configure`. */
|
|
10
|
+
export interface Logger {
|
|
11
|
+
trace: LogFn;
|
|
12
|
+
debug: LogFn;
|
|
13
|
+
info: LogFn;
|
|
14
|
+
warn: LogFn;
|
|
15
|
+
error: LogFn;
|
|
16
|
+
}
|
|
17
|
+
/** The package options `configure` sets. */
|
|
18
|
+
export interface ConfigureOptions {
|
|
19
|
+
/** The logger to log to, nothing is logged without one. */
|
|
20
|
+
logger?: Logger;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Configures the package, eg. sets the logger its functions log to. Options
|
|
24
|
+
* which are left out are reset to their defaults.
|
|
25
|
+
*
|
|
26
|
+
* @param options the options to set
|
|
27
|
+
*/
|
|
28
|
+
export declare function configure(options?: ConfigureOptions): void;
|
|
29
|
+
/** The logger set by `configure`, a silent one by default. */
|
|
30
|
+
export declare function getLogger(): Logger;
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const noop = () => {
|
|
2
|
+
// logging is off
|
|
3
|
+
};
|
|
4
|
+
const silentLogger = {
|
|
5
|
+
trace: noop,
|
|
6
|
+
debug: noop,
|
|
7
|
+
info: noop,
|
|
8
|
+
warn: noop,
|
|
9
|
+
error: noop,
|
|
10
|
+
};
|
|
11
|
+
let current = silentLogger;
|
|
12
|
+
/**
|
|
13
|
+
* Configures the package, eg. sets the logger its functions log to. Options
|
|
14
|
+
* which are left out are reset to their defaults.
|
|
15
|
+
*
|
|
16
|
+
* @param options the options to set
|
|
17
|
+
*/
|
|
18
|
+
export function configure(options = {}) {
|
|
19
|
+
current = options.logger ?? silentLogger;
|
|
20
|
+
}
|
|
21
|
+
/** The logger set by `configure`, a silent one by default. */
|
|
22
|
+
export function getLogger() {
|
|
23
|
+
return current;
|
|
24
|
+
}
|
package/dist/min-cb.d.ts
CHANGED
|
@@ -18,3 +18,17 @@ export declare function filterByMinCb(data: ToolVersions, cbVersion: string): {
|
|
|
18
18
|
versions: ToolVersion[];
|
|
19
19
|
needed: string[];
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Lists the containerbase version each tool version needs, by the `minCb`
|
|
23
|
+
* ranges of its data.
|
|
24
|
+
*
|
|
25
|
+
* The data lists the newest release first. A range covers its `version` and
|
|
26
|
+
* every version above it in the data, prereleases count for the position. A
|
|
27
|
+
* range whose `version` is not listed is ignored. A version covered by several
|
|
28
|
+
* ranges needs the newest `cb`, a `cb` which is not valid semver is never met
|
|
29
|
+
* and so wins over the valid ones, the first of several invalid ones is kept.
|
|
30
|
+
* @param data - the tool-versions data of a tool
|
|
31
|
+
* @returns the needed `cb` by version, versions without a covering range are
|
|
32
|
+
* not listed
|
|
33
|
+
*/
|
|
34
|
+
export declare function minCbByVersion(data: ToolVersions): Map<string, string>;
|
package/dist/min-cb.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import semverGt from 'semver/functions/gt.js';
|
|
1
2
|
import semverGte from 'semver/functions/gte.js';
|
|
2
3
|
import semverValid from 'semver/functions/valid.js';
|
|
3
4
|
import { isReleaseVersion } from "./release-version.js";
|
|
@@ -33,3 +34,32 @@ export function filterByMinCb(data, cbVersion) {
|
|
|
33
34
|
}
|
|
34
35
|
return { versions: data.versions.slice(unmet + 1), needed };
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Lists the containerbase version each tool version needs, by the `minCb`
|
|
39
|
+
* ranges of its data.
|
|
40
|
+
*
|
|
41
|
+
* The data lists the newest release first. A range covers its `version` and
|
|
42
|
+
* every version above it in the data, prereleases count for the position. A
|
|
43
|
+
* range whose `version` is not listed is ignored. A version covered by several
|
|
44
|
+
* ranges needs the newest `cb`, a `cb` which is not valid semver is never met
|
|
45
|
+
* and so wins over the valid ones, the first of several invalid ones is kept.
|
|
46
|
+
* @param data - the tool-versions data of a tool
|
|
47
|
+
* @returns the needed `cb` by version, versions without a covering range are
|
|
48
|
+
* not listed
|
|
49
|
+
*/
|
|
50
|
+
export function minCbByVersion(data) {
|
|
51
|
+
const result = new Map();
|
|
52
|
+
for (const range of data.minCb ?? []) {
|
|
53
|
+
const start = data.versions.findIndex((v) => v.version === range.version);
|
|
54
|
+
for (let i = 0; i <= start; i++) {
|
|
55
|
+
const version = data.versions[i].version;
|
|
56
|
+
const current = result.get(version);
|
|
57
|
+
if (current === undefined ||
|
|
58
|
+
(semverValid(current) !== null &&
|
|
59
|
+
(semverValid(range.cb) === null || semverGt(range.cb, current)))) {
|
|
60
|
+
result.set(version, range.cb);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
@@ -20,6 +20,7 @@ export declare const ToolVersion: z.ZodObject<{
|
|
|
20
20
|
version: z.ZodString;
|
|
21
21
|
prerelease: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
22
22
|
lts: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
23
|
+
deprecated: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
23
24
|
releaseTimestamp: z.ZodExactOptional<z.ZodISODateTime>;
|
|
24
25
|
files: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
|
|
25
26
|
name: z.ZodString;
|
|
@@ -44,6 +45,8 @@ export declare const ToolVersions: z.ZodObject<{
|
|
|
44
45
|
}>>;
|
|
45
46
|
sourceUrl: z.ZodExactOptional<z.ZodURL>;
|
|
46
47
|
homepage: z.ZodExactOptional<z.ZodURL>;
|
|
48
|
+
lts: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
49
|
+
latest: z.ZodExactOptional<z.ZodString>;
|
|
47
50
|
minVersion: z.ZodExactOptional<z.ZodString>;
|
|
48
51
|
distroMinVersion: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
49
52
|
minCb: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -55,6 +58,7 @@ export declare const ToolVersions: z.ZodObject<{
|
|
|
55
58
|
version: z.ZodString;
|
|
56
59
|
prerelease: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
57
60
|
lts: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
61
|
+
deprecated: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
58
62
|
releaseTimestamp: z.ZodExactOptional<z.ZodISODateTime>;
|
|
59
63
|
files: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
|
|
60
64
|
name: z.ZodString;
|
|
@@ -131,3 +135,13 @@ export declare const FormatIndex: z.ZodObject<{
|
|
|
131
135
|
removalDate: z.ZodExactOptional<z.ZodISODate>;
|
|
132
136
|
}, z.core.$strip>>;
|
|
133
137
|
}, z.core.$strip>;
|
|
138
|
+
/**
|
|
139
|
+
* The content of the root `release.json` file: the release the data belongs to
|
|
140
|
+
* and when it was built, so a reader with embedded data can tell whether the
|
|
141
|
+
* online data is newer without fetching it.
|
|
142
|
+
*/
|
|
143
|
+
export declare const ReleaseInfo: z.ZodObject<{
|
|
144
|
+
$schema: z.ZodExactOptional<z.ZodURL>;
|
|
145
|
+
version: z.ZodString;
|
|
146
|
+
buildTime: z.ZodISODateTime;
|
|
147
|
+
}, z.core.$strip>;
|
|
@@ -45,6 +45,8 @@ export const ToolVersion = z.object({
|
|
|
45
45
|
version: z.string().min(1),
|
|
46
46
|
prerelease: z.literal(true).exactOptional(),
|
|
47
47
|
lts: z.literal(true).exactOptional(),
|
|
48
|
+
/** the registry deprecates the version, only for npm tools */
|
|
49
|
+
deprecated: z.literal(true).exactOptional(),
|
|
48
50
|
/** when the version was released, in UTC */
|
|
49
51
|
releaseTimestamp: z.iso.datetime().exactOptional(),
|
|
50
52
|
/**
|
|
@@ -85,6 +87,13 @@ export const ToolVersions = z.object({
|
|
|
85
87
|
sourceUrl: z.url({ protocol: /^https$/ }).exactOptional(),
|
|
86
88
|
/** the homepage of the tool, omitted when unset */
|
|
87
89
|
homepage: z.url({ protocol: /^https$/ }).exactOptional(),
|
|
90
|
+
/** the tool has LTS release streams, like `node` and `java` */
|
|
91
|
+
lts: z.literal(true).exactOptional(),
|
|
92
|
+
/**
|
|
93
|
+
* the version of the npm `latest` dist-tag, only for npm tools and only when
|
|
94
|
+
* it is listed in `versions`
|
|
95
|
+
*/
|
|
96
|
+
latest: z.string().min(1).exactOptional(),
|
|
88
97
|
/**
|
|
89
98
|
* the oldest version containerbase supports, on the `defaultDistro` of the
|
|
90
99
|
* root index, in the versioning of the tool. Older versions aren't listed.
|
|
@@ -179,3 +188,15 @@ export const FormatIndex = z.object({
|
|
|
179
188
|
removalDate: z.iso.date().exactOptional(),
|
|
180
189
|
})),
|
|
181
190
|
});
|
|
191
|
+
/**
|
|
192
|
+
* The content of the root `release.json` file: the release the data belongs to
|
|
193
|
+
* and when it was built, so a reader with embedded data can tell whether the
|
|
194
|
+
* online data is newer without fetching it.
|
|
195
|
+
*/
|
|
196
|
+
export const ReleaseInfo = z.object({
|
|
197
|
+
$schema: SchemaUrl,
|
|
198
|
+
/** the version of the release, like `1.7.22` */
|
|
199
|
+
version: z.string().min(1),
|
|
200
|
+
/** when the build of the data started, in UTC */
|
|
201
|
+
buildTime: z.iso.datetime(),
|
|
202
|
+
});
|
|
@@ -41,6 +41,10 @@ export interface ToolVersion {
|
|
|
41
41
|
version: string;
|
|
42
42
|
prerelease?: true;
|
|
43
43
|
lts?: true;
|
|
44
|
+
/**
|
|
45
|
+
* The registry deprecates the version, only for npm tools.
|
|
46
|
+
*/
|
|
47
|
+
deprecated?: true;
|
|
44
48
|
/**
|
|
45
49
|
* When the version was released, in UTC.
|
|
46
50
|
*/
|
|
@@ -88,6 +92,15 @@ export interface ToolVersions {
|
|
|
88
92
|
* The homepage of the tool, omitted when unset.
|
|
89
93
|
*/
|
|
90
94
|
homepage?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The tool has LTS release streams, like `node` and `java`.
|
|
97
|
+
*/
|
|
98
|
+
lts?: true;
|
|
99
|
+
/**
|
|
100
|
+
* The version of the npm `latest` dist-tag, only for npm tools and only when
|
|
101
|
+
* it is listed in `versions`.
|
|
102
|
+
*/
|
|
103
|
+
latest?: string;
|
|
91
104
|
/**
|
|
92
105
|
* The oldest version containerbase supports, on the `defaultDistro` of the
|
|
93
106
|
* root index, in the versioning of the tool. Older versions aren't listed.
|
|
@@ -214,3 +227,22 @@ export interface FormatIndex {
|
|
|
214
227
|
removalDate?: string;
|
|
215
228
|
}[];
|
|
216
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* The content of the root `release.json` file: the release the data belongs to
|
|
232
|
+
* and when it was built, so a reader with embedded data can tell whether the
|
|
233
|
+
* online data is newer without fetching it.
|
|
234
|
+
*/
|
|
235
|
+
export interface ReleaseInfo {
|
|
236
|
+
/**
|
|
237
|
+
* The url of the json schema of the file, which identifies its format.
|
|
238
|
+
*/
|
|
239
|
+
$schema?: string;
|
|
240
|
+
/**
|
|
241
|
+
* The version of the release, like `1.7.22`.
|
|
242
|
+
*/
|
|
243
|
+
version: string;
|
|
244
|
+
/**
|
|
245
|
+
* When the build of the data started, in UTC.
|
|
246
|
+
*/
|
|
247
|
+
buildTime: string;
|
|
248
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@containerbase/base",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.57.1",
|
|
4
4
|
"description": "Metadata about the tools supported by containerbase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"containerbase",
|
|
7
7
|
"tools"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "https://github.com/containerbase/base#readme",
|
|
10
|
+
"license": "MIT",
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
12
13
|
"url": "https://github.com/containerbase/base.git",
|
|
13
14
|
"directory": "packages/base"
|
|
14
15
|
},
|
|
15
|
-
"
|
|
16
|
+
"files": [
|
|
17
|
+
"data",
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
16
20
|
"type": "module",
|
|
17
21
|
"exports": {
|
|
18
22
|
".": {
|
|
@@ -27,10 +31,10 @@
|
|
|
27
31
|
"./tools.json": "./data/tools.json",
|
|
28
32
|
"./tools.schema.json": "./data/tools.schema.json"
|
|
29
33
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"provenance": true
|
|
37
|
+
},
|
|
34
38
|
"dependencies": {
|
|
35
39
|
"semver": "^7.8.5"
|
|
36
40
|
},
|
|
@@ -48,9 +52,5 @@
|
|
|
48
52
|
},
|
|
49
53
|
"engines": {
|
|
50
54
|
"node": ">=24.10.0"
|
|
51
|
-
},
|
|
52
|
-
"publishConfig": {
|
|
53
|
-
"access": "public",
|
|
54
|
-
"provenance": true
|
|
55
55
|
}
|
|
56
56
|
}
|