@into-cps-association/libms 0.5.0 → 0.5.2
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/DEVELOPER.md +11 -29
- package/README.md +64 -35
- package/config/http.json +1 -0
- package/config/libms.yaml.default +12 -0
- package/dist/src/app.module.js +5 -6
- package/dist/src/app.module.js.map +1 -1
- package/dist/src/bootstrap.js +11 -21
- package/dist/src/bootstrap.js.map +1 -1
- package/dist/src/config/config.interface.d.ts +14 -0
- package/dist/src/config/config.interface.js +2 -0
- package/dist/src/config/config.interface.js.map +1 -0
- package/dist/src/config/config.model.d.ts +14 -0
- package/dist/src/config/config.model.js +2 -0
- package/dist/src/config/config.model.js.map +1 -0
- package/dist/src/config/config.module.d.ts +2 -0
- package/dist/src/config/config.module.js +33 -0
- package/dist/src/config/config.module.js.map +1 -0
- package/dist/src/config/config.service.d.ts +17 -0
- package/dist/src/config/config.service.js +61 -0
- package/dist/src/config/config.service.js.map +1 -0
- package/dist/src/config/util.d.ts +1 -0
- package/dist/src/config/util.js +5 -0
- package/dist/src/config/util.js.map +1 -0
- package/dist/src/files/files-service.factory.d.ts +2 -2
- package/dist/src/files/files-service.factory.js +4 -1
- package/dist/src/files/files-service.factory.js.map +1 -1
- package/dist/src/files/files.module.js +2 -2
- package/dist/src/files/files.module.js.map +1 -1
- package/dist/src/files/git/git-files.service.d.ts +4 -2
- package/dist/src/files/git/git-files.service.js +31 -20
- package/dist/src/files/git/git-files.service.js.map +1 -1
- package/dist/src/files/interfaces/files.service.interface.d.ts +1 -0
- package/dist/src/files/local/local-files.service.d.ts +3 -2
- package/dist/src/files/local/local-files.service.js +12 -4
- package/dist/src/files/local/local-files.service.js.map +1 -1
- package/dist/src/main.d.ts +4 -1
- package/dist/test/cloudcmd/cloudcmd.spec.js +3 -3
- package/dist/test/cloudcmd/cloudcmd.spec.js.map +1 -1
- package/dist/test/e2e/app.e2e.spec.js +18 -12
- package/dist/test/e2e/app.e2e.spec.js.map +1 -1
- package/dist/test/integration/files.service.integration.spec.js +6 -6
- package/dist/test/integration/files.service.integration.spec.js.map +1 -1
- package/dist/test/testUtil.d.ts +7 -1
- package/dist/test/testUtil.js +20 -17
- package/dist/test/testUtil.js.map +1 -1
- package/dist/test/unit/files-service.factory.unit.spec.js +20 -8
- package/dist/test/unit/files-service.factory.unit.spec.js.map +1 -1
- package/dist/test/unit/files.resolver.unit.spec.js +1 -0
- package/dist/test/unit/files.resolver.unit.spec.js.map +1 -1
- package/dist/test/unit/git-files.service.unit.spec.js +6 -5
- package/dist/test/unit/git-files.service.unit.spec.js.map +1 -1
- package/dist/test/unit/local-files.service.unit.spec.js +36 -21
- package/dist/test/unit/local-files.service.unit.spec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +5 -0
- package/libms.yaml.sample +12 -0
- package/package.json +10 -8
- package/src/app.module.ts +6 -7
- package/src/bootstrap.ts +14 -21
- package/src/config/config.interface.ts +14 -0
- package/src/config/config.model.ts +13 -0
- package/src/config/config.module.ts +23 -0
- package/src/config/config.service.ts +54 -0
- package/src/config/util.ts +5 -0
- package/src/files/files-service.factory.ts +5 -3
- package/src/files/files.module.ts +3 -3
- package/src/files/git/git-files.service.ts +28 -21
- package/src/files/interfaces/files.service.interface.ts +1 -0
- package/src/files/local/local-files.service.ts +13 -4
- package/src/main.ts +1 -1
- package/test/cloudcmd/cloudcmd.spec.ts +4 -4
- package/test/data/user2/tools/large_file.md +1 -0
- package/test/e2e/app.e2e.spec.ts +23 -13
- package/test/integration/files.service.integration.spec.ts +9 -10
- package/test/jest-e2e.json +3 -0
- package/test/libms.test.yaml +6 -0
- package/test/testUtil.ts +23 -19
- package/test/unit/files-service.factory.unit.spec.ts +22 -11
- package/test/unit/files.resolver.unit.spec.ts +1 -0
- package/test/unit/git-files.service.unit.spec.ts +6 -5
- package/test/unit/local-files.service.unit.spec.ts +41 -25
- package/test/update-config.js +25 -0
- package/config/.env.default +0 -6
package/DEVELOPER.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Developer Instructions
|
|
2
2
|
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
The **pm2** package needs to be available for tests.
|
|
6
|
+
You can install the same by executing
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install -g pm2
|
|
10
|
+
```
|
|
11
|
+
|
|
3
12
|
## :gear: Configure
|
|
4
13
|
|
|
5
14
|
This microservice needs library assets and configuration
|
|
@@ -26,34 +35,7 @@ yarn clean # Deletes "build", "coverage", "dist" and other temp files
|
|
|
26
35
|
```
|
|
27
36
|
|
|
28
37
|
**NOTE:** The integration, end-to-end and http tests require a valid
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```ini
|
|
32
|
-
PORT='4001'
|
|
33
|
-
MODE='local'
|
|
34
|
-
LOCAL_PATH ='/Users/<Username>/DTaaS/files'
|
|
35
|
-
LOG_LEVEL='debug'
|
|
36
|
-
APOLLO_PATH='/lib'
|
|
37
|
-
GRAPHQL_PLAYGROUND='true'
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Here is another with `git` mode.
|
|
41
|
-
|
|
42
|
-
```ini
|
|
43
|
-
PORT='4001'
|
|
44
|
-
MODE='git'
|
|
45
|
-
LOCAL_PATH ='/Users/<Username>/DTaaS/files'
|
|
46
|
-
LOG_LEVEL='debug'
|
|
47
|
-
APOLLO_PATH='/lib'
|
|
48
|
-
GRAPHQL_PLAYGROUND='true'
|
|
49
|
-
|
|
50
|
-
GIT_USER1_REPO_URL='<git repo url>'
|
|
51
|
-
GIT_USER1_API_TOKEN='<TOKEN>'
|
|
52
|
-
...
|
|
53
|
-
GIT_USERX_REPO_URL='<git repo url>'
|
|
54
|
-
GIT_USERX_API_TOKEN='<TOKEN>'
|
|
55
|
-
```
|
|
56
|
-
|
|
38
|
+
configuration. This configuration is already set in `libms.test.yaml` file.
|
|
57
39
|
|
|
58
40
|
## Service Endpoint
|
|
59
41
|
|
|
@@ -99,7 +81,7 @@ for more information publishing docker images.
|
|
|
99
81
|
The default registry for npm packages is [npmjs](https://registry.npmjs.org).
|
|
100
82
|
|
|
101
83
|
```bash
|
|
102
|
-
|
|
84
|
+
npm install -g @into-cps-association/libms
|
|
103
85
|
```
|
|
104
86
|
|
|
105
87
|
The steps for publishing the package to npmjs are listed in
|
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# Overview
|
|
2
2
|
|
|
3
|
-
The **lib microservice** is a simplified file manager
|
|
4
|
-
It
|
|
3
|
+
The **lib microservice** is a simplified file manager which serves files
|
|
4
|
+
from local file system or public git repositories. It is possible to
|
|
5
5
|
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Upload and download files from web browser
|
|
7
|
+
* Query available files and download them using GraphQL API
|
|
8
|
+
* Clone public git repositories and serve them as local files
|
|
8
9
|
|
|
9
10
|
## :arrow_down: Install
|
|
10
11
|
|
|
@@ -14,14 +15,9 @@ The default registry for npm packages is [npmjs](https://registry.npmjs.org).
|
|
|
14
15
|
Install the package with the following commands
|
|
15
16
|
|
|
16
17
|
```bash
|
|
17
|
-
|
|
18
|
+
npm install -g @into-cps-association/libms
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
The package on [npmjs](https://registry.npmjs.org) is published
|
|
21
|
-
less frequently than the one on Github NPM Registry. But
|
|
22
|
-
the package on npmjs is more stable version of libms and should
|
|
23
|
-
be used for production purposes.
|
|
24
|
-
|
|
25
21
|
### Github NPM Registry
|
|
26
22
|
|
|
27
23
|
The package is also available in Github
|
|
@@ -30,8 +26,8 @@ The package is also available in Github
|
|
|
30
26
|
Set the registry and install the package with the following commands
|
|
31
27
|
|
|
32
28
|
```bash
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
npm config set @into-cps-association:registry https://npm.pkg.github.com
|
|
30
|
+
npm install -g @into-cps-association/libms
|
|
35
31
|
```
|
|
36
32
|
|
|
37
33
|
The _npm install_ command asks for username and password. The username is
|
|
@@ -45,29 +41,61 @@ needs to have _read:packages_ scope.
|
|
|
45
41
|
The microservices requires config specified in INI format.
|
|
46
42
|
The template configuration file is:
|
|
47
43
|
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
```yaml
|
|
45
|
+
port: '4001'
|
|
46
|
+
mode: 'git' # either git or local
|
|
47
|
+
local-path: 'files'
|
|
48
|
+
log-level: 'debug'
|
|
49
|
+
apollo-path: '/lib'
|
|
50
|
+
graphql-playground: 'true'
|
|
51
|
+
|
|
52
|
+
git-repos:
|
|
53
|
+
- user-1:
|
|
54
|
+
repo-url: 'https://github.com/isomorphic-git/lightning-fs'
|
|
55
|
+
- user-2:
|
|
56
|
+
repo-url: 'https://gitlab.com/dtaas/user2.git'
|
|
57
|
+
- common:
|
|
58
|
+
repo-url: 'https://gitlab.com/dtaas/common'
|
|
63
59
|
```
|
|
64
60
|
|
|
65
|
-
The `
|
|
61
|
+
The `local-path` variable is the relative filepath to the
|
|
66
62
|
location of the local directory which will be served to users
|
|
67
63
|
by the Library microservice.
|
|
68
64
|
|
|
69
65
|
Replace the default values the appropriate values for your setup.
|
|
70
|
-
Please save this config in a file.
|
|
66
|
+
Please save this config in a file as a yaml file, for example as `libms.yaml`.
|
|
67
|
+
|
|
68
|
+
### Operation Modes
|
|
69
|
+
|
|
70
|
+
The mode indicates the backend storage for the files.
|
|
71
|
+
There are two possible modes - `local` and `git`.
|
|
72
|
+
The files available in the `local-path` are served to users in `local` mode.
|
|
73
|
+
In the `git` mode, the remote git repos are cloned and they are
|
|
74
|
+
served to users as local files.
|
|
75
|
+
|
|
76
|
+
#### git mode
|
|
77
|
+
|
|
78
|
+
A fragment of the config for `git` mode is:
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
...
|
|
82
|
+
git-repos:
|
|
83
|
+
- user-1:
|
|
84
|
+
repo-url: 'https://github.com/isomorphic-git/lightning-fs'
|
|
85
|
+
- user-2:
|
|
86
|
+
repo-url: 'https://gitlab.com/dtaas/user2.git'
|
|
87
|
+
- common:
|
|
88
|
+
repo-url: 'https://gitlab.com/dtaas/common'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Here, `user-1`, `user-2` and `common` are the local directories into which
|
|
92
|
+
the remote git repositories get cloned. The name of the repository need not
|
|
93
|
+
match with the local directory name. For example, the above configuration
|
|
94
|
+
enables library microservice to clone
|
|
95
|
+
`https://github.com/isomorphic-git/lightning-fs` repository into
|
|
96
|
+
`user-1` directory. Any git server accessible over
|
|
97
|
+
HTTP(S) protocol is supported.
|
|
98
|
+
The `.git` suffix is optional.
|
|
71
99
|
|
|
72
100
|
## :rocket: Use
|
|
73
101
|
|
|
@@ -81,7 +109,7 @@ The lib microservice is a file server. It supports file transfer
|
|
|
81
109
|
over GraphQL and HTTP protocols.
|
|
82
110
|
|
|
83
111
|
Options:
|
|
84
|
-
-c, --config <file> provide the config file (default .
|
|
112
|
+
-c, --config <file> provide the config file (default libms.yaml)
|
|
85
113
|
-H, --http <file> enable the HTTP server with the specified config
|
|
86
114
|
-h, --help display help for libms
|
|
87
115
|
```
|
|
@@ -90,9 +118,9 @@ Both the options are not mandatory.
|
|
|
90
118
|
|
|
91
119
|
### Configuration file
|
|
92
120
|
|
|
93
|
-
The config is saved
|
|
121
|
+
The config is saved `libms.yaml` file by convention. If `-c` is not specified
|
|
94
122
|
The **libms** looks for
|
|
95
|
-
|
|
123
|
+
`libms.yaml` file in the working directory from which it is run.
|
|
96
124
|
If you want to run **libms** without explicitly specifying the configuration
|
|
97
125
|
file, run
|
|
98
126
|
|
|
@@ -107,11 +135,11 @@ libms -c FILE-PATH
|
|
|
107
135
|
libms --config FILE-PATH
|
|
108
136
|
```
|
|
109
137
|
|
|
110
|
-
If the environment file is named something other than
|
|
111
|
-
for example as `config
|
|
138
|
+
If the environment file is named something other than `libms.yaml`,
|
|
139
|
+
for example as `config/libms.yaml.default`, you can run
|
|
112
140
|
|
|
113
141
|
```sh
|
|
114
|
-
libms -c "config
|
|
142
|
+
libms -c "config/libms.yaml.default"
|
|
115
143
|
```
|
|
116
144
|
|
|
117
145
|
You can press `Ctl+C` to halt the application.
|
|
@@ -150,6 +178,7 @@ libms --http FILE-PATH
|
|
|
150
178
|
"confirmCopy": true,
|
|
151
179
|
"confirmMove": true,
|
|
152
180
|
"showConfig": false,
|
|
181
|
+
"showDotFiles": false,
|
|
153
182
|
"showFileName": true,
|
|
154
183
|
"contact": false,
|
|
155
184
|
"configDialog": false,
|
package/config/http.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
port: '4001'
|
|
2
|
+
mode: 'git'
|
|
3
|
+
local-path: '..\..\files'
|
|
4
|
+
log-level: 'debug'
|
|
5
|
+
apollo-path: '/lib'
|
|
6
|
+
graphql-playground: 'true'
|
|
7
|
+
|
|
8
|
+
git-repos:
|
|
9
|
+
- user-1:
|
|
10
|
+
repo-url: 'https://github.com/isomorphic-git/lightning-fs'
|
|
11
|
+
- user-2:
|
|
12
|
+
repo-url: 'https://github.com/isomorphic-git/lightning-fs'
|
package/dist/src/app.module.js
CHANGED
|
@@ -4,27 +4,26 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
8
7
|
import { Module } from '@nestjs/common';
|
|
9
8
|
import { GraphQLModule } from '@nestjs/graphql';
|
|
10
9
|
import { ApolloDriver } from '@nestjs/apollo';
|
|
11
10
|
import { join } from 'path';
|
|
12
11
|
import FilesModule from './files/files.module.js';
|
|
12
|
+
import { ConfigModule } from './config/config.module.js';
|
|
13
|
+
import { CONFIG_SERVICE } from './config/config.interface.js';
|
|
13
14
|
let AppModule = class AppModule {
|
|
14
15
|
};
|
|
15
16
|
AppModule = __decorate([
|
|
16
17
|
Module({
|
|
17
18
|
imports: [
|
|
18
|
-
ConfigModule
|
|
19
|
-
isGlobal: true,
|
|
20
|
-
}),
|
|
19
|
+
ConfigModule,
|
|
21
20
|
GraphQLModule.forRootAsync({
|
|
22
21
|
driver: ApolloDriver,
|
|
23
22
|
useFactory: (configService) => ({
|
|
24
23
|
autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
|
|
25
|
-
path: configService.
|
|
24
|
+
path: configService.getApolloPath(),
|
|
26
25
|
}),
|
|
27
|
-
inject: [
|
|
26
|
+
inject: [CONFIG_SERVICE],
|
|
28
27
|
}),
|
|
29
28
|
FilesModule,
|
|
30
29
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAW,MAAM,8BAA8B,CAAC;AAgBxD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAd7B,MAAM,CAAC;QACN,OAAO,EAAE;YACP,YAAY;YACZ,aAAa,CAAC,YAAY,CAAC;gBACzB,MAAM,EAAE,YAAY;gBACpB,UAAU,EAAE,CAAC,aAAsB,EAAE,EAAE,CAAC,CAAC;oBACvC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;oBACrD,IAAI,EAAE,aAAa,CAAC,aAAa,EAAE;iBACpC,CAAC;gBACF,MAAM,EAAE,CAAC,cAAc,CAAC;aACzB,CAAC;YACF,WAAW;SACZ;KACF,CAAC;GACmB,SAAS,CAAG;eAAZ,SAAS"}
|
package/dist/src/bootstrap.js
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import { NestFactory } from '@nestjs/core';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import * as dotenv from 'dotenv';
|
|
4
2
|
import AppModule from './app.module.js';
|
|
5
3
|
import cloudCMD from './cloudcmd/cloudcmd.js';
|
|
4
|
+
import { Logger } from '@nestjs/common';
|
|
5
|
+
import { CONFIG_SERVICE } from './config/config.interface.js';
|
|
6
6
|
export default async function bootstrap(options) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
if (configFile.error && process.env.LOCAL_PATH === undefined) {
|
|
12
|
-
console.error(configFile.error);
|
|
13
|
-
if (options.runHelp) {
|
|
14
|
-
options.runHelp();
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
7
|
+
const logger = new Logger(bootstrap.name);
|
|
8
|
+
if (process.env.LIBMS_CONFIG_PATH == null)
|
|
9
|
+
process.env.LIBMS_CONFIG_PATH = options.config ?? 'libms.yaml';
|
|
20
10
|
const app = await NestFactory.create(AppModule);
|
|
21
|
-
const configService = app.get(
|
|
22
|
-
const port = configService.
|
|
23
|
-
const localPath = configService.
|
|
24
|
-
const mode = configService.
|
|
25
|
-
|
|
11
|
+
const configService = app.get(CONFIG_SERVICE);
|
|
12
|
+
const port = configService.getPort();
|
|
13
|
+
const localPath = configService.getLocalPath();
|
|
14
|
+
const mode = configService.getMode();
|
|
15
|
+
logger.log(`\x1b[32mStarting libms in \x1b[33m${mode} \x1b[32mmode, serving files from \x1b[34m${localPath} \x1b[32mon port \x1b[35m${port}\x1b[0m`);
|
|
26
16
|
if (options.httpServer) {
|
|
27
|
-
cloudCMD(app, options.httpServer, configService.
|
|
17
|
+
cloudCMD(app, options.httpServer, configService.getLocalPath());
|
|
28
18
|
}
|
|
29
19
|
await app.listen(port);
|
|
30
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAW,MAAM,8BAA8B,CAAC;AAQvE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,SAAS,CAAC,OAA0B;IAChE,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAE1C,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI;QACvC,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC;IAEjE,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,cAAc,CAAY,CAAC;IACzD,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;IACrC,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,EAAE,CAAC;IAC/C,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;IAErC,MAAM,CAAC,GAAG,CACR,qCAAqC,IAAI,6CAA6C,SAAS,4BAA4B,IAAI,SAAS,CACzI,CAAC;IAEF,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,YAAY,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GitRepo } from './config.model';
|
|
2
|
+
export declare const CONFIG_SERVICE = "CONFIG_SERVICE";
|
|
3
|
+
export interface IConfig {
|
|
4
|
+
loadConfig(configPath: string): Promise<void>;
|
|
5
|
+
getLocalPath(): string;
|
|
6
|
+
getApolloPath(): string;
|
|
7
|
+
getMode(): string;
|
|
8
|
+
getPort(): number;
|
|
9
|
+
getLogLevel(): string;
|
|
10
|
+
getGraphqlPlayground(): string;
|
|
11
|
+
getGitRepos(): {
|
|
12
|
+
[key: string]: GitRepo;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.interface.js","sourceRoot":"","sources":["../../../src/config/config.interface.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ConfigValues = {
|
|
2
|
+
port: number;
|
|
3
|
+
'local-path': string;
|
|
4
|
+
mode: string;
|
|
5
|
+
'log-level': string;
|
|
6
|
+
'apollo-path': string;
|
|
7
|
+
'graphql-playground': string;
|
|
8
|
+
'git-repos': {
|
|
9
|
+
[key: string]: GitRepo;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
export type GitRepo = {
|
|
13
|
+
'repo-url': string;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.model.js","sourceRoot":"","sources":["../../../src/config/config.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Global, Module } from '@nestjs/common';
|
|
8
|
+
import * as nestConfig from '@nestjs/config';
|
|
9
|
+
import Config from './config.service.js';
|
|
10
|
+
import { CONFIG_SERVICE } from './config.interface.js';
|
|
11
|
+
let ConfigModule = class ConfigModule {
|
|
12
|
+
};
|
|
13
|
+
ConfigModule = __decorate([
|
|
14
|
+
Global(),
|
|
15
|
+
Module({
|
|
16
|
+
imports: [nestConfig.ConfigModule.forRoot({ isGlobal: true })],
|
|
17
|
+
providers: [
|
|
18
|
+
{
|
|
19
|
+
provide: CONFIG_SERVICE,
|
|
20
|
+
useFactory: async (envConfigservice) => {
|
|
21
|
+
const confPath = envConfigservice.get('LIBMS_CONFIG_PATH');
|
|
22
|
+
const config = new Config();
|
|
23
|
+
await config.loadConfig(confPath);
|
|
24
|
+
return config;
|
|
25
|
+
},
|
|
26
|
+
inject: [nestConfig.ConfigService],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
exports: [CONFIG_SERVICE],
|
|
30
|
+
})
|
|
31
|
+
], ConfigModule);
|
|
32
|
+
export { ConfigModule };
|
|
33
|
+
//# sourceMappingURL=config.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.module.js","sourceRoot":"","sources":["../../../src/config/config.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAmBhD,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IAjBxB,MAAM,EAAE;IACR,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9D,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,cAAc;gBACvB,UAAU,EAAE,KAAK,EAAE,gBAA0C,EAAE,EAAE;oBAC/D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAS,mBAAmB,CAAC,CAAC;oBACnE,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;oBAC5B,MAAM,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;oBAClC,OAAO,MAAM,CAAC;gBAChB,CAAC;gBACD,MAAM,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;aACnC;SACF;QACD,OAAO,EAAE,CAAC,cAAc,CAAC;KAC1B,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GitRepo } from './config.model.js';
|
|
2
|
+
import { IConfig } from './config.interface.js';
|
|
3
|
+
export default class Config implements IConfig {
|
|
4
|
+
private configValues;
|
|
5
|
+
private logger;
|
|
6
|
+
constructor();
|
|
7
|
+
loadConfig(configPath: string): Promise<void>;
|
|
8
|
+
getLocalPath(): string;
|
|
9
|
+
getApolloPath(): string;
|
|
10
|
+
getMode(): string;
|
|
11
|
+
getPort(): number;
|
|
12
|
+
getLogLevel(): string;
|
|
13
|
+
getGraphqlPlayground(): string;
|
|
14
|
+
getGitRepos(): {
|
|
15
|
+
[key: string]: GitRepo;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var Config_1;
|
|
11
|
+
import { readFileSync } from 'fs';
|
|
12
|
+
import * as yaml from 'js-yaml';
|
|
13
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
14
|
+
import resolveFile from './util.js';
|
|
15
|
+
let Config = Config_1 = class Config {
|
|
16
|
+
configValues;
|
|
17
|
+
logger;
|
|
18
|
+
constructor() {
|
|
19
|
+
this.logger = new Logger(Config_1.name);
|
|
20
|
+
}
|
|
21
|
+
async loadConfig(configPath) {
|
|
22
|
+
if (configPath !== undefined) {
|
|
23
|
+
try {
|
|
24
|
+
const configFile = readFileSync(resolveFile(configPath), 'utf8');
|
|
25
|
+
this.configValues = yaml.load(configFile);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
this.logger.error('Error loading config file', e);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
this.logger.log('Config loaded', this.configValues);
|
|
33
|
+
}
|
|
34
|
+
getLocalPath() {
|
|
35
|
+
return this.configValues['local-path'];
|
|
36
|
+
}
|
|
37
|
+
getApolloPath() {
|
|
38
|
+
return this.configValues['apollo-path'];
|
|
39
|
+
}
|
|
40
|
+
getMode() {
|
|
41
|
+
return this.configValues['mode'];
|
|
42
|
+
}
|
|
43
|
+
getPort() {
|
|
44
|
+
return this.configValues['port'];
|
|
45
|
+
}
|
|
46
|
+
getLogLevel() {
|
|
47
|
+
return this.configValues['log-level'];
|
|
48
|
+
}
|
|
49
|
+
getGraphqlPlayground() {
|
|
50
|
+
return this.configValues['graphql-playground'];
|
|
51
|
+
}
|
|
52
|
+
getGitRepos() {
|
|
53
|
+
return this.configValues['git-repos'];
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
Config = Config_1 = __decorate([
|
|
57
|
+
Injectable(),
|
|
58
|
+
__metadata("design:paramtypes", [])
|
|
59
|
+
], Config);
|
|
60
|
+
export default Config;
|
|
61
|
+
//# sourceMappingURL=config.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.service.js","sourceRoot":"","sources":["../../../src/config/config.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,WAAW,MAAM,WAAW,CAAC;AAIrB,IAAM,MAAM,cAAZ,MAAM,MAAM;IACjB,YAAY,CAAe;IAC3B,MAAM,CAAS;IAEvB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,QAAM,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAkB;QACjC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;gBACjE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAiB,CAAC;YAC5D,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,CAAC,CAAC,CAAC;gBAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,WAAW;QACT,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IACD,oBAAoB;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;IACjD,CAAC;IACD,WAAW;QACT,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AA7CoB,MAAM;IAD1B,UAAU,EAAE;;GACQ,MAAM,CA6C1B;eA7CoB,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function resolveFile(name: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/config/util.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,IAAY;IAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
1
|
import { IFilesService } from './interfaces/files.service.interface.js';
|
|
2
|
+
import { IConfig } from 'src/config/config.interface.js';
|
|
3
3
|
export default class FilesServiceFactory {
|
|
4
|
-
static create(configService:
|
|
4
|
+
static create(configService: IConfig, fileServices: IFilesService[]): IFilesService;
|
|
5
5
|
}
|
|
@@ -7,11 +7,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Injectable } from '@nestjs/common';
|
|
8
8
|
let FilesServiceFactory = class FilesServiceFactory {
|
|
9
9
|
static create(configService, fileServices) {
|
|
10
|
-
const mode = configService.
|
|
10
|
+
const mode = configService.getMode();
|
|
11
11
|
const service = fileServices.find((s) => s.getMode() == mode);
|
|
12
12
|
if (service == undefined) {
|
|
13
13
|
throw new Error(`Invalid MODE: ${mode}`);
|
|
14
14
|
}
|
|
15
|
+
else {
|
|
16
|
+
service.init();
|
|
17
|
+
}
|
|
15
18
|
return service;
|
|
16
19
|
}
|
|
17
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-service.factory.js","sourceRoot":"","sources":["../../../src/files/files-service.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK7B,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACtC,MAAM,CAAC,MAAM,CACX,
|
|
1
|
+
{"version":3,"file":"files-service.factory.js","sourceRoot":"","sources":["../../../src/files/files-service.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK7B,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACtC,MAAM,CAAC,MAAM,CACX,aAAsB,EACtB,YAA6B;QAE7B,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC;QAE9D,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AAfoB,mBAAmB;IADvC,UAAU,EAAE;GACQ,mBAAmB,CAevC;eAfoB,mBAAmB"}
|
|
@@ -12,7 +12,7 @@ import LocalFilesService from './local/local-files.service.js';
|
|
|
12
12
|
import GitFilesService from './git/git-files.service.js';
|
|
13
13
|
import { FILE_SERVICE } from './interfaces/files.service.interface.js';
|
|
14
14
|
import FilesServiceFactory from './files-service.factory.js';
|
|
15
|
-
import {
|
|
15
|
+
import { CONFIG_SERVICE } from '../config/config.interface.js';
|
|
16
16
|
let FilesModule = class FilesModule {
|
|
17
17
|
};
|
|
18
18
|
FilesModule = __decorate([
|
|
@@ -26,7 +26,7 @@ FilesModule = __decorate([
|
|
|
26
26
|
const fileServices = [localFilesService, gitFilesService];
|
|
27
27
|
return FilesServiceFactory.create(configService, fileServices);
|
|
28
28
|
},
|
|
29
|
-
inject: [
|
|
29
|
+
inject: [CONFIG_SERVICE, LocalFilesService, GitFilesService],
|
|
30
30
|
},
|
|
31
31
|
],
|
|
32
32
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAW,MAAM,+BAA+B,CAAC;AAoBzD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IAlB/B,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,gBAAgB,EAAE,cAAc,CAAC;QAC3C,SAAS,EAAE;YACT,aAAa;YACb;gBACE,OAAO,EAAE,YAAY;gBACrB,UAAU,EAAE,CACV,aAAsB,EACtB,iBAAoC,EACpC,eAAgC,EAChC,EAAE;oBACF,MAAM,YAAY,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;oBAC1D,OAAO,mBAAmB,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;gBACjE,CAAC;gBACD,MAAM,EAAE,CAAC,cAAc,EAAE,iBAAiB,EAAE,eAAe,CAAC;aAC7D;SACF;KACF,CAAC;GACmB,WAAW,CAAG;eAAd,WAAW"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Project } from 'src/types.js';
|
|
2
2
|
import { IFilesService } from '../interfaces/files.service.interface.js';
|
|
3
3
|
import { CONFIG_MODE } from '../../enums/config-mode.enum.js';
|
|
4
|
-
import
|
|
4
|
+
import Config from '../../config/config.service.js';
|
|
5
5
|
export default class GitFilesService implements IFilesService {
|
|
6
6
|
private configService;
|
|
7
7
|
private readonly dataPath;
|
|
8
|
+
private readonly logger;
|
|
8
9
|
private localFilesService;
|
|
9
|
-
constructor(configService:
|
|
10
|
+
constructor(configService: Config);
|
|
11
|
+
init(): Promise<any>;
|
|
10
12
|
private cloneRepositories;
|
|
11
13
|
getMode(): CONFIG_MODE;
|
|
12
14
|
listDirectory(path: string): Promise<Project>;
|