@whyvix/remote 0.3.8 → 0.3.9

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyvix/remote",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -24,6 +24,7 @@ export class DeploymentManager{
24
24
  this.security=security;this.audit=audit;this.execFileFn=execFileFn;this.transferArtifact=transferArtifact;
25
25
  }
26
26
  listProfiles(){return [...this.profiles.values()].map(({alias,label="",remoteAlias})=>({alias,label,remoteAlias}));}
27
+ resolveOperation({profile:profileAlias,operation,commit}){return buildDeploymentOperation(this.#profile(profileAlias),{operation,commit});}
27
28
  #profile(alias){const value=String(alias||"");if(!PROFILE_RE.test(value)||!this.profiles.has(value))fail("DEPLOY_PROFILE_DENIED","Deployment profile is not registered");return this.profiles.get(value);}
28
29
  async prepareLocal({profile:profileAlias,commit,baseCommit=null}){
29
30
  const profile=this.#profile(profileAlias);
@@ -33,8 +34,8 @@ export class DeploymentManager{
33
34
  const {stdout:rootRaw}=await this.execFileFn("git",["rev-parse","--show-toplevel"],{cwd:repo,windowsHide:true,maxBuffer:1024*1024});
34
35
  const root=this.security.resolveAllowed(rootRaw.trim());
35
36
  if(path.resolve(root)!==path.resolve(repo))fail("DEPLOY_PROFILE_DENIED","Deployment repository root does not match profile");
36
- const {stdout:status}=await this.execFileFn("git",["status","--porcelain"],{cwd:root,windowsHide:true,maxBuffer:1024*1024});
37
- const dirty=status.split(/\r?\n/).filter(Boolean).filter(line=>!line.startsWith("?? .deploy/"));
37
+ const {stdout:status}=await this.execFileFn("git",["status","--porcelain","--untracked-files=no"],{cwd:root,windowsHide:true,maxBuffer:1024*1024});
38
+ const dirty=status.split(/\r?\n/).filter(Boolean);
38
39
  if(dirty.length)fail("DEPLOY_REPOSITORY_DIRTY","Deployment repository must be clean");
39
40
  try{await this.execFileFn("git",["cat-file","-e",commit+"^{commit}"],{cwd:root,windowsHide:true,maxBuffer:1024*1024});}catch{fail("DEPLOY_COMMIT_INVALID","Deployment commit does not exist locally");}
40
41
  let dependencyChanged=false;
@@ -22,9 +22,9 @@ export function releaseIdFromCommit(commit){
22
22
 
23
23
  export function buildDeployHelperArgs(input){
24
24
  const operation=String(input?.operation||""),commit=String(input?.commit||""),releaseId=releaseIdFromCommit(commit);
25
- if(!["verify","prepare","status"].includes(operation))fail("DEPLOY_OPERATION_DENIED","Deployment helper operation is not allowed");
25
+ if(!["verify","prepare","certify","status","activate"].includes(operation))fail("DEPLOY_OPERATION_DENIED","Deployment helper operation is not allowed");
26
26
  if(input?.releaseId!==undefined&&String(input.releaseId)!==releaseId)fail("DEPLOY_ARGUMENT_INVALID","Release identity does not match commit");
27
- if(operation==="status"){if(input?.artifactSha256!==undefined)fail("DEPLOY_ARGUMENT_INVALID","Status does not accept artifact checksum");return Object.freeze([operation,releaseId,commit]);}
27
+ if(["status","activate","certify"].includes(operation)){if(input?.artifactSha256!==undefined)fail("DEPLOY_ARGUMENT_INVALID",operation+" does not accept artifact checksum");return Object.freeze([operation,releaseId,commit]);}
28
28
  const artifactSha256=String(input?.artifactSha256||"");if(!HASH_RE.test(artifactSha256))fail("DEPLOY_CHECKSUM_INVALID","Artifact SHA-256 is required");
29
29
  return Object.freeze([operation,releaseId,commit,artifactSha256]);
30
30
  }
@@ -116,6 +116,7 @@ export function createToolExecutor({ security, processManager, remoteExecutionMa
116
116
  if(tool==="remote.targets"){if(!remoteExecutionManager)throw Object.assign(new Error("Remote execution is not configured"),{code:"REMOTE_TARGET_DENIED"});return{targets:remoteExecutionManager.listTargets()};}
117
117
  if(tool==="remote.start"){if(!remoteExecutionManager)throw Object.assign(new Error("Remote execution is not configured"),{code:"REMOTE_TARGET_DENIED"});return remoteExecutionManager.start(args);}
118
118
  if(tool==="remote.deploy_status"){if(!remoteExecutionManager)throw Object.assign(new Error("Remote execution is not configured"),{code:"REMOTE_TARGET_DENIED"});return remoteExecutionManager.startDeployHelper({alias:args.alias,input:{operation:"status",commit:args.commit},timeoutMs:args.timeoutMs,ownerId:args.ownerId});}
119
+ if(tool==="deploy.status_release"||tool==="deploy.certify_release"||tool==="deploy.activate_release"){if(!remoteExecutionManager||!deploymentManager)throw Object.assign(new Error("Deployment authority is not configured"),{code:"DEPLOY_PROFILE_DENIED"});const operation=tool==="deploy.status_release"?"status":tool==="deploy.certify_release"?"certify":"activate",resolved=deploymentManager.resolveOperation({profile:args.profile,operation,commit:args.commit});return remoteExecutionManager.startDeployHelper({alias:resolved.remoteAlias,input:{operation,commit:resolved.commit},timeoutMs:args.timeoutMs,ownerId:args.ownerId});}
119
120
  if(tool==="remote.output"){if(!remoteExecutionManager)throw Object.assign(new Error("Remote execution is not configured"),{code:"REMOTE_JOB_NOT_FOUND"});return remoteExecutionManager.output(args);}
120
121
  if(tool==="remote.input"){if(!remoteExecutionManager)throw Object.assign(new Error("Remote execution is not configured"),{code:"REMOTE_JOB_NOT_FOUND"});return remoteExecutionManager.input(args);}
121
122
  if(tool==="remote.stop"){if(!remoteExecutionManager)throw Object.assign(new Error("Remote execution is not configured"),{code:"REMOTE_JOB_NOT_FOUND"});return remoteExecutionManager.stop(args);}