merge multiple repositories into an existing monorepo

- merged using: 'monorepo_add.sh libraries-settings:libraries/settings'
- see https://github.com/shopsys/monorepo-tools
This commit is contained in:
Jakob Ackermann 2021-08-05 08:34:51 +01:00
commit dea32cc656
No known key found for this signature in database
GPG key ID: 30C56800FCA3828A
8 changed files with 116 additions and 0 deletions

2
libraries/settings/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.npmrc
Dockerfile

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-2021 Overleaf
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,19 @@
@overleaf/settings
===================
A small module to allow global config settings to be set for all services
within the Overleaf architecture.
Settings file location
----------------------
You can specify a custom location for the settings file by setting the
`SHARELATEX_CONFIG` environment variable. E.g.
$ export SHARELATEX_CONFIG=/home/james/config/settings.development.js
Otherwise, the settings will be loaded from `config/settings.NODE_ENV.js`,
where `NODE_ENV` is another environment variable, or defaults to `development`.
The config directory is first looked for in the current directory, and then relative
to the settings module directory.

View file

@ -0,0 +1,50 @@
let defaults, possibleConfigFiles, settingsExist;
const fs = require("fs");
const path = require("path");
const env = (process.env.NODE_ENV || "development").toLowerCase();
const { merge } = require('./merge');
const defaultSettingsPath = path.normalize(__dirname + "/../../../config/settings.defaults");
if (fs.existsSync(`${defaultSettingsPath}.js`)) {
console.log(`Using default settings from ${defaultSettingsPath}.js`);
defaults = require(`${defaultSettingsPath}.js`);
settingsExist = true;
} else if (fs.existsSync(`${defaultSettingsPath}.coffee`)) {
// TODO: remove this in the next major version
throw new Error(`CoffeeScript settings file ${defaultSettingsPath}.coffee is no longer supported, please convert to JavaScript`);
} else {
defaults = {};
settingsExist = false;
}
if (process.env.SHARELATEX_CONFIG) {
possibleConfigFiles = [process.env.SHARELATEX_CONFIG];
} else {
possibleConfigFiles = [
process.cwd() + `/config/settings.${env}.js`,
path.normalize(__dirname + `/../../../config/settings.${env}.js`),
// TODO: remove these in the next major version
process.cwd() + `/config/settings.${env}.coffee`,
path.normalize(__dirname + `/../../../config/settings.${env}.coffee`)
];
}
for (let file of possibleConfigFiles) {
if (fs.existsSync(file)) {
// TODO: remove this in the next major version
if (file.endsWith('.coffee')) {
throw new Error(`CoffeeScript settings file ${file} is no longer supported, please convert to JavaScript`);
}
console.log("Using settings from " + file);
module.exports = merge(require(file), defaults);
settingsExist = true;
break;
}
}
if (!settingsExist) {
console.warn("No settings or defaults found. I'm flying blind.");
}
module.exports = defaults;

1
libraries/settings/index.js Executable file
View file

@ -0,0 +1 @@
module.exports = require('./Settings');

View file

@ -0,0 +1,12 @@
function merge(settings, defaults) {
for (const [key, value] of Object.entries(settings)) {
if ((typeof(value) === "object") && !(value instanceof Array)) {
defaults[key] = merge(value, defaults[key] || {});
} else {
defaults[key] = value;
}
}
return defaults;
}
module.exports = { merge };

5
libraries/settings/package-lock.json generated Normal file
View file

@ -0,0 +1,5 @@
{
"name": "@overleaf/settings",
"version": "2.1.1",
"lockfileVersion": 1
}

View file

@ -0,0 +1,6 @@
{
"name": "@overleaf/settings",
"description": "A centralised settings system for Overleaf",
"version": "2.1.1",
"repository": "overleaf/settings-module"
}