@argos-ci/core 4.1.2 → 4.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -21
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -749,36 +749,44 @@ var schema = {
749
749
  nullable: true
750
750
  }
751
751
  };
752
- var createConfig = () => {
753
- return convict(schema, {
754
- args: []
755
- });
756
- };
752
+ function createConfig() {
753
+ return convict(schema, { args: [], env: {} });
754
+ }
755
+ function getDefaultConfig() {
756
+ return Object.entries(schema).reduce(
757
+ (cfg, [key, entry]) => {
758
+ cfg[key] = "env" in entry && entry.env && process.env[entry.env] ? process.env[entry.env] : entry.default;
759
+ return cfg;
760
+ },
761
+ {}
762
+ );
763
+ }
757
764
  async function readConfig(options = {}) {
758
765
  const config = createConfig();
759
766
  const ciEnv = await getCiEnvironment();
767
+ const defaultConfig = getDefaultConfig();
760
768
  config.load({
761
- apiBaseUrl: options.apiBaseUrl || config.get("apiBaseUrl"),
762
- commit: options.commit || config.get("commit") || ciEnv?.commit || null,
763
- branch: options.branch || config.get("branch") || ciEnv?.branch || null,
764
- token: options.token || config.get("token") || null,
765
- buildName: options.buildName || config.get("buildName") || null,
766
- prNumber: options.prNumber || config.get("prNumber") || ciEnv?.prNumber || null,
767
- prHeadCommit: config.get("prHeadCommit") || ciEnv?.prHeadCommit || null,
768
- prBaseBranch: config.get("prBaseBranch") || ciEnv?.prBaseBranch || null,
769
- referenceBranch: options.referenceBranch || config.get("referenceBranch") || null,
770
- referenceCommit: options.referenceCommit || config.get("referenceCommit") || null,
769
+ apiBaseUrl: options.apiBaseUrl || defaultConfig.apiBaseUrl,
770
+ commit: options.commit || defaultConfig.commit || ciEnv?.commit || null,
771
+ branch: options.branch || defaultConfig.branch || ciEnv?.branch || null,
772
+ token: options.token || defaultConfig.token || null,
773
+ buildName: options.buildName || defaultConfig.buildName || null,
774
+ prNumber: options.prNumber || defaultConfig.prNumber || ciEnv?.prNumber || null,
775
+ prHeadCommit: defaultConfig.prHeadCommit || ciEnv?.prHeadCommit || null,
776
+ prBaseBranch: defaultConfig.prBaseBranch || ciEnv?.prBaseBranch || null,
777
+ referenceBranch: options.referenceBranch || defaultConfig.referenceBranch || null,
778
+ referenceCommit: options.referenceCommit || defaultConfig.referenceCommit || null,
771
779
  repository: ciEnv?.repository || null,
772
780
  jobId: ciEnv?.jobId || null,
773
781
  runId: ciEnv?.runId || null,
774
782
  runAttempt: ciEnv?.runAttempt || null,
775
- parallel: options.parallel ?? config.get("parallel") ?? false,
776
- parallelNonce: options.parallelNonce || config.get("parallelNonce") || ciEnv?.nonce || null,
777
- parallelTotal: options.parallelTotal ?? config.get("parallelTotal") ?? null,
778
- parallelIndex: options.parallelIndex ?? config.get("parallelIndex") ?? null,
779
- mode: options.mode || config.get("mode") || null,
783
+ parallel: options.parallel ?? defaultConfig.parallel ?? false,
784
+ parallelNonce: options.parallelNonce || defaultConfig.parallelNonce || ciEnv?.nonce || null,
785
+ parallelTotal: options.parallelTotal ?? defaultConfig.parallelTotal ?? null,
786
+ parallelIndex: options.parallelIndex ?? defaultConfig.parallelIndex ?? null,
787
+ mode: options.mode || defaultConfig.mode || null,
780
788
  ciProvider: ciEnv?.key || null,
781
- previewBaseUrl: config.get("previewBaseUrl") || null
789
+ previewBaseUrl: defaultConfig.previewBaseUrl || null
782
790
  });
783
791
  config.validate();
784
792
  return config.get();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/core",
3
3
  "description": "Node.js SDK for visual testing with Argos.",
4
- "version": "4.1.2",
4
+ "version": "4.1.3",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "exports": {
@@ -64,5 +64,5 @@
64
64
  "lint": "eslint .",
65
65
  "test": "vitest"
66
66
  },
67
- "gitHead": "c705285fa19c31ef0c071bc7bf5182f7a366e2c4"
67
+ "gitHead": "9bda48090685f3215301526c7d979716d485f3ed"
68
68
  }