@flux-lang/cli 0.1.6 → 0.1.8
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/bin/flux.js +11 -7
- package/dist/versionInfo.js +46 -0
- package/package.json +7 -6
package/dist/bin/flux.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createRuntime, parseDocument } from "@flux-lang/core";
|
|
|
8
8
|
import { shouldLaunchUi } from "../ui-routing.js";
|
|
9
9
|
import { computeBuildId, defaultEmbeddedDir, VIEWER_VERSION as VIEWER_PACKAGE_VERSION, } from "@flux-lang/viewer";
|
|
10
10
|
import { FLUX_CLI_VERSION } from "../version.js";
|
|
11
|
+
import { getFluxVersionInfoCli } from "../versionInfo.js";
|
|
11
12
|
const CLI_VERSION = FLUX_CLI_VERSION;
|
|
12
13
|
void (async () => {
|
|
13
14
|
try {
|
|
@@ -24,6 +25,7 @@ void (async () => {
|
|
|
24
25
|
async function main(argv) {
|
|
25
26
|
const parsed = parseGlobalArgs(argv);
|
|
26
27
|
const args = parsed.args;
|
|
28
|
+
const fluxVersionInfo = await getFluxVersionInfoCli(process.cwd());
|
|
27
29
|
const uiEnabled = shouldLaunchUi({
|
|
28
30
|
stdoutIsTTY: Boolean(process.stdout.isTTY),
|
|
29
31
|
stdinIsTTY: process.stdin.isTTY,
|
|
@@ -37,11 +39,12 @@ async function main(argv) {
|
|
|
37
39
|
initialArgs: args,
|
|
38
40
|
detach: parsed.detach,
|
|
39
41
|
helpCommand: parsed.help ? args[0] : undefined,
|
|
40
|
-
|
|
42
|
+
versionInfo: fluxVersionInfo,
|
|
43
|
+
showVersionModal: parsed.version,
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
if (parsed.version) {
|
|
44
|
-
await printVersion(parsed.json);
|
|
47
|
+
await printVersion(parsed.json, fluxVersionInfo);
|
|
45
48
|
return 0;
|
|
46
49
|
}
|
|
47
50
|
if (parsed.help) {
|
|
@@ -148,7 +151,7 @@ function parseGlobalArgs(argv) {
|
|
|
148
151
|
}
|
|
149
152
|
return { ...flags, args };
|
|
150
153
|
}
|
|
151
|
-
async function collectComponentVersions() {
|
|
154
|
+
async function collectComponentVersions(versionInfo) {
|
|
152
155
|
let editorBuildId = null;
|
|
153
156
|
try {
|
|
154
157
|
const embedded = defaultEmbeddedDir();
|
|
@@ -159,13 +162,13 @@ async function collectComponentVersions() {
|
|
|
159
162
|
editorBuildId = null;
|
|
160
163
|
}
|
|
161
164
|
return {
|
|
162
|
-
cli:
|
|
165
|
+
cli: versionInfo.version,
|
|
163
166
|
viewer: VIEWER_PACKAGE_VERSION,
|
|
164
167
|
editorBuildId,
|
|
165
168
|
};
|
|
166
169
|
}
|
|
167
|
-
async function printVersion(asJson) {
|
|
168
|
-
const info = await collectComponentVersions();
|
|
170
|
+
async function printVersion(asJson, versionInfo) {
|
|
171
|
+
const info = await collectComponentVersions(versionInfo);
|
|
169
172
|
if (asJson) {
|
|
170
173
|
console.log(JSON.stringify(info));
|
|
171
174
|
return;
|
|
@@ -1320,7 +1323,8 @@ async function launchUi(options) {
|
|
|
1320
1323
|
initialArgs: options.initialArgs,
|
|
1321
1324
|
detach: options.detach,
|
|
1322
1325
|
helpCommand: options.helpCommand,
|
|
1323
|
-
|
|
1326
|
+
versionInfo: options.versionInfo,
|
|
1327
|
+
showVersionModal: options.showVersionModal,
|
|
1324
1328
|
});
|
|
1325
1329
|
return 0;
|
|
1326
1330
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { coerceVersionInfo } from "@flux-lang/brand";
|
|
4
|
+
import cliPkg from "../package.json" with { type: "json" };
|
|
5
|
+
const VERSION_FILENAME = "version.json";
|
|
6
|
+
function inferChannelFromSemver(version) {
|
|
7
|
+
return /-canary(?:\.|$)/i.test(version) ? "canary" : "stable";
|
|
8
|
+
}
|
|
9
|
+
async function findVersionJson(startDir) {
|
|
10
|
+
let current = path.resolve(startDir);
|
|
11
|
+
while (true) {
|
|
12
|
+
const candidate = path.join(current, VERSION_FILENAME);
|
|
13
|
+
try {
|
|
14
|
+
await fs.access(candidate);
|
|
15
|
+
return candidate;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// keep walking
|
|
19
|
+
}
|
|
20
|
+
const parent = path.dirname(current);
|
|
21
|
+
if (parent === current)
|
|
22
|
+
return null;
|
|
23
|
+
current = parent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export async function getFluxVersionInfoCli(cwd = process.cwd()) {
|
|
27
|
+
const fromRepo = await findVersionJson(cwd);
|
|
28
|
+
if (fromRepo) {
|
|
29
|
+
try {
|
|
30
|
+
const raw = await fs.readFile(fromRepo, "utf8");
|
|
31
|
+
const parsed = JSON.parse(raw);
|
|
32
|
+
return coerceVersionInfo({
|
|
33
|
+
version: parsed.baseVersion ?? parsed.version,
|
|
34
|
+
channel: parsed.channel,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Fall through to package fallback.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const packageVersion = String(cliPkg.version ?? "0.0.0");
|
|
42
|
+
return coerceVersionInfo({
|
|
43
|
+
version: packageVersion,
|
|
44
|
+
channel: inferChannelFromSemver(packageVersion),
|
|
45
|
+
});
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flux-lang/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "CLI tooling for the Flux score language",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Suarez-Solis",
|
|
@@ -17,18 +17,19 @@
|
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"prebuild": "npm run build --workspace @flux-lang/cli-core && npm run build --workspace @flux-lang/cli-ui",
|
|
20
|
+
"prebuild": "npm run build --workspace @flux-lang/cli-core && npm run build --workspace @flux-lang/brand && npm run build --workspace @flux-lang/cli-ui",
|
|
21
21
|
"build": "tsc -p tsconfig.json",
|
|
22
22
|
"dev": "tsc -p tsconfig.json --watch",
|
|
23
23
|
"lint": "eslint src --ext .ts",
|
|
24
|
-
"pretest": "npm run build --workspace @flux-lang/core",
|
|
24
|
+
"pretest": "npm run build --workspace @flux-lang/core && npm run build --workspace @flux-lang/brand",
|
|
25
25
|
"test": "npm run build && vitest",
|
|
26
26
|
"prepublishOnly": "npm run build && chmod +x dist/bin/flux.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@flux-lang/
|
|
30
|
-
"@flux-lang/
|
|
31
|
-
"@flux-lang/cli-
|
|
29
|
+
"@flux-lang/brand": "workspace:^",
|
|
30
|
+
"@flux-lang/core": "workspace:^",
|
|
31
|
+
"@flux-lang/cli-core": "workspace:^",
|
|
32
|
+
"@flux-lang/cli-ui": "workspace:^"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/node": "^22.0.0",
|