@platforma-sdk/bootstrap 3.5.0 → 3.5.1

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.
@@ -16,6 +16,8 @@ export default class S3 extends Command {
16
16
  arch: OptionFlag<string | undefined, CustomOptions>;
17
17
  version: OptionFlag<string | undefined, CustomOptions>;
18
18
  image: OptionFlag<string | undefined, CustomOptions>;
19
+ 's3-port': OptionFlag<number, CustomOptions>;
20
+ 's3-console-port': OptionFlag<number, CustomOptions>;
19
21
  'grpc-port': OptionFlag<number | undefined, CustomOptions>;
20
22
  'grpc-listen': OptionFlag<string | undefined, CustomOptions>;
21
23
  'monitoring-port': OptionFlag<number | undefined, CustomOptions>;
@@ -1 +1 @@
1
- {"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../../src/commands/svc/create/docker/s3.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,aAAa,CAAC;AAQ5C,MAAM,CAAC,OAAO,OAAO,EAAG,SAAQ,OAAO;IACrC,OAAgB,WAAW,SAAsG;IAEjI,OAAgB,QAAQ,WAA2C;IAEnE,OAAgB,KAAK;;;;;;;;;;;;;;;;;;;;MAcnB;IAEF,MAAM,CAAC,IAAI;;MAET;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAwDlC"}
1
+ {"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../../../src/commands/svc/create/docker/s3.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,aAAa,CAAC;AAQ5C,MAAM,CAAC,OAAO,OAAO,EAAG,SAAQ,OAAO;IACrC,OAAgB,WAAW,SAAsG;IAEjI,OAAgB,QAAQ,WAA2C;IAEnE,OAAgB,KAAK;;;;;;;;;;;;;;;;;;;;;;MAenB;IAEF,MAAM,CAAC,IAAI;;MAET;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2DlC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var kr=Object.defineProperty;var Sr=(a,e,t)=>e in a?kr(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var l=(a,e,t)=>Sr(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@oclif/core"),E=require("node:os"),f=require("node:fs"),h=require("node:path"),ge=require("node:child_process"),ue=require("winston"),$r=require("node:crypto"),Z=require("readline-sync"),Lr=require("node:fs/promises"),Ar=require("node:stream"),N=require("zod"),Ir=require("decompress"),me=require("@milaboratories/pl-deployments"),gr=require("yaml"),Or=require("node:https"),Fr=require("tar");function Ge(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 fe=Ge(E),C=Ge(Lr),Er=Ge(Fr),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 he={image:u.Flags.string({description:"use custom docker image to run platforma"})},M={version:u.Flags.string({description:"use custom platforma release (official docker image or binary package)"})},ye={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"})},j={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'."})},B={"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"})},qe={"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"})},U={storage:u.Flags.string({description:"specify path on host to be used as storage for all Platforma Backend data"})},hr={"minio-presign-host":u.Flags.boolean({description:"use 'minio' host instead of 'localhost' in presign URLs"})},be={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"})},we={"pl-log-file":u.Flags.file({description:"specify path for Platforma Backend log file"})},pe={"pl-workdir":u.Flags.file({description:"specify working directory for Platforma Backend process"})},Pe={"pl-binary":u.Flags.file({description:"start given Platforma Backend binary instead of automatically downloaded version"})},ve={"pl-sources":u.Flags.file({description:"path to pl repository root: build Platforma Backend from sources and start the resulting binary"})},ke={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 ie={"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 ce={"storage-primary":u.Flags.string({description:`specify 'primary' storage destination URL.
1
+ "use strict";var kr=Object.defineProperty;var Sr=(a,e,t)=>e in a?kr(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var l=(a,e,t)=>Sr(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@oclif/core"),E=require("node:os"),f=require("node:fs"),h=require("node:path"),ge=require("node:child_process"),ue=require("winston"),$r=require("node:crypto"),Z=require("readline-sync"),Lr=require("node:fs/promises"),Ar=require("node:stream"),N=require("zod"),Ir=require("decompress"),me=require("@milaboratories/pl-deployments"),gr=require("yaml"),Or=require("node:https"),Fr=require("tar");function qe(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 fe=qe(E),C=qe(Lr),Er=qe(Fr),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 he={image:u.Flags.string({description:"use custom docker image to run platforma"})},M={version:u.Flags.string({description:"use custom platforma release (official docker image or binary package)"})},ye={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"})},j={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'."})},B={"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"})},be={"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"})},U={storage:u.Flags.string({description:"specify path on host to be used as storage for all Platforma Backend data"})},hr={"minio-presign-host":u.Flags.boolean({description:"use 'minio' host instead of 'localhost' in presign URLs"})},we={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"})},pe={"pl-log-file":u.Flags.file({description:"specify path for Platforma Backend log file"})},Pe={"pl-workdir":u.Flags.file({description:"specify working directory for Platforma Backend process"})},ve={"pl-binary":u.Flags.file({description:"start given Platforma Backend binary instead of automatically downloaded version"})},ke={"pl-sources":u.Flags.file({description:"path to pl repository root: build Platforma Backend from sources and start the resulting binary"})},Se={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 ie={"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 ce={"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
@@ -8,12 +8,12 @@
8
8
  s3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http
9
9
  s3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https`})},Rr={"auth-enabled":u.Flags.boolean({description:"enable authorization"})},Tr={"auth-htpasswd-file":u.Flags.file({description:"path to .htpasswd file with Platforma users (static user DB auth source)"})},xr={"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"})},G={...Rr,...Tr,...xr,...Dr};function _r(a){return Z.question(`${a} [y/N] `).toLowerCase()==="y"}function q(a){throw new Error("this should never happen")}function A(a="debug"){return ue.createLogger({level:a,format:ue.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 n=t.split(`
10
10
  `).map((i,c)=>c===0?i:r+i).join(`
11
- `);return`${(i=>ue.format.colorize().colorize(i,i))(e)}: ${n}`}),transports:[new ue.transports.Console({stderrLevels:["error","warn","info","debug"],handleExceptions:!0})]})}function Nr(a){return $r.randomBytes(Math.ceil(a/2)).toString("hex").slice(0,a)}function Cr(a){return a.startsWith("~")?h.join(E.homedir(),a.slice(1)):a}function $e(a,e){f.existsSync(a)||(f.mkdirSync(a,{recursive:!0}),e!=null&&e.mode&&f.chmodSync(a,e.mode))}function Mr(a){try{if(E.platform()!=="win32")return ge.execSync(`ps -p ${a} -o comm=`,{encoding:"utf8"}).trim();const e=`wmic process where processid=${a} get Caption`,t=ge.execSync(e,{encoding:"utf8"}).split(`
12
- `);return t.length<=1?"":t[1].trim()}catch{return""}}function jr(a){const e=ge.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 Fe=["Python"],yr=["Tengo","Python"],Br=N.z.union([N.z.literal("Tengo"),N.z.literal("Python")]),Ur=N.z.object({npmOrgName:N.z.string().min(1),orgName:N.z.string().min(1,{message:"Organization name must be provided"}),blockName:N.z.string().min(1,{message:"Block name must be provided"}),softwarePlatforms:N.z.array(Br).refine(a=>new Set(a).size===a.length,{message:"Must be an array of unique software platforms"})});async function Gr(a){const{npmOrgName:e,orgName:t,blockName:r,softwarePlatforms:n}=qr(),s=h.join(process.cwd(),r);a.info("Downloading boilerplate code..."),await Jr("https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip","platforma-block-boilerplate-main",s);const i=yr.filter(o=>n.indexOf(o)<0),c=Fe.length==i.length;a.info(`Keep platforms '${n}', remove: '${i}'. Will remove all platforms? ${c}`);for(const o of i)await Hr(s,o);c&&await Wr(s),a.info("Replace everything in the template with provided options..."),zr(s,[{from:/@platforma-open(?!.*runenv-python-3)/g,to:`@${e}`},{from:/my-org/g,to:t},{from:/block-boilerplate/g,to:r}])}function qr(){let a=Z.question('Write an organization name for npm. Default is "platforma-open": ');a===""&&(a="platforma-open");let e="";for(;e.length<1;)e=Z.question('Write an organization name, e.g. "my-org": ');let t="";for(;t.length<1;)t=Z.question('Write a name of the block, e.g. "hello-world": ');const r=Z.keyInYN("Create package for block's software?");let n=["Tengo"];if(r)for(;n.length<yr.length;){const i=Z.keyInSelect(Fe,"Choose software platform:");if(i<0)break;n.push(Fe[i])}n=Array.from(new Set(n)).sort();const s=Ur.safeParse({npmOrgName:a,orgName:e,blockName:t,softwarePlatforms:n});if(!s.success&&s.error.issues.length)throw new Error(s.error.issues.map(i=>i.message).join("; "));return s.data}async function Jr(a,e,t){const n=await(await fetch(a)).blob(),s=await C.mkdtemp(h.join(E.tmpdir(),"create-repo")),i=h.join(s,"packed-repo.zip"),c=Ar.Writable.toWeb(f.createWriteStream(i));await n.stream().pipeTo(c);const o=h.join(s,"unpacked-repo");await C.mkdir(o),await Ir(i,o),await C.cp(h.join(o,e),t,{recursive:!0})}async function Hr(a,e){const t=e.toLowerCase();await ee(h.join(a,"ui","src","pages","MainPage.vue"),new RegExp(`.*${t}Message.*\\n`,"g")),await ee(h.join(a,"model","src","index.ts"),new RegExp(`.*${t}Message.*\\n\\n`,"g")),await ee(h.join(a,"workflow","src","main.tpl.tengo"),new RegExp(`.*${t}.*exec.builder.*[\\s\\S]*?\\n\\n`,"g")),await ee(h.join(a,"workflow","src","main.tpl.tengo"),new RegExp(`.*${t}Message.*\\n`,"g")),await ee(h.join(a,"workflow","src","wf.test.ts"),new RegExp(`.*${t}Message.*\\n.*expect.*\\n\\n`,"g")),await C.rm(h.join(a,"software",`src_${t}`),{recursive:!0}),await Je(h.join(a,"software","package.json"),r=>{const n=JSON.parse(r);return delete n["block-software"].artifacts[`hello-${t}-artifact`],delete n["block-software"].entrypoints[`hello-world-${t}`],JSON.stringify(n,null,2)})}async function Wr(a){await C.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 ee(h.join(a,"pnpm-workspace.yaml"),/.*- software$\n/gm)}async function zr(a,e){const t=await Yr(a);for(const{from:r,to:n}of e)for(const s of t)await br(s,r,n)}async function Yr(a){return(await C.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 C.readFile(a),r=e(t.toString());await C.writeFile(a,r)}async function br(a,e,t){return await Je(a,r=>r.replaceAll(e,t))}async function ee(a,e){return await br(a,e,"")}const re=class re extends u.Command{async run(){const{flags:e}=await this.parse(re),t=A(e["log-level"]);await Gr(t)}};l(re,"description","Helps to create a new block by downloading a block's template."),l(re,"examples",["<%= name %>"]),l(re,"flags",{...L});let Ee=re;function wr(...a){return h.resolve(__dirname,"..",...a)}function X(...a){return wr("assets",...a)}function Le(...a){return f.readFileSync(wr(...a))}function ur(a){return a||(a=me.getDefaultPlVersion()),`quay.io/milaboratories/platforma:${a}`}const J=class J{constructor(e){l(this,"state",{currentInstance:""});l(this,"filePath");l(this,"dirPath");e=e??h.resolve(E.homedir(),".config","pl-bootstrap");const t=h.join(e,"state.json");this.dirPath=e,this.filePath=t,f.existsSync(e)||f.mkdirSync(e,{recursive:!0}),f.existsSync(t)&&(this.state=JSON.parse(Le(t).toString()))}static getStateInstance(){return J.instance||(J.instance=new J),J.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(){f.writeFileSync(this.filePath,JSON.stringify(this.state))}get instanceList(){return f.existsSync(this.instanceDir())?f.readdirSync(this.instanceDir()).filter(t=>this.instanceExists(t)):[]}instanceExists(e){return f.existsSync(this.instanceDir(e,"instance.json"))}getInstanceInfo(e){const t=this.instanceDir(e,"instance.json");if(!f.existsSync(t))throw new Error(`platforma backend instance '${e}' does not exist or is corrupted`);const r=JSON.parse(Le(t).toString());return{name:e,...r}}setInstanceInfo(e,t){f.existsSync(this.instanceDir(e))||f.mkdirSync(this.instanceDir(e),{recursive:!0});const r=this.instanceDir(e,"instance.json");let n={};f.existsSync(r)&&(n=JSON.parse(Le(r).toString())),f.writeFileSync(r,JSON.stringify({...n,...t}))}isInstanceActive(e){switch(e.type){case"docker":{const r=jr(`pl-${e.name}`);return r?r.Status.trim().startsWith("running"):!1}case"process":return e.pid?mr(e.pid):!1;default:throw q(),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 mr(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(J,"instance");let Re=J;function mr(a){const e=Mr(a);return e==="platforma"||e.endsWith("/platforma")||e.endsWith("\\platforma")}const m=Re.getStateInstance();function Ae(a,e,t){const r=[],n=[];for(const s of e){const i={cwd:s.workdir,env:{...s.envs,...t==null?void 0:t.env},...s.runOpts,...t};if(s.async){const c=Vr(a,s.cmd,s.args,i);n.push(c)}else{const c=Kr(a,s.cmd,s.args,i);if(r.push(c),c.error||c.status!==0)break}}return{executed:r,spawned:n}}function Vr(a,e,t,r){var c;a.debug(`Running:
11
+ `);return`${(i=>ue.format.colorize().colorize(i,i))(e)}: ${n}`}),transports:[new ue.transports.Console({stderrLevels:["error","warn","info","debug"],handleExceptions:!0})]})}function Nr(a){return $r.randomBytes(Math.ceil(a/2)).toString("hex").slice(0,a)}function Cr(a){return a.startsWith("~")?h.join(E.homedir(),a.slice(1)):a}function Le(a,e){f.existsSync(a)||(f.mkdirSync(a,{recursive:!0}),e!=null&&e.mode&&f.chmodSync(a,e.mode))}function Mr(a){try{if(E.platform()!=="win32")return ge.execSync(`ps -p ${a} -o comm=`,{encoding:"utf8"}).trim();const e=`wmic process where processid=${a} get Caption`,t=ge.execSync(e,{encoding:"utf8"}).split(`
12
+ `);return t.length<=1?"":t[1].trim()}catch{return""}}function jr(a){const e=ge.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 Ee=["Python"],yr=["Tengo","Python"],Br=N.z.union([N.z.literal("Tengo"),N.z.literal("Python")]),Ur=N.z.object({npmOrgName:N.z.string().min(1),orgName:N.z.string().min(1,{message:"Organization name must be provided"}),blockName:N.z.string().min(1,{message:"Block name must be provided"}),softwarePlatforms:N.z.array(Br).refine(a=>new Set(a).size===a.length,{message:"Must be an array of unique software platforms"})});async function Gr(a){const{npmOrgName:e,orgName:t,blockName:r,softwarePlatforms:n}=qr(),s=h.join(process.cwd(),r);a.info("Downloading boilerplate code..."),await Jr("https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip","platforma-block-boilerplate-main",s);const i=yr.filter(o=>n.indexOf(o)<0),c=Ee.length==i.length;a.info(`Keep platforms '${n}', remove: '${i}'. Will remove all platforms? ${c}`);for(const o of i)await Hr(s,o);c&&await Wr(s),a.info("Replace everything in the template with provided options..."),zr(s,[{from:/@platforma-open(?!.*runenv-python-3)/g,to:`@${e}`},{from:/my-org/g,to:t},{from:/block-boilerplate/g,to:r}])}function qr(){let a=Z.question('Write an organization name for npm. Default is "platforma-open": ');a===""&&(a="platforma-open");let e="";for(;e.length<1;)e=Z.question('Write an organization name, e.g. "my-org": ');let t="";for(;t.length<1;)t=Z.question('Write a name of the block, e.g. "hello-world": ');const r=Z.keyInYN("Create package for block's software?");let n=["Tengo"];if(r)for(;n.length<yr.length;){const i=Z.keyInSelect(Ee,"Choose software platform:");if(i<0)break;n.push(Ee[i])}n=Array.from(new Set(n)).sort();const s=Ur.safeParse({npmOrgName:a,orgName:e,blockName:t,softwarePlatforms:n});if(!s.success&&s.error.issues.length)throw new Error(s.error.issues.map(i=>i.message).join("; "));return s.data}async function Jr(a,e,t){const n=await(await fetch(a)).blob(),s=await C.mkdtemp(h.join(E.tmpdir(),"create-repo")),i=h.join(s,"packed-repo.zip"),c=Ar.Writable.toWeb(f.createWriteStream(i));await n.stream().pipeTo(c);const o=h.join(s,"unpacked-repo");await C.mkdir(o),await Ir(i,o),await C.cp(h.join(o,e),t,{recursive:!0})}async function Hr(a,e){const t=e.toLowerCase();await ee(h.join(a,"ui","src","pages","MainPage.vue"),new RegExp(`.*${t}Message.*\\n`,"g")),await ee(h.join(a,"model","src","index.ts"),new RegExp(`.*${t}Message.*\\n\\n`,"g")),await ee(h.join(a,"workflow","src","main.tpl.tengo"),new RegExp(`.*${t}.*exec.builder.*[\\s\\S]*?\\n\\n`,"g")),await ee(h.join(a,"workflow","src","main.tpl.tengo"),new RegExp(`.*${t}Message.*\\n`,"g")),await ee(h.join(a,"workflow","src","wf.test.ts"),new RegExp(`.*${t}Message.*\\n.*expect.*\\n\\n`,"g")),await C.rm(h.join(a,"software",`src_${t}`),{recursive:!0}),await Je(h.join(a,"software","package.json"),r=>{const n=JSON.parse(r);return delete n["block-software"].artifacts[`hello-${t}-artifact`],delete n["block-software"].entrypoints[`hello-world-${t}`],JSON.stringify(n,null,2)})}async function Wr(a){await C.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 ee(h.join(a,"pnpm-workspace.yaml"),/.*- software$\n/gm)}async function zr(a,e){const t=await Yr(a);for(const{from:r,to:n}of e)for(const s of t)await br(s,r,n)}async function Yr(a){return(await C.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 C.readFile(a),r=e(t.toString());await C.writeFile(a,r)}async function br(a,e,t){return await Je(a,r=>r.replaceAll(e,t))}async function ee(a,e){return await br(a,e,"")}const re=class re extends u.Command{async run(){const{flags:e}=await this.parse(re),t=A(e["log-level"]);await Gr(t)}};l(re,"description","Helps to create a new block by downloading a block's template."),l(re,"examples",["<%= name %>"]),l(re,"flags",{...L});let Re=re;function wr(...a){return h.resolve(__dirname,"..",...a)}function X(...a){return wr("assets",...a)}function Ae(...a){return f.readFileSync(wr(...a))}function ur(a){return a||(a=me.getDefaultPlVersion()),`quay.io/milaboratories/platforma:${a}`}const J=class J{constructor(e){l(this,"state",{currentInstance:""});l(this,"filePath");l(this,"dirPath");e=e??h.resolve(E.homedir(),".config","pl-bootstrap");const t=h.join(e,"state.json");this.dirPath=e,this.filePath=t,f.existsSync(e)||f.mkdirSync(e,{recursive:!0}),f.existsSync(t)&&(this.state=JSON.parse(Ae(t).toString()))}static getStateInstance(){return J.instance||(J.instance=new J),J.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(){f.writeFileSync(this.filePath,JSON.stringify(this.state))}get instanceList(){return f.existsSync(this.instanceDir())?f.readdirSync(this.instanceDir()).filter(t=>this.instanceExists(t)):[]}instanceExists(e){return f.existsSync(this.instanceDir(e,"instance.json"))}getInstanceInfo(e){const t=this.instanceDir(e,"instance.json");if(!f.existsSync(t))throw new Error(`platforma backend instance '${e}' does not exist or is corrupted`);const r=JSON.parse(Ae(t).toString());return{name:e,...r}}setInstanceInfo(e,t){f.existsSync(this.instanceDir(e))||f.mkdirSync(this.instanceDir(e),{recursive:!0});const r=this.instanceDir(e,"instance.json");let n={};f.existsSync(r)&&(n=JSON.parse(Ae(r).toString())),f.writeFileSync(r,JSON.stringify({...n,...t}))}isInstanceActive(e){switch(e.type){case"docker":{const r=jr(`pl-${e.name}`);return r?r.Status.trim().startsWith("running"):!1}case"process":return e.pid?mr(e.pid):!1;default:throw q(),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 mr(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(J,"instance");let Te=J;function mr(a){const e=Mr(a);return e==="platforma"||e.endsWith("/platforma")||e.endsWith("\\platforma")}const m=Te.getStateInstance();function Ie(a,e,t){const r=[],n=[];for(const s of e){const i={cwd:s.workdir,env:{...s.envs,...t==null?void 0:t.env},...s.runOpts,...t};if(s.async){const c=Vr(a,s.cmd,s.args,i);n.push(c)}else{const c=Kr(a,s.cmd,s.args,i);if(r.push(c),c.error||c.status!==0)break}}return{executed:r,spawned:n}}function Vr(a,e,t,r){var c;a.debug(`Running:
13
13
  cmd: ${JSON.stringify([e,...t])}
14
14
  wd: ${(c=r.cwd)==null?void 0:c.toString()}`),r.env={...process.env,...r.env},a.debug(" spawning child process");const n=ge.spawn(e,t,r);let s=!1;const i=()=>{n.kill("SIGINT"),s=!0};return a.debug(" setting up signal handler"),process.on("SIGINT",i),n.on("close",o=>{process.removeListener("SIGINT",i),s&&process.exit(o)}),n}function Kr(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},ge.spawnSync(e,t,r)}function Ie(a,e,t,r,n){const s=f.readFileSync(a,{encoding:"utf-8"}),i=gr.parse(s.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}`)}}n!=null&&n.dropVolumes&&delete i.volumes,f.writeFileSync(e,gr.stringify(i))}function Xr(a){return{id:a,type:"S3",indexCachePeriod:"0s",endpoint:"",region:"",bucketName:"",createBucket:!1,forcePathStyle:!1,key:"",secret:"",keyPrefix:"",accessPrefixes:[],uploadKeyPrefix:""}}function pr(a){return{id:a,type:"FS",indexCachePeriod:"0s",rootPath:""}}function Q(a,e,t){a=Cr(a);const r=new URL(a,`file:${e}`);switch(r.protocol){case"s3:":{const n=r.hostname,s=r.searchParams.get("region"),i=r.pathname.slice(1);return{...t,type:"S3",bucketName:n,region:s,keyPrefix:i}}case"s3e:":{const n=r.pathname.split("/").slice(1),s=n[0],i=n.length>1?n.slice(1).join("/"):"";return{...t,type:"S3",endpoint:`http://${r.host}/`,bucketName:s,keyPrefix:i,region:r.searchParams.get("region"),key:r.username?`static:${r.username}`:"",secret:r.password?`static:${r.password}`:""}}case"s3es:":{const n=r.pathname.split("/").slice(1),s=n[0],i=n.length>1?n.slice(1).join("/"):"";return{...t,type:"S3",endpoint:`https://${r.host}/`,bucketName:s,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,v,$,k,P,S,_,le,O,He,We,ze,Ye,Ve,Ke,Xe,Qe,Ze,er,rr,tr,ar,nr,sr,ir,cr,or,lr,dr;const t=(e==null?void 0:e.localRoot)??m.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`},n={listen:((v=e==null?void 0:e.grpc)==null?void 0:v.listen)??"localhost:6345",tls:{enable:de((k=($=e==null?void 0:e.grpc)==null?void 0:$.tls)==null?void 0:k.enable,!1),clientAuthMode:((S=(P=e==null?void 0:e.grpc)==null?void 0:P.tls)==null?void 0:S.clientAuthMode)??"NoAuth",certFile:((le=(_=e==null?void 0:e.grpc)==null?void 0:_.tls)==null?void 0:le.certFile)??`${t}/certs/tls.cert`,keyFile:((He=(O=e==null?void 0:e.grpc)==null?void 0:O.tls)==null?void 0:He.keyFile)??`${t}/certs/tls.key`,...(We=e==null?void 0:e.grpc)==null?void 0:We.tls}},s={auth:{enabled:((Ye=(ze=e==null?void 0:e.core)==null?void 0:ze.auth)==null?void 0:Ye.enabled)??!1,drivers:((Ke=(Ve=e==null?void 0:e.core)==null?void 0:Ve.auth)==null?void 0:Ke.drivers)??[{driver:"jwt",key:a},{driver:"htpasswd",path:`${t}/users.htpasswd`}]},db:{path:`${t}/db`}},i=fr("main",`${t}/storages/main`,"main-bucket",(Xe=e==null?void 0:e.storages)==null?void 0:Xe.primary);let c;switch((Ze=(Qe=e==null?void 0:e.storages)==null?void 0:Qe.work)==null?void 0:Ze.type){case void 0:case"FS":c=pr("work"),c.rootPath=((rr=(er=e==null?void 0:e.storages)==null?void 0:er.work)==null?void 0:rr.rootPath)??`${t}/storages/work`,c.indexCachePeriod=((ar=(tr=e==null?void 0:e.storages)==null?void 0:tr.work)==null?void 0:ar.indexCachePeriod)??"1m";break;default:throw new Error("work storage MUST have 'FS' type as it is used for working directories management")}const g=fr("library",`${t}/storages/library`,"library-bucket",(nr=e==null?void 0:e.storages)==null?void 0:nr.library),d={enabled:de((sr=e==null?void 0:e.monitoring)==null?void 0:sr.enabled,!0),listen:((ir=e==null?void 0:e.monitoring)==null?void 0:ir.listen)??"127.0.0.1:9090"},y={enabled:de((cr=e==null?void 0:e.debug)==null?void 0:cr.enabled,!0),listen:((or=e==null?void 0:e.debug)==null?void 0:or.listen)??"127.0.0.1:9091"},w={value:((lr=e==null?void 0:e.license)==null?void 0:lr.value)??"",file:((dr=e==null?void 0:e.license)==null?void 0:dr.file)??""};return{localRoot:t,license:w,log:r,grpc:n,core:s,monitoring:d,debug:y,numCpu:e==null?void 0:e.numCpu,storages:{primary:i,work:c,library:g},hacks:{libraryDownloadable:!0}}}function fr(a,e,t,r){let n;switch(r==null?void 0:r.type){case void 0:case"FS":n=pr(a),n.rootPath=(r==null?void 0:r.rootPath)??e;break;case"S3":n=Xr(a),n.endpoint=r==null?void 0:r.endpoint,n.region=r==null?void 0:r.region,n.presignEndpoint=(r==null?void 0:r.presignEndpoint)??(r==null?void 0:r.endpoint),n.bucketName=(r==null?void 0:r.bucketName)??t,n.createBucket=de(r==null?void 0:r.createBucket,!0),n.forcePathStyle=de(r==null?void 0:r.forcePathStyle,!0),n.key=(r==null?void 0:r.key)??"",n.secret=(r==null?void 0:r.secret)??"",n.keyPrefix=(r==null?void 0:r.keyPrefix)??"",n.accessPrefixes=(r==null?void 0:r.accessPrefixes)??[""],n.uploadKeyPrefix=(r==null?void 0:r.uploadKeyPrefix)??"";break;default:throw q(),new Error("unknown storage type")}return n}function Zr(a){const e=a.monitoring.enabled?"":" disabled",t=a.debug.enabled?"":" disabled",r=a.hacks.libraryDownloadable?"true":"false";let n=a.license.value;a.license.file!=""&&(n=f.readFileSync(a.license.file).toString().trimEnd());let s="";return a.numCpu&&(s=`
16
+ opts: ${JSON.stringify(r)}`),r.env={...process.env,...r.env},ge.spawnSync(e,t,r)}function Oe(a,e,t,r,n){const s=f.readFileSync(a,{encoding:"utf-8"}),i=gr.parse(s.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}`)}}n!=null&&n.dropVolumes&&delete i.volumes,f.writeFileSync(e,gr.stringify(i))}function Xr(a){return{id:a,type:"S3",indexCachePeriod:"0s",endpoint:"",region:"",bucketName:"",createBucket:!1,forcePathStyle:!1,key:"",secret:"",keyPrefix:"",accessPrefixes:[],uploadKeyPrefix:""}}function pr(a){return{id:a,type:"FS",indexCachePeriod:"0s",rootPath:""}}function Q(a,e,t){a=Cr(a);const r=new URL(a,`file:${e}`);switch(r.protocol){case"s3:":{const n=r.hostname,s=r.searchParams.get("region"),i=r.pathname.slice(1);return{...t,type:"S3",bucketName:n,region:s,keyPrefix:i}}case"s3e:":{const n=r.pathname.split("/").slice(1),s=n[0],i=n.length>1?n.slice(1).join("/"):"";return{...t,type:"S3",endpoint:`http://${r.host}/`,bucketName:s,keyPrefix:i,region:r.searchParams.get("region"),key:r.username?`static:${r.username}`:"",secret:r.password?`static:${r.password}`:""}}case"s3es:":{const n=r.pathname.split("/").slice(1),s=n[0],i=n.length>1?n.slice(1).join("/"):"";return{...t,type:"S3",endpoint:`https://${r.host}/`,bucketName:s,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,v,$,k,P,S,_,le,O,He,We,ze,Ye,Ve,Ke,Xe,Qe,Ze,er,rr,tr,ar,nr,sr,ir,cr,or,lr,dr;const t=(e==null?void 0:e.localRoot)??m.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`},n={listen:((v=e==null?void 0:e.grpc)==null?void 0:v.listen)??"localhost:6345",tls:{enable:de((k=($=e==null?void 0:e.grpc)==null?void 0:$.tls)==null?void 0:k.enable,!1),clientAuthMode:((S=(P=e==null?void 0:e.grpc)==null?void 0:P.tls)==null?void 0:S.clientAuthMode)??"NoAuth",certFile:((le=(_=e==null?void 0:e.grpc)==null?void 0:_.tls)==null?void 0:le.certFile)??`${t}/certs/tls.cert`,keyFile:((He=(O=e==null?void 0:e.grpc)==null?void 0:O.tls)==null?void 0:He.keyFile)??`${t}/certs/tls.key`,...(We=e==null?void 0:e.grpc)==null?void 0:We.tls}},s={auth:{enabled:((Ye=(ze=e==null?void 0:e.core)==null?void 0:ze.auth)==null?void 0:Ye.enabled)??!1,drivers:((Ke=(Ve=e==null?void 0:e.core)==null?void 0:Ve.auth)==null?void 0:Ke.drivers)??[{driver:"jwt",key:a},{driver:"htpasswd",path:`${t}/users.htpasswd`}]},db:{path:`${t}/db`}},i=fr("main",`${t}/storages/main`,"main-bucket",(Xe=e==null?void 0:e.storages)==null?void 0:Xe.primary);let c;switch((Ze=(Qe=e==null?void 0:e.storages)==null?void 0:Qe.work)==null?void 0:Ze.type){case void 0:case"FS":c=pr("work"),c.rootPath=((rr=(er=e==null?void 0:e.storages)==null?void 0:er.work)==null?void 0:rr.rootPath)??`${t}/storages/work`,c.indexCachePeriod=((ar=(tr=e==null?void 0:e.storages)==null?void 0:tr.work)==null?void 0:ar.indexCachePeriod)??"1m";break;default:throw new Error("work storage MUST have 'FS' type as it is used for working directories management")}const g=fr("library",`${t}/storages/library`,"library-bucket",(nr=e==null?void 0:e.storages)==null?void 0:nr.library),d={enabled:de((sr=e==null?void 0:e.monitoring)==null?void 0:sr.enabled,!0),listen:((ir=e==null?void 0:e.monitoring)==null?void 0:ir.listen)??"127.0.0.1:9090"},y={enabled:de((cr=e==null?void 0:e.debug)==null?void 0:cr.enabled,!0),listen:((or=e==null?void 0:e.debug)==null?void 0:or.listen)??"127.0.0.1:9091"},w={value:((lr=e==null?void 0:e.license)==null?void 0:lr.value)??"",file:((dr=e==null?void 0:e.license)==null?void 0:dr.file)??""};return{localRoot:t,license:w,log:r,grpc:n,core:s,monitoring:d,debug:y,numCpu:e==null?void 0:e.numCpu,storages:{primary:i,work:c,library:g},hacks:{libraryDownloadable:!0}}}function fr(a,e,t,r){let n;switch(r==null?void 0:r.type){case void 0:case"FS":n=pr(a),n.rootPath=(r==null?void 0:r.rootPath)??e;break;case"S3":n=Xr(a),n.endpoint=r==null?void 0:r.endpoint,n.region=r==null?void 0:r.region,n.presignEndpoint=(r==null?void 0:r.presignEndpoint)??(r==null?void 0:r.endpoint),n.bucketName=(r==null?void 0:r.bucketName)??t,n.createBucket=de(r==null?void 0:r.createBucket,!0),n.forcePathStyle=de(r==null?void 0:r.forcePathStyle,!0),n.key=(r==null?void 0:r.key)??"",n.secret=(r==null?void 0:r.secret)??"",n.keyPrefix=(r==null?void 0:r.keyPrefix)??"",n.accessPrefixes=(r==null?void 0:r.accessPrefixes)??[""],n.uploadKeyPrefix=(r==null?void 0:r.uploadKeyPrefix)??"";break;default:throw q(),new Error("unknown storage type")}return n}function Zr(a){const e=a.monitoring.enabled?"":" disabled",t=a.debug.enabled?"":" disabled",r=a.hacks.libraryDownloadable?"true":"false";let n=a.license.value;a.license.file!=""&&(n=f.readFileSync(a.license.file).toString().trimEnd());let s="";return a.numCpu&&(s=`
17
17
  resources:
18
18
  cpu: ${a.numCpu}
19
19
  `),`
@@ -101,8 +101,8 @@ ${s}
101
101
  URL: ${s}
102
102
  Save to: ${i}`);const c=Or.get(s);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=f.createWriteStream(i);d.pipe(p),d.on("data",b=>{w+=b.length;const v=w/y*100;r&&process.stdout.write(` downloading: ${v.toFixed(2)}%\r`)}),d.on("error",b=>{f.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 nt(a,e){a.debug("extracting archive...");const t=(e==null?void 0:e.version)??me.getDefaultPlVersion();a.debug(` version: '${t}'`);const r=`${vr({version:t})}.tgz`,n=(e==null?void 0:e.archivePath)??m.binaries(r);a.debug(` archive path: '${n}'`);const s=(e==null?void 0:e.extractTo)??it(n);if(a.debug(` target dir: '${s}'`),f.existsSync(s))return a.info(`Platforma Backend binaries unpack skipped: '${s}' exists`),s;if(!f.existsSync(n)){const i=`Platforma Backend binary archive not found at '${n}'`;throw a.error(i),new Error(i)}return f.existsSync(s)||(a.debug(` creating target dir '${s}'`),f.mkdirSync(s,{recursive:!0})),a.info(`Unpacking Platforma Backend archive:
103
103
  Archive: ${n}
104
- Target dir: ${s}`),Er.x({file:n,cwd:s,gzip:!0,sync:!0}),a.info(" ... unpack done."),s}function Se(a,e){return at(a,e).then(t=>nt(a,{archivePath:t}))}function vr(a){return`pl-${(a==null?void 0:a.version)??me.getDefaultPlVersion()}-${Pr()}`}function st(a,...e){return m.binaries(vr({version:a}),...e)}function it(a){const e=a.lastIndexOf(".");return e===-1?a:a.slice(0,e)}class I{constructor(e){this.logger=e}startLast(){const e=m.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}':
105
- ${r}`)}const t=Ae(this.logger,e.upCommands);return Oe(t.executed),t.spawned.length>0&&e.type==="process"&&(e.pid=t.spawned[t.spawned.length-1].pid,m.setInstanceInfo(e.name,e),this.logger.info(`instance '${e.name}' started`)),m.currentInstanceName=e.name,t.spawned}stopInstance(e){this.logger.info(`stopping platforma backend instance '${e.name}'...`);const t=Ae(this.logger,e.downCommands);switch(Oe(t.executed),e.type){case"docker":return;case"process":{e.pid&&m.isInstanceActive(e)&&process.kill(e.pid);return}default:q()}}switchInstance(e){for(const t of m.instanceList)if(t!==e.name){const r=m.getInstanceInfo(t);m.isInstanceActive(r)&&this.stopInstance(r)}return this.startInstance(e)}createLocal(e,t){var d,y,w,p,b,v,$,k,P,S,_,le;let r=st(t==null?void 0:t.version,"binaries","platforma");t!=null&&t.sourcesPath&&(r=h.join(E.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():m.instanceDir(e));t!=null&&t.primaryURL&&(t.configOptions={...t.configOptions,storages:{...(d=t.configOptions)==null?void 0:d.storages,primary:Q(t.primaryURL,s,(w=(y=t.configOptions)==null?void 0:y.storages)==null?void 0:w.primary)}}),t!=null&&t.libraryURL&&(t.configOptions={...t.configOptions,storages:{...(p=t.configOptions)==null?void 0:p.storages,library:Q(t.libraryURL,s,(v=(b=t.configOptions)==null?void 0:b.storages)==null?void 0:v.library)}});const i=Qr(this.getLastJwt(),t==null?void 0:t.configOptions);this.logger.debug(" checking license..."),this.checkLicense((k=($=t==null?void 0:t.configOptions)==null?void 0:$.license)==null?void 0:k.value,(S=(P=t==null?void 0:t.configOptions)==null?void 0:P.license)==null?void 0:S.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 O of c)f.existsSync(O)||(this.logger.debug(` '${O}'`),f.mkdirSync(O,{recursive:!0}));for(const O of i.core.auth.drivers)O.driver==="htpasswd"&&(f.existsSync(O.path)||(this.logger.debug(` installing default 'users.htpasswd' to ${O.path}...`),f.copyFileSync(X("users.htpasswd"),O.path)));n||(n=h.join(i.localRoot,"config.yaml"),this.logger.debug(` rendering configuration '${n}'...`),f.writeFileSync(n,Zr(i)));const o=[];t!=null&&t.sourcesPath&&o.push({cmd:"go",args:["build","-o",r,"."],workdir:h.resolve(t.sourcesPath,"cmd","platforma"),runOpts:{stdio:"inherit"}});const g={async:!0,cmd:r,args:["--quiet","--config",n],workdir:s,runOpts:{stdio:"inherit"}};return(_=t==null?void 0:t.configOptions)!=null&&_.numCpu&&(g.runOpts.env={GOMAXPROCS:String((le=t==null?void 0:t.configOptions)==null?void 0:le.numCpu)}),o.push(g),m.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}}),m.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],m.setInstanceInfo(e,n),n}createMinio(e,t){this.logger.debug(" creating docker compose for minio service...");const r=X("compose-backend.yaml"),n=m.instanceDir(e,"compose-minio.yaml");Ie(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)??m.instanceDir(e,"minio");$e(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:m.instanceDir(e),runOpts:{stdio:"inherit"}},stop:{cmd:"docker",args:["compose",`--file=${n}`,"down"],envs:d,workdir:m.instanceDir(e),runOpts:{stdio:"inherit"}},cleanup:{cmd:"docker",args:["compose",`--file=${n}`,"down","--volumes","--remove-orphans"],envs:d,workdir:m.instanceDir(e),runOpts:{stdio:"inherit"}}}}createDockerS3(e,t,r){this.logger.debug("creating platforma instance in 'docker s3' mode...");const n=X("compose-backend.yaml"),s=(r==null?void 0:r.image)??ur(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...P)=>h.join(t,...P),c=P=>{const S=i(P);return $e(S,{mode:"0775"}),S},o=i("logs","platforma.log");f.existsSync(o)||(f.mkdirSync(h.dirname(o),{recursive:!0}),f.writeFileSync(o,""));const g=(r==null?void 0:r.presignHost)??"localhost",d=Q("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=Q("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");f.existsSync(b)||f.copyFileSync(X("users.htpasswd"),b);const v=i("compose.yaml");f.existsSync(v)&&this.logger.info(`replacing docker compose file ${v}`);const $=[];for(const P of(r==null?void 0:r.customMounts)??[])$.push({hostPath:P.hostPath,containerPath:P.containerPath??P.hostPath});Ie(n,v,`pl-${e}`,new Map([["minio",{}],["backend",{platform:r==null?void 0:r.platformOverride,mounts:$}]]));const k={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&&(k.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(k.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(k.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(k.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(k.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(k.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.s3Port&&(k.MINIO_PORT=r.s3Port.toString()),r!=null&&r.s3ConsolePort&&(k.MINIO_CONSOLE_PORT=r.s3ConsolePort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(k.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const P of r.auth.drivers)P.driver==="htpasswd"&&(k.PL_AUTH_HTPASSWD_PATH=h.resolve(P.path),P.path="/etc/platforma/users.htpasswd");k.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return m.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${v}`,"up","--detach","--remove-orphans","--pull=missing"],envs:k,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${v}`,"down"],envs:k,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${v}`,"down","--volumes","--remove-orphans"],envs:k,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}}),m.getInstanceInfo(e)}createDocker(e,t,r){this.logger.debug("creating platforma instance in 'docker' mode...");const n=X("compose-backend.yaml"),s=(r==null?void 0:r.image)??ur(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...S)=>h.join(t,...S),c=S=>{const _=i(S);return $e(_,{mode:"0775"}),_},o=i("logs","platforma.log");f.existsSync(o)||(f.mkdirSync(h.dirname(o),{recursive:!0}),f.writeFileSync(o,""));const g=c("db"),d=c("primary"),y=c("library"),w=c("work"),p=i("users.htpasswd");f.existsSync(p)||f.copyFileSync(X("users.htpasswd"),p);const b=i("compose.yaml");f.existsSync(b)&&this.logger.info(`replacing docker compose file ${b}`);const v=[];for(const S of(r==null?void 0:r.customMounts)??[])v.push({hostPath:S.hostPath,containerPath:S.containerPath??S.hostPath});this.logger.debug(`Rendering docker compose file '${b}' using '${n}' as base template`),Ie(n,b,`pl-${e}`,new Map([["backend",{platform:r==null?void 0:r.platformOverride,mounts:v}]]));const $=Q((r==null?void 0:r.primaryStorageURL)??`file:${d}`,"."),k=Q((r==null?void 0:r.libraryStorageURL)??`file:${y}`,"."),P={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",k)};if(r!=null&&r.grpcAddr&&(P.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(P.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(P.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(P.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(P.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(P.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(P.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const S of r.auth.drivers)S.driver==="htpasswd"&&(P.PL_AUTH_HTPASSWD_PATH=h.resolve(S.path),S.path="/etc/platforma/users.htpasswd");P.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return m.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"up","--detach","--remove-orphans","--pull=missing"],envs:P,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down"],envs:P,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down","--volumes","--remove-orphans"],envs:P,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:k,dbPath:g}}),m.getInstanceInfo(e)}cleanupInstance(e){const t=[],r=new Map;let n="";if(e){const s=m.getInstanceInfo(e);switch(r.set(e,s),s.type){case"docker":{t.push(`docker service 'pl-${e}', including all its volumes and data in '${m.instanceDir(e)}' will be destroyed`);break}case"process":{t.push(`directory '${m.instanceDir(e)}' would be deleted`),s.downCommands&&t.push("associated docker service, including all volumes and data will be destroyed");break}default:q()}e===m.currentInstanceName&&t.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)"),n=`
104
+ Target dir: ${s}`),Er.x({file:n,cwd:s,gzip:!0,sync:!0}),a.info(" ... unpack done."),s}function $e(a,e){return at(a,e).then(t=>nt(a,{archivePath:t}))}function vr(a){return`pl-${(a==null?void 0:a.version)??me.getDefaultPlVersion()}-${Pr()}`}function st(a,...e){return m.binaries(vr({version:a}),...e)}function it(a){const e=a.lastIndexOf(".");return e===-1?a:a.slice(0,e)}class I{constructor(e){this.logger=e}startLast(){const e=m.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}':
105
+ ${r}`)}const t=Ie(this.logger,e.upCommands);return Fe(t.executed),t.spawned.length>0&&e.type==="process"&&(e.pid=t.spawned[t.spawned.length-1].pid,m.setInstanceInfo(e.name,e),this.logger.info(`instance '${e.name}' started`)),m.currentInstanceName=e.name,t.spawned}stopInstance(e){this.logger.info(`stopping platforma backend instance '${e.name}'...`);const t=Ie(this.logger,e.downCommands);switch(Fe(t.executed),e.type){case"docker":return;case"process":{e.pid&&m.isInstanceActive(e)&&process.kill(e.pid);return}default:q()}}switchInstance(e){for(const t of m.instanceList)if(t!==e.name){const r=m.getInstanceInfo(t);m.isInstanceActive(r)&&this.stopInstance(r)}return this.startInstance(e)}createLocal(e,t){var d,y,w,p,b,v,$,k,P,S,_,le;let r=st(t==null?void 0:t.version,"binaries","platforma");t!=null&&t.sourcesPath&&(r=h.join(E.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():m.instanceDir(e));t!=null&&t.primaryURL&&(t.configOptions={...t.configOptions,storages:{...(d=t.configOptions)==null?void 0:d.storages,primary:Q(t.primaryURL,s,(w=(y=t.configOptions)==null?void 0:y.storages)==null?void 0:w.primary)}}),t!=null&&t.libraryURL&&(t.configOptions={...t.configOptions,storages:{...(p=t.configOptions)==null?void 0:p.storages,library:Q(t.libraryURL,s,(v=(b=t.configOptions)==null?void 0:b.storages)==null?void 0:v.library)}});const i=Qr(this.getLastJwt(),t==null?void 0:t.configOptions);this.logger.debug(" checking license..."),this.checkLicense((k=($=t==null?void 0:t.configOptions)==null?void 0:$.license)==null?void 0:k.value,(S=(P=t==null?void 0:t.configOptions)==null?void 0:P.license)==null?void 0:S.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 O of c)f.existsSync(O)||(this.logger.debug(` '${O}'`),f.mkdirSync(O,{recursive:!0}));for(const O of i.core.auth.drivers)O.driver==="htpasswd"&&(f.existsSync(O.path)||(this.logger.debug(` installing default 'users.htpasswd' to ${O.path}...`),f.copyFileSync(X("users.htpasswd"),O.path)));n||(n=h.join(i.localRoot,"config.yaml"),this.logger.debug(` rendering configuration '${n}'...`),f.writeFileSync(n,Zr(i)));const o=[];t!=null&&t.sourcesPath&&o.push({cmd:"go",args:["build","-o",r,"."],workdir:h.resolve(t.sourcesPath,"cmd","platforma"),runOpts:{stdio:"inherit"}});const g={async:!0,cmd:r,args:["--quiet","--config",n],workdir:s,runOpts:{stdio:"inherit"}};return(_=t==null?void 0:t.configOptions)!=null&&_.numCpu&&(g.runOpts.env={GOMAXPROCS:String((le=t==null?void 0:t.configOptions)==null?void 0:le.numCpu)}),o.push(g),m.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}}),m.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],m.setInstanceInfo(e,n),n}createMinio(e,t){this.logger.debug(" creating docker compose for minio service...");const r=X("compose-backend.yaml"),n=m.instanceDir(e,"compose-minio.yaml");Oe(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)??m.instanceDir(e,"minio");Le(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:m.instanceDir(e),runOpts:{stdio:"inherit"}},stop:{cmd:"docker",args:["compose",`--file=${n}`,"down"],envs:d,workdir:m.instanceDir(e),runOpts:{stdio:"inherit"}},cleanup:{cmd:"docker",args:["compose",`--file=${n}`,"down","--volumes","--remove-orphans"],envs:d,workdir:m.instanceDir(e),runOpts:{stdio:"inherit"}}}}createDockerS3(e,t,r){this.logger.debug("creating platforma instance in 'docker s3' mode...");const n=X("compose-backend.yaml"),s=(r==null?void 0:r.image)??ur(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...P)=>h.join(t,...P),c=P=>{const S=i(P);return Le(S,{mode:"0775"}),S},o=i("logs","platforma.log");f.existsSync(o)||(f.mkdirSync(h.dirname(o),{recursive:!0}),f.writeFileSync(o,""));const g=(r==null?void 0:r.presignHost)??"localhost",d=Q("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=Q("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");f.existsSync(b)||f.copyFileSync(X("users.htpasswd"),b);const v=i("compose.yaml");f.existsSync(v)&&this.logger.info(`replacing docker compose file ${v}`);const $=[];for(const P of(r==null?void 0:r.customMounts)??[])$.push({hostPath:P.hostPath,containerPath:P.containerPath??P.hostPath});Oe(n,v,`pl-${e}`,new Map([["minio",{}],["backend",{platform:r==null?void 0:r.platformOverride,mounts:$}]]));const k={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&&(k.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(k.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(k.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(k.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(k.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(k.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.s3Port&&(k.MINIO_PORT=r.s3Port.toString()),r!=null&&r.s3ConsolePort&&(k.MINIO_CONSOLE_PORT=r.s3ConsolePort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(k.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const P of r.auth.drivers)P.driver==="htpasswd"&&(k.PL_AUTH_HTPASSWD_PATH=h.resolve(P.path),P.path="/etc/platforma/users.htpasswd");k.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return m.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${v}`,"up","--detach","--remove-orphans","--pull=missing"],envs:k,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${v}`,"down"],envs:k,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${v}`,"down","--volumes","--remove-orphans"],envs:k,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}}),m.getInstanceInfo(e)}createDocker(e,t,r){this.logger.debug("creating platforma instance in 'docker' mode...");const n=X("compose-backend.yaml"),s=(r==null?void 0:r.image)??ur(r==null?void 0:r.version);this.checkLicense(r==null?void 0:r.license,r==null?void 0:r.licenseFile);const i=(...S)=>h.join(t,...S),c=S=>{const _=i(S);return Le(_,{mode:"0775"}),_},o=i("logs","platforma.log");f.existsSync(o)||(f.mkdirSync(h.dirname(o),{recursive:!0}),f.writeFileSync(o,""));const g=c("db"),d=c("primary"),y=c("library"),w=c("work"),p=i("users.htpasswd");f.existsSync(p)||f.copyFileSync(X("users.htpasswd"),p);const b=i("compose.yaml");f.existsSync(b)&&this.logger.info(`replacing docker compose file ${b}`);const v=[];for(const S of(r==null?void 0:r.customMounts)??[])v.push({hostPath:S.hostPath,containerPath:S.containerPath??S.hostPath});this.logger.debug(`Rendering docker compose file '${b}' using '${n}' as base template`),Oe(n,b,`pl-${e}`,new Map([["backend",{platform:r==null?void 0:r.platformOverride,mounts:v}]]));const $=Q((r==null?void 0:r.primaryStorageURL)??`file:${d}`,"."),k=Q((r==null?void 0:r.libraryStorageURL)??`file:${y}`,"."),P={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",k)};if(r!=null&&r.grpcAddr&&(P.PL_GRPC_ADDR=r.grpcAddr),r!=null&&r.grpcPort&&(P.PL_GRPC_PORT=r.grpcPort.toString()),r!=null&&r.monitoringAddr&&(P.PL_MONITORING_ADDR=r.monitoringAddr),r!=null&&r.monitoringPort&&(P.PL_MONITORING_PORT=r.monitoringPort.toString()),r!=null&&r.debugAddr&&(P.PL_DEBUG_ADDR=r.debugAddr),r!=null&&r.debugPort&&(P.PL_DEBUG_PORT=r.debugPort.toString()),r!=null&&r.auth&&(r.auth.enabled&&(P.PL_AUTH_ENABLED="true"),r.auth.drivers)){for(const S of r.auth.drivers)S.driver==="htpasswd"&&(P.PL_AUTH_HTPASSWD_PATH=h.resolve(S.path),S.path="/etc/platforma/users.htpasswd");P.PL_AUTH_DRIVERS=JSON.stringify(r.auth.drivers)}return m.setInstanceInfo(e,{type:"docker",upCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"up","--detach","--remove-orphans","--pull=missing"],envs:P,runOpts:{stdio:"inherit"}}],downCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down"],envs:P,runOpts:{stdio:"inherit"}}],cleanupCommands:[{cmd:"docker",args:["compose",`--file=${b}`,"down","--volumes","--remove-orphans"],envs:P,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:k,dbPath:g}}),m.getInstanceInfo(e)}cleanupInstance(e){const t=[],r=new Map;let n="";if(e){const s=m.getInstanceInfo(e);switch(r.set(e,s),s.type){case"docker":{t.push(`docker service 'pl-${e}', including all its volumes and data in '${m.instanceDir(e)}' will be destroyed`);break}case"process":{t.push(`directory '${m.instanceDir(e)}' would be deleted`),s.downCommands&&t.push("associated docker service, including all volumes and data will be destroyed");break}default:q()}e===m.currentInstanceName&&t.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)"),n=`
106
106
  You are going to reset the state of platforma service '${e}':
107
107
  - ${t.join(`
108
108
  - `)}
@@ -110,7 +110,7 @@ You are going to reset the state of platforma service '${e}':
110
110
  You are going to reset the state of all platforma services configured with pl-bootstrap package.
111
111
  - ${t.join(`
112
112
  - `)}
113
- `}if(this.logger.warn(n),!_r("Are you sure?")){this.logger.info("Reset action was canceled");return}for(const[s,i]of r.entries()){if(i.cleanupCommands.length){this.logger.info(`Wiping instance ${s} services`);const c=Ae(this.logger,i.cleanupCommands);Oe(c.executed,`failed to wipe instance ${s} services`)}this.logger.info(`Destroying instance '${s}' data directory`),f.rmSync(m.instanceDir(s),{recursive:!0,force:!0})}e||(this.logger.info(`Destroying state dir '${m.path()}'`),f.rmSync(m.path(),{recursive:!0,force:!0})),this.logger.info(`
113
+ `}if(this.logger.warn(n),!_r("Are you sure?")){this.logger.info("Reset action was canceled");return}for(const[s,i]of r.entries()){if(i.cleanupCommands.length){this.logger.info(`Wiping instance ${s} services`);const c=Ie(this.logger,i.cleanupCommands);Fe(c.executed,`failed to wipe instance ${s} services`)}this.logger.info(`Destroying instance '${s}' data directory`),f.rmSync(m.instanceDir(s),{recursive:!0,force:!0})}e||(this.logger.info(`Destroying state dir '${m.path()}'`),f.rmSync(m.path(),{recursive:!0,force:!0})),this.logger.info(`
114
114
  If you want to remove all downloaded platforma binaries, delete '${m.binaries()}' dir manually
115
115
  `)}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:f.existsSync(h.resolve(E.homedir(),".pl.license"))&&(e["license-file"]=h.resolve(E.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=m.path("auth.jwt"),t="utf-8";let r="";return f.existsSync(e)&&(r=f.readFileSync(e,{encoding:t})),r==""&&(r=Nr(64),f.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.
116
116
 
@@ -123,5 +123,5 @@ The license file can also be set with the variables 'MI_LICENSE_FILE' or 'PL_LIC
123
123
  or stored in '$HOME/.pl.license'.
124
124
 
125
125
  You can obtain the license from "https://licensing.milaboratories.com".`),new Error("The license was not provided.")}configureDockerStorage(e,t){const r={},n=t.type;switch(e=e.toUpperCase(),n){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:q()}return{}}renderRunInfo(e,t=10){var c,o;const r=[],n=g=>g.padStart(t," ");switch(e.configPath&&r.push(`${n("config")}: ${e.configPath}`),e.apiAddr?r.push(`${n("API")}: ${e.apiAddr}`):e.apiPort?r.push(`${n("API")}: 127.0.0.1:${e.apiPort.toString()}`):r.push(`${n("API")}: 127.0.0.1:6345`),e.logPath&&r.push(`${n("log")}: ${e.logPath}`),(c=e.primary)==null?void 0:c.type){case void 0:break;case"FS":r.push(`${n("primary")}: ${e.primary.rootPath}`);break;case"S3":r.push(`${n("primary")}: S3 at '${e.primary.endpoint??"AWS"}', bucket '${e.primary.bucketName}', prefix: '${e.primary.keyPrefix??""}'`);break;default:q()}switch((o=e.library)==null?void 0:o.type){case void 0:break;case"FS":r.push(`${n("library")}: ${e.library.rootPath}`);break;case"S3":r.push(`${n("library")}: S3 at '${e.library.endpoint??"AWS"}', bucket '${e.library.bucketName}', prefix: '${e.library.keyPrefix??""}'`);break;default:q()}return e.work&&r.push(`${n("workdirs")}: ${e.work.rootPath}`),e.dbPath&&r.push(`${n("db")}: ${e.dbPath}`),r.join(`
126
- `)}}function Oe(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 te=class te extends u.Command{async run(){const{flags:e}=await this.parse(te),t=A(e["log-level"]);new I(t).cleanupInstance()}};l(te,"description","Clear service state (forget last run command, destroy docker services, volumes and so on)"),l(te,"examples",["<%= config.bin %> <%= command.id %>"]),l(te,"flags",{...L});let Te=te;const ae=class ae extends u.Command{async run(){const{flags:e}=await this.parse(ae),t=A(e["log-level"]);new I(t).startLast()}};l(ae,"description","Start last run service configuraiton"),l(ae,"examples",["<%= config.bin %> <%= command.id %>"]),l(ae,"flags",{...L});let xe=ae;const ne=class ne extends u.Command{async run(){const{flags:e}=await this.parse(ne),t=A(e["log-level"]),r=new I(t);m.currentInstance?r.stopInstance(m.currentInstance):t.warn("up/start command was not called for any instance, nothing to stop")}};l(ne,"description","Stop platforma service"),l(ne,"examples",["<%= config.bin %> <%= command.id %>"]),l(ne,"flags",{...L});let De=ne;var R;let ct=(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",s=e["auth-enabled"],i=s?{enabled:s,drivers:r.initAuthDriversList(e,".")}:void 0,c=e.storage?h.join(".",e.storage):m.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(R,"description","Run platforma backend service with 'FS' primary storage type"),l(R,"examples",["<%= config.bin %> <%= command.id %>"]),l(R,"flags",{...L,...B,...he,...M,...ye,...G,...j,...be,...U,...ce,...ie,...oe}),R);var T;let ot=(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",s=e["pl-workdir"]??".",i=e.storage?h.join(s,e.storage):m.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"]}},numCpu:Math.max(fe.cpus().length-2,1)}},b=r.createLocal(n,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):Se(t,{version:e.version}).then(()=>{const v=r.switchInstance(b);setTimeout(()=>{for(const $ of v)$.unref()},1e3)}).catch(function(v){t.error(v.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,...M,...B,...Pe,...ve,...ke,...j,...U,...ce,...ie,...oe,...we,...pe,...G}),T);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;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(H,"description","List available instances"),l(H,"examples",["<%= config.bin %> <%= command.id %>"]),l(H,"flags",{...L,all:u.Flags.boolean({description:"remove all known instances",required:!1})}),l(H,"args",{name:u.Args.string({required:!1})});let _e=H;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),s=t.name??m.currentInstanceName;s||(r.info("no pl service instance selected. No service was stopped"),process.exit(0)),n.stopInstance(m.getInstanceInfo(s))}};l(W,"description","List available instances"),l(W,"examples",["<%= config.bin %> <%= command.id %>"]),l(W,"flags",{...L}),l(W,"args",{name:u.Args.string({required:!1})});let Ne=W;const se=class se extends u.Command{async run(){await this.parse(se);const e=m.instanceList,t=m.currentInstanceName;for(const r of e){const n=[],s=m.getInstanceInfo(r);m.isInstanceActive(s)&&n.push("status:up"),n.push(`type:${s.type}`),console.log(r===t?` * ${r} (${n.join(", ")})`:` ${r} (${n.join(", ")})`)}}};l(se,"description","List available instances"),l(se,"examples",["<%= config.bin %> <%= command.id %>"]),l(se,"flags",{});let Ce=se;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),s=t.name??m.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(m.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(z,"description","List available instances"),l(z,"examples",["<%= config.bin %> <%= command.id %>"]),l(z,"flags",{...L}),l(z,"args",{name:u.Args.string({required:!1})});let Me=z;var x;let lt=(x=class extends u.Command{async run(){const{flags:e}=await this.parse(x),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):m.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"],s3Port:e["s3-port"],s3ConsolePort:e["s3-console-port"],presignHost:d});r.switchInstance(y)}},l(x,"description","Run platforma backend service with 'S3' primary storage type"),l(x,"examples",["<%= config.bin %> <%= command.id %>"]),l(x,"flags",{...L,...B,...qe,...he,...M,...ye,...G,...j,...be,...U,...hr}),x);var D;let dt=(D=class extends u.Command{async run(){const{flags:e}=await this.parse(D),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):m.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}},numCpu:Math.max(fe.cpus().length-2,1),storages:{work:{type:"FS",rootPath:e["storage-work"]}}}},b=r.createLocalS3(n,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):await Se(t,{version:e.version}).then(()=>{const v=r.switchInstance(b),$=[];for(const k of v)$.push(new Promise((P,S)=>{k.on("close",P),k.on("error",S)}));return Promise.all($)}).catch(function(v){t.error(v.message)})}},l(D,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(D,"examples",["<%= config.bin %> <%= command.id %>"]),l(D,"flags",{...L,...M,...B,...qe,...Pe,...ve,...ke,...j,...U,...ce,...ie,...oe,...we,...pe,...G}),D);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["auth-enabled"],c=i?{enabled:i,drivers:n.initAuthDriversList(e,".")}:void 0,o=e.storage?h.join(".",e.storage):m.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(Y,"description","Run Platforma Backend service as docker container on current host"),l(Y,"examples",["<%= config.bin %> <%= command.id %>"]),l(Y,"flags",{...L,...B,...he,...M,...ye,...G,...j,...be,...U,...ce,...ie,...oe}),l(Y,"args",{name:u.Args.string({required:!0})});let je=Y;var F;let gt=(F=class extends u.Command{async run(){const{flags:e,args:t}=await this.parse(F),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):m.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"]}},numCpu:Math.max(fe.cpus().length-2,1)}};if(n.createLocal(s,b),b.binaryPath||b.sourcesPath){r.info(`Instance '${s}' was created. To start it run 'up' command`);return}Se(r,{version:e.version}).then(()=>r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(v){r.error(v.message)})}},l(F,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(F,"examples",["<%= config.bin %> <%= command.id %>"]),l(F,"flags",{...L,...M,...B,...Pe,...ve,...ke,...j,...U,...ce,...ie,...oe,...we,...pe,...G}),l(F,"args",{name:u.Args.string({required:!0})}),F);const V=class V extends u.Command{async run(){const{flags:e,args:t}=await this.parse(V),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):m.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(V,"description","Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"),l(V,"examples",["<%= config.bin %> <%= command.id %>"]),l(V,"flags",{...L,...B,...he,...M,...ye,...G,...j,...be,...U,...hr}),l(V,"args",{name:u.Args.string({required:!0})});let Be=V;const K=class K extends u.Command{async run(){const{flags:e,args:t}=await this.parse(K),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):m.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"]}},numCpu:Math.max(fe.cpus().length-2,1)}};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}Se(r,{version:e.version}).then(()=>r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(v){r.error(v.message)})}};l(K,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(K,"examples",["<%= config.bin %> <%= command.id %>"]),l(K,"flags",{...L,...M,...qe,...B,...Pe,...ve,...ke,...j,...U,...ce,...ie,...oe,...we,...pe,...G}),l(K,"args",{name:u.Args.string({required:!0})});let Ue=K;const ut={"create-block":Ee,reset:Te,start:xe,stop:De,"start:docker":ct,"start:local":ot,"svc:delete":_e,"svc:down":Ne,"svc:list":Ce,"svc:up":Me,"start:docker:s3":lt,"start:local:s3":dt,"svc:create:docker":je,"svc:create:local":gt,"svc:create:docker:s3":Be,"svc:create:local:s3":Ue};exports.COMMANDS=ut;
126
+ `)}}function Fe(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 te=class te extends u.Command{async run(){const{flags:e}=await this.parse(te),t=A(e["log-level"]);new I(t).cleanupInstance()}};l(te,"description","Clear service state (forget last run command, destroy docker services, volumes and so on)"),l(te,"examples",["<%= config.bin %> <%= command.id %>"]),l(te,"flags",{...L});let xe=te;const ae=class ae extends u.Command{async run(){const{flags:e}=await this.parse(ae),t=A(e["log-level"]);new I(t).startLast()}};l(ae,"description","Start last run service configuraiton"),l(ae,"examples",["<%= config.bin %> <%= command.id %>"]),l(ae,"flags",{...L});let De=ae;const ne=class ne extends u.Command{async run(){const{flags:e}=await this.parse(ne),t=A(e["log-level"]),r=new I(t);m.currentInstance?r.stopInstance(m.currentInstance):t.warn("up/start command was not called for any instance, nothing to stop")}};l(ne,"description","Stop platforma service"),l(ne,"examples",["<%= config.bin %> <%= command.id %>"]),l(ne,"flags",{...L});let _e=ne;var R;let ct=(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",s=e["auth-enabled"],i=s?{enabled:s,drivers:r.initAuthDriversList(e,".")}:void 0,c=e.storage?h.join(".",e.storage):m.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(R,"description","Run platforma backend service with 'FS' primary storage type"),l(R,"examples",["<%= config.bin %> <%= command.id %>"]),l(R,"flags",{...L,...B,...he,...M,...ye,...G,...j,...we,...U,...ce,...ie,...oe}),R);var T;let ot=(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",s=e["pl-workdir"]??".",i=e.storage?h.join(s,e.storage):m.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"]}},numCpu:Math.max(fe.cpus().length-2,1)}},b=r.createLocal(n,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):$e(t,{version:e.version}).then(()=>{const v=r.switchInstance(b);setTimeout(()=>{for(const $ of v)$.unref()},1e3)}).catch(function(v){t.error(v.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,...M,...B,...ve,...ke,...Se,...j,...U,...ce,...ie,...oe,...pe,...Pe,...G}),T);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;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(H,"description","List available instances"),l(H,"examples",["<%= config.bin %> <%= command.id %>"]),l(H,"flags",{...L,all:u.Flags.boolean({description:"remove all known instances",required:!1})}),l(H,"args",{name:u.Args.string({required:!1})});let Ne=H;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),s=t.name??m.currentInstanceName;s||(r.info("no pl service instance selected. No service was stopped"),process.exit(0)),n.stopInstance(m.getInstanceInfo(s))}};l(W,"description","List available instances"),l(W,"examples",["<%= config.bin %> <%= command.id %>"]),l(W,"flags",{...L}),l(W,"args",{name:u.Args.string({required:!1})});let Ce=W;const se=class se extends u.Command{async run(){await this.parse(se);const e=m.instanceList,t=m.currentInstanceName;for(const r of e){const n=[],s=m.getInstanceInfo(r);m.isInstanceActive(s)&&n.push("status:up"),n.push(`type:${s.type}`),console.log(r===t?` * ${r} (${n.join(", ")})`:` ${r} (${n.join(", ")})`)}}};l(se,"description","List available instances"),l(se,"examples",["<%= config.bin %> <%= command.id %>"]),l(se,"flags",{});let Me=se;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),s=t.name??m.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(m.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(z,"description","List available instances"),l(z,"examples",["<%= config.bin %> <%= command.id %>"]),l(z,"flags",{...L}),l(z,"args",{name:u.Args.string({required:!1})});let je=z;var x;let lt=(x=class extends u.Command{async run(){const{flags:e}=await this.parse(x),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):m.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"],s3Port:e["s3-port"],s3ConsolePort:e["s3-console-port"],presignHost:d});r.switchInstance(y)}},l(x,"description","Run platforma backend service with 'S3' primary storage type"),l(x,"examples",["<%= config.bin %> <%= command.id %>"]),l(x,"flags",{...L,...B,...be,...he,...M,...ye,...G,...j,...we,...U,...hr}),x);var D;let dt=(D=class extends u.Command{async run(){const{flags:e}=await this.parse(D),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):m.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}},numCpu:Math.max(fe.cpus().length-2,1),storages:{work:{type:"FS",rootPath:e["storage-work"]}}}},b=r.createLocalS3(n,p);p.binaryPath||p.sourcesPath?r.switchInstance(b):await $e(t,{version:e.version}).then(()=>{const v=r.switchInstance(b),$=[];for(const k of v)$.push(new Promise((P,S)=>{k.on("close",P),k.on("error",S)}));return Promise.all($)}).catch(function(v){t.error(v.message)})}},l(D,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(D,"examples",["<%= config.bin %> <%= command.id %>"]),l(D,"flags",{...L,...M,...B,...be,...ve,...ke,...Se,...j,...U,...ce,...ie,...oe,...pe,...Pe,...G}),D);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["auth-enabled"],c=i?{enabled:i,drivers:n.initAuthDriversList(e,".")}:void 0,o=e.storage?h.join(".",e.storage):m.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(Y,"description","Run Platforma Backend service as docker container on current host"),l(Y,"examples",["<%= config.bin %> <%= command.id %>"]),l(Y,"flags",{...L,...B,...he,...M,...ye,...G,...j,...we,...U,...ce,...ie,...oe}),l(Y,"args",{name:u.Args.string({required:!0})});let Be=Y;var F;let gt=(F=class extends u.Command{async run(){const{flags:e,args:t}=await this.parse(F),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):m.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"]}},numCpu:Math.max(fe.cpus().length-2,1)}};if(n.createLocal(s,b),b.binaryPath||b.sourcesPath){r.info(`Instance '${s}' was created. To start it run 'up' command`);return}$e(r,{version:e.version}).then(()=>r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(v){r.error(v.message)})}},l(F,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(F,"examples",["<%= config.bin %> <%= command.id %>"]),l(F,"flags",{...L,...M,...B,...ve,...ke,...Se,...j,...U,...ce,...ie,...oe,...pe,...Pe,...G}),l(F,"args",{name:u.Args.string({required:!0})}),F);const V=class V extends u.Command{async run(){const{flags:e,args:t}=await this.parse(V),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):m.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"],s3Port:e["s3-port"],s3ConsolePort:e["s3-console-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(V,"description","Run Platforma Backend service as docker container on current host with MinIO as local S3 storage"),l(V,"examples",["<%= config.bin %> <%= command.id %>"]),l(V,"flags",{...L,...B,...be,...he,...M,...ye,...G,...j,...we,...U,...hr}),l(V,"args",{name:u.Args.string({required:!0})});let Ue=V;const K=class K extends u.Command{async run(){const{flags:e,args:t}=await this.parse(K),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):m.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"]}},numCpu:Math.max(fe.cpus().length-2,1)}};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}$e(r,{version:e.version}).then(()=>r.info(`Instance '${s}' was created. To start it run 'svc up' command`)).catch(function(v){r.error(v.message)})}};l(K,"description","Run Platforma Backend service as local process on current host (no docker container)"),l(K,"examples",["<%= config.bin %> <%= command.id %>"]),l(K,"flags",{...L,...M,...be,...B,...ve,...ke,...Se,...j,...U,...ce,...ie,...oe,...pe,...Pe,...G}),l(K,"args",{name:u.Args.string({required:!0})});let Ge=K;const ut={"create-block":Re,reset:xe,start:De,stop:_e,"start:docker":ct,"start:local":ot,"svc:delete":Ne,"svc:down":Ce,"svc:list":Me,"svc:up":je,"start:docker:s3":lt,"start:local:s3":dt,"svc:create:docker":Be,"svc:create:local":gt,"svc:create:docker:s3":Ue,"svc:create:local:s3":Ge};exports.COMMANDS=ut;
127
127
  //# sourceMappingURL=index.js.map