@joystick.js/cli-canary 0.0.0-canary.581 → 0.0.0-canary.582
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 g from"../../build/build_files.js";import k from"../../debounce.js";import s from"./get_after_run_tasks.js";import y 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:u}=h.promises,o=async(e={},i={})=>{const r=process.initial_build_complete?await y(e?.path):[];if(i?.is_build_file&&await g({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 new Error("BUILD_ERROR")}),r?.length>0)for(let t=0;t<r?.length;t+=1){const a=r[t];return o({path:a})}return Promise.resolve()},E=async(e={})=>{switch(e?.operation){case"add_directory":return p(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return o(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}`),o(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}),o(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={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),I=(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:l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),S=(e={})=>({operation:l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),T=(e={})=>{switch(e?.event){case"add_file":return S(e);case"change_file":return O(e);case"delete_file":return I(e);case"add_directory":return $(e);case"delete_directory":return D(e)}},x=async(e=[],i={})=>{try{const r=new Set([]);for(let a=0;a<e?.length;a+=1){const _=e[a],n=T(_);if(await E(n),n?.after_run_tasks)for(let c=0;c<n?.after_run_tasks?.length;c+=1){const d=n?.after_run_tasks[c];r.add(d)}}const t=Array.from(r);for(let a=0;a<t?.length;a+=1){const _=t[a];w.is_function(i[_])&&await i[_](e)}}catch(r){r?.message==="BUILD_ERROR"&&console.log("SEND IT TO THE SERVER!")}},B=(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"}},L=(e={})=>{const i=f.watch(R.map(({path:t})=>t),{ignored:".joystick"});let r=[];process.initial_build_complete=!1,i.on("error",t=>console.error(t)),i.on("all",(t,a)=>{r.push({event:B(t),path:a}),k(async()=>{await x(r,e),process.initial_build_complete=!0,r=[]},100)})};var J=L;export{J as default};
|
package/package.json
CHANGED
|
@@ -22,10 +22,12 @@ const handle_build_files = async (job = {}, options = {}) => {
|
|
|
22
22
|
await build_files({
|
|
23
23
|
files: [{ path: job?.path, platform: get_path_platform(job?.path) }],
|
|
24
24
|
}).catch((errors = []) => {
|
|
25
|
-
if (!process.initial_build_complete) {
|
|
25
|
+
if (!process.initial_build_complete && errors?.length > 0) {
|
|
26
26
|
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (process.initial_build_complete && errors?.length > 0) {
|
|
30
|
+
throw new Error('BUILD_ERROR');
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
}
|
|
@@ -119,29 +121,35 @@ const get_job_to_be_done = (job = {}) => {
|
|
|
119
121
|
};
|
|
120
122
|
|
|
121
123
|
const process_file_watcher_jobs = async (jobs = [], after_run_functions = {}) => {
|
|
122
|
-
|
|
124
|
+
try {
|
|
125
|
+
const after_run_tasks = new Set([]);
|
|
123
126
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
for (let i = 0; i < jobs?.length; i += 1) {
|
|
128
|
+
const job_to_run = jobs[i];
|
|
129
|
+
const job = get_job_to_be_done(job_to_run);
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
await run_job(job);
|
|
129
132
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
if (job?.after_run_tasks) {
|
|
134
|
+
for (let i = 0; i < job?.after_run_tasks?.length; i += 1) {
|
|
135
|
+
const after_run_task = job?.after_run_tasks[i];
|
|
136
|
+
after_run_tasks.add(after_run_task);
|
|
137
|
+
}
|
|
134
138
|
}
|
|
135
139
|
}
|
|
136
|
-
}
|
|
137
140
|
|
|
138
|
-
|
|
141
|
+
const tasks_to_run = Array.from(after_run_tasks);
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
for (let i = 0; i < tasks_to_run?.length; i += 1) {
|
|
144
|
+
const after_run_task = tasks_to_run[i];
|
|
142
145
|
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
if (types.is_function(after_run_functions[after_run_task])) {
|
|
147
|
+
await after_run_functions[after_run_task](jobs);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
} catch(error) {
|
|
151
|
+
if (error?.message === 'BUILD_ERROR') {
|
|
152
|
+
console.log('SEND IT TO THE SERVER!');
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
155
|
};
|