From 1abcdee2f0b8aaaea10f3132345f4e147c2ca2fe Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 19 Jul 2023 10:55:56 +0800 Subject: [PATCH] fix(cli): update `dev-core` (#3296) --- .env.template | 11 +++++++++++ packages/cli/src/bin/dev-core.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 .env.template diff --git a/.env.template b/.env.template new file mode 100644 index 0000000000..a1b60c7978 --- /dev/null +++ b/.env.template @@ -0,0 +1,11 @@ +ENABLE_PLUGIN= +ENABLE_TEST_PROPERTIES= +ENABLE_BC_PROVIDER= +CHANGELOG_URL= +ENABLE_PRELOADING= +ENABLE_NEW_SETTING_MODAL= +ENABLE_SQLITE_PROVIDER= +ENABLE_NEW_SETTING_UNSTABLE_API= +ENABLE_NOTIFICATION_CENTER= +ENABLE_CLOUD= +ENABLE_MOVE_DATABASE= diff --git a/packages/cli/src/bin/dev-core.ts b/packages/cli/src/bin/dev-core.ts index 38651114b0..9eaf1d55f3 100644 --- a/packages/cli/src/bin/dev-core.ts +++ b/packages/cli/src/bin/dev-core.ts @@ -1,10 +1,24 @@ import { spawn } from 'node:child_process'; +import { existsSync } from 'node:fs'; import path from 'node:path'; import * as p from '@clack/prompts'; +import { config } from 'dotenv'; import { type BuildFlags, projectRoot } from '../config/index.js'; +const files = ['.env', '.env.local']; + +for (const file of files) { + if (existsSync(path.resolve(projectRoot, file))) { + config({ + path: path.resolve(projectRoot, file), + }); + console.log(`${file} loaded`); + break; + } +} + const cwd = path.resolve(projectRoot, 'apps', 'core'); const flags: BuildFlags = { @@ -16,6 +30,19 @@ const flags: BuildFlags = { const buildFlags = await p.group( { + distribution: () => + p.select({ + message: 'Distribution', + options: [ + { + value: 'browser', + }, + { + value: 'desktop', + }, + ], + initialValue: 'browser', + }), mode: () => p.select({ message: 'Mode', @@ -59,6 +86,7 @@ const buildFlags = await p.group( } ); +flags.distribution = buildFlags.distribution as any; flags.mode = buildFlags.mode as any; flags.channel = buildFlags.channel as any; flags.coverage = buildFlags.coverage;