@selentar/analitoly 0.1.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/LICENSE +21 -0
- package/README.md +93 -0
- package/api/dist/dashboards/dash_1775220041958_v1r8io.json +829 -0
- package/api/dist/dashboards/dash_1775222037264_1rrsrd.json +309 -0
- package/api/dist/src/agent/agent.controller.d.ts +26 -0
- package/api/dist/src/agent/agent.controller.js +124 -0
- package/api/dist/src/agent/agent.controller.js.map +1 -0
- package/api/dist/src/agent/agent.module.d.ts +2 -0
- package/api/dist/src/agent/agent.module.js +23 -0
- package/api/dist/src/agent/agent.module.js.map +1 -0
- package/api/dist/src/agent/agent.service.d.ts +39 -0
- package/api/dist/src/agent/agent.service.js +389 -0
- package/api/dist/src/agent/agent.service.js.map +1 -0
- package/api/dist/src/agent/mcp-config.d.ts +9 -0
- package/api/dist/src/agent/mcp-config.js +51 -0
- package/api/dist/src/agent/mcp-config.js.map +1 -0
- package/api/dist/src/app.module.d.ts +2 -0
- package/api/dist/src/app.module.js +52 -0
- package/api/dist/src/app.module.js.map +1 -0
- package/api/dist/src/chart/chart.controller.d.ts +8 -0
- package/api/dist/src/chart/chart.controller.js +38 -0
- package/api/dist/src/chart/chart.controller.js.map +1 -0
- package/api/dist/src/chart/chart.module.d.ts +2 -0
- package/api/dist/src/chart/chart.module.js +24 -0
- package/api/dist/src/chart/chart.module.js.map +1 -0
- package/api/dist/src/chart/chart.service.d.ts +32 -0
- package/api/dist/src/chart/chart.service.js +106 -0
- package/api/dist/src/chart/chart.service.js.map +1 -0
- package/api/dist/src/chat/chat.controller.d.ts +14 -0
- package/api/dist/src/chat/chat.controller.js +73 -0
- package/api/dist/src/chat/chat.controller.js.map +1 -0
- package/api/dist/src/chat/chat.module.d.ts +2 -0
- package/api/dist/src/chat/chat.module.js +22 -0
- package/api/dist/src/chat/chat.module.js.map +1 -0
- package/api/dist/src/chat/chat.service.d.ts +25 -0
- package/api/dist/src/chat/chat.service.js +168 -0
- package/api/dist/src/chat/chat.service.js.map +1 -0
- package/api/dist/src/connection/connection.controller.d.ts +46 -0
- package/api/dist/src/connection/connection.controller.js +189 -0
- package/api/dist/src/connection/connection.controller.js.map +1 -0
- package/api/dist/src/connection/connection.model.d.ts +116 -0
- package/api/dist/src/connection/connection.model.js +23 -0
- package/api/dist/src/connection/connection.model.js.map +1 -0
- package/api/dist/src/connection/connection.module.d.ts +2 -0
- package/api/dist/src/connection/connection.module.js +31 -0
- package/api/dist/src/connection/connection.module.js.map +1 -0
- package/api/dist/src/connection/connection.repository.d.ts +16 -0
- package/api/dist/src/connection/connection.repository.js +195 -0
- package/api/dist/src/connection/connection.repository.js.map +1 -0
- package/api/dist/src/connection/connection.service.d.ts +50 -0
- package/api/dist/src/connection/connection.service.js +343 -0
- package/api/dist/src/connection/connection.service.js.map +1 -0
- package/api/dist/src/context/context.controller.d.ts +13 -0
- package/api/dist/src/context/context.controller.js +86 -0
- package/api/dist/src/context/context.controller.js.map +1 -0
- package/api/dist/src/context/context.module.d.ts +2 -0
- package/api/dist/src/context/context.module.js +39 -0
- package/api/dist/src/context/context.module.js.map +1 -0
- package/api/dist/src/context/context.service.d.ts +32 -0
- package/api/dist/src/context/context.service.js +177 -0
- package/api/dist/src/context/context.service.js.map +1 -0
- package/api/dist/src/dashboard/dashboard.controller.d.ts +21 -0
- package/api/dist/src/dashboard/dashboard.controller.js +109 -0
- package/api/dist/src/dashboard/dashboard.controller.js.map +1 -0
- package/api/dist/src/dashboard/dashboard.model.d.ts +15 -0
- package/api/dist/src/dashboard/dashboard.model.js +3 -0
- package/api/dist/src/dashboard/dashboard.model.js.map +1 -0
- package/api/dist/src/dashboard/dashboard.module.d.ts +2 -0
- package/api/dist/src/dashboard/dashboard.module.js +24 -0
- package/api/dist/src/dashboard/dashboard.module.js.map +1 -0
- package/api/dist/src/dashboard/dashboard.repository.d.ts +9 -0
- package/api/dist/src/dashboard/dashboard.repository.js +72 -0
- package/api/dist/src/dashboard/dashboard.repository.js.map +1 -0
- package/api/dist/src/dashboard/dashboard.service.d.ts +14 -0
- package/api/dist/src/dashboard/dashboard.service.js +87 -0
- package/api/dist/src/dashboard/dashboard.service.js.map +1 -0
- package/api/dist/src/datasource/connectors/connector.interface.d.ts +6 -0
- package/api/dist/src/datasource/connectors/connector.interface.js +3 -0
- package/api/dist/src/datasource/connectors/connector.interface.js.map +1 -0
- package/api/dist/src/datasource/connectors/mongo.connector.d.ts +30 -0
- package/api/dist/src/datasource/connectors/mongo.connector.js +167 -0
- package/api/dist/src/datasource/connectors/mongo.connector.js.map +1 -0
- package/api/dist/src/datasource/connectors/mongo.connector.test.d.ts +1 -0
- package/api/dist/src/datasource/connectors/mongo.connector.test.js +179 -0
- package/api/dist/src/datasource/connectors/mongo.connector.test.js.map +1 -0
- package/api/dist/src/datasource/connectors/postgres.connector.d.ts +50 -0
- package/api/dist/src/datasource/connectors/postgres.connector.js +213 -0
- package/api/dist/src/datasource/connectors/postgres.connector.js.map +1 -0
- package/api/dist/src/datasource/connectors/postgres.connector.test.d.ts +1 -0
- package/api/dist/src/datasource/connectors/postgres.connector.test.js +197 -0
- package/api/dist/src/datasource/connectors/postgres.connector.test.js.map +1 -0
- package/api/dist/src/datasource/datasource.controller.d.ts +16 -0
- package/api/dist/src/datasource/datasource.controller.js +79 -0
- package/api/dist/src/datasource/datasource.controller.js.map +1 -0
- package/api/dist/src/datasource/datasource.model.d.ts +26 -0
- package/api/dist/src/datasource/datasource.model.js +3 -0
- package/api/dist/src/datasource/datasource.model.js.map +1 -0
- package/api/dist/src/datasource/datasource.module.d.ts +2 -0
- package/api/dist/src/datasource/datasource.module.js +31 -0
- package/api/dist/src/datasource/datasource.module.js.map +1 -0
- package/api/dist/src/datasource/datasource.repository.d.ts +11 -0
- package/api/dist/src/datasource/datasource.repository.js +61 -0
- package/api/dist/src/datasource/datasource.repository.js.map +1 -0
- package/api/dist/src/datasource/datasource.service.d.ts +28 -0
- package/api/dist/src/datasource/datasource.service.js +95 -0
- package/api/dist/src/datasource/datasource.service.js.map +1 -0
- package/api/dist/src/example/example.controller.d.ts +10 -0
- package/api/dist/src/example/example.controller.js +43 -0
- package/api/dist/src/example/example.controller.js.map +1 -0
- package/api/dist/src/example/example.model.d.ts +6 -0
- package/api/dist/src/example/example.model.js +3 -0
- package/api/dist/src/example/example.model.js.map +1 -0
- package/api/dist/src/example/example.module.d.ts +2 -0
- package/api/dist/src/example/example.module.js +23 -0
- package/api/dist/src/example/example.module.js.map +1 -0
- package/api/dist/src/example/example.repository.d.ts +6 -0
- package/api/dist/src/example/example.repository.js +30 -0
- package/api/dist/src/example/example.repository.js.map +1 -0
- package/api/dist/src/example/example.service.d.ts +10 -0
- package/api/dist/src/example/example.service.js +31 -0
- package/api/dist/src/example/example.service.js.map +1 -0
- package/api/dist/src/integration/integration.controller.d.ts +15 -0
- package/api/dist/src/integration/integration.controller.js +69 -0
- package/api/dist/src/integration/integration.controller.js.map +1 -0
- package/api/dist/src/integration/integration.model.d.ts +17 -0
- package/api/dist/src/integration/integration.model.js +3 -0
- package/api/dist/src/integration/integration.model.js.map +1 -0
- package/api/dist/src/integration/integration.module.d.ts +2 -0
- package/api/dist/src/integration/integration.module.js +24 -0
- package/api/dist/src/integration/integration.module.js.map +1 -0
- package/api/dist/src/integration/integration.repository.d.ts +6 -0
- package/api/dist/src/integration/integration.repository.js +45 -0
- package/api/dist/src/integration/integration.repository.js.map +1 -0
- package/api/dist/src/integration/integration.service.d.ts +12 -0
- package/api/dist/src/integration/integration.service.js +78 -0
- package/api/dist/src/integration/integration.service.js.map +1 -0
- package/api/dist/src/main.d.ts +1 -0
- package/api/dist/src/main.js +19 -0
- package/api/dist/src/main.js.map +1 -0
- package/api/dist/src/mcp/grafana.mcp.d.ts +1 -0
- package/api/dist/src/mcp/grafana.mcp.js +95 -0
- package/api/dist/src/mcp/grafana.mcp.js.map +1 -0
- package/api/dist/src/mcp/graylog.mcp.d.ts +1 -0
- package/api/dist/src/mcp/graylog.mcp.js +241 -0
- package/api/dist/src/mcp/graylog.mcp.js.map +1 -0
- package/api/dist/src/mcp/mcp-server.d.ts +1 -0
- package/api/dist/src/mcp/mcp-server.js +336 -0
- package/api/dist/src/mcp/mcp-server.js.map +1 -0
- package/api/dist/src/paths.d.ts +8 -0
- package/api/dist/src/paths.js +50 -0
- package/api/dist/src/paths.js.map +1 -0
- package/api/dist/src/paths.test.d.ts +1 -0
- package/api/dist/src/paths.test.js +60 -0
- package/api/dist/src/paths.test.js.map +1 -0
- package/api/dist/src/project/project.controller.d.ts +44 -0
- package/api/dist/src/project/project.controller.js +79 -0
- package/api/dist/src/project/project.controller.js.map +1 -0
- package/api/dist/src/project/project.model.d.ts +19 -0
- package/api/dist/src/project/project.model.js +3 -0
- package/api/dist/src/project/project.model.js.map +1 -0
- package/api/dist/src/project/project.module.d.ts +2 -0
- package/api/dist/src/project/project.module.js +24 -0
- package/api/dist/src/project/project.module.js.map +1 -0
- package/api/dist/src/project/project.repository.d.ts +6 -0
- package/api/dist/src/project/project.repository.js +52 -0
- package/api/dist/src/project/project.repository.js.map +1 -0
- package/api/dist/src/project/project.service.d.ts +17 -0
- package/api/dist/src/project/project.service.js +163 -0
- package/api/dist/src/project/project.service.js.map +1 -0
- package/api/dist/tsconfig.tsbuildinfo +1 -0
- package/api/dist/vitest.config.d.ts +2 -0
- package/api/dist/vitest.config.js +10 -0
- package/api/dist/vitest.config.js.map +1 -0
- package/api/public/dist/Analitoly.png +0 -0
- package/api/public/dist/AnalitolyShort.png +0 -0
- package/api/public/dist/Gitlab.png +0 -0
- package/api/public/dist/Grafana.png +0 -0
- package/api/public/dist/Graylog.png +0 -0
- package/api/public/dist/Mongodb.png +0 -0
- package/api/public/dist/PostgreSQL.png +0 -0
- package/api/public/dist/assets/index-BPB3ckw4.js +222 -0
- package/api/public/dist/assets/index-CSAGa0SG.js +227 -0
- package/api/public/dist/index.html +12 -0
- package/bin/analitoly-mcp.js +18 -0
- package/bin/analitoly.js +38 -0
- package/package.json +54 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataDir = dataDir;
|
|
4
|
+
exports.configPath = configPath;
|
|
5
|
+
exports.dashboardsDir = dashboardsDir;
|
|
6
|
+
exports.contextPath = contextPath;
|
|
7
|
+
exports.envFilePath = envFilePath;
|
|
8
|
+
exports.mcpScriptsDir = mcpScriptsDir;
|
|
9
|
+
exports.publicDir = publicDir;
|
|
10
|
+
exports.serverPort = serverPort;
|
|
11
|
+
const os = require("os");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
function apiRoot() {
|
|
15
|
+
const inDist = __dirname.includes(path.sep + 'dist' + path.sep) || __dirname.endsWith(path.sep + 'dist');
|
|
16
|
+
return inDist
|
|
17
|
+
? path.resolve(__dirname, '..', '..')
|
|
18
|
+
: path.resolve(__dirname, '..');
|
|
19
|
+
}
|
|
20
|
+
function dataDir() {
|
|
21
|
+
return process.env.ANALITOLY_DATA_DIR || path.join(os.homedir(), '.analitoly');
|
|
22
|
+
}
|
|
23
|
+
function configPath() {
|
|
24
|
+
return path.join(dataDir(), 'config.json');
|
|
25
|
+
}
|
|
26
|
+
function dashboardsDir() {
|
|
27
|
+
return path.join(dataDir(), 'dashboards');
|
|
28
|
+
}
|
|
29
|
+
function contextPath() {
|
|
30
|
+
return path.join(dataDir(), 'context.md');
|
|
31
|
+
}
|
|
32
|
+
function envFilePath() {
|
|
33
|
+
const cwdEnv = path.join(process.cwd(), '.env');
|
|
34
|
+
if ((0, fs_1.existsSync)(cwdEnv))
|
|
35
|
+
return cwdEnv;
|
|
36
|
+
const dataEnv = path.join(dataDir(), '.env');
|
|
37
|
+
if ((0, fs_1.existsSync)(dataEnv))
|
|
38
|
+
return dataEnv;
|
|
39
|
+
return cwdEnv;
|
|
40
|
+
}
|
|
41
|
+
function mcpScriptsDir() {
|
|
42
|
+
return path.resolve(__dirname, 'mcp');
|
|
43
|
+
}
|
|
44
|
+
function publicDir() {
|
|
45
|
+
return path.join(apiRoot(), 'public');
|
|
46
|
+
}
|
|
47
|
+
function serverPort() {
|
|
48
|
+
return parseInt(process.env.PORT || process.env.ANALITOLY_PORT || '40000', 10);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/paths.ts"],"names":[],"mappings":";;AAqBA,0BAEC;AAGD,gCAEC;AAGD,sCAEC;AAGD,kCAEC;AAOD,kCAMC;AAGD,sCAEC;AAGD,8BAEC;AAGD,gCAEC;AAlED,yBAAyB;AACzB,6BAA6B;AAC7B,2BAAgC;AAOhC,SAAS,OAAO;IACd,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC;IACzG,OAAO,MAAM;QACX,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC;QACrC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;AAOD,SAAgB,OAAO;IACrB,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AACjF,CAAC;AAGD,SAAgB,UAAU;IACxB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;AAC7C,CAAC;AAGD,SAAgB,aAAa;IAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAC5C,CAAC;AAGD,SAAgB,WAAW;IACzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAC5C,CAAC;AAOD,SAAgB,WAAW;IACzB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IAChD,IAAI,IAAA,eAAU,EAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,IAAA,eAAU,EAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC;AAGD,SAAgB,aAAa;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAGD,SAAgB,SAAS;IACvB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAGD,SAAgB,UAAU;IACxB,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
(0, vitest_1.describe)('paths', () => {
|
|
7
|
+
const originalEnv = process.env;
|
|
8
|
+
(0, vitest_1.beforeEach)(() => {
|
|
9
|
+
vitest_1.vi.resetModules();
|
|
10
|
+
process.env = { ...originalEnv };
|
|
11
|
+
delete process.env.ANALITOLY_DATA_DIR;
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.afterEach)(() => {
|
|
14
|
+
process.env = originalEnv;
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.it)('defaults dataDir to ~/.analitoly', async () => {
|
|
17
|
+
const { dataDir } = await Promise.resolve().then(() => require('./paths'));
|
|
18
|
+
(0, vitest_1.expect)(dataDir()).toBe(path.join(os.homedir(), '.analitoly'));
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.it)('respects ANALITOLY_DATA_DIR env over all defaults', async () => {
|
|
21
|
+
process.env.ANALITOLY_DATA_DIR = '/tmp/test-analitoly';
|
|
22
|
+
const { dataDir } = await Promise.resolve().then(() => require('./paths'));
|
|
23
|
+
(0, vitest_1.expect)(dataDir()).toBe('/tmp/test-analitoly');
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.it)('configPath is inside dataDir', async () => {
|
|
26
|
+
process.env.ANALITOLY_DATA_DIR = '/tmp/test-analitoly';
|
|
27
|
+
const { configPath } = await Promise.resolve().then(() => require('./paths'));
|
|
28
|
+
(0, vitest_1.expect)(configPath()).toBe('/tmp/test-analitoly/config.json');
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.it)('dashboardsDir is inside dataDir', async () => {
|
|
31
|
+
process.env.ANALITOLY_DATA_DIR = '/tmp/test-analitoly';
|
|
32
|
+
const { dashboardsDir } = await Promise.resolve().then(() => require('./paths'));
|
|
33
|
+
(0, vitest_1.expect)(dashboardsDir()).toBe('/tmp/test-analitoly/dashboards');
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.it)('envFilePath returns path ending in .env', async () => {
|
|
36
|
+
const { envFilePath } = await Promise.resolve().then(() => require('./paths'));
|
|
37
|
+
const result = envFilePath();
|
|
38
|
+
(0, vitest_1.expect)(result.endsWith('.env')).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.it)('mcpScriptsDir contains "mcp" segment', async () => {
|
|
41
|
+
const { mcpScriptsDir } = await Promise.resolve().then(() => require('./paths'));
|
|
42
|
+
(0, vitest_1.expect)(mcpScriptsDir()).toContain('mcp');
|
|
43
|
+
});
|
|
44
|
+
(0, vitest_1.it)('publicDir contains "public" segment', async () => {
|
|
45
|
+
const { publicDir } = await Promise.resolve().then(() => require('./paths'));
|
|
46
|
+
(0, vitest_1.expect)(publicDir()).toContain('public');
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.it)('serverPort defaults to 40000', async () => {
|
|
49
|
+
delete process.env.PORT;
|
|
50
|
+
delete process.env.ANALITOLY_PORT;
|
|
51
|
+
const { serverPort } = await Promise.resolve().then(() => require('./paths'));
|
|
52
|
+
(0, vitest_1.expect)(serverPort()).toBe(40000);
|
|
53
|
+
});
|
|
54
|
+
(0, vitest_1.it)('serverPort respects PORT env', async () => {
|
|
55
|
+
process.env.PORT = '3000';
|
|
56
|
+
const { serverPort } = await Promise.resolve().then(() => require('./paths'));
|
|
57
|
+
(0, vitest_1.expect)(serverPort()).toBe(3000);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=paths.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.test.js","sourceRoot":"","sources":["../../src/paths.test.ts"],"names":[],"mappings":";;AAAA,mCAAyE;AACzE,yBAAyB;AACzB,6BAA6B;AAE7B,IAAA,iBAAQ,EAAC,OAAO,EAAE,GAAG,EAAE;IACrB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAEhC,IAAA,mBAAU,EAAC,GAAG,EAAE;QACd,WAAE,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,IAAA,kBAAS,EAAC,GAAG,EAAE;QACb,OAAO,CAAC,GAAG,GAAG,WAAW,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,IAAA,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AAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ProjectService } from './project.service';
|
|
2
|
+
import { ProjectConfig } from './project.model';
|
|
3
|
+
export declare class ProjectController {
|
|
4
|
+
private readonly service;
|
|
5
|
+
constructor(service: ProjectService);
|
|
6
|
+
getProject(): {
|
|
7
|
+
configured: boolean;
|
|
8
|
+
} | {
|
|
9
|
+
config: {
|
|
10
|
+
type: "gitlab";
|
|
11
|
+
url: string;
|
|
12
|
+
token: string;
|
|
13
|
+
branch?: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "local";
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
localPath: string;
|
|
19
|
+
status: import("./project.model").ProjectStatus;
|
|
20
|
+
error?: string;
|
|
21
|
+
configured: boolean;
|
|
22
|
+
};
|
|
23
|
+
saveProject(body: ProjectConfig): Promise<{
|
|
24
|
+
config: {
|
|
25
|
+
type: "gitlab";
|
|
26
|
+
url: string;
|
|
27
|
+
token: string;
|
|
28
|
+
branch?: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: "local";
|
|
31
|
+
path: string;
|
|
32
|
+
};
|
|
33
|
+
localPath: string;
|
|
34
|
+
status: import("./project.model").ProjectStatus;
|
|
35
|
+
error?: string;
|
|
36
|
+
}>;
|
|
37
|
+
testAccess(body: ProjectConfig): Promise<{
|
|
38
|
+
accessible: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
}>;
|
|
41
|
+
deleteProject(): Promise<{
|
|
42
|
+
success: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ProjectController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const project_service_1 = require("./project.service");
|
|
18
|
+
let ProjectController = class ProjectController {
|
|
19
|
+
constructor(service) {
|
|
20
|
+
this.service = service;
|
|
21
|
+
}
|
|
22
|
+
getProject() {
|
|
23
|
+
const project = this.service.getProject();
|
|
24
|
+
if (!project)
|
|
25
|
+
return { configured: false };
|
|
26
|
+
const config = { ...project.config };
|
|
27
|
+
if (config.type === 'gitlab') {
|
|
28
|
+
config.token = '***';
|
|
29
|
+
}
|
|
30
|
+
return { configured: true, ...project, config };
|
|
31
|
+
}
|
|
32
|
+
async saveProject(body) {
|
|
33
|
+
const state = await this.service.saveProject(body);
|
|
34
|
+
const config = { ...state.config };
|
|
35
|
+
if (config.type === 'gitlab') {
|
|
36
|
+
config.token = '***';
|
|
37
|
+
}
|
|
38
|
+
return { ...state, config };
|
|
39
|
+
}
|
|
40
|
+
async testAccess(body) {
|
|
41
|
+
return this.service.testAccess(body);
|
|
42
|
+
}
|
|
43
|
+
async deleteProject() {
|
|
44
|
+
await this.service.deleteProject();
|
|
45
|
+
return { success: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.ProjectController = ProjectController;
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, common_1.Get)(),
|
|
51
|
+
__metadata("design:type", Function),
|
|
52
|
+
__metadata("design:paramtypes", []),
|
|
53
|
+
__metadata("design:returntype", void 0)
|
|
54
|
+
], ProjectController.prototype, "getProject", null);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, common_1.Post)(),
|
|
57
|
+
__param(0, (0, common_1.Body)()),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", [Object]),
|
|
60
|
+
__metadata("design:returntype", Promise)
|
|
61
|
+
], ProjectController.prototype, "saveProject", null);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, common_1.Post)('test'),
|
|
64
|
+
__param(0, (0, common_1.Body)()),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", [Object]),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], ProjectController.prototype, "testAccess", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, common_1.Delete)(),
|
|
71
|
+
__metadata("design:type", Function),
|
|
72
|
+
__metadata("design:paramtypes", []),
|
|
73
|
+
__metadata("design:returntype", Promise)
|
|
74
|
+
], ProjectController.prototype, "deleteProject", null);
|
|
75
|
+
exports.ProjectController = ProjectController = __decorate([
|
|
76
|
+
(0, common_1.Controller)('project'),
|
|
77
|
+
__metadata("design:paramtypes", [project_service_1.ProjectService])
|
|
78
|
+
], ProjectController);
|
|
79
|
+
//# sourceMappingURL=project.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.controller.js","sourceRoot":"","sources":["../../../src/project/project.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqE;AACrE,uDAAmD;AAI5C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAGxD,UAAU;QACR,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC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AGK;IADL,IAAA,eAAM,GAAE;;;;sDAIR;4BAlCU,iBAAiB;IAD7B,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAEkB,gCAAc;GADzC,iBAAiB,CAmC7B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ProjectSourceType = 'gitlab' | 'local';
|
|
2
|
+
export interface GitLabConfig {
|
|
3
|
+
type: 'gitlab';
|
|
4
|
+
url: string;
|
|
5
|
+
token: string;
|
|
6
|
+
branch?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LocalConfig {
|
|
9
|
+
type: 'local';
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
export type ProjectConfig = GitLabConfig | LocalConfig;
|
|
13
|
+
export type ProjectStatus = 'cloning' | 'ready' | 'error';
|
|
14
|
+
export interface ProjectState {
|
|
15
|
+
config: ProjectConfig;
|
|
16
|
+
localPath: string;
|
|
17
|
+
status: ProjectStatus;
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.model.js","sourceRoot":"","sources":["../../../src/project/project.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ProjectModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const project_controller_1 = require("./project.controller");
|
|
12
|
+
const project_service_1 = require("./project.service");
|
|
13
|
+
const project_repository_1 = require("./project.repository");
|
|
14
|
+
let ProjectModule = class ProjectModule {
|
|
15
|
+
};
|
|
16
|
+
exports.ProjectModule = ProjectModule;
|
|
17
|
+
exports.ProjectModule = ProjectModule = __decorate([
|
|
18
|
+
(0, common_1.Module)({
|
|
19
|
+
controllers: [project_controller_1.ProjectController],
|
|
20
|
+
providers: [project_service_1.ProjectService, project_repository_1.ProjectRepository],
|
|
21
|
+
exports: [project_service_1.ProjectService],
|
|
22
|
+
})
|
|
23
|
+
], ProjectModule);
|
|
24
|
+
//# sourceMappingURL=project.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.module.js","sourceRoot":"","sources":["../../../src/project/project.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6DAAyD;AACzD,uDAAmD;AACnD,6DAAyD;AAOlD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IALzB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,SAAS,EAAE,CAAC,gCAAc,EAAE,sCAAiB,CAAC;QAC9C,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ProjectRepository = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const connection_repository_1 = require("../connection/connection.repository");
|
|
12
|
+
const connectionRepo = new connection_repository_1.ConnectionRepository();
|
|
13
|
+
let ProjectRepository = class ProjectRepository {
|
|
14
|
+
read() {
|
|
15
|
+
for (const type of ['local', 'gitlab']) {
|
|
16
|
+
const conn = connectionRepo.findActive(type);
|
|
17
|
+
if (conn?.state) {
|
|
18
|
+
return {
|
|
19
|
+
config: { type, ...conn.config },
|
|
20
|
+
localPath: conn.state.localPath,
|
|
21
|
+
status: conn.state.status,
|
|
22
|
+
error: conn.state.error,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
write(state) {
|
|
29
|
+
const type = state.config.type;
|
|
30
|
+
const conn = connectionRepo.findActive(type);
|
|
31
|
+
if (conn) {
|
|
32
|
+
connectionRepo.updateState(conn.id, {
|
|
33
|
+
localPath: state.localPath,
|
|
34
|
+
status: state.status,
|
|
35
|
+
error: state.error,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
delete() {
|
|
40
|
+
for (const type of ['local', 'gitlab']) {
|
|
41
|
+
const conn = connectionRepo.findActive(type);
|
|
42
|
+
if (conn?.state) {
|
|
43
|
+
connectionRepo.updateState(conn.id, undefined);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.ProjectRepository = ProjectRepository;
|
|
49
|
+
exports.ProjectRepository = ProjectRepository = __decorate([
|
|
50
|
+
(0, common_1.Injectable)()
|
|
51
|
+
], ProjectRepository);
|
|
52
|
+
//# sourceMappingURL=project.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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CAAC,CAAC;YAC7C,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;gBAChB,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AArCY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAqC7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProjectRepository } from './project.repository';
|
|
2
|
+
import { ProjectConfig, ProjectState } from './project.model';
|
|
3
|
+
export declare class ProjectService {
|
|
4
|
+
private readonly repository;
|
|
5
|
+
constructor(repository: ProjectRepository);
|
|
6
|
+
getProject(): ProjectState | null;
|
|
7
|
+
saveProject(config: ProjectConfig): Promise<ProjectState>;
|
|
8
|
+
private connectLocal;
|
|
9
|
+
private connectGitLab;
|
|
10
|
+
private buildCloneUrl;
|
|
11
|
+
testAccess(config: ProjectConfig): Promise<{
|
|
12
|
+
accessible: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}>;
|
|
15
|
+
deleteProject(): Promise<void>;
|
|
16
|
+
private cleanupPreviousClone;
|
|
17
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ProjectService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const project_repository_1 = require("./project.repository");
|
|
15
|
+
const child_process_1 = require("child_process");
|
|
16
|
+
const fs = require("fs");
|
|
17
|
+
const os = require("os");
|
|
18
|
+
const path = require("path");
|
|
19
|
+
const crypto = require("crypto");
|
|
20
|
+
let ProjectService = class ProjectService {
|
|
21
|
+
constructor(repository) {
|
|
22
|
+
this.repository = repository;
|
|
23
|
+
}
|
|
24
|
+
getProject() {
|
|
25
|
+
return this.repository.read();
|
|
26
|
+
}
|
|
27
|
+
async saveProject(config) {
|
|
28
|
+
await this.cleanupPreviousClone();
|
|
29
|
+
if (config.type === 'local') {
|
|
30
|
+
return this.connectLocal(config);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return this.connectGitLab(config);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
connectLocal(config) {
|
|
37
|
+
const resolvedPath = path.resolve(config.path);
|
|
38
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
39
|
+
throw new common_1.BadRequestException(`Path does not exist: ${resolvedPath}`);
|
|
40
|
+
}
|
|
41
|
+
const stat = fs.statSync(resolvedPath);
|
|
42
|
+
if (!stat.isDirectory()) {
|
|
43
|
+
throw new common_1.BadRequestException(`Path is not a directory: ${resolvedPath}`);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
fs.accessSync(resolvedPath, fs.constants.R_OK);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new common_1.BadRequestException(`Path is not readable: ${resolvedPath}`);
|
|
50
|
+
}
|
|
51
|
+
const state = {
|
|
52
|
+
config,
|
|
53
|
+
localPath: resolvedPath,
|
|
54
|
+
status: 'ready',
|
|
55
|
+
};
|
|
56
|
+
this.repository.write(state);
|
|
57
|
+
return state;
|
|
58
|
+
}
|
|
59
|
+
async connectGitLab(config) {
|
|
60
|
+
try {
|
|
61
|
+
const parsed = new URL(config.url);
|
|
62
|
+
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
|
63
|
+
throw new Error();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
throw new common_1.BadRequestException(`Invalid URL: ${config.url}`);
|
|
68
|
+
}
|
|
69
|
+
const tmpDir = path.join(os.tmpdir(), `analitoly-${crypto.randomBytes(6).toString('hex')}`);
|
|
70
|
+
const branch = config.branch || undefined;
|
|
71
|
+
const cloningState = {
|
|
72
|
+
config,
|
|
73
|
+
localPath: tmpDir,
|
|
74
|
+
status: 'cloning',
|
|
75
|
+
};
|
|
76
|
+
this.repository.write(cloningState);
|
|
77
|
+
try {
|
|
78
|
+
const cloneUrl = this.buildCloneUrl(config.url, config.token);
|
|
79
|
+
const branchArgs = branch ? `--branch ${branch}` : '';
|
|
80
|
+
const cmd = `git clone --depth 1 ${branchArgs} ${cloneUrl} ${tmpDir}`;
|
|
81
|
+
await new Promise((resolve, reject) => {
|
|
82
|
+
(0, child_process_1.exec)(cmd, { timeout: 120_000 }, (error) => {
|
|
83
|
+
if (error)
|
|
84
|
+
reject(error);
|
|
85
|
+
else
|
|
86
|
+
resolve();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const readyState = {
|
|
90
|
+
config,
|
|
91
|
+
localPath: tmpDir,
|
|
92
|
+
status: 'ready',
|
|
93
|
+
};
|
|
94
|
+
this.repository.write(readyState);
|
|
95
|
+
return readyState;
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
const errorState = {
|
|
99
|
+
config,
|
|
100
|
+
localPath: tmpDir,
|
|
101
|
+
status: 'error',
|
|
102
|
+
error: String(err),
|
|
103
|
+
};
|
|
104
|
+
this.repository.write(errorState);
|
|
105
|
+
return errorState;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
buildCloneUrl(url, token) {
|
|
109
|
+
const parsed = new URL(url);
|
|
110
|
+
let pathname = parsed.pathname;
|
|
111
|
+
if (!pathname.endsWith('.git')) {
|
|
112
|
+
pathname = pathname + '.git';
|
|
113
|
+
}
|
|
114
|
+
return `${parsed.protocol}//oauth2:${token}@${parsed.host}${pathname}`;
|
|
115
|
+
}
|
|
116
|
+
async testAccess(config) {
|
|
117
|
+
if (config.type === 'local') {
|
|
118
|
+
try {
|
|
119
|
+
const resolvedPath = path.resolve(config.path);
|
|
120
|
+
fs.accessSync(resolvedPath, fs.constants.R_OK);
|
|
121
|
+
const stat = fs.statSync(resolvedPath);
|
|
122
|
+
if (!stat.isDirectory()) {
|
|
123
|
+
return { accessible: false, error: 'Path is not a directory' };
|
|
124
|
+
}
|
|
125
|
+
return { accessible: true };
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
return { accessible: false, error: String(err) };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const cloneUrl = this.buildCloneUrl(config.url, config.token);
|
|
133
|
+
(0, child_process_1.execSync)(`git ls-remote --exit-code ${cloneUrl}`, {
|
|
134
|
+
timeout: 15_000,
|
|
135
|
+
stdio: 'pipe',
|
|
136
|
+
});
|
|
137
|
+
return { accessible: true };
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
return { accessible: false, error: 'Cannot access repository. Check URL and token.' };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async deleteProject() {
|
|
144
|
+
await this.cleanupPreviousClone();
|
|
145
|
+
this.repository.delete();
|
|
146
|
+
}
|
|
147
|
+
async cleanupPreviousClone() {
|
|
148
|
+
const current = this.repository.read();
|
|
149
|
+
if (current && current.config.type === 'gitlab' && current.localPath) {
|
|
150
|
+
try {
|
|
151
|
+
fs.rmSync(current.localPath, { recursive: true, force: true });
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
exports.ProjectService = ProjectService;
|
|
159
|
+
exports.ProjectService = ProjectService = __decorate([
|
|
160
|
+
(0, common_1.Injectable)(),
|
|
161
|
+
__metadata("design:paramtypes", [project_repository_1.ProjectRepository])
|
|
162
|
+
], ProjectService);
|
|
163
|
+
//# sourceMappingURL=project.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.service.js","sourceRoot":"","sources":["../../../src/project/project.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoF;AACpF,6DAAyD;AAEzD,iDAA+C;AAC/C,yBAAyB;AACzB,yBAAyB;AACzB,6BAA6B;AAC7B,iCAAiC;AAG1B,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAA6B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAG,CAAC;IAE9D,UAAU;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAqB;QAErC,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAElC,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,MAAyC;QAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,4BAAmB,CAAC,wBAAwB,YAAY,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;Q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