@joystick.js/cli-canary 0.0.0-canary.614 → 0.0.0-canary.616
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.
- package/dist/commands/create/index.js +2 -2
- package/dist/commands/create/template/index.server.js +1 -1
- package/dist/commands/create/template/ui/pages/error/index.js +2 -2
- package/dist/lib/build/index.js +2 -2
- package/dist/lib/development_server/watch_for_changes/index.js +1 -1
- package/package.json +1 -1
- package/src/commands/create/index.js +9 -2
- package/src/commands/create/template/index.server.js +1 -1
- package/src/commands/create/template/ui/pages/error/index.js +2 -2
- package/src/lib/build/index.js +1 -1
- package/src/lib/development_server/watch_for_changes/index.js +6 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
cd ${e?.name} && joystick start`)},1e3)};var
|
|
1
|
+
import i from"fs";import o from"chalk";import s 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(s.exec),f=(e="")=>d(`./${e}/package.json`,n(e)),j=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 f(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{options?.release === 'canary' ? '-canary' : ''}@latest`),console.log(`${o.green("Project created! To get started, run:")}
|
|
2
|
+
cd ${e?.name} && joystick start`)},1e3)};var T=j;export{T as default};
|
|
@@ -34,11 +34,11 @@ const Error = joystick.component({
|
|
|
34
34
|
margin-top: 10px;
|
|
35
35
|
}
|
|
36
36
|
`,
|
|
37
|
-
render: ({ i18n }) => {
|
|
37
|
+
render: ({ i18n, props }) => {
|
|
38
38
|
return `
|
|
39
39
|
<div class="error">
|
|
40
40
|
<header>
|
|
41
|
-
<h1
|
|
41
|
+
<h1>${props.status_code}</h1>
|
|
42
42
|
<h4>${i18n('page_not_found')}</h4>
|
|
43
43
|
<p>${i18n('double_check_url')}</p>
|
|
44
44
|
</header>
|
package/dist/lib/build/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import u from"chalk";import b from"child_process";import h from"fs";import{dirname as g}from"path";import w from"util";import $ from"./build_files.js";import x from"./get_files_to_build.js";import y from"./get_file_operation.js";import v from"./get_path_platform.js";import z from"./get_tar_ignore_list.js";import j from"../load_settings.js";import k from"../loader.js";import f from"../path_exists.js";const{mkdir:B,copyFile:P}=h.promises,a=w.promisify(b.exec),A=(
|
|
2
|
-
\u2714 App built as ${e} to ${e==="tar"?
|
|
1
|
+
import u from"chalk";import b from"child_process";import h from"fs";import{dirname as g}from"path";import w from"util";import $ from"./build_files.js";import x from"./get_files_to_build.js";import y from"./get_file_operation.js";import v from"./get_path_platform.js";import z from"./get_tar_ignore_list.js";import j from"../load_settings.js";import k from"../loader.js";import f from"../path_exists.js";const{mkdir:B,copyFile:P}=h.promises,a=w.promisify(b.exec),A=(o=[])=>o?.map(r=>({path:r,operation:y(r),platform:v(r)})),F=async(o={})=>{const r=new k,e=o?.type||"tar",n=o?.environment||"production";r.print(`Building app to ${e} for ${n}...`);const l=await j(n),_=l?.config?.build?.excluded_paths||l?.config?.build?.excludedPaths,d=await x(_),i=e==="tar"?".build/.tar":".build",p=A(d);await f(".build")&&await a("rm -rf .build");const s=p?.filter(t=>t?.operation==="copy_file"),m=p?.filter(t=>t?.operation==="build_file");for(let t=0;t<s?.length;t+=1){const c=s[t];await B(g(`${i}/${c?.path}`),{recursive:!0}),await P(c?.path,`${i}/${c?.path}`)}if(await $({files:m,environment:n,output_path:i}).catch(t=>{console.warn(t)}),e==="tar"){const t=z(l?.config?.build?.excludedPaths);await a(`cd ${i} && tar --exclude=${t} -czf ../build.tar.gz .`),await a(`rm -rf ${i}`)}o?.silence_confirmation||console.log(u.greenBright(`
|
|
2
|
+
\u2714 App built as ${e} to ${e==="tar"?i?.replace("/.tar","/build.tar.gz"):i}!
|
|
3
3
|
`)),await f(".build/component_id_cache.json")&&await a("rm -rf .build/component_id_cache.json")};var Q=F;export{Q 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];return 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 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(console.log({codependencies:a,options:i,job:e}),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];return 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};
|
package/package.json
CHANGED
|
@@ -31,8 +31,15 @@ const create = async (args = {}, options = {}) => {
|
|
|
31
31
|
await create_package_json(args.name);
|
|
32
32
|
|
|
33
33
|
await mkdir(`./${args?.name}/.joystick`, { recursive: true });
|
|
34
|
+
await mkdir(`./${args?.name}/fixtures`, { recursive: true });
|
|
35
|
+
await mkdir(`./${args?.name}/indexes`, { recursive: true });
|
|
34
36
|
await mkdir(`./${args?.name}/lib`, { recursive: true });
|
|
35
37
|
await mkdir(`./${args?.name}/private`, { recursive: true });
|
|
38
|
+
await mkdir(`./${args?.name}/queues`, { recursive: true });
|
|
39
|
+
await mkdir(`./${args?.name}/routes`, { recursive: true });
|
|
40
|
+
await mkdir(`./${args?.name}/uploaders`, { recursive: true });
|
|
41
|
+
await mkdir(`./${args?.name}/tests`, { recursive: true });
|
|
42
|
+
await mkdir(`./${args?.name}/websockets`, { recursive: true });
|
|
36
43
|
|
|
37
44
|
if (options?.release === 'canary') {
|
|
38
45
|
await replace_in_files({
|
|
@@ -59,10 +66,10 @@ const create = async (args = {}, options = {}) => {
|
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
// NOTE: Pure aesthetics. Above step completes so quickly that it almost looks like
|
|
62
|
-
// it's skipped. Add a buffer of
|
|
69
|
+
// it's skipped. Add a buffer of 1s here to make for a better dev experience.
|
|
63
70
|
setTimeout(async () => {
|
|
64
71
|
process.loader.print("Installing dependencies...");
|
|
65
|
-
await exec(`cd ./${args?.name} && npm install --save @joystick.js/ui${options?.release === 'canary' ? '-canary' : ''}@latest @joystick.js/node${options?.release === 'canary' ? '-canary' : ''}@latest`);
|
|
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`);
|
|
66
73
|
console.log(
|
|
67
74
|
`${chalk.green("Project created! To get started, run:")}\ncd ${args?.name} && joystick start`
|
|
68
75
|
);
|
|
@@ -34,11 +34,11 @@ const Error = joystick.component({
|
|
|
34
34
|
margin-top: 10px;
|
|
35
35
|
}
|
|
36
36
|
`,
|
|
37
|
-
render: ({ i18n }) => {
|
|
37
|
+
render: ({ i18n, props }) => {
|
|
38
38
|
return `
|
|
39
39
|
<div class="error">
|
|
40
40
|
<header>
|
|
41
|
-
<h1
|
|
41
|
+
<h1>${props.status_code}</h1>
|
|
42
42
|
<h4>${i18n('page_not_found')}</h4>
|
|
43
43
|
<p>${i18n('double_check_url')}</p>
|
|
44
44
|
</header>
|
package/src/lib/build/index.js
CHANGED
|
@@ -34,7 +34,7 @@ const build = async (options = {}) => {
|
|
|
34
34
|
loader.print(`Building app to ${build_type} for ${environment}...`);
|
|
35
35
|
|
|
36
36
|
const settings = await load_settings(environment);
|
|
37
|
-
const excluded_paths = settings?.config?.build?.excludedPaths;
|
|
37
|
+
const excluded_paths = settings?.config?.build?.excluded_paths || settings?.config?.build?.excludedPaths;
|
|
38
38
|
const files_for_build = await get_files_to_build(excluded_paths);
|
|
39
39
|
const output_path = build_type === 'tar' ? '.build/.tar' : '.build';
|
|
40
40
|
const files_to_build_with_operation_and_platform = get_files_to_build_with_operation_and_platform(files_for_build);
|
|
@@ -15,6 +15,12 @@ const { mkdir, copyFile, rm: remove } = fs.promises;
|
|
|
15
15
|
const handle_build_files = async (job = {}, options = {}) => {
|
|
16
16
|
const codependencies = process.initial_build_complete ? await get_file_codependencies(job?.path) : [];
|
|
17
17
|
|
|
18
|
+
console.log({
|
|
19
|
+
codependencies,
|
|
20
|
+
options,
|
|
21
|
+
job,
|
|
22
|
+
})
|
|
23
|
+
|
|
18
24
|
// NOTE: If we have codependencies, make sure that the file triggering the current job is rebuilt first
|
|
19
25
|
// *before* rebuilding its codependencies. This ensures that codependencies get the latest build of the
|
|
20
26
|
// file. If we do them all together in parallel, the latest build is missed.
|