@joystick.js/cli-canary 0.0.0-canary.656 → 0.0.0-canary.658
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/lib/development_server/databases/mongodb/index.js +2 -2
- package/dist/lib/development_server/databases/postgresql/index.js +2 -2
- package/package.json +1 -1
- package/src/lib/development_server/databases/mongodb/index.js +1 -1
- package/src/lib/development_server/databases/postgresql/index.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import i from"child_process";import g from"fs";import p from"../../../cli_log.js";import l from"../../../command_exists.js";import f from"../../../get_platform_safe_path.js";import
|
|
1
|
+
import i from"child_process";import g from"fs";import p from"../../../cli_log.js";import l from"../../../command_exists.js";import f from"../../../get_platform_safe_path.js";import u from"../../../get_process_id_from_port.js";import w from"../../../kill_port_process.js";import c from"../../../path_exists.js";const{rename:y,readdir:b,mkdir:h}=g.promises,k=()=>{p(` MongoDB is not installed on this computer.
|
|
2
2
|
|
|
3
3
|
Download MongoDB at https://www.mongodb.com/try/download/community
|
|
4
4
|
|
|
5
|
-
After you've installed MongoDB, run joystick start again, or, remove MongoDB from your config.databases array in your settings.development.json file to skip starting it up.`,{level:"danger",docs:"https://github.com/cheatcode/joystick#databases"})},v=async()=>{if(process.platform==="win32"){const o=await d();return o&&o.length>0}return l("mongod")},d=async()=>await b("C:\\Program Files\\MongoDB\\Server\\"),x=(o=[])=>process.platform==="win32"&&["6.0","7.0","8.0","9.0","10.0"].some(t=>o.includes(t))?"mongosh":"mongo",j=(o=2610,s=[])=>new Promise(t=>{const n=["--port",o,"--dbpath",f(`./.joystick/data/mongodb_${o}`),"--quiet","--replSet",`joystick_${o}`];i.spawn("mongod",n.filter(a=>!!a)).stdout.on("data",async a=>{if((a?.toString()).includes("Waiting for connections")){const m=x(s);i.exec(`${m} --eval "rs.initiate()" --verbose --port ${o}`,async(e,S,r)=>{if(e||r)console.warn(e||r);else{const _=await
|
|
5
|
+
After you've installed MongoDB, run joystick start again, or, remove MongoDB from your config.databases array in your settings.development.json file to skip starting it up.`,{level:"danger",docs:"https://github.com/cheatcode/joystick#databases"})},v=async()=>{if(process.platform==="win32"){const o=await d();return o&&o.length>0}return l("mongod")},d=async()=>await b("C:\\Program Files\\MongoDB\\Server\\"),x=(o=[])=>process.platform==="win32"&&["6.0","7.0","8.0","9.0","10.0"].some(t=>o.includes(t))?"mongosh":"mongo",j=(o=2610,s=[])=>new Promise(t=>{const n=["--port",o,"--dbpath",f(`./.joystick/data/mongodb_${o}`),"--quiet","--replSet",`joystick_${o}`];i.spawn("mongod",n.filter(a=>!!a)).stdout.on("data",async a=>{if((a?.toString()).includes("Waiting for connections")){const m=x(s);i.exec(`${m} --eval "rs.initiate()" --verbose --port ${o}`,async(e,S,r)=>{if(e||r)console.warn(e||r);else{const _=await u(o);return t(parseInt(_,10))}})}})}),$=async(o=2610)=>{const s=await c(".joystick/data/mongodb"),t=await c(`.joystick/data/mongodb_${o}`);return s&&!t&&await y(".joystick/data/mongodb",`.joystick/data/mongodb_${o}`),t||await h(`.joystick/data/mongodb_${o}`,{recursive:!0}),t},D=async(o=2610)=>{const s=await v(),t=process.platform==="win32"?await d():null;s||(k(),process.exit(1)),await $(o);try{return await w(o),await j(o,t)}catch(n){console.warn(n),process.exit(1)}};var E=D;export{E as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import g from"child_process";import w from"fs";import h from"util";import m from"../../../cli_log.js";import y from"../../../command_exists.js";import x from"../../../get_platform_safe_path.js";import f from"../../../get_process_id_from_port.js";import"../../../kill_port_process.js";import u from"../../../path_exists.js";const c=h.promisify(g.exec),{rename:q}=w.promises,k=async(t=2610)=>{const n=await u(".joystick/data/postgresql");let s=await u(`.joystick/data/postgresql_${t}`);return n&&!s&&(await q(".joystick/data/postgresql",`.joystick/data/postgresql_${t}`),s=!0),s},j=()=>{m("PostgreSQL is not installed on this computer. You can download PostgreSQL at https://www.postgresql.org/download. After you've installed PostgreSQL, run joystick start again, or, remove PostgreSQL from your databases list in your settings.development.json file to skip startup.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/cli#databases"})},b=()=>y("psql"),P=()=>y("pg_ctl"),L=async(t=2610)=>{await b()||(j(),process.exit(1));const s=await P();s||m("PostgreSQL is installed on this computer, but pg_ctl (what Joystick uses to start and manage PostgreSQL) is not in your command line's PATH variable. Add pg_ctl to your command line's PATH, restart your command line, and try again.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/postgresql#path"});try{!await k(t)&&s&&await c(`pg_ctl init -D .joystick/data/postgresql_${t}`);const o=t,
|
|
2
|
-
`,"");c(`createdb -h 127.0.0.1 -p ${o} app`).then(a=>{e(parseInt(_,10))}).catch(({stderr:a})=>{a&&a.includes('database "app" already exists')?e(parseInt(_,10)):console.log(a)})}})})}catch(
|
|
1
|
+
import g from"child_process";import w from"fs";import h from"util";import m from"../../../cli_log.js";import y from"../../../command_exists.js";import x from"../../../get_platform_safe_path.js";import f from"../../../get_process_id_from_port.js";import"../../../kill_port_process.js";import u from"../../../path_exists.js";const c=h.promisify(g.exec),{rename:q}=w.promises,k=async(t=2610)=>{const n=await u(".joystick/data/postgresql");let s=await u(`.joystick/data/postgresql_${t}`);return n&&!s&&(await q(".joystick/data/postgresql",`.joystick/data/postgresql_${t}`),s=!0),s},j=()=>{m("PostgreSQL is not installed on this computer. You can download PostgreSQL at https://www.postgresql.org/download. After you've installed PostgreSQL, run joystick start again, or, remove PostgreSQL from your databases list in your settings.development.json file to skip startup.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/cli#databases"})},b=()=>y("psql"),P=()=>y("pg_ctl"),L=async(t=2610)=>{await b()||(j(),process.exit(1));const s=await P();s||m("PostgreSQL is installed on this computer, but pg_ctl (what Joystick uses to start and manage PostgreSQL) is not in your command line's PATH variable. Add pg_ctl to your command line's PATH, restart your command line, and try again.",{level:"danger",docs:"https://cheatcode.co/docs/joystick/postgresql#path"});try{!await k(t)&&s&&await c(`pg_ctl init -D .joystick/data/postgresql_${t}`);const o=t,l=parseInt(await f(o),10);l&&await c(`pg_ctl kill KILL ${l}`);const d=g.spawn("pg_ctl",["-o",`"-p ${o}"`,"-D",x(`.joystick/data/postgresql_${t}`),"start"].filter(e=>!!e));return new Promise(e=>{d.stderr.on("data",async r=>{const i=r?.toString();i?.includes("another server might be running")||console.warn(i)}),d.stdout.on("data",async r=>{if((r?.toString()).includes("database system is ready to accept connections")){const _=(await f(o))?.replace(`
|
|
2
|
+
`,"");c(`createdb -h 127.0.0.1 -p ${o} app`).then(a=>{e(parseInt(_,10))}).catch(({stderr:a})=>{a&&a.includes('database "app" already exists')?e(parseInt(_,10)):console.log(a)})}})})}catch(p){console.warn(p),process.exit(1)}};var K=L;export{K as default};
|
package/package.json
CHANGED
|
@@ -100,7 +100,7 @@ const setup_data_directory = async (mongodb_port = 2610) => {
|
|
|
100
100
|
|
|
101
101
|
const start_mongodb = async (mongodb_port = 2610) => {
|
|
102
102
|
const mongodb_exists = await check_if_mongodb_exists();
|
|
103
|
-
const
|
|
103
|
+
const mongodb_windows_versions = process.platform === 'win32' ? await get_mongodb_windows_versions() : null;
|
|
104
104
|
|
|
105
105
|
if (!mongodb_exists) {
|
|
106
106
|
warn_mongodb_not_installed();
|
|
@@ -71,7 +71,7 @@ const start_postgresql = async (port = 2610) => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const postgresql_port = port;
|
|
74
|
-
const existing_process_id = await get_process_id_from_port(postgresql_port);
|
|
74
|
+
const existing_process_id = parseInt(await get_process_id_from_port(postgresql_port), 10);
|
|
75
75
|
|
|
76
76
|
if (existing_process_id) {
|
|
77
77
|
await exec(`pg_ctl kill KILL ${existing_process_id}`);
|