@catladder/cli 0.0.0-main-81a23fae → 0.0.0-main-bdf003a6

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.
@@ -41,7 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
41
  exports.__esModule = true;
42
42
  exports.editAsFile = void 0;
43
43
  var tmp_promise_1 = require("tmp-promise");
44
- var js_yaml_1 = require("js-yaml");
44
+ var yaml_1 = require("yaml");
45
45
  var fs_extra_1 = require("fs-extra");
46
46
  var getEditor_1 = __importDefault(require("./getEditor"));
47
47
  var editAsFile = function (inObject, preamble) { return __awaiter(void 0, void 0, void 0, function () {
@@ -52,7 +52,7 @@ var editAsFile = function (inObject, preamble) { return __awaiter(void 0, void 0
52
52
  fullPreamble = preamble
53
53
  ? "#\n# ".concat(preamble.split("\n").join("\n# "), "\n#\n\n")
54
54
  : "\n";
55
- asString = fullPreamble + (0, js_yaml_1.dump)(inObject, { noRefs: true });
55
+ asString = fullPreamble + (0, yaml_1.stringify)(inObject, { aliasDuplicateObjects: false });
56
56
  return [4 /*yield*/, (0, tmp_promise_1.withFile)(function (_a) {
57
57
  var tmpFilePath = _a.path;
58
58
  return __awaiter(void 0, void 0, void 0, function () {
@@ -66,7 +66,7 @@ var editAsFile = function (inObject, preamble) { return __awaiter(void 0, void 0
66
66
  case 2: return [4 /*yield*/, (_c.sent()).open(tmpFilePath)];
67
67
  case 3:
68
68
  _c.sent();
69
- _b = js_yaml_1.load;
69
+ _b = yaml_1.parse;
70
70
  return [4 /*yield*/, (0, fs_extra_1.readFile)(tmpFilePath)];
71
71
  case 4:
72
72
  newContent = _b.apply(void 0, [(_c.sent()).toString("utf-8")]);
@@ -1 +1 @@
1
- {"version":3,"file":"editAsFile.js","sourceRoot":"","sources":["../../src/utils/editAsFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAuC;AACvC,mCAAqC;AA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CAAC,CAAC,eACF,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAGpC;oBACG,CAAC,CAAC,IAAI,CAAC;gBACH,QAAQ,GACZ,YAAY,GAAG,IAAA,gBAAS,EAAC,QAAQ,EAAE,EAAE,qBAAqB,EAAE,KAAK,EAAE,CAAC,CAAC;gBAGvE,qBAAM,IAAA,sBAAQ,EACZ,UAAO,EAAqB;4BAAb,WAAW,UAAA;;;;;4CACxB,qBAAM,IAAA,oBAAS,EAAC,WAAW,EAAE,QAAQ,CAAC,EAAA;;wCAAtC,SAAsC,CAAC;wCAChC,qBAAM,IAAA,sBAAS,GAAE,EAAA;4CAAxB,qBAAM,CAAC,SAAiB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAA;;wCAA3C,SAA2C,CAAC;wCAC/B,KAAA,YAAK,CAAA;wCAAE,qBAAM,IAAA,mBAAQ,EAAC,WAAW,CAAC,EAAA;;wCAA/C,UAAU,GAAG,kBAAM,CAAC,SAA2B,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAM,CAAC;;;;;qBAC1E,EACD,EAAE,OAAO,EAAE,MAAM,EAAE,CACpB,EAAA;;gBAPD,SAOC,CAAC;gBAEF,sBAAO,UAAU,EAAC;;;KACnB,CAAC;AAzBW,QAAA,UAAU,cAyBrB"}
@@ -1,2 +1 @@
1
1
  export declare const readFileOrError: (filePath: string) => Promise<any[]>;
2
- export declare const readYaml: <T = Record<string, any>>(filename: string) => Promise<T>;
@@ -39,9 +39,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  exports.__esModule = true;
42
- exports.readYaml = exports.readFileOrError = void 0;
42
+ exports.readFileOrError = void 0;
43
43
  var fs_extra_1 = __importDefault(require("fs-extra"));
44
- var js_yaml_1 = __importDefault(require("js-yaml"));
45
44
  var readFile = function (file) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
46
45
  return [2 /*return*/, fs_extra_1["default"].readFile(file, { encoding: "utf-8" })];
47
46
  }); }); };
@@ -63,21 +62,4 @@ var readFileOrError = function (filePath) { return __awaiter(void 0, void 0, voi
63
62
  });
64
63
  }); };
65
64
  exports.readFileOrError = readFileOrError;
66
- var readYaml = function (filename) { return __awaiter(void 0, void 0, void 0, function () {
67
- var _a, _b, e_2;
68
- return __generator(this, function (_c) {
69
- switch (_c.label) {
70
- case 0:
71
- _c.trys.push([0, 2, , 3]);
72
- _b = (_a = js_yaml_1["default"]).load;
73
- return [4 /*yield*/, readFile(filename)];
74
- case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
75
- case 2:
76
- e_2 = _c.sent();
77
- return [2 /*return*/, null];
78
- case 3: return [2 /*return*/];
79
- }
80
- });
81
- }); };
82
- exports.readYaml = readYaml;
83
65
  //# sourceMappingURL=files.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/utils/files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA0B;AAC1B,oDAA2B;AAE3B,IAAM,QAAQ,GAAG,UAAO,IAAY;IAClC,sBAAA,qBAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAA;SAAA,CAAC;AAEpC,IAAM,eAAe,GAAG,UAAO,QAAgB;;;;;;gBAErC,qBAAM,QAAQ,CAAC,QAAQ,CAAC,EAAA;;gBAA/B,IAAI,GAAG,SAAwB;gBACrC,sBAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAC;;;gBAEpB,sBAAO,CAAC,GAAC,CAAC,EAAC;;;;KAEd,CAAC;AAPW,QAAA,eAAe,mBAO1B;AAEK,IAAM,QAAQ,GAAG,UAAgC,QAAgB;;;;;;gBAE7D,KAAA,CAAA,KAAA,oBAAI,CAAA,CAAC,IAAI,CAAA;gBAAC,qBAAM,QAAQ,CAAC,QAAQ,CAAC,EAAA;oBAAzC,sBAAO,cAAU,SAAwB,EAAM,EAAC;;;gBAEhD,sBAAO,IAAI,EAAC;;;;KAEf,CAAC;AANW,QAAA,QAAQ,YAMnB"}
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/utils/files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA0B;AAE1B,IAAM,QAAQ,GAAG,UAAO,IAAY;IAClC,sBAAA,qBAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAA;SAAA,CAAC;AAEpC,IAAM,eAAe,GAAG,UAAO,QAAgB;;;;;;gBAErC,qBAAM,QAAQ,CAAC,QAAQ,CAAC,EAAA;;gBAA/B,IAAI,GAAG,SAAwB;gBACrC,sBAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAC;;;gBAEpB,sBAAO,CAAC,GAAC,CAAC,EAAC;;;;KAEd,CAAC;AAPW,QAAA,eAAe,mBAO1B"}
@@ -53,7 +53,7 @@ exports.__esModule = true;
53
53
  exports.setPreference = exports.getPreference = exports.hasPreference = void 0;
54
54
  var fs_extra_1 = __importDefault(require("fs-extra"));
55
55
  var os_1 = require("os");
56
- var js_yaml_1 = require("js-yaml");
56
+ var yaml_1 = require("yaml");
57
57
  var directory = "".concat((0, os_1.homedir)(), "/.catladder");
58
58
  var file = "".concat(directory, "/preferences.yml");
59
59
  var getPreferences = function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -69,7 +69,7 @@ var getPreferences = function () { return __awaiter(void 0, void 0, void 0, func
69
69
  _c.sent();
70
70
  _c.label = 3;
71
71
  case 3:
72
- _a = js_yaml_1.load;
72
+ _a = yaml_1.parse;
73
73
  return [4 /*yield*/, fs_extra_1["default"].readFile(file, { encoding: "utf-8" })];
74
74
  case 4: return [2 /*return*/, ((_b = _a.apply(void 0, [_c.sent()])) !== null && _b !== void 0 ? _b : {})];
75
75
  }
@@ -108,7 +108,7 @@ var setPreference = function (key, value) { return __awaiter(void 0, void 0, voi
108
108
  case 1:
109
109
  preferences = _b.sent();
110
110
  newPreferences = __assign(__assign({}, preferences), (_a = {}, _a[key] = value, _a));
111
- return [4 /*yield*/, fs_extra_1["default"].writeFile(file, (0, js_yaml_1.dump)(newPreferences))];
111
+ return [4 /*yield*/, fs_extra_1["default"].writeFile(file, (0, yaml_1.stringify)(newPreferences))];
112
112
  case 2:
113
113
  _b.sent();
114
114
  return [2 /*return*/];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/preferences/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA0B;AAC1B,yBAA6B;AAE7B,mCAAqC;AACrC,IAAM,SAAS,GAAG,UAAG,IAAA,YAAO,GAAE,gBAAa,CAAC;AAC5C,IAAM,IAAI,GAAG,UAAG,SAAS,qBAAkB,CAAC;AAE5C,IAAM,cAAc,GAAG;;;;;oBACf,qBAAM,qBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;qBAA3B,CAAC,CAAC,SAAyB,CAAC,EAA5B,wBAA4B;gBAC9B,qBAAM,qBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;gBAAzB,SAAyB,CAAC;;;gBAEpB,KAAA,cAAI,CAAA;gBAAC,qBAAM,qBAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAA;oBAA3D,sBAAO,CAAC,MAAA,kBAAK,SAA8C,EAAC,mCAAI,EAAE,CAGjE,EAAC;;;KACH,CAAC;AAEK,IAAM,aAAa,GAAG,UAAO,GAAW;;;;oBACzB,qBAAM,cAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBAC1C,sBAAO,GAAG,IAAI,WAA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AA,kBAAM,SAA8C,EAAC,mCAC3D,EAAE,CAA2B,EAAC;;;KACjC,CAAC;AAEK,IAAM,aAAa,GAAG,UAAO,GAAW;;;;oBACzB,qBAAM,cAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBAC1C,sBAAO,GAAG,IAAI,WAAW,EAAC;;;KAC3B,CAAC;AAHW,QAAA,aAAa,iBAGxB;AACK,IAAM,aAAa,GAAG,UAAO,GAAW;;;;oBACzB,qBAAM,cAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBAC1C,sBAAO,WAAW,CAAC,GAAG,CAAC,EAAC;;;KACzB,CAAC;AAHW,QAAA,aAAa,iBAGxB;AAEK,IAAM,aAAa,GAAG,UAAO,GAAW,EAAE,KAAsB;;;;;oBACjD,qBAAM,cAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBAEpC,cAAc,yBACf,WAAW,gBACb,GAAG,IAAG,KAAK,MACb,CAAC;gBAEF,qBAAM,qBAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAA,gBAAS,EAAC,cAAc,CAAC,CAAC,EAAA;;gBAAnD,SAAmD,CAAC;;;;KACrD,CAAC;AATW,QAAA,aAAa,iBASxB"}
package/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  }
53
53
  ],
54
54
  "license": "MIT",
55
- "version": "0.0.0-main-81a23fae",
55
+ "version": "0.0.0-main-bdf003a6",
56
56
  "scripts": {
57
57
  "lint": "eslint \"src/**/*.ts\"",
58
58
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -74,13 +74,12 @@
74
74
  "ts-node": "^10.9.1"
75
75
  },
76
76
  "devDependencies": {
77
- "@catladder/pipeline": "0.0.0-main-81a23fae",
77
+ "@catladder/pipeline": "0.0.0-main-bdf003a6",
78
78
  "@gitbeaker/rest": "^39.28.0",
79
79
  "@kubernetes/client-node": "^0.16.2",
80
80
  "@tsconfig/node14": "^1.0.1",
81
81
  "@types/common-tags": "^1.8.0",
82
82
  "@types/fs-extra": "^5.0.4",
83
- "@types/js-yaml": "^4.0.5",
84
83
  "@types/lodash": "^4.14.185",
85
84
  "@types/memoizee": "^0.4.2",
86
85
  "@types/node-fetch": "^2.1.4",
@@ -99,7 +98,6 @@
99
98
  "eslint": "^8.7.0",
100
99
  "fs-extra": "^7.0.1",
101
100
  "gitlab": "^4.4.1",
102
- "js-yaml": "^4.1.0",
103
101
  "lodash": "^4.17.21",
104
102
  "memoizee": "^0.4.14",
105
103
  "node-fetch": "^2.3.0",
@@ -108,7 +106,8 @@
108
106
  "tmp-promise": "^2.0.2",
109
107
  "ts-results-es": "^4.1.0-alpha.1",
110
108
  "typescript": "^4.5.4",
111
- "vorpal": "^1.12.0"
109
+ "vorpal": "^1.12.0",
110
+ "yaml": "^2.4.5"
112
111
  },
113
112
  "stableVersion": "0.0.0"
114
113
  }
@@ -1,4 +1,4 @@
1
- import { dump } from "js-yaml";
1
+ import { stringify } from "yaml";
2
2
  import { pick } from "lodash";
3
3
  import type Vorpal from "vorpal";
4
4
  import { getProjectPods } from "../../../../kubernetes";
@@ -13,6 +13,8 @@ export default async (vorpal: Vorpal) =>
13
13
  await ensureCluster.call(this, envComponent);
14
14
  const pods = await getProjectPods(envComponent);
15
15
  this.log(
16
- dump(pods.map((p) => pick(p, ["metadata.name", "status.startTime"])))
16
+ stringify(
17
+ pods.map((p) => pick(p, ["metadata.name", "status.startTime"]))
18
+ )
17
19
  );
18
20
  });
@@ -11,7 +11,7 @@ import type { CommandInstance } from "vorpal";
11
11
  import { getAllVariables, getVariableValueByRawName } from "../utils/gitlab";
12
12
 
13
13
  import { getGitRoot } from "../utils/projects";
14
- import { readYaml } from "../utils/files";
14
+
15
15
  import { watch } from "fs";
16
16
 
17
17
  export { parseChoice } from "./parseChoice";
@@ -42,19 +42,6 @@ export const getProjectConfig = async () => {
42
42
  return currentConfig as Config;
43
43
  };
44
44
 
45
- export const getGitlabCiFilePath = async () => {
46
- const gitRoot = await getGitRoot();
47
- return gitRoot + "/.gitlab-ci.yml";
48
- };
49
- export const getGitlabCi = async <T = Record<string, any>>() => {
50
- try {
51
- return readYaml(await getGitlabCiFilePath()) as Promise<T>;
52
- } catch (e) {
53
- // ignore
54
- return null;
55
- }
56
- };
57
-
58
45
  export const getProjectComponents = async () => {
59
46
  const config = await getProjectConfig();
60
47
  if (!config) return [];
@@ -1,5 +1,5 @@
1
1
  import { withFile } from "tmp-promise";
2
- import { dump, load } from "js-yaml";
2
+ import { parse, stringify } from "yaml";
3
3
 
4
4
  import { readFile, writeFile } from "fs-extra";
5
5
  import getEditor from "./getEditor";
@@ -15,14 +15,15 @@ export const editAsFile = async <T>(
15
15
 
16
16
  `
17
17
  : "\n";
18
- const asString = fullPreamble + dump(inObject, { noRefs: true });
18
+ const asString =
19
+ fullPreamble + stringify(inObject, { aliasDuplicateObjects: false });
19
20
  let newContent: T;
20
21
 
21
22
  await withFile(
22
23
  async ({ path: tmpFilePath }) => {
23
24
  await writeFile(tmpFilePath, asString);
24
25
  await (await getEditor()).open(tmpFilePath);
25
- newContent = load((await readFile(tmpFilePath)).toString("utf-8")) as T;
26
+ newContent = parse((await readFile(tmpFilePath)).toString("utf-8")) as T;
26
27
  },
27
28
  { postfix: ".yml" }
28
29
  );
@@ -1,5 +1,4 @@
1
1
  import fs from "fs-extra";
2
- import yaml from "js-yaml";
3
2
 
4
3
  const readFile = async (file: string) =>
5
4
  fs.readFile(file, { encoding: "utf-8" });
@@ -12,11 +11,3 @@ export const readFileOrError = async (filePath: string) => {
12
11
  return [e];
13
12
  }
14
13
  };
15
-
16
- export const readYaml = async <T = Record<string, any>>(filename: string) => {
17
- try {
18
- return yaml.load(await readFile(filename)) as T;
19
- } catch (e) {
20
- return null;
21
- }
22
- };
@@ -1,7 +1,7 @@
1
1
  import fs from "fs-extra";
2
2
  import { homedir } from "os";
3
3
 
4
- import { load, dump } from "js-yaml";
4
+ import { parse, stringify } from "yaml";
5
5
  const directory = `${homedir()}/.catladder`;
6
6
  const file = `${directory}/preferences.yml`;
7
7
 
@@ -9,10 +9,8 @@ const getPreferences = async () => {
9
9
  if (!(await fs.pathExists(file))) {
10
10
  await fs.createFile(file);
11
11
  }
12
- return (load(await fs.readFile(file, { encoding: "utf-8" })) ?? {}) as Record<
13
- string,
14
- string
15
- >;
12
+ return (parse(await fs.readFile(file, { encoding: "utf-8" })) ??
13
+ {}) as Record<string, string>;
16
14
  };
17
15
 
18
16
  export const hasPreference = async (key: string) => {
@@ -32,5 +30,5 @@ export const setPreference = async (key: string, value: string | number) => {
32
30
  [key]: value,
33
31
  };
34
32
 
35
- await fs.writeFile(file, dump(newPreferences));
33
+ await fs.writeFile(file, stringify(newPreferences));
36
34
  };
@@ -1,5 +0,0 @@
1
- import type { Config } from "@catladder/pipeline";
2
- import type { CommandInstance } from "vorpal";
3
- export declare const writeConfig: (vorpal: CommandInstance, config: Config, options?: {
4
- endComment?: string;
5
- }) => Promise<void>;
@@ -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,IAAM,WAA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G,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
- };