@dreamlake/dreamlake-cli 0.109.0 → 0.110.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/cli/self-update/alias.d.ts +9 -0
- package/dist/cli/self-update/alias.js +86 -0
- package/dist/cli/self-update/index.js +2 -0
- package/dist/cli/self-update/install.d.ts +1 -0
- package/dist/cli/self-update/install.js +7 -2
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +11 -10
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface AliasOptions {
|
|
2
|
+
bin: string;
|
|
3
|
+
/** Known installed binaries, including the previous version before pruning. */
|
|
4
|
+
versions: string[];
|
|
5
|
+
windows?: boolean;
|
|
6
|
+
searchPath?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Return a warning when dl cannot be installed safely; never replace a foreign command. */
|
|
9
|
+
export declare function installAlias(opts: AliasOptions): string | null;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// A command on PATH, not a shell alias: works in scripts and every shell.
|
|
2
|
+
import { accessSync, constants, copyFileSync, lstatSync, readFileSync, readlinkSync, renameSync, rmSync, statSync, symlinkSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
/** Return a warning when dl cannot be installed safely; never replace a foreign command. */
|
|
5
|
+
export function installAlias(opts) {
|
|
6
|
+
const windows = opts.windows ?? process.platform === "win32";
|
|
7
|
+
const launcher = path.join(opts.bin, windows ? "dreamlake.exe" : "dreamlake");
|
|
8
|
+
const alias = path.join(opts.bin, windows ? "dl.exe" : "dl");
|
|
9
|
+
const conflict = (file) => `Warning: dl was not configured because ${file} already exists. It was left unchanged. Use dreamlake, or rename the conflicting command and re-run dreamlake install.`;
|
|
10
|
+
const staging = `${alias}.new-${process.pid}`;
|
|
11
|
+
let staged = false;
|
|
12
|
+
try {
|
|
13
|
+
let existing;
|
|
14
|
+
try {
|
|
15
|
+
existing = lstatSync(alias);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
if (err.code !== "ENOENT")
|
|
19
|
+
throw err;
|
|
20
|
+
}
|
|
21
|
+
if (existing) {
|
|
22
|
+
if (windows) {
|
|
23
|
+
if (!existing.isFile() || existing.isSymbolicLink())
|
|
24
|
+
return conflict(alias);
|
|
25
|
+
const bytes = readFileSync(alias);
|
|
26
|
+
if (!opts.versions.some(file => bytes.equals(readFileSync(file))))
|
|
27
|
+
return conflict(alias);
|
|
28
|
+
}
|
|
29
|
+
else if (!existing.isSymbolicLink() || path.resolve(opts.bin, readlinkSync(alias)) !== launcher) {
|
|
30
|
+
return conflict(alias);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Check all PATH entries before creating a new alias: PATH setup may prepend
|
|
34
|
+
// our bin directory, which would otherwise silently take over another dl.
|
|
35
|
+
const extensions = windows ? ["", ...new Set([".exe", ".cmd", ".bat", ".com", ".ps1", ...(process.env.PATHEXT ?? "").toLowerCase().split(";").filter(Boolean)])] : [""];
|
|
36
|
+
let other = null;
|
|
37
|
+
for (const dir of (opts.searchPath ?? process.env.PATH ?? "").split(windows ? ";" : ":")) {
|
|
38
|
+
for (const ext of extensions) {
|
|
39
|
+
const candidate = path.resolve(dir || ".", `dl${ext}`);
|
|
40
|
+
if (windows ? candidate.toLowerCase() === alias.toLowerCase() : candidate === alias)
|
|
41
|
+
continue;
|
|
42
|
+
try {
|
|
43
|
+
if (!statSync(candidate).isFile())
|
|
44
|
+
continue;
|
|
45
|
+
accessSync(candidate, windows ? constants.F_OK : constants.X_OK);
|
|
46
|
+
other = candidate;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
catch { /* absent or not executable */ }
|
|
50
|
+
}
|
|
51
|
+
if (other)
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
if (other && !existing)
|
|
55
|
+
return conflict(other);
|
|
56
|
+
if (windows) {
|
|
57
|
+
// A copy needs no symlink privileges, preserves argv/stdio/exit status,
|
|
58
|
+
// and can be invoked directly by PowerShell, CMD, or another program.
|
|
59
|
+
copyFileSync(launcher, staging, constants.COPYFILE_EXCL);
|
|
60
|
+
staged = true;
|
|
61
|
+
try {
|
|
62
|
+
renameSync(staging, alias);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if (!existing || !["EBUSY", "EPERM", "EACCES"].includes(err.code ?? ""))
|
|
66
|
+
throw err;
|
|
67
|
+
// dl self-update may be running this executable. Windows permits
|
|
68
|
+
// renaming that copy; the installer prunes it once its process exits.
|
|
69
|
+
renameSync(alias, `${alias}.old-${process.pid}`);
|
|
70
|
+
renameSync(staging, alias);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (!existing) {
|
|
74
|
+
// Exclusive creation also protects a command created since the check.
|
|
75
|
+
symlinkSync("dreamlake", alias);
|
|
76
|
+
}
|
|
77
|
+
return other ? `Warning: another dl is on PATH at ${other}. PATH order selects which runs; use ${alias} for DreamLake. Shell aliases and functions can also override dl.` : null;
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
return `Warning: could not configure dl at ${alias}: ${err.message}. Use dreamlake and re-run dreamlake install after resolving this.`;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
if (staged)
|
|
84
|
+
rmSync(staging, { force: true });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -21,6 +21,8 @@ export function registerInstallCommand(program) {
|
|
|
21
21
|
const converting = !isNativeInstall() && process.env.DREAMLAKE_BOOTSTRAP !== "1";
|
|
22
22
|
const result = await performInstall(target, { modifyPath: opts.modifyPath });
|
|
23
23
|
process.stdout.write(`Installed dreamlake ${result.version} → ${result.launcher}\n`);
|
|
24
|
+
if (!result.launcherConflict && !result.aliasWarning)
|
|
25
|
+
process.stdout.write("Also available as dl (same commands and settings).\n");
|
|
24
26
|
if (converting) {
|
|
25
27
|
process.stdout.write("This is now a native install under ~/.local; the copy you ran this from is untouched.\n");
|
|
26
28
|
}
|
|
@@ -20,6 +20,7 @@ export interface InstallResult {
|
|
|
20
20
|
* user ends up with `command not found` after a green checkmark.
|
|
21
21
|
*/
|
|
22
22
|
launcherConflict: string | null;
|
|
23
|
+
aliasWarning: string | null;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Resolve a user-supplied target into a concrete version. Accepts a channel
|
|
@@ -17,6 +17,7 @@ import { compareVersions, detectPlatform, downloadBinary, fetchManifest, isChann
|
|
|
17
17
|
import { activeChannel, pinnedVersion, updatesDisabled, writeSettings } from "./settings.js";
|
|
18
18
|
import { BytesProgress } from "../progress.js";
|
|
19
19
|
import { VERSION } from "../version.js";
|
|
20
|
+
import { installAlias } from "./alias.js";
|
|
20
21
|
/**
|
|
21
22
|
* Resolve a user-supplied target into a concrete version. Accepts a channel
|
|
22
23
|
* name or an exact version; a channel also becomes the saved default for
|
|
@@ -208,7 +209,7 @@ function prune(keep) {
|
|
|
208
209
|
// Launchers renamed out of the way because Windows had them locked.
|
|
209
210
|
try {
|
|
210
211
|
for (const entry of readdirSync(binDir())) {
|
|
211
|
-
if (/^dreamlake\.exe\.old-\d+$/.test(entry)) {
|
|
212
|
+
if (/^(dreamlake|dl)\.exe\.old-\d+$/.test(entry)) {
|
|
212
213
|
rmSync(path.join(binDir(), entry), { force: true });
|
|
213
214
|
}
|
|
214
215
|
}
|
|
@@ -295,6 +296,7 @@ export async function performInstall(target, opts = {}) {
|
|
|
295
296
|
throw new Error(`superseded by a pin to ${pinnedVersion()} set while downloading`);
|
|
296
297
|
}
|
|
297
298
|
const { previous, conflict } = linkLauncher(version);
|
|
299
|
+
const aliasWarning = conflict ? null : installAlias({ bin: binDir(), versions: listVersions().map(versionPath) });
|
|
298
300
|
// Asking for an exact version pins it; asking for a channel resumes
|
|
299
301
|
// following that channel. Without this the background updater would move
|
|
300
302
|
// you straight off the version you just asked for.
|
|
@@ -329,6 +331,7 @@ export async function performInstall(target, opts = {}) {
|
|
|
329
331
|
launcher: launcherPath(),
|
|
330
332
|
pinned: channel ? null : version,
|
|
331
333
|
launcherConflict: conflict,
|
|
334
|
+
aliasWarning,
|
|
332
335
|
shadowedBy,
|
|
333
336
|
pathAdvice,
|
|
334
337
|
};
|
|
@@ -339,6 +342,7 @@ export async function performInstall(target, opts = {}) {
|
|
|
339
342
|
*/
|
|
340
343
|
export function installWarnings(result) {
|
|
341
344
|
const tilde = (p) => p.replace(homedir(), "~");
|
|
345
|
+
const aliasWarnings = result.aliasWarning ? [result.aliasWarning] : [];
|
|
342
346
|
if (result.launcherConflict) {
|
|
343
347
|
return [
|
|
344
348
|
`Warning: ${tilde(result.launcherConflict)} already exists and is not a symlink we manage.`,
|
|
@@ -349,6 +353,7 @@ export function installWarnings(result) {
|
|
|
349
353
|
}
|
|
350
354
|
if (result.shadowedBy) {
|
|
351
355
|
return [
|
|
356
|
+
...aliasWarnings,
|
|
352
357
|
`Warning: another dreamlake is earlier on your PATH and will keep running instead:`,
|
|
353
358
|
` ${tilde(result.shadowedBy)}`,
|
|
354
359
|
`Installed ${result.version} at ${tilde(result.launcher)}.`,
|
|
@@ -356,7 +361,7 @@ export function installWarnings(result) {
|
|
|
356
361
|
`or put ~/.local/bin ahead of it in PATH. Check with: dreamlake doctor`,
|
|
357
362
|
];
|
|
358
363
|
}
|
|
359
|
-
return
|
|
364
|
+
return aliasWarnings;
|
|
360
365
|
}
|
|
361
366
|
/** Newest version available on `channel`, or null when the check fails. */
|
|
362
367
|
export async function latestAvailable(channel) {
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.110.0";
|
package/dist/cli/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dreamlake-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.110.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"homepage": "https://cli.dreamlake.ai",
|
|
9
9
|
"description": "dreamlake — data-warehouse CLI. The `dreamlake` command uploads/downloads assets, manages episodes, bindrs, datasets, organizations and teams, and versions artifacts, workflow specs and pipelines against a DreamLake server + BSS.",
|
|
10
10
|
"bin": {
|
|
11
|
-
"dreamlake": "bin/dreamlake.js"
|
|
11
|
+
"dreamlake": "bin/dreamlake.js",
|
|
12
|
+
"dl": "bin/dreamlake.js"
|
|
12
13
|
},
|
|
13
14
|
"exports": {
|
|
14
15
|
"./api": {
|
|
@@ -36,13 +37,13 @@
|
|
|
36
37
|
"node": ">=18"
|
|
37
38
|
},
|
|
38
39
|
"optionalDependencies": {
|
|
39
|
-
"@dreamlake/dreamlake-cli-darwin-arm64": "0.
|
|
40
|
-
"@dreamlake/dreamlake-cli-darwin-x64": "0.
|
|
41
|
-
"@dreamlake/dreamlake-cli-linux-x64": "0.
|
|
42
|
-
"@dreamlake/dreamlake-cli-linux-arm64": "0.
|
|
43
|
-
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.
|
|
44
|
-
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.
|
|
45
|
-
"@dreamlake/dreamlake-cli-win32-x64": "0.
|
|
46
|
-
"@dreamlake/dreamlake-cli-win32-arm64": "0.
|
|
40
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.110.0",
|
|
41
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.110.0",
|
|
42
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.110.0",
|
|
43
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.110.0",
|
|
44
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.110.0",
|
|
45
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.110.0",
|
|
46
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.110.0",
|
|
47
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.110.0"
|
|
47
48
|
}
|
|
48
49
|
}
|