@catladder/cli 1.18.1 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps/cli/commands/project/index.js +0 -2
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/config/writeConfig.js +1 -4
- package/dist/apps/cli/config/writeConfig.js.map +1 -1
- package/dist/config/getProjectConfig.d.ts +2 -3
- package/dist/config/getProjectConfig.js +38 -22
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/apps/cli/commands/project/index.ts +0 -2
- package/src/apps/cli/config/writeConfig.ts +0 -2
- package/src/config/getProjectConfig.ts +31 -18
- package/dist/apps/cli/commands/project/commandReloadConfig.d.ts +0 -3
- package/dist/apps/cli/commands/project/commandReloadConfig.js +0 -62
- package/dist/apps/cli/commands/project/commandReloadConfig.js.map +0 -1
- package/src/apps/cli/commands/project/commandReloadConfig.ts +0 -12
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"catladder": "./bin/catladder"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@catladder/pipeline": "1.
|
|
19
|
+
"@catladder/pipeline": "1.19.0",
|
|
20
20
|
"@kubernetes/client-node": "^0.16.2",
|
|
21
21
|
"child-process-promise": "^2.2.1",
|
|
22
22
|
"command-exists-promise": "^2.0.2",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"eslint": "^8.7.0",
|
|
56
56
|
"typescript": "^4.5.4"
|
|
57
57
|
},
|
|
58
|
-
"version": "1.
|
|
58
|
+
"version": "1.19.0"
|
|
59
59
|
}
|
|
@@ -24,10 +24,8 @@ import commandPortForward from "./commandPortForward";
|
|
|
24
24
|
import commandTriggerCronjob from "./commandTriggerCronjob";
|
|
25
25
|
|
|
26
26
|
import commandOpenGrafanaPod from "./commandOpenGrafanaPod";
|
|
27
|
-
import commandReloadConfig from "./commandReloadConfig";
|
|
28
27
|
|
|
29
28
|
export default async (vorpal: Vorpal) => {
|
|
30
|
-
commandReloadConfig(vorpal);
|
|
31
29
|
commandSetup(vorpal);
|
|
32
30
|
|
|
33
31
|
commandEnvVars(vorpal);
|
|
@@ -4,7 +4,6 @@ import { writeFile } from "fs-extra";
|
|
|
4
4
|
import { dump } from "js-yaml";
|
|
5
5
|
import { format } from "prettier";
|
|
6
6
|
import { CommandInstance } from "vorpal";
|
|
7
|
-
import { reloadConfig } from "../../../config/getProjectConfig";
|
|
8
7
|
import { getGitRoot } from "../../../utils/projects";
|
|
9
8
|
|
|
10
9
|
export const writeConfig = async (
|
|
@@ -67,7 +66,6 @@ export const writeConfig = async (
|
|
|
67
66
|
);
|
|
68
67
|
await exec("git add " + file);
|
|
69
68
|
}
|
|
70
|
-
await reloadConfig();
|
|
71
69
|
vorpal.log("done!");
|
|
72
70
|
vorpal.log("");
|
|
73
71
|
};
|
|
@@ -4,29 +4,41 @@ import {
|
|
|
4
4
|
getEnvironment as _getEnvironment,
|
|
5
5
|
createContext,
|
|
6
6
|
getSecretVarName,
|
|
7
|
+
Config,
|
|
7
8
|
} from "@catladder/pipeline";
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { CommandInstance } from "vorpal";
|
|
10
11
|
import { getAllVariables, getVariableValueByRawName } from "../utils/gitlab";
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
import { getGitRoot } from "../utils/projects";
|
|
13
14
|
import { readYaml } from "../utils/files";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
{
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
import { watch } from "fs";
|
|
16
|
+
|
|
17
|
+
let currentConfig: Config = null;
|
|
18
|
+
|
|
19
|
+
// reload the config on change
|
|
20
|
+
const reloadConfigAndObserve = async () => {
|
|
21
|
+
const gitRoot = await getGitRoot();
|
|
22
|
+
const result = readConfigSync(gitRoot);
|
|
23
|
+
if (!result) {
|
|
24
|
+
// can't do anything, there is no config
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const { config, path } = result;
|
|
28
|
+
const watcher = watch(path, () => {
|
|
29
|
+
watcher.close();
|
|
30
|
+
reloadConfigAndObserve();
|
|
31
|
+
});
|
|
32
|
+
currentConfig = config;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const getProjectConfig = async () => {
|
|
36
|
+
if (!currentConfig) {
|
|
37
|
+
// initially
|
|
38
|
+
await reloadConfigAndObserve();
|
|
39
|
+
}
|
|
40
|
+
return currentConfig;
|
|
41
|
+
};
|
|
30
42
|
|
|
31
43
|
export const getGitlabCiFilePath = async () => {
|
|
32
44
|
const gitRoot = await getGitRoot();
|
|
@@ -99,6 +111,7 @@ export const getAllPipelineContexts = async () => {
|
|
|
99
111
|
|
|
100
112
|
export const getEnvironment = async (env: string, componentName: string) => {
|
|
101
113
|
const config = await getProjectConfig();
|
|
114
|
+
|
|
102
115
|
return _getEnvironment(config, componentName, env);
|
|
103
116
|
};
|
|
104
117
|
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
39
|
-
var getProjectConfig_1 = require("../../../../config/getProjectConfig");
|
|
40
|
-
var showProjectBanner_1 = require("./utils/showProjectBanner");
|
|
41
|
-
exports["default"] = (function (vorpal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
return __generator(this, function (_a) {
|
|
43
|
-
return [2 /*return*/, vorpal
|
|
44
|
-
.command("project-reload-config", "reloads the config")
|
|
45
|
-
.action(function () {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0: return [4 /*yield*/, (0, getProjectConfig_1.reloadConfig)()];
|
|
50
|
-
case 1:
|
|
51
|
-
_a.sent();
|
|
52
|
-
return [4 /*yield*/, (0, showProjectBanner_1.showProjectBanner)(vorpal)];
|
|
53
|
-
case 2:
|
|
54
|
-
_a.sent();
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
})];
|
|
60
|
-
});
|
|
61
|
-
}); });
|
|
62
|
-
//# sourceMappingURL=commandReloadConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandReloadConfig.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/project/commandReloadConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wEAAmE;AACnE,+DAA8D;AAE9D,sBAAe,UAAO,MAAc;;QAClC,sBAAA,MAAM;iBACH,OAAO,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;iBAEtD,MAAM,CAAC;;;;oCACN,qBAAM,IAAA,+BAAY,GAAE,EAAA;;gCAApB,SAAoB,CAAC;gCACrB,qBAAM,IAAA,qCAAiB,EAAC,MAAM,CAAC,EAAA;;gCAA/B,SAA+B,CAAC;;;;;aACjC,CAAC,EAAA;;KAAA,EAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Vorpal from "vorpal";
|
|
2
|
-
import { reloadConfig } from "../../../../config/getProjectConfig";
|
|
3
|
-
import { showProjectBanner } from "./utils/showProjectBanner";
|
|
4
|
-
|
|
5
|
-
export default async (vorpal: Vorpal) =>
|
|
6
|
-
vorpal
|
|
7
|
-
.command("project-reload-config", "reloads the config")
|
|
8
|
-
|
|
9
|
-
.action(async function () {
|
|
10
|
-
await reloadConfig();
|
|
11
|
-
await showProjectBanner(vorpal);
|
|
12
|
-
});
|