@runium/cli 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname as h}from"node:path";import{Option as j}from"commander";import{Container as u}from"typedi";import{ProjectEvent as d,RuniumError as m}from"@runium/core";import{ErrorCode as f}from"../../constants/index.js";import{ShutdownService as P}from"../../services/index.js";import{ProjectStateCommand as S}from"./project-state-command.js";class x extends S{shutdownService;fileWriter=null;constructor(e){super(e),this.shutdownService=u.get(P)}config(){this.command.name("start").description("start project").option("-f, --file","use file path instead of project name").option("-o, --output","output project state changes").addOption(new j("-w, --working-dir <choice>","set working directory").choices(["cwd","project"]).default("cwd")).argument("<name>","project name")}async handle(e,{file:
|
|
1
|
+
import{dirname as h}from"node:path";import{Option as j}from"commander";import{Container as u}from"typedi";import{ProjectEvent as d,RuniumError as m}from"@runium/core";import{ErrorCode as f}from"../../constants/index.js";import{ShutdownService as P}from"../../services/index.js";import{ProjectStateCommand as S}from"./project-state-command.js";class x extends S{shutdownService;fileWriter=null;constructor(e){super(e),this.shutdownService=u.get(P)}config(){this.command.name("start").description("start project").option("-f, --file","use file path instead of project name").option("-o, --output","output project state changes").addOption(new j("-w, --working-dir <choice>","set working directory").choices(["cwd","project"]).default("cwd")).argument("<name>","project name")}async handle(e,{file:i,workingDir:p,output:c}){const o=i?this.projectService.resolvePath(e):this.ensureProfileProject(e).path,s=this.getProjectDataFileName(i?o:e),t=this.profileService.getPath("projects",s),r=await this.readProjectData(t);if(r&&this.isProjectProcessStarted(r.pid))throw new m(`Project "${e}" is already started`,f.PROJECT_ALREADY_STARTED,{name:e});if(p==="project"){const n=h(o);n!==process.cwd()&&process.chdir(n)}const a=await this.projectService.initProject(o);this.shutdownService.addBlocker(n=>a.stop(n)),await this.fileService.ensureDirExists(h(t)),this.fileWriter=this.fileService.createAtomicWriter(t),this.addProjectListeners(a,{projectPath:o,output:c}),await this.projectService.runHook("project.beforeStart",{project:a,path:o,name:i?null:e}),await a.start()}addProjectListeners(e,i){const{projectPath:p,output:c}=i,o={id:e.getConfig().id,pid:process.pid,cwd:process.cwd(),path:p,state:{project:[],tasks:{}}},s=()=>{this.fileWriter.writeJson(o).then()};s(),e.on(d.STATE_CHANGE,async t=>{o.state.project.push(t),s(),c&&this.outputService.info("Project %s",t.status)}),e.on(d.TASK_STATE_CHANGE,(t,r)=>{o.state.tasks[t]||(o.state.tasks[t]=[]),o.state.tasks[t].push(r),s(),c&&this.outputService.info("Task %s %s %s",t,r.status,r.exitCode||r.error||"")}),e.on(d.STATE_CHANGE,t=>{t.status==="stopped"&&t.reason==="action"&&this.shutdownService.shutdown("project-stop")})}}export{x as ProjectStartCommand};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var w=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)}},f,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 T,ProjectEvent as A,ProjectStatus as I}from"@runium/core";import{RuniumCommand as N}from"../commands/runium-command.js";import{CommandService as S,FileService as b,OutputLevel as g,OutputService as y,ProfileService as _,ShutdownService as P}from"./index.js";import{getVersion as B,convertPathToValidFileName as D}from"../utils/index.js";import{ErrorCode as J}from"../constants/index.js";global.runium=null;let d=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:N,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:A,ProjectStatus:I,TaskEvent:L,TaskStatus:T},utils:{applyMacros:C,isRuniumError:W,pathToId:D},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:B()};global.runium=Object.freeze(o)}};d=w([R(),c(0,s()),c(1,s()),c(2,s()),c(3,s()),c(4,s()),j("design:paramtypes",[typeof(f=typeof S<"u"&&S)=="function"?f:Object,typeof(p=typeof y<"u"&&y)=="function"?p:Object,typeof(l=typeof P<"u"&&P)=="function"?l:Object,typeof(m=typeof b<"u"&&b)=="function"?m:Object,typeof(v=typeof _<"u"&&_)=="function"?v:Object])],d);export{d as PluginContextService};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const n=200;function i(
|
|
1
|
+
const n=200;function i(t,r="-"){let e=t.trim();e=e.replace(/^\/+/,""),e=e.replace(/[/\\]/g,r),e=e.replace(/[.<>:"|?*\x00-\x1F]/g,r),e=e.replace(/^[.\s]+|[.\s]+$/g,"");const g=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}+`,"g");return e=e.replace(g,r),e.length>200&&(e=e.substring(0,200)),e.toLowerCase()}export{i as convertPathToValidFileName};
|