@lesscap/baton-cli 0.2.7 → 0.2.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/baton.mjs +33 -12
- package/package.json +1 -1
package/dist/baton.mjs
CHANGED
|
@@ -700,6 +700,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
700
700
|
import { join } from "node:path";
|
|
701
701
|
var PROJECT_CONFIG_NAME = ".baton.json";
|
|
702
702
|
var projectConfigPath = (cwd = process.cwd()) => join(cwd, PROJECT_CONFIG_NAME);
|
|
703
|
+
var configPathFromArgs = (args, cwd) => args.config ?? projectConfigPath(cwd);
|
|
703
704
|
var loadProjectConfig = (path) => {
|
|
704
705
|
try {
|
|
705
706
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
@@ -2870,6 +2871,10 @@ var worker = defineCommand({
|
|
|
2870
2871
|
args: {
|
|
2871
2872
|
project: { type: "string", description: "project id (overrides .baton.json)" },
|
|
2872
2873
|
name: { type: "string", description: "worker display name (default: hostname)" },
|
|
2874
|
+
config: {
|
|
2875
|
+
type: "string",
|
|
2876
|
+
description: "path to the worker config file (default: ./.baton.json)"
|
|
2877
|
+
},
|
|
2873
2878
|
...common
|
|
2874
2879
|
},
|
|
2875
2880
|
run: async ({ args }) => {
|
|
@@ -2883,13 +2888,17 @@ var worker = defineCommand({
|
|
|
2883
2888
|
const hostname = osHostname();
|
|
2884
2889
|
const machineId = readOrCreateMachineId();
|
|
2885
2890
|
const name = args.name ?? hostname;
|
|
2886
|
-
const { out, configPath } = await registerWorker(
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2891
|
+
const { out, configPath } = await registerWorker(
|
|
2892
|
+
c,
|
|
2893
|
+
{
|
|
2894
|
+
projectId: resolveProjectId(args),
|
|
2895
|
+
name,
|
|
2896
|
+
server,
|
|
2897
|
+
hostname,
|
|
2898
|
+
machineId
|
|
2899
|
+
},
|
|
2900
|
+
configPathFromArgs(args)
|
|
2901
|
+
);
|
|
2893
2902
|
if (args.json) {
|
|
2894
2903
|
console.log(toJson({ ...out, configPath, machineIdPath: machineIdPath() }));
|
|
2895
2904
|
return;
|
|
@@ -2906,9 +2915,15 @@ var worker = defineCommand({
|
|
|
2906
2915
|
name: "run",
|
|
2907
2916
|
description: "run the persistent worker daemon (listens for session create/delete commands)"
|
|
2908
2917
|
},
|
|
2909
|
-
args: {
|
|
2910
|
-
|
|
2911
|
-
|
|
2918
|
+
args: {
|
|
2919
|
+
config: {
|
|
2920
|
+
type: "string",
|
|
2921
|
+
description: "path to the worker config file (default: ./.baton.json)"
|
|
2922
|
+
},
|
|
2923
|
+
...common
|
|
2924
|
+
},
|
|
2925
|
+
run: async ({ args }) => {
|
|
2926
|
+
const cfg = viewWorker(loadProjectConfig(configPathFromArgs(args)));
|
|
2912
2927
|
const client = createClient(cfg.server, { bearer: cfg.apiToken });
|
|
2913
2928
|
const ac = new AbortController();
|
|
2914
2929
|
const stop = () => ac.abort();
|
|
@@ -2977,11 +2992,17 @@ var worker = defineCommand({
|
|
|
2977
2992
|
}),
|
|
2978
2993
|
whoami: defineCommand({
|
|
2979
2994
|
meta: { name: "whoami", description: "show local worker config from .baton.json" },
|
|
2980
|
-
args: {
|
|
2995
|
+
args: {
|
|
2996
|
+
config: {
|
|
2997
|
+
type: "string",
|
|
2998
|
+
description: "path to the worker config file (default: ./.baton.json)"
|
|
2999
|
+
},
|
|
3000
|
+
...common
|
|
3001
|
+
},
|
|
2981
3002
|
run: ({ args }) => {
|
|
2982
3003
|
const cfg = (() => {
|
|
2983
3004
|
try {
|
|
2984
|
-
return loadProjectConfig(
|
|
3005
|
+
return loadProjectConfig(configPathFromArgs(args));
|
|
2985
3006
|
} catch {
|
|
2986
3007
|
return null;
|
|
2987
3008
|
}
|