@blinkhost/cli 2.3.0 → 2.5.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/CHANGELOG.md +246 -0
- package/README.md +251 -3
- package/dist/api.d.ts +1 -0
- package/dist/api.js +129 -2
- package/dist/assistant.d.ts +7 -0
- package/dist/assistant.js +460 -0
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +21 -24
- package/dist/cli.js +39 -13
- package/dist/compatibility.d.ts +1 -0
- package/dist/compatibility.js +43 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +9 -1
- package/dist/credential-process.d.ts +19 -0
- package/dist/credential-process.js +75 -0
- package/dist/credentials.d.ts +4 -0
- package/dist/credentials.js +45 -46
- package/dist/device-flow.d.ts +24 -0
- package/dist/device-flow.js +76 -0
- package/dist/guidance.d.ts +1 -1
- package/dist/guidance.js +68 -5
- package/dist/macos-keychain-input.d.ts +6 -0
- package/dist/macos-keychain-input.js +22 -0
- package/dist/module-build.d.ts +7 -0
- package/dist/module-build.js +37 -0
- package/dist/peer-review.d.ts +8 -0
- package/dist/peer-review.js +55 -0
- package/dist/project-export.d.ts +1 -0
- package/dist/project-export.js +79 -0
- package/dist/research.d.ts +1 -0
- package/dist/research.js +42 -0
- package/dist/starter.d.ts +11 -0
- package/dist/starter.js +45 -0
- package/dist/templates.js +10 -8
- package/dist/terminal.d.ts +2 -0
- package/dist/terminal.js +12 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/windows-vault-command.d.ts +12 -0
- package/dist/windows-vault-command.js +42 -0
- package/dist/workflows.d.ts +17 -1
- package/dist/workflows.js +76 -4
- package/package.json +2 -2
package/dist/workflows.d.ts
CHANGED
|
@@ -3,6 +3,22 @@ export declare function testProject(input: string[], json?: boolean): Promise<un
|
|
|
3
3
|
export declare function observability(kind: 'logs' | 'metrics' | 'analytics', input: string[], profile?: string): Promise<unknown>;
|
|
4
4
|
export declare function runPlugins(input: string[], json?: boolean): Promise<unknown>;
|
|
5
5
|
export declare function completion(shell: string | undefined): string;
|
|
6
|
-
|
|
6
|
+
interface ReleaseCheck {
|
|
7
|
+
current_version: string;
|
|
8
|
+
latest_version: string | null;
|
|
9
|
+
update_available: boolean;
|
|
10
|
+
affected?: boolean;
|
|
11
|
+
impact?: string;
|
|
12
|
+
requires_action?: boolean;
|
|
13
|
+
summary?: string;
|
|
14
|
+
release_url?: string;
|
|
15
|
+
migration_url?: string;
|
|
16
|
+
install_command?: string;
|
|
17
|
+
automatic_install: false;
|
|
18
|
+
}
|
|
19
|
+
export declare function checkForUpdate(profile?: string, timeoutMs?: number): Promise<ReleaseCheck>;
|
|
20
|
+
export declare function releaseNotes(version?: string, profile?: string): Promise<unknown>;
|
|
21
|
+
export declare function maybeUpdateNotice(profile?: string): Promise<string | null>;
|
|
7
22
|
export declare function ciCheck(profile?: string): Promise<unknown>;
|
|
8
23
|
export declare function supportBundle(input: string[], profile?: string): Promise<unknown>;
|
|
24
|
+
export {};
|
package/dist/workflows.js
CHANGED
|
@@ -4,7 +4,7 @@ import { hostname, platform, release } from 'node:os';
|
|
|
4
4
|
import { basename, dirname, isAbsolute, join } from 'node:path';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
6
|
import { ApiClient } from './api.js';
|
|
7
|
-
import { readConfig, writeConfig } from './config.js';
|
|
7
|
+
import { activeProfile, readConfig, writeConfig } from './config.js';
|
|
8
8
|
import { CliError, EXIT } from './errors.js';
|
|
9
9
|
import { readProjectManifest, resolveLocalPath, validateProject } from './project.js';
|
|
10
10
|
import { readProjectLink } from './remote.js';
|
|
@@ -177,12 +177,84 @@ const COMPLETIONS = {
|
|
|
177
177
|
};
|
|
178
178
|
export function completion(shell) { if (!shell || !COMPLETIONS[shell])
|
|
179
179
|
throw new CliError('Choose bash, zsh, fish, or powershell.', EXIT.usage, 'invalid_shell'); return `${COMPLETIONS[shell]}\n`; }
|
|
180
|
-
|
|
181
|
-
const
|
|
180
|
+
function versionTuple(value) {
|
|
181
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?$/.exec(value);
|
|
182
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
183
|
+
}
|
|
184
|
+
function newerThan(candidate, current) {
|
|
185
|
+
const left = versionTuple(candidate);
|
|
186
|
+
const right = versionTuple(current);
|
|
187
|
+
if (!left || !right)
|
|
188
|
+
return false;
|
|
189
|
+
for (let index = 0; index < 3; index += 1) {
|
|
190
|
+
const candidatePart = left[index] ?? 0;
|
|
191
|
+
const currentPart = right[index] ?? 0;
|
|
192
|
+
if (candidatePart !== currentPart)
|
|
193
|
+
return candidatePart > currentPart;
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
async function releaseRequest(path, profile, timeoutMs = 3000) {
|
|
198
|
+
const selected = await activeProfile(profile);
|
|
199
|
+
return fetch(`${selected.profile.apiOrigin}${path}`, {
|
|
200
|
+
headers: { Accept: 'application/json', 'User-Agent': `BlinkHost-CLI/${VERSION}` },
|
|
201
|
+
redirect: 'error',
|
|
202
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
export async function checkForUpdate(profile, timeoutMs = 3000) {
|
|
206
|
+
const query = new URLSearchParams({ component: 'cli', channel: 'stable', current_version: VERSION });
|
|
207
|
+
const response = await releaseRequest(`/api/documentation/releases/latest/?${query}`, profile, timeoutMs);
|
|
182
208
|
if (!response.ok)
|
|
183
209
|
throw new CliError('The release service could not be reached.', EXIT.network, 'update_check_failed');
|
|
184
210
|
const data = await response.json();
|
|
185
|
-
return {
|
|
211
|
+
return { ...data, current_version: VERSION, automatic_install: false };
|
|
212
|
+
}
|
|
213
|
+
export async function releaseNotes(version, profile) {
|
|
214
|
+
const query = new URLSearchParams({ component: 'cli', channel: 'stable' });
|
|
215
|
+
const response = await releaseRequest(`/api/documentation/releases/?${query}`, profile);
|
|
216
|
+
if (!response.ok)
|
|
217
|
+
throw new CliError('Release notes could not be loaded.', EXIT.network, 'release_notes_failed');
|
|
218
|
+
const payload = await response.json();
|
|
219
|
+
const rows = Array.isArray(payload) ? payload : (payload.results || []);
|
|
220
|
+
const releases = rows.filter((item) => Boolean(item && typeof item === 'object'));
|
|
221
|
+
if (version) {
|
|
222
|
+
const selected = releases.find((item) => item.version === version);
|
|
223
|
+
if (!selected)
|
|
224
|
+
throw new CliError(`No published CLI release notes were found for ${version}.`, EXIT.remote, 'release_not_found');
|
|
225
|
+
return selected;
|
|
226
|
+
}
|
|
227
|
+
return { component: 'cli', releases };
|
|
228
|
+
}
|
|
229
|
+
export async function maybeUpdateNotice(profile) {
|
|
230
|
+
if (!process.stderr.isTTY || process.env.CI || process.env.BLINKHOST_NO_UPDATE_NOTIFIER === '1')
|
|
231
|
+
return null;
|
|
232
|
+
const selected = await activeProfile(profile);
|
|
233
|
+
if (selected.config.updateNotifications === false)
|
|
234
|
+
return null;
|
|
235
|
+
const checkedAt = selected.config.updateCheckedAt ? Date.parse(selected.config.updateCheckedAt) : 0;
|
|
236
|
+
if (Number.isFinite(checkedAt) && Date.now() - checkedAt < 48 * 60 * 60 * 1000)
|
|
237
|
+
return null;
|
|
238
|
+
try {
|
|
239
|
+
const result = await checkForUpdate(profile, 500);
|
|
240
|
+
selected.config.updateCheckedAt = new Date().toISOString();
|
|
241
|
+
if (result.latest_version)
|
|
242
|
+
selected.config.latestVersion = result.latest_version;
|
|
243
|
+
else
|
|
244
|
+
delete selected.config.latestVersion;
|
|
245
|
+
if (result.release_url)
|
|
246
|
+
selected.config.latestReleaseUrl = result.release_url;
|
|
247
|
+
else
|
|
248
|
+
delete selected.config.latestReleaseUrl;
|
|
249
|
+
await writeConfig(selected.config);
|
|
250
|
+
if (!result.latest_version || !newerThan(result.latest_version, VERSION))
|
|
251
|
+
return null;
|
|
252
|
+
const instruction = result.install_command || `npm install --global @blinkhost/cli@${result.latest_version}`;
|
|
253
|
+
return `BlinkHost CLI ${result.latest_version} is available. Run ${instruction} or \`blinkhost update notes ${result.latest_version}\`.`;
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
186
258
|
}
|
|
187
259
|
export async function ciCheck(profile) {
|
|
188
260
|
const client = await ApiClient.create(profile);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blinkhost/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Secure local and remote developer workflows for BlinkHost",
|
|
5
5
|
"keywords": ["blinkhost", "deployment", "hosting", "cloud", "cli", "developer-tools"],
|
|
6
6
|
"homepage": "https://app.blinkhost.me/docs/source-control/cli",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"bugs": { "url": "https://github.com/blinkhost-ltd/blinkhost-cli/issues" },
|
|
9
9
|
"type": "module",
|
|
10
10
|
"bin": { "blinkhost": "dist/cli.js" },
|
|
11
|
-
"files": ["dist/*.js", "dist/*.d.ts", "README.md", "LICENSE"],
|
|
11
|
+
"files": ["dist/*.js", "dist/*.d.ts", "README.md", "CHANGELOG.md", "LICENSE"],
|
|
12
12
|
"engines": { "node": ">=22.12.0" },
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc -p tsconfig.json",
|