@joystick.js/cli-canary 0.0.0-canary.652 → 0.0.0-canary.654
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
|
|
1
|
+
import c from"child_process";import o from"util";import n from"../../lib/loader.js";import e from"../../lib/replace_in_files.js";const s=o.promisify(c.exec),t=async(a={},r={})=>{const i=new n;a?.release==="canary"&&(await e(process.cwd(),{match:[/\.js$/],exclude:[/node_modules/],replace_regex:/(@joystick\.js\/node)(?!-)/g,replace_with:"@joystick.js/node-canary"}),await e(process.cwd(),{match:[/\.js$/],exclude:[/node_modules/],replace_regex:/(@joystick\.js\/ui)(?!-)/g,replace_with:"@joystick.js/ui-canary"}),i.print("Swapping production packages for canary versions..."),await s("npm uninstall @joystick.js/node && npm i @joystick.js/node-canary"),await s("npm uninstall @joystick.js/ui && npm i @joystick.js/ui-canary")),a?.release==="production"&&(await e(process.cwd(),{match:[/\.js$/],exclude:[/node_modules/],replace_regex:/(@joystick\.js\/node-canary)/g,replace_with:"@joystick.js/node"}),await e(process.cwd(),{match:[/\.js$/],exclude:[/node_modules/],replace_regex:/(@joystick.js\/ui-canary)/g,replace_with:"@joystick.js/ui"}),i.print("Swapping canary packages for production versions..."),await s("npm uninstall @joystick.js/node-canary && npm i @joystick.js/node"),await s("npm uninstall @joystick.js/ui-canary && npm i @joystick.js/ui"))};var y=t;export{y as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
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 w from"../../../get_process_id_from_port.js";import u 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"})},
|
|
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 w(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=os.platform()==="win32"?await d():null;s||(k(),process.exit(1)),await $(o);try{return await u(o),await j(o,mongodb_windows_versions)}catch(n){console.warn(n),process.exit(1)}};var E=D;export{E as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import replace_in_files from 'replace-in-files';
|
|
2
1
|
import child_process from "child_process";
|
|
3
2
|
import util from 'util';
|
|
4
3
|
import Loader from '../../lib/loader.js';
|
|
4
|
+
import replace_in_files from '../../lib/replace_in_files.js';
|
|
5
5
|
|
|
6
6
|
const exec = util.promisify(child_process.exec);
|
|
7
7
|
|
|
@@ -9,26 +9,18 @@ const use = async (args = {}, options = {}) => {
|
|
|
9
9
|
const loader = new Loader();
|
|
10
10
|
|
|
11
11
|
if (args?.release === 'canary') {
|
|
12
|
-
await replace_in_files({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"ignore": [
|
|
18
|
-
"**/node_modules/**"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
12
|
+
await replace_in_files(process.cwd(), {
|
|
13
|
+
match: [/\.js$/],
|
|
14
|
+
exclude: [/node_modules/],
|
|
15
|
+
replace_regex: /(@joystick\.js\/node)(?!-)/g,
|
|
16
|
+
replace_with: '@joystick.js/node-canary',
|
|
21
17
|
});
|
|
22
|
-
|
|
23
|
-
await replace_in_files({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"ignore": [
|
|
29
|
-
"**/node_modules/**"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
18
|
+
|
|
19
|
+
await replace_in_files(process.cwd(), {
|
|
20
|
+
match: [/\.js$/],
|
|
21
|
+
exclude: [/node_modules/],
|
|
22
|
+
replace_regex: /(@joystick\.js\/ui)(?!-)/g,
|
|
23
|
+
replace_with: '@joystick.js/ui-canary',
|
|
32
24
|
});
|
|
33
25
|
|
|
34
26
|
loader.print('Swapping production packages for canary versions...');
|
|
@@ -38,26 +30,18 @@ const use = async (args = {}, options = {}) => {
|
|
|
38
30
|
}
|
|
39
31
|
|
|
40
32
|
if (args?.release === 'production') {
|
|
41
|
-
await replace_in_files({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"ignore": [
|
|
47
|
-
"**/node_modules/**"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
33
|
+
await replace_in_files(process.cwd(), {
|
|
34
|
+
match: [/\.js$/],
|
|
35
|
+
exclude: [/node_modules/],
|
|
36
|
+
replace_regex: /(@joystick\.js\/node-canary)/g,
|
|
37
|
+
replace_with: '@joystick.js/node',
|
|
50
38
|
});
|
|
51
|
-
|
|
52
|
-
await replace_in_files({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"ignore": [
|
|
58
|
-
"**/node_modules/**"
|
|
59
|
-
]
|
|
60
|
-
}
|
|
39
|
+
|
|
40
|
+
await replace_in_files(process.cwd(), {
|
|
41
|
+
match: [/\.js$/],
|
|
42
|
+
exclude: [/node_modules/],
|
|
43
|
+
replace_regex: /(@joystick.js\/ui-canary)/g,
|
|
44
|
+
replace_with: '@joystick.js/ui',
|
|
61
45
|
});
|
|
62
46
|
|
|
63
47
|
loader.print('Swapping canary packages for production versions...');
|
|
@@ -21,14 +21,31 @@ const warn_mongodb_not_installed = () => {
|
|
|
21
21
|
|
|
22
22
|
const check_if_mongodb_exists = async () => {
|
|
23
23
|
if (process.platform === "win32") {
|
|
24
|
-
const mongodb_versions =
|
|
24
|
+
const mongodb_versions = await get_mongodb_windows_versions();
|
|
25
25
|
return mongodb_versions && mongodb_versions.length > 0;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return command_exists("mongod");
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const get_mongodb_windows_versions = async () => {
|
|
32
|
+
const mongodb_versions = (await readdir(`C:\\Program Files\\MongoDB\\Server\\`));
|
|
33
|
+
return mongodb_versions;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const get_mongo_command = (mongodb_windows_versions = []) => {
|
|
37
|
+
if (process.platform === 'win32') {
|
|
38
|
+
const has_mongodb_six_or_greater = ['6.0', '7.0', '8.0', '9.0', '10.0'].some((mongodb_version) => {
|
|
39
|
+
return mongodb_windows_versions.includes(mongodb_version);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return has_mongodb_six_or_greater ? 'mongosh' : 'mongo';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return 'mongo';
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const start_mongodb_process = (mongodb_port = 2610, mongodb_windows_versions = []) => {
|
|
32
49
|
return new Promise((resolve) => {
|
|
33
50
|
const database_process_flags = [
|
|
34
51
|
'--port',
|
|
@@ -49,7 +66,8 @@ const start_mongodb_process = (mongodb_port = 2610) => {
|
|
|
49
66
|
const stdout = data?.toString();
|
|
50
67
|
|
|
51
68
|
if (stdout.includes('Waiting for connections')) {
|
|
52
|
-
|
|
69
|
+
const mongo_command = get_mongo_command(mongodb_windows_versions);
|
|
70
|
+
child_process.exec(`${mongo_command} --eval "rs.initiate()" --verbose --port ${mongodb_port}`, async (error, _stdout, stderr) => {
|
|
53
71
|
if (error || stderr) {
|
|
54
72
|
console.warn(error || stderr);
|
|
55
73
|
} else {
|
|
@@ -82,6 +100,7 @@ const setup_data_directory = async (mongodb_port = 2610) => {
|
|
|
82
100
|
|
|
83
101
|
const start_mongodb = async (mongodb_port = 2610) => {
|
|
84
102
|
const mongodb_exists = await check_if_mongodb_exists();
|
|
103
|
+
const windows_latest_mongodb = os.platform() === 'win32' ? await get_mongodb_windows_versions() : null;
|
|
85
104
|
|
|
86
105
|
if (!mongodb_exists) {
|
|
87
106
|
warn_mongodb_not_installed();
|
|
@@ -92,7 +111,7 @@ const start_mongodb = async (mongodb_port = 2610) => {
|
|
|
92
111
|
|
|
93
112
|
try {
|
|
94
113
|
await kill_port_process(mongodb_port);
|
|
95
|
-
const mongo_process_id = await start_mongodb_process(mongodb_port);
|
|
114
|
+
const mongo_process_id = await start_mongodb_process(mongodb_port, mongodb_windows_versions);
|
|
96
115
|
return mongo_process_id;
|
|
97
116
|
} catch (exception) {
|
|
98
117
|
console.warn(exception);
|