@dsh-workbench/adapter-profile 1.1.8 → 1.1.10
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/host-actions.d.ts +7 -0
- package/dist/host-actions.js +28 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -3
- package/dist/release.d.ts +28 -21
- package/dist/release.js +10 -73
- package/package.json +2 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HostActions, ProfileCreateDeps } from '@dsh-workbench/shared/host';
|
|
2
|
+
export declare function runSetupAt(packageRoot: string, env: Readonly<Record<string, string>>): Promise<{
|
|
3
|
+
ok: boolean;
|
|
4
|
+
log: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function createHostActions(): HostActions;
|
|
7
|
+
export declare function profileCreateDepsOf(deps: Omit<ProfileCreateDeps, 'runSetup'>): ProfileCreateDeps;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { configSyncAction, configSyncHandler, profileCreateAction, profileCreateHandler, } from '@dsh-workbench/shared/host';
|
|
4
|
+
const SETUP_TIMEOUT_MS = 10 * 60 * 1000;
|
|
5
|
+
export function runSetupAt(packageRoot, env) {
|
|
6
|
+
const bin = join(packageRoot, 'bin', 'dsh-workbench');
|
|
7
|
+
let log = '';
|
|
8
|
+
const child = execa('bash', [bin, 'setup'], {
|
|
9
|
+
cwd: packageRoot,
|
|
10
|
+
env: { ...process.env, ...env },
|
|
11
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
12
|
+
timeout: SETUP_TIMEOUT_MS,
|
|
13
|
+
reject: false,
|
|
14
|
+
windowsHide: true,
|
|
15
|
+
});
|
|
16
|
+
const collect = (chunk) => {
|
|
17
|
+
log = `${log}${chunk.toString('utf8')}`.slice(-20_000);
|
|
18
|
+
};
|
|
19
|
+
child.stdout?.on('data', collect);
|
|
20
|
+
child.stderr?.on('data', collect);
|
|
21
|
+
return child.then((result) => (result.timedOut === true ? { ok: false, log: `${log}\n创建超时` } : { ok: result.exitCode === 0, log }), (error) => ({ ok: false, log: `${log}\n${error instanceof Error ? error.message : String(error)}` }));
|
|
22
|
+
}
|
|
23
|
+
export function createHostActions() {
|
|
24
|
+
return { configSyncAction, configSyncHandler, profileCreateAction, profileCreateHandler };
|
|
25
|
+
}
|
|
26
|
+
export function profileCreateDepsOf(deps) {
|
|
27
|
+
return { ...deps, runSetup: (env) => runSetupAt(deps.packageRoot, env) };
|
|
28
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { configSyncAction, configSyncApply, configSyncHandler, configSyncSnapshot, createHostActions, mergeBlocks, normalizeBlock, profileCreateAction, profileCreateApply, profileCreateHandler, profileCreateSnapshot, readPatchBlocks, syncRows, } from '@dsh-workbench/shared/host';
|
|
2
|
+
export type { ConfigSyncDeps, PatchBlock, ProfileCreateDeps } from '@dsh-workbench/shared/host';
|
|
3
|
+
export { patchBlocks, writePatchFile } from '@dsh-workbench/shared/host';
|
|
4
|
+
export { createRegistryNotebook, mergeRegistryConfig, normalizeRegistry, REGISTRY_MARKER, registryFailure, replaceScopeRegistry, sameRegistry, scopeOf, sourcesFromLockfile, } from '@dsh-workbench/shared/host';
|
|
4
5
|
export * from './release.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { configSyncAction, configSyncApply, configSyncHandler, configSyncSnapshot, createHostActions, mergeBlocks, normalizeBlock, profileCreateAction, profileCreateApply, profileCreateHandler, profileCreateSnapshot, readPatchBlocks, syncRows, } from '@dsh-workbench/shared/host';
|
|
2
|
+
export { patchBlocks, writePatchFile } from '@dsh-workbench/shared/host';
|
|
3
|
+
export { createRegistryNotebook, mergeRegistryConfig, normalizeRegistry, REGISTRY_MARKER, registryFailure, replaceScopeRegistry, sameRegistry, scopeOf, sourcesFromLockfile, } from '@dsh-workbench/shared/host';
|
|
4
4
|
export * from './release.js';
|
package/dist/release.d.ts
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import type { DshShell } from '@dsh-workbench/shared';
|
|
2
2
|
import type { PluginRelease } from '@dsh-workbench/shared';
|
|
3
|
-
|
|
3
|
+
import { parseLedgerVersion } from '@dsh-workbench/shared/host';
|
|
4
|
+
export { parseLedgerVersion };
|
|
4
5
|
export { compareVersions, isNewerVersion } from '@dsh-workbench/shared/host';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
export interface ReleasePort {
|
|
7
|
+
latestVersion(options: {
|
|
8
|
+
readonly shell: DshShell;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly registry: string;
|
|
11
|
+
readonly force?: boolean;
|
|
12
|
+
}): Promise<string | undefined>;
|
|
13
|
+
missingReleaseParts(options: {
|
|
14
|
+
readonly shell: DshShell;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly registry: string;
|
|
17
|
+
readonly version: string;
|
|
18
|
+
readonly force?: boolean;
|
|
19
|
+
}): Promise<readonly string[]>;
|
|
20
|
+
probeRelease(options: {
|
|
21
|
+
readonly shell: DshShell;
|
|
22
|
+
readonly package: string;
|
|
23
|
+
readonly registry?: string | undefined;
|
|
24
|
+
readonly force?: boolean;
|
|
25
|
+
}): Promise<PluginRelease | undefined>;
|
|
26
|
+
reset(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function createReleasePort(options: {
|
|
29
|
+
readonly cacheDir: string;
|
|
30
|
+
readonly prefix: string;
|
|
31
|
+
}): ReleasePort;
|
package/dist/release.js
CHANGED
|
@@ -1,77 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { npmCacheDir, vendorPrefix } from '@dsh-workbench/adapter-runtime';
|
|
4
|
-
import { runShell } from '@dsh-workbench/shared/host';
|
|
5
|
-
export function parseLedgerVersion(stdout, name) {
|
|
6
|
-
const parsed = parseJsonLoose(stdout);
|
|
7
|
-
if (typeof parsed !== "object" || parsed === null)
|
|
8
|
-
return undefined;
|
|
9
|
-
const entry = parsed
|
|
10
|
-
.dependencies?.[name];
|
|
11
|
-
if (typeof entry !== "object" || entry === null)
|
|
12
|
-
return undefined;
|
|
13
|
-
const version = entry.version;
|
|
14
|
-
return typeof version === "string" && isValidVersion(version.trim())
|
|
15
|
-
? version.trim()
|
|
16
|
-
: undefined;
|
|
17
|
-
}
|
|
1
|
+
import { createReleaseProbe, parseLedgerVersion } from '@dsh-workbench/shared/host';
|
|
2
|
+
export { parseLedgerVersion };
|
|
18
3
|
export { compareVersions, isNewerVersion } from '@dsh-workbench/shared/host';
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
return isValidVersion(value) ? value : undefined;
|
|
22
|
-
}
|
|
23
|
-
const latestCache = new Map();
|
|
24
|
-
export async function latestVersion(options) {
|
|
25
|
-
const { shell, name, registry, force = false } = options;
|
|
26
|
-
const key = `${registry}|${name}`;
|
|
27
|
-
const hit = latestCache.get(key);
|
|
28
|
-
if (!force && hit !== undefined && Date.now() - hit.at < VERSION_CHECK_TTL_MS)
|
|
29
|
-
return hit.value;
|
|
30
|
-
const result = await runShell(shell, `npm view ${quoteShellArg(name)} version --registry ${quoteShellArg(registry)} --cache ${quoteShellArg(npmCacheDir())}`, { timeoutMs: VERSION_CHECK_TIMEOUT_MS }).catch(() => undefined);
|
|
31
|
-
const read = result?.exitCode === 0 ? parseVersion(result.stdout) : undefined;
|
|
32
|
-
latestCache.set(key, { at: Date.now(), value: read });
|
|
33
|
-
return read;
|
|
34
|
-
}
|
|
35
|
-
const existsCache = new Map();
|
|
36
|
-
async function versionExists(options) {
|
|
37
|
-
const { shell, name, version, registry, force = false } = options;
|
|
38
|
-
const key = `${registry}|${name}@${version}`;
|
|
39
|
-
const hit = existsCache.get(key);
|
|
40
|
-
if (!force && hit !== undefined && (hit.value || Date.now() - hit.at < VERSION_CHECK_TTL_MS))
|
|
41
|
-
return hit.value;
|
|
42
|
-
const result = await runShell(shell, `npm view ${quoteShellArg(`${name}@${version}`)} version --registry ${quoteShellArg(registry)} --cache ${quoteShellArg(npmCacheDir())}`, { timeoutMs: VERSION_CHECK_TIMEOUT_MS }).catch(() => undefined);
|
|
43
|
-
const value = result?.exitCode === 0 && parseVersion(result.stdout) !== undefined;
|
|
44
|
-
existsCache.set(key, { at: Date.now(), value });
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
export async function missingReleaseParts(options) {
|
|
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);
|
|
54
|
-
}
|
|
55
|
-
export async function probeRelease(options) {
|
|
56
|
-
const { shell, package: pkg, registry, force = false } = options;
|
|
57
|
-
if (pkg === "")
|
|
58
|
-
return undefined;
|
|
59
|
-
const ledger = await runShell(shell, `npm ls --prefix ${quoteShellArg(vendorPrefix())} ${quoteShellArg(pkg)} --json --depth=0 --cache ${quoteShellArg(npmCacheDir())}`, { timeoutMs: VERSION_CHECK_TIMEOUT_MS }).catch(() => undefined);
|
|
60
|
-
const installed = ledger === undefined ? undefined : parseLedgerVersion(ledger.stdout, pkg);
|
|
61
|
-
if (installed === undefined)
|
|
62
|
-
return undefined;
|
|
63
|
-
const source = registry === undefined || registry.trim() === ""
|
|
64
|
-
? undefined
|
|
65
|
-
: registry.trim();
|
|
66
|
-
const latest = source === undefined
|
|
67
|
-
? undefined
|
|
68
|
-
: await latestVersion({ shell, name: pkg, registry: source, force });
|
|
4
|
+
export function createReleasePort(options) {
|
|
5
|
+
const probe = createReleaseProbe();
|
|
69
6
|
return {
|
|
70
|
-
|
|
71
|
-
|
|
7
|
+
latestVersion: (call) => probe.latestVersion({ ...call, cacheDir: options.cacheDir }),
|
|
8
|
+
missingReleaseParts: (call) => probe.missingReleaseParts({ ...call, cacheDir: options.cacheDir }),
|
|
9
|
+
probeRelease: (call) => probe.probeRelease({ ...call, cacheDir: options.cacheDir, prefix: options.prefix }),
|
|
10
|
+
reset: () => {
|
|
11
|
+
probe.reset();
|
|
12
|
+
},
|
|
72
13
|
};
|
|
73
14
|
}
|
|
74
|
-
export function resetReleaseCache() {
|
|
75
|
-
latestCache.clear();
|
|
76
|
-
existsCache.clear();
|
|
77
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-workbench/adapter-profile",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "Workbench profile adapter package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
"execa": "^10.2.0",
|
|
33
33
|
"proper-lockfile": "^4.1.2",
|
|
34
34
|
"write-file-atomic": "^8.0.0",
|
|
35
|
-
"@dsh-workbench/shared": "1.1.
|
|
36
|
-
"@dsh-workbench/adapter-runtime": "1.1.8"
|
|
35
|
+
"@dsh-workbench/shared": "1.1.10"
|
|
37
36
|
},
|
|
38
37
|
"scripts": {
|
|
39
38
|
"build": "tsc -p tsconfig.json",
|