@whyvix/remote 0.3.2 → 0.3.3
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/package.json
CHANGED
|
@@ -3,12 +3,13 @@ import path from "node:path";
|
|
|
3
3
|
|
|
4
4
|
function fail(code,message){throw Object.assign(new Error(message),{code});}
|
|
5
5
|
|
|
6
|
-
export async function loadDeploymentProfiles(filePath){
|
|
6
|
+
export async function loadDeploymentProfiles(filePath,{optional=false}={}){
|
|
7
7
|
const requested=String(filePath||"").trim();
|
|
8
8
|
if(!requested)return[];
|
|
9
9
|
const resolved=path.resolve(requested);
|
|
10
10
|
let parsed;
|
|
11
11
|
try{parsed=JSON.parse(await fs.readFile(resolved,"utf8"));}catch(error){
|
|
12
|
+
if(optional&&error?.code==="ENOENT")return[];
|
|
12
13
|
if(error instanceof SyntaxError)fail("DEPLOY_PROFILE_DENIED","Deployment profile file is not valid JSON");
|
|
13
14
|
fail("DEPLOY_PROFILE_DENIED","Deployment profile file cannot be read");
|
|
14
15
|
}
|
package/packages/cli/index.js
CHANGED
|
@@ -16,7 +16,9 @@ const gatewayUrl=process.env.WHYVIX_GATEWAY_URL||"wss://remote.whyvix.com";
|
|
|
16
16
|
const authUrl=(process.env.WHYVIX_AUTH_URL||"https://auth.whyvix.com").replace(/\/$/,"");
|
|
17
17
|
const workspaces=(process.env.WHYVIX_WORKSPACES||process.cwd()).split(";").filter(Boolean);
|
|
18
18
|
const remoteTargets=(process.env.WHYVIX_REMOTE_TARGETS||"").split(";").map(alias=>alias.trim()).filter(Boolean).map(alias=>({alias}));
|
|
19
|
-
const
|
|
19
|
+
const configuredDeploymentProfiles=String(process.env.WHYVIX_DEPLOY_PROFILES_FILE||"").trim();
|
|
20
|
+
const defaultDeploymentProfiles=join(os.homedir(),".whyvix-remote","deployment-profiles.json");
|
|
21
|
+
const deploymentProfiles=await loadDeploymentProfiles(configuredDeploymentProfiles||defaultDeploymentProfiles,{optional:!configuredDeploymentProfiles});
|
|
20
22
|
const capabilities=["filesystem.crud","process.bounded","git.read","git.mutate",...(remoteTargets.length?["remote.bounded"]:[]),...(deploymentProfiles.length?["deployment.profiled"]:[])];
|
|
21
23
|
const deviceId=process.env.WHYVIX_DEVICE_ID||crypto.createHash("sha256").update(os.hostname()+"|"+os.userInfo().username).digest("hex").slice(0,24);
|
|
22
24
|
const credentialDir=join(os.homedir(),".whyvix-remote");
|