@into-cps-association/libms 0.4.7 → 0.5.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.
- package/DEVELOPER.md +18 -0
- package/README.md +9 -0
- package/config/http.json +1 -0
- package/dist/src/app.module.js +5 -6
- package/dist/src/app.module.js.map +1 -1
- package/dist/src/bootstrap.js +11 -18
- 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.module.js +2 -1
- package/dist/src/files/git/git-files.module.js.map +1 -1
- package/dist/src/files/git/git-files.service.d.ts +10 -3
- package/dist/src/files/git/git-files.service.js +58 -9
- 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 -14
- package/dist/test/testUtil.js.map +1 -1
- package/dist/test/unit/files-service.factory.unit.spec.js +25 -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.d.ts +1 -0
- package/dist/test/unit/git-files.service.unit.spec.js +56 -0
- package/dist/test/unit/git-files.service.unit.spec.js.map +1 -0
- 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 +14 -11
- package/src/app.module.ts +6 -7
- package/src/bootstrap.ts +15 -18
- 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.module.ts +2 -1
- package/src/files/git/git-files.service.ts +52 -7
- 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 -16
- package/test/unit/files-service.factory.unit.spec.ts +31 -13
- package/test/unit/files.resolver.unit.spec.ts +1 -0
- package/test/unit/git-files.service.unit.spec.ts +82 -0
- package/test/unit/local-files.service.unit.spec.ts +41 -25
- package/test/update-config.js +25 -0
package/DEVELOPER.md
CHANGED
|
@@ -37,6 +37,24 @@ APOLLO_PATH='/lib'
|
|
|
37
37
|
GRAPHQL_PLAYGROUND='true'
|
|
38
38
|
```
|
|
39
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
|
+
|
|
57
|
+
|
|
40
58
|
## Service Endpoint
|
|
41
59
|
|
|
42
60
|
The URL endpoint for this microservice is located at: `localhost:PORT/lib`
|
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ Install the package with the following commands
|
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
sudo npm install -g @into-cps-association/libms
|
|
18
|
+
sudo npm install -g pm2
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
The package on [npmjs](https://registry.npmjs.org) is published
|
|
@@ -52,6 +53,14 @@ LOCAL_PATH ='/Users/<Username>/DTaaS/files'
|
|
|
52
53
|
LOG_LEVEL='debug'
|
|
53
54
|
APOLLO_PATH='/lib' or ''
|
|
54
55
|
GRAPHQL_PLAYGROUND='false' or 'true'
|
|
56
|
+
|
|
57
|
+
#Only needed if git mode
|
|
58
|
+
GIT_USER1_REPO_URL='<git repo url>'
|
|
59
|
+
GIT_USER1_API_TOKEN='<TOKEN>'
|
|
60
|
+
...
|
|
61
|
+
GIT_USERX_REPO_URL='<git repo url>'
|
|
62
|
+
GIT_USERX_API_TOKEN='<TOKEN>'
|
|
63
|
+
|
|
55
64
|
```
|
|
56
65
|
|
|
57
66
|
The `LOCAL_PATH` variable is the absolute filepath to the
|
package/config/http.json
CHANGED
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,27 +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.
|
|
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`);
|
|
23
16
|
if (options.httpServer) {
|
|
24
|
-
cloudCMD(app, options.httpServer, configService.
|
|
17
|
+
cloudCMD(app, options.httpServer, configService.getLocalPath());
|
|
25
18
|
}
|
|
26
19
|
await app.listen(port);
|
|
27
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,EAA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: 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"}
|
|
@@ -6,11 +6,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Module } from '@nestjs/common';
|
|
8
8
|
import GitFilesService from './git-files.service.js';
|
|
9
|
+
import LocalFilesService from '../local/local-files.service.js';
|
|
9
10
|
let GitFilesModule = class GitFilesModule {
|
|
10
11
|
};
|
|
11
12
|
GitFilesModule = __decorate([
|
|
12
13
|
Module({
|
|
13
|
-
providers: [GitFilesService],
|
|
14
|
+
providers: [GitFilesService, LocalFilesService],
|
|
14
15
|
exports: [GitFilesService],
|
|
15
16
|
})
|
|
16
17
|
], GitFilesModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-files.module.js","sourceRoot":"","sources":["../../../../src/files/git/git-files.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,eAAe,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"git-files.module.js","sourceRoot":"","sources":["../../../../src/files/git/git-files.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,eAAe,MAAM,wBAAwB,CAAC;AACrD,OAAO,iBAAiB,MAAM,iCAAiC,CAAC;AAMzD,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,cAAc;IAJ1B,MAAM,CAAC;QACN,SAAS,EAAE,CAAC,eAAe,EAAE,iBAAiB,CAAC;QAC/C,OAAO,EAAE,CAAC,eAAe,CAAC;KAC3B,CAAC;GACW,cAAc,CAAG"}
|
|
@@ -1,9 +1,16 @@
|
|
|
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 Config from '../../config/config.service.js';
|
|
4
5
|
export default class GitFilesService implements IFilesService {
|
|
5
|
-
|
|
6
|
+
private configService;
|
|
7
|
+
private readonly dataPath;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private localFilesService;
|
|
10
|
+
constructor(configService: Config);
|
|
11
|
+
init(): Promise<any>;
|
|
12
|
+
private cloneRepositories;
|
|
6
13
|
getMode(): CONFIG_MODE;
|
|
7
|
-
listDirectory(): Promise<Project>;
|
|
8
|
-
readFile(): Promise<Project>;
|
|
14
|
+
listDirectory(path: string): Promise<Project>;
|
|
15
|
+
readFile(path: string): Promise<Project>;
|
|
9
16
|
}
|
|
@@ -7,23 +7,72 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var GitFilesService_1;
|
|
14
|
+
import { Inject, Injectable, Logger } from '@nestjs/common';
|
|
11
15
|
import { CONFIG_MODE } from '../../enums/config-mode.enum.js';
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
import * as git from 'isomorphic-git';
|
|
17
|
+
import * as fs from 'fs';
|
|
18
|
+
import * as http from 'isomorphic-git/http/node/index.cjs';
|
|
19
|
+
import LocalFilesService from '../local/local-files.service.js';
|
|
20
|
+
import Config from '../../config/config.service.js';
|
|
21
|
+
import { CONFIG_SERVICE } from '../../config/config.interface.js';
|
|
22
|
+
import path from 'path';
|
|
23
|
+
let GitFilesService = GitFilesService_1 = class GitFilesService {
|
|
24
|
+
configService;
|
|
25
|
+
dataPath;
|
|
26
|
+
logger;
|
|
27
|
+
localFilesService;
|
|
28
|
+
constructor(configService) {
|
|
29
|
+
this.configService = configService;
|
|
30
|
+
this.dataPath = this.configService.getLocalPath();
|
|
31
|
+
this.logger = new Logger(GitFilesService_1.name);
|
|
32
|
+
}
|
|
33
|
+
init() {
|
|
34
|
+
return this.cloneRepositories();
|
|
35
|
+
}
|
|
36
|
+
cloneRepositories() {
|
|
37
|
+
const userRepoConfigs = this.configService.getGitRepos();
|
|
38
|
+
if (!userRepoConfigs || userRepoConfigs.length === 0) {
|
|
39
|
+
throw new Error('No git repos found in config');
|
|
40
|
+
}
|
|
41
|
+
const clonePromises = userRepoConfigs.map((repoConf) => {
|
|
42
|
+
const user = Object.keys(repoConf)[0];
|
|
43
|
+
const repoUrl = repoConf[user]['repo-url'];
|
|
44
|
+
return git
|
|
45
|
+
.clone({
|
|
46
|
+
fs,
|
|
47
|
+
http,
|
|
48
|
+
dir: this.dataPath + `/${user}`,
|
|
49
|
+
gitdir: path.join(this.dataPath, 'gitdir', user, '.git'),
|
|
50
|
+
url: repoUrl.includes('.git') ? repoUrl : repoUrl + '.git',
|
|
51
|
+
singleBranch: true,
|
|
52
|
+
depth: 1,
|
|
53
|
+
})
|
|
54
|
+
.then(() => this.logger.log('done cloning ' + repoUrl));
|
|
55
|
+
});
|
|
56
|
+
return Promise.all(clonePromises);
|
|
57
|
+
}
|
|
14
58
|
getMode() {
|
|
15
59
|
return CONFIG_MODE.GIT;
|
|
16
60
|
}
|
|
17
|
-
listDirectory() {
|
|
18
|
-
|
|
61
|
+
listDirectory(path) {
|
|
62
|
+
return this.localFilesService.listDirectory(path);
|
|
19
63
|
}
|
|
20
|
-
readFile() {
|
|
21
|
-
|
|
64
|
+
readFile(path) {
|
|
65
|
+
return this.localFilesService.readFile(path);
|
|
22
66
|
}
|
|
23
67
|
};
|
|
24
|
-
|
|
68
|
+
__decorate([
|
|
69
|
+
Inject(LocalFilesService),
|
|
70
|
+
__metadata("design:type", LocalFilesService)
|
|
71
|
+
], GitFilesService.prototype, "localFilesService", void 0);
|
|
72
|
+
GitFilesService = GitFilesService_1 = __decorate([
|
|
25
73
|
Injectable(),
|
|
26
|
-
|
|
74
|
+
__param(0, Inject(CONFIG_SERVICE)),
|
|
75
|
+
__metadata("design:paramtypes", [Config])
|
|
27
76
|
], GitFilesService);
|
|
28
77
|
export default GitFilesService;
|
|
29
78
|
//# sourceMappingURL=git-files.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-files.service.js","sourceRoot":"","sources":["../../../../src/files/git/git-files.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git-files.service.js","sourceRoot":"","sources":["../../../../src/files/git/git-files.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA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AC,CAAC,UAAU,CAAC,CAAC;YAE3C,OAAO,GAAG;iBACP,KAAK,CAAC;gBACL,EAAE;gBACF,IAAI;gBACJ,GAAG,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,EAAE;gBAC/B,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC;gBACxD,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,MAAM;gBAC1D,YAAY,EAAE,IAAI;gBAClB,KAAK,EAAE,CAAC;aACT,CAAC;iBACD,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACL,OAAO,WAAW,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AAhDoC;IAAlC,MAAM,CAAC,iBAAiB,CAAC;8BAA4B,iBAAiB;0DAAC;AAHrD,eAAe;IADnC,UAAU,EAAE;IAME,WAAA,MAAM,CAAC,cAAc,CAAC,CAAA;qCAAwB,MAAM;GAL9C,eAAe,CAmDnC;eAnDoB,eAAe"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
1
|
import { Project } from 'src/types.js';
|
|
3
2
|
import { IFilesService } from '../interfaces/files.service.interface.js';
|
|
4
3
|
import { CONFIG_MODE } from '../../enums/config-mode.enum.js';
|
|
4
|
+
import Config from '../../config/config.service.js';
|
|
5
5
|
export default class LocalFilesService implements IFilesService {
|
|
6
6
|
private configService;
|
|
7
7
|
private readonly dataPath;
|
|
8
|
-
constructor(configService:
|
|
8
|
+
constructor(configService: Config);
|
|
9
|
+
init(): Promise<any>;
|
|
9
10
|
getMode(): CONFIG_MODE;
|
|
10
11
|
listDirectory(path: string): Promise<Project>;
|
|
11
12
|
readFile(path: string): Promise<Project>;
|
|
@@ -7,18 +7,25 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
10
13
|
var LocalFilesService_1;
|
|
11
|
-
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
14
|
+
import { Inject, Injectable, InternalServerErrorException, } from '@nestjs/common';
|
|
12
15
|
import * as fs from 'fs';
|
|
13
16
|
import { join } from 'path';
|
|
14
|
-
import { ConfigService } from '@nestjs/config';
|
|
15
17
|
import { CONFIG_MODE } from '../../enums/config-mode.enum.js';
|
|
18
|
+
import Config from '../../config/config.service.js';
|
|
19
|
+
import { CONFIG_SERVICE } from '../../config/config.interface.js';
|
|
16
20
|
let LocalFilesService = LocalFilesService_1 = class LocalFilesService {
|
|
17
21
|
configService;
|
|
18
22
|
dataPath;
|
|
19
23
|
constructor(configService) {
|
|
20
24
|
this.configService = configService;
|
|
21
|
-
this.dataPath = this.configService.
|
|
25
|
+
this.dataPath = this.configService.getLocalPath();
|
|
26
|
+
}
|
|
27
|
+
init() {
|
|
28
|
+
return Promise.resolve();
|
|
22
29
|
}
|
|
23
30
|
getMode() {
|
|
24
31
|
return CONFIG_MODE.LOCAL;
|
|
@@ -73,7 +80,8 @@ let LocalFilesService = LocalFilesService_1 = class LocalFilesService {
|
|
|
73
80
|
};
|
|
74
81
|
LocalFilesService = LocalFilesService_1 = __decorate([
|
|
75
82
|
Injectable(),
|
|
76
|
-
|
|
83
|
+
__param(0, Inject(CONFIG_SERVICE)),
|
|
84
|
+
__metadata("design:paramtypes", [Config])
|
|
77
85
|
], LocalFilesService);
|
|
78
86
|
export default LocalFilesService;
|
|
79
87
|
//# sourceMappingURL=local-files.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-files.service.js","sourceRoot":"","sources":["../../../../src/files/local/local-files.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-files.service.js","sourceRoot":"","sources":["../../../../src/files/local/local-files.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGnD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAGQ;IAF3B,QAAQ,CAAS;IAElC,YAA4C,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;IACpD,CAAC;IAED,IAAI;QACF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,OAAO,WAAW,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,I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