@h-rig/cli-surface-plugin 0.0.6-alpha.157 → 0.0.6-alpha.159
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/src/app/drone-ui.d.ts +0 -11
- package/dist/src/app/drone-ui.js +0 -114
- package/dist/src/commands/_async-ui.d.ts +1 -1
- package/dist/src/commands/_cli-format.d.ts +0 -29
- package/dist/src/commands/_cli-format.js +59 -113
- package/dist/src/commands/_connection-state.d.ts +6 -33
- package/dist/src/commands/_connection-state.js +654 -138
- package/dist/src/commands/_doctor-checks.d.ts +2 -5
- package/dist/src/commands/_doctor-checks.js +10 -9
- package/dist/src/commands/_help-catalog.d.ts +2 -1
- package/dist/src/commands/_help-catalog.js +654 -7
- package/dist/src/commands/_inprocess-services.d.ts +5 -5
- package/dist/src/commands/_inprocess-services.js +1 -1
- package/dist/src/commands/_parsers.js +651 -12
- package/dist/src/commands/_paths.d.ts +0 -2
- package/dist/src/commands/_paths.js +2 -10
- package/dist/src/commands/_pi-install.d.ts +2 -12
- package/dist/src/commands/_pi-install.js +3 -36
- package/dist/src/commands/_policy.js +659 -20
- package/dist/src/commands/agent.d.ts +1 -1
- package/dist/src/commands/agent.js +675 -24
- package/dist/src/commands/config.d.ts +1 -1
- package/dist/src/commands/config.js +656 -21
- package/dist/src/commands/dist.d.ts +1 -1
- package/dist/src/commands/dist.js +828 -102
- package/dist/src/commands/doctor.d.ts +1 -1
- package/dist/src/commands/doctor.js +658 -12
- package/dist/src/commands/github.d.ts +1 -1
- package/dist/src/commands/github.js +658 -19
- package/dist/src/commands/inbox.d.ts +12 -8
- package/dist/src/commands/inbox.js +741 -22
- package/dist/src/commands/init.d.ts +17 -19
- package/dist/src/commands/init.js +836 -306
- package/dist/src/commands/inspect.d.ts +5 -6
- package/dist/src/commands/inspect.js +754 -42
- package/dist/src/commands/pi.d.ts +1 -1
- package/dist/src/commands/pi.js +655 -16
- package/dist/src/commands/plugin.d.ts +9 -9
- package/dist/src/commands/plugin.js +652 -13
- package/dist/src/commands/profile-and-review.d.ts +1 -1
- package/dist/src/commands/profile-and-review.js +655 -16
- package/dist/src/commands/queue.d.ts +1 -1
- package/dist/src/commands/queue.js +871 -12
- package/dist/src/commands/remote-client.d.ts +152 -0
- package/dist/src/commands/remote-client.js +475 -0
- package/dist/src/commands/remote.d.ts +1 -1
- package/dist/src/commands/remote.js +1100 -29
- package/dist/src/commands/repo-git-harness.d.ts +1 -1
- package/dist/src/commands/repo-git-harness.js +2321 -47
- package/dist/src/commands/run.d.ts +10 -6
- package/dist/src/commands/run.js +830 -50
- package/dist/src/commands/server.d.ts +1 -1
- package/dist/src/commands/server.js +649 -11
- package/dist/src/commands/setup.d.ts +2 -2
- package/dist/src/commands/setup.js +829 -18
- package/dist/src/commands/stats.d.ts +2 -4
- package/dist/src/commands/stats.js +1299 -20
- package/dist/src/commands/test.d.ts +1 -1
- package/dist/src/commands/test.js +648 -9
- package/dist/src/commands/triage.d.ts +2 -3
- package/dist/src/commands/triage.js +657 -11
- package/dist/src/commands/workspace.d.ts +1 -1
- package/dist/src/commands/workspace.js +1280 -15
- package/dist/src/control-plane/agent-binary-build.d.ts +9 -0
- package/dist/src/control-plane/agent-binary-build.js +88 -0
- package/dist/src/control-plane/embedded-native-assets.d.ts +7 -0
- package/dist/src/control-plane/embedded-native-assets.js +6 -0
- package/dist/src/control-plane/guard.d.ts +17 -0
- package/dist/src/control-plane/guard.js +684 -0
- package/dist/src/control-plane/harness-cli.d.ts +12 -0
- package/dist/src/control-plane/harness-cli.js +1623 -0
- package/dist/src/control-plane/native/git-ops.d.ts +67 -0
- package/dist/src/control-plane/native/git-ops.js +1381 -0
- package/dist/src/control-plane/native/github-auth-env.d.ts +1 -0
- package/dist/src/control-plane/native/github-auth-env.js +21 -0
- package/dist/src/control-plane/native/host-git.d.ts +4 -0
- package/dist/src/control-plane/native/host-git.js +51 -0
- package/dist/src/control-plane/priority-queue.d.ts +22 -0
- package/dist/src/control-plane/priority-queue.js +212 -0
- package/dist/src/control-plane/rigfig.d.ts +9 -0
- package/dist/src/control-plane/rigfig.js +70 -0
- package/dist/src/control-plane/scope.d.ts +3 -0
- package/dist/src/control-plane/scope.js +58 -0
- package/dist/src/control-plane/setup-status.d.ts +44 -0
- package/dist/src/control-plane/setup-status.js +164 -0
- package/dist/src/control-plane/task-data.d.ts +2 -0
- package/dist/src/control-plane/task-data.js +12 -0
- package/dist/src/control-plane/workspace-ops.d.ts +79 -0
- package/dist/src/control-plane/workspace-ops.js +639 -0
- package/dist/src/help-catalog-data.d.ts +7 -0
- package/dist/src/help-catalog-data.js +660 -0
- package/dist/src/kernel-dispatch.js +1 -3
- package/dist/src/plugin.js +10072 -30
- package/dist/src/runner.d.ts +7 -9
- package/dist/src/runner.js +750 -30
- package/package.json +12 -13
- package/dist/src/commands/_json-output.d.ts +0 -11
- package/dist/src/commands/_json-output.js +0 -54
- package/dist/src/commands/_pi-frontend.d.ts +0 -35
- package/dist/src/commands/_pi-frontend.js +0 -64
- package/dist/src/commands/_run-driver-helpers.d.ts +0 -26
- package/dist/src/commands/_run-driver-helpers.js +0 -132
- package/dist/src/commands/task-run-driver.d.ts +0 -93
- package/dist/src/commands/task-run-driver.js +0 -136
- package/dist/src/commands/task.d.ts +0 -46
- package/dist/src/commands/task.js +0 -555
- package/dist/src/provider-model.d.ts +0 -34
- package/dist/src/provider-model.js +0 -56
- package/dist/src/rig-config-package-deps.d.ts +0 -10
- package/dist/src/rig-config-package-deps.js +0 -272
- package/dist/src/version.d.ts +0 -8
- package/dist/src/version.js +0 -47
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli-surface-plugin/src/rig-config-package-deps.ts
|
|
3
|
-
import { spawnSync } from "child_process";
|
|
4
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
5
|
-
import { basename, join, resolve as resolve2 } from "path";
|
|
6
|
-
|
|
7
|
-
// packages/cli-surface-plugin/src/version.ts
|
|
8
|
-
import { existsSync, readFileSync } from "fs";
|
|
9
|
-
import { dirname, resolve } from "path";
|
|
10
|
-
import { fileURLToPath } from "url";
|
|
11
|
-
import { readBuildConfig } from "@rig/runtime/build-time-config";
|
|
12
|
-
var SOURCE_CLI_VERSION = "0.0.0-alpha.1";
|
|
13
|
-
var DEV_CLI_VERSION = "0.0.0-dev";
|
|
14
|
-
function resolveInstalledCliVersion() {
|
|
15
|
-
const buildConfig = readBuildConfig();
|
|
16
|
-
const envVersion = process.env.RIG_CLI_VERSION?.trim();
|
|
17
|
-
const buildVersion = buildConfig.RIG_CLI_VERSION?.trim();
|
|
18
|
-
let version = envVersion || buildVersion || "";
|
|
19
|
-
if (!version) {
|
|
20
|
-
try {
|
|
21
|
-
const execPath = process.execPath || "";
|
|
22
|
-
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
23
|
-
const candidates = [
|
|
24
|
-
execPath ? resolve(dirname(execPath), "..", "manifest.json") : "",
|
|
25
|
-
resolve(moduleDir, "..", "package.json"),
|
|
26
|
-
resolve(moduleDir, "..", "..", "package.json"),
|
|
27
|
-
resolve(process.cwd(), "packages/cli/package.json")
|
|
28
|
-
].filter(Boolean);
|
|
29
|
-
for (const candidate of candidates) {
|
|
30
|
-
if (!existsSync(candidate))
|
|
31
|
-
continue;
|
|
32
|
-
const parsed = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
33
|
-
const candidateVersion = parsed.version?.trim();
|
|
34
|
-
if (candidateVersion) {
|
|
35
|
-
version = candidateVersion;
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
} catch {}
|
|
40
|
-
}
|
|
41
|
-
return version || DEV_CLI_VERSION;
|
|
42
|
-
}
|
|
43
|
-
function isPublishedCliVersion(version) {
|
|
44
|
-
const normalized = version.trim();
|
|
45
|
-
return normalized.length > 0 && normalized !== SOURCE_CLI_VERSION && normalized !== DEV_CLI_VERSION;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// packages/cli-surface-plugin/src/rig-config-package-deps.ts
|
|
49
|
-
var REQUIRED_RIG_CONFIG_PACKAGE_NAMES = ["core", "standard-plugin"];
|
|
50
|
-
var RIG_CONFIG_FILENAMES = ["rig.config.ts", "rig.config.mts", "rig.config.json"];
|
|
51
|
-
var DEPENDENCY_SECTION_NAMES = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
52
|
-
var INSTALL_CHECK_SECTION_NAMES = ["dependencies", "devDependencies", "optionalDependencies"];
|
|
53
|
-
function hasRigConfig(projectRoot) {
|
|
54
|
-
const root = resolve2(projectRoot);
|
|
55
|
-
return RIG_CONFIG_FILENAMES.some((name) => existsSync2(join(root, name)));
|
|
56
|
-
}
|
|
57
|
-
function resolveRigConfigPackageVersion() {
|
|
58
|
-
const explicit = process.env.RIG_CONFIG_PACKAGE_VERSION?.trim();
|
|
59
|
-
if (explicit)
|
|
60
|
-
return explicit;
|
|
61
|
-
const installed = resolveInstalledCliVersion();
|
|
62
|
-
return isPublishedCliVersion(installed) ? installed : "latest";
|
|
63
|
-
}
|
|
64
|
-
function rigConfigDevDependencies() {
|
|
65
|
-
const version = resolveRigConfigPackageVersion();
|
|
66
|
-
return Object.fromEntries(REQUIRED_RIG_CONFIG_PACKAGE_NAMES.map((name) => [`@rig/${name}`, rigPackageSpec(name, version)]));
|
|
67
|
-
}
|
|
68
|
-
function readPackageManifest(path) {
|
|
69
|
-
if (!existsSync2(path))
|
|
70
|
-
return null;
|
|
71
|
-
return JSON.parse(readFileSync2(path, "utf8"));
|
|
72
|
-
}
|
|
73
|
-
function mutableDeps(manifest, key) {
|
|
74
|
-
const source = manifest[key];
|
|
75
|
-
return source && typeof source === "object" && !Array.isArray(source) ? { ...source } : {};
|
|
76
|
-
}
|
|
77
|
-
function rigPackageName(name) {
|
|
78
|
-
const match = name.match(/^@rig\/([^/]+)$/);
|
|
79
|
-
return match?.[1] ?? null;
|
|
80
|
-
}
|
|
81
|
-
function rigPackageNameFromSpecifier(specifier) {
|
|
82
|
-
const match = specifier.match(/^@rig\/([^/]+)/);
|
|
83
|
-
return match?.[1] ?? null;
|
|
84
|
-
}
|
|
85
|
-
function rigPackageSpec(packageName, version = resolveRigConfigPackageVersion()) {
|
|
86
|
-
return `npm:@h-rig/${packageName}@${version}`;
|
|
87
|
-
}
|
|
88
|
-
function mutableDependencySections(manifest) {
|
|
89
|
-
return Object.fromEntries(DEPENDENCY_SECTION_NAMES.map((section) => [section, mutableDeps(manifest, section)]));
|
|
90
|
-
}
|
|
91
|
-
function discoveredConfigRigSpecs(sections, packageNames) {
|
|
92
|
-
const version = resolveRigConfigPackageVersion();
|
|
93
|
-
const expected = {};
|
|
94
|
-
for (const section of DEPENDENCY_SECTION_NAMES) {
|
|
95
|
-
for (const name of Object.keys(sections[section])) {
|
|
96
|
-
const packageName = rigPackageName(name);
|
|
97
|
-
if (packageName && packageNames.has(packageName))
|
|
98
|
-
expected[name] = rigPackageSpec(packageName, version);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return expected;
|
|
102
|
-
}
|
|
103
|
-
function installedConfigDependencySpecs(sections, packageNames) {
|
|
104
|
-
const expected = {};
|
|
105
|
-
for (const section of INSTALL_CHECK_SECTION_NAMES) {
|
|
106
|
-
for (const [name, spec] of Object.entries(sections[section])) {
|
|
107
|
-
const packageName = rigPackageName(name);
|
|
108
|
-
if (packageName && packageNames.has(packageName) && typeof spec === "string")
|
|
109
|
-
expected[name] = spec;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return expected;
|
|
113
|
-
}
|
|
114
|
-
function hasFirstPartyRigDependency(manifest) {
|
|
115
|
-
const sections = mutableDependencySections(manifest);
|
|
116
|
-
return DEPENDENCY_SECTION_NAMES.some((section) => Object.keys(sections[section]).some((name) => rigPackageName(name) !== null));
|
|
117
|
-
}
|
|
118
|
-
function rigConfigImportPackageNames(projectRoot) {
|
|
119
|
-
const names = new Set;
|
|
120
|
-
for (const filename of RIG_CONFIG_FILENAMES) {
|
|
121
|
-
const path = join(projectRoot, filename);
|
|
122
|
-
if (!existsSync2(path))
|
|
123
|
-
continue;
|
|
124
|
-
const source = readFileSync2(path, "utf8");
|
|
125
|
-
const importPattern = /(?:from\s*|import\s*\(\s*|import\s*)["'](@rig\/[^"']+)["']/g;
|
|
126
|
-
for (const match of source.matchAll(importPattern)) {
|
|
127
|
-
const packageName = rigPackageNameFromSpecifier(match[1] ?? "");
|
|
128
|
-
if (packageName)
|
|
129
|
-
names.add(packageName);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return [...names];
|
|
133
|
-
}
|
|
134
|
-
function withRigConfigDeps(projectRoot, manifest, options) {
|
|
135
|
-
const configPackageNames = new Set(options.requiredConfigPackageNames);
|
|
136
|
-
const sections = mutableDependencySections(manifest);
|
|
137
|
-
let changed = false;
|
|
138
|
-
for (const [name, spec] of Object.entries(discoveredConfigRigSpecs(sections, configPackageNames))) {
|
|
139
|
-
for (const section of DEPENDENCY_SECTION_NAMES) {
|
|
140
|
-
if (!Object.prototype.hasOwnProperty.call(sections[section], name))
|
|
141
|
-
continue;
|
|
142
|
-
if (sections[section][name] !== spec) {
|
|
143
|
-
sections[section][name] = spec;
|
|
144
|
-
changed = true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
for (const packageName of options.requiredConfigPackageNames) {
|
|
149
|
-
const name = `@rig/${packageName}`;
|
|
150
|
-
const existsInInstallableSection = INSTALL_CHECK_SECTION_NAMES.some((section) => Object.prototype.hasOwnProperty.call(sections[section], name));
|
|
151
|
-
if (existsInInstallableSection)
|
|
152
|
-
continue;
|
|
153
|
-
sections.devDependencies[name] = rigPackageSpec(packageName);
|
|
154
|
-
changed = true;
|
|
155
|
-
}
|
|
156
|
-
const next = {
|
|
157
|
-
...Object.keys(manifest).length > 0 ? manifest : { name: basename(projectRoot) || "rig-project", private: true }
|
|
158
|
-
};
|
|
159
|
-
for (const section of DEPENDENCY_SECTION_NAMES) {
|
|
160
|
-
if (Object.keys(sections[section]).length > 0)
|
|
161
|
-
next[section] = sections[section];
|
|
162
|
-
}
|
|
163
|
-
return { next, changed, expectedInstalled: installedConfigDependencySpecs(sections, configPackageNames) };
|
|
164
|
-
}
|
|
165
|
-
function expectedPublishedVersion(spec) {
|
|
166
|
-
const match = spec.match(/^npm:@h-rig\/[^@]+@(.+)$/);
|
|
167
|
-
if (!match)
|
|
168
|
-
return null;
|
|
169
|
-
return match[1] === "latest" ? null : match[1] ?? null;
|
|
170
|
-
}
|
|
171
|
-
function installedRigPackageHealthy(projectRoot, packageName, expectedSpec) {
|
|
172
|
-
const rigName = rigPackageName(packageName);
|
|
173
|
-
if (!rigName)
|
|
174
|
-
return true;
|
|
175
|
-
const manifest = readPackageManifest(join(projectRoot, "node_modules", "@rig", rigName, "package.json"));
|
|
176
|
-
if (!manifest)
|
|
177
|
-
return false;
|
|
178
|
-
const installedVersion = typeof manifest.version === "string" ? manifest.version.trim() : "";
|
|
179
|
-
const expectedVersion = expectedPublishedVersion(expectedSpec);
|
|
180
|
-
if (expectedVersion && installedVersion !== expectedVersion)
|
|
181
|
-
return false;
|
|
182
|
-
if (!installedVersion)
|
|
183
|
-
return false;
|
|
184
|
-
if (rigName === "core" || rigName === "standard-plugin") {
|
|
185
|
-
const exportsField = manifest.exports;
|
|
186
|
-
if (!exportsField || typeof exportsField !== "object" || Array.isArray(exportsField))
|
|
187
|
-
return false;
|
|
188
|
-
const exportsRecord = exportsField;
|
|
189
|
-
if (rigName === "core" && !("./config" in exportsRecord))
|
|
190
|
-
return false;
|
|
191
|
-
if (rigName === "standard-plugin" && !("./bundle" in exportsRecord))
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
function resolvePackageManagerBinary(manager) {
|
|
197
|
-
if (manager !== "bun")
|
|
198
|
-
return manager;
|
|
199
|
-
const candidates = [
|
|
200
|
-
Bun.which("bun") ?? "",
|
|
201
|
-
process.env.RIG_BUN_PATH?.trim() ?? "",
|
|
202
|
-
process.env.HOME ? join(process.env.HOME, ".bun", "bin", "bun") : "",
|
|
203
|
-
"/opt/homebrew/bin/bun",
|
|
204
|
-
"/usr/local/bin/bun",
|
|
205
|
-
"/usr/bin/bun"
|
|
206
|
-
];
|
|
207
|
-
for (const candidate of candidates) {
|
|
208
|
-
if (candidate && existsSync2(candidate))
|
|
209
|
-
return candidate;
|
|
210
|
-
}
|
|
211
|
-
return "bun";
|
|
212
|
-
}
|
|
213
|
-
function installCommandFor(manifest) {
|
|
214
|
-
const packageManager = typeof manifest.packageManager === "string" ? manifest.packageManager.trim() : "";
|
|
215
|
-
const manager = packageManager.split("@")[0] || "bun";
|
|
216
|
-
switch (manager) {
|
|
217
|
-
case "npm":
|
|
218
|
-
return ["npm", "install", "--ignore-scripts"];
|
|
219
|
-
case "pnpm":
|
|
220
|
-
return ["pnpm", "install", "--ignore-scripts"];
|
|
221
|
-
case "yarn":
|
|
222
|
-
return ["yarn", "install", "--ignore-scripts"];
|
|
223
|
-
default:
|
|
224
|
-
return [resolvePackageManagerBinary("bun"), "install", "--ignore-scripts"];
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function ensureRigConfigDependenciesInstalled(projectRoot) {
|
|
228
|
-
const root = resolve2(projectRoot);
|
|
229
|
-
const version = resolveRigConfigPackageVersion();
|
|
230
|
-
const manifestPath = join(root, "package.json");
|
|
231
|
-
const current = readPackageManifest(manifestPath);
|
|
232
|
-
const hasConfig = hasRigConfig(root);
|
|
233
|
-
if (!hasConfig && (!current || !hasFirstPartyRigDependency(current))) {
|
|
234
|
-
return { rewroteManifest: false, ranInstall: false, command: null, version };
|
|
235
|
-
}
|
|
236
|
-
const requiredConfigPackageNames = hasConfig ? [...new Set([...REQUIRED_RIG_CONFIG_PACKAGE_NAMES, ...rigConfigImportPackageNames(root)])] : [];
|
|
237
|
-
const { next, changed, expectedInstalled } = withRigConfigDeps(root, current ?? {}, { requiredConfigPackageNames });
|
|
238
|
-
const installNeeded = changed || Object.entries(expectedInstalled).some(([name, spec]) => !installedRigPackageHealthy(root, name, spec));
|
|
239
|
-
if (changed) {
|
|
240
|
-
writeFileSync(manifestPath, `${JSON.stringify(next, null, 2)}
|
|
241
|
-
`, "utf8");
|
|
242
|
-
}
|
|
243
|
-
if (!installNeeded) {
|
|
244
|
-
return { rewroteManifest: changed, ranInstall: false, command: null, version };
|
|
245
|
-
}
|
|
246
|
-
const command = installCommandFor(next);
|
|
247
|
-
const executable = command[0];
|
|
248
|
-
if (!executable)
|
|
249
|
-
throw new Error("Rig dependency preflight could not determine a package manager command.");
|
|
250
|
-
const result = spawnSync(executable, command.slice(1), {
|
|
251
|
-
cwd: root,
|
|
252
|
-
encoding: "utf8",
|
|
253
|
-
env: process.env
|
|
254
|
-
});
|
|
255
|
-
if (result.status !== 0) {
|
|
256
|
-
const detail = [
|
|
257
|
-
result.error ? String(result.error) : "",
|
|
258
|
-
`${result.stdout ?? ""}${result.stderr ?? ""}`.trim()
|
|
259
|
-
].filter(Boolean).join(`
|
|
260
|
-
`);
|
|
261
|
-
throw new Error(`Rig dependency preflight failed in ${root}: ${command.join(" ")}${detail ? `
|
|
262
|
-
${detail}` : ""}
|
|
263
|
-
Rig does not delete node_modules or lockfiles automatically; fix the repo/package-manager state explicitly if install recovery is needed.`.trim());
|
|
264
|
-
}
|
|
265
|
-
return { rewroteManifest: changed, ranInstall: true, command: command.join(" "), version };
|
|
266
|
-
}
|
|
267
|
-
export {
|
|
268
|
-
rigConfigDevDependencies,
|
|
269
|
-
resolveRigConfigPackageVersion,
|
|
270
|
-
hasRigConfig,
|
|
271
|
-
ensureRigConfigDependenciesInstalled
|
|
272
|
-
};
|
package/dist/src/version.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const SOURCE_CLI_VERSION = "0.0.0-alpha.1";
|
|
2
|
-
export declare const DEV_CLI_VERSION = "0.0.0-dev";
|
|
3
|
-
/**
|
|
4
|
-
* Resolve the CLI version no matter how the command was launched:
|
|
5
|
-
* compiled binary, dist artifact, npm JS bin, or source checkout.
|
|
6
|
-
*/
|
|
7
|
-
export declare function resolveInstalledCliVersion(): string;
|
|
8
|
-
export declare function isPublishedCliVersion(version: string): boolean;
|
package/dist/src/version.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli-surface-plugin/src/version.ts
|
|
3
|
-
import { existsSync, readFileSync } from "fs";
|
|
4
|
-
import { dirname, resolve } from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
import { readBuildConfig } from "@rig/runtime/build-time-config";
|
|
7
|
-
var SOURCE_CLI_VERSION = "0.0.0-alpha.1";
|
|
8
|
-
var DEV_CLI_VERSION = "0.0.0-dev";
|
|
9
|
-
function resolveInstalledCliVersion() {
|
|
10
|
-
const buildConfig = readBuildConfig();
|
|
11
|
-
const envVersion = process.env.RIG_CLI_VERSION?.trim();
|
|
12
|
-
const buildVersion = buildConfig.RIG_CLI_VERSION?.trim();
|
|
13
|
-
let version = envVersion || buildVersion || "";
|
|
14
|
-
if (!version) {
|
|
15
|
-
try {
|
|
16
|
-
const execPath = process.execPath || "";
|
|
17
|
-
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const candidates = [
|
|
19
|
-
execPath ? resolve(dirname(execPath), "..", "manifest.json") : "",
|
|
20
|
-
resolve(moduleDir, "..", "package.json"),
|
|
21
|
-
resolve(moduleDir, "..", "..", "package.json"),
|
|
22
|
-
resolve(process.cwd(), "packages/cli/package.json")
|
|
23
|
-
].filter(Boolean);
|
|
24
|
-
for (const candidate of candidates) {
|
|
25
|
-
if (!existsSync(candidate))
|
|
26
|
-
continue;
|
|
27
|
-
const parsed = JSON.parse(readFileSync(candidate, "utf-8"));
|
|
28
|
-
const candidateVersion = parsed.version?.trim();
|
|
29
|
-
if (candidateVersion) {
|
|
30
|
-
version = candidateVersion;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
} catch {}
|
|
35
|
-
}
|
|
36
|
-
return version || DEV_CLI_VERSION;
|
|
37
|
-
}
|
|
38
|
-
function isPublishedCliVersion(version) {
|
|
39
|
-
const normalized = version.trim();
|
|
40
|
-
return normalized.length > 0 && normalized !== SOURCE_CLI_VERSION && normalized !== DEV_CLI_VERSION;
|
|
41
|
-
}
|
|
42
|
-
export {
|
|
43
|
-
resolveInstalledCliVersion,
|
|
44
|
-
isPublishedCliVersion,
|
|
45
|
-
SOURCE_CLI_VERSION,
|
|
46
|
-
DEV_CLI_VERSION
|
|
47
|
-
};
|