wip
This commit is contained in:
parent
570a795785
commit
791684efc0
|
|
@ -19,8 +19,7 @@ const configYmlPath = process.env.MISSKEY_CONFIG_YML
|
||||||
? resolve(dir, 'test.yml')
|
? resolve(dir, 'test.yml')
|
||||||
: resolve(dir, 'default.yml');
|
: resolve(dir, 'default.yml');
|
||||||
|
|
||||||
// Change extension from .yml to .json
|
const configJsonPath = resolve(dir, 'config.json');
|
||||||
const configJsonPath = configYmlPath.replace(/\.yml$/, '.json');
|
|
||||||
|
|
||||||
if (!fs.existsSync(configYmlPath)) {
|
if (!fs.existsSync(configYmlPath)) {
|
||||||
console.error(`Configuration file not found: ${configYmlPath}`);
|
console.error(`Configuration file not found: ${configYmlPath}`);
|
||||||
|
|
@ -29,6 +28,6 @@ if (!fs.existsSync(configYmlPath)) {
|
||||||
|
|
||||||
const yamlContent = fs.readFileSync(configYmlPath, 'utf-8');
|
const yamlContent = fs.readFileSync(configYmlPath, 'utf-8');
|
||||||
const config = yaml.load(yamlContent, { schema: yaml.JSON_SCHEMA });
|
const config = yaml.load(yamlContent, { schema: yaml.JSON_SCHEMA });
|
||||||
fs.writeFileSync(configJsonPath, JSON.stringify(config, null, '\t'), 'utf-8');
|
fs.writeFileSync(configJsonPath, JSON.stringify(config), 'utf-8');
|
||||||
|
|
||||||
console.log(`Compiled config: ${configYmlPath} -> ${configJsonPath}`);
|
console.log(`Compiled config: ${configYmlPath} -> ${configJsonPath}`);
|
||||||
|
|
|
||||||
|
|
@ -223,18 +223,9 @@ const _dirname = dirname(_filename);
|
||||||
const dir = `${_dirname}/../../../.config`;
|
const dir = `${_dirname}/../../../.config`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path of configuration file (YAML)
|
* Path of configuration file
|
||||||
*/
|
*/
|
||||||
const configYmlPath = process.env.MISSKEY_CONFIG_YML
|
export const path = resolve(dir, 'config.json');
|
||||||
? resolve(dir, process.env.MISSKEY_CONFIG_YML)
|
|
||||||
: process.env.NODE_ENV === 'test'
|
|
||||||
? resolve(dir, 'test.yml')
|
|
||||||
: resolve(dir, 'default.yml');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path of configuration file (JSON, pre-compiled from YAML)
|
|
||||||
*/
|
|
||||||
export const path = configYmlPath.replace(/\.yml$/, '.json');
|
|
||||||
|
|
||||||
export function loadConfig(): Config {
|
export function loadConfig(): Config {
|
||||||
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
|
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,6 @@ services:
|
||||||
source: ./.config/a.test.default.yml
|
source: ./.config/a.test.default.yml
|
||||||
target: /misskey/.config/default.yml
|
target: /misskey/.config/default.yml
|
||||||
read_only: true
|
read_only: true
|
||||||
- type: bind
|
|
||||||
source: ./.config/a.test.default.json
|
|
||||||
target: /misskey/.config/default.json
|
|
||||||
read_only: false
|
|
||||||
|
|
||||||
db.a.test:
|
db.a.test:
|
||||||
extends:
|
extends:
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,6 @@ services:
|
||||||
source: ./.config/b.test.default.yml
|
source: ./.config/b.test.default.yml
|
||||||
target: /misskey/.config/default.yml
|
target: /misskey/.config/default.yml
|
||||||
read_only: true
|
read_only: true
|
||||||
- type: bind
|
|
||||||
source: ./.config/b.test.default.json
|
|
||||||
target: /misskey/.config/default.json
|
|
||||||
read_only: false
|
|
||||||
|
|
||||||
db.b.test:
|
db.b.test:
|
||||||
extends:
|
extends:
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,6 @@ services:
|
||||||
source: ../ormconfig.js
|
source: ../ormconfig.js
|
||||||
target: /misskey/packages/backend/ormconfig.js
|
target: /misskey/packages/backend/ormconfig.js
|
||||||
read_only: true
|
read_only: true
|
||||||
- type: bind
|
|
||||||
source: ../scripts
|
|
||||||
target: /misskey/packages/backend/scripts
|
|
||||||
read_only: true
|
|
||||||
- type: bind
|
- type: bind
|
||||||
source: ../package.json
|
source: ../package.json
|
||||||
target: /misskey/packages/backend/package.json
|
target: /misskey/packages/backend/package.json
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ function generate {
|
||||||
if [ ! -f .config/docker.env ]; then cp .config/example.docker.env .config/docker.env; fi
|
if [ ! -f .config/docker.env ]; then cp .config/example.docker.env .config/docker.env; fi
|
||||||
if [ ! -f .config/$1.conf ]; then sed "s/\${HOST}/$1/g" .config/example.conf > .config/$1.conf; fi
|
if [ ! -f .config/$1.conf ]; then sed "s/\${HOST}/$1/g" .config/example.conf > .config/$1.conf; fi
|
||||||
if [ ! -f .config/$1.default.yml ]; then sed "s/\${HOST}/$1/g" .config/example.default.yml > .config/$1.default.yml; fi
|
if [ ! -f .config/$1.default.yml ]; then sed "s/\${HOST}/$1/g" .config/example.default.yml > .config/$1.default.yml; fi
|
||||||
# Pre-compile YAML config to JSON (for runtime use without js-yaml)
|
|
||||||
if [ -f .config/$1.default.yml ]; then node -e "const fs=require('fs'),yaml=require('js-yaml');fs.writeFileSync('.config/$1.default.json',JSON.stringify(yaml.load(fs.readFileSync('.config/$1.default.yml','utf-8'),{schema:yaml.JSON_SCHEMA}),null,'\t'),'utf-8')"; fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generate a.test
|
generate a.test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue