@joystick.js/cli-canary 0.0.0-canary.623 → 0.0.0-canary.625

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.
@@ -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)}},Q=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))},W=async(s={})=>{await Q(),await K(),await X();const e=z(s?.port),t=await g(e),r=await g(e+1);t&&B(e),r&&u(e),F(s,e);const o=await h(process.env.NODE_ENV);await j({environment:process.env.NODE_ENV,port:e,settings:o}),T({hot_module_reload:(c=[])=>V(c),restart_app_server:(c=[])=>v(d,s?.watch,o),start_app_server:()=>N(d,s?.watch),start_hmr_server:s?.environment!=="test"?()=>J(d,f,s?.watch,o):null},{custom_copy_paths:o?.config?.build?.copy_paths||[]}),P(l,d,f)};var vs=W;export{vs as default};
10
+ `)}`}}n(r,{level:"danger",docs:"https://cheatcode.co/docs/joystick/structure"}),process.exit(0)}},Q=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))},W=async(s={})=>{await Q(),await K(),await X();const e=z(s?.port),t=await g(e),r=await g(e+1);t&&B(e),r&&u(e),F(s,e);const o=await h(process.env.NODE_ENV);await j({environment:process.env.NODE_ENV,port:e,settings:o}),T({hot_module_reload:(c=[])=>V(c),restart_app_server:(c=[])=>v(d,s?.watch,o),start_app_server:()=>N(d,s?.watch),start_hmr_server:s?.environment!=="test"?()=>J(d,f,s?.watch,o):null},{custom_copy_paths:o?.config?.build?.copy_paths?.map(c=>({path:c}))||[]}),P(l,d,f)};var vs=W;export{vs 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 c from"./get_after_run_tasks.js";import k from"./get_file_codependencies.js";import p 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:l,copyFile:b,rm:u}=h.promises,n=async(e={},a={})=>{const s=process.initial_build_complete?await k(e?.path):[];if(a?.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")}),s?.length>0)for(let r=0;r<s?.length;r+=1){const t=s[r];await n({path:t},a)}return Promise.resolve()},D=async(e={})=>{switch(e?.operation){case"add_directory":return l(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return n(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}`),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}},O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?c(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?c(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?c(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?c(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>({operation:e?.is_custom_copy_path?"copy_file":p(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?c(e?.path):["start_app_server","start_hmr_server"]}),L=(e={})=>{switch(e?.event){case"add_file":return I(e);case"change_file":return B(e);case"delete_file":return E(e);case"add_directory":return $(e);case"delete_directory":return O(e)}},S=async(e=[],a={})=>{try{const s=new Set([]);for(let t=0;t<e?.length;t+=1){const i=e[t],_=L(i);if(await D(_),_?.after_run_tasks)for(let o=0;o<_?.after_run_tasks?.length;o+=1){const d=_?.after_run_tasks[o];s.add(d)}}const r=Array.from(s);for(let t=0;t<r?.length;t+=1){const i=r[t];w.is_function(a[i])&&await a[i](e)}}catch{}},U=(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"}},x=(e={},a={})=>{const s=f.watch([...R,a?.custom_copy_paths||[]].map(({path:t})=>t),{ignored:".joystick"});let r=[];process.initial_build_complete=!1,s.on("error",t=>console.error(t)),s.on("all",(t,i)=>{r.push({event:U(t),path:i,is_custom_copy_path:a?.custom_copy_paths?.length?a?.custom_copy_paths.some(_=>i.includes(_)):!1}),g(async()=>{await S(r,e),process.initial_build_complete=!0,r=[]},100)})};var M=x;export{M as default};
1
+ import h from"chokidar";import m from"fs";import{dirname as y}from"path";import g from"../../build/build_files.js";import k from"../../debounce.js";import c from"./get_after_run_tasks.js";import v from"./get_file_codependencies.js";import p from"../../build/get_file_operation.js";import w from"../../build/get_path_platform.js";import R from"../../types.js";import l from"./watch_paths.js";const{mkdir:u,copyFile:b,rm:d}=m.promises,o=async(e={},s={})=>{const a=process.initial_build_complete?await v(e?.path):[];if(s?.is_build_file&&await g({files:[{path:e?.path,platform:w(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()},D=async(e={})=>{switch(e?.operation){case"add_directory":return u(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return o(e,{is_build_file:!0});case"copy_file":return await u(y(`.joystick/build/${e?.path}`),{recursive:!0}),await b(e?.path,`.joystick/build/${e?.path}`),o(e,{is_build_file:!1});case"delete_directory":return d(`.joystick/build/${e?.path}`,{recursive:!0});case"delete_file":return await d(`.joystick/build/${e?.path}`,{recursive:!0}),o(e,{is_build_file:!1});default:return!0}},O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?c(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?c(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?c(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?c(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>({operation:e?.is_custom_copy_path?"copy_file":p(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?c(e?.path):["start_app_server","start_hmr_server"]}),L=(e={})=>{switch(e?.event){case"add_file":return I(e);case"change_file":return B(e);case"delete_file":return E(e);case"add_directory":return $(e);case"delete_directory":return O(e)}},S=async(e=[],s={})=>{try{const a=new Set([]);for(let t=0;t<e?.length;t+=1){const i=e[t],_=L(i);if(await D(_),_?.after_run_tasks)for(let n=0;n<_?.after_run_tasks?.length;n+=1){const f=_?.after_run_tasks[n];a.add(f)}}const r=Array.from(a);for(let t=0;t<r?.length;t+=1){const i=r[t];R.is_function(s[i])&&await s[i](e)}}catch{}},U=(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"}},x=(e={},s={})=>{console.log("watch",[...l,s?.custom_copy_paths||[]]);const a=h.watch([...l,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)=>{r.push({event:U(t),path:i,is_custom_copy_path:s?.custom_copy_paths?.length?s?.custom_copy_paths.some(_=>i.includes(_)):!1}),k(async()=>{await S(r,e),process.initial_build_complete=!0,r=[]},100)})};var M=x;export{M as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/cli-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.623",
4
+ "version": "0.0.0-canary.625",
5
5
  "description": "The CLI for Joystick.",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -381,7 +381,9 @@ const development_server = async (development_server_options = {}) => {
381
381
  settings,
382
382
  ) : null,
383
383
  }, {
384
- custom_copy_paths: settings?.config?.build?.copy_paths || [],
384
+ custom_copy_paths: settings?.config?.build?.copy_paths?.map((path) => {
385
+ return { path };
386
+ }) || [],
385
387
  });
386
388
 
387
389
  handle_signal_events(process_ids, node_major_version, __dirname);
@@ -181,6 +181,7 @@ const transform_chokidar_event = (event = '') => {
181
181
  };
182
182
 
183
183
  const watch_for_changes = (after_run_functions = {}, watch_for_changes_options = {}) => {
184
+ console.log('watch', [...watch_paths, (watch_for_changes_options?.custom_copy_paths || [])]);
184
185
  const file_watcher = chokidar.watch([...watch_paths, (watch_for_changes_options?.custom_copy_paths || [])].map(({ path }) => path), {
185
186
  ignored: '.joystick',
186
187
  });