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

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,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=[])=>{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 _ 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:
2
2
 
3
3
  `;if(e?.length>0){r+=` ${i.yellow(">")} Required Files:
4
4
 
@@ -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];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 M=S;export{M 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 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};
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.1571",
5
- "canary_version": "0.0.0-canary.1570",
4
+ "version": "0.0.0-canary.1573",
5
+ "canary_version": "0.0.0-canary.1572",
6
6
  "description": "The CLI for Joystick.",
7
7
  "main": "dist/index.js",
8
8
  "bin": {
@@ -84,10 +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
+
87
89
  const has_settings_change = jobs?.find((job) => (job?.path?.match(constants.SETTINGS_FILE_NAME_REGEX))?.length > 0);
88
90
  const has_i18n_change = jobs?.find((job) => job?.path?.includes('i18n'));
89
91
  const has_index_html_change = jobs?.find((job) => job?.path?.includes('index.html'));
90
- const has_index_css_change = jobs?.find((job) => job?.path?.includes('index.css') || job?.path?.incudes('css/'));
92
+ const has_index_css_change = jobs?.find((job) => {
93
+ return job?.path?.includes('index.css') || job?.path?.incudes('css/');
94
+ });
91
95
  const has_index_client_change = jobs?.find((job) => job?.path?.includes('index.client.js'));
92
96
 
93
97
  console.log('THIS', {
@@ -156,6 +156,8 @@ const process_file_watcher_jobs = async (jobs = [], after_run_functions = {}) =>
156
156
  for (let i = 0; i < tasks_to_run?.length; i += 1) {
157
157
  const after_run_task = tasks_to_run[i];
158
158
 
159
+ console.log('ART', after_run_task);
160
+
159
161
  if (types.is_function(after_run_functions[after_run_task])) {
160
162
  await after_run_functions[after_run_task](jobs);
161
163
  }