@giteeteam/apps-cli 0.1.15 → 0.1.17-alpha.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.
Files changed (2) hide show
  1. package/dist/index.js +66 -8
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -9,11 +9,12 @@ var archiver = require('archiver');
9
9
  var ora = require('ora');
10
10
  var yaml = require('yaml');
11
11
  var inquirer = require('inquirer');
12
- var simpleGit = require('simple-git');
13
12
  var uuid = require('uuid');
13
+ var simpleGit = require('simple-git');
14
14
  var chalk = require('chalk');
15
15
  var readline = require('readline');
16
16
  var execa = require('execa');
17
+ var child_process = require('child_process');
17
18
 
18
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
20
 
@@ -25,8 +26,9 @@ var inquirer__default = /*#__PURE__*/_interopDefaultLegacy(inquirer);
25
26
  var simpleGit__default = /*#__PURE__*/_interopDefaultLegacy(simpleGit);
26
27
  var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
27
28
  var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
29
+ var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
28
30
 
29
- var version = "0.1.15";
31
+ var version = "0.1.17-alpha.0";
30
32
 
31
33
  const packageApp = async ({ outputDir, manifest, copyFiles }) => {
32
34
  const { resources } = manifest;
@@ -124,7 +126,7 @@ const getManifestObject = async () => {
124
126
  return obj;
125
127
  };
126
128
 
127
- var run$1 = async ({ outputDir, inputDir, prod, copyFiles, zip }) => {
129
+ var run$2 = async ({ outputDir, inputDir, prod, copyFiles, zip }) => {
128
130
  const manifest = await getManifestObject();
129
131
  const { app: { version, key }, } = manifest;
130
132
  if (!key) {
@@ -163,7 +165,7 @@ var run$1 = async ({ outputDir, inputDir, prod, copyFiles, zip }) => {
163
165
  const defaultCopyFiles = ['manifest.yml'];
164
166
  var build = async (options) => {
165
167
  const { input = 'src', output = 'dist', prod, copy = [], zip } = options;
166
- await run$1({
168
+ await run$2({
167
169
  outputDir: path__default["default"].resolve(output),
168
170
  inputDir: path__default["default"].resolve(input),
169
171
  prod: !!prod,
@@ -190,7 +192,7 @@ const templateURL = 'https://github.com/moriahq/apps-template.git';
190
192
  var TemplateType;
191
193
  (function (TemplateType) {
192
194
  TemplateType["micro"] = "micro";
193
- // 'uikit' = 'uikit',
195
+ TemplateType["uikit"] = "uikit";
194
196
  })(TemplateType || (TemplateType = {}));
195
197
  // 重写替换文件内带模版的地方。格式为 {{field}}
196
198
  // options为字段变量
@@ -258,7 +260,7 @@ const selectTemplate = async () => {
258
260
  const result = await prompt({
259
261
  type: 'list',
260
262
  name: 'Please select template type',
261
- choices: Object.keys(TemplateType),
263
+ choices: [TemplateType.micro],
262
264
  });
263
265
  return Object.values(result)[0];
264
266
  };
@@ -276,7 +278,7 @@ const dependenciesInstall = async (projectPath) => {
276
278
  succeed: 'Install dependencies success!',
277
279
  }, () => command.executeCommand('yarn', ['install'], projectPath));
278
280
  };
279
- var run = async (options) => {
281
+ var run$1 = async (options) => {
280
282
  const { cwd, packageName } = options;
281
283
  const projectPath = path__default["default"].join(cwd, packageName);
282
284
  if (await fse__default["default"].pathExists(projectPath)) {
@@ -324,12 +326,67 @@ var create = async (packageName) => {
324
326
  console.error('Please input your project name');
325
327
  return;
326
328
  }
327
- await run({
329
+ await run$1({
328
330
  cwd,
329
331
  packageName,
330
332
  });
331
333
  };
332
334
 
335
+ const containerName = 'cli-dev-apps-runtime-server';
336
+ class DockerService {
337
+ constructor(imageName) {
338
+ this.imageName = imageName;
339
+ }
340
+ async downloadImage() {
341
+ await this.execPromise(`docker pull ${this.imageName}`);
342
+ }
343
+ async runContainer() {
344
+ const command = `docker run -d -p 8455:8455 -e PORT=8455 --name ${containerName} ${this.imageName}`;
345
+ await this.execPromise(command);
346
+ }
347
+ async removeContainer() {
348
+ await this.execPromise(`docker rm -f ${containerName}`);
349
+ }
350
+ execPromise(cmd) {
351
+ return new Promise(resolve => {
352
+ child_process__default["default"].exec(cmd, (err, stdout, stderr) => {
353
+ resolve({
354
+ err: err,
355
+ stdout: stdout,
356
+ stderr: stderr,
357
+ });
358
+ });
359
+ });
360
+ }
361
+ }
362
+
363
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
364
+ var run = async (options) => {
365
+ const { imageName } = options;
366
+ const dockerService = new DockerService(imageName);
367
+ process.on('SIGINT', () => {
368
+ console.log('process,SIGINT');
369
+ dockerService.removeContainer();
370
+ process.exit();
371
+ });
372
+ await dockerService.downloadImage();
373
+ await dockerService.runContainer();
374
+ await sleep(30000);
375
+ };
376
+
377
+ const image = {
378
+ repository: 'registry.baidubce.com/proxima/proxima-apps-runtime-server',
379
+ tag: '2.5.0-alpha-41',
380
+ };
381
+ var dev = async (options) => {
382
+ const { input = 'src', output = 'dist' } = options;
383
+ await run({
384
+ imageName: `${image.repository}:${image.tag}`,
385
+ outputDir: path__default["default"].resolve(output),
386
+ inputDir: path__default["default"].resolve(input),
387
+ });
388
+ };
389
+
333
390
  const program = new commander.Command();
334
391
  program.version(version).description('Giteeteam Apps Cli');
335
392
  program
@@ -341,4 +398,5 @@ program
341
398
  .option('-o --output [dir]', 'output dir')
342
399
  .action(build);
343
400
  program.command('create [name]').action(create);
401
+ program.command('dev').action(dev);
344
402
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-cli",
3
- "version": "0.1.15",
3
+ "version": "0.1.17-alpha.0",
4
4
  "description": "Giteeteam Apps cli",
5
5
  "keywords": [
6
6
  "typescript",
@@ -41,6 +41,7 @@
41
41
  "@giteeteam/apps-bundler": "^0.1.7",
42
42
  "archiver": "^5.3.1",
43
43
  "chalk": "^4.1.2",
44
+ "chokidar": "^3.5.3",
44
45
  "commander": "^9.3.0",
45
46
  "execa": "^5.1.1",
46
47
  "fs-extra": "^10.1.0",
@@ -56,5 +57,5 @@
56
57
  "@types/inquirer": "^8.2.1",
57
58
  "@types/uuid": "^8.3.4"
58
59
  },
59
- "gitHead": "e6150c7c1dd0a090fb03c0b506bd530ae19976a3"
60
+ "gitHead": "2151038acb5e1e9695f11009e542187839482907"
60
61
  }