@catladder/cli 0.0.0-main-81a23fae → 0.0.0-main-6fadf9ea
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/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/apps/cli/config/writeConfig.d.ts +0 -5
- package/dist/apps/cli/config/writeConfig.js +0 -106
- package/dist/apps/cli/config/writeConfig.js.map +0 -1
- package/src/apps/cli/config/writeConfig.ts +0 -71
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
],
|
|
54
54
|
"license": "MIT",
|
|
55
|
-
"version": "0.0.0-main-
|
|
55
|
+
"version": "0.0.0-main-6fadf9ea",
|
|
56
56
|
"scripts": {
|
|
57
57
|
"lint": "eslint \"src/**/*.ts\"",
|
|
58
58
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"ts-node": "^10.9.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@catladder/pipeline": "0.0.0-main-
|
|
77
|
+
"@catladder/pipeline": "0.0.0-main-6fadf9ea",
|
|
78
78
|
"@gitbeaker/rest": "^39.28.0",
|
|
79
79
|
"@kubernetes/client-node": "^0.16.2",
|
|
80
80
|
"@tsconfig/node14": "^1.0.1",
|
|
@@ -1,106 +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
|
-
exports.writeConfig = void 0;
|
|
40
|
-
var child_process_promise_1 = require("child-process-promise");
|
|
41
|
-
var fs_extra_1 = require("fs-extra");
|
|
42
|
-
var js_yaml_1 = require("js-yaml");
|
|
43
|
-
var prettier_1 = require("prettier");
|
|
44
|
-
var projects_1 = require("../../../utils/projects");
|
|
45
|
-
var writeConfig = function (vorpal, config, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var gitRoot, TS, configType, file, content, file, content;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0: return [4 /*yield*/, (0, projects_1.getGitRoot)()];
|
|
50
|
-
case 1:
|
|
51
|
-
gitRoot = _a.sent();
|
|
52
|
-
TS = "typescript (recommended)";
|
|
53
|
-
return [4 /*yield*/, vorpal.prompt({
|
|
54
|
-
type: "list",
|
|
55
|
-
name: "configType",
|
|
56
|
-
choices: [TS, "yaml"],
|
|
57
|
-
message: "In which format do you want the config? 🤔"
|
|
58
|
-
})];
|
|
59
|
-
case 2:
|
|
60
|
-
configType = (_a.sent()).configType;
|
|
61
|
-
vorpal.log("");
|
|
62
|
-
if (!(configType === TS)) return [3 /*break*/, 6];
|
|
63
|
-
file = gitRoot + "/catladder.ts";
|
|
64
|
-
content = (0, prettier_1.format)("\n import type { Config } from \"@catladder/pipeline\";\n \n const config: Config = ".concat(JSON.stringify(config), ";\n\n export default config;\n\n \n ").concat((options === null || options === void 0 ? void 0 : options.endComment) ? "/*".concat(options.endComment, "*/") : "", "\n \n "), {
|
|
65
|
-
parser: "babel"
|
|
66
|
-
});
|
|
67
|
-
return [4 /*yield*/, (0, fs_extra_1.writeFile)(file, content, {
|
|
68
|
-
encoding: "utf-8"
|
|
69
|
-
})];
|
|
70
|
-
case 3:
|
|
71
|
-
_a.sent();
|
|
72
|
-
vorpal.log("adding type @catladder/pipeline....");
|
|
73
|
-
return [4 /*yield*/, (0, child_process_promise_1.spawn)("yarn add --non-interactive @catladder/pipeline -DW", {
|
|
74
|
-
shell: true
|
|
75
|
-
})];
|
|
76
|
-
case 4:
|
|
77
|
-
_a.sent();
|
|
78
|
-
return [4 /*yield*/, (0, child_process_promise_1.exec)("git add " + file)];
|
|
79
|
-
case 5:
|
|
80
|
-
_a.sent();
|
|
81
|
-
return [3 /*break*/, 9];
|
|
82
|
-
case 6:
|
|
83
|
-
file = gitRoot + "/catladder.yml";
|
|
84
|
-
content = (0, js_yaml_1.dump)(config);
|
|
85
|
-
return [4 /*yield*/, (0, fs_extra_1.writeFile)(file, content +
|
|
86
|
-
"\n\n" +
|
|
87
|
-
(options.endComment
|
|
88
|
-
? "# " + options.endComment.split("\n").join("\n# ")
|
|
89
|
-
: ""), {
|
|
90
|
-
encoding: "utf-8"
|
|
91
|
-
})];
|
|
92
|
-
case 7:
|
|
93
|
-
_a.sent();
|
|
94
|
-
return [4 /*yield*/, (0, child_process_promise_1.exec)("git add " + file)];
|
|
95
|
-
case 8:
|
|
96
|
-
_a.sent();
|
|
97
|
-
_a.label = 9;
|
|
98
|
-
case 9:
|
|
99
|
-
vorpal.log("done!");
|
|
100
|
-
vorpal.log("");
|
|
101
|
-
return [2 /*return*/];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}); };
|
|
105
|
-
exports.writeConfig = writeConfig;
|
|
106
|
-
//# sourceMappingURL=writeConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeConfig.js","sourceRoot":"","sources":["../../../../src/apps/cli/config/writeConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+DAAoD;AACpD,qCAAqC;AACrC,mCAA+B;AAC/B,qCAAkC;AAElC,oDAAqD;AAE9C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,OAAO,GAAG,IAAA,cAAI,EAAC,MAAM,CAAC,CAAC;gBAE7B,qBAAM,IAAA,oBAAS,EACb,IAAI,EACJ,OAAO;wBACL,MAAM;wBACN,CAAC,OAAO,CAAC,UAAU;4BACjB,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;4BACpD,CAAC,CAAC,EAAE,CAAC,EACT;wBACE,QAAQ,EAAE,OAAO;qBAClB,CACF,EAAA;;gBAVD,SAUC,CAAC;gBACF,qBAAM,IAAA,4BAAI,EAAC,UAAU,GAAG,IAAI,CAAC,EAAA;;gBAA7B,SAA6B,CAAC;;;gBAEhC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACpB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;;;;KAChB,CAAC;AA9DW,QAAA,WAAW,eA8DtB"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { Config } from "@catladder/pipeline";
|
|
2
|
-
import { spawn, exec } from "child-process-promise";
|
|
3
|
-
import { writeFile } from "fs-extra";
|
|
4
|
-
import { dump } from "js-yaml";
|
|
5
|
-
import { format } from "prettier";
|
|
6
|
-
import type { CommandInstance } from "vorpal";
|
|
7
|
-
import { getGitRoot } from "../../../utils/projects";
|
|
8
|
-
|
|
9
|
-
export const writeConfig = async (
|
|
10
|
-
vorpal: CommandInstance,
|
|
11
|
-
config: Config,
|
|
12
|
-
options?: {
|
|
13
|
-
endComment?: string;
|
|
14
|
-
}
|
|
15
|
-
) => {
|
|
16
|
-
const gitRoot = await getGitRoot();
|
|
17
|
-
const TS = "typescript (recommended)";
|
|
18
|
-
const { configType } = await vorpal.prompt({
|
|
19
|
-
type: "list",
|
|
20
|
-
name: "configType",
|
|
21
|
-
choices: [TS, "yaml"],
|
|
22
|
-
message: "In which format do you want the config? 🤔",
|
|
23
|
-
});
|
|
24
|
-
vorpal.log("");
|
|
25
|
-
if (configType === TS) {
|
|
26
|
-
const file = gitRoot + "/catladder.ts";
|
|
27
|
-
const content = format(
|
|
28
|
-
`
|
|
29
|
-
import type { Config } from "@catladder/pipeline";
|
|
30
|
-
|
|
31
|
-
const config: Config = ${JSON.stringify(config)};
|
|
32
|
-
|
|
33
|
-
export default config;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
${options?.endComment ? `/*${options.endComment}*/` : ""}
|
|
37
|
-
|
|
38
|
-
`,
|
|
39
|
-
{
|
|
40
|
-
parser: "babel",
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
await writeFile(file, content, {
|
|
45
|
-
encoding: "utf-8",
|
|
46
|
-
});
|
|
47
|
-
vorpal.log("adding type @catladder/pipeline....");
|
|
48
|
-
await spawn("yarn add --non-interactive @catladder/pipeline -DW", {
|
|
49
|
-
shell: true,
|
|
50
|
-
});
|
|
51
|
-
await exec("git add " + file);
|
|
52
|
-
} else {
|
|
53
|
-
const file = gitRoot + "/catladder.yml";
|
|
54
|
-
const content = dump(config);
|
|
55
|
-
|
|
56
|
-
await writeFile(
|
|
57
|
-
file,
|
|
58
|
-
content +
|
|
59
|
-
"\n\n" +
|
|
60
|
-
(options.endComment
|
|
61
|
-
? "# " + options.endComment.split("\n").join("\n# ")
|
|
62
|
-
: ""),
|
|
63
|
-
{
|
|
64
|
-
encoding: "utf-8",
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
await exec("git add " + file);
|
|
68
|
-
}
|
|
69
|
-
vorpal.log("done!");
|
|
70
|
-
vorpal.log("");
|
|
71
|
-
};
|