mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
install: goodbye, mongosh
This commit is contained in:
1 parent
002af33ed5
commit
0d122bb703
1 file changed
+14
-6
+14
-6
@@ -191,7 +191,7 @@ function removeOptionalEsbuildDeps() {
|
|||||||
if (!yarnGlobalPath) return false;
|
if (!yarnGlobalPath) return false;
|
||||||
const pkgjson = `${yarnGlobalPath}/package.json`;
|
const pkgjson = `${yarnGlobalPath}/package.json`;
|
||||||
const data = existsSync(pkgjson) ? require(pkgjson) : {};
|
const data = existsSync(pkgjson) ? require(pkgjson) : {};
|
||||||
data.resolutions = data.resolutions || {};
|
data.resolutions ||= {};
|
||||||
Object.assign(data.resolutions, Object.fromEntries([
|
Object.assign(data.resolutions, Object.fromEntries([
|
||||||
'@esbuild/linux-loong64',
|
'@esbuild/linux-loong64',
|
||||||
'esbuild-windows-32',
|
'esbuild-windows-32',
|
||||||
@@ -326,12 +326,20 @@ connect-timeout = 10`);
|
|||||||
operations: [
|
operations: [
|
||||||
'pm2 start mongod',
|
'pm2 start mongod',
|
||||||
() => sleep(3000),
|
() => sleep(3000),
|
||||||
() => writeFileSync(tmpFile, `db.createUser(${JSON.stringify({
|
async () => {
|
||||||
user: 'hydro',
|
// eslint-disable-next-line import/no-absolute-path
|
||||||
pwd: password,
|
const { MongoClient } = require('/usr/local/share/.config/yarn/global/node_modules/mongodb');
|
||||||
|
const client = await MongoClient.connect('mongodb://127.0.0.1', {
|
||||||
|
useNewUrlParser: true,
|
||||||
|
useUnifiedTopology: true,
|
||||||
|
readPreference: 'nearest',
|
||||||
|
writeConcern: 'majority',
|
||||||
|
});
|
||||||
|
await client.db('hydro').addUser('hydro', password, {
|
||||||
roles: [{ role: 'readWrite', db: 'hydro' }],
|
roles: [{ role: 'readWrite', db: 'hydro' }],
|
||||||
})})`),
|
});
|
||||||
[`mongosh 127.0.0.1:27017/hydro ${tmpFile}`, { retry: true }],
|
await client.close();
|
||||||
|
},
|
||||||
() => writeFileSync(`${process.env.HOME}/.hydro/config.json`, JSON.stringify({
|
() => writeFileSync(`${process.env.HOME}/.hydro/config.json`, JSON.stringify({
|
||||||
uri: `mongodb://hydro:${password}@127.0.0.1:27017/hydro`,
|
uri: `mongodb://hydro:${password}@127.0.0.1:27017/hydro`,
|
||||||
})),
|
})),
|
||||||
|
|||||||
Reference in new issue
Block a user