@jayfong/x-server 2.91.0 → 2.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,13 +23,15 @@ async function deploy(argv) {
23
23
  const deployEnvFiles = _env_util.EnvUtil.getFile('deploy', channel, true);
24
24
  const deployEnv = await _env_util.EnvUtil.parseFileAsMap({
25
25
  cwd: process.cwd(),
26
- file: deployEnvFiles
26
+ file: deployEnvFiles,
27
+ channel: channel
27
28
  });
28
29
  if (argv.type === 'env') {
29
30
  const appEnvFiles = _env_util.EnvUtil.getFile('production', channel);
30
31
  const appEnv = await _env_util.EnvUtil.parseFileAsMap({
31
32
  cwd: process.cwd(),
32
- file: appEnvFiles
33
+ file: appEnvFiles,
34
+ channel: channel
33
35
  });
34
36
  await _deploy_util.DeployUtil.deployEnv({
35
37
  host: deployEnv.HOST,
@@ -104,7 +106,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
104
106
  const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, channel);
105
107
  await _env_util.EnvUtil.importFile({
106
108
  cwd: process.cwd(),
107
- file: envFiles
109
+ file: envFiles,
110
+ channel: channel
108
111
  });
109
112
  _env_util.EnvUtil.outputTypes({
110
113
  cwd: process.cwd(),
@@ -184,7 +187,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
184
187
  const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, channel);
185
188
  const envMap = await _env_util.EnvUtil.parseFileAsMap({
186
189
  cwd: process.cwd(),
187
- file: envFiles
190
+ file: envFiles,
191
+ channel: channel
188
192
  });
189
193
  envMap.NODE_ENV = 'production';
190
194
  await _template_util.TemplateUtil.init(process.cwd());
@@ -237,7 +241,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
237
241
  const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, channel);
238
242
  await _env_util.EnvUtil.importFile({
239
243
  cwd: process.cwd(),
240
- file: envFiles
244
+ file: envFiles,
245
+ channel: channel
241
246
  });
242
247
  await new _api_generator.ApiGenerator().start();
243
248
  }
@@ -260,7 +265,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
260
265
  const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, channel);
261
266
  await _env_util.EnvUtil.importFile({
262
267
  cwd: process.cwd(),
263
- file: envFiles
268
+ file: envFiles,
269
+ channel: channel
264
270
  });
265
271
  // 之所以能成功是因为 Prisma 用的 dotenv 默认不会覆盖已经设置的环境变量
266
272
  // https://github.com/motdotla/dotenv#override
@@ -304,7 +310,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
304
310
  const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, channel);
305
311
  await _env_util.EnvUtil.importFile({
306
312
  cwd: process.cwd(),
307
- file: envFiles
313
+ file: envFiles,
314
+ channel: channel
308
315
  });
309
316
  process.env.DATABASE_URL = process.env.DATABASE_ACTION_URL || process.env.DATABASE_URL;
310
317
  if (!argv.script) {
@@ -149,7 +149,9 @@ class EnvUtil {
149
149
  return Object.values(envMap);
150
150
  }
151
151
  static async parseFileAsMap(options) {
152
- const envsObj = {};
152
+ const envsObj = {
153
+ APP_CHANNEL: options.channel
154
+ };
153
155
  const envs = await EnvUtil.parseFile(options);
154
156
  for (const env of envs) {
155
157
  envsObj[env.key] = env.value;
@@ -157,7 +159,9 @@ class EnvUtil {
157
159
  return envsObj;
158
160
  }
159
161
  static async importFile(options) {
160
- const envsObj = {};
162
+ const envsObj = {
163
+ APP_CHANNEL: options.channel
164
+ };
161
165
  const envs = await EnvUtil.parseFile(options);
162
166
  for (const env of envs) {
163
167
  envsObj[env.key] = env.value;
@@ -177,6 +181,10 @@ class EnvUtil {
177
181
  * 当前环境
178
182
  */
179
183
  NODE_ENV: 'development' | 'production';
184
+ /**
185
+ * 当前渠道
186
+ */
187
+ APP_CHANNEL: string;
180
188
  ${envs.map(env => (0, _vtils.dedent)`
181
189
  ${env.comment ? (0, _vtils.dedent)`
182
190
  /**
package/lib/cli/cli.js CHANGED
@@ -21,13 +21,15 @@ async function deploy(argv) {
21
21
  const deployEnvFiles = EnvUtil.getFile('deploy', channel, true);
22
22
  const deployEnv = await EnvUtil.parseFileAsMap({
23
23
  cwd: process.cwd(),
24
- file: deployEnvFiles
24
+ file: deployEnvFiles,
25
+ channel: channel
25
26
  });
26
27
  if (argv.type === 'env') {
27
28
  const appEnvFiles = EnvUtil.getFile('production', channel);
28
29
  const appEnv = await EnvUtil.parseFileAsMap({
29
30
  cwd: process.cwd(),
30
- file: appEnvFiles
31
+ file: appEnvFiles,
32
+ channel: channel
31
33
  });
32
34
  await DeployUtil.deployEnv({
33
35
  host: deployEnv.HOST,
@@ -102,7 +104,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
102
104
  const envFiles = EnvUtil.getFile(process.env.NODE_ENV, channel);
103
105
  await EnvUtil.importFile({
104
106
  cwd: process.cwd(),
105
- file: envFiles
107
+ file: envFiles,
108
+ channel: channel
106
109
  });
107
110
  EnvUtil.outputTypes({
108
111
  cwd: process.cwd(),
@@ -182,7 +185,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
182
185
  const envFiles = EnvUtil.getFile(process.env.NODE_ENV, channel);
183
186
  const envMap = await EnvUtil.parseFileAsMap({
184
187
  cwd: process.cwd(),
185
- file: envFiles
188
+ file: envFiles,
189
+ channel: channel
186
190
  });
187
191
  envMap.NODE_ENV = 'production';
188
192
  await TemplateUtil.init(process.cwd());
@@ -235,7 +239,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
235
239
  const envFiles = EnvUtil.getFile(process.env.NODE_ENV, channel);
236
240
  await EnvUtil.importFile({
237
241
  cwd: process.cwd(),
238
- file: envFiles
242
+ file: envFiles,
243
+ channel: channel
239
244
  });
240
245
  await new ApiGenerator().start();
241
246
  }
@@ -258,7 +263,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
258
263
  const envFiles = EnvUtil.getFile(process.env.NODE_ENV, channel);
259
264
  await EnvUtil.importFile({
260
265
  cwd: process.cwd(),
261
- file: envFiles
266
+ file: envFiles,
267
+ channel: channel
262
268
  });
263
269
  // 之所以能成功是因为 Prisma 用的 dotenv 默认不会覆盖已经设置的环境变量
264
270
  // https://github.com/motdotla/dotenv#override
@@ -302,7 +308,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
302
308
  const envFiles = EnvUtil.getFile(process.env.NODE_ENV, channel);
303
309
  await EnvUtil.importFile({
304
310
  cwd: process.cwd(),
305
- file: envFiles
311
+ file: envFiles,
312
+ channel: channel
306
313
  });
307
314
  process.env.DATABASE_URL = process.env.DATABASE_ACTION_URL || process.env.DATABASE_URL;
308
315
  if (!argv.script) {
@@ -26,10 +26,12 @@ export declare class EnvUtil {
26
26
  static parseFileAsMap(options: {
27
27
  cwd: string;
28
28
  file: string[];
29
+ channel?: string;
29
30
  }): Promise<Record<string, any>>;
30
31
  static importFile(options: {
31
32
  cwd: string;
32
33
  file: string[];
34
+ channel?: string;
33
35
  }): Promise<void>;
34
36
  static makeTypes(envs: ParsedEnv[]): string;
35
37
  static outputTypes(options: {
@@ -144,7 +144,9 @@ export class EnvUtil {
144
144
  return Object.values(envMap);
145
145
  }
146
146
  static async parseFileAsMap(options) {
147
- const envsObj = {};
147
+ const envsObj = {
148
+ APP_CHANNEL: options.channel
149
+ };
148
150
  const envs = await EnvUtil.parseFile(options);
149
151
  for (const env of envs) {
150
152
  envsObj[env.key] = env.value;
@@ -152,7 +154,9 @@ export class EnvUtil {
152
154
  return envsObj;
153
155
  }
154
156
  static async importFile(options) {
155
- const envsObj = {};
157
+ const envsObj = {
158
+ APP_CHANNEL: options.channel
159
+ };
156
160
  const envs = await EnvUtil.parseFile(options);
157
161
  for (const env of envs) {
158
162
  envsObj[env.key] = env.value;
@@ -172,6 +176,10 @@ export class EnvUtil {
172
176
  * 当前环境
173
177
  */
174
178
  NODE_ENV: 'development' | 'production';
179
+ /**
180
+ * 当前渠道
181
+ */
182
+ APP_CHANNEL: string;
175
183
  ${envs.map(env => dedent`
176
184
  ${env.comment ? dedent`
177
185
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.91.0",
3
+ "version": "2.92.0",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",