@argos-ci/core 4.1.2 → 4.1.4
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/index.js +34 -21
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -749,37 +749,50 @@ var schema = {
|
|
|
749
749
|
nullable: true
|
|
750
750
|
}
|
|
751
751
|
};
|
|
752
|
-
|
|
753
|
-
return convict(schema, {
|
|
754
|
-
|
|
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 ||
|
|
762
|
-
commit: options.commit ||
|
|
763
|
-
branch: options.branch ||
|
|
764
|
-
token: options.token ||
|
|
765
|
-
buildName: options.buildName ||
|
|
766
|
-
prNumber: options.prNumber ||
|
|
767
|
-
prHeadCommit:
|
|
768
|
-
prBaseBranch:
|
|
769
|
-
referenceBranch: options.referenceBranch ||
|
|
770
|
-
referenceCommit: options.referenceCommit ||
|
|
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 ??
|
|
776
|
-
parallelNonce: options.parallelNonce ||
|
|
777
|
-
parallelTotal: options.parallelTotal ??
|
|
778
|
-
parallelIndex: options.parallelIndex ??
|
|
779
|
-
mode: options.mode ||
|
|
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:
|
|
789
|
+
previewBaseUrl: defaultConfig.previewBaseUrl || null
|
|
782
790
|
});
|
|
791
|
+
if (!config.get("branch") || !config.get("commit")) {
|
|
792
|
+
throw new Error(
|
|
793
|
+
"Argos requires a branch and a commit to be set. If you are running in a non-git environment consider setting ARGOS_BRANCH and ARGOS_COMMIT environment variables."
|
|
794
|
+
);
|
|
795
|
+
}
|
|
783
796
|
config.validate();
|
|
784
797
|
return config.get();
|
|
785
798
|
}
|
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.
|
|
4
|
+
"version": "4.1.4",
|
|
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": "
|
|
67
|
+
"gitHead": "a1f55cdee00ce144eb5b0f7ef08e451867d0c129"
|
|
68
68
|
}
|