@applitools/core 4.24.2 → 4.25.0
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/CHANGELOG.md +7 -0
- package/dist/cli/cli.js +0 -25
- package/dist/index.js +1 -0
- package/dist/offline/merge-configs.js +42 -0
- package/dist/{run-offline-snapshots.js → offline/run-offline-snapshots.js} +17 -11
- package/package.json +4 -4
- package/types/index.d.ts +1 -0
- package/types/offline/merge-configs.d.ts +1 -0
- package/types/offline/run-offline-snapshots.d.ts +11 -0
- package/types/run-offline-snapshots.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.25.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.24.2...js/core@4.25.0) (2024-11-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* offline cli with config ([#2646](https://github.com/Applitools-Dev/sdk/issues/2646)) ([0589dc4](https://github.com/Applitools-Dev/sdk/commit/0589dc429a0c94451e957932106f258dadfd88cc))
|
|
9
|
+
|
|
3
10
|
## [4.24.2](https://github.com/Applitools-Dev/sdk/compare/js/core@4.24.1...js/core@4.24.2) (2024-11-27)
|
|
4
11
|
|
|
5
12
|
|
package/dist/cli/cli.js
CHANGED
|
@@ -32,7 +32,6 @@ const core_server_1 = require("../universal/core-server");
|
|
|
32
32
|
const core_server_process_1 = require("../universal/core-server-process");
|
|
33
33
|
const logs_1 = require("../troubleshoot/logs");
|
|
34
34
|
const check_network_1 = require("../troubleshoot/check-network");
|
|
35
|
-
const run_offline_snapshots_1 = require("../run-offline-snapshots");
|
|
36
35
|
const yargs_1 = __importDefault(require("yargs"));
|
|
37
36
|
const utils = __importStar(require("@applitools/utils"));
|
|
38
37
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -152,29 +151,5 @@ void yargs_1.default
|
|
|
152
151
|
handler: async () => {
|
|
153
152
|
await (0, check_network_1.checkNetwork)();
|
|
154
153
|
},
|
|
155
|
-
})
|
|
156
|
-
.command({
|
|
157
|
-
command: 'run-offline-snapshots',
|
|
158
|
-
builder: yargs => yargs
|
|
159
|
-
.options({
|
|
160
|
-
offlineLocationPath: {
|
|
161
|
-
description: 'path to offline snapshots folder',
|
|
162
|
-
type: 'string',
|
|
163
|
-
},
|
|
164
|
-
failOnDiff: {
|
|
165
|
-
description: 'should exit process with non-zero exit code, thereby failing the CI job',
|
|
166
|
-
type: 'boolean',
|
|
167
|
-
default: false,
|
|
168
|
-
},
|
|
169
|
-
})
|
|
170
|
-
.fail((_msg, err, _yargs) => {
|
|
171
|
-
if (err) {
|
|
172
|
-
console.error(err.message);
|
|
173
|
-
process.exit(1);
|
|
174
|
-
}
|
|
175
|
-
}),
|
|
176
|
-
handler: async (args) => {
|
|
177
|
-
await (0, run_offline_snapshots_1.runOfflineSnapshots)(args);
|
|
178
|
-
},
|
|
179
154
|
})
|
|
180
155
|
.wrap(yargs_1.default.terminalWidth()).argv;
|
package/dist/index.js
CHANGED
|
@@ -35,3 +35,4 @@ __exportStar(require("./autonomous/core"), exports);
|
|
|
35
35
|
__exportStar(require("@applitools/driver/dist/debug"), exports);
|
|
36
36
|
exports.formatters = __importStar(require("./utils/format-results"));
|
|
37
37
|
exports.logs = __importStar(require("./troubleshoot/logs"));
|
|
38
|
+
__exportStar(require("./offline/run-offline-snapshots"), exports);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.mergeConfigs = void 0;
|
|
27
|
+
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
+
function mergeConfigs(base, other) {
|
|
29
|
+
return Object.entries(other).reduce((base, [key, value]) => {
|
|
30
|
+
if (utils.types.has(base, key) &&
|
|
31
|
+
utils.types.isObject(value) &&
|
|
32
|
+
!(value instanceof String) &&
|
|
33
|
+
!utils.types.isArray(value)) {
|
|
34
|
+
base[key] = mergeConfigs(base[key], value);
|
|
35
|
+
}
|
|
36
|
+
else if (value !== undefined) {
|
|
37
|
+
base[key] = value;
|
|
38
|
+
}
|
|
39
|
+
return base;
|
|
40
|
+
}, { ...base });
|
|
41
|
+
}
|
|
42
|
+
exports.mergeConfigs = mergeConfigs;
|
|
@@ -29,19 +29,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.runOfflineSnapshots = void 0;
|
|
30
30
|
const fs_1 = __importDefault(require("fs"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const core_1 = require("
|
|
33
|
-
const get_ufg_client_1 = require("
|
|
32
|
+
const core_1 = require("../core");
|
|
33
|
+
const get_ufg_client_1 = require("../ufg/get-ufg-client");
|
|
34
34
|
const logger_1 = require("@applitools/logger");
|
|
35
|
-
const to_base_check_settings_1 = require("
|
|
35
|
+
const to_base_check_settings_1 = require("../automation/utils/to-base-check-settings");
|
|
36
36
|
const chalk_1 = __importDefault(require("chalk"));
|
|
37
37
|
const utils = __importStar(require("@applitools/utils"));
|
|
38
|
+
const merge_configs_1 = require("./merge-configs");
|
|
38
39
|
async function runOfflineSnapshots(options) {
|
|
40
|
+
var _a, _b;
|
|
39
41
|
if (!options.offlineLocationPath)
|
|
40
42
|
throw new Error('offlineLocationPath is required');
|
|
41
43
|
const startTime = Date.now();
|
|
42
|
-
const logger = (0, logger_1.makeLogger)({ format: { label: 'offline-exec' } });
|
|
44
|
+
const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : (0, logger_1.makeLogger)({ format: { label: 'offline-exec' } });
|
|
45
|
+
const eyesServerSettings = { ...(_b = options.config) === null || _b === void 0 ? void 0 : _b.open, ...options };
|
|
43
46
|
const core = (0, core_1.makeCore)();
|
|
44
|
-
const account = await core.getAccountInfo({ settings:
|
|
47
|
+
const account = await core.getAccountInfo({ settings: eyesServerSettings });
|
|
45
48
|
const ufgClient = await (0, get_ufg_client_1.makeGetUFGClient)({ logger })({
|
|
46
49
|
settings: { ...account.eyesServer, ...account.ufgServer },
|
|
47
50
|
});
|
|
@@ -66,6 +69,7 @@ async function runOfflineSnapshots(options) {
|
|
|
66
69
|
else {
|
|
67
70
|
logger.console.log(outputStr);
|
|
68
71
|
}
|
|
72
|
+
return allTestResults;
|
|
69
73
|
async function runExecution(executionName) {
|
|
70
74
|
const executionLogger = logger.extend({ tags: [executionName] });
|
|
71
75
|
const executionPath = path_1.default.resolve(options.offlineLocationPath, executionName);
|
|
@@ -75,9 +79,10 @@ async function runOfflineSnapshots(options) {
|
|
|
75
79
|
const results = await Promise.all(testFolders.map(async (testFolder) => {
|
|
76
80
|
const testLogger = logger.extend({ tags: [testFolder] });
|
|
77
81
|
const testPath = path_1.default.resolve(executionPath, testFolder);
|
|
78
|
-
const
|
|
82
|
+
const fileOpenSettings = await fs_1.default.promises
|
|
79
83
|
.readFile(path_1.default.resolve(testPath, 'settings.json'), 'utf-8')
|
|
80
|
-
.then(JSON.parse)
|
|
84
|
+
.then(JSON.parse);
|
|
85
|
+
const openSettings = (0, merge_configs_1.mergeConfigs)(fileOpenSettings, options.config.open);
|
|
81
86
|
logger.console.log(`Running test: ${openSettings.testName} (${formatEnvironment(openSettings.environment)})`);
|
|
82
87
|
return runTest(executionPath, testPath, openSettings, testLogger);
|
|
83
88
|
}));
|
|
@@ -110,9 +115,9 @@ async function runOfflineSnapshots(options) {
|
|
|
110
115
|
// logger.log('resource hashes for test', testFolder, ':', resourceHashes)
|
|
111
116
|
logger.log('uploaded resources for test', testPath);
|
|
112
117
|
await Promise.all(targets.map((target, index) => runCheck(eyes, target, index, logger)));
|
|
113
|
-
await
|
|
114
|
-
|
|
115
|
-
});
|
|
118
|
+
const fileCloseSettings = await fs_1.default.promises.readFile(path_1.default.resolve(testPath, 'close.json'), 'utf-8').then(JSON.parse);
|
|
119
|
+
const closeSettings = (0, merge_configs_1.mergeConfigs)(fileCloseSettings, options.config.close);
|
|
120
|
+
await eyes.close({ settings: closeSettings });
|
|
116
121
|
logger.log('done running test', logger);
|
|
117
122
|
return { batchId: openSettings.batch.id, results: (await eyes.getResults({ logger }))[0] };
|
|
118
123
|
}
|
|
@@ -180,9 +185,10 @@ async function runOfflineSnapshots(options) {
|
|
|
180
185
|
baseSettings.stepIndex = index;
|
|
181
186
|
baseTarget.source = target.target.source; // TODO verify
|
|
182
187
|
// baseTarget.name = snapshot.title // TODO figure out
|
|
188
|
+
const mergedCheckSettings = (0, merge_configs_1.mergeConfigs)(baseSettings, options.config.check);
|
|
183
189
|
await eyes.check({
|
|
184
190
|
target: { ...baseTarget, isTransformed: true },
|
|
185
|
-
settings:
|
|
191
|
+
settings: mergedCheckSettings,
|
|
186
192
|
logger: checkLogger,
|
|
187
193
|
});
|
|
188
194
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.25.0",
|
|
4
4
|
"homepage": "https://applitools.com",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"bin": {
|
|
31
|
-
"eyes": "./dist/
|
|
32
|
-
"eyes-
|
|
31
|
+
"eyes-check-network": "./dist/troubleshoot/check-network.js",
|
|
32
|
+
"eyes-core": "./dist/cli/cli.js"
|
|
33
33
|
},
|
|
34
34
|
"main": "./dist/index.js",
|
|
35
35
|
"types": "./types/index.d.ts",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"setup": "run --top-level browsers:setup"
|
|
59
59
|
},
|
|
60
60
|
"sea": {
|
|
61
|
-
"bin": "eyes",
|
|
61
|
+
"bin": "eyes-core",
|
|
62
62
|
"certs": {
|
|
63
63
|
"win": {
|
|
64
64
|
"cert": "env.CODE_SIGNING_CERT_WIN",
|
package/types/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { type SpecType, type SpecDriver, type Selector } from '@applitools/drive
|
|
|
7
7
|
export * from '@applitools/driver/dist/debug';
|
|
8
8
|
export * as formatters from './utils/format-results';
|
|
9
9
|
export * as logs from './troubleshoot/logs';
|
|
10
|
+
export * from './offline/run-offline-snapshots';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeConfigs<TBase extends Record<string, any>>(base: TBase, other: Record<string, any>): TBase;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Config, type EyesServerSettings } from '../types';
|
|
2
|
+
import { type Logger } from '@applitools/logger';
|
|
3
|
+
import type { TestResult } from '@applitools/core-base';
|
|
4
|
+
import type { SpecType } from '@applitools/driver';
|
|
5
|
+
export type OfflineSnapshotsSettings = EyesServerSettings & {
|
|
6
|
+
offlineLocationPath: string;
|
|
7
|
+
failOnDiff: boolean;
|
|
8
|
+
config: Config<SpecType, 'ufg'>;
|
|
9
|
+
logger?: Logger;
|
|
10
|
+
};
|
|
11
|
+
export declare function runOfflineSnapshots(options: OfflineSnapshotsSettings): Promise<TestResult[]>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type EyesServerSettings } from './types';
|
|
2
|
-
export type OfflineSnapshotsSettings = EyesServerSettings & {
|
|
3
|
-
offlineLocationPath: string;
|
|
4
|
-
failOnDiff: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare function runOfflineSnapshots(options: OfflineSnapshotsSettings): Promise<void>;
|