@joystick.js/cli-canary 0.0.0-canary.1573 → 0.0.0-canary.1575

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 p from"query-string";import{WebSocketServer as i}from"ws";import g from"../generate_id.js";import N from"./get_translations.js";process.title="joystick_hmr";var m=(()=>{const a=new i({port:parseInt(process.env.PORT,10)+1,path:"/_joystick/hmr"});process.on("message",async c=>{const e=JSON.parse(c);if(typeof process.HMR_CONNECTIONS=="object"&&e?.type){const t=Object.values(process.HMR_CONNECTIONS);for(let n=0;n<t?.length;n+=1){const s=t[n];s?.connection?.send&&(e?.type==="BUILD_ERROR"&&s.connection.send(JSON.stringify({type:"BUILD_ERROR"})),e?.type==="FILE_CHANGE"&&(console.log("SEND FILE CHANGE HMR"),s.connection.send(JSON.stringify({type:"FILE_CHANGE",settings:e?.settings?{global:e?.settings?.global,public:e?.settings?.public}:null,i18n:e?.i18n_change?await N(".joystick/build",s?.page_component_path,{headers:{"accept-language":s?.browser_language},context:{user:{language:s?.user_language}}}):null,index_html_changed:e?.index_html_change,index_css_changed:e?.index_css_change,index_client_changed:e?.index_client_change}))))}}}),a.on("connection",function(e,t={}){const n=g(16),[s,r]=t?.url?.split("?"),o=p.parse(r);process.HMR_CONNECTIONS={...process.HMR_CONNECTIONS||{},[n]:{connection:e,browser_language:o?.browser_language,user_language:o?.user_language,page_component_path:o?.page_component_path}},Object.keys(process.HMR_CONNECTIONS||{})?.length>0&&process.send({type:"HAS_HMR_CONNECTIONS"}),e.on("message",_=>{JSON.parse(_)?.type==="HMR_UPDATE_COMPLETE"&&process.send({type:"HMR_UPDATE_COMPLETE"})}),e.on("close",()=>{process.HMR_CONNECTIONS[n]&&(delete process.HMR_CONNECTIONS[n],Object.keys(process.HMR_CONNECTIONS||{})?.length===0&&process.send({type:"HAS_NO_HMR_CONNECTIONS"}))})})})();export{m as default};
1
+ import p from"query-string";import{WebSocketServer as i}from"ws";import g from"../generate_id.js";import N from"./get_translations.js";process.title="joystick_hmr";var u=(()=>{const a=new i({port:parseInt(process.env.PORT,10)+1,path:"/_joystick/hmr"});process.on("message",async c=>{const e=JSON.parse(c);if(typeof process.HMR_CONNECTIONS=="object"&&e?.type){const t=Object.values(process.HMR_CONNECTIONS);for(let n=0;n<t?.length;n+=1){const s=t[n];s?.connection?.send&&(e?.type==="BUILD_ERROR"&&s.connection.send(JSON.stringify({type:"BUILD_ERROR"})),e?.type==="FILE_CHANGE"&&s.connection.send(JSON.stringify({type:"FILE_CHANGE",settings:e?.settings?{global:e?.settings?.global,public:e?.settings?.public}:null,i18n:e?.i18n_change?await N(".joystick/build",s?.page_component_path,{headers:{"accept-language":s?.browser_language},context:{user:{language:s?.user_language}}}):null,index_html_changed:e?.index_html_change,index_css_changed:e?.index_css_change,index_client_changed:e?.index_client_change})))}}}),a.on("connection",function(e,t={}){const n=g(16),[s,r]=t?.url?.split("?"),o=p.parse(r);process.HMR_CONNECTIONS={...process.HMR_CONNECTIONS||{},[n]:{connection:e,browser_language:o?.browser_language,user_language:o?.user_language,page_component_path:o?.page_component_path}},Object.keys(process.HMR_CONNECTIONS||{})?.length>0&&process.send({type:"HAS_HMR_CONNECTIONS"}),e.on("message",_=>{JSON.parse(_)?.type==="HMR_UPDATE_COMPLETE"&&process.send({type:"HMR_UPDATE_COMPLETE"})}),e.on("close",()=>{process.HMR_CONNECTIONS[n]&&(delete process.HMR_CONNECTIONS[n],Object.keys(process.HMR_CONNECTIONS||{})?.length===0&&process.send({type:"HAS_NO_HMR_CONNECTIONS"}))})})})();export{u as default};
@@ -1,4 +1,4 @@
1
- import i from"chalk";import m from"child_process";import x from"fs";import"os";import g,{dirname as O}from"path";import{fileURLToPath as b}from"url";import k from"util";import u from"./check_if_port_occupied.js";import n from"../cli_log.js";import p from"./get_database_process_ids.js";import S from"../get_platform_safe_path.js";import y from"../kill_port_process.js";import _ from"../load_settings.js";import D from"../loader.js";import d from"../path_exists.js";import v from"../required_files.js";import T from"./start_app_server.js";import $ from"./start_databases.js";import j from"./start_hmr_server.js";import I from"./watch_for_changes/index.js";import R from"../constants.js";import N from"./kill_process_ids.js";import H from"./run_tests.js";import C from"../debounce.js";import A from"./databases/download_database_binary.js";const{stat:M}=x.promises,V=k.promisify(m.exec),l=parseInt(process?.version?.split(".")[0]?.replace("v",""),10),P=b(import.meta.url),f=O(P),h=[],L=async(s=!1)=>{const e=p();await H({watch:s,__dirname:f,process_ids:[...h,...e],cleanup_process:process.cleanup_process})},q=(s=[],e=0,t="")=>{const r=["--no-warnings"];e<19&&r.push("--experimental-specifier-resolution=node");const o=m.fork(g.resolve(`${t}/cleanup.js`),[],{detached:!0,silent:!0});process.cleanup_process=o,process.on("SIGINT",async()=>{const c=p();o.send(JSON.stringify({process_ids:[...s,...c]})),process.exit()}),process.on("SIGTERM",async()=>{const c=p();o.send(JSON.stringify({process_ids:[...s,...c]})),process.exit()})},G=async(s=[])=>{console.log(s);const e=s?.find(a=>a?.path?.match(R.SETTINGS_FILE_NAME_REGEX)?.length>0),t=s?.find(a=>a?.path?.includes("i18n")),r=s?.find(a=>a?.path?.includes("index.html")),o=s?.find(a=>a?.path?.includes("index.css")||a?.path?.incudes("css/")),c=s?.find(a=>a?.path?.includes("index.client.js"));console.log("THIS",{type:"FILE_CHANGE",settings:e?await _(process.env.NODE_ENV):null,i18n_change:!!t,index_html_change:!!r,index_css_change:!!o,index_client_change:!!c}),process.hmr_server_process.send(JSON.stringify({type:"FILE_CHANGE",settings:e?await _(process.env.NODE_ENV):null,i18n_change:!!t,index_html_change:!!r,index_css_change:!!o,index_client_change:!!c}))},J=(s=0,e=!1,t={})=>{process.hmr_server_process.on("message",async r=>{["HAS_HMR_CONNECTIONS","HAS_NO_HMR_CONNECTIONS","HMR_UPDATE_COMPLETE"].includes(r?.type)||process.loader.print(r),r?.type==="HAS_HMR_CONNECTIONS"&&(process.hmr_server_process.has_connections=!0),r?.type==="HAS_NO_HMR_CONNECTIONS"&&(process.hmr_server_process.has_connections=!1),r?.type==="HMR_UPDATE_COMPLETE"&&process.app_server_process&&!process.app_server_restarting&&(process.app_server_restarting=!0,E(s,e,t))})},F=()=>{process.hmr_server_process.on("error",s=>{n(s.toString(),{level:"danger",docs:"https://github.com/cheatcode/joystick"})}),process.hmr_server_process.stdout.on("data",s=>{console.log(s.toString())}),process.hmr_server_process.stderr.on("data",s=>{n(s.toString(),{level:"danger",docs:"https://github.com/cheatcode/joystick"})})},U=(s=0,e="",t=!1,r={})=>{process.hmr_server_process=j(s,e),h.push(process.hmr_server_process?.pid),F(),J(s,t,r)},B=async(s={})=>{const e=await _(process.env.NODE_ENV),t=e?.config?.databases?JSON.stringify(e?.config?.databases):"",r=s?.config?.databases?JSON.stringify(s?.config?.databases):"";return t!==r},E=async(s=0,e=!1,t=null)=>{C(async()=>{if(await B(t)){const o=p();n(`Database configuration has changed in settings.${process.env.NODE_ENV}.json. Please restart your app to add, change, or remove databases.`,{level:"danger",docs:"https://cheatcode.co/docs/joystick/structure"}),N([process.hmr_server_process?.pid,process.app_server_process?.pid,...o]),process.exit(0)}else N([...process.app_server_process.external_process_ids||[]]),await y(process.env.PORT),w(s,e)},300)},z=(s=!1)=>{process.app_server_process.external_process_ids=[],process.app_server_process.on("message",e=>{e?.external_process_id&&(process.app_server_process.external_process_ids=[...process.app_server_process.external_process_ids||[],e?.external_process_id])}),process.app_server_process.on("error",e=>{n(e.toString(),{level:"danger",docs:"https://github.com/cheatcode/joystick"})}),process.app_server_process.stdout.on("data",e=>{const t=e.toString(),r=t.includes("App running at:");t&&r&&process.env.NODE_ENV!=="test"&&process.loader.print(t),t&&!r&&!t.includes("BUILD_ERROR")&&console.log(t),t&&r&&process.env.NODE_ENV==="test"&&L(s)}),process.app_server_process.stderr.on("data",e=>{n(e.toString(),{level:"danger",docs:"https://cheatcode.co/docs/joystick"})})},w=(s=0,e=!1)=>{process.app_server_process=T(s,e),h.push(process.app_server_process?.pid),z(e),process.app_server_restarting=!1},X=async(s={})=>{const e=s?.config?.databases?.map((t={})=>t?.provider);for(let t=0;t<e?.length;t+=1){const r=e[t];await A(r)}},K=(s={},e=2600)=>{process.title=s?.environment==="test"?"joystick_test":"joystick",process.project_folder=g.basename(process.cwd()),process.loader=new D,s?.environment==="test"&&process.loader.print("Initializing test environment..."),process.env.LOGS_PATH=s?.logs||null,process.env.NODE_ENV=s?.environment||"development",process.env.PORT=e,process.env.IS_DEBUG_MODE=s?.debug},Q=(s=2600)=>{n(`Port ${s} is already occupied. To start Joystick on this port, clear it and try again.`,{level:"danger"}),process.exit(0)},W=(s=2600)=>parseInt(s||2600,10),Y=async()=>{const s=S(`${process.cwd()}/.joystick/build`);await d(s)&&await V(`${process.platform==="win32"?"rmdir /s /q":"rm -rf"} ${s}`)},Z=async()=>{const s=[];for(let e=0;e<v?.length;e+=1){const t=v[e],r=await d(`${process.cwd()}/${t.path}`),o=r&&await M(`${process.cwd()}/${t.path}`);t&&t.type==="file"&&(!r||r&&!o.isFile())&&s.push({type:"file",path:t.path}),t&&t.type==="directory"&&(!r||r&&!o.isDirectory())&&s.push({type:"directory",path:t.path})}if(s?.length>0){const e=s?.filter(o=>o.type==="file"),t=s?.filter(o=>o.type==="directory");let r=`The following paths are missing and required in a Joystick project:
1
+ import i from"chalk";import m from"child_process";import x from"fs";import"os";import g,{dirname as O}from"path";import{fileURLToPath as b}from"url";import k from"util";import u from"./check_if_port_occupied.js";import n from"../cli_log.js";import p from"./get_database_process_ids.js";import S from"../get_platform_safe_path.js";import y from"../kill_port_process.js";import h from"../load_settings.js";import $ from"../loader.js";import _ from"../path_exists.js";import v from"../required_files.js";import j from"./start_app_server.js";import D from"./start_databases.js";import T from"./start_hmr_server.js";import R from"./watch_for_changes/index.js";import I from"../constants.js";import N from"./kill_process_ids.js";import H from"./run_tests.js";import C from"../debounce.js";import M from"./databases/download_database_binary.js";const{stat:A}=x.promises,P=k.promisify(m.exec),d=parseInt(process?.version?.split(".")[0]?.replace("v",""),10),V=b(import.meta.url),f=O(V),l=[],q=async(s=!1)=>{const e=p();await H({watch:s,__dirname:f,process_ids:[...l,...e],cleanup_process:process.cleanup_process})},L=(s=[],e=0,t="")=>{const r=["--no-warnings"];e<19&&r.push("--experimental-specifier-resolution=node");const o=m.fork(g.resolve(`${t}/cleanup.js`),[],{detached:!0,silent:!0});process.cleanup_process=o,process.on("SIGINT",async()=>{const c=p();o.send(JSON.stringify({process_ids:[...s,...c]})),process.exit()}),process.on("SIGTERM",async()=>{const c=p();o.send(JSON.stringify({process_ids:[...s,...c]})),process.exit()})},G=async(s=[])=>{const e=s?.find(a=>a?.path?.match(I.SETTINGS_FILE_NAME_REGEX)?.length>0),t=s?.find(a=>a?.path?.includes("i18n")),r=s?.find(a=>a?.path?.includes("index.html")),o=s?.find(a=>a?.path?.includes("index.css")||a?.path?.includes("css/")),c=s?.find(a=>a?.path?.includes("index.client.js"));process.hmr_server_process.send(JSON.stringify({type:"FILE_CHANGE",settings:e?await h(process.env.NODE_ENV):null,i18n_change:!!t,index_html_change:!!r,index_css_change:!!o,index_client_change:!!c}))},J=(s=0,e=!1,t={})=>{process.hmr_server_process.on("message",async r=>{["HAS_HMR_CONNECTIONS","HAS_NO_HMR_CONNECTIONS","HMR_UPDATE_COMPLETE"].includes(r?.type)||process.loader.print(r),r?.type==="HAS_HMR_CONNECTIONS"&&(process.hmr_server_process.has_connections=!0),r?.type==="HAS_NO_HMR_CONNECTIONS"&&(process.hmr_server_process.has_connections=!1),r?.type==="HMR_UPDATE_COMPLETE"&&process.app_server_process&&!process.app_server_restarting&&(process.app_server_restarting=!0,w(s,e,t))})},U=()=>{process.hmr_server_process.on("error",s=>{n(s.toString(),{level:"danger",docs:"https://github.com/cheatcode/joystick"})}),process.hmr_server_process.stdout.on("data",s=>{console.log(s.toString())}),process.hmr_server_process.stderr.on("data",s=>{n(s.toString(),{level:"danger",docs:"https://github.com/cheatcode/joystick"})})},F=(s=0,e="",t=!1,r={})=>{process.hmr_server_process=T(s,e),l.push(process.hmr_server_process?.pid),U(),J(s,t,r)},B=async(s={})=>{const e=await h(process.env.NODE_ENV),t=e?.config?.databases?JSON.stringify(e?.config?.databases):"",r=s?.config?.databases?JSON.stringify(s?.config?.databases):"";return t!==r},w=async(s=0,e=!1,t=null)=>{C(async()=>{if(await B(t)){const o=p();n(`Database configuration has changed in settings.${process.env.NODE_ENV}.json. Please restart your app to add, change, or remove databases.`,{level:"danger",docs:"https://cheatcode.co/docs/joystick/structure"}),N([process.hmr_server_process?.pid,process.app_server_process?.pid,...o]),process.exit(0)}else N([...process.app_server_process.external_process_ids||[]]),await y(process.env.PORT),E(s,e)},300)},z=(s=!1)=>{process.app_server_process.external_process_ids=[],process.app_server_process.on("message",e=>{e?.external_process_id&&(process.app_server_process.external_process_ids=[...process.app_server_process.external_process_ids||[],e?.external_process_id])}),process.app_server_process.on("error",e=>{n(e.toString(),{level:"danger",docs:"https://github.com/cheatcode/joystick"})}),process.app_server_process.stdout.on("data",e=>{const t=e.toString(),r=t.includes("App running at:");t&&r&&process.env.NODE_ENV!=="test"&&process.loader.print(t),t&&!r&&!t.includes("BUILD_ERROR")&&console.log(t),t&&r&&process.env.NODE_ENV==="test"&&q(s)}),process.app_server_process.stderr.on("data",e=>{n(e.toString(),{level:"danger",docs:"https://cheatcode.co/docs/joystick"})})},E=(s=0,e=!1)=>{process.app_server_process=j(s,e),l.push(process.app_server_process?.pid),z(e),process.app_server_restarting=!1},X=async(s={})=>{const e=s?.config?.databases?.map((t={})=>t?.provider);for(let t=0;t<e?.length;t+=1){const r=e[t];await M(r)}},K=(s={},e=2600)=>{process.title=s?.environment==="test"?"joystick_test":"joystick",process.project_folder=g.basename(process.cwd()),process.loader=new $,s?.environment==="test"&&process.loader.print("Initializing test environment..."),process.env.LOGS_PATH=s?.logs||null,process.env.NODE_ENV=s?.environment||"development",process.env.PORT=e,process.env.IS_DEBUG_MODE=s?.debug},Q=(s=2600)=>{n(`Port ${s} is already occupied. To start Joystick on this port, clear it and try again.`,{level:"danger"}),process.exit(0)},W=(s=2600)=>parseInt(s||2600,10),Y=async()=>{const s=S(`${process.cwd()}/.joystick/build`);await _(s)&&await P(`${process.platform==="win32"?"rmdir /s /q":"rm -rf"} ${s}`)},Z=async()=>{const s=[];for(let e=0;e<v?.length;e+=1){const t=v[e],r=await _(`${process.cwd()}/${t.path}`),o=r&&await A(`${process.cwd()}/${t.path}`);t&&t.type==="file"&&(!r||r&&!o.isFile())&&s.push({type:"file",path:t.path}),t&&t.type==="directory"&&(!r||r&&!o.isDirectory())&&s.push({type:"directory",path:t.path})}if(s?.length>0){const e=s?.filter(o=>o.type==="file"),t=s?.filter(o=>o.type==="directory");let r=`The following paths are missing and required in a Joystick project:
2
2
 
3
3
  `;if(e?.length>0){r+=` ${i.yellow(">")} Required Files:
4
4
 
@@ -7,4 +7,4 @@ ${a&&t?.length>0?`
7
7
  `:""}`)}`}}if(t?.length>0){r+=` ${i.yellow(">")} Required Directories:
8
8
 
9
9
  `;for(let o=0;o<t?.length;o+=1){const c=t[o];r+=` ${i.red(`/${c.path}
10
- `)}`}}n(r,{level:"danger",docs:"https://cheatcode.co/docs/joystick/structure"}),process.exit(0)}},ss=async()=>{const s=await d(`${process.cwd()}/.joystick`),e=await d(`${process.cwd()}/tests`);process.env.NODE_ENV==="test"&&(!s||!e)&&(n("joystick test must be run in a directory with a .joystick folder and tests folder.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/cli/test"}),process.exit(0)),process.env.NODE_ENV!=="test"&&!s&&(n("joystick start must be run in a directory with a .joystick folder.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/cli/start"}),process.exit(0))},es=async(s={})=>{await ss(),await Z(),await Y();const e=W(s?.port),t=await u(e),r=await u(e+1);t&&Q(e),r&&y(e),K(s,e);const o=await _(process.env.NODE_ENV);await X(o),await $({environment:process.env.NODE_ENV,port:e,settings:o}),I({hot_module_reload:(c=[])=>G(c),restart_app_server:()=>E(l,s?.watch,o),start_app_server:()=>w(l,s?.watch),start_hmr_server:s?.environment!=="test"?()=>U(l,f,s?.watch,o):null},{excluded_paths:o?.config?.build?.excluded_paths,custom_copy_paths:o?.config?.build?.copy_paths?.map(c=>({path:c}))||[]}),q(h,l,f)};var Ds=es;export{Ds as default};
10
+ `)}`}}n(r,{level:"danger",docs:"https://cheatcode.co/docs/joystick/structure"}),process.exit(0)}},ss=async()=>{const s=await _(`${process.cwd()}/.joystick`),e=await _(`${process.cwd()}/tests`);process.env.NODE_ENV==="test"&&(!s||!e)&&(n("joystick test must be run in a directory with a .joystick folder and tests folder.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/cli/test"}),process.exit(0)),process.env.NODE_ENV!=="test"&&!s&&(n("joystick start must be run in a directory with a .joystick folder.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/cli/start"}),process.exit(0))},es=async(s={})=>{await ss(),await Z(),await Y();const e=W(s?.port),t=await u(e),r=await u(e+1);t&&Q(e),r&&y(e),K(s,e);const o=await h(process.env.NODE_ENV);await X(o),await D({environment:process.env.NODE_ENV,port:e,settings:o}),R({hot_module_reload:(c=[])=>G(c),restart_app_server:()=>w(d,s?.watch,o),start_app_server:()=>E(d,s?.watch),start_hmr_server:s?.environment!=="test"?()=>F(d,f,s?.watch,o):null},{excluded_paths:o?.config?.build?.excluded_paths,custom_copy_paths:o?.config?.build?.copy_paths?.map(c=>({path:c}))||[]}),L(l,d,f)};var $s=es;export{$s as default};
@@ -1 +1 @@
1
- import f from"chokidar";import h from"fs";import{dirname as m}from"path";import y from"../../build/build_files.js";import g from"../../debounce.js";import o from"./get_after_run_tasks.js";import k from"./get_file_codependencies.js";import l from"../../build/get_file_operation.js";import v from"../../build/get_path_platform.js";import w from"../../types.js";import R from"./watch_paths.js";const{mkdir:p,copyFile:O,rm:u}=h.promises,n=async(e={},s={})=>{const a=process.initial_build_complete?await k(e?.path):[];if(s?.is_build_file&&await y({files:[{path:e?.path,platform:v(e?.path)}]}).catch((r=[])=>{if(!process.initial_build_complete&&r?.length>0&&process.exit(0),process.initial_build_complete&&r?.length>0)throw process.app_server_process.send(JSON.stringify({type:"BUILD_ERROR",paths:r.filter(({success:t})=>!t)})),process.hmr_server_process.send(JSON.stringify({type:"BUILD_ERROR"})),new Error("BUILD_ERROR")}),a?.length>0)for(let r=0;r<a?.length;r+=1){const t=a[r];await n({path:t},s)}return Promise.resolve()},b=async(e={})=>{switch(e?.operation){case"add_directory":return p(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return n(e,{is_build_file:!0});case"copy_file":return await p(m(`.joystick/build/${e?.path}`),{recursive:!0}),await O(e?.path,`.joystick/build/${e?.path}`),n(e,{is_build_file:!1});case"delete_directory":return u(`.joystick/build/${e?.path}`,{recursive:!0});case"delete_file":return await u(`.joystick/build/${e?.path}`,{recursive:!0}),n(e,{is_build_file:!1});default:return!0}},x=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?o(e?.path):["start_app_server","start_hmr_server"]}),D=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?o(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?o(e?.path):["start_app_server","start_hmr_server"]}),B=(e={})=>({operation:e?.is_custom_copy_path?"copy_file":l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?o(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:e?.is_custom_copy_path?"copy_file":l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?o(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>{switch(e?.event){case"add_file":return E(e);case"change_file":return B(e);case"delete_file":return $(e);case"add_directory":return D(e);case"delete_directory":return x(e)}},J=async(e=[],s={})=>{try{const a=new Set([]);for(let t=0;t<e?.length;t+=1){const i=e[t],c=I(i);if(console.log("JOB",c),await b(c),c?.after_run_tasks)for(let _=0;_<c?.after_run_tasks?.length;_+=1){const d=c?.after_run_tasks[_];a.add(d)}}const r=Array.from(a);for(let t=0;t<r?.length;t+=1){const i=r[t];console.log("ART",i),w.is_function(s[i])&&await s[i](e)}}catch{}},L=(e="")=>{switch(e){case"add":return"add_file";case"change":return"change_file";case"unlink":return"delete_file";case"addDir":return"add_directory";case"unlinkDir":return"delete_directory"}},S=(e={},s={})=>{const a=f.watch([...R,...s?.custom_copy_paths||[]].map(({path:t})=>t),{ignored:".joystick"});let r=[];process.initial_build_complete=!1,a.on("error",t=>console.error(t)),a.on("all",(t,i)=>{s?.excluded_paths?.some(_=>i.includes(_))||(r.push({event:L(t),path:i,is_custom_copy_path:s?.custom_copy_paths?.length?s?.custom_copy_paths.some(_=>i.includes(_?.path)):!1}),g(async()=>{console.log(r),await J(r,e),process.initial_build_complete=!0,r=[]},100))})};var K=S;export{K as default};
1
+ import f from"chokidar";import h from"fs";import{dirname as m}from"path";import y from"../../build/build_files.js";import k from"../../debounce.js";import n from"./get_after_run_tasks.js";import v from"./get_file_codependencies.js";import p from"../../build/get_file_operation.js";import g from"../../build/get_path_platform.js";import w from"../../types.js";import R from"./watch_paths.js";const{mkdir:l,copyFile:b,rm:u}=h.promises,o=async(e={},s={})=>{const a=process.initial_build_complete?await v(e?.path):[];if(s?.is_build_file&&await y({files:[{path:e?.path,platform:g(e?.path)}]}).catch((r=[])=>{if(!process.initial_build_complete&&r?.length>0&&process.exit(0),process.initial_build_complete&&r?.length>0)throw process.app_server_process.send(JSON.stringify({type:"BUILD_ERROR",paths:r.filter(({success:t})=>!t)})),process.hmr_server_process.send(JSON.stringify({type:"BUILD_ERROR"})),new Error("BUILD_ERROR")}),a?.length>0)for(let r=0;r<a?.length;r+=1){const t=a[r];await o({path:t},s)}return Promise.resolve()},x=async(e={})=>{switch(e?.operation){case"add_directory":return l(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return o(e,{is_build_file:!0});case"copy_file":return await l(m(`.joystick/build/${e?.path}`),{recursive:!0}),await b(e?.path,`.joystick/build/${e?.path}`),o(e,{is_build_file:!1});case"delete_directory":return u(`.joystick/build/${e?.path}`,{recursive:!0});case"delete_file":return await u(`.joystick/build/${e?.path}`,{recursive:!0}),o(e,{is_build_file:!1});default:return!0}},D=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?n(e?.path):["start_app_server","start_hmr_server"]}),O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?n(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?n(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:e?.is_custom_copy_path?"copy_file":p(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?n(e?.path):["start_app_server","start_hmr_server"]}),B=(e={})=>({operation:e?.is_custom_copy_path?"copy_file":p(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?n(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>{switch(e?.event){case"add_file":return B(e);case"change_file":return E(e);case"delete_file":return $(e);case"add_directory":return O(e);case"delete_directory":return D(e)}},L=async(e=[],s={})=>{try{const a=new Set([]);for(let t=0;t<e?.length;t+=1){const i=e[t],c=I(i);if(await x(c),c?.after_run_tasks)for(let _=0;_<c?.after_run_tasks?.length;_+=1){const d=c?.after_run_tasks[_];a.add(d)}}const r=Array.from(a);for(let t=0;t<r?.length;t+=1){const i=r[t];w.is_function(s[i])&&await s[i](e)}}catch{}},S=(e="")=>{switch(e){case"add":return"add_file";case"change":return"change_file";case"unlink":return"delete_file";case"addDir":return"add_directory";case"unlinkDir":return"delete_directory"}},U=(e={},s={})=>{const a=f.watch([...R,...s?.custom_copy_paths||[]].map(({path:t})=>t),{ignored:".joystick"});let r=[];process.initial_build_complete=!1,a.on("error",t=>console.error(t)),a.on("all",(t,i)=>{s?.excluded_paths?.some(_=>i.includes(_))||(r.push({event:S(t),path:i,is_custom_copy_path:s?.custom_copy_paths?.length?s?.custom_copy_paths.some(_=>i.includes(_?.path)):!1}),k(async()=>{await L(r,e),process.initial_build_complete=!0,r=[]},100))})};var M=U;export{M as default};
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@joystick.js/cli-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.1573",
5
- "canary_version": "0.0.0-canary.1572",
4
+ "version": "0.0.0-canary.1575",
5
+ "canary_version": "0.0.0-canary.1574",
6
6
  "description": "The CLI for Joystick.",
7
7
  "main": "dist/index.js",
8
8
  "bin": {
@@ -26,7 +26,6 @@ export default (() => {
26
26
  }
27
27
 
28
28
  if (parsed_message?.type === 'FILE_CHANGE') {
29
- console.log('SEND FILE CHANGE HMR');
30
29
  connection.connection.send(
31
30
  JSON.stringify({
32
31
  type: "FILE_CHANGE",
@@ -84,25 +84,14 @@ const handle_signal_events = (process_ids = [], node_major_version = 0, __dirnam
84
84
  };
85
85
 
86
86
  const handle_signal_hmr_update = async (jobs = []) => {
87
- console.log(jobs);
88
-
89
87
  const has_settings_change = jobs?.find((job) => (job?.path?.match(constants.SETTINGS_FILE_NAME_REGEX))?.length > 0);
90
88
  const has_i18n_change = jobs?.find((job) => job?.path?.includes('i18n'));
91
89
  const has_index_html_change = jobs?.find((job) => job?.path?.includes('index.html'));
92
90
  const has_index_css_change = jobs?.find((job) => {
93
- return job?.path?.includes('index.css') || job?.path?.incudes('css/');
91
+ return job?.path?.includes('index.css') || job?.path?.includes('css/');
94
92
  });
95
93
  const has_index_client_change = jobs?.find((job) => job?.path?.includes('index.client.js'));
96
94
 
97
- console.log('THIS', {
98
- type: 'FILE_CHANGE',
99
- settings: has_settings_change ? await load_settings(process.env.NODE_ENV) : null,
100
- i18n_change: !!has_i18n_change,
101
- index_html_change: !!has_index_html_change,
102
- index_css_change: !!has_index_css_change,
103
- index_client_change: !!has_index_client_change,
104
- });
105
-
106
95
  process.hmr_server_process.send(JSON.stringify({
107
96
  type: 'FILE_CHANGE',
108
97
  settings: has_settings_change ? await load_settings(process.env.NODE_ENV) : null,
@@ -139,8 +139,6 @@ const process_file_watcher_jobs = async (jobs = [], after_run_functions = {}) =>
139
139
  const job_to_run = jobs[i];
140
140
  const job = get_job_to_be_done(job_to_run);
141
141
 
142
- console.log('JOB', job);
143
-
144
142
  await run_job(job);
145
143
 
146
144
  if (job?.after_run_tasks) {
@@ -156,8 +154,6 @@ const process_file_watcher_jobs = async (jobs = [], after_run_functions = {}) =>
156
154
  for (let i = 0; i < tasks_to_run?.length; i += 1) {
157
155
  const after_run_task = tasks_to_run[i];
158
156
 
159
- console.log('ART', after_run_task);
160
-
161
157
  if (types.is_function(after_run_functions[after_run_task])) {
162
158
  await after_run_functions[after_run_task](jobs);
163
159
  }
@@ -215,7 +211,6 @@ const watch_for_changes = (after_run_functions = {}, watch_for_changes_options =
215
211
  // triggering multiple HMR calls or server restarts for files related to the
216
212
  // same job. This is near-instant, so there's no delay for the developer.
217
213
  debounce(async () => {
218
- console.log(file_watcher_jobs);
219
214
  await process_file_watcher_jobs(file_watcher_jobs, after_run_functions);
220
215
  process.initial_build_complete = true;
221
216
  file_watcher_jobs = [];