@dsh-workbench/adapter-profile 1.0.0-beta.0 → 1.0.0-beta.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/dist/release.d.ts +2 -2
- package/dist/release.js +14 -28
- package/package.json +3 -3
package/dist/release.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { DshShell } from '@dsh-workbench/shared';
|
|
2
2
|
import type { PluginRelease } from '@dsh-workbench/shared';
|
|
3
3
|
export declare function parseLedgerVersion(stdout: string, name: string): string | undefined;
|
|
4
|
-
export
|
|
5
|
-
export { isNewerVersion } from '@dsh-workbench/shared/host';
|
|
4
|
+
export { compareVersions, isNewerVersion } from '@dsh-workbench/shared/host';
|
|
6
5
|
export declare function latestVersion(options: {
|
|
7
6
|
shell: DshShell;
|
|
8
7
|
name: string;
|
|
@@ -11,6 +10,7 @@ export declare function latestVersion(options: {
|
|
|
11
10
|
}): Promise<string | undefined>;
|
|
12
11
|
export declare function missingReleaseParts(options: {
|
|
13
12
|
shell: DshShell;
|
|
13
|
+
name: string;
|
|
14
14
|
registry: string;
|
|
15
15
|
version: string;
|
|
16
16
|
force?: boolean;
|
package/dist/release.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseJsonLoose, quoteShellArg } from '@dsh-workbench/shared/host';
|
|
1
|
+
import { RELEASE_PACKAGES, VERSION_CHECK_TIMEOUT_MS, VERSION_CHECK_TTL_MS, } from '@dsh-workbench/shared/host';
|
|
2
|
+
import { isValidVersion, parseJsonLoose, quoteShellArg } from '@dsh-workbench/shared/host';
|
|
3
3
|
import { npmCacheDir, vendorPrefix } from '@dsh-workbench/adapter-runtime';
|
|
4
4
|
import { runShell } from '@dsh-workbench/shared/host';
|
|
5
5
|
export function parseLedgerVersion(stdout, name) {
|
|
@@ -11,27 +11,14 @@ export function parseLedgerVersion(stdout, name) {
|
|
|
11
11
|
if (typeof entry !== "object" || entry === null)
|
|
12
12
|
return undefined;
|
|
13
13
|
const version = entry.version;
|
|
14
|
-
return typeof version === "string" &&
|
|
14
|
+
return typeof version === "string" && isValidVersion(version.trim())
|
|
15
15
|
? version.trim()
|
|
16
16
|
: undefined;
|
|
17
17
|
}
|
|
18
|
-
export
|
|
19
|
-
const na = a.split(".").map((part) => Number.parseInt(part, 10));
|
|
20
|
-
const nb = b.split(".").map((part) => Number.parseInt(part, 10));
|
|
21
|
-
if (na.some(Number.isNaN) || nb.some(Number.isNaN))
|
|
22
|
-
return undefined;
|
|
23
|
-
for (let index = 0; index < Math.max(na.length, nb.length); index += 1) {
|
|
24
|
-
const left = na[index] ?? 0;
|
|
25
|
-
const right = nb[index] ?? 0;
|
|
26
|
-
if (left !== right)
|
|
27
|
-
return left > right ? 1 : -1;
|
|
28
|
-
}
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
export { isNewerVersion } from '@dsh-workbench/shared/host';
|
|
18
|
+
export { compareVersions, isNewerVersion } from '@dsh-workbench/shared/host';
|
|
32
19
|
function parseVersion(stdout) {
|
|
33
20
|
const value = stdout.trim();
|
|
34
|
-
return
|
|
21
|
+
return isValidVersion(value) ? value : undefined;
|
|
35
22
|
}
|
|
36
23
|
const latestCache = new Map();
|
|
37
24
|
export async function latestVersion(options) {
|
|
@@ -41,9 +28,9 @@ export async function latestVersion(options) {
|
|
|
41
28
|
if (!force && hit !== undefined && Date.now() - hit.at < VERSION_CHECK_TTL_MS)
|
|
42
29
|
return hit.value;
|
|
43
30
|
const result = await runShell(shell, `npm view ${quoteShellArg(name)} version --registry ${quoteShellArg(registry)} --cache ${quoteShellArg(npmCacheDir())}`, { timeoutMs: VERSION_CHECK_TIMEOUT_MS }).catch(() => undefined);
|
|
44
|
-
const
|
|
45
|
-
latestCache.set(key, { at: Date.now(), value });
|
|
46
|
-
return
|
|
31
|
+
const read = result?.exitCode === 0 ? parseVersion(result.stdout) : undefined;
|
|
32
|
+
latestCache.set(key, { at: Date.now(), value: read });
|
|
33
|
+
return read;
|
|
47
34
|
}
|
|
48
35
|
const existsCache = new Map();
|
|
49
36
|
async function versionExists(options) {
|
|
@@ -58,13 +45,12 @@ async function versionExists(options) {
|
|
|
58
45
|
return value;
|
|
59
46
|
}
|
|
60
47
|
export async function missingReleaseParts(options) {
|
|
61
|
-
const { shell, registry, version, force = false } = options;
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return missing;
|
|
48
|
+
const { shell, name, registry, version, force = false } = options;
|
|
49
|
+
const checked = await Promise.all(RELEASE_PACKAGES.filter((part) => part !== name).map(async (part) => ({
|
|
50
|
+
part,
|
|
51
|
+
present: await versionExists({ shell, name: part, version, registry, force }),
|
|
52
|
+
})));
|
|
53
|
+
return checked.filter((entry) => !entry.present).map((entry) => entry.part);
|
|
68
54
|
}
|
|
69
55
|
export async function probeRelease(options) {
|
|
70
56
|
const { shell, package: pkg, registry, force = false } = options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-workbench/adapter-profile",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Workbench profile adapter package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"execa": "^10.2.0",
|
|
33
33
|
"proper-lockfile": "^4.1.2",
|
|
34
34
|
"write-file-atomic": "^8.0.0",
|
|
35
|
-
"@dsh-workbench/adapter-runtime": "1.0.0-beta.
|
|
36
|
-
"@dsh-workbench/shared": "1.0.0-beta.
|
|
35
|
+
"@dsh-workbench/adapter-runtime": "1.0.0-beta.1",
|
|
36
|
+
"@dsh-workbench/shared": "1.0.0-beta.1"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc -p tsconfig.json",
|