@joystick.js/cli-canary 0.0.0-canary.1301 → 0.0.0-canary.1302
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,10 +1,10 @@
|
|
|
1
|
-
import i from"chalk";import m from"child_process";import
|
|
1
|
+
import i from"chalk";import m from"child_process";import N from"fs";import"os";import w,{dirname as x}from"path";import{fileURLToPath as O}from"url";import k 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 S from"../get_platform_safe_path.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 v from"../required_files.js";import T from"./start_app_server.js";import $ from"./start_databases.js";import j from"./start_hmr_server.js";import D from"./watch_for_changes/index.js";import R from"../constants.js";import I from"./kill_process_ids.js";import H from"./run_tests.js";import A from"../debounce.js";const{stat:C}=N.promises,M=k.promisify(m.exec),d=parseInt(process?.version?.split(".")[0]?.replace("v",""),10),L=O(import.meta.url),f=x(L),l=[],P=async(s=!1)=>{const e=p();await H({watch:s,__dirname:f,process_ids:[...l,...e],cleanup_process:process.cleanup_process})},V=(s=[],e=0,r="")=>{const t=["--no-warnings"];e<19&&t.push("--experimental-specifier-resolution=node");const o=m.fork(w.resolve(`${r}/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()})},q=async(s=[])=>{const e=s?.find(a=>a?.path?.match(R.SETTINGS_FILE_NAME_REGEX)?.length>0),r=s?.find(a=>a?.path?.includes("i18n")),t=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:!!r,index_html_change:!!t,index_css_change:!!o,index_client_change:!!c}))},G=(s=0,e=!1,r={})=>{process.hmr_server_process.on("message",async t=>{["HAS_HMR_CONNECTIONS","HAS_NO_HMR_CONNECTIONS","HMR_UPDATE_COMPLETE"].includes(t?.type)||process.loader.print(t),t?.type==="HAS_HMR_CONNECTIONS"&&(process.hmr_server_process.has_connections=!0),t?.type==="HAS_NO_HMR_CONNECTIONS"&&(process.hmr_server_process.has_connections=!1),t?.type==="HMR_UPDATE_COMPLETE"&&process.app_server_process&&!process.app_server_restarting&&(process.app_server_restarting=!0,y(s,e,r))})},J=()=>{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"})})},U=(s=0,e="",r=!1,t={})=>{process.hmr_server_process=j(s,e),l.push(process.hmr_server_process?.pid),J(),G(s,r,t)},F=async(s={})=>{const e=await h(process.env.NODE_ENV),r=e?.config?.databases?JSON.stringify(e?.config?.databases):"",t=s?.config?.databases?JSON.stringify(s?.config?.databases):"";return r!==t},y=async(s=0,e=!1,r=null)=>{A(async()=>{if(await F(r)){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"}),console.log("KILL THESE RESTART",[process.hmr_server_process?.pid,process.app_server_process?.pid,...o,...process.app_server_process.external_process_ids||[]]),I([process.hmr_server_process?.pid,process.app_server_process?.pid,...o,...process.app_server_process.external_process_ids||[]]),process.exit(0)}else await u(process.env.PORT),E(s,e)},300)},B=(s=!1)=>{process.app_server_process.external_process_ids=[],process.app_server_process.on("message",e=>{e?.external_process_id&&(console.log(e?.external_process_id),process.app_server_process.external_process_ids=[...process.app_server_process.external_process_ids||[],e?.external_process_id])}),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 r=e.toString(),t=r.includes("App running at:");r&&t&&process.env.NODE_ENV!=="test"&&process.loader.print(r),r&&!t&&!r.includes("BUILD_ERROR")&&console.log(r),r&&t&&process.env.NODE_ENV==="test"&&P(s)}),process.app_server_process.stderr.on("data",e=>{n(e.toString(),{level:"danger",docs:"https://cheatcode.co/docs/joystick"})})},E=(s=0,e=!1)=>{process.app_server_process=T(s,e),l.push(process.app_server_process?.pid),B(e),process.app_server_restarting=!1},z=(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},K=(s=2600)=>{n(`Port ${s} is already occupied. To start Joystick on this port, clear it and try again.`,{level:"danger"}),process.exit(0)},X=(s=2600)=>parseInt(s||2600,10),Q=async()=>{const s=S(`${process.cwd()}/.joystick/build`);await _(s)&&await M(`${process.platform==="win32"?"rmdir /s /q":"rm -rf"} ${s}`)},W=async()=>{const s=[];for(let e=0;e<v?.length;e+=1){const r=v[e],t=await _(`${process.cwd()}/${r.path}`),o=t&&await C(`${process.cwd()}/${r.path}`);r&&r.type==="file"&&(!t||t&&!o.isFile())&&s.push({type:"file",path:r.path}),r&&r.type==="directory"&&(!t||t&&!o.isDirectory())&&s.push({type:"directory",path:r.path})}if(s?.length>0){const e=s?.filter(o=>o.type==="file"),r=s?.filter(o=>o.type==="directory");let t=`The following paths are missing and required in a Joystick project:
|
|
2
2
|
|
|
3
|
-
`;if(e?.length>0){
|
|
3
|
+
`;if(e?.length>0){t+=` ${i.yellow(">")} Required Files:
|
|
4
4
|
|
|
5
|
-
`;for(let o=0;o<e?.length;o+=1){const c=e[o],a=o+1===e?.length;
|
|
6
|
-
${a&&
|
|
7
|
-
`:""}`)}`}}if(
|
|
5
|
+
`;for(let o=0;o<e?.length;o+=1){const c=e[o],a=o+1===e?.length;t+=` ${i.red(`/${c.path}
|
|
6
|
+
${a&&r?.length>0?`
|
|
7
|
+
`:""}`)}`}}if(r?.length>0){t+=` ${i.yellow(">")} Required Directories:
|
|
8
8
|
|
|
9
|
-
`;for(let o=0;o<
|
|
10
|
-
`)}`}}n(
|
|
9
|
+
`;for(let o=0;o<r?.length;o+=1){const c=r[o];t+=` ${i.red(`/${c.path}
|
|
10
|
+
`)}`}}n(t,{level:"danger",docs:"https://cheatcode.co/docs/joystick/structure"}),process.exit(0)}},Y=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))},Z=async(s={})=>{await Y(),await W(),await Q();const e=X(s?.port),r=await g(e),t=await g(e+1);r&&K(e),t&&u(e),z(s,e);const o=await h(process.env.NODE_ENV);await $({environment:process.env.NODE_ENV,port:e,settings:o}),D({hot_module_reload:(c=[])=>q(c),restart_app_server:()=>y(d,s?.watch,o),start_app_server:()=>E(d,s?.watch),start_hmr_server:s?.environment!=="test"?()=>U(d,f,s?.watch,o):null},{excluded_paths:o?.config?.build?.excluded_paths,custom_copy_paths:o?.config?.build?.copy_paths?.map(c=>({path:c}))||[]}),V(l,d,f)};var ks=Z;export{ks as default};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joystick.js/cli-canary",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-canary.
|
|
5
|
-
"canary_version": "0.0.0-canary.
|
|
4
|
+
"version": "0.0.0-canary.1302",
|
|
5
|
+
"canary_version": "0.0.0-canary.1301",
|
|
6
6
|
"description": "The CLI for Joystick.",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"bin": {
|
|
@@ -174,6 +174,13 @@ const handle_restart_app_server = async (node_major_version = 0, watch = false,
|
|
|
174
174
|
docs: "https://cheatcode.co/docs/joystick/structure",
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
+
console.log('KILL THESE RESTART', [
|
|
178
|
+
process.hmr_server_process?.pid,
|
|
179
|
+
process.app_server_process?.pid,
|
|
180
|
+
...database_process_ids,
|
|
181
|
+
...(process.app_server_process.external_process_ids || []),
|
|
182
|
+
]);
|
|
183
|
+
|
|
177
184
|
kill_process_ids([
|
|
178
185
|
process.hmr_server_process?.pid,
|
|
179
186
|
process.app_server_process?.pid,
|