@giteeteam/apps-cli 0.1.17 → 0.2.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.
- package/README.md +7 -2
- package/dist/index.js +57 -12
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -8,10 +8,15 @@ $ npm install @giteeteam/apps-cli -g
|
|
|
8
8
|
## 创建应用
|
|
9
9
|
```bash
|
|
10
10
|
// uikit-app为项目名称
|
|
11
|
-
$ giteeteam-apps
|
|
11
|
+
$ giteeteam-apps create uikit-app
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## 打包应用
|
|
15
15
|
```bash
|
|
16
|
-
$ giteeteam-apps
|
|
16
|
+
$ giteeteam-apps build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 调试插件function
|
|
20
|
+
```bash
|
|
21
|
+
$ giteeteam-apps dev
|
|
17
22
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
require('dotenv/config');
|
|
4
5
|
var commander = require('commander');
|
|
5
6
|
var appsBundler = require('@giteeteam/apps-bundler');
|
|
6
7
|
var fse = require('fs-extra');
|
|
@@ -30,7 +31,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
|
30
31
|
var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
|
|
31
32
|
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
|
|
32
33
|
|
|
33
|
-
var version = "0.
|
|
34
|
+
var version = "0.2.0";
|
|
34
35
|
|
|
35
36
|
const packageApp = async ({ outputDir, manifest, copyFiles }) => {
|
|
36
37
|
const { resources } = manifest;
|
|
@@ -379,19 +380,23 @@ var create = async (packageName) => {
|
|
|
379
380
|
});
|
|
380
381
|
};
|
|
381
382
|
|
|
382
|
-
const containerName = 'cli-dev-apps-runtime-server';
|
|
383
383
|
class DockerService {
|
|
384
384
|
constructor(imageName) {
|
|
385
385
|
this.imageName = imageName;
|
|
386
386
|
}
|
|
387
387
|
async downloadImage() {
|
|
388
388
|
await this.execPromise(`docker pull ${this.imageName}`);
|
|
389
|
+
console.log(`Download image(${this.imageName}) success`);
|
|
389
390
|
}
|
|
390
|
-
async runContainer() {
|
|
391
|
-
const
|
|
391
|
+
async runContainer({ port, env, name, volume = [] }) {
|
|
392
|
+
const envStr = Object.keys(env)
|
|
393
|
+
.map(k => `-e ${k}=${env[k]}`)
|
|
394
|
+
.join(' ');
|
|
395
|
+
const volumeStr = volume === null || volume === void 0 ? void 0 : volume.map(v => `-v ${v}`).join(' ');
|
|
396
|
+
const command = `docker run -d -p ${port}:${port} ${envStr} ${volumeStr} --name ${name} ${this.imageName}`;
|
|
392
397
|
await this.execPromise(command);
|
|
393
398
|
}
|
|
394
|
-
async removeContainer() {
|
|
399
|
+
async removeContainer(containerName) {
|
|
395
400
|
await this.execPromise(`docker rm -f ${containerName}`);
|
|
396
401
|
}
|
|
397
402
|
execPromise(cmd) {
|
|
@@ -412,9 +417,17 @@ const watchFiles = async (options) => {
|
|
|
412
417
|
const manifest = await getManifest();
|
|
413
418
|
const functionFiles = manifest.getFunctionFiles();
|
|
414
419
|
for (const fileName of functionFiles) {
|
|
415
|
-
|
|
420
|
+
appsBundler.bundle({
|
|
421
|
+
inputDir,
|
|
422
|
+
outputDir,
|
|
423
|
+
fileName,
|
|
424
|
+
mode: appsBundler.MODE.DEV,
|
|
425
|
+
});
|
|
426
|
+
const filePath = path__default["default"].join(inputDir, `${fileName}.ts`);
|
|
427
|
+
console.log(`watch file path: ${filePath}`);
|
|
416
428
|
const watcher = chokidar__default["default"].watch(filePath);
|
|
417
429
|
watcher.on('change', () => {
|
|
430
|
+
console.log(`File ${filePath} has been changed`);
|
|
418
431
|
appsBundler.bundle({
|
|
419
432
|
inputDir,
|
|
420
433
|
outputDir,
|
|
@@ -425,25 +438,53 @@ const watchFiles = async (options) => {
|
|
|
425
438
|
}
|
|
426
439
|
};
|
|
427
440
|
|
|
441
|
+
var _a$1;
|
|
442
|
+
const containerPort = Number((_a$1 = process.env.CONTAINER_PORT) !== null && _a$1 !== void 0 ? _a$1 : 8455);
|
|
443
|
+
const containerName = 'cli-dev-apps-runtime-server';
|
|
444
|
+
const copyManifest = async (pluginDir) => {
|
|
445
|
+
const manifestFile = path__default["default"].resolve('./manifest.yml');
|
|
446
|
+
const targetFile = path__default["default"].join(pluginDir, 'manifest.yml');
|
|
447
|
+
await fse__default["default"].copy(manifestFile, targetFile);
|
|
448
|
+
};
|
|
428
449
|
var run = async (options) => {
|
|
429
450
|
const { imageName, inputDir, outputDir } = options;
|
|
430
451
|
const dockerService = new DockerService(imageName);
|
|
452
|
+
const pluginDir = path__default["default"].join(outputDir, '_test/production/1.0/server-side');
|
|
431
453
|
await dockerService.downloadImage();
|
|
432
|
-
await dockerService.runContainer(
|
|
454
|
+
await dockerService.runContainer({
|
|
455
|
+
port: containerPort,
|
|
456
|
+
env: {
|
|
457
|
+
PORT: containerPort,
|
|
458
|
+
APPS_DIR: '/usr/src/app/apps',
|
|
459
|
+
LRU_TTL: 0,
|
|
460
|
+
DEBUG: 'runtime*',
|
|
461
|
+
PARSE_PUBLIC_SERVER_URL: process.env.PARSE_PUBLIC_SERVER_URL,
|
|
462
|
+
PARSE_SERVER_MASTER_KEY: process.env.PARSE_SERVER_MASTER_KEY,
|
|
463
|
+
PROXIMA_CORE_URL: process.env.PROXIMA_CORE_URL,
|
|
464
|
+
PGSQL_CLIENT_HOST: process.env.PGSQL_CLIENT_HOST,
|
|
465
|
+
PGSQL_CLIENT_PORT: process.env.PGSQL_CLIENT_PORT,
|
|
466
|
+
PGSQL_CLIENT_USER: process.env.PGSQL_CLIENT_USER,
|
|
467
|
+
PGSQL_CLIENT_PASSWORD: process.env.PGSQL_CLIENT_PASSWORD,
|
|
468
|
+
},
|
|
469
|
+
volume: [`${outputDir}:/usr/src/app/apps`],
|
|
470
|
+
name: containerName,
|
|
471
|
+
});
|
|
433
472
|
process.on('SIGINT', () => {
|
|
434
473
|
console.log('process,SIGINT');
|
|
435
|
-
dockerService.removeContainer();
|
|
474
|
+
dockerService.removeContainer(containerName);
|
|
436
475
|
process.exit();
|
|
437
476
|
});
|
|
438
|
-
await
|
|
477
|
+
await copyManifest(pluginDir);
|
|
478
|
+
await watchFiles({ inputDir, outputDir: pluginDir });
|
|
439
479
|
};
|
|
440
480
|
|
|
481
|
+
var _a;
|
|
441
482
|
const image = {
|
|
442
483
|
repository: 'registry.baidubce.com/proxima/proxima-apps-runtime-server',
|
|
443
|
-
tag: '2.5.0-alpha-41',
|
|
484
|
+
tag: (_a = process.env.IMAGE_TAG) !== null && _a !== void 0 ? _a : '2.5.0-alpha-41',
|
|
444
485
|
};
|
|
445
486
|
var dev = async (options) => {
|
|
446
|
-
const { input = 'src', output = '
|
|
487
|
+
const { input = 'src', output = 'cache' } = options;
|
|
447
488
|
await run({
|
|
448
489
|
imageName: `${image.repository}:${image.tag}`,
|
|
449
490
|
outputDir: path__default["default"].resolve(output),
|
|
@@ -462,5 +503,9 @@ program
|
|
|
462
503
|
.option('-o --output [dir]', 'output dir')
|
|
463
504
|
.action(build);
|
|
464
505
|
program.command('create [name]').action(create);
|
|
465
|
-
program
|
|
506
|
+
program
|
|
507
|
+
.command('dev')
|
|
508
|
+
.option('-i --input [dir]', 'input dir')
|
|
509
|
+
.option('-o --output [dir]', 'output dir,default cache')
|
|
510
|
+
.action(dev);
|
|
466
511
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giteeteam/apps-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Giteeteam Apps cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -39,11 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@giteeteam/apps-bundler": "^0.1.7",
|
|
42
|
-
"@giteeteam/apps-manifest": "^0.0
|
|
42
|
+
"@giteeteam/apps-manifest": "^0.1.0",
|
|
43
43
|
"archiver": "^5.3.1",
|
|
44
44
|
"chalk": "^4.1.2",
|
|
45
45
|
"chokidar": "^3.5.3",
|
|
46
46
|
"commander": "^9.3.0",
|
|
47
|
+
"dotenv": "^16.0.2",
|
|
47
48
|
"execa": "^5.1.1",
|
|
48
49
|
"fs-extra": "^10.1.0",
|
|
49
50
|
"inquirer": "^8.2.4",
|
|
@@ -58,5 +59,5 @@
|
|
|
58
59
|
"@types/inquirer": "^8.2.1",
|
|
59
60
|
"@types/uuid": "^8.3.4"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "11be8747537fcd607f97a80f5f3e07a592e85b14"
|
|
62
63
|
}
|