@joystick.js/cli-canary 0.0.0-canary.657 → 0.0.0-canary.659
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
|
|
1
|
+
import a 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 r 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
|
|
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 i();return o&&o.length>0}return l("mongod")},i=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}`];a.spawn("mongod",n.filter(e=>!!e)).stdout.on("data",async e=>{if((e?.toString()).includes("Waiting for connections")){const c=x(s);a.exec(`${c} --eval "rs.initiate()" --verbose --port ${o}`,async(d,S,m)=>{if(!(d||m)){const _=await u(o);return t(parseInt(_,10))}})}})}),$=async(o=2610)=>{const s=await r(".joystick/data/mongodb"),t=await r(`.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 i():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
|
@@ -69,7 +69,7 @@ const start_mongodb_process = (mongodb_port = 2610, mongodb_windows_versions = [
|
|
|
69
69
|
const mongo_command = get_mongo_command(mongodb_windows_versions);
|
|
70
70
|
child_process.exec(`${mongo_command} --eval "rs.initiate()" --verbose --port ${mongodb_port}`, async (error, _stdout, stderr) => {
|
|
71
71
|
if (error || stderr) {
|
|
72
|
-
|
|
72
|
+
// NOTE: Just capture error as it means the replicaSet is already initialized.
|
|
73
73
|
} else {
|
|
74
74
|
const process_id = await get_process_id_from_port(mongodb_port);
|
|
75
75
|
return resolve(parseInt(process_id, 10));
|
|
@@ -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}`);
|