@catladder/cli 0.0.0-main-a01765dc → 0.0.0-main-16d091cb
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 +18 -6
- package/dist/bundles/cli/index.js +18 -6
- package/dist/pipeline/src/types/hooks.d.ts +15 -6
- package/dist/pipeline/src/utils/writeFiles.d.ts +2 -0
- package/dist/pipeline/src/utils/writeFiles.js +18 -6
- package/dist/pipeline/src/utils/writeFiles.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -7728,21 +7728,33 @@ class FileWriter {
|
|
|
7728
7728
|
}
|
|
7729
7729
|
async writeTheFile(path, content) {
|
|
7730
7730
|
var _a, _b;
|
|
7731
|
-
const transformedContent = await ((_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite({
|
|
7732
|
-
|
|
7731
|
+
const transformedContent = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
7732
|
+
...(await this.getBaseHookContext(path)),
|
|
7733
7733
|
content,
|
|
7734
|
-
extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
|
|
7735
|
-
path,
|
|
7736
7734
|
}));
|
|
7737
7735
|
await (0, promises_1.writeFile)(path, transformedContent !== null && transformedContent !== void 0 ? transformedContent : content, {
|
|
7738
7736
|
encoding: "utf-8",
|
|
7739
7737
|
});
|
|
7740
7738
|
}
|
|
7739
|
+
async getBaseHookContext(path) {
|
|
7740
|
+
var _a, _b;
|
|
7741
|
+
const filename = (_a = path.split("/").pop()) !== null && _a !== void 0 ? _a : "";
|
|
7742
|
+
return {
|
|
7743
|
+
filename,
|
|
7744
|
+
path,
|
|
7745
|
+
extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
|
|
7746
|
+
};
|
|
7747
|
+
}
|
|
7741
7748
|
async writeGeneratedFile(path, content, options) {
|
|
7742
7749
|
await this.writeTheFile(path, [this.getAutoGeneratedHeader(options.commentChar), content].join("\n"));
|
|
7743
7750
|
}
|
|
7744
|
-
writeYamlfile(path, data) {
|
|
7745
|
-
|
|
7751
|
+
async writeYamlfile(path, data) {
|
|
7752
|
+
var _a, _b;
|
|
7753
|
+
const dataTransformed = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformYamlBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
7754
|
+
...(await this.getBaseHookContext(path)),
|
|
7755
|
+
data,
|
|
7756
|
+
}));
|
|
7757
|
+
return this.writeGeneratedFile(path, (0, yaml_1.stringify)(dataTransformed !== null && dataTransformed !== void 0 ? dataTransformed : data, exports.yamlStringifyOptions), {
|
|
7746
7758
|
commentChar: "#",
|
|
7747
7759
|
});
|
|
7748
7760
|
}
|
|
@@ -10983,21 +10983,33 @@ class FileWriter {
|
|
|
10983
10983
|
}
|
|
10984
10984
|
async writeTheFile(path, content) {
|
|
10985
10985
|
var _a, _b;
|
|
10986
|
-
const transformedContent = await ((_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite({
|
|
10987
|
-
|
|
10986
|
+
const transformedContent = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
10987
|
+
...(await this.getBaseHookContext(path)),
|
|
10988
10988
|
content,
|
|
10989
|
-
extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
|
|
10990
|
-
path,
|
|
10991
10989
|
}));
|
|
10992
10990
|
await (0, promises_1.writeFile)(path, transformedContent !== null && transformedContent !== void 0 ? transformedContent : content, {
|
|
10993
10991
|
encoding: "utf-8",
|
|
10994
10992
|
});
|
|
10995
10993
|
}
|
|
10994
|
+
async getBaseHookContext(path) {
|
|
10995
|
+
var _a, _b;
|
|
10996
|
+
const filename = (_a = path.split("/").pop()) !== null && _a !== void 0 ? _a : "";
|
|
10997
|
+
return {
|
|
10998
|
+
filename,
|
|
10999
|
+
path,
|
|
11000
|
+
extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
|
|
11001
|
+
};
|
|
11002
|
+
}
|
|
10996
11003
|
async writeGeneratedFile(path, content, options) {
|
|
10997
11004
|
await this.writeTheFile(path, [this.getAutoGeneratedHeader(options.commentChar), content].join("\n"));
|
|
10998
11005
|
}
|
|
10999
|
-
writeYamlfile(path, data) {
|
|
11000
|
-
|
|
11006
|
+
async writeYamlfile(path, data) {
|
|
11007
|
+
var _a, _b;
|
|
11008
|
+
const dataTransformed = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformYamlBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
11009
|
+
...(await this.getBaseHookContext(path)),
|
|
11010
|
+
data,
|
|
11011
|
+
}));
|
|
11012
|
+
return this.writeGeneratedFile(path, (0, yaml_1.stringify)(dataTransformed !== null && dataTransformed !== void 0 ? dataTransformed : data, exports.yamlStringifyOptions), {
|
|
11001
11013
|
commentChar: "#",
|
|
11002
11014
|
});
|
|
11003
11015
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type BaseHookContext = {
|
|
2
2
|
/**
|
|
3
3
|
* the filename of the file
|
|
4
4
|
*/
|
|
5
5
|
filename: string;
|
|
6
|
-
/**
|
|
7
|
-
* the extension of the file
|
|
8
|
-
*/
|
|
9
|
-
extension: string;
|
|
10
6
|
/**
|
|
11
7
|
* the path of the file
|
|
12
8
|
*/
|
|
13
9
|
path: string;
|
|
10
|
+
/**
|
|
11
|
+
* the extension of the file
|
|
12
|
+
*/
|
|
13
|
+
extension: string;
|
|
14
|
+
};
|
|
15
|
+
export type YamlHookContext = BaseHookContext & {
|
|
16
|
+
data: any;
|
|
17
|
+
};
|
|
18
|
+
export type FileHookContext = BaseHookContext & {
|
|
14
19
|
/**
|
|
15
20
|
* the content of the file
|
|
16
21
|
*/
|
|
@@ -21,6 +26,10 @@ export type Hooks = {
|
|
|
21
26
|
/**
|
|
22
27
|
* transform the file before it is written. If undefined is returned, the file is not modified
|
|
23
28
|
*/
|
|
24
|
-
transformFileBeforeWrite
|
|
29
|
+
transformFileBeforeWrite?: (fileHookContext: FileHookContext) => MaybePromise<string | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* transform the yaml before it is written. If undefined is returned, the yaml is not modified
|
|
32
|
+
*/
|
|
33
|
+
transformYamlBeforeWrite?: (fileHookContext: YamlHookContext) => MaybePromise<any | undefined>;
|
|
25
34
|
};
|
|
26
35
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stringify } from "yaml";
|
|
2
2
|
import type { Config } from "../types";
|
|
3
|
+
import type { BaseHookContext } from "../types/hooks";
|
|
3
4
|
type WriteFileOptions = {
|
|
4
5
|
commentChar: string;
|
|
5
6
|
};
|
|
@@ -10,6 +11,7 @@ export declare class FileWriter {
|
|
|
10
11
|
static create(config: Config): FileWriter;
|
|
11
12
|
constructor(config: Config);
|
|
12
13
|
protected writeTheFile(path: string, content: string): Promise<void>;
|
|
14
|
+
protected getBaseHookContext(path: string): Promise<BaseHookContext>;
|
|
13
15
|
writeGeneratedFile(path: string, content: string, options: WriteFileOptions): Promise<void>;
|
|
14
16
|
writeYamlfile(path: string, data: any): Promise<void>;
|
|
15
17
|
protected getAutoGeneratedHeader(commentChar: string): string;
|
|
@@ -21,21 +21,33 @@ class FileWriter {
|
|
|
21
21
|
}
|
|
22
22
|
async writeTheFile(path, content) {
|
|
23
23
|
var _a, _b;
|
|
24
|
-
const transformedContent = await ((_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite({
|
|
25
|
-
|
|
24
|
+
const transformedContent = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
25
|
+
...(await this.getBaseHookContext(path)),
|
|
26
26
|
content,
|
|
27
|
-
extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
|
|
28
|
-
path,
|
|
29
27
|
}));
|
|
30
28
|
await (0, promises_1.writeFile)(path, transformedContent !== null && transformedContent !== void 0 ? transformedContent : content, {
|
|
31
29
|
encoding: "utf-8",
|
|
32
30
|
});
|
|
33
31
|
}
|
|
32
|
+
async getBaseHookContext(path) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const filename = (_a = path.split("/").pop()) !== null && _a !== void 0 ? _a : "";
|
|
35
|
+
return {
|
|
36
|
+
filename,
|
|
37
|
+
path,
|
|
38
|
+
extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
34
41
|
async writeGeneratedFile(path, content, options) {
|
|
35
42
|
await this.writeTheFile(path, [this.getAutoGeneratedHeader(options.commentChar), content].join("\n"));
|
|
36
43
|
}
|
|
37
|
-
writeYamlfile(path, data) {
|
|
38
|
-
|
|
44
|
+
async writeYamlfile(path, data) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const dataTransformed = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformYamlBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
47
|
+
...(await this.getBaseHookContext(path)),
|
|
48
|
+
data,
|
|
49
|
+
}));
|
|
50
|
+
return this.writeGeneratedFile(path, (0, yaml_1.stringify)(dataTransformed !== null && dataTransformed !== void 0 ? dataTransformed : data, exports.yamlStringifyOptions), {
|
|
39
51
|
commentChar: "#",
|
|
40
52
|
});
|
|
41
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFiles.js","sourceRoot":"","sources":["../../../../../pipeline/src/utils/writeFiles.ts"],"names":[],"mappings":";;;AAAA,0CAAwC;AACxC,+BAAiC;
|
|
1
|
+
{"version":3,"file":"writeFiles.js","sourceRoot":"","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