@naesofteak/naeso 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +46 -2
- package/package.json +48 -4
- package/src/core/cache.js +39 -0
- package/src/core/checksum.js +33 -0
- package/src/core/compatibility.js +152 -0
- package/src/core/downloader.js +234 -0
- package/src/core/environment.js +225 -0
- package/src/core/extractor.js +235 -0
- package/src/core/installer.js +691 -0
- package/src/core/package-downloader.js +284 -0
- package/src/core/package-manager.js +0 -0
- package/src/core/package-resolver.js +125 -0
- package/src/core/platform.js +41 -0
- package/src/core/registry.js +70 -0
- package/src/core/target.js +56 -0
- package/src/core/uninstaller.js +389 -0
- package/src/index.js +635 -0
- package/src/registry/packages/mongodb/package.json +100 -0
- package/src/services/launchd.js +174 -0
- package/src/services/mongodb.js +166 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mongodb",
|
|
3
|
+
"displayName": "MongoDB Community Server",
|
|
4
|
+
"description": "MongoDB Community Server with MongoDB Shell and Database Tools",
|
|
5
|
+
"category": "database",
|
|
6
|
+
"homepage": "https://www.mongodb.com/",
|
|
7
|
+
"license": "SSPL-1.0",
|
|
8
|
+
|
|
9
|
+
"versions": {
|
|
10
|
+
"9.0.2": {
|
|
11
|
+
"targets": {
|
|
12
|
+
"macos-x86_64": {
|
|
13
|
+
"artifacts": {
|
|
14
|
+
"server": {
|
|
15
|
+
"type": "tarball",
|
|
16
|
+
"url": "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-9.0.2.tgz",
|
|
17
|
+
"sha256Url": "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-9.0.2.tgz.sha256"
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
"mongosh": {
|
|
21
|
+
"type": "zip",
|
|
22
|
+
"version": "2.12.0",
|
|
23
|
+
"url": "https://downloads.mongodb.com/compass/mongosh-2.12.0-darwin-x64.zip"
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
"databaseTools": {
|
|
27
|
+
"type": "zip",
|
|
28
|
+
"version": "100.19.1",
|
|
29
|
+
"url": "https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-x86_64-100.19.1.zip"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
"macos-arm64": {
|
|
35
|
+
"artifacts": {
|
|
36
|
+
"server": {
|
|
37
|
+
"type": "tarball",
|
|
38
|
+
"url": "https://fastdl.mongodb.org/osx/mongodb-macos-arm64-9.0.2.tgz",
|
|
39
|
+
"sha256Url": "https://fastdl.mongodb.org/osx/mongodb-macos-arm64-9.0.2.tgz.sha256"
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
"mongosh": {
|
|
43
|
+
"type": "zip",
|
|
44
|
+
"version": "2.12.0",
|
|
45
|
+
"url": "https://downloads.mongodb.com/compass/mongosh-2.12.0-darwin-arm64.zip"
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
"databaseTools": {
|
|
49
|
+
"type": "zip",
|
|
50
|
+
"version": "100.19.1",
|
|
51
|
+
"url": "https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-arm64-100.19.1.zip"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
"install": {
|
|
60
|
+
"type": "multi-artifact",
|
|
61
|
+
|
|
62
|
+
"artifacts": [
|
|
63
|
+
"server",
|
|
64
|
+
"mongosh",
|
|
65
|
+
"databaseTools"
|
|
66
|
+
],
|
|
67
|
+
|
|
68
|
+
"binaries": [
|
|
69
|
+
"mongod",
|
|
70
|
+
"mongos",
|
|
71
|
+
"mongosh",
|
|
72
|
+
"mongodump",
|
|
73
|
+
"mongorestore",
|
|
74
|
+
"mongoexport",
|
|
75
|
+
"mongoimport",
|
|
76
|
+
"bsondump",
|
|
77
|
+
"mongostat",
|
|
78
|
+
"mongotop"
|
|
79
|
+
],
|
|
80
|
+
|
|
81
|
+
"dataDirectory": "~/.naeso/data/mongodb",
|
|
82
|
+
"logDirectory": "~/.naeso/logs/mongodb",
|
|
83
|
+
"configDirectory": "~/.naeso/packages/mongodb/config"
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
"service": {
|
|
87
|
+
"manager": "launchd",
|
|
88
|
+
"label": "com.naesofteak.naeso.mongodb",
|
|
89
|
+
"startCommand": "mongod",
|
|
90
|
+
"stopCommand": "mongod",
|
|
91
|
+
"restartCommand": "mongod",
|
|
92
|
+
"statusCommand": "mongod"
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
"environment": {
|
|
96
|
+
"path": [
|
|
97
|
+
"~/.naeso/packages/mongodb/current/bin"
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
|
|
5
|
+
const HOME = process.env.HOME;
|
|
6
|
+
|
|
7
|
+
const LAUNCH_AGENTS_DIR = path.join(
|
|
8
|
+
HOME,
|
|
9
|
+
"Library",
|
|
10
|
+
"LaunchAgents"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
function getPlistPath(label) {
|
|
14
|
+
return path.join(
|
|
15
|
+
LAUNCH_AGENTS_DIR,
|
|
16
|
+
`${label}.plist`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function ensureLaunchAgentsDirectory() {
|
|
21
|
+
fs.mkdirSync(
|
|
22
|
+
LAUNCH_AGENTS_DIR,
|
|
23
|
+
{ recursive: true }
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function writePlist(label, plistContent) {
|
|
28
|
+
ensureLaunchAgentsDirectory();
|
|
29
|
+
|
|
30
|
+
const plistPath = getPlistPath(label);
|
|
31
|
+
|
|
32
|
+
fs.writeFileSync(
|
|
33
|
+
plistPath,
|
|
34
|
+
plistContent,
|
|
35
|
+
"utf8"
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return plistPath;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function load(label) {
|
|
42
|
+
const plistPath = getPlistPath(label);
|
|
43
|
+
|
|
44
|
+
if (!fs.existsSync(plistPath)) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Service plist not found: ${plistPath}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const result = spawnSync(
|
|
51
|
+
"launchctl",
|
|
52
|
+
["load", plistPath],
|
|
53
|
+
{
|
|
54
|
+
encoding: "utf8"
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (result.status !== 0) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
result.stderr.trim() ||
|
|
61
|
+
`Failed to load service '${label}'.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function unload(label) {
|
|
67
|
+
const plistPath = getPlistPath(label);
|
|
68
|
+
|
|
69
|
+
if (!fs.existsSync(plistPath)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const result = spawnSync(
|
|
74
|
+
"launchctl",
|
|
75
|
+
["unload", plistPath],
|
|
76
|
+
{
|
|
77
|
+
encoding: "utf8"
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (
|
|
82
|
+
result.status !== 0 &&
|
|
83
|
+
!result.stderr.includes("Could not find service")
|
|
84
|
+
) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
result.stderr.trim() ||
|
|
87
|
+
`Failed to unload service '${label}'.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function isLoaded(label) {
|
|
93
|
+
const result = spawnSync(
|
|
94
|
+
"launchctl",
|
|
95
|
+
["list", label],
|
|
96
|
+
{
|
|
97
|
+
encoding: "utf8"
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return result.status === 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function start(label) {
|
|
105
|
+
const plistPath = getPlistPath(label);
|
|
106
|
+
|
|
107
|
+
if (!fs.existsSync(plistPath)) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Service '${label}' is not installed.`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (isLoaded(label)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
load(label);
|
|
118
|
+
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function stop(label) {
|
|
123
|
+
if (!isLoaded(label)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
unload(label);
|
|
128
|
+
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function restart(label) {
|
|
133
|
+
if (isLoaded(label)) {
|
|
134
|
+
unload(label);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
load(label);
|
|
138
|
+
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function status(label) {
|
|
143
|
+
const result = spawnSync(
|
|
144
|
+
"launchctl",
|
|
145
|
+
["list", label],
|
|
146
|
+
{
|
|
147
|
+
encoding: "utf8"
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (result.status !== 0) {
|
|
152
|
+
return {
|
|
153
|
+
loaded: false,
|
|
154
|
+
output: ""
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
loaded: true,
|
|
160
|
+
output: result.stdout.trim()
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = {
|
|
165
|
+
getPlistPath,
|
|
166
|
+
writePlist,
|
|
167
|
+
load,
|
|
168
|
+
unload,
|
|
169
|
+
isLoaded,
|
|
170
|
+
start,
|
|
171
|
+
stop,
|
|
172
|
+
restart,
|
|
173
|
+
status
|
|
174
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const launchd = require("./launchd");
|
|
5
|
+
|
|
6
|
+
const HOME = process.env.HOME;
|
|
7
|
+
|
|
8
|
+
const LABEL = "com.naesofteak.naeso.mongodb";
|
|
9
|
+
|
|
10
|
+
const MONGODB_HOME = path.join(
|
|
11
|
+
HOME,
|
|
12
|
+
".naeso",
|
|
13
|
+
"packages",
|
|
14
|
+
"mongodb",
|
|
15
|
+
"current"
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const MONGOD = path.join(
|
|
19
|
+
MONGODB_HOME,
|
|
20
|
+
"bin",
|
|
21
|
+
"mongod"
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const DATA_DIRECTORY = path.join(
|
|
25
|
+
HOME,
|
|
26
|
+
".naeso",
|
|
27
|
+
"data",
|
|
28
|
+
"mongodb"
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const LOG_DIRECTORY = path.join(
|
|
32
|
+
HOME,
|
|
33
|
+
".naeso",
|
|
34
|
+
"logs",
|
|
35
|
+
"mongodb"
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const LOG_FILE = path.join(
|
|
39
|
+
LOG_DIRECTORY,
|
|
40
|
+
"mongod.log"
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
function ensureDirectories() {
|
|
44
|
+
fs.mkdirSync(DATA_DIRECTORY, {
|
|
45
|
+
recursive: true
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
fs.mkdirSync(LOG_DIRECTORY, {
|
|
49
|
+
recursive: true
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createPlist() {
|
|
54
|
+
if (!fs.existsSync(MONGOD)) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`MongoDB binary not found: ${MONGOD}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ensureDirectories();
|
|
61
|
+
|
|
62
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
63
|
+
<!DOCTYPE plist PUBLIC
|
|
64
|
+
"-//Apple//DTD PLIST 1.0//EN"
|
|
65
|
+
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
66
|
+
|
|
67
|
+
<plist version="1.0">
|
|
68
|
+
<dict>
|
|
69
|
+
|
|
70
|
+
<key>Label</key>
|
|
71
|
+
<string>${LABEL}</string>
|
|
72
|
+
|
|
73
|
+
<key>ProgramArguments</key>
|
|
74
|
+
<array>
|
|
75
|
+
<string>${MONGOD}</string>
|
|
76
|
+
<string>--dbpath</string>
|
|
77
|
+
<string>${DATA_DIRECTORY}</string>
|
|
78
|
+
<string>--logpath</string>
|
|
79
|
+
<string>${LOG_FILE}</string>
|
|
80
|
+
<string>--bind_ip</string>
|
|
81
|
+
<string>127.0.0.1</string>
|
|
82
|
+
<string>--port</string>
|
|
83
|
+
<string>27017</string>
|
|
84
|
+
</array>
|
|
85
|
+
|
|
86
|
+
<key>RunAtLoad</key>
|
|
87
|
+
<true/>
|
|
88
|
+
|
|
89
|
+
<key>KeepAlive</key>
|
|
90
|
+
<true/>
|
|
91
|
+
|
|
92
|
+
<key>ProcessType</key>
|
|
93
|
+
<string>Background</string>
|
|
94
|
+
|
|
95
|
+
<key>StandardOutPath</key>
|
|
96
|
+
<string>${LOG_FILE}</string>
|
|
97
|
+
|
|
98
|
+
<key>StandardErrorPath</key>
|
|
99
|
+
<string>${LOG_FILE}</string>
|
|
100
|
+
|
|
101
|
+
<key>WorkingDirectory</key>
|
|
102
|
+
<string>${DATA_DIRECTORY}</string>
|
|
103
|
+
|
|
104
|
+
</dict>
|
|
105
|
+
</plist>
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function installService() {
|
|
110
|
+
const plist = createPlist();
|
|
111
|
+
|
|
112
|
+
const plistPath = launchd.writePlist(
|
|
113
|
+
LABEL,
|
|
114
|
+
plist
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return plistPath;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function start() {
|
|
121
|
+
installService();
|
|
122
|
+
|
|
123
|
+
const started = launchd.start(LABEL);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
started,
|
|
127
|
+
label: LABEL,
|
|
128
|
+
plist: launchd.getPlistPath(LABEL)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function stop() {
|
|
133
|
+
return launchd.stop(LABEL);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function restart() {
|
|
137
|
+
installService();
|
|
138
|
+
|
|
139
|
+
launchd.restart(LABEL);
|
|
140
|
+
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function status() {
|
|
145
|
+
const result = launchd.status(LABEL);
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
...result,
|
|
149
|
+
label: LABEL,
|
|
150
|
+
mongod: MONGOD,
|
|
151
|
+
dataDirectory: DATA_DIRECTORY,
|
|
152
|
+
logFile: LOG_FILE
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = {
|
|
157
|
+
LABEL,
|
|
158
|
+
MONGOD,
|
|
159
|
+
DATA_DIRECTORY,
|
|
160
|
+
LOG_FILE,
|
|
161
|
+
installService,
|
|
162
|
+
start,
|
|
163
|
+
stop,
|
|
164
|
+
restart,
|
|
165
|
+
status
|
|
166
|
+
};
|