@runium/cli 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var _=(R=>(R.FILE_READ_JSON_ERROR="file-read-json-error",R.FILE_WRITE_JSON_ERROR="file-write-json-error",R.FILE_READ_ERROR="file-read-error",R.FILE_WRITE_ERROR="file-write-error",R.FILE_CREATE_DIR_ERROR="file-create-dir-error",R.PLUGIN_NOT_FOUND="plugin-not-found",R.PLUGIN_FILE_NOT_FOUND="plugin-file-not-found",R.PLUGIN_INCORRECT_MODULE="plugin-incorrect-module",R.PLUGIN_INVALID="plugin-invalid",R.PLUGIN_PATH_RESOLVE_ERROR="plugin-path-resolve-error",R.PLUGIN_LOAD_ERROR="plugin-load-error",R.PLUGIN_HOOK_ERROR="plugin-hook-error",R.PROJECT_ALREADY_STARTED="project-already-started",R.PROJECT_NOT_STARTED="project-not-started",R.PROJECT_STOP_ERROR="project-stop-error",R.PROJECT_NOT_FOUND="project-not-found",R.PROJECT_FILE_NOT_FOUND="project-file-not-found",R.PROJECT_FILE_CAN_NOT_READ="project-file-can-not-read",R.PROJECT_JSON_PARSE_ERROR="project-json-parse-error",R.INVALID_ARGUMENT="invalid-argument",R.INVALID_PATH="invalid-path",R.CONFIG_INVALID_DATA="config-invalid-data",R.COMMAND_REGISTRATION_ERROR="command-registration-error",R.COMMAND_INCORRECT="command-incorrect",R.COMMAND_NOT_FOUND="command-not-found",R.COMMAND_RUN_ERROR="command-run-error",R))(_||{});export{_ as ErrorCode};
1
+ var _=(R=>(R.FILE_READ_JSON_ERROR="file-read-json-error",R.FILE_WRITE_JSON_ERROR="file-write-json-error",R.FILE_READ_ERROR="file-read-error",R.FILE_WRITE_ERROR="file-write-error",R.FILE_CREATE_DIR_ERROR="file-create-dir-error",R.FILE_REMOVE_ERROR="file-remove-error",R.PLUGIN_NOT_FOUND="plugin-not-found",R.PLUGIN_FILE_NOT_FOUND="plugin-file-not-found",R.PLUGIN_INCORRECT_MODULE="plugin-incorrect-module",R.PLUGIN_INVALID="plugin-invalid",R.PLUGIN_PATH_RESOLVE_ERROR="plugin-path-resolve-error",R.PLUGIN_LOAD_ERROR="plugin-load-error",R.PLUGIN_HOOK_ERROR="plugin-hook-error",R.PROJECT_ALREADY_STARTED="project-already-started",R.PROJECT_NOT_STARTED="project-not-started",R.PROJECT_STOP_ERROR="project-stop-error",R.PROJECT_NOT_FOUND="project-not-found",R.PROJECT_FILE_NOT_FOUND="project-file-not-found",R.PROJECT_FILE_CAN_NOT_READ="project-file-can-not-read",R.PROJECT_JSON_PARSE_ERROR="project-json-parse-error",R.INVALID_ARGUMENT="invalid-argument",R.INVALID_PATH="invalid-path",R.CONFIG_INVALID_DATA="config-invalid-data",R.COMMAND_REGISTRATION_ERROR="command-registration-error",R.COMMAND_INCORRECT="command-incorrect",R.COMMAND_NOT_FOUND="command-not-found",R.COMMAND_RUN_ERROR="command-run-error",R))(_||{});export{_ as ErrorCode};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runium/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Runium CLI",
5
5
  "author": "TheBeastApp",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "module": "./index.js",
15
15
  "dependencies": {
16
- "@runium/core": "^0.1.0",
16
+ "@runium/core": "^0.1.1",
17
17
  "@segment/ajv-human-errors": "^2.15.0",
18
18
  "commander": "^14.0.2",
19
19
  "reflect-metadata": "^0.2.2",
package/services/file.js CHANGED
@@ -1 +1 @@
1
- var m=function(r,e,t,i){var a=arguments.length,n=a<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(r,e,t,i);else for(var l=r.length-1;l>=0;l--)(c=r[l])&&(n=(a<3?c(n):a>3?c(e,t,n):c(e,t))||n);return a>3&&n&&Object.defineProperty(e,t,n),n};import{basename as u,dirname as R,join as y}from"node:path";import{access as E,constants as x,mkdir as d,readFile as h,rename as _,writeFile as f}from"node:fs/promises";import{fileURLToPath as O}from"node:url";import{Service as F}from"typedi";import{RuniumError as o}from"@runium/core";import{ErrorCode as s}from"../constants/index.js";let w=class{async read(e,t={}){try{return await h(e,{encoding:t.encoding||"utf-8"})}catch(i){throw new o(`Can not read file ${e}`,s.FILE_READ_ERROR,{path:e,options:t,original:i})}}async write(e,t,i={}){try{await f(e,t,{encoding:i.encoding||"utf-8"})}catch(a){throw new o(`Can not write file ${e}`,s.FILE_WRITE_ERROR,{path:e,data:t,options:i,original:a})}}async readJson(e){try{const t=await h(e,{encoding:"utf-8"});return JSON.parse(t)}catch(t){throw new o(`Can not read JSON file ${e}`,s.FILE_READ_JSON_ERROR,{path:e,original:t})}}async writeJson(e,t){try{await f(e,JSON.stringify(t,null,2),{encoding:"utf-8"})}catch(i){throw new o(`Can not write JSON file ${e}`,s.FILE_WRITE_JSON_ERROR,{path:e,data:t,original:i})}}async isExists(e){try{return await E(e,x.F_OK),!0}catch{return!1}}async ensureDirExists(e){try{await d(e,{recursive:!0})}catch(t){throw new o(`Can not create directory ${e}`,s.FILE_CREATE_DIR_ERROR,{path:e,original:t})}}createAtomicWriter(e){return new p(e)}};w=m([F()],w);function g(r){const e=r instanceof URL?O(r):r.toString();return y(R(e),`.${u(e)}.tmp`)}async function D(r,e,t){for(let i=0;i<e;i++)try{return await r()}catch(a){if(i<e-1)await new Promise(n=>setTimeout(n,t));else throw a}}class p{filename;tempFilename;locked=!1;prev=null;next=null;nextPromise=null;nextData=null;constructor(e){this.filename=e,this.tempFilename=g(e)}addData(e){return this.nextData=e,this.nextPromise||=new Promise((t,i)=>{this.next=[t,i]}),new Promise((t,i)=>{this.nextPromise?.then(t).catch(i)})}async writeData(e){this.locked=!0;try{await f(this.tempFilename,e,"utf-8"),await D(async()=>{await _(this.tempFilename,this.filename)},10,100),this.prev?.[0]()}catch(t){throw t instanceof Error&&this.prev?.[1](t),t}finally{if(this.locked=!1,this.prev=this.next,this.next=this.nextPromise=null,this.nextData!==null){const t=this.nextData;this.nextData=null,await this.write(t)}}}async write(e){try{await(this.locked?this.addData(e):this.writeData(e))}catch(t){throw new o(`Can not write file ${this.filename}`,s.FILE_WRITE_ERROR,{path:this.filename,data:e,original:t})}}async writeJson(e){return this.write(JSON.stringify(e,null,2))}}export{p as AtomicWriter,w as FileService};
1
+ var h=function(i,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(i,e,t,r);else for(var l=i.length-1;l>=0;l--)(s=i[l])&&(n=(a<3?s(n):a>3?s(e,t,n):s(e,t))||n);return a>3&&n&&Object.defineProperty(e,t,n),n};import{basename as u,dirname as R,join as y}from"node:path";import{access as E,constants as x,mkdir as _,readFile as m,rename as d,rm as O,writeFile as w}from"node:fs/promises";import{fileURLToPath as F}from"node:url";import{Service as g}from"typedi";import{RuniumError as o}from"@runium/core";import{ErrorCode as c}from"../constants/index.js";let f=class{async read(e,t={}){try{return await m(e,{encoding:t.encoding||"utf-8"})}catch(r){throw new o(`Can not read file ${e}`,c.FILE_READ_ERROR,{path:e,options:t,original:r})}}async write(e,t,r={}){try{await w(e,t,{encoding:r.encoding||"utf-8"})}catch(a){throw new o(`Can not write file ${e}`,c.FILE_WRITE_ERROR,{path:e,data:t,options:r,original:a})}}async readJson(e){try{const t=await m(e,{encoding:"utf-8"});return JSON.parse(t)}catch(t){throw new o(`Can not read JSON file ${e}`,c.FILE_READ_JSON_ERROR,{path:e,original:t})}}async writeJson(e,t){try{await w(e,JSON.stringify(t,null,2),{encoding:"utf-8"})}catch(r){throw new o(`Can not write JSON file ${e}`,c.FILE_WRITE_JSON_ERROR,{path:e,data:t,original:r})}}async isExists(e){try{return await E(e,x.F_OK),!0}catch{return!1}}async remove(e){try{await O(e,{recursive:!0,force:!0})}catch(t){throw new o(`Can not remove ${e}`,c.FILE_REMOVE_ERROR,{path:e,original:t})}}async ensureDirExists(e){try{await _(e,{recursive:!0})}catch(t){throw new o(`Can not create directory ${e}`,c.FILE_CREATE_DIR_ERROR,{path:e,original:t})}}createAtomicWriter(e){return new p(e)}};f=h([g()],f);function D(i){const e=i instanceof URL?F(i):i.toString();return y(R(e),`.${u(e)}.tmp`)}async function v(i,e,t){for(let r=0;r<e;r++)try{return await i()}catch(a){if(r<e-1)await new Promise(n=>setTimeout(n,t));else throw a}}class p{filename;tempFilename;locked=!1;prev=null;next=null;nextPromise=null;nextData=null;constructor(e){this.filename=e,this.tempFilename=D(e)}addData(e){return this.nextData=e,this.nextPromise||=new Promise((t,r)=>{this.next=[t,r]}),new Promise((t,r)=>{this.nextPromise?.then(t).catch(r)})}async writeData(e){this.locked=!0;try{await w(this.tempFilename,e,"utf-8"),await v(async()=>{await d(this.tempFilename,this.filename)},10,100),this.prev?.[0]()}catch(t){throw t instanceof Error&&this.prev?.[1](t),t}finally{if(this.locked=!1,this.prev=this.next,this.next=this.nextPromise=null,this.nextData!==null){const t=this.nextData;this.nextData=null,await this.write(t)}}}async write(e){try{await(this.locked?this.addData(e):this.writeData(e))}catch(t){throw new o(`Can not write file ${this.filename}`,c.FILE_WRITE_ERROR,{path:this.filename,data:e,original:t})}}async writeJson(e){return this.write(JSON.stringify(e,null,2))}}export{p as AtomicWriter,f as FileService};
@@ -1 +1 @@
1
- var P=function(a,t,e,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,t,e,r);else for(var u=a.length-1;u>=0;u--)(n=a[u])&&(i=(o<3?n(i):o>3?n(t,e,i):n(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i},j=function(a,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,t)},c=function(a,t){return function(e,r){t(e,r,a)}},d,p,l,m,v;import{delimiter as O}from"node:path";import{Inject as s,Service as R}from"typedi";import{RuniumError as h,isRuniumError as W,RuniumTask as E,RuniumTrigger as x,applyMacros as C,TaskEvent as L,TaskStatus as A,ProjectEvent as T,ProjectStatus as B}from"@runium/core";import{RuniumCommand as D}from"../commands/runium-command.js";import{CommandService as S,FileService as b,OutputLevel as g,OutputService as y,ProfileService as _,ShutdownService as w}from"./index.js";import{getVersion as I}from"../utils/index.js";import{ErrorCode as J}from"../constants/index.js";global.runium=null;let f=class{commandService;outputService;shutdownService;fileService;profileService;constructor(t,e,r,o,i){this.commandService=t,this.outputService=e,this.shutdownService=r,this.fileService=o,this.profileService=i}createStorageWrapper(t){return((...e)=>{const[r,...o]=e,i=this.resolveProfilePath(r),n=this.fileService[t];return n(i,...o)})}resolveProfilePath(t){const e=Array.isArray(t)?t:t.split(O);if(e.length===0||e.every(r=>r.trim()===""))throw new h("Invalid path",J.INVALID_PATH,{path:t});return this.profileService.getPath(...e)}async init(){const t=this.commandService,e=this.outputService,r=this.shutdownService,o={class:{RuniumCommand:D,RuniumError:h,RuniumTask:E,RuniumTrigger:x},enum:{OutputLevel:Object.keys(g).filter(i=>isNaN(Number(i))).reduce((i,n)=>(i[n]=g[n],i),{}),ProjectEvent:T,ProjectStatus:B,TaskEvent:L,TaskStatus:A},utils:{applyMacros:C,isRuniumError:W},output:{getLevel:e.getLevel.bind(e),setLevel:e.setLevel.bind(e),trace:e.trace.bind(e),debug:e.debug.bind(e),info:e.info.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),table:e.table.bind(e),log:e.log.bind(e)},shutdown:{addBlocker:r.addBlocker.bind(r),removeBlocker:r.removeBlocker.bind(r)},command:{has:t.hasCommand.bind(t),run:t.runCommand.bind(t)},storage:{read:this.createStorageWrapper("read"),write:this.createStorageWrapper("write"),readJson:this.createStorageWrapper("readJson"),writeJson:this.createStorageWrapper("writeJson"),isExists:this.createStorageWrapper("isExists"),ensureDirExists:this.createStorageWrapper("ensureDirExists"),createAtomicWriter:this.createStorageWrapper("createAtomicWriter"),getPath:this.resolveProfilePath.bind(this)},version:I()};global.runium=Object.freeze(o)}};f=P([R(),c(0,s()),c(1,s()),c(2,s()),c(3,s()),c(4,s()),j("design:paramtypes",[typeof(d=typeof S<"u"&&S)=="function"?d:Object,typeof(p=typeof y<"u"&&y)=="function"?p:Object,typeof(l=typeof w<"u"&&w)=="function"?l:Object,typeof(m=typeof b<"u"&&b)=="function"?m:Object,typeof(v=typeof _<"u"&&_)=="function"?v:Object])],f);export{f as PluginContextService};
1
+ var P=function(a,t,e,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,e):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,t,e,r);else for(var u=a.length-1;u>=0;u--)(n=a[u])&&(i=(o<3?n(i):o>3?n(t,e,i):n(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i},j=function(a,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,t)},c=function(a,t){return function(e,r){t(e,r,a)}},d,p,m,l,v;import{delimiter as O}from"node:path";import{Inject as s,Service as R}from"typedi";import{RuniumError as h,isRuniumError as W,RuniumTask as E,RuniumTrigger as x,applyMacros as C,TaskEvent as L,TaskStatus as A,ProjectEvent as T,ProjectStatus as B}from"@runium/core";import{RuniumCommand as D}from"../commands/runium-command.js";import{CommandService as S,FileService as b,OutputLevel as g,OutputService as y,ProfileService as _,ShutdownService as w}from"./index.js";import{getVersion as I}from"../utils/index.js";import{ErrorCode as J}from"../constants/index.js";global.runium=null;let f=class{commandService;outputService;shutdownService;fileService;profileService;constructor(t,e,r,o,i){this.commandService=t,this.outputService=e,this.shutdownService=r,this.fileService=o,this.profileService=i}createStorageWrapper(t){return((...e)=>{const[r,...o]=e,i=this.resolveProfilePath(r),n=this.fileService[t];return n(i,...o)})}resolveProfilePath(t){const e=Array.isArray(t)?t:t.split(O);if(e.length===0||e.every(r=>r.trim()===""))throw new h("Invalid path",J.INVALID_PATH,{path:t});return this.profileService.getPath(...e)}async init(){const t=this.commandService,e=this.outputService,r=this.shutdownService,o={class:{RuniumCommand:D,RuniumError:h,RuniumTask:E,RuniumTrigger:x},enum:{OutputLevel:Object.keys(g).filter(i=>isNaN(Number(i))).reduce((i,n)=>(i[n]=g[n],i),{}),ProjectEvent:T,ProjectStatus:B,TaskEvent:L,TaskStatus:A},utils:{applyMacros:C,isRuniumError:W},output:{getLevel:e.getLevel.bind(e),setLevel:e.setLevel.bind(e),trace:e.trace.bind(e),debug:e.debug.bind(e),info:e.info.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),table:e.table.bind(e),log:e.log.bind(e)},shutdown:{addBlocker:r.addBlocker.bind(r),removeBlocker:r.removeBlocker.bind(r)},command:{has:t.hasCommand.bind(t),run:t.runCommand.bind(t)},storage:{read:this.createStorageWrapper("read"),write:this.createStorageWrapper("write"),readJson:this.createStorageWrapper("readJson"),writeJson:this.createStorageWrapper("writeJson"),isExists:this.createStorageWrapper("isExists"),ensureDirExists:this.createStorageWrapper("ensureDirExists"),remove:this.createStorageWrapper("remove"),createAtomicWriter:this.createStorageWrapper("createAtomicWriter"),getPath:this.resolveProfilePath.bind(this)},version:I()};global.runium=Object.freeze(o)}};f=P([R(),c(0,s()),c(1,s()),c(2,s()),c(3,s()),c(4,s()),j("design:paramtypes",[typeof(d=typeof S<"u"&&S)=="function"?d:Object,typeof(p=typeof y<"u"&&y)=="function"?p:Object,typeof(m=typeof w<"u"&&w)=="function"?m:Object,typeof(l=typeof b<"u"&&b)=="function"?l:Object,typeof(v=typeof _<"u"&&_)=="function"?v:Object])],f);export{f as PluginContextService};