@platforma-sdk/bootstrap 3.3.1 → 3.4.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/assets/compose-backend.yaml +4 -1
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -73
- package/dist/index.mjs.map +1 -1
- package/dist/templates/pl-config.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -55,7 +55,10 @@ services:
|
|
|
55
55
|
- "PL_AUTH_ENABLED=${PL_AUTH_ENABLED:-false}"
|
|
56
56
|
- "PL_AUTH_HTPASSWD_PATH=${PL_AUTH_HTPASSWD_PATH:+/etc/platforma/users.htpasswd}"
|
|
57
57
|
|
|
58
|
-
- "
|
|
58
|
+
- "PL_RUNNER_WD_CACHE_ON_SUCCESS=${PL_RUNNER_WD_CACHE_ON_SUCCESS:-20m}"
|
|
59
|
+
- "PL_RUNNER_WD_CACHE_ON_FAILURE=${PL_RUNNER_WD_CACHE_ON_FAILURE:-1h}"
|
|
60
|
+
|
|
61
|
+
- "PL_WORKFLOW_ENABLE_ALL_FEATURES=true"
|
|
59
62
|
|
|
60
63
|
# Data Controller: general settings
|
|
61
64
|
- "PL_DATA_CREATE_BUCKET=true" # try to automatically create buckets for storages if they not exist
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Pr=Object.defineProperty;var kr=(a,e,t)=>e in a?Pr(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var l=(a,e,t)=>kr(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@oclif/core"),D=require("node:os"),m=require("node:fs"),h=require("node:path"),le=require("node:child_process"),de=require("winston"),Sr=require("node:crypto"),Q=require("readline-sync"),$r=require("node:fs/promises"),Lr=require("node:stream"),x=require("zod"),Ar=require("decompress"),ge=require("@milaboratories/pl-deployments"),or=require("yaml"),Ir=require("node:https"),Or=require("tar");function ur(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const _=ur($r),Fr=ur(Or),L={"log-level":u.Flags.string({description:"logging level",default:"info",options:["error","warn","info","debug"],required:!1})};u.Flags.string({description:"name of instance",required:!1});const ue={image:u.Flags.string({description:"use custom docker image to run platforma"})},N={version:u.Flags.string({description:"use custom platforma release (official docker image or binary package)"})},fe={arch:u.Flags.string({description:"override architecture. You can start amd64 linux image on arm-based host (say, Apple M family processor). I.e. arm64, amd64, amd64/v2"})},C={license:u.Flags.string({description:'pass a license code. The license can be got from "https://licensing.milaboratories.com".'}),"license-file":u.Flags.file({exists:!0,description:"specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."})},M={"grpc-port":u.Flags.integer({description:"port for Platforma Backend gRPC API. Default is 6345",env:"PLATFORMA_GRPC_PORT"}),"grpc-listen":u.Flags.string({description:"full listen addr for Platforma Backend gRPC API. Default is 127.0.0.1:6345",env:"PLATFORMA_GRPC_LISTEN"}),"monitoring-port":u.Flags.integer({description:"port for Platforma Backend monitoring API. Default is 9090",env:"PLATFORMA_MONITORING_PORT"}),"monitoring-listen":u.Flags.string({description:"full listen addr for Platforma Backend monitoring API. Default is 127.0.0.1:9090",env:"PLATFORMA_MONITORING_LISTEN"}),"debug-port":u.Flags.integer({description:"port for Platforma Backend debug API. Default is 9091",env:"PLATFORMA_DEBUG_PORT"}),"debug-listen":u.Flags.string({description:"full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",env:"PLATFORMA_DEBUG_LISTEN"})},fr={"s3-port":u.Flags.integer({description:"port that S3 will listen, default is 9000",default:9e3,env:"PLATFORMA_S3_PORT"}),"s3-console-port":u.Flags.integer({description:"port that a console of S3 will listen, default is 9001",default:9001,env:"PLATFORMA_S3_CONSOLE_PORT"})},j={storage:u.Flags.string({description:"specify path on host to be used as storage for all Platforma Backend data"})},mr={"minio-presign-host":u.Flags.boolean({description:"use 'minio' host instead of 'localhost' in presign URLs"})},me={mount:u.Flags.string({multiple:!0,description:"things to be mounted into platforma docker container. Targets will appear inside the container under the same absolute paths"})},he={"pl-log-file":u.Flags.file({description:"specify path for Platforma Backend log file"})},ye={"pl-workdir":u.Flags.file({description:"specify working directory for Platforma Backend process"})},be={"pl-binary":u.Flags.file({description:"start given Platforma Backend binary instead of automatically downloaded version"})},we={"pl-sources":u.Flags.file({description:"path to pl repository root: build Platforma Backend from sources and start the resulting binary"})},pe={config:u.Flags.string({description:"use custom Platforma Backend config"})};u.Flags.file({description:"specify path on host to be used as 'primary' storage"});const
|
|
1
|
+
"use strict";var Pr=Object.defineProperty;var kr=(a,e,t)=>e in a?Pr(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var l=(a,e,t)=>kr(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@oclif/core"),D=require("node:os"),m=require("node:fs"),h=require("node:path"),le=require("node:child_process"),de=require("winston"),Sr=require("node:crypto"),Q=require("readline-sync"),$r=require("node:fs/promises"),Lr=require("node:stream"),x=require("zod"),Ar=require("decompress"),ge=require("@milaboratories/pl-deployments"),or=require("yaml"),Ir=require("node:https"),Or=require("tar");function ur(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const _=ur($r),Fr=ur(Or),L={"log-level":u.Flags.string({description:"logging level",default:"info",options:["error","warn","info","debug"],required:!1})};u.Flags.string({description:"name of instance",required:!1});const ue={image:u.Flags.string({description:"use custom docker image to run platforma"})},N={version:u.Flags.string({description:"use custom platforma release (official docker image or binary package)"})},fe={arch:u.Flags.string({description:"override architecture. You can start amd64 linux image on arm-based host (say, Apple M family processor). I.e. arm64, amd64, amd64/v2"})},C={license:u.Flags.string({description:'pass a license code. The license can be got from "https://licensing.milaboratories.com".'}),"license-file":u.Flags.file({exists:!0,description:"specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."})},M={"grpc-port":u.Flags.integer({description:"port for Platforma Backend gRPC API. Default is 6345",env:"PLATFORMA_GRPC_PORT"}),"grpc-listen":u.Flags.string({description:"full listen addr for Platforma Backend gRPC API. Default is 127.0.0.1:6345",env:"PLATFORMA_GRPC_LISTEN"}),"monitoring-port":u.Flags.integer({description:"port for Platforma Backend monitoring API. Default is 9090",env:"PLATFORMA_MONITORING_PORT"}),"monitoring-listen":u.Flags.string({description:"full listen addr for Platforma Backend monitoring API. Default is 127.0.0.1:9090",env:"PLATFORMA_MONITORING_LISTEN"}),"debug-port":u.Flags.integer({description:"port for Platforma Backend debug API. Default is 9091",env:"PLATFORMA_DEBUG_PORT"}),"debug-listen":u.Flags.string({description:"full listen addr for Platforma Backend debug API. Default is 127.0.0.1:9091",env:"PLATFORMA_DEBUG_LISTEN"})},fr={"s3-port":u.Flags.integer({description:"port that S3 will listen, default is 9000",default:9e3,env:"PLATFORMA_S3_PORT"}),"s3-console-port":u.Flags.integer({description:"port that a console of S3 will listen, default is 9001",default:9001,env:"PLATFORMA_S3_CONSOLE_PORT"})},j={storage:u.Flags.string({description:"specify path on host to be used as storage for all Platforma Backend data"})},mr={"minio-presign-host":u.Flags.boolean({description:"use 'minio' host instead of 'localhost' in presign URLs"})},me={mount:u.Flags.string({multiple:!0,description:"things to be mounted into platforma docker container. Targets will appear inside the container under the same absolute paths"})},he={"pl-log-file":u.Flags.file({description:"specify path for Platforma Backend log file"})},ye={"pl-workdir":u.Flags.file({description:"specify working directory for Platforma Backend process"})},be={"pl-binary":u.Flags.file({description:"start given Platforma Backend binary instead of automatically downloaded version"})},we={"pl-sources":u.Flags.file({description:"path to pl repository root: build Platforma Backend from sources and start the resulting binary"})},pe={config:u.Flags.string({description:"use custom Platforma Backend config"})};u.Flags.file({description:"specify path on host to be used as 'primary' storage"});const se={"storage-work":u.Flags.file({description:"specify path on host to be used as 'work' storage"})};u.Flags.file({description:"specify path on host to be used as 'library' storage"});const ne={"storage-primary":u.Flags.string({description:`specify 'primary' storage destination URL.
|
|
2
2
|
file:/path/to/dir for directory on local FS
|
|
3
3
|
s3://<bucket>/?region=<name> for real AWS bucket
|
|
4
4
|
s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
file:/path/to/dir for directory on local FS
|
|
7
7
|
s3://<bucket>/?region=<name> for real AWS bucket
|
|
8
8
|
s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
|
|
9
|
-
s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`})},Er={"auth-enabled":u.Flags.boolean({description:"enable authorization"})},Rr={"auth-htpasswd-file":u.Flags.file({description:"path to .htpasswd file with Platforma users (static user DB auth source)"})},Tr={"auth-ldap-server":u.Flags.string({description:"address of LDAP server to use for auth in Platforma (auth source)"})},Dr={"auth-ldap-default-dn":u.Flags.string({description:"DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com"})},B={...Er,...Rr,...Tr,...Dr};function xr(a){return Q.question(`${a} [y/N] `).toLowerCase()==="y"}function U(a){throw new Error("this should never happen")}function A(a="debug"){return de.createLogger({level:a,format:de.format.printf(({level:e,message:t})=>{const r=" ".repeat(e.length+2);if(typeof t!="string"){const i=JSON.stringify(t);throw Error(`logger message ${i} is not a string`)}const
|
|
9
|
+
s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`})},Er={"auth-enabled":u.Flags.boolean({description:"enable authorization"})},Rr={"auth-htpasswd-file":u.Flags.file({description:"path to .htpasswd file with Platforma users (static user DB auth source)"})},Tr={"auth-ldap-server":u.Flags.string({description:"address of LDAP server to use for auth in Platforma (auth source)"})},Dr={"auth-ldap-default-dn":u.Flags.string({description:"DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com"})},B={...Er,...Rr,...Tr,...Dr};function xr(a){return Q.question(`${a} [y/N] `).toLowerCase()==="y"}function U(a){throw new Error("this should never happen")}function A(a="debug"){return de.createLogger({level:a,format:de.format.printf(({level:e,message:t})=>{const r=" ".repeat(e.length+2);if(typeof t!="string"){const i=JSON.stringify(t);throw Error(`logger message ${i} is not a string`)}const s=t.split(`
|
|
10
10
|
`).map((i,c)=>c===0?i:r+i).join(`
|
|
11
|
-
`);return`${(i=>de.format.colorize().colorize(i,i))(e)}: ${
|
|
12
|
-
`);return t.length<=1?"":t[1].trim()}catch{return""}}function Mr(a){const e=le.execSync(`docker compose ls --filter name=${a} --format json`,{encoding:"utf8"}).trim(),t=JSON.parse(e);for(const r of t)if(r.Name===a)return r}const Ae=["Python"],hr=["Tengo","Python"],jr=x.z.union([x.z.literal("Tengo"),x.z.literal("Python")]),Br=x.z.object({npmOrgName:x.z.string().min(1),orgName:x.z.string().min(1,{message:"Organization name must be provided"}),blockName:x.z.string().min(1,{message:"Block name must be provided"}),softwarePlatforms:x.z.array(jr).refine(a=>new Set(a).size===a.length,{message:"Must be an array of unique software platforms"})});async function Ur(a){const{npmOrgName:e,orgName:t,blockName:r,softwarePlatforms:
|
|
11
|
+
`);return`${(i=>de.format.colorize().colorize(i,i))(e)}: ${s}`}),transports:[new de.transports.Console({stderrLevels:["error","warn","info","debug"],handleExceptions:!0})]})}function _r(a){return Sr.randomBytes(Math.ceil(a/2)).toString("hex").slice(0,a)}function Nr(a){return a.startsWith("~")?h.join(D.homedir(),a.slice(1)):a}function Pe(a,e){m.existsSync(a)||(m.mkdirSync(a,{recursive:!0}),e!=null&&e.mode&&m.chmodSync(a,e.mode))}function Cr(a){try{if(D.platform()!=="win32")return le.execSync(`ps -p ${a} -o comm=`,{encoding:"utf8"}).trim();const e=`wmic process where processid=${a} get Caption`,t=le.execSync(e,{encoding:"utf8"}).split(`
|
|
12
|
+
`);return t.length<=1?"":t[1].trim()}catch{return""}}function Mr(a){const e=le.execSync(`docker compose ls --filter name=${a} --format json`,{encoding:"utf8"}).trim(),t=JSON.parse(e);for(const r of t)if(r.Name===a)return r}const Ae=["Python"],hr=["Tengo","Python"],jr=x.z.union([x.z.literal("Tengo"),x.z.literal("Python")]),Br=x.z.object({npmOrgName:x.z.string().min(1),orgName:x.z.string().min(1,{message:"Organization name must be provided"}),blockName:x.z.string().min(1,{message:"Block name must be provided"}),softwarePlatforms:x.z.array(jr).refine(a=>new Set(a).size===a.length,{message:"Must be an array of unique software platforms"})});async function Ur(a){const{npmOrgName:e,orgName:t,blockName:r,softwarePlatforms:s}=Gr(),n=h.join(process.cwd(),r);a.info("Downloading boilerplate code..."),await qr("https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip","platforma-block-boilerplate-main",n);const i=hr.filter(o=>s.indexOf(o)<0),c=Ae.length==i.length;a.info(`Keep platforms '${s}', remove: '${i}'. Will remove all platforms? ${c}`);for(const o of i)await Jr(n,o);c&&await Hr(n),a.info("Replace everything in the template with provided options..."),Wr(n,[{from:/@platforma-open(?!.*runenv-python-3)/g,to:`@${e}`},{from:/my-org/g,to:t},{from:/block-boilerplate/g,to:r}])}function Gr(){let a=Q.question('Write an organization name for npm. Default is "platforma-open": ');a===""&&(a="platforma-open");let e="";for(;e.length<1;)e=Q.question('Write an organization name, e.g. "my-org": ');let t="";for(;t.length<1;)t=Q.question('Write a name of the block, e.g. "hello-world": ');const r=Q.keyInYN("Create package for block's software?");let s=["Tengo"];if(r)for(;s.length<hr.length;){const i=Q.keyInSelect(Ae,"Choose software platform:");if(i<0)break;s.push(Ae[i])}s=Array.from(new Set(s)).sort();const n=Br.safeParse({npmOrgName:a,orgName:e,blockName:t,softwarePlatforms:s});if(!n.success&&n.error.issues.length)throw new Error(n.error.issues.map(i=>i.message).join("; "));return n.data}async function qr(a,e,t){const s=await(await fetch(a)).blob(),n=await _.mkdtemp(h.join(D.tmpdir(),"create-repo")),i=h.join(n,"packed-repo.zip"),c=Lr.Writable.toWeb(m.createWriteStream(i));await s.stream().pipeTo(c);const o=h.join(n,"unpacked-repo");await _.mkdir(o),await Ar(i,o),await _.cp(h.join(o,e),t,{recursive:!0})}async function Jr(a,e){const t=e.toLowerCase();await X(h.join(a,"ui","src","pages","MainPage.vue"),new RegExp(`.*${t}Message.*\\n`,"g")),await X(h.join(a,"model","src","index.ts"),new RegExp(`.*${t}Message.*\\n\\n`,"g")),await X(h.join(a,"workflow","src","main.tpl.tengo"),new RegExp(`.*${t}.*exec.builder.*[\\s\\S]*?\\n\\n`,"g")),await X(h.join(a,"workflow","src","main.tpl.tengo"),new RegExp(`.*${t}Message.*\\n`,"g")),await X(h.join(a,"workflow","src","wf.test.ts"),new RegExp(`.*${t}Message.*\\n.*expect.*\\n\\n`,"g")),await _.rm(h.join(a,"software",`src_${t}`),{recursive:!0}),await je(h.join(a,"software","package.json"),r=>{const s=JSON.parse(r);return delete s["block-software"].artifacts[`hello-${t}-artifact`],delete s["block-software"].entrypoints[`hello-world-${t}`],JSON.stringify(s,null,2)})}async function Hr(a){await _.rm(h.join(a,"software"),{recursive:!0}),await je(h.join(a,"workflow","package.json"),e=>{const t=JSON.parse(e);return delete t.dependencies["@platforma-open/my-org.block-boilerplate.software"],JSON.stringify(t,null,2)}),await X(h.join(a,"pnpm-workspace.yaml"),/.*- software$\n/gm)}async function Wr(a,e){const t=await zr(a);for(const{from:r,to:s}of e)for(const n of t)await yr(n,r,s)}async function zr(a){return(await _.readdir(a,{withFileTypes:!0,recursive:!0})).filter(t=>t.isFile()).map(t=>h.join(t.parentPath,t.name))}async function je(a,e){const t=await _.readFile(a),r=e(t.toString());await _.writeFile(a,r)}async function yr(a,e,t){return await je(a,r=>r.replaceAll(e,t))}async function X(a,e){return await yr(a,e,"")}const Z=class Z extends u.Command{async run(){const{flags:e}=await this.parse(Z),t=A(e["log-level"]);await Ur(t)}};l(Z,"description","Helps to create a new block by downloading a block's template."),l(Z,"examples",["<%= name %>"]),l(Z,"flags",{...L});let Ie=Z;function br(...a){return h.resolve(__dirname,"..",...a)}function V(...a){return br("assets",...a)}function ke(...a){return m.readFileSync(br(...a))}function lr(a){return a||(a=ge.getDefaultPlVersion()),`quay.io/milaboratories/platforma:${a}`}const G=class G{constructor(e){l(this,"state",{currentInstance:""});l(this,"filePath");l(this,"dirPath");e=e??h.resolve(D.homedir(),".config","pl-bootstrap");const t=h.join(e,"state.json");this.dirPath=e,this.filePath=t,m.existsSync(e)||m.mkdirSync(e,{recursive:!0}),m.existsSync(t)&&(this.state=JSON.parse(ke(t).toString()))}static getStateInstance(){return G.instance||(G.instance=new G),G.instance}path(...e){return h.join(this.dirPath,...e)}instanceDir(e,...t){return e?this.path("data",e,...t):this.path("data")}binaries(...e){return this.path("binaries",...e)}writeState(){m.writeFileSync(this.filePath,JSON.stringify(this.state))}get instanceList(){return m.existsSync(this.instanceDir())?m.readdirSync(this.instanceDir()).filter(t=>this.instanceExists(t)):[]}instanceExists(e){return m.existsSync(this.instanceDir(e,"instance.json"))}getInstanceInfo(e){const t=this.instanceDir(e,"instance.json");if(!m.existsSync(t))throw new Error(`platforma backend instance '${e}' does not exist or is corrupted`);const r=JSON.parse(ke(t).toString());return{name:e,...r}}setInstanceInfo(e,t){m.existsSync(this.instanceDir(e))||m.mkdirSync(this.instanceDir(e),{recursive:!0});const r=this.instanceDir(e,"instance.json");let s={};m.existsSync(r)&&(s=JSON.parse(ke(r).toString())),m.writeFileSync(r,JSON.stringify({...s,...t}))}isInstanceActive(e){switch(e.type){case"docker":{const r=Mr(`pl-${e.name}`);return r?r.Status.trim().startsWith("running"):!1}case"process":return e.pid?dr(e.pid):!1;default:throw U(),new Error("cli logic error: unknown service type, cannot check its state")}}get isActive(){for(const e of this.instanceList){const t=this.getInstanceInfo(e);if(this.isInstanceActive(t))return!0}return!1}isValidPID(e){return dr(e)}get currentInstance(){const e=this.state.currentInstance;if(e&&this.instanceExists(e))return this.getInstanceInfo(e)}get currentInstanceName(){return this.state.currentInstance}set currentInstanceName(e){this.state.currentInstance=e,this.writeState()}selectInstance(e){if(!this.instanceExists(e))throw new Error(`instance '${e}' does not exist`);this.state.currentInstance=e,this.writeState()}};l(G,"instance");let Oe=G;function dr(a){const e=Cr(a);return e==="platforma"||e.endsWith("/platforma")||e.endsWith("\\platforma")}const f=Oe.getStateInstance();function Se(a,e,t){const r=[],s=[];for(const n of e){const i={cwd:n.workdir,env:{...n.envs,...t==null?void 0:t.env},...n.runOpts,...t};if(n.async){const c=Yr(a,n.cmd,n.args,i);s.push(c)}else{const c=Vr(a,n.cmd,n.args,i);if(r.push(c),c.error||c.status!==0)break}}return{executed:r,spawned:s}}function Yr(a,e,t,r){var c;a.debug(`Running:
|
|
13
13
|
cmd: ${JSON.stringify([e,...t])}
|
|
14
|
-
wd: ${(c=r.cwd)==null?void 0:c.toString()}`),r.env={...process.env,...r.env},a.debug(" spawning child process");const
|
|
14
|
+
wd: ${(c=r.cwd)==null?void 0:c.toString()}`),r.env={...process.env,...r.env},a.debug(" spawning child process");const s=le.spawn(e,t,r);let n=!1;const i=()=>{s.kill("SIGINT"),n=!0};return a.debug(" setting up signal handler"),process.on("SIGINT",i),s.on("close",o=>{process.removeListener("SIGINT",i),n&&process.exit(o)}),s}function Vr(a,e,t,r){return a.debug(`Running:
|
|
15
15
|
cmd: ${JSON.stringify([e,...t])}
|
|
16
|
-
opts: ${JSON.stringify(r)}`),r.env={...process.env,...r.env},le.spawnSync(e,t,r)}function $e(a,e,t,r,
|
|
16
|
+
opts: ${JSON.stringify(r)}`),r.env={...process.env,...r.env},le.spawnSync(e,t,r)}function $e(a,e,t,r,s){const n=m.readFileSync(a,{encoding:"utf-8"}),i=or.parse(n.toString());if(!i.services)throw new Error(`file '${a}' seems to be not a docker-compose file or has unsupported version`);if(r)for(const c of Object.keys(i.services))r.has(c)||delete i.services[c];i.name=t;for(const[c,o]of(r==null?void 0:r.entries())??[]){const g=i.services[c];if(!g)throw new Error(`docker compose '${a}' has no declaration of service '${c}'`);if(o.platform&&(g.platform=o.platform),o.envs){g.environment||(g.environment=[]);for(let d=0;d<((g==null?void 0:g.environment.length)??0);){const w=g.environment[d].split("=")[0];if(o.envs[w]){const p=g.environment.pop();p&&g.environment.length!==d&&(g.environment[d]=p)}else d++}for(const[d,y]of Object.entries(o.envs))g.environment.push(`${d}=${y}`)}if(o.mounts){g.volumes||(g.volumes=[]);for(const d of o.mounts)g.volumes.push(`${d.hostPath}:${d.containerPath}`)}}s!=null&&s.dropVolumes&&delete i.volumes,m.writeFileSync(e,or.stringify(i))}function Kr(a){return{id:a,type:"S3",indexCachePeriod:"0s",endpoint:"",region:"",bucketName:"",createBucket:!1,forcePathStyle:!1,key:"",secret:"",keyPrefix:"",accessPrefixes:[],uploadKeyPrefix:""}}function wr(a){return{id:a,type:"FS",indexCachePeriod:"0s",rootPath:""}}function K(a,e,t){a=Nr(a);const r=new URL(a,`file:${e}`);switch(r.protocol){case"s3:":{const s=r.hostname,n=r.searchParams.get("region"),i=r.pathname.slice(1);return{...t,type:"S3",bucketName:s,region:n,keyPrefix:i}}case"s3e:":{const s=r.pathname.split("/").slice(1),n=s[0],i=s.length>1?s.slice(1).join("/"):"";return{...t,type:"S3",endpoint:`http://${r.host}/`,bucketName:n,keyPrefix:i,region:r.searchParams.get("region"),key:r.username?`static:${r.username}`:"",secret:r.password?`static:${r.password}`:""}}case"s3es:":{const s=r.pathname.split("/").slice(1),n=s[0],i=s.length>1?s.slice(1).join("/"):"";return{...t,type:"S3",endpoint:`https://${r.host}/`,bucketName:n,keyPrefix:i,region:r.searchParams.get("region"),key:r.username?`static:${r.username}`:"",secret:r.password?`static:${r.password}`:""}}case"file:":return{type:"FS",rootPath:r.pathname};default:throw new Error(`storage protocol '${r.protocol}' is not supported`)}}function Qr(a,e){var p,b,P,$,S,v,k,ce,Be,Ue,Ge,qe,Je,He,We,ze,Ye,Ve,Ke,Qe,Xe,Ze,er,rr,tr,ar,sr,nr,ir,cr;const t=(e==null?void 0:e.localRoot)??f.instanceDir("default"),r={level:((p=e==null?void 0:e.log)==null?void 0:p.level)??"info",path:((b=e==null?void 0:e.log)==null?void 0:b.path)??`${t}/logs/platforma.log`},s={listen:((P=e==null?void 0:e.grpc)==null?void 0:P.listen)??"localhost:6345",tls:{enable:oe((S=($=e==null?void 0:e.grpc)==null?void 0:$.tls)==null?void 0:S.enable,!1),clientAuthMode:((k=(v=e==null?void 0:e.grpc)==null?void 0:v.tls)==null?void 0:k.clientAuthMode)??"NoAuth",certFile:((Be=(ce=e==null?void 0:e.grpc)==null?void 0:ce.tls)==null?void 0:Be.certFile)??`${t}/certs/tls.cert`,keyFile:((Ge=(Ue=e==null?void 0:e.grpc)==null?void 0:Ue.tls)==null?void 0:Ge.keyFile)??`${t}/certs/tls.key`,...(qe=e==null?void 0:e.grpc)==null?void 0:qe.tls}},n={auth:{enabled:((He=(Je=e==null?void 0:e.core)==null?void 0:Je.auth)==null?void 0:He.enabled)??!1,drivers:((ze=(We=e==null?void 0:e.core)==null?void 0:We.auth)==null?void 0:ze.drivers)??[{driver:"jwt",key:a},{driver:"htpasswd",path:`${t}/users.htpasswd`}]},db:{path:`${t}/db`}},i=gr("main",`${t}/storages/main`,"main-bucket",(Ye=e==null?void 0:e.storages)==null?void 0:Ye.primary);let c;switch((Ke=(Ve=e==null?void 0:e.storages)==null?void 0:Ve.work)==null?void 0:Ke.type){case void 0:case"FS":c=wr("work"),c.rootPath=((Xe=(Qe=e==null?void 0:e.storages)==null?void 0:Qe.work)==null?void 0:Xe.rootPath)??`${t}/storages/work`,c.indexCachePeriod=((er=(Ze=e==null?void 0:e.storages)==null?void 0:Ze.work)==null?void 0:er.indexCachePeriod)??"1m";break;default:throw new Error("work storage MUST have 'FS' type as it is used for working directories management")}const g=gr("library",`${t}/storages/library`,"library-bucket",(rr=e==null?void 0:e.storages)==null?void 0:rr.library),d={enabled:oe((tr=e==null?void 0:e.monitoring)==null?void 0:tr.enabled,!0),listen:((ar=e==null?void 0:e.monitoring)==null?void 0:ar.listen)??"127.0.0.1:9090"},y={enabled:oe((sr=e==null?void 0:e.debug)==null?void 0:sr.enabled,!0),listen:((nr=e==null?void 0:e.debug)==null?void 0:nr.listen)??"127.0.0.1:9091"},w={value:((ir=e==null?void 0:e.license)==null?void 0:ir.value)??"",file:((cr=e==null?void 0:e.license)==null?void 0:cr.file)??""};return{localRoot:t,license:w,log:r,grpc:s,core:n,monitoring:d,debug:y,storages:{primary:i,work:c,library:g},hacks:{libraryDownloadable:!0}}}function gr(a,e,t,r){let s;switch(r==null?void 0:r.type){case void 0:case"FS":s=wr(a),s.rootPath=(r==null?void 0:r.rootPath)??e;break;case"S3":s=Kr(a),s.endpoint=r==null?void 0:r.endpoint,s.region=r==null?void 0:r.region,s.presignEndpoint=(r==null?void 0:r.presignEndpoint)??(r==null?void 0:r.endpoint),s.bucketName=(r==null?void 0:r.bucketName)??t,s.createBucket=oe(r==null?void 0:r.createBucket,!0),s.forcePathStyle=oe(r==null?void 0:r.forcePathStyle,!0),s.key=(r==null?void 0:r.key)??"",s.secret=(r==null?void 0:r.secret)??"",s.keyPrefix=(r==null?void 0:r.keyPrefix)??"",s.accessPrefixes=(r==null?void 0:r.accessPrefixes)??[""],s.uploadKeyPrefix=(r==null?void 0:r.uploadKeyPrefix)??"";break;default:throw U(),new Error("unknown storage type")}return s}function Xr(a){const e=a.monitoring.enabled?"":" disabled",t=a.debug.enabled?"":" disabled",r=a.hacks.libraryDownloadable?"true":"false";let s=a.license.value;return a.license.file!=""&&(s=m.readFileSync(a.license.file).toString().trimEnd()),`
|
|
17
17
|
license:
|
|
18
18
|
value: '${a.license.value}'
|
|
19
19
|
file: '${a.license.file}'
|
|
@@ -82,26 +82,31 @@ controllers:
|
|
|
82
82
|
workdirCacheOnFailure: 1h
|
|
83
83
|
secrets:
|
|
84
84
|
- map:
|
|
85
|
-
MI_LICENSE: ${JSON.stringify(
|
|
85
|
+
MI_LICENSE: ${JSON.stringify(s)}
|
|
86
86
|
|
|
87
87
|
packageLoader:
|
|
88
88
|
packagesRoot: '${a.localRoot}/packages'
|
|
89
89
|
|
|
90
|
-
workflows:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
${r}`)}const t=Se(this.logger,e.upCommands);return Le(t.executed),t.spawned.length>0&&e.type==="process"&&(e.pid=t.spawned[t.spawned.length-1].pid,f.setInstanceInfo(e.name,e),this.logger.info(`instance '${e.name}' started`)),f.currentInstanceName=e.name,t.spawned}stopInstance(e){this.logger.info(`stopping platforma backend instance '${e.name}'...`);const t=Se(this.logger,e.downCommands);switch(Le(t.executed),e.type){case"docker":return;case"process":{e.pid&&f.isInstanceActive(e)&&process.kill(e.pid);return}default:U()}}switchInstance(e){for(const t of f.instanceList)if(t!==e.name){const r=f.getInstanceInfo(t);f.isInstanceActive(r)&&this.stopInstance(r)}return this.startInstance(e)}createLocal(e,t){var g,d,y,w,p,b,P,$,S,v;let r=nt(t==null?void 0:t.version,"binaries","platforma");t!=null&&t.sourcesPath&&(r=h.join(D.tmpdir(),"platforma-custom-build")),t!=null&&t.binaryPath&&(r=t.binaryPath);let n=t==null?void 0:t.configPath;const s=(t==null?void 0:t.workdir)??(n?process.cwd():f.instanceDir(e));t!=null&&t.primaryURL&&(t.configOptions={...t.configOptions,storages:{...(g=t.configOptions)==null?void 0:g.storages,primary:K(t.primaryURL,s,(y=(d=t.configOptions)==null?void 0:d.storages)==null?void 0:y.primary)}}),t!=null&&t.libraryURL&&(t.configOptions={...t.configOptions,storages:{...(w=t.configOptions)==null?void 0:w.storages,library:K(t.libraryURL,s,(b=(p=t.configOptions)==null?void 0:p.storages)==null?void 0:b.library)}});const i=Qr(this.getLastJwt(),t==null?void 0:t.configOptions);this.logger.debug(" checking license..."),this.checkLicense(($=(P=t==null?void 0:t.configOptions)==null?void 0:P.license)==null?void 0:$.value,(v=(S=t==null?void 0:t.configOptions)==null?void 0:S.license)==null?void 0:v.file);const c=[`${i.localRoot}/packages`,`${i.localRoot}/packages-local`,`${i.localRoot}/blocks-local`];i.storages.primary.type==="FS"&&c.push(i.storages.primary.rootPath),i.storages.library.type==="FS"&&(c.push(i.storages.library.rootPath),i.hacks.libraryDownloadable=!1),i.storages.work.type==="FS"&&c.push(i.storages.work.rootPath),this.logger.debug(" creating pl state directories...");for(const k of c)m.existsSync(k)||(this.logger.debug(` '${k}'`),m.mkdirSync(k,{recursive:!0}));for(const k of i.core.auth.drivers)k.driver==="htpasswd"&&(m.existsSync(k.path)||(this.logger.debug(` installing default 'users.htpasswd' to ${k.path}...`),m.copyFileSync(V("users.htpasswd"),k.path)));n||(n=h.join(i.localRoot,"config.yaml"),this.logger.debug(` rendering configuration '${n}'...`),m.writeFileSync(n,Xr(i)));const o=[];return t!=null&&t.sourcesPath&&o.push({cmd:"go",args:["build","-o",r,"."],workdir:h.resolve(t.sourcesPath,"cmd","platforma"),runOpts:{stdio:"inherit"}}),o.push({async:!0,cmd:r,args:["--quiet","--config",n],workdir:s,runOpts:{stdio:"inherit"}}),f.setInstanceInfo(e,{type:"process",upCommands:o,downCommands:[],cleanupCommands:[],runInfo:{configPath:n,dbPath:i.core.db.path,apiAddr:i.grpc.listen,logPath:i.log.path,primary:i.storages.primary,work:i.storages.work,library:i.storages.library}}),f.getInstanceInfo(e)}createLocalS3(e,t){var c;this.logger.debug("creating platforma instance in 'local s3' mode...");const r=(t==null?void 0:t.minioPort)??9e3,n=this.createLocal(e,{...t,primaryURL:(t==null?void 0:t.primaryURL)??`s3e://testuser:testpassword@localhost:${r}/main-bucket/?region=no-region`,libraryURL:(t==null?void 0:t.libraryURL)??`s3e://testuser:testpassword@localhost:${r}/library-bucket/?region=no-region`}),s=(c=t==null?void 0:t.configOptions)==null?void 0:c.localRoot,i=this.createMinio(e,{minioPort:r,minioConsolePort:t==null?void 0:t.minioConsolePort,storage:s?h.join(s,"minio"):void 0});return n.upCommands=[i.start,...n.upCommands],n.downCommands=[i.stop,...n.downCommands],n.cleanupCommands=[i.cleanup,...n.cleanupCommands],f.setInstanceInfo(e,n),n}createMinio(e,t){this.logger.debug(" creating docker compose for minio service...");const r=V("compose-backend.yaml"),n=f.instanceDir(e,"compose-minio.yaml");$e(r,n,`pl-${e}-minio`,new Map([["minio",{}]]),{dropVolumes:!0});const s=t!=null&&t.version?`:${t.version}`:"";this.logger.debug(` minio version: ${s}`);const i=(t==null?void 0:t.image)??`quay.io/minio/minio${s}`;this.logger.debug(` minio image: ${i}`);const c=(t==null?void 0:t.storage)??f.instanceDir(e,"minio");Pe(c,{mode:"0775"});const o=(t==null?void 0:t.minioPort)??9e3,g=(t==null?void 0:t.minioConsolePort)??9001,d={MINIO_IMAGE:i,MINIO_STORAGE:h.resolve(c),MINIO_PORT:o.toString(),MINIO_CONSOLE_PORT:g.toString()};return{start:{cmd:"docker",args:["compose",`--file=${n}`,"up","--detach","--remove-orphans","--pull=missing"],envs:d,workdir:f.instanceDir(e),runOpts:{stdio:"inherit"}},stop:{cmd:"docker",args:["compose",`--file=${n}`,"down"],envs:d,workdir:f.instanceDir(e),runOpts:{stdio:"inherit"}},cleanup:{cmd:"docker",args:["compose",`--file=${n}`,"down","--volumes","--remove-orphans"],envs:d,workdir:f.instanceDir(e),runOpts:{stdio:"inherit"}}}}createDockerS3(e,t,r){this.logger.debug("creating platforma instance in 'docker s3' mode...");const n=V("compose-backend.yaml"),s=(r==null?void 0:r.image)??lr(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...v)=>h.join(t,...v),c=v=>{const k=i(v);return Pe(k,{mode:"0775"}),k},o=i("logs","platforma.log");m.existsSync(o)||(m.mkdirSync(h.dirname(o),{recursive:!0}),m.writeFileSync(o,""));const g=(r==null?void 0:r.presignHost)??"localhost",d=K("s3e://testuser:testpassword@minio:9000/main-bucket");if(d.type!=="S3")throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");d.presignEndpoint=`http://${g}:9000`;const y=K("s3e://testuser:testpassword@minio:9000/library-bucket");if(y.type!=="S3")throw new Error(`${y.type} storage type is not supported for library storage`);y.presignEndpoint=`http://${g}:9000`;const w=c("db"),p=c("work"),b=i("users.htpasswd");m.existsSync(b)||m.copyFileSync(V("users.htpasswd"),b);const P=i("compose.yaml");m.existsSync(P)&&this.logger.info(`replacing docker compose file ${P}`);const $=[];for(const v of(r==null?void 0:r.customMounts)??[])$.push({hostPath:v.hostPath,containerPath:v.containerPath??v.hostPath});$e(n,P,`pl-${e}`,new Map([["minio",{}],["backend",{platform:r==null?void 0:r.platformOverride,mounts:$}]]));const S={MINIO_IMAGE:"quay.io/minio/minio",MINIO_STORAGE:c("minio"),PL_IMAGE:s,PL_AUTH_HTPASSWD_PATH:b,PL_LICENSE:r==null?void 0:r.license,PL_LICENSE_FILE:r==null?void 0:r.licenseFile,PL_LOG_LEVEL:(r==null?void 0:r.logLevel)??"info",PL_LOG_DIR:h.dirname(o),PL_LOG_ROTATION_ENABLED:"true",PL_RUNNER_WD_CACHE_ON_FAILURE:"1h",PL_DATA_DB_ROOT:w,PL_DATA_PRIMARY_ROOT:c("primary"),PL_DATA_LIBRARY_ROOT:c("library"),PL_DATA_WORKDIR_ROOT:p,...this.configureDockerStorage("primary",d),...this.configureDockerStorage("library",y)};if(r!=null&&r.grpcAddr&&(S.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(S.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(S.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(S.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(S.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(S.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(S.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const v of r.auth.drivers)v.driver==="htpasswd"&&(S.PL_AUTH_HTPASSWD_PATH=h.resolve(v.path),v.path="/etc/platforma/users.htpasswd");S.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return f.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${P}`,"up","--detach","--remove-orphans","--pull=missing"],envs:S,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${P}`,"down"],envs:S,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${P}`,"down","--volumes","--remove-orphans"],envs:S,runOpts:{stdio:"inherit"}}],runInfo:{apiPort:r==null?void 0:r.grpcPort,apiAddr:r==null?void 0:r.grpcAddr,logPath:o,primary:d,work:{type:"FS",rootPath:p},library:y,dbPath:w}}),f.getInstanceInfo(e)}createDocker(e,t,r){this.logger.debug("creating platforma instance in 'docker' mode...");const n=V("compose-backend.yaml"),s=(r==null?void 0:r.image)??lr(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...k)=>h.join(t,...k),c=k=>{const ce=i(k);return Pe(ce,{mode:"0775"}),ce},o=i("logs","platforma.log");m.existsSync(o)||(m.mkdirSync(h.dirname(o),{recursive:!0}),m.writeFileSync(o,""));const g=c("db"),d=c("primary"),y=c("library"),w=c("work"),p=i("users.htpasswd");m.existsSync(p)||m.copyFileSync(V("users.htpasswd"),p);const b=i("compose.yaml");m.existsSync(b)&&this.logger.info(`replacing docker compose file ${b}`);const P=[];for(const k of(r==null?void 0:r.customMounts)??[])P.push({hostPath:k.hostPath,containerPath:k.containerPath??k.hostPath});this.logger.debug(`Rendering docker compose file '${b}' using '${n}' as base template`),$e(n,b,`pl-${e}`,new Map([["backend",{platform:r==null?void 0:r.platformOverride,mounts:P}]]));const $=K((r==null?void 0:r.primaryStorageURL)??`file:${d}`,"."),S=K((r==null?void 0:r.libraryStorageURL)??`file:${y}`,"."),v={PL_IMAGE:s,PL_AUTH_HTPASSWD_PATH:p,PL_LICENSE:r==null?void 0:r.license,PL_LICENSE_FILE:r==null?void 0:r.licenseFile,PL_LOG_LEVEL:"info",PL_LOG_DIR:h.dirname(o),PL_LOG_ROTATION_ENABLED:"true",PL_RUNNER_WD_CACHE_ON_FAILURE:"1h",PL_DATA_DB_ROOT:g,PL_DATA_PRIMARY_ROOT:d,PL_DATA_LIBRARY_ROOT:y,PL_DATA_WORKDIR_ROOT:w,PL_DATA_PACKAGE_ROOT:c("packages"),...this.configureDockerStorage("primary",$),...this.configureDockerStorage("library",S)};if(r!=null&&r.grpcAddr&&(v.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(v.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(v.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(v.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(v.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(v.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(v.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const k of r.auth.drivers)k.driver==="htpasswd"&&(v.PL_AUTH_HTPASSWD_PATH=h.resolve(k.path),k.path="/etc/platforma/users.htpasswd");v.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return f.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"up","--detach","--remove-orphans","--pull=missing"],envs:v,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down"],envs:v,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down","--volumes","--remove-orphans"],envs:v,runOpts:{stdio:"inherit"}}],runInfo:{apiPort:r==null?void 0:r.grpcPort,apiAddr:r==null?void 0:r.grpcAddr,logPath:o,primary:$,work:{type:"FS",rootPath:w},library:S,dbPath:g}}),f.getInstanceInfo(e)}cleanupInstance(e){const t=[],r=new Map;let n="";if(e){const s=f.getInstanceInfo(e);switch(r.set(e,s),s.type){case"docker":{t.push(`docker service 'pl-${e}', including all its volumes and data in '${f.instanceDir(e)}' will be destroyed`);break}case"process":{t.push(`directory '${f.instanceDir(e)}' would be deleted`),s.downCommands&&t.push("associated docker service, including all volumes and data will be destroyed");break}default:U()}e===f.currentInstanceName&&t.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)"),n=`
|
|
90
|
+
workflows:
|
|
91
|
+
features:
|
|
92
|
+
pureFutureFields: true
|
|
93
|
+
commandExpressions: true
|
|
94
|
+
workdirLimits: true
|
|
95
|
+
computeLimits: true
|
|
96
|
+
`}function oe(a,e){return a===void 0?e:a}const Zr=["linux","macos","windows"];function et(a){const e=D.platform();switch(e){case"darwin":return"macos";case"linux":return"linux";case"win32":return"windows";default:throw new Error(`operating system '${e}' is not currently supported by Platforma ecosystem. The list of OSes supported: `+JSON.stringify(Zr))}}const rt=["amd64","arm64"];function pr(a){const e=D.arch();switch(e){case"arm64":return"arm64";case"x64":return"amd64";default:throw new Error(`processor architecture '${e}' is not currently supported by Platforma ecosystem. The list of architectures supported: `+JSON.stringify(rt))}}function tt(a,e){const t=(e==null?void 0:e.version)??ge.getDefaultPlVersion(),r=(e==null?void 0:e.showProgress)??process.stdout.isTTY,s=`pl-${t}-${pr()}.tgz`,n=(e==null?void 0:e.downloadURL)??`https://cdn.platforma.bio/software/pl/${et()}/${s}`,i=(e==null?void 0:e.saveTo)??f.binaries(s);if(m.existsSync(i))return a.info(`Platforma Backend archive download skipped: '${i}' already exists`),Promise.resolve(i);m.mkdirSync(h.dirname(i),{recursive:!0}),a.info(`Downloading Platforma Backend archive:
|
|
97
|
+
URL: ${n}
|
|
98
|
+
Save to: ${i}`);const c=Ir.get(n);return new Promise((o,g)=>{c.on("response",d=>{if(!d.statusCode){const b=new Error("failed to download archive: no HTTP status code in response from server");c.destroy(),g(b);return}if(d.statusCode!==200){const b=new Error(`failed to download archive: ${d.statusCode} ${d.statusMessage}`);c.destroy(),g(b);return}const y=parseInt(d.headers["content-length"]||"0",10);let w=0;const p=m.createWriteStream(i);d.pipe(p),d.on("data",b=>{w+=b.length;const P=w/y*100;r&&process.stdout.write(` downloading: ${P.toFixed(2)}%\r`)}),d.on("error",b=>{m.unlinkSync(i),a.error(`Failed to download Platforma Binary: ${b.message}`),c.destroy(),g(b)}),p.on("finish",()=>{p.close(),a.info(" ... download done."),c.destroy(),o(i)})})})}function at(a,e){a.debug("extracting archive...");const t=(e==null?void 0:e.version)??ge.getDefaultPlVersion();a.debug(` version: '${t}'`);const r=`${vr({version:t})}.tgz`,s=(e==null?void 0:e.archivePath)??f.binaries(r);a.debug(` archive path: '${s}'`);const n=(e==null?void 0:e.extractTo)??nt(s);if(a.debug(` target dir: '${n}'`),m.existsSync(n))return a.info(`Platforma Backend binaries unpack skipped: '${n}' exists`),n;if(!m.existsSync(s)){const i=`Platforma Backend binary archive not found at '${s}'`;throw a.error(i),new Error(i)}return m.existsSync(n)||(a.debug(` creating target dir '${n}'`),m.mkdirSync(n,{recursive:!0})),a.info(`Unpacking Platforma Backend archive:
|
|
99
|
+
Archive: ${s}
|
|
100
|
+
Target dir: ${n}`),Fr.x({file:s,cwd:n,gzip:!0,sync:!0}),a.info(" ... unpack done."),n}function ve(a,e){return tt(a,e).then(t=>at(a,{archivePath:t}))}function vr(a){return`pl-${(a==null?void 0:a.version)??ge.getDefaultPlVersion()}-${pr()}`}function st(a,...e){return f.binaries(vr({version:a}),...e)}function nt(a){const e=a.lastIndexOf(".");return e===-1?a:a.slice(0,e)}class I{constructor(e){this.logger=e}startLast(){const e=f.currentInstance;if(!e)throw this.logger.error("failed to bring back Platforma Backend in the last started configuration: no last configuration found"),new Error("no previous run info found");return this.startInstance(e)}startInstance(e){if(e.runInfo){const r=this.renderRunInfo(e.runInfo);this.logger.info(`Starting platforma backend instance '${e.name}':
|
|
101
|
+
${r}`)}const t=Se(this.logger,e.upCommands);return Le(t.executed),t.spawned.length>0&&e.type==="process"&&(e.pid=t.spawned[t.spawned.length-1].pid,f.setInstanceInfo(e.name,e),this.logger.info(`instance '${e.name}' started`)),f.currentInstanceName=e.name,t.spawned}stopInstance(e){this.logger.info(`stopping platforma backend instance '${e.name}'...`);const t=Se(this.logger,e.downCommands);switch(Le(t.executed),e.type){case"docker":return;case"process":{e.pid&&f.isInstanceActive(e)&&process.kill(e.pid);return}default:U()}}switchInstance(e){for(const t of f.instanceList)if(t!==e.name){const r=f.getInstanceInfo(t);f.isInstanceActive(r)&&this.stopInstance(r)}return this.startInstance(e)}createLocal(e,t){var g,d,y,w,p,b,P,$,S,v;let r=st(t==null?void 0:t.version,"binaries","platforma");t!=null&&t.sourcesPath&&(r=h.join(D.tmpdir(),"platforma-custom-build")),t!=null&&t.binaryPath&&(r=t.binaryPath);let s=t==null?void 0:t.configPath;const n=(t==null?void 0:t.workdir)??(s?process.cwd():f.instanceDir(e));t!=null&&t.primaryURL&&(t.configOptions={...t.configOptions,storages:{...(g=t.configOptions)==null?void 0:g.storages,primary:K(t.primaryURL,n,(y=(d=t.configOptions)==null?void 0:d.storages)==null?void 0:y.primary)}}),t!=null&&t.libraryURL&&(t.configOptions={...t.configOptions,storages:{...(w=t.configOptions)==null?void 0:w.storages,library:K(t.libraryURL,n,(b=(p=t.configOptions)==null?void 0:p.storages)==null?void 0:b.library)}});const i=Qr(this.getLastJwt(),t==null?void 0:t.configOptions);this.logger.debug(" checking license..."),this.checkLicense(($=(P=t==null?void 0:t.configOptions)==null?void 0:P.license)==null?void 0:$.value,(v=(S=t==null?void 0:t.configOptions)==null?void 0:S.license)==null?void 0:v.file);const c=[`${i.localRoot}/packages`,`${i.localRoot}/packages-local`,`${i.localRoot}/blocks-local`];i.storages.primary.type==="FS"&&c.push(i.storages.primary.rootPath),i.storages.library.type==="FS"&&(c.push(i.storages.library.rootPath),i.hacks.libraryDownloadable=!1),i.storages.work.type==="FS"&&c.push(i.storages.work.rootPath),this.logger.debug(" creating pl state directories...");for(const k of c)m.existsSync(k)||(this.logger.debug(` '${k}'`),m.mkdirSync(k,{recursive:!0}));for(const k of i.core.auth.drivers)k.driver==="htpasswd"&&(m.existsSync(k.path)||(this.logger.debug(` installing default 'users.htpasswd' to ${k.path}...`),m.copyFileSync(V("users.htpasswd"),k.path)));s||(s=h.join(i.localRoot,"config.yaml"),this.logger.debug(` rendering configuration '${s}'...`),m.writeFileSync(s,Xr(i)));const o=[];return t!=null&&t.sourcesPath&&o.push({cmd:"go",args:["build","-o",r,"."],workdir:h.resolve(t.sourcesPath,"cmd","platforma"),runOpts:{stdio:"inherit"}}),o.push({async:!0,cmd:r,args:["--quiet","--config",s],workdir:n,runOpts:{stdio:"inherit"}}),f.setInstanceInfo(e,{type:"process",upCommands:o,downCommands:[],cleanupCommands:[],runInfo:{configPath:s,dbPath:i.core.db.path,apiAddr:i.grpc.listen,logPath:i.log.path,primary:i.storages.primary,work:i.storages.work,library:i.storages.library}}),f.getInstanceInfo(e)}createLocalS3(e,t){var c;this.logger.debug("creating platforma instance in 'local s3' mode...");const r=(t==null?void 0:t.minioPort)??9e3,s=this.createLocal(e,{...t,primaryURL:(t==null?void 0:t.primaryURL)??`s3e://testuser:testpassword@localhost:${r}/main-bucket/?region=no-region`,libraryURL:(t==null?void 0:t.libraryURL)??`s3e://testuser:testpassword@localhost:${r}/library-bucket/?region=no-region`}),n=(c=t==null?void 0:t.configOptions)==null?void 0:c.localRoot,i=this.createMinio(e,{minioPort:r,minioConsolePort:t==null?void 0:t.minioConsolePort,storage:n?h.join(n,"minio"):void 0});return s.upCommands=[i.start,...s.upCommands],s.downCommands=[i.stop,...s.downCommands],s.cleanupCommands=[i.cleanup,...s.cleanupCommands],f.setInstanceInfo(e,s),s}createMinio(e,t){this.logger.debug(" creating docker compose for minio service...");const r=V("compose-backend.yaml"),s=f.instanceDir(e,"compose-minio.yaml");$e(r,s,`pl-${e}-minio`,new Map([["minio",{}]]),{dropVolumes:!0});const n=t!=null&&t.version?`:${t.version}`:"";this.logger.debug(` minio version: ${n}`);const i=(t==null?void 0:t.image)??`quay.io/minio/minio${n}`;this.logger.debug(` minio image: ${i}`);const c=(t==null?void 0:t.storage)??f.instanceDir(e,"minio");Pe(c,{mode:"0775"});const o=(t==null?void 0:t.minioPort)??9e3,g=(t==null?void 0:t.minioConsolePort)??9001,d={MINIO_IMAGE:i,MINIO_STORAGE:h.resolve(c),MINIO_PORT:o.toString(),MINIO_CONSOLE_PORT:g.toString()};return{start:{cmd:"docker",args:["compose",`--file=${s}`,"up","--detach","--remove-orphans","--pull=missing"],envs:d,workdir:f.instanceDir(e),runOpts:{stdio:"inherit"}},stop:{cmd:"docker",args:["compose",`--file=${s}`,"down"],envs:d,workdir:f.instanceDir(e),runOpts:{stdio:"inherit"}},cleanup:{cmd:"docker",args:["compose",`--file=${s}`,"down","--volumes","--remove-orphans"],envs:d,workdir:f.instanceDir(e),runOpts:{stdio:"inherit"}}}}createDockerS3(e,t,r){this.logger.debug("creating platforma instance in 'docker s3' mode...");const s=V("compose-backend.yaml"),n=(r==null?void 0:r.image)??lr(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...v)=>h.join(t,...v),c=v=>{const k=i(v);return Pe(k,{mode:"0775"}),k},o=i("logs","platforma.log");m.existsSync(o)||(m.mkdirSync(h.dirname(o),{recursive:!0}),m.writeFileSync(o,""));const g=(r==null?void 0:r.presignHost)??"localhost",d=K("s3e://testuser:testpassword@minio:9000/main-bucket");if(d.type!=="S3")throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");d.presignEndpoint=`http://${g}:9000`;const y=K("s3e://testuser:testpassword@minio:9000/library-bucket");if(y.type!=="S3")throw new Error(`${y.type} storage type is not supported for library storage`);y.presignEndpoint=`http://${g}:9000`;const w=c("db"),p=c("work"),b=i("users.htpasswd");m.existsSync(b)||m.copyFileSync(V("users.htpasswd"),b);const P=i("compose.yaml");m.existsSync(P)&&this.logger.info(`replacing docker compose file ${P}`);const $=[];for(const v of(r==null?void 0:r.customMounts)??[])$.push({hostPath:v.hostPath,containerPath:v.containerPath??v.hostPath});$e(s,P,`pl-${e}`,new Map([["minio",{}],["backend",{platform:r==null?void 0:r.platformOverride,mounts:$}]]));const S={MINIO_IMAGE:"quay.io/minio/minio",MINIO_STORAGE:c("minio"),PL_IMAGE:n,PL_AUTH_HTPASSWD_PATH:b,PL_LICENSE:r==null?void 0:r.license,PL_LICENSE_FILE:r==null?void 0:r.licenseFile,PL_LOG_LEVEL:(r==null?void 0:r.logLevel)??"info",PL_LOG_DIR:h.dirname(o),PL_LOG_ROTATION_ENABLED:"true",PL_RUNNER_WD_CACHE_ON_FAILURE:"1h",PL_DATA_DB_ROOT:w,PL_DATA_PRIMARY_ROOT:c("primary"),PL_DATA_LIBRARY_ROOT:c("library"),PL_DATA_WORKDIR_ROOT:p,...this.configureDockerStorage("primary",d),...this.configureDockerStorage("library",y)};if(r!=null&&r.grpcAddr&&(S.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(S.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(S.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(S.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(S.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(S.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(S.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const v of r.auth.drivers)v.driver==="htpasswd"&&(S.PL_AUTH_HTPASSWD_PATH=h.resolve(v.path),v.path="/etc/platforma/users.htpasswd");S.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return f.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${P}`,"up","--detach","--remove-orphans","--pull=missing"],envs:S,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${P}`,"down"],envs:S,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${P}`,"down","--volumes","--remove-orphans"],envs:S,runOpts:{stdio:"inherit"}}],runInfo:{apiPort:r==null?void 0:r.grpcPort,apiAddr:r==null?void 0:r.grpcAddr,logPath:o,primary:d,work:{type:"FS",rootPath:p},library:y,dbPath:w}}),f.getInstanceInfo(e)}createDocker(e,t,r){this.logger.debug("creating platforma instance in 'docker' mode...");const s=V("compose-backend.yaml"),n=(r==null?void 0:r.image)??lr(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...k)=>h.join(t,...k),c=k=>{const ce=i(k);return Pe(ce,{mode:"0775"}),ce},o=i("logs","platforma.log");m.existsSync(o)||(m.mkdirSync(h.dirname(o),{recursive:!0}),m.writeFileSync(o,""));const g=c("db"),d=c("primary"),y=c("library"),w=c("work"),p=i("users.htpasswd");m.existsSync(p)||m.copyFileSync(V("users.htpasswd"),p);const b=i("compose.yaml");m.existsSync(b)&&this.logger.info(`replacing docker compose file ${b}`);const P=[];for(const k of(r==null?void 0:r.customMounts)??[])P.push({hostPath:k.hostPath,containerPath:k.containerPath??k.hostPath});this.logger.debug(`Rendering docker compose file '${b}' using '${s}' as base template`),$e(s,b,`pl-${e}`,new Map([["backend",{platform:r==null?void 0:r.platformOverride,mounts:P}]]));const $=K((r==null?void 0:r.primaryStorageURL)??`file:${d}`,"."),S=K((r==null?void 0:r.libraryStorageURL)??`file:${y}`,"."),v={PL_IMAGE:n,PL_AUTH_HTPASSWD_PATH:p,PL_LICENSE:r==null?void 0:r.license,PL_LICENSE_FILE:r==null?void 0:r.licenseFile,PL_LOG_LEVEL:"info",PL_LOG_DIR:h.dirname(o),PL_LOG_ROTATION_ENABLED:"true",PL_RUNNER_WD_CACHE_ON_FAILURE:"1h",PL_DATA_DB_ROOT:g,PL_DATA_PRIMARY_ROOT:d,PL_DATA_LIBRARY_ROOT:y,PL_DATA_WORKDIR_ROOT:w,PL_DATA_PACKAGE_ROOT:c("packages"),...this.configureDockerStorage("primary",$),...this.configureDockerStorage("library",S)};if(r!=null&&r.grpcAddr&&(v.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(v.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(v.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(v.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(v.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(v.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(v.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const k of r.auth.drivers)k.driver==="htpasswd"&&(v.PL_AUTH_HTPASSWD_PATH=h.resolve(k.path),k.path="/etc/platforma/users.htpasswd");v.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return f.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"up","--detach","--remove-orphans","--pull=missing"],envs:v,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down"],envs:v,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down","--volumes","--remove-orphans"],envs:v,runOpts:{stdio:"inherit"}}],runInfo:{apiPort:r==null?void 0:r.grpcPort,apiAddr:r==null?void 0:r.grpcAddr,logPath:o,primary:$,work:{type:"FS",rootPath:w},library:S,dbPath:g}}),f.getInstanceInfo(e)}cleanupInstance(e){const t=[],r=new Map;let s="";if(e){const n=f.getInstanceInfo(e);switch(r.set(e,n),n.type){case"docker":{t.push(`docker service 'pl-${e}', including all its volumes and data in '${f.instanceDir(e)}' will be destroyed`);break}case"process":{t.push(`directory '${f.instanceDir(e)}' would be deleted`),n.downCommands&&t.push("associated docker service, including all volumes and data will be destroyed");break}default:U()}e===f.currentInstanceName&&t.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)"),s=`
|
|
97
102
|
You are going to reset the state of platforma service '${e}':
|
|
98
103
|
- ${t.join(`
|
|
99
104
|
- `)}
|
|
100
|
-
`}else{for(const
|
|
105
|
+
`}else{for(const n of f.instanceList)r.set(n,f.getInstanceInfo(n));t.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)",`all service configurations stored in: ${f.instanceDir()} (including all associated docker containers and volumes)`),s=`
|
|
101
106
|
You are going to reset the state of all platforma services configured with pl-bootstrap package.
|
|
102
107
|
- ${t.join(`
|
|
103
108
|
- `)}
|
|
104
|
-
`}if(this.logger.warn(
|
|
109
|
+
`}if(this.logger.warn(s),!xr("Are you sure?")){this.logger.info("Reset action was canceled");return}for(const[n,i]of r.entries()){if(i.cleanupCommands.length){this.logger.info(`Wiping instance ${n} services`);const c=Se(this.logger,i.cleanupCommands);Le(c.executed,`failed to wipe instance ${n} services`)}this.logger.info(`Destroying instance '${n}' data directory`),m.rmSync(f.instanceDir(n),{recursive:!0,force:!0})}e||(this.logger.info(`Destroying state dir '${f.path()}'`),m.rmSync(f.path(),{recursive:!0,force:!0})),this.logger.info(`
|
|
105
110
|
If you want to remove all downloaded platforma binaries, delete '${f.binaries()}' dir manually
|
|
106
111
|
`)}mergeLicenseEnvs(e){e.license===void 0&&((process.env.MI_LICENSE??"")!=""?e.license=process.env.MI_LICENSE:(process.env.PL_LICENSE??"")!=""&&(e.license=process.env.PL_LICENSE)),e["license-file"]===void 0&&e.license===void 0&&((process.env.MI_LICENSE_FILE??"")!=""?e["license-file"]=process.env.MI_LICENSE_FILE:(process.env.PL_LICENSE_FILE??"")!=""?e["license-file"]=process.env.PL_LICENSE_FILE:m.existsSync(h.resolve(D.homedir(),".pl.license"))&&(e["license-file"]=h.resolve(D.homedir(),".pl.license")))}initAuthDriversList(e,t){const r=[];if(e["auth-htpasswd-file"]&&r.push({driver:"htpasswd",path:h.resolve(t,e["auth-htpasswd-file"])}),!!e["auth-ldap-server"]!=!!e["auth-ldap-default-dn"])throw new Error("LDAP auth settings require both 'server' and 'default DN' options to be set");if(e["auth-ldap-server"]&&r.push({driver:"ldap",serverUrl:e["auth-ldap-server"],defaultDN:e["auth-ldap-default-dn"]}),r.length!==0)return[{driver:"jwt",key:this.getLastJwt()},...r]}getLastJwt(){const e=f.path("auth.jwt"),t="utf-8";let r="";return m.existsSync(e)&&(r=m.readFileSync(e,{encoding:t})),r==""&&(r=_r(64),m.writeFileSync(e,r,{encoding:t})),r}checkLicense(e,t){if(!(e!==void 0&&e!="")&&!(t!==void 0&&t!=""))throw this.logger.error(`A license for Platforma Backend must be set.
|
|
107
112
|
|
|
@@ -113,6 +118,6 @@ Alternatively, you can set it via the environment variables 'MI_LICENSE' or 'PL_
|
|
|
113
118
|
The license file can also be set with the variables 'MI_LICENSE_FILE' or 'PL_LICENSE_FILE',
|
|
114
119
|
or stored in '$HOME/.pl.license'.
|
|
115
120
|
|
|
116
|
-
You can obtain the license from "https://licensing.milaboratories.com".`),new Error("The license was not provided.")}configureDockerStorage(e,t){const r={},
|
|
117
|
-
`)}}function Le(a,e){for(const t of a){if(t.error)throw t.error;const r=e??"failed to run command";if(t.status!==0)throw new Error(`${r}, process exited with code '${t.status}'`)}}const ee=class ee extends u.Command{async run(){const{flags:e}=await this.parse(ee),t=A(e["log-level"]);new I(t).cleanupInstance()}};l(ee,"description","Clear service state (forget last run command, destroy docker services, volumes and so on)"),l(ee,"examples",["<%= config.bin %> <%= command.id %>"]),l(ee,"flags",{...L});let Fe=ee;const re=class re extends u.Command{async run(){const{flags:e}=await this.parse(re),t=A(e["log-level"]);new I(t).startLast()}};l(re,"description","Start last run service configuraiton"),l(re,"examples",["<%= config.bin %> <%= command.id %>"]),l(re,"flags",{...L});let Ee=re;const te=class te extends u.Command{async run(){const{flags:e}=await this.parse(te),t=A(e["log-level"]),r=new I(t);f.currentInstance?r.stopInstance(f.currentInstance):t.warn("up/start command was not called for any instance, nothing to stop")}};l(te,"description","Stop platforma service"),l(te,"examples",["<%= config.bin %> <%= command.id %>"]),l(te,"flags",{...L});let Re=te;var F;let it=(F=class extends u.Command{async run(){const{flags:e}=await this.parse(F),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const n="docker",s=e["auth-enabled"],i=s?{enabled:s,drivers:r.initAuthDriversList(e,".")}:void 0,c=e.storage?h.join(".",e.storage):f.instanceDir(n),o=[];for(const y of e.mount??[])o.push({hostPath:y});const g=e.arch?`linux/${e.arch}`:void 0,d=r.createDocker(n,c,{primaryStorageURL:e["storage-primary"],workStoragePath:e["storage-work"],libraryStorageURL:e["storage-library"],image:e.image,version:e.version,platformOverride:g,customMounts:o,license:e.license,licenseFile:e["license-file"],auth:i,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"]});r.switchInstance(d)}},l(F,"description","Run platforma backend service with 'FS' primary storage type"),l(F,"examples",["<%= config.bin %> <%= command.id %>"]),l(F,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...se,...ne,...ie}),F);var E;let ct=(E=class extends u.Command{async run(){const{flags:e}=await this.parse(E),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const n="local",s=e["pl-workdir"]??".",i=e.storage?h.join(s,e.storage):f.instanceDir(n),c=e["pl-log-file"]?h.join(s,e["pl-log-file"]):void 0,o=r.initAuthDriversList(e,s),g=e["auth-enabled"]??o!==void 0;let d="127.0.0.1:6345";e["grpc-listen"]?d=e["grpc-listen"]:e["grpc-port"]&&(d=`127.0.0.1:${e["grpc-port"]}`);let y="127.0.0.1:9090";e["monitoring-listen"]?y=e["monitoring-listen"]:e["monitoring-port"]&&(y=`127.0.0.1:${e["monitoring-port"]}`);let w="127.0.0.1:9091";e["debug-listen"]?w=e["debug-listen"]:e["debug-port"]&&(w=`127.0.0.1:${e["debug-port"]}`);const p={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],configOptions:{grpc:{listen:d},monitoring:{listen:y},debug:{listen:w},license:{value:e.license,file:e["license-file"]},log:{path:c},localRoot:i,core:{auth:{enabled:g,drivers:o}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}},b=r.createLocal(n,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):ve(t,{version:e.version}).then(()=>{const P=r.switchInstance(b);setTimeout(()=>{for(const $ of P)$.unref()},1e3)}).catch(function(P){t.error(P.message)})}},l(E,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(E,"examples",["<%= config.bin %> <%= command.id %>"]),l(E,"flags",{...L,...N,...M,...be,...we,...pe,...C,...j,...se,...ne,...ie,...he,...ye,...B}),E);const q=class q extends u.Command{async run(){const{flags:e,args:t}=await this.parse(q),r=A(e["log-level"]),n=new I(r),s=t.name;e.all&&(n.cleanupInstance(),process.exit(0)),s||(r.error("Please, specify name of instance to be removed or set '--all' flag instead"),process.exit(1)),n.cleanupInstance(s)}};l(q,"description","List available instances"),l(q,"examples",["<%= config.bin %> <%= command.id %>"]),l(q,"flags",{...L,all:u.Flags.boolean({description:"remove all known instances",required:!1})}),l(q,"args",{name:u.Args.string({required:!1})});let Te=q;const J=class J extends u.Command{async run(){const{flags:e,args:t}=await this.parse(J),r=A(e["log-level"]),n=new I(r),s=t.name??f.currentInstanceName;s||(r.info("no pl service instance selected. No service was stopped"),process.exit(0)),n.stopInstance(f.getInstanceInfo(s))}};l(J,"description","List available instances"),l(J,"examples",["<%= config.bin %> <%= command.id %>"]),l(J,"flags",{...L}),l(J,"args",{name:u.Args.string({required:!1})});let De=J;const ae=class ae extends u.Command{async run(){await this.parse(ae);const e=f.instanceList,t=f.currentInstanceName;for(const r of e){const n=[],s=f.getInstanceInfo(r);f.isInstanceActive(s)&&n.push("status:up"),n.push(`type:${s.type}`),console.log(r===t?` * ${r} (${n.join(", ")})`:` ${r} (${n.join(", ")})`)}}};l(ae,"description","List available instances"),l(ae,"examples",["<%= config.bin %> <%= command.id %>"]),l(ae,"flags",{});let xe=ae;const H=class H extends u.Command{async run(){const{flags:e,args:t}=await this.parse(H),r=A(e["log-level"]),n=new I(r),s=t.name??f.currentInstanceName;s||(r.error("no pl service instance is selected. Select instance with 'select' command or provide name to 'up'"),process.exit(1));const i=n.switchInstance(f.getInstanceInfo(s)),c=[];for(const o of i)c.push(new Promise((g,d)=>{o.on("close",g),o.on("error",d)}));await Promise.all(c)}};l(H,"description","List available instances"),l(H,"examples",["<%= config.bin %> <%= command.id %>"]),l(H,"flags",{...L}),l(H,"args",{name:u.Args.string({required:!1})});let _e=H;var R;let ot=(R=class extends u.Command{async run(){const{flags:e}=await this.parse(R),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const n="docker-s3",s=e["auth-enabled"],i=s?{enabled:s,drivers:r.initAuthDriversList(e,".")}:void 0,c=e.storage?h.join(".",e.storage):f.instanceDir(n),o=[];for(const w of e.mount??[])o.push({hostPath:w});const g=e.arch?`linux/${e.arch}`:void 0,d=e["minio-presign-host"]?"minio":"localhost",y=r.createDockerS3(n,c,{image:e.image,version:e.version,license:e.license,licenseFile:e["license-file"],platformOverride:g,customMounts:o,auth:i,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"],presignHost:d});r.switchInstance(y)}},l(R,"description","Run platforma backend service with 'S3' primary storage type"),l(R,"examples",["<%= config.bin %> <%= command.id %>"]),l(R,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...mr}),R);var T;let lt=(T=class extends u.Command{async run(){const{flags:e}=await this.parse(T),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const n="local-s3",s=e["pl-workdir"]??".",i=e.storage?h.join(s,e.storage):f.instanceDir(n),c=e["pl-log-file"]?h.join(s,e["pl-log-file"]):void 0,o=r.initAuthDriversList(e,s),g=e["auth-enabled"]??o!==void 0;let d="127.0.0.1:6345";e["grpc-listen"]?d=e["grpc-listen"]:e["grpc-port"]&&(d=`127.0.0.1:${e["grpc-port"]}`);let y="127.0.0.1:9090";e["monitoring-listen"]?y=e["monitoring-listen"]:e["monitoring-port"]&&(y=`127.0.0.1:${e["monitoring-port"]}`);let w="127.0.0.1:9091";e["debug-listen"]?w=e["debug-listen"]:e["debug-port"]&&(w=`127.0.0.1:${e["debug-port"]}`);const p={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],minioPort:e["s3-port"],minioConsolePort:e["s3-console-port"],configOptions:{grpc:{listen:d},monitoring:{listen:y},debug:{listen:w},license:{value:e.license,file:e["license-file"]},log:{path:c},localRoot:i,core:{auth:{enabled:g,drivers:o}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}},b=r.createLocalS3(n,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):await ve(t,{version:e.version}).then(()=>{const P=r.switchInstance(b),$=[];for(const S of P)$.push(new Promise((v,k)=>{S.on("close",v),S.on("error",k)}));return Promise.all($)}).catch(function(P){t.error(P.message)})}},l(T,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(T,"examples",["<%= config.bin %> <%= command.id %>"]),l(T,"flags",{...L,...N,...M,...fr,...be,...we,...pe,...C,...j,...se,...ne,...ie,...he,...ye,...B}),T);const W=class W extends u.Command{async run(){const{flags:e,args:t}=await this.parse(W),r=A(e["log-level"]),n=new I(r);n.mergeLicenseEnvs(e);const s=t.name,i=e["auth-enabled"],c=i?{enabled:i,drivers:n.initAuthDriversList(e,".")}:void 0,o=e.storage?h.join(".",e.storage):f.instanceDir(s),g=[];for(const y of e.mount??[])g.push({hostPath:y});const d=e.arch?`linux/${e.arch}`:void 0;n.createDocker(s,o,{primaryStorageURL:e["storage-primary"],workStoragePath:e["storage-work"],libraryStorageURL:e["storage-library"],image:e.image,version:e.version,platformOverride:d,customMounts:g,license:e.license,licenseFile:e["license-file"],auth:c,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"]}),r.info(`Instance '${s}' was created. To start it run 'up' command`)}};l(W,"description","Run Platforma Backend service as docker container on current host"),l(W,"examples",["<%= config.bin %> <%= command.id %>"]),l(W,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...se,...ne,...ie}),l(W,"args",{name:u.Args.string({required:!0})});let Ne=W;var O;let dt=(O=class extends u.Command{async run(){const{flags:e,args:t}=await this.parse(O),r=A(e["log-level"]),n=new I(r);n.mergeLicenseEnvs(e);const s=t.name,i=e["pl-workdir"]??".",c=e.storage?h.join(i,e.storage):f.instanceDir(s),o=e["pl-log-file"]?h.join(i,e["pl-log-file"]):void 0,g=n.initAuthDriversList(e,i),d=e["auth-enabled"]??g!==void 0;let y="127.0.0.1:6345";e["grpc-listen"]?y=e["grpc-listen"]:e["grpc-port"]&&(y=`127.0.0.1:${e["grpc-port"]}`);let w="127.0.0.1:9090";e["monitoring-listen"]?w=e["monitoring-listen"]:e["monitoring-port"]&&(w=`127.0.0.1:${e["monitoring-port"]}`);let p="127.0.0.1:9091";e["debug-listen"]?p=e["debug-listen"]:e["debug-port"]&&(p=`127.0.0.1:${e["debug-port"]}`);const b={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],configOptions:{grpc:{listen:y},monitoring:{listen:w},debug:{listen:p},license:{value:e.license,file:e["license-file"]},log:{path:o},localRoot:c,core:{auth:{enabled:d,drivers:g}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}};if(n.createLocal(s,b),b.binaryPath||b.sourcesPath){r.info(`Instance '${s}' was created. To start it run 'up' command`);return}ve(r,{version:e.version}).then(()=>r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(P){r.error(P.message)})}},l(O,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(O,"examples",["<%= config.bin %> <%= command.id %>"]),l(O,"flags",{...L,...N,...M,...be,...we,...pe,...C,...j,...se,...ne,...ie,...he,...ye,...B}),l(O,"args",{name:u.Args.string({required:!0})}),O);const z=class z extends u.Command{async run(){const{flags:e,args:t}=await this.parse(z),r=A(e["log-level"]),n=new I(r);n.mergeLicenseEnvs(e);const s=t.name,i=e["auth-enabled"],c=i?{enabled:i,drivers:n.initAuthDriversList(e,".")}:void 0,o=e.storage?h.join(".",e.storage):f.instanceDir(s),g=[];for(const w of e.mount??[])g.push({hostPath:w});const d=e.arch?`linux/${e.arch}`:void 0,y=e["minio-presign-host"]?"minio":"localhost";n.createDockerS3(s,o,{image:e.image,version:e.version,license:e.license,licenseFile:e["license-file"],platformOverride:d,customMounts:g,auth:c,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"],presignHost:y}),r.info(`Instance '${s}' was created. To start it run 'up' command`),e["minio-presign-host"]&&r.info(" NOTE: make sure you have 'minio' host in your hosts file as 127.0.0.1 address")}};l(z,"description","Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"),l(z,"examples",["<%= config.bin %> <%= command.id %>"]),l(z,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...mr}),l(z,"args",{name:u.Args.string({required:!0})});let Ce=z;const Y=class Y extends u.Command{async run(){const{flags:e,args:t}=await this.parse(Y),r=A(e["log-level"]),n=new I(r);n.mergeLicenseEnvs(e);const s=t.name,i=e["pl-workdir"]??".",c=e.storage?h.join(i,e.storage):f.instanceDir(s),o=e["pl-log-file"]?h.join(i,e["pl-log-file"]):void 0,g=n.initAuthDriversList(e,i),d=e["auth-enabled"]??g!==void 0;let y="127.0.0.1:6345";e["grpc-listen"]?y=e["grpc-listen"]:e["grpc-port"]&&(y=`127.0.0.1:${e["grpc-port"]}`);let w="127.0.0.1:9090";e["monitoring-listen"]?w=e["monitoring-listen"]:e["monitoring-port"]&&(w=`127.0.0.1:${e["monitoring-port"]}`);let p="127.0.0.1:9091";e["debug-listen"]?p=e["debug-listen"]:e["debug-port"]&&(p=`127.0.0.1:${e["debug-port"]}`);const b={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],minioPort:e["s3-port"],minioConsolePort:e["s3-console-port"],configOptions:{grpc:{listen:y},monitoring:{listen:w},debug:{listen:p},license:{value:e.license,file:e["license-file"]},log:{path:o},localRoot:c,core:{auth:{enabled:d,drivers:g}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}};if(r.info("Creating instance configuration, data directory and other stuff..."),n.createLocalS3(s,b),b.binaryPath||b.sourcesPath){r.info(`Instance '${s}' was created. To start it run 'up' command`);return}ve(r,{version:e.version}).then(()=>r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(P){r.error(P.message)})}};l(Y,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(Y,"examples",["<%= config.bin %> <%= command.id %>"]),l(Y,"flags",{...L,...N,...fr,...M,...be,...we,...pe,...C,...j,...se,...ne,...ie,...he,...ye,...B}),l(Y,"args",{name:u.Args.string({required:!0})});let Me=Y;const gt={"create-block":Ie,reset:Fe,start:Ee,stop:Re,"start:docker":it,"start:local":ct,"svc:delete":Te,"svc:down":De,"svc:list":xe,"svc:up":_e,"start:docker:s3":ot,"start:local:s3":lt,"svc:create:docker":Ne,"svc:create:local":dt,"svc:create:docker:s3":Ce,"svc:create:local:s3":Me};exports.COMMANDS=gt;
|
|
121
|
+
You can obtain the license from "https://licensing.milaboratories.com".`),new Error("The license was not provided.")}configureDockerStorage(e,t){const r={},s=t.type;switch(e=e.toUpperCase(),s){case"S3":return r[`PL_DATA_${e}_TYPE`]="S3",r[`PL_DATA_${e}_S3_BUCKET`]=t.bucketName,t.endpoint&&(r[`PL_DATA_${e}_S3_ENDPOINT`]=t.endpoint),t.presignEndpoint&&(r[`PL_DATA_${e}_S3_PRESIGN_ENDPOINT`]=t.presignEndpoint),t.region&&(r[`PL_DATA_${e}_S3_REGION`]=t.region),t.key&&(r[`PL_DATA_${e}_S3_KEY`]=t.key),t.secret&&(r[`PL_DATA_${e}_S3_SECRET`]=t.secret),r;case"FS":return r[`PL_DATA_${e}_TYPE`]="FS",r;default:U()}return{}}renderRunInfo(e,t=10){var c,o;const r=[],s=g=>g.padStart(t," ");switch(e.configPath&&r.push(`${s("config")}: ${e.configPath}`),e.apiAddr?r.push(`${s("API")}: ${e.apiAddr}`):e.apiPort?r.push(`${s("API")}: 127.0.0.1:${e.apiPort.toString()}`):r.push(`${s("API")}: 127.0.0.1:6345`),e.logPath&&r.push(`${s("log")}: ${e.logPath}`),(c=e.primary)==null?void 0:c.type){case void 0:break;case"FS":r.push(`${s("primary")}: ${e.primary.rootPath}`);break;case"S3":r.push(`${s("primary")}: S3 at '${e.primary.endpoint??"AWS"}', bucket '${e.primary.bucketName}', prefix: '${e.primary.keyPrefix??""}'`);break;default:U()}switch((o=e.library)==null?void 0:o.type){case void 0:break;case"FS":r.push(`${s("library")}: ${e.library.rootPath}`);break;case"S3":r.push(`${s("library")}: S3 at '${e.library.endpoint??"AWS"}', bucket '${e.library.bucketName}', prefix: '${e.library.keyPrefix??""}'`);break;default:U()}return e.work&&r.push(`${s("workdirs")}: ${e.work.rootPath}`),e.dbPath&&r.push(`${s("db")}: ${e.dbPath}`),r.join(`
|
|
122
|
+
`)}}function Le(a,e){for(const t of a){if(t.error)throw t.error;const r=e??"failed to run command";if(t.status!==0)throw new Error(`${r}, process exited with code '${t.status}'`)}}const ee=class ee extends u.Command{async run(){const{flags:e}=await this.parse(ee),t=A(e["log-level"]);new I(t).cleanupInstance()}};l(ee,"description","Clear service state (forget last run command, destroy docker services, volumes and so on)"),l(ee,"examples",["<%= config.bin %> <%= command.id %>"]),l(ee,"flags",{...L});let Fe=ee;const re=class re extends u.Command{async run(){const{flags:e}=await this.parse(re),t=A(e["log-level"]);new I(t).startLast()}};l(re,"description","Start last run service configuraiton"),l(re,"examples",["<%= config.bin %> <%= command.id %>"]),l(re,"flags",{...L});let Ee=re;const te=class te extends u.Command{async run(){const{flags:e}=await this.parse(te),t=A(e["log-level"]),r=new I(t);f.currentInstance?r.stopInstance(f.currentInstance):t.warn("up/start command was not called for any instance, nothing to stop")}};l(te,"description","Stop platforma service"),l(te,"examples",["<%= config.bin %> <%= command.id %>"]),l(te,"flags",{...L});let Re=te;var F;let it=(F=class extends u.Command{async run(){const{flags:e}=await this.parse(F),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const s="docker",n=e["auth-enabled"],i=n?{enabled:n,drivers:r.initAuthDriversList(e,".")}:void 0,c=e.storage?h.join(".",e.storage):f.instanceDir(s),o=[];for(const y of e.mount??[])o.push({hostPath:y});const g=e.arch?`linux/${e.arch}`:void 0,d=r.createDocker(s,c,{primaryStorageURL:e["storage-primary"],workStoragePath:e["storage-work"],libraryStorageURL:e["storage-library"],image:e.image,version:e.version,platformOverride:g,customMounts:o,license:e.license,licenseFile:e["license-file"],auth:i,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"]});r.switchInstance(d)}},l(F,"description","Run platforma backend service with 'FS' primary storage type"),l(F,"examples",["<%= config.bin %> <%= command.id %>"]),l(F,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...ne,...se,...ie}),F);var E;let ct=(E=class extends u.Command{async run(){const{flags:e}=await this.parse(E),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const s="local",n=e["pl-workdir"]??".",i=e.storage?h.join(n,e.storage):f.instanceDir(s),c=e["pl-log-file"]?h.join(n,e["pl-log-file"]):void 0,o=r.initAuthDriversList(e,n),g=e["auth-enabled"]??o!==void 0;let d="127.0.0.1:6345";e["grpc-listen"]?d=e["grpc-listen"]:e["grpc-port"]&&(d=`127.0.0.1:${e["grpc-port"]}`);let y="127.0.0.1:9090";e["monitoring-listen"]?y=e["monitoring-listen"]:e["monitoring-port"]&&(y=`127.0.0.1:${e["monitoring-port"]}`);let w="127.0.0.1:9091";e["debug-listen"]?w=e["debug-listen"]:e["debug-port"]&&(w=`127.0.0.1:${e["debug-port"]}`);const p={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],configOptions:{grpc:{listen:d},monitoring:{listen:y},debug:{listen:w},license:{value:e.license,file:e["license-file"]},log:{path:c},localRoot:i,core:{auth:{enabled:g,drivers:o}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}},b=r.createLocal(s,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):ve(t,{version:e.version}).then(()=>{const P=r.switchInstance(b);setTimeout(()=>{for(const $ of P)$.unref()},1e3)}).catch(function(P){t.error(P.message)})}},l(E,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(E,"examples",["<%= config.bin %> <%= command.id %>"]),l(E,"flags",{...L,...N,...M,...be,...we,...pe,...C,...j,...ne,...se,...ie,...he,...ye,...B}),E);const q=class q extends u.Command{async run(){const{flags:e,args:t}=await this.parse(q),r=A(e["log-level"]),s=new I(r),n=t.name;e.all&&(s.cleanupInstance(),process.exit(0)),n||(r.error("Please, specify name of instance to be removed or set '--all' flag instead"),process.exit(1)),s.cleanupInstance(n)}};l(q,"description","List available instances"),l(q,"examples",["<%= config.bin %> <%= command.id %>"]),l(q,"flags",{...L,all:u.Flags.boolean({description:"remove all known instances",required:!1})}),l(q,"args",{name:u.Args.string({required:!1})});let Te=q;const J=class J extends u.Command{async run(){const{flags:e,args:t}=await this.parse(J),r=A(e["log-level"]),s=new I(r),n=t.name??f.currentInstanceName;n||(r.info("no pl service instance selected. No service was stopped"),process.exit(0)),s.stopInstance(f.getInstanceInfo(n))}};l(J,"description","List available instances"),l(J,"examples",["<%= config.bin %> <%= command.id %>"]),l(J,"flags",{...L}),l(J,"args",{name:u.Args.string({required:!1})});let De=J;const ae=class ae extends u.Command{async run(){await this.parse(ae);const e=f.instanceList,t=f.currentInstanceName;for(const r of e){const s=[],n=f.getInstanceInfo(r);f.isInstanceActive(n)&&s.push("status:up"),s.push(`type:${n.type}`),console.log(r===t?` * ${r} (${s.join(", ")})`:` ${r} (${s.join(", ")})`)}}};l(ae,"description","List available instances"),l(ae,"examples",["<%= config.bin %> <%= command.id %>"]),l(ae,"flags",{});let xe=ae;const H=class H extends u.Command{async run(){const{flags:e,args:t}=await this.parse(H),r=A(e["log-level"]),s=new I(r),n=t.name??f.currentInstanceName;n||(r.error("no pl service instance is selected. Select instance with 'select' command or provide name to 'up'"),process.exit(1));const i=s.switchInstance(f.getInstanceInfo(n)),c=[];for(const o of i)c.push(new Promise((g,d)=>{o.on("close",g),o.on("error",d)}));await Promise.all(c)}};l(H,"description","List available instances"),l(H,"examples",["<%= config.bin %> <%= command.id %>"]),l(H,"flags",{...L}),l(H,"args",{name:u.Args.string({required:!1})});let _e=H;var R;let ot=(R=class extends u.Command{async run(){const{flags:e}=await this.parse(R),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const s="docker-s3",n=e["auth-enabled"],i=n?{enabled:n,drivers:r.initAuthDriversList(e,".")}:void 0,c=e.storage?h.join(".",e.storage):f.instanceDir(s),o=[];for(const w of e.mount??[])o.push({hostPath:w});const g=e.arch?`linux/${e.arch}`:void 0,d=e["minio-presign-host"]?"minio":"localhost",y=r.createDockerS3(s,c,{image:e.image,version:e.version,license:e.license,licenseFile:e["license-file"],platformOverride:g,customMounts:o,auth:i,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"],presignHost:d});r.switchInstance(y)}},l(R,"description","Run platforma backend service with 'S3' primary storage type"),l(R,"examples",["<%= config.bin %> <%= command.id %>"]),l(R,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...mr}),R);var T;let lt=(T=class extends u.Command{async run(){const{flags:e}=await this.parse(T),t=A(e["log-level"]),r=new I(t);r.mergeLicenseEnvs(e);const s="local-s3",n=e["pl-workdir"]??".",i=e.storage?h.join(n,e.storage):f.instanceDir(s),c=e["pl-log-file"]?h.join(n,e["pl-log-file"]):void 0,o=r.initAuthDriversList(e,n),g=e["auth-enabled"]??o!==void 0;let d="127.0.0.1:6345";e["grpc-listen"]?d=e["grpc-listen"]:e["grpc-port"]&&(d=`127.0.0.1:${e["grpc-port"]}`);let y="127.0.0.1:9090";e["monitoring-listen"]?y=e["monitoring-listen"]:e["monitoring-port"]&&(y=`127.0.0.1:${e["monitoring-port"]}`);let w="127.0.0.1:9091";e["debug-listen"]?w=e["debug-listen"]:e["debug-port"]&&(w=`127.0.0.1:${e["debug-port"]}`);const p={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],minioPort:e["s3-port"],minioConsolePort:e["s3-console-port"],configOptions:{grpc:{listen:d},monitoring:{listen:y},debug:{listen:w},license:{value:e.license,file:e["license-file"]},log:{path:c},localRoot:i,core:{auth:{enabled:g,drivers:o}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}},b=r.createLocalS3(s,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):await ve(t,{version:e.version}).then(()=>{const P=r.switchInstance(b),$=[];for(const S of P)$.push(new Promise((v,k)=>{S.on("close",v),S.on("error",k)}));return Promise.all($)}).catch(function(P){t.error(P.message)})}},l(T,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(T,"examples",["<%= config.bin %> <%= command.id %>"]),l(T,"flags",{...L,...N,...M,...fr,...be,...we,...pe,...C,...j,...ne,...se,...ie,...he,...ye,...B}),T);const W=class W extends u.Command{async run(){const{flags:e,args:t}=await this.parse(W),r=A(e["log-level"]),s=new I(r);s.mergeLicenseEnvs(e);const n=t.name,i=e["auth-enabled"],c=i?{enabled:i,drivers:s.initAuthDriversList(e,".")}:void 0,o=e.storage?h.join(".",e.storage):f.instanceDir(n),g=[];for(const y of e.mount??[])g.push({hostPath:y});const d=e.arch?`linux/${e.arch}`:void 0;s.createDocker(n,o,{primaryStorageURL:e["storage-primary"],workStoragePath:e["storage-work"],libraryStorageURL:e["storage-library"],image:e.image,version:e.version,platformOverride:d,customMounts:g,license:e.license,licenseFile:e["license-file"],auth:c,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"]}),r.info(`Instance '${n}' was created. To start it run 'up' command`)}};l(W,"description","Run Platforma Backend service as docker container on current host"),l(W,"examples",["<%= config.bin %> <%= command.id %>"]),l(W,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...ne,...se,...ie}),l(W,"args",{name:u.Args.string({required:!0})});let Ne=W;var O;let dt=(O=class extends u.Command{async run(){const{flags:e,args:t}=await this.parse(O),r=A(e["log-level"]),s=new I(r);s.mergeLicenseEnvs(e);const n=t.name,i=e["pl-workdir"]??".",c=e.storage?h.join(i,e.storage):f.instanceDir(n),o=e["pl-log-file"]?h.join(i,e["pl-log-file"]):void 0,g=s.initAuthDriversList(e,i),d=e["auth-enabled"]??g!==void 0;let y="127.0.0.1:6345";e["grpc-listen"]?y=e["grpc-listen"]:e["grpc-port"]&&(y=`127.0.0.1:${e["grpc-port"]}`);let w="127.0.0.1:9090";e["monitoring-listen"]?w=e["monitoring-listen"]:e["monitoring-port"]&&(w=`127.0.0.1:${e["monitoring-port"]}`);let p="127.0.0.1:9091";e["debug-listen"]?p=e["debug-listen"]:e["debug-port"]&&(p=`127.0.0.1:${e["debug-port"]}`);const b={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],configOptions:{grpc:{listen:y},monitoring:{listen:w},debug:{listen:p},license:{value:e.license,file:e["license-file"]},log:{path:o},localRoot:c,core:{auth:{enabled:d,drivers:g}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}};if(s.createLocal(n,b),b.binaryPath||b.sourcesPath){r.info(`Instance '${n}' was created. To start it run 'up' command`);return}ve(r,{version:e.version}).then(()=>r.info(`Instance '${n}' was created. To start it run 'svc up' command`)).catch(function(P){r.error(P.message)})}},l(O,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(O,"examples",["<%= config.bin %> <%= command.id %>"]),l(O,"flags",{...L,...N,...M,...be,...we,...pe,...C,...j,...ne,...se,...ie,...he,...ye,...B}),l(O,"args",{name:u.Args.string({required:!0})}),O);const z=class z extends u.Command{async run(){const{flags:e,args:t}=await this.parse(z),r=A(e["log-level"]),s=new I(r);s.mergeLicenseEnvs(e);const n=t.name,i=e["auth-enabled"],c=i?{enabled:i,drivers:s.initAuthDriversList(e,".")}:void 0,o=e.storage?h.join(".",e.storage):f.instanceDir(n),g=[];for(const w of e.mount??[])g.push({hostPath:w});const d=e.arch?`linux/${e.arch}`:void 0,y=e["minio-presign-host"]?"minio":"localhost";s.createDockerS3(n,o,{image:e.image,version:e.version,license:e.license,licenseFile:e["license-file"],platformOverride:d,customMounts:g,auth:c,grpcAddr:e["grpc-listen"],grpcPort:e["grpc-port"],monitoringAddr:e["monitoring-listen"],monitoringPort:e["monitoring-port"],debugAddr:e["debug-listen"],debugPort:e["debug-port"],presignHost:y}),r.info(`Instance '${n}' was created. To start it run 'up' command`),e["minio-presign-host"]&&r.info(" NOTE: make sure you have 'minio' host in your hosts file as 127.0.0.1 address")}};l(z,"description","Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"),l(z,"examples",["<%= config.bin %> <%= command.id %>"]),l(z,"flags",{...L,...M,...ue,...N,...fe,...B,...C,...me,...j,...mr}),l(z,"args",{name:u.Args.string({required:!0})});let Ce=z;const Y=class Y extends u.Command{async run(){const{flags:e,args:t}=await this.parse(Y),r=A(e["log-level"]),s=new I(r);s.mergeLicenseEnvs(e);const n=t.name,i=e["pl-workdir"]??".",c=e.storage?h.join(i,e.storage):f.instanceDir(n),o=e["pl-log-file"]?h.join(i,e["pl-log-file"]):void 0,g=s.initAuthDriversList(e,i),d=e["auth-enabled"]??g!==void 0;let y="127.0.0.1:6345";e["grpc-listen"]?y=e["grpc-listen"]:e["grpc-port"]&&(y=`127.0.0.1:${e["grpc-port"]}`);let w="127.0.0.1:9090";e["monitoring-listen"]?w=e["monitoring-listen"]:e["monitoring-port"]&&(w=`127.0.0.1:${e["monitoring-port"]}`);let p="127.0.0.1:9091";e["debug-listen"]?p=e["debug-listen"]:e["debug-port"]&&(p=`127.0.0.1:${e["debug-port"]}`);const b={sourcesPath:e["pl-sources"],binaryPath:e["pl-binary"],version:e.version,configPath:e.config,workdir:e["pl-workdir"],primaryURL:e["storage-primary"],libraryURL:e["storage-library"],minioPort:e["s3-port"],minioConsolePort:e["s3-console-port"],configOptions:{grpc:{listen:y},monitoring:{listen:w},debug:{listen:p},license:{value:e.license,file:e["license-file"]},log:{path:o},localRoot:c,core:{auth:{enabled:d,drivers:g}},storages:{work:{type:"FS",rootPath:e["storage-work"]}}}};if(r.info("Creating instance configuration, data directory and other stuff..."),s.createLocalS3(n,b),b.binaryPath||b.sourcesPath){r.info(`Instance '${n}' was created. To start it run 'up' command`);return}ve(r,{version:e.version}).then(()=>r.info(`Instance '${n}' was created. To start it run 'svc up' command`)).catch(function(P){r.error(P.message)})}};l(Y,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(Y,"examples",["<%= config.bin %> <%= command.id %>"]),l(Y,"flags",{...L,...N,...fr,...M,...be,...we,...pe,...C,...j,...ne,...se,...ie,...he,...ye,...B}),l(Y,"args",{name:u.Args.string({required:!0})});let Me=Y;const gt={"create-block":Ie,reset:Fe,start:Ee,stop:Re,"start:docker":it,"start:local":ct,"svc:delete":Te,"svc:down":De,"svc:list":xe,"svc:up":_e,"start:docker:s3":ot,"start:local:s3":lt,"svc:create:docker":Ne,"svc:create:local":dt,"svc:create:docker:s3":Ce,"svc:create:local:s3":Me};exports.COMMANDS=gt;
|
|
118
123
|
//# sourceMappingURL=index.js.map
|