@joystick.js/cli-canary 0.0.0-canary.1572 → 0.0.0-canary.1574

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?.includes("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
 
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.1572",
5
- "canary_version": "0.0.0-canary.1571",
4
+ "version": "0.0.0-canary.1574",
5
+ "canary_version": "0.0.0-canary.1573",
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?.includes('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', {