@joystick.js/cli-canary 0.0.0-canary.582 → 0.0.0-canary.583
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 f from"chokidar";import h from"fs";import{dirname as m}from"path";import
|
|
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 b from"./watch_paths.js";const{mkdir:p,copyFile:R,rm:u}=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)})),new Error("BUILD_ERROR")}),a?.length>0)for(let t=0;t<a?.length;t+=1){const r=a[t];return c({path:r})}return Promise.resolve()},$=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 R(e?.path,`.joystick/build/${e?.path}`),c(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}),c(e,{is_build_file:!1});default:return!0}},D=(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"]}),O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),x=(e={})=>({operation:l(e?.path),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={})=>{switch(e?.event){case"add_file":return B(e);case"change_file":return x(e);case"delete_file":return O(e);case"add_directory":return E(e);case"delete_directory":return D(e)}},L=async(e=[],i={})=>{try{const a=new Set([]);for(let r=0;r<e?.length;r+=1){const _=e[r],n=I(_);if(await $(n),n?.after_run_tasks)for(let o=0;o<n?.after_run_tasks?.length;o+=1){const d=n?.after_run_tasks[o];a.add(d)}}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{}},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={})=>{const i=f.watch(b.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:S(t),path:r}),g(async()=>{await L(a,e),process.initial_build_complete=!0,a=[]},100)})};var M=U;export{M as default};
|
package/package.json
CHANGED
|
@@ -27,6 +27,13 @@ const handle_build_files = async (job = {}, options = {}) => {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (process.initial_build_complete && errors?.length > 0) {
|
|
30
|
+
process.app_server_process.send(
|
|
31
|
+
JSON.stringify({
|
|
32
|
+
type: "BUILD_ERROR",
|
|
33
|
+
paths: errors.filter(({ success }) => !success),
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
|
|
30
37
|
throw new Error('BUILD_ERROR');
|
|
31
38
|
}
|
|
32
39
|
});
|
|
@@ -148,9 +155,9 @@ const process_file_watcher_jobs = async (jobs = [], after_run_functions = {}) =>
|
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
} catch(error) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
// NOTE: Dead catch as we just want to avoid after_run_tasks from running. Actual
|
|
159
|
+
// errors are handled as part of run_job() (e.g., build errors are handled as a part
|
|
160
|
+
// of handle_build_files()).
|
|
154
161
|
}
|
|
155
162
|
};
|
|
156
163
|
|