kist 0.1.37 → 0.1.38

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.
@@ -1,10 +1,8 @@
1
1
  import { ConfigInterface } from "../../interface/ConfigInterface";
2
2
  import { AbstractProcess } from "../abstract/AbstractProcess";
3
3
  /**
4
- * ConfigLoader is responsible for loading and parsing configuration files
5
- * (`kist.yaml` or `kist.yml` by default). It validates the configuration
6
- * structure and provides it in a usable format for the pipeline.
7
- * Extends `AbstractProcess` for consistent logging.
4
+ * ConfigLoader is responsible for loading and parsing configuration files.
5
+ * Supports a custom path via `--config`, and falls back to `kist.yaml` or `kist.yml`.
8
6
  */
9
7
  export declare class ConfigLoader extends AbstractProcess {
10
8
  /**
@@ -15,21 +13,12 @@ export declare class ConfigLoader extends AbstractProcess {
15
13
  * Default filenames to search for configuration files.
16
14
  */
17
15
  private readonly defaultFilenames;
18
- /**
19
- * Constructs a ConfigLoader instance.
20
- * Searches for `kist.yaml` or `kist.yml` in the working directory
21
- * unless a custom path is provided.
22
- *
23
- * @param configPath - Optional custom configuration file path.
24
- */
25
- constructor(configPath?: string);
16
+ constructor();
26
17
  /**
27
18
  * Initializes the loader by locating the configuration file.
28
- * Searches for `kist.yaml` or `kist.yml` by default.
29
- *
30
- * @param configPath - Optional custom configuration file path.
19
+ * Uses `--config` CLI flag if provided, otherwise defaults.
31
20
  */
32
- initialize(configPath?: string): Promise<void>;
21
+ initialize(): Promise<void>;
33
22
  /**
34
23
  * Loads and validates the configuration file.
35
24
  *
@@ -19,27 +19,19 @@ exports.ConfigLoader = void 0;
19
19
  const fs_1 = __importDefault(require("fs"));
20
20
  const js_yaml_1 = __importDefault(require("js-yaml"));
21
21
  const path_1 = __importDefault(require("path"));
22
+ const ArgumentParser_1 = require("../../cli/ArgumentParser");
22
23
  const AbstractProcess_1 = require("../abstract/AbstractProcess");
23
24
  // ============================================================================
24
25
  // Class
25
26
  // ============================================================================
26
27
  /**
27
- * ConfigLoader is responsible for loading and parsing configuration files
28
- * (`kist.yaml` or `kist.yml` by default). It validates the configuration
29
- * structure and provides it in a usable format for the pipeline.
30
- * Extends `AbstractProcess` for consistent logging.
28
+ * ConfigLoader is responsible for loading and parsing configuration files.
29
+ * Supports a custom path via `--config`, and falls back to `kist.yaml` or `kist.yml`.
31
30
  */
32
31
  class ConfigLoader extends AbstractProcess_1.AbstractProcess {
33
32
  // Constructor
34
33
  // ========================================================================
35
- /**
36
- * Constructs a ConfigLoader instance.
37
- * Searches for `kist.yaml` or `kist.yml` in the working directory
38
- * unless a custom path is provided.
39
- *
40
- * @param configPath - Optional custom configuration file path.
41
- */
42
- constructor(configPath) {
34
+ constructor() {
43
35
  super();
44
36
  // Parameters
45
37
  // ========================================================================
@@ -51,27 +43,22 @@ class ConfigLoader extends AbstractProcess_1.AbstractProcess {
51
43
  * Default filenames to search for configuration files.
52
44
  */
53
45
  this.defaultFilenames = ["kist.yaml", "kist.yml"];
54
- if (configPath) {
55
- this.configPath = path_1.default.resolve(process.cwd(), configPath);
56
- this.logDebug(`Custom configuration path set: ${this.configPath}`);
57
- }
58
- else {
59
- this.logDebug("ConfigLoader initialized without custom path.");
60
- }
46
+ this.logDebug("ConfigLoader initialized.");
61
47
  }
62
48
  // Methods
63
49
  // ========================================================================
64
50
  /**
65
51
  * Initializes the loader by locating the configuration file.
66
- * Searches for `kist.yaml` or `kist.yml` by default.
67
- *
68
- * @param configPath - Optional custom configuration file path.
52
+ * Uses `--config` CLI flag if provided, otherwise defaults.
69
53
  */
70
- initialize(configPath) {
54
+ initialize() {
71
55
  return __awaiter(this, void 0, void 0, function* () {
72
- const searchPaths = configPath ? [configPath] : this.defaultFilenames;
56
+ const parser = new ArgumentParser_1.ArgumentParser();
57
+ const cliFlags = parser.getAllFlags();
58
+ const cliPath = typeof cliFlags.config === "string" ? cliFlags.config : undefined;
59
+ const searchPaths = cliPath ? [cliPath] : this.defaultFilenames;
73
60
  this.logDebug(`Current working directory: ${process.cwd()}`);
74
- this.logDebug("Searching for configuration files...");
61
+ this.logDebug(`Searching for config file${cliPath ? ` from --config=${cliPath}` : ""}...`);
75
62
  for (const fileName of searchPaths) {
76
63
  const resolvedPath = path_1.default.resolve(process.cwd(), fileName);
77
64
  this.logDebug(`Checking: ${resolvedPath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kist",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "Package Pipeline Processor",
5
5
  "keywords": [
6
6
  "kist",
@@ -5,6 +5,7 @@
5
5
  import fs from "fs";
6
6
  import yaml from "js-yaml";
7
7
  import path from "path";
8
+ import { ArgumentParser } from "../../cli/ArgumentParser";
8
9
  import { ConfigInterface } from "../../interface/ConfigInterface";
9
10
  import { AbstractProcess } from "../abstract/AbstractProcess";
10
11
 
@@ -13,10 +14,8 @@ import { AbstractProcess } from "../abstract/AbstractProcess";
13
14
  // ============================================================================
14
15
 
15
16
  /**
16
- * ConfigLoader is responsible for loading and parsing configuration files
17
- * (`kist.yaml` or `kist.yml` by default). It validates the configuration
18
- * structure and provides it in a usable format for the pipeline.
19
- * Extends `AbstractProcess` for consistent logging.
17
+ * ConfigLoader is responsible for loading and parsing configuration files.
18
+ * Supports a custom path via `--config`, and falls back to `kist.yaml` or `kist.yml`.
20
19
  */
21
20
  export class ConfigLoader extends AbstractProcess {
22
21
  // Parameters
@@ -35,21 +34,9 @@ export class ConfigLoader extends AbstractProcess {
35
34
  // Constructor
36
35
  // ========================================================================
37
36
 
38
- /**
39
- * Constructs a ConfigLoader instance.
40
- * Searches for `kist.yaml` or `kist.yml` in the working directory
41
- * unless a custom path is provided.
42
- *
43
- * @param configPath - Optional custom configuration file path.
44
- */
45
- constructor(configPath?: string) {
37
+ constructor() {
46
38
  super();
47
- if (configPath) {
48
- this.configPath = path.resolve(process.cwd(), configPath);
49
- this.logDebug(`Custom configuration path set: ${this.configPath}`);
50
- } else {
51
- this.logDebug("ConfigLoader initialized without custom path.");
52
- }
39
+ this.logDebug("ConfigLoader initialized.");
53
40
  }
54
41
 
55
42
  // Methods
@@ -57,15 +44,20 @@ export class ConfigLoader extends AbstractProcess {
57
44
 
58
45
  /**
59
46
  * Initializes the loader by locating the configuration file.
60
- * Searches for `kist.yaml` or `kist.yml` by default.
61
- *
62
- * @param configPath - Optional custom configuration file path.
47
+ * Uses `--config` CLI flag if provided, otherwise defaults.
63
48
  */
64
- public async initialize(configPath?: string): Promise<void> {
65
- const searchPaths = configPath ? [configPath] : this.defaultFilenames;
49
+ public async initialize(): Promise<void> {
50
+ const parser = new ArgumentParser();
51
+ const cliFlags = parser.getAllFlags();
52
+ const cliPath =
53
+ typeof cliFlags.config === "string" ? cliFlags.config : undefined;
54
+
55
+ const searchPaths = cliPath ? [cliPath] : this.defaultFilenames;
66
56
 
67
57
  this.logDebug(`Current working directory: ${process.cwd()}`);
68
- this.logDebug("Searching for configuration files...");
58
+ this.logDebug(
59
+ `Searching for config file${cliPath ? ` from --config=${cliPath}` : ""}...`,
60
+ );
69
61
 
70
62
  for (const fileName of searchPaths) {
71
63
  const resolvedPath = path.resolve(process.cwd(), fileName);