@joystick.js/cli-canary 0.0.0-canary.620 → 0.0.0-canary.622

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,2 +1,2 @@
1
- import i from"fs";import s from"chalk";import o from"child_process";import c from"util";import t from"replace-in-files";import n from"./build_package_json.js";import l from"../../lib/cli_log.js";import m from"../../lib/loader.js";import u from"../../lib/node_path_polyfills.js";const{cp:p,writeFile:d,mkdir:r}=i.promises,y=c.promisify(o.exec),$=(e="")=>d(`./${e}/package.json`,n(e)),f=async(e={},a={})=>{process.loader=new m,process.loader.print("Creating app..."),a?.release&&!["production","canary"].includes(a.release)&&(l("Must pass either production or canary for --release.",{level:"danger",docs:"https://docs.cheatcode.co/joystick/cli/create"}),process.exit(0)),await p(`${u?.__package}/commands/create/template`,`./${e.name}`,{recursive:!0}),await $(e.name),await r(`./${e?.name}/.joystick`,{recursive:!0}),await r(`./${e?.name}/fixtures`,{recursive:!0}),await r(`./${e?.name}/indexes`,{recursive:!0}),await r(`./${e?.name}/lib`,{recursive:!0}),await r(`./${e?.name}/private`,{recursive:!0}),await r(`./${e?.name}/queues`,{recursive:!0}),await r(`./${e?.name}/routes`,{recursive:!0}),await r(`./${e?.name}/uploaders`,{recursive:!0}),await r(`./${e?.name}/tests`,{recursive:!0}),await r(`./${e?.name}/websockets`,{recursive:!0}),a?.release==="canary"&&(await t({files:[`${process.cwd()}/${e?.name}/**/*.js`],from:/(@joystick.js\/node)(?!-)/g,to:"@joystick.js/node-canary",optionsForFiles:{ignore:["**/node_modules/**"]}}),await t({files:[`${process.cwd()}/${e?.name}/**/*.js`],from:/(@joystick.js\/ui)(?!-)/g,to:"@joystick.js/ui-canary",optionsForFiles:{ignore:["**/node_modules/**"]}})),setTimeout(async()=>{process.loader.print("Installing dependencies..."),await y(`cd ./${e?.name} && npm install --save @joystick.js/ui${a?.release==="canary"?"-canary":""}@latest @joystick.js/node${a?.release==="canary"?"-canary":""}@latest @joystick.js/test${a?.release==="canary"?"-canary":""}@latest`),console.log(`${s.green("Project created! To get started, run:")}
2
- cd ${e?.name} && joystick start`)},1e3)};var T=f;export{T as default};
1
+ import i from"fs";import s from"chalk";import c from"child_process";import o from"util";import t from"replace-in-files";import n from"./build_package_json.js";import l from"../../lib/cli_log.js";import m from"../../lib/loader.js";import u from"../../lib/node_path_polyfills.js";const{cp:p,writeFile:d,mkdir:r}=i.promises,y=o.promisify(c.exec),$=(e="")=>d(`./${e}/package.json`,n(e)),f=async(e={},a={})=>{process.loader=new m,process.loader.print("Creating app..."),a?.release&&!["production","canary"].includes(a.release)&&(l("Must pass either production or canary for --release.",{level:"danger",docs:"https://docs.cheatcode.co/joystick/cli/create"}),process.exit(0)),await p(`${u?.__package}/commands/create/template`,`./${e.name}`,{recursive:!0}),await $(e.name),await r(`./${e?.name}/.joystick`,{recursive:!0}),await r(`./${e?.name}/fixtures`,{recursive:!0}),await r(`./${e?.name}/indexes`,{recursive:!0}),await r(`./${e?.name}/lib`,{recursive:!0}),await r(`./${e?.name}/private`,{recursive:!0}),await r(`./${e?.name}/queues`,{recursive:!0}),await r(`./${e?.name}/routes`,{recursive:!0}),await r(`./${e?.name}/uploaders`,{recursive:!0}),await r(`./${e?.name}/tests`,{recursive:!0}),await r(`./${e?.name}/websockets`,{recursive:!0}),a?.release==="canary"&&(await t({files:[`${process.cwd()}/${e?.name}/**/*.js`],from:/(@joystick.js\/node)(?!-)/g,to:"@joystick.js/node-canary",optionsForFiles:{ignore:["**/node_modules/**"]}}),await t({files:[`${process.cwd()}/${e?.name}/**/*.js`],from:/(@joystick.js\/ui)(?!-)/g,to:"@joystick.js/ui-canary",optionsForFiles:{ignore:["**/node_modules/**"]}})),setTimeout(async()=>{process.loader.print("Installing dependencies..."),await y(`cd ./${e?.name} && npm install --save @joystick.js/ui${a?.release==="canary"?"-canary":""}@latest @joystick.js/node${a?.release==="canary"?"-canary":""}@latest @joystick.js/test${a?.release==="canary"?"-canary":""}@latest`),console.log(`${s.green("Project created! To get started, run:")}
2
+ cd ${e?.name} && joystick${a?.release==="canary"?"-canary":""} start`)},1e3)};var T=f;export{T as default};
@@ -1,4 +1,4 @@
1
- import i from"chalk";import m from"child_process";import E from"fs";import w,{dirname as O}from"path";import{fileURLToPath as k}from"url";import S from"util";import g from"./check_if_port_occupied.js";import n from"../cli_log.js";import p from"./get_database_process_ids.js";import u from"../kill_port_process.js";import h from"../load_settings.js";import b from"../loader.js";import _ from"../path_exists.js";import y from"../required_files.js";import x from"./start_app_server.js";import j from"./start_databases.js";import D from"./start_hmr_server.js";import T from"./watch_for_changes/index.js";import $ from"../constants.js";import R from"./kill_process_ids.js";import I from"./run_tests.js";const{stat:H}=E.promises,C=S.promisify(m.exec),d=parseInt(process?.version?.split(".")[0]?.replace("v",""),10),M=k(import.meta.url),f=O(M),l=[],A=async(s=!1)=>{const e=p();await I({watch:s,__dirname:f,process_ids:[...l,...e],cleanup_process:process.cleanup_process})},P=(s=[],e=0,t="")=>{const r=["--no-warnings"];e<19&&r.push("--experimental-specifier-resolution=node");const o=m.fork(w.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()})},V=async(s=[])=>{const e=s?.find(a=>a?.path?.match($.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")),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}))},L=(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,v(s,e,t))})},G=()=>{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"})})},J=(s=0,e="",t=!1,r={})=>{process.hmr_server_process=D(s,e),l.push(process.hmr_server_process?.pid),G(),L(s,t,r)},q=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},v=async(s=0,e=!1,t=null)=>{if(await q(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"}),R([process.hmr_server_process?.pid,process.app_server_process?.pid,...o]),process.exit(0)}else await u(process.env.PORT),N(s,e)},U=(s=!1)=>{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"&&A(s)}),process.app_server_process.stderr.on("data",e=>{n(e.toString(),{level:"danger",docs:"https://cheatcode.co/docs/joystick"})})},N=(s=0,e=!1)=>{process.app_server_process=x(s,e),l.push(process.app_server_process?.pid),U(e),process.app_server_restarting=!1},F=(s={},e=2600)=>{process.title=s?.environment==="test"?"joystick_test":"joystick",process.loader=new b,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},B=(s=2600)=>{n(`Port ${s} is already occupied. To start Joystick on this port, clear it and try again.`,{level:"danger"}),process.exit(0)},z=(s=2600)=>parseInt(s||2600,10),X=async()=>{const s=`${process.cwd()}/.joystick/build`;await _(s)&&await C(`rm -rf ${s}`)},K=async()=>{const s=[];for(let e=0;e<y?.length;e+=1){const t=y[e],r=await _(`${process.cwd()}/${t.path}`),o=r&&await H(`${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 E from"fs";import w,{dirname as O}from"path";import{fileURLToPath as k}from"url";import b from"util";import g from"./check_if_port_occupied.js";import n from"../cli_log.js";import p from"./get_database_process_ids.js";import u from"../kill_port_process.js";import h from"../load_settings.js";import S from"../loader.js";import _ from"../path_exists.js";import y from"../required_files.js";import x from"./start_app_server.js";import j from"./start_databases.js";import D from"./start_hmr_server.js";import T from"./watch_for_changes/index.js";import $ from"../constants.js";import R from"./kill_process_ids.js";import I from"./run_tests.js";const{stat:H}=E.promises,C=b.promisify(m.exec),d=parseInt(process?.version?.split(".")[0]?.replace("v",""),10),M=k(import.meta.url),f=O(M),l=[],A=async(s=!1)=>{const e=p();await I({watch:s,__dirname:f,process_ids:[...l,...e],cleanup_process:process.cleanup_process})},P=(s=[],e=0,t="")=>{const r=["--no-warnings"];e<19&&r.push("--experimental-specifier-resolution=node");const o=m.fork(w.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()})},V=async(s=[])=>{const e=s?.find(a=>a?.path?.match($.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")),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}))},L=(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,v(s,e,t))})},G=()=>{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"})})},J=(s=0,e="",t=!1,r={})=>{process.hmr_server_process=D(s,e),l.push(process.hmr_server_process?.pid),G(),L(s,t,r)},q=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},v=async(s=0,e=!1,t=null)=>{if(await q(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"}),R([process.hmr_server_process?.pid,process.app_server_process?.pid,...o]),process.exit(0)}else await u(process.env.PORT),N(s,e)},U=(s=!1)=>{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"&&A(s)}),process.app_server_process.stderr.on("data",e=>{n(e.toString(),{level:"danger",docs:"https://cheatcode.co/docs/joystick"})})},N=(s=0,e=!1)=>{process.app_server_process=x(s,e),l.push(process.app_server_process?.pid),U(e),process.app_server_restarting=!1},F=(s={},e=2600)=>{process.title=s?.environment==="test"?"joystick_test":"joystick",process.loader=new S,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},B=(s=2600)=>{n(`Port ${s} is already occupied. To start Joystick on this port, clear it and try again.`,{level:"danger"}),process.exit(0)},z=(s=2600)=>parseInt(s||2600,10),X=async()=>{const s=`${process.cwd()}/.joystick/build`;await _(s)&&await C(`rm -rf ${s}`)},K=async()=>{const s=[];for(let e=0;e<y?.length;e+=1){const t=y[e],r=await _(`${process.cwd()}/${t.path}`),o=r&&await H(`${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)}},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}),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}),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 s 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:b,rm:d}=h.promises,c=async(e={},i={})=>{const a=process.initial_build_complete?await k(e?.path):[];if(i?.is_build_file&&await y({files:[{path:e?.path,platform:v(e?.path)}]}).catch((t=[])=>{if(!process.initial_build_complete&&t?.length>0&&process.exit(0),process.initial_build_complete&&t?.length>0)throw process.app_server_process.send(JSON.stringify({type:"BUILD_ERROR",paths:t.filter(({success:r})=>!r)})),process.hmr_server_process.send(JSON.stringify({type:"BUILD_ERROR"})),new Error("BUILD_ERROR")}),a?.length>0)for(let t=0;t<a?.length;t+=1){const r=a[t];await c({path:r},i)}return Promise.resolve()},D=async(e={})=>{switch(e?.operation){case"add_directory":return p(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return c(e,{is_build_file:!0});case"copy_file":return await p(m(`.joystick/build/${e?.path}`),{recursive:!0}),await b(e?.path,`.joystick/build/${e?.path}`),c(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}),c(e,{is_build_file:!1});default:return!0}},O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),B=(e={})=>({operation:l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>({operation:l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?s(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=[],i={})=>{try{const a=new Set([]);for(let r=0;r<e?.length;r+=1){const _=e[r],n=L(_);if(await D(n),n?.after_run_tasks)for(let o=0;o<n?.after_run_tasks?.length;o+=1){const u=n?.after_run_tasks[o];a.add(u)}}const t=Array.from(a);for(let r=0;r<t?.length;r+=1){const _=t[r];w.is_function(i[_])&&await 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={})=>{const i=f.watch(R.map(({path:t})=>t),{ignored:".joystick"});let a=[];process.initial_build_complete=!1,i.on("error",t=>console.error(t)),i.on("all",(t,r)=>{a.push({event:U(t),path:r}),g(async()=>{await S(a,e),process.initial_build_complete=!0,a=[]},100)})};var M=x;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 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};
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.620",
4
+ "version": "0.0.0-canary.622",
5
5
  "description": "The CLI for Joystick.",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -71,7 +71,7 @@ const create = async (args = {}, options = {}) => {
71
71
  process.loader.print("Installing dependencies...");
72
72
  await exec(`cd ./${args?.name} && npm install --save @joystick.js/ui${options?.release === 'canary' ? '-canary' : ''}@latest @joystick.js/node${options?.release === 'canary' ? '-canary' : ''}@latest @joystick.js/test${options?.release === 'canary' ? '-canary' : ''}@latest`);
73
73
  console.log(
74
- `${chalk.green("Project created! To get started, run:")}\ncd ${args?.name} && joystick start`
74
+ `${chalk.green("Project created! To get started, run:")}\ncd ${args?.name} && joystick${options?.release === 'canary' ? '-canary' : ''} start`
75
75
  );
76
76
  }, 1000);
77
77
  };
@@ -380,6 +380,8 @@ const development_server = async (development_server_options = {}) => {
380
380
  development_server_options?.watch,
381
381
  settings,
382
382
  ) : null,
383
+ }, {
384
+ custom_copy_paths: settings?.config?.build?.copy_paths,
383
385
  });
384
386
 
385
387
  handle_signal_events(process_ids, node_major_version, __dirname);
@@ -102,7 +102,7 @@ const get_delete_file_job = (job = {}) => {
102
102
 
103
103
  const get_change_file_job = (job = {}) => {
104
104
  return {
105
- operation: get_file_operation(job?.path),
105
+ operation: job?.is_custom_copy_path ? 'copy_file' : get_file_operation(job?.path),
106
106
  path: job?.path,
107
107
  after_run_tasks: process.initial_build_complete ? get_after_run_tasks(job?.path) : ['start_app_server', 'start_hmr_server'],
108
108
  };
@@ -110,7 +110,7 @@ const get_change_file_job = (job = {}) => {
110
110
 
111
111
  const get_add_file_job = (job = {}) => {
112
112
  return {
113
- operation: get_file_operation(job?.path),
113
+ operation: job?.is_custom_copy_path ? 'copy_file' : get_file_operation(job?.path),
114
114
  path: job?.path,
115
115
  after_run_tasks: process.initial_build_complete ? get_after_run_tasks(job?.path) : ['start_app_server', 'start_hmr_server'],
116
116
  };
@@ -180,8 +180,8 @@ const transform_chokidar_event = (event = '') => {
180
180
  }
181
181
  };
182
182
 
183
- const watch_for_changes = (after_run_functions = {}) => {
184
- const file_watcher = chokidar.watch(watch_paths.map(({ path }) => path), {
183
+ const watch_for_changes = (after_run_functions = {}, watch_for_changes_options = {}) => {
184
+ const file_watcher = chokidar.watch([...watch_paths, (watch_for_changes_options?.custom_copy_paths || [])].map(({ path }) => path), {
185
185
  ignored: '.joystick',
186
186
  });
187
187
 
@@ -192,7 +192,13 @@ const watch_for_changes = (after_run_functions = {}) => {
192
192
  file_watcher.on('error', (error) => console.error(error));
193
193
 
194
194
  file_watcher.on('all', (event, path) => {
195
- file_watcher_jobs.push({ event: transform_chokidar_event(event), path });
195
+ file_watcher_jobs.push({
196
+ event: transform_chokidar_event(event),
197
+ path,
198
+ is_custom_copy_path: watch_for_changes_options?.custom_copy_paths?.length ? watch_for_changes_options?.custom_copy_paths.some((custom_copy_path) => {
199
+ return path.includes(custom_copy_path);
200
+ }) : false,
201
+ });
196
202
 
197
203
  // NOTE: Depending on the watch event, we expect multiple events to be emitted
198
204
  // by chokidar. Debouncing here allows us to "collect" the jobs for the current