0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

Merge pull request #2124 from logto-io/gao-clean-up-core-inquiry

refactor(core): remove parameters
This commit is contained in:
Gao Sun 2022-10-12 11:47:46 +08:00 committed by GitHub
commit 343456f44d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 27 deletions

View file

@ -15,8 +15,6 @@ tasks:
pnpm cli db seed pnpm cli db seed
pnpm lerna --ignore=@logto/integration-test run --parallel dev pnpm lerna --ignore=@logto/integration-test run --parallel dev
env: env:
ALL_YES: 1
NO_INQUIRY: 0
TRUST_PROXY_HEADER: 1 TRUST_PROXY_HEADER: 1
DB_URL: postgres://postgres:p0stgr3s@127.0.0.1:5432 DB_URL: postgres://postgres:p0stgr3s@127.0.0.1:5432

View file

@ -1 +0,0 @@
/alterations

View file

@ -40,6 +40,7 @@
"deepmerge": "^4.2.2", "deepmerge": "^4.2.2",
"dotenv": "^16.0.0", "dotenv": "^16.0.0",
"etag": "^1.8.1", "etag": "^1.8.1",
"find-up": "^5.0.0",
"fs-extra": "^10.1.0", "fs-extra": "^10.1.0",
"got": "^11.8.2", "got": "^11.8.2",
"hash-wasm": "^4.9.0", "hash-wasm": "^4.9.0",

View file

@ -1,17 +1,12 @@
import { appendFileSync } from 'fs'; import { appendFileSync } from 'fs';
import dotenv from 'dotenv'; import dotenv from 'dotenv';
import findUp from 'find-up';
import { fromRoot } from './parameters';
export const appendDotEnv = (key: string, value: string) => { export const appendDotEnv = (key: string, value: string) => {
appendFileSync('.env', `${key}=${value}\n`); appendFileSync('.env', `${key}=${value}\n`);
}; };
export const configDotEnv = () => { export const configDotEnv = async () => {
if (fromRoot) { dotenv.config({ path: await findUp('.env', {}) });
dotenv.config({ path: '../../.env' });
} else {
dotenv.config();
}
}; };

View file

@ -1,9 +1,2 @@
import { getEnv } from '@silverhand/essentials';
export const isTrue = (value: string) => export const isTrue = (value: string) =>
['1', 'true', 'y', 'yes', 'yep', 'yeah'].includes(value.toLowerCase()); ['1', 'true', 'y', 'yes', 'yep', 'yeah'].includes(value.toLowerCase());
const parameters = new Set(process.argv.slice(2));
export const noInquiry = parameters.has('--no-inquiry') || isTrue(getEnv('NO_INQUIRY'));
export const fromRoot = parameters.has('--from-root') || isTrue(getEnv('FROM_ROOT'));
export const allYes = parameters.has('--all-yes') || isTrue(getEnv('ALL_YES'));

View file

@ -2,22 +2,17 @@ import 'module-alias/register';
import Koa from 'koa'; import Koa from 'koa';
// eslint-disable-next-line import/order
import { configDotEnv } from './env-set/dot-env';
configDotEnv();
/* eslint-disable import/first */
import initApp from './app/init'; import initApp from './app/init';
import { initConnectors } from './connectors'; import { initConnectors } from './connectors';
import envSet from './env-set'; import envSet from './env-set';
import { configDotEnv } from './env-set/dot-env';
import initI18n from './i18n/init'; import initI18n from './i18n/init';
/* eslint-enable import/first */
// Update after we migrate to ESM // Update after we migrate to ESM
// eslint-disable-next-line unicorn/prefer-top-level-await // eslint-disable-next-line unicorn/prefer-top-level-await
(async () => { (async () => {
try { try {
await configDotEnv();
await envSet.load(); await envSet.load();
const app = new Koa({ const app = new Koa({
proxy: envSet.values.trustProxyHeader, proxy: envSet.values.trustProxyHeader,

View file

@ -275,6 +275,7 @@ importers:
dotenv: ^16.0.0 dotenv: ^16.0.0
eslint: ^8.21.0 eslint: ^8.21.0
etag: ^1.8.1 etag: ^1.8.1
find-up: ^5.0.0
fs-extra: ^10.1.0 fs-extra: ^10.1.0
got: ^11.8.2 got: ^11.8.2
hash-wasm: ^4.9.0 hash-wasm: ^4.9.0
@ -331,6 +332,7 @@ importers:
deepmerge: 4.2.2 deepmerge: 4.2.2
dotenv: 16.0.0 dotenv: 16.0.0
etag: 1.8.1 etag: 1.8.1
find-up: 5.0.0
fs-extra: 10.1.0 fs-extra: 10.1.0
got: 11.8.3 got: 11.8.3
hash-wasm: 4.9.0 hash-wasm: 4.9.0
@ -4035,7 +4037,7 @@ packages:
'@jest/types': 28.1.3 '@jest/types': 28.1.3
deepmerge: 4.2.2 deepmerge: 4.2.2
identity-obj-proxy: 3.0.0 identity-obj-proxy: 3.0.0
jest: 28.1.3_k5ytkvaprncdyzidqqws5bqksq jest: 28.1.3_@types+node@16.11.12
jest-matcher-specific-error: 1.0.0 jest-matcher-specific-error: 1.0.0
jest-transform-stub: 2.0.0 jest-transform-stub: 2.0.0
ts-jest: 28.0.7_lhw3xkmzugq5tscs3x2ndm4sby ts-jest: 28.0.7_lhw3xkmzugq5tscs3x2ndm4sby
@ -15205,7 +15207,7 @@ packages:
'@jest/types': 28.1.3 '@jest/types': 28.1.3
bs-logger: 0.2.6 bs-logger: 0.2.6
fast-json-stable-stringify: 2.1.0 fast-json-stable-stringify: 2.1.0
jest: 28.1.3_k5ytkvaprncdyzidqqws5bqksq jest: 28.1.3_@types+node@16.11.12
jest-util: 28.1.3 jest-util: 28.1.3
json5: 2.2.1 json5: 2.2.1
lodash.memoize: 4.1.2 lodash.memoize: 4.1.2