@jayfong/x-server 2.79.0 → 2.79.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.
@@ -73,60 +73,63 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
73
73
  describe: '渠道',
74
74
  type: 'string'
75
75
  }), async argv => {
76
- if (argv.channel === '_') {
77
- argv.channel = await _env_util.EnvUtil.chooseChannel(process.cwd());
78
- }
79
- process.env.NODE_ENV = 'development';
80
- let lastRun;
81
- const run = () => {
82
- lastRun = _dev_util.DevUtil.runFile({
83
- file: 'src/main.ts',
84
- cwd: process.cwd(),
85
- runner: argv.tsx ? 'tsx' : 'esbuild-register'
86
- });
87
- };
88
- if (argv.npc) {
89
- const [server, vkey] = argv.npc.split('@');
90
- (0, _execa.default)('docker', ['run', '--rm', 'ffdfgdfg/npc:v0.26.9', `-server=${server}`, `-vkey=${vkey}`, '-type=tcp'], {
91
- cwd: process.cwd(),
92
- stdio: 'inherit'
93
- });
94
- }
95
- await _template_util.TemplateUtil.init(process.cwd());
96
- const xsignoreFile = _path.default.join(process.cwd(), '.xsignore');
97
- const xsignoreContent = (await _fsExtra.default.pathExists(xsignoreFile)) ? (await _fsExtra.default.readFile(xsignoreFile, 'utf-8')).trim().split(/[\r\n]+/g).filter(v => v && !v.startsWith('#')) : [];
98
- const watcher = _chokidar.default.watch(['src', '.env', '.env*'], {
76
+ await _env_util.EnvUtil.withChannel({
99
77
  cwd: process.cwd(),
100
- ignored: ['**/*.test.*', ...xsignoreContent]
101
- });
102
- watcher.on('all', (0, _vtils.debounce)(async () => {
103
- const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, argv.channel);
104
- await _env_util.EnvUtil.importFile({
105
- cwd: process.cwd(),
106
- file: envFiles
107
- });
108
- _env_util.EnvUtil.outputTypes({
109
- cwd: process.cwd(),
110
- file: envFiles,
111
- outFile: 'env.d.ts'
112
- });
113
- (0, _vscodeGenerateIndexStandalone.generateManyIndex)({
114
- cwd: process.cwd(),
115
- patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', '!src/handlers/**/*', ...(argv.index || [])],
116
- replaceFile: true,
117
- onSuccess: filePath => {
118
- console.log(`✔️ 索引文件已更新: ${filePath}`);
78
+ channel: argv.channel,
79
+ cb: async channel => {
80
+ process.env.NODE_ENV = 'development';
81
+ let lastRun;
82
+ const run = () => {
83
+ lastRun = _dev_util.DevUtil.runFile({
84
+ file: 'src/main.ts',
85
+ cwd: process.cwd(),
86
+ runner: argv.tsx ? 'tsx' : 'esbuild-register'
87
+ });
88
+ };
89
+ if (argv.npc) {
90
+ const [server, vkey] = argv.npc.split('@');
91
+ (0, _execa.default)('docker', ['run', '--rm', 'ffdfgdfg/npc:v0.26.9', `-server=${server}`, `-vkey=${vkey}`, '-type=tcp'], {
92
+ cwd: process.cwd(),
93
+ stdio: 'inherit'
94
+ });
119
95
  }
120
- });
121
- if (lastRun) {
122
- console.log('==== 重启服务中 ====');
123
- lastRun.kill();
124
- setTimeout(run, 0);
125
- } else {
126
- console.log('==== 启动服务中 ====');
127
- run();
96
+ await _template_util.TemplateUtil.init(process.cwd());
97
+ const xsignoreFile = _path.default.join(process.cwd(), '.xsignore');
98
+ const xsignoreContent = (await _fsExtra.default.pathExists(xsignoreFile)) ? (await _fsExtra.default.readFile(xsignoreFile, 'utf-8')).trim().split(/[\r\n]+/g).filter(v => v && !v.startsWith('#')) : [];
99
+ const watcher = _chokidar.default.watch(['src', '.env', '.env*'], {
100
+ cwd: process.cwd(),
101
+ ignored: ['**/*.test.*', ...xsignoreContent]
102
+ });
103
+ watcher.on('all', (0, _vtils.debounce)(async () => {
104
+ const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, channel);
105
+ await _env_util.EnvUtil.importFile({
106
+ cwd: process.cwd(),
107
+ file: envFiles
108
+ });
109
+ _env_util.EnvUtil.outputTypes({
110
+ cwd: process.cwd(),
111
+ file: envFiles,
112
+ outFile: 'env.d.ts'
113
+ });
114
+ (0, _vscodeGenerateIndexStandalone.generateManyIndex)({
115
+ cwd: process.cwd(),
116
+ patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', '!src/handlers/**/*', ...(argv.index || [])],
117
+ replaceFile: true,
118
+ onSuccess: filePath => {
119
+ console.log(`✔️ 索引文件已更新: ${filePath}`);
120
+ }
121
+ });
122
+ if (lastRun) {
123
+ console.log('==== 重启服务中 ====');
124
+ lastRun.kill();
125
+ setTimeout(run, 0);
126
+ } else {
127
+ console.log('==== 启动服务中 ====');
128
+ run();
129
+ }
130
+ }, 30));
128
131
  }
129
- }, 30));
132
+ });
130
133
  }).command('build', '构建', _ => _.positional('external', {
131
134
  alias: 'e',
132
135
  describe: '不应该被打的包',
@@ -207,16 +210,19 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
207
210
  describe: '渠道',
208
211
  type: 'string'
209
212
  }), async argv => {
210
- if (argv.channel === '_') {
211
- argv.channel = await _env_util.EnvUtil.chooseChannel(process.cwd());
212
- }
213
- process.env.NODE_ENV = 'production';
214
- const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, argv.channel);
215
- await _env_util.EnvUtil.importFile({
213
+ await _env_util.EnvUtil.withChannel({
216
214
  cwd: process.cwd(),
217
- file: envFiles
215
+ channel: argv.channel,
216
+ cb: async channel => {
217
+ process.env.NODE_ENV = 'production';
218
+ const envFiles = _env_util.EnvUtil.getFile(process.env.NODE_ENV, channel);
219
+ await _env_util.EnvUtil.importFile({
220
+ cwd: process.cwd(),
221
+ file: envFiles
222
+ });
223
+ await new _api_generator.ApiGenerator().start();
224
+ }
218
225
  });
219
- await new _api_generator.ApiGenerator().start();
220
226
  }).command('prisma', 'prisma 代理,主要为了注入环境变量', _ => _.positional('production', {
221
227
  alias: 'p',
222
228
  describe: '是否生产模式',
package/lib/cli/cli.js CHANGED
@@ -71,60 +71,63 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
71
71
  describe: '渠道',
72
72
  type: 'string'
73
73
  }), async argv => {
74
- if (argv.channel === '_') {
75
- argv.channel = await EnvUtil.chooseChannel(process.cwd());
76
- }
77
- process.env.NODE_ENV = 'development';
78
- let lastRun;
79
- const run = () => {
80
- lastRun = DevUtil.runFile({
81
- file: 'src/main.ts',
82
- cwd: process.cwd(),
83
- runner: argv.tsx ? 'tsx' : 'esbuild-register'
84
- });
85
- };
86
- if (argv.npc) {
87
- const [server, vkey] = argv.npc.split('@');
88
- execa('docker', ['run', '--rm', 'ffdfgdfg/npc:v0.26.9', `-server=${server}`, `-vkey=${vkey}`, '-type=tcp'], {
89
- cwd: process.cwd(),
90
- stdio: 'inherit'
91
- });
92
- }
93
- await TemplateUtil.init(process.cwd());
94
- const xsignoreFile = path.join(process.cwd(), '.xsignore');
95
- const xsignoreContent = (await fs.pathExists(xsignoreFile)) ? (await fs.readFile(xsignoreFile, 'utf-8')).trim().split(/[\r\n]+/g).filter(v => v && !v.startsWith('#')) : [];
96
- const watcher = chokidar.watch(['src', '.env', '.env*'], {
74
+ await EnvUtil.withChannel({
97
75
  cwd: process.cwd(),
98
- ignored: ['**/*.test.*', ...xsignoreContent]
99
- });
100
- watcher.on('all', debounce(async () => {
101
- const envFiles = EnvUtil.getFile(process.env.NODE_ENV, argv.channel);
102
- await EnvUtil.importFile({
103
- cwd: process.cwd(),
104
- file: envFiles
105
- });
106
- EnvUtil.outputTypes({
107
- cwd: process.cwd(),
108
- file: envFiles,
109
- outFile: 'env.d.ts'
110
- });
111
- generateManyIndex({
112
- cwd: process.cwd(),
113
- patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', '!src/handlers/**/*', ...(argv.index || [])],
114
- replaceFile: true,
115
- onSuccess: filePath => {
116
- console.log(`✔️ 索引文件已更新: ${filePath}`);
76
+ channel: argv.channel,
77
+ cb: async channel => {
78
+ process.env.NODE_ENV = 'development';
79
+ let lastRun;
80
+ const run = () => {
81
+ lastRun = DevUtil.runFile({
82
+ file: 'src/main.ts',
83
+ cwd: process.cwd(),
84
+ runner: argv.tsx ? 'tsx' : 'esbuild-register'
85
+ });
86
+ };
87
+ if (argv.npc) {
88
+ const [server, vkey] = argv.npc.split('@');
89
+ execa('docker', ['run', '--rm', 'ffdfgdfg/npc:v0.26.9', `-server=${server}`, `-vkey=${vkey}`, '-type=tcp'], {
90
+ cwd: process.cwd(),
91
+ stdio: 'inherit'
92
+ });
117
93
  }
118
- });
119
- if (lastRun) {
120
- console.log('==== 重启服务中 ====');
121
- lastRun.kill();
122
- setTimeout(run, 0);
123
- } else {
124
- console.log('==== 启动服务中 ====');
125
- run();
94
+ await TemplateUtil.init(process.cwd());
95
+ const xsignoreFile = path.join(process.cwd(), '.xsignore');
96
+ const xsignoreContent = (await fs.pathExists(xsignoreFile)) ? (await fs.readFile(xsignoreFile, 'utf-8')).trim().split(/[\r\n]+/g).filter(v => v && !v.startsWith('#')) : [];
97
+ const watcher = chokidar.watch(['src', '.env', '.env*'], {
98
+ cwd: process.cwd(),
99
+ ignored: ['**/*.test.*', ...xsignoreContent]
100
+ });
101
+ watcher.on('all', debounce(async () => {
102
+ const envFiles = EnvUtil.getFile(process.env.NODE_ENV, channel);
103
+ await EnvUtil.importFile({
104
+ cwd: process.cwd(),
105
+ file: envFiles
106
+ });
107
+ EnvUtil.outputTypes({
108
+ cwd: process.cwd(),
109
+ file: envFiles,
110
+ outFile: 'env.d.ts'
111
+ });
112
+ generateManyIndex({
113
+ cwd: process.cwd(),
114
+ patterns: ['src/**/index.ts', 'node_modules/.x/*.ts', '!src/handlers/**/*', ...(argv.index || [])],
115
+ replaceFile: true,
116
+ onSuccess: filePath => {
117
+ console.log(`✔️ 索引文件已更新: ${filePath}`);
118
+ }
119
+ });
120
+ if (lastRun) {
121
+ console.log('==== 重启服务中 ====');
122
+ lastRun.kill();
123
+ setTimeout(run, 0);
124
+ } else {
125
+ console.log('==== 启动服务中 ====');
126
+ run();
127
+ }
128
+ }, 30));
126
129
  }
127
- }, 30));
130
+ });
128
131
  }).command('build', '构建', _ => _.positional('external', {
129
132
  alias: 'e',
130
133
  describe: '不应该被打的包',
@@ -205,16 +208,19 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
205
208
  describe: '渠道',
206
209
  type: 'string'
207
210
  }), async argv => {
208
- if (argv.channel === '_') {
209
- argv.channel = await EnvUtil.chooseChannel(process.cwd());
210
- }
211
- process.env.NODE_ENV = 'production';
212
- const envFiles = EnvUtil.getFile(process.env.NODE_ENV, argv.channel);
213
- await EnvUtil.importFile({
211
+ await EnvUtil.withChannel({
214
212
  cwd: process.cwd(),
215
- file: envFiles
213
+ channel: argv.channel,
214
+ cb: async channel => {
215
+ process.env.NODE_ENV = 'production';
216
+ const envFiles = EnvUtil.getFile(process.env.NODE_ENV, channel);
217
+ await EnvUtil.importFile({
218
+ cwd: process.cwd(),
219
+ file: envFiles
220
+ });
221
+ await new ApiGenerator().start();
222
+ }
216
223
  });
217
- await new ApiGenerator().start();
218
224
  }).command('prisma', 'prisma 代理,主要为了注入环境变量', _ => _.positional('production', {
219
225
  alias: 'p',
220
226
  describe: '是否生产模式',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.79.0",
3
+ "version": "2.79.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",