@containerbase/base 14.53.0 → 14.55.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 +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/min-cb.d.ts +20 -0
- package/dist/min-cb.js +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,6 +121,19 @@ replaceUrl(
|
|
|
121
121
|
);
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
+
A tool's data may list `minCb` ranges, the oldest containerbase version which can install a version and every version above it.
|
|
125
|
+
`filterByMinCb(data, cbVersion)` returns the `versions` the given containerbase version can install, in the order of the data, and the `cb` values of the unmet ranges as `needed`.
|
|
126
|
+
A `cbVersion` which isn't a release, like `0.0.0-PLACEHOLDER` (see `isReleaseVersion(version)`), skips the filter:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { filterByMinCb, packageVersion } from '@containerbase/base';
|
|
130
|
+
import type { ToolVersions } from '@containerbase/base';
|
|
131
|
+
|
|
132
|
+
declare const data: ToolVersions; // the content of eg. `node.json`
|
|
133
|
+
|
|
134
|
+
const { versions, needed } = filterByMinCb(data, packageVersion);
|
|
135
|
+
```
|
|
136
|
+
|
|
124
137
|
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.
|
|
125
138
|
|
|
126
139
|
## Contents
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { DistroCode } from './types.ts';
|
|
|
3
3
|
export type { Arch, 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
5
|
export { containerbaseVersionFile, isCompatibleVersion, isContainerbase, packageVersion, toolVersionsPath, validateContainerbaseVersion, } from './containerbase.ts';
|
|
6
|
+
export { filterByMinCb } from './min-cb.ts';
|
|
7
|
+
export { isReleaseVersion } from './release-version.ts';
|
|
6
8
|
export { isToolVersionsFormat, toolVersionsFormat, toolVersionsFormatPath, } from './tool-versions-format.ts';
|
|
7
9
|
export type { UrlReplacement, UrlReplacements } from './url.ts';
|
|
8
10
|
export { getUrlReplacements, replaceUrl } from './url.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { tools } from "./data.js";
|
|
2
2
|
export { containerbaseVersionFile, isCompatibleVersion, isContainerbase, packageVersion, toolVersionsPath, validateContainerbaseVersion, } from "./containerbase.js";
|
|
3
|
+
export { filterByMinCb } from "./min-cb.js";
|
|
4
|
+
export { isReleaseVersion } from "./release-version.js";
|
|
3
5
|
export { isToolVersionsFormat, toolVersionsFormat, toolVersionsFormatPath, } from "./tool-versions-format.js";
|
|
4
6
|
export { getUrlReplacements, replaceUrl } from "./url.js";
|
|
5
7
|
export { tools };
|
package/dist/min-cb.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ToolVersion, ToolVersions } from './tool-versions-types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Filters the versions of a tool by the `minCb` ranges of its data, to the
|
|
4
|
+
* releases the given containerbase version can install.
|
|
5
|
+
*
|
|
6
|
+
* The data lists the newest release first. A range covers its `version` and
|
|
7
|
+
* every version above it in the data, prereleases count for the position. A
|
|
8
|
+
* range whose `version` is not listed is ignored. A range is met when its `cb`
|
|
9
|
+
* is valid semver and the containerbase version is the same or newer, a `cb`
|
|
10
|
+
* which is not valid semver is never met. A containerbase version which is not
|
|
11
|
+
* a release, like the development build `0.0.0-PLACEHOLDER`, skips the filter.
|
|
12
|
+
* @param data - the tool-versions data of a tool
|
|
13
|
+
* @param cbVersion - the containerbase version
|
|
14
|
+
* @returns the installable `versions` in the order of the data, and the `cb`
|
|
15
|
+
* values of the unmet ranges as `needed`
|
|
16
|
+
*/
|
|
17
|
+
export declare function filterByMinCb(data: ToolVersions, cbVersion: string): {
|
|
18
|
+
versions: ToolVersion[];
|
|
19
|
+
needed: string[];
|
|
20
|
+
};
|
package/dist/min-cb.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import semverGte from 'semver/functions/gte.js';
|
|
2
|
+
import semverValid from 'semver/functions/valid.js';
|
|
3
|
+
import { isReleaseVersion } from "./release-version.js";
|
|
4
|
+
/**
|
|
5
|
+
* Filters the versions of a tool by the `minCb` ranges of its data, to the
|
|
6
|
+
* releases the given containerbase version can install.
|
|
7
|
+
*
|
|
8
|
+
* The data lists the newest release first. A range covers its `version` and
|
|
9
|
+
* every version above it in the data, prereleases count for the position. A
|
|
10
|
+
* range whose `version` is not listed is ignored. A range is met when its `cb`
|
|
11
|
+
* is valid semver and the containerbase version is the same or newer, a `cb`
|
|
12
|
+
* which is not valid semver is never met. A containerbase version which is not
|
|
13
|
+
* a release, like the development build `0.0.0-PLACEHOLDER`, skips the filter.
|
|
14
|
+
* @param data - the tool-versions data of a tool
|
|
15
|
+
* @param cbVersion - the containerbase version
|
|
16
|
+
* @returns the installable `versions` in the order of the data, and the `cb`
|
|
17
|
+
* values of the unmet ranges as `needed`
|
|
18
|
+
*/
|
|
19
|
+
export function filterByMinCb(data, cbVersion) {
|
|
20
|
+
// the versions up to this index need a newer containerbase: a range which
|
|
21
|
+
// isn't met covers all versions from its start up to the newest one
|
|
22
|
+
let unmet = -1;
|
|
23
|
+
const needed = [];
|
|
24
|
+
if (isReleaseVersion(cbVersion)) {
|
|
25
|
+
for (const range of data.minCb ?? []) {
|
|
26
|
+
const start = data.versions.findIndex((v) => v.version === range.version);
|
|
27
|
+
if (start >= 0 &&
|
|
28
|
+
!(semverValid(range.cb) !== null && semverGte(cbVersion, range.cb))) {
|
|
29
|
+
unmet = Math.max(unmet, start);
|
|
30
|
+
needed.push(range.cb);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { versions: data.versions.slice(unmet + 1), needed };
|
|
35
|
+
}
|