@chipctx/cli-updater 0.1.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/dist/bootChecker.d.ts +16 -0
- package/dist/cache.d.ts +8 -0
- package/dist/decideAction.d.ts +9 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1943 -0
- package/dist/interceptor.d.ts +6 -0
- package/dist/runner/npm.d.ts +22 -0
- package/dist/runner/tarball.d.ts +15 -0
- package/dist/types.d.ts +71 -0
- package/dist/updateManager.d.ts +25 -0
- package/dist/versionClient.d.ts +15 -0
- package/package.json +35 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface CriticalSignal {
|
|
2
|
+
target: string | null;
|
|
3
|
+
reason: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare function interpretResponseHeaders(headers: Headers): CriticalSignal | null;
|
|
6
|
+
export declare function attachResponseInterceptor(onCritical: (signal: CriticalSignal) => void): (res: Response) => Response;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DistConfigNpm } from "../types.js";
|
|
2
|
+
export type SpawnFn = (cmd: [string, string[]]) => Promise<{
|
|
3
|
+
exitCode: number;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
}>;
|
|
7
|
+
export interface NpmRunDeps {
|
|
8
|
+
spawn: SpawnFn;
|
|
9
|
+
lastInstalledFile: string;
|
|
10
|
+
writeLastInstalled(version: string): Promise<void>;
|
|
11
|
+
readLastInstalled?: () => Promise<string | null>;
|
|
12
|
+
packageName?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface NpmRunInput {
|
|
15
|
+
target: string;
|
|
16
|
+
dist: DistConfigNpm;
|
|
17
|
+
}
|
|
18
|
+
export interface NpmRunner {
|
|
19
|
+
run(input: NpmRunInput): Promise<void>;
|
|
20
|
+
rollback(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare function createNpmRunner(deps: NpmRunDeps): NpmRunner;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DistConfigTarball } from "../types.js";
|
|
2
|
+
export interface TarballRunDeps {
|
|
3
|
+
installDir: string;
|
|
4
|
+
fetchBuffer(url: string): Promise<Buffer>;
|
|
5
|
+
extractTarball(buf: Buffer, targetDir: string): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export interface TarballRunInput {
|
|
8
|
+
target: string;
|
|
9
|
+
dist: DistConfigTarball;
|
|
10
|
+
}
|
|
11
|
+
export interface TarballRunner {
|
|
12
|
+
run(input: TarballRunInput): Promise<void>;
|
|
13
|
+
rollback(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function createTarballRunner(deps: TarballRunDeps): TarballRunner;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type Severity = "none" | "recommended" | "critical";
|
|
2
|
+
export type DistType = "tarball" | "npm";
|
|
3
|
+
export type Mode = "interactive" | "non-interactive";
|
|
4
|
+
export interface DistConfigTarball {
|
|
5
|
+
url_r2: string;
|
|
6
|
+
url_gh: string | null;
|
|
7
|
+
sha256: string;
|
|
8
|
+
size_bytes: number;
|
|
9
|
+
}
|
|
10
|
+
export interface DistConfigNpm {
|
|
11
|
+
package: string;
|
|
12
|
+
version: string;
|
|
13
|
+
registry: string;
|
|
14
|
+
}
|
|
15
|
+
export type DistConfig = DistConfigTarball | DistConfigNpm;
|
|
16
|
+
export interface VersionResponse {
|
|
17
|
+
app: string;
|
|
18
|
+
latest: string;
|
|
19
|
+
min_required: string;
|
|
20
|
+
severity: Severity;
|
|
21
|
+
dist_type: DistType;
|
|
22
|
+
dist: DistConfig;
|
|
23
|
+
release_notes_url: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface UpdateState {
|
|
26
|
+
version: 1;
|
|
27
|
+
app: string;
|
|
28
|
+
current: string;
|
|
29
|
+
last_check_at: number;
|
|
30
|
+
ttl_expires_at: number;
|
|
31
|
+
latest: string | null;
|
|
32
|
+
min_required: string | null;
|
|
33
|
+
severity: Severity;
|
|
34
|
+
dist_type: DistType | null;
|
|
35
|
+
dist: DistConfig | null;
|
|
36
|
+
last_prompted_by_target: Record<string, number>;
|
|
37
|
+
}
|
|
38
|
+
export interface AppAdapter {
|
|
39
|
+
app_id: "hardawa" | "chipctx";
|
|
40
|
+
channel: string;
|
|
41
|
+
currentVersion(): string;
|
|
42
|
+
os(): "linux" | "darwin" | "win32";
|
|
43
|
+
arch(): "x64" | "arm64";
|
|
44
|
+
isNonInteractive(): boolean;
|
|
45
|
+
runnerBackend: "tarball" | "npm";
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
confirmUpgrade(opts: {
|
|
48
|
+
target: string;
|
|
49
|
+
current: string;
|
|
50
|
+
severity: Severity;
|
|
51
|
+
notesUrl: string | null;
|
|
52
|
+
}): Promise<boolean>;
|
|
53
|
+
}
|
|
54
|
+
export type Action = {
|
|
55
|
+
kind: "silent";
|
|
56
|
+
} | {
|
|
57
|
+
kind: "banner";
|
|
58
|
+
target: string;
|
|
59
|
+
notesUrl: string | null;
|
|
60
|
+
} | {
|
|
61
|
+
kind: "prompt_block";
|
|
62
|
+
target: string;
|
|
63
|
+
reason: string | null;
|
|
64
|
+
} | {
|
|
65
|
+
kind: "stderr_warn";
|
|
66
|
+
target: string;
|
|
67
|
+
reason: string | null;
|
|
68
|
+
} | {
|
|
69
|
+
kind: "auto_update";
|
|
70
|
+
target: string;
|
|
71
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CacheStore } from "./cache.js";
|
|
2
|
+
import type { CriticalSignal } from "./interceptor.js";
|
|
3
|
+
import type { AppAdapter, Mode, VersionResponse } from "./types.js";
|
|
4
|
+
export interface UpdateManagerDeps {
|
|
5
|
+
adapter: AppAdapter;
|
|
6
|
+
cache: CacheStore;
|
|
7
|
+
renderBanner(opts: {
|
|
8
|
+
target: string;
|
|
9
|
+
current: string;
|
|
10
|
+
notesUrl: string | null;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
runUpgrade(target: string, mode: Mode): Promise<void>;
|
|
13
|
+
writeStderr(s: string): void;
|
|
14
|
+
autoUpdateEnv?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class UpdateManager {
|
|
17
|
+
private deps;
|
|
18
|
+
private handledCritical;
|
|
19
|
+
constructor(deps: UpdateManagerDeps);
|
|
20
|
+
private mode;
|
|
21
|
+
handleResponse(resp: VersionResponse): Promise<void>;
|
|
22
|
+
handleCritical(signal: CriticalSignal): Promise<void>;
|
|
23
|
+
private dispatch;
|
|
24
|
+
private emptyState;
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VersionResponse } from "./types.js";
|
|
2
|
+
export interface QueryInput {
|
|
3
|
+
current: string;
|
|
4
|
+
os: "linux" | "darwin" | "win32";
|
|
5
|
+
arch: "x64" | "arm64";
|
|
6
|
+
userAgent: string;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
export declare class VersionClient {
|
|
10
|
+
readonly baseUrl: string;
|
|
11
|
+
readonly app: "hardawa" | "chipctx";
|
|
12
|
+
readonly channel: string;
|
|
13
|
+
constructor(baseUrl: string, app: "hardawa" | "chipctx", channel?: string);
|
|
14
|
+
query(input: QueryInput): Promise<VersionResponse>;
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chipctx/cli-updater",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared CLI updater for ChipCloud products (hardawa, chipctx)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist/"],
|
|
15
|
+
"publishConfig": { "access": "public" },
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "bun build src/index.ts --outdir dist --target node && tsc --emitDeclarationOnly --outDir dist",
|
|
18
|
+
"test": "bun test",
|
|
19
|
+
"type-check": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"proper-lockfile": "^4.1.2",
|
|
23
|
+
"semver": "^7.5.4"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^20.0.0",
|
|
27
|
+
"@types/semver": "^7.5.0",
|
|
28
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
29
|
+
"typescript": "^5.3.0",
|
|
30
|
+
"msw": "^2.0.0"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20"
|
|
34
|
+
}
|
|
35
|
+
}
|