@jayfong/x-server 2.71.0 → 2.72.1

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.
@@ -16,8 +16,8 @@ class BuildUtil {
16
16
  const mainFile = _nodePath.default.join(options.cwd, 'src/main.ts');
17
17
  const pkgFile = _nodePath.default.join(options.cwd, 'package.json');
18
18
  const pkgContent = await _fsExtra.default.readJson(pkgFile);
19
- const distDir = _nodePath.default.join(options.cwd, 'dist');
20
- const tempDir = _nodePath.default.join(options.cwd, 'temp');
19
+ const distDir = _nodePath.default.join(options.cwd, options.channel ? `dist/${options.channel}` : 'dist');
20
+ const tempDir = _nodePath.default.join(options.cwd, options.channel ? `temp/${options.channel}` : 'temp');
21
21
  const distMainFile = _nodePath.default.join(distDir, 'main.js');
22
22
  const distPkgFile = _nodePath.default.join(distDir, 'package.json');
23
23
  const distNvmrcFile = _nodePath.default.join(distDir, '.nvmrc');
@@ -50,7 +50,7 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
50
50
  await _template_util.TemplateUtil.init(process.cwd());
51
51
  const xsignoreFile = _path.default.join(process.cwd(), '.xsignore');
52
52
  const xsignoreContent = (await _fsExtra.default.pathExists(xsignoreFile)) ? (await _fsExtra.default.readFile(xsignoreFile, 'utf-8')).trim().split(/[\r\n]+/g).filter(v => v && !v.startsWith('#')) : [];
53
- const watcher = _chokidar.default.watch(['src', '.env', '.env.*'], {
53
+ const watcher = _chokidar.default.watch(['src', '.env', '.env*'], {
54
54
  cwd: process.cwd(),
55
55
  ignored: ['**/*.test.*', ...xsignoreContent]
56
56
  });
@@ -124,7 +124,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
124
124
  external: externals,
125
125
  inlineEnvs: envMap,
126
126
  minify: argv.minify,
127
- noInstall: argv['no-install']
127
+ noInstall: argv['no-install'],
128
+ channel: argv.channel
128
129
  });
129
130
  console.log('构建成功');
130
131
  }).command('api', '生成 API', _ => _.positional('channel', {
@@ -245,7 +246,8 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
245
246
  dir: deployEnv.DIR,
246
247
  cmd: deployEnv.CMD,
247
248
  memory: deployEnv.MEMORY,
248
- cron: deployEnv.CRON
249
+ cron: deployEnv.CRON,
250
+ channel: argv.channel
249
251
  });
250
252
  }
251
253
  }).parse();
@@ -10,7 +10,7 @@ var _vtils = require("vtils");
10
10
  class DeployUtil {
11
11
  static async deploy(options) {
12
12
  const pkgContent = await _fsExtra.default.readJson(_path.default.join(options.cwd, 'package.json'));
13
- const appFile = _path.default.join(options.cwd, `temp/app.${pkgContent.version}.tgz`);
13
+ const appFile = _path.default.join(options.cwd, `temp${options.channel ? `/${options.channel}` : ''}/app.${pkgContent.version}.tgz`);
14
14
  if (!(await _fsExtra.default.pathExists(appFile))) {
15
15
  throw new Error('请先构建');
16
16
  }
@@ -37,7 +37,7 @@ class DeployUtil {
37
37
  await ssh.execCommand((0, _vtils.dedent)`
38
38
  set -ex
39
39
  tar -zxvf ${remoteAppFile} -C ${appDir}
40
- cd ${appDir}/dist
40
+ cd "${appDir}/${options.channel || 'dist'}"
41
41
  [ -f no_install.lock ] && yarn_disable_self_update_check=true tyn
42
42
  ${options.cmd || ''}
43
43
  ${options.memory ? `PM2_MEMORY=${options.memory} ` : ''}${options.cron ? `PM2_CRON="${options.cron}" ` : ''}pm2 startOrReload pm2.config.js
@@ -4,6 +4,7 @@ export interface BuildOptions {
4
4
  inlineEnvs?: Record<string, any>;
5
5
  minify?: boolean;
6
6
  noInstall?: boolean;
7
+ channel?: string;
7
8
  }
8
9
  export declare class BuildUtil {
9
10
  static build(options: BuildOptions): Promise<void>;
@@ -10,8 +10,8 @@ export class BuildUtil {
10
10
  const mainFile = path.join(options.cwd, 'src/main.ts');
11
11
  const pkgFile = path.join(options.cwd, 'package.json');
12
12
  const pkgContent = await fs.readJson(pkgFile);
13
- const distDir = path.join(options.cwd, 'dist');
14
- const tempDir = path.join(options.cwd, 'temp');
13
+ const distDir = path.join(options.cwd, options.channel ? `dist/${options.channel}` : 'dist');
14
+ const tempDir = path.join(options.cwd, options.channel ? `temp/${options.channel}` : 'temp');
15
15
  const distMainFile = path.join(distDir, 'main.js');
16
16
  const distPkgFile = path.join(distDir, 'package.json');
17
17
  const distNvmrcFile = path.join(distDir, '.nvmrc');
package/lib/cli/cli.js CHANGED
@@ -47,7 +47,7 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
47
47
  await TemplateUtil.init(process.cwd());
48
48
  const xsignoreFile = path.join(process.cwd(), '.xsignore');
49
49
  const xsignoreContent = (await fs.pathExists(xsignoreFile)) ? (await fs.readFile(xsignoreFile, 'utf-8')).trim().split(/[\r\n]+/g).filter(v => v && !v.startsWith('#')) : [];
50
- const watcher = chokidar.watch(['src', '.env', '.env.*'], {
50
+ const watcher = chokidar.watch(['src', '.env', '.env*'], {
51
51
  cwd: process.cwd(),
52
52
  ignored: ['**/*.test.*', ...xsignoreContent]
53
53
  });
@@ -121,7 +121,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
121
121
  external: externals,
122
122
  inlineEnvs: envMap,
123
123
  minify: argv.minify,
124
- noInstall: argv['no-install']
124
+ noInstall: argv['no-install'],
125
+ channel: argv.channel
125
126
  });
126
127
  console.log('构建成功');
127
128
  }).command('api', '生成 API', _ => _.positional('channel', {
@@ -242,7 +243,8 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
242
243
  dir: deployEnv.DIR,
243
244
  cmd: deployEnv.CMD,
244
245
  memory: deployEnv.MEMORY,
245
- cron: deployEnv.CRON
246
+ cron: deployEnv.CRON,
247
+ channel: argv.channel
246
248
  });
247
249
  }
248
250
  }).parse();
@@ -8,6 +8,7 @@ export interface DeployOptions {
8
8
  memory?: string;
9
9
  cron?: string;
10
10
  cmd?: string;
11
+ channel?: string;
11
12
  }
12
13
  export interface DeployEnvOptions {
13
14
  host: string;
@@ -5,7 +5,7 @@ import { dedent } from 'vtils';
5
5
  export class DeployUtil {
6
6
  static async deploy(options) {
7
7
  const pkgContent = await fs.readJson(path.join(options.cwd, 'package.json'));
8
- const appFile = path.join(options.cwd, `temp/app.${pkgContent.version}.tgz`);
8
+ const appFile = path.join(options.cwd, `temp${options.channel ? `/${options.channel}` : ''}/app.${pkgContent.version}.tgz`);
9
9
  if (!(await fs.pathExists(appFile))) {
10
10
  throw new Error('请先构建');
11
11
  }
@@ -32,7 +32,7 @@ export class DeployUtil {
32
32
  await ssh.execCommand(dedent`
33
33
  set -ex
34
34
  tar -zxvf ${remoteAppFile} -C ${appDir}
35
- cd ${appDir}/dist
35
+ cd "${appDir}/${options.channel || 'dist'}"
36
36
  [ -f no_install.lock ] && yarn_disable_self_update_check=true tyn
37
37
  ${options.cmd || ''}
38
38
  ${options.memory ? `PM2_MEMORY=${options.memory} ` : ''}${options.cron ? `PM2_CRON="${options.cron}" ` : ''}pm2 startOrReload pm2.config.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.71.0",
3
+ "version": "2.72.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",