@midscene/cli 1.10.4-beta-20260710100314.0 → 1.10.4-beta-20260710115744.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/dist/es/framework/index.mjs +11 -23
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +26 -26
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +10 -22
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +25 -25
- package/dist/lib/index.js.map +1 -1
- package/dist/types/framework/index.d.ts +4 -0
- package/package.json +8 -8
package/dist/es/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import node_stream from "node:stream";
|
|
|
10
10
|
import { StringDecoder } from "node:string_decoder";
|
|
11
11
|
import { fileURLToPath as external_url_fileURLToPath } from "url";
|
|
12
12
|
import node_process, { cwd as external_node_process_cwd } from "node:process";
|
|
13
|
-
import { ScriptPlayer, interpolateEnvVars, parseYamlScript as yaml_parseYamlScript } from "@midscene/core/yaml";
|
|
13
|
+
import { ScriptPlayer, interpolateEnvVars, parseYamlScript as yaml_parseYamlScript, resolveWebTarget } from "@midscene/core/yaml";
|
|
14
14
|
import lodash_merge from "lodash.merge";
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
import { getMidsceneRunSubDir } from "@midscene/shared/common";
|
|
@@ -3025,7 +3025,7 @@ var __webpack_modules__ = {
|
|
|
3025
3025
|
module.exports = (string, columns, options)=>String(string).normalize().replace(/\r\n/g, '\n').split('\n').map((line)=>exec(line, columns, options)).join('\n');
|
|
3026
3026
|
},
|
|
3027
3027
|
"./src/index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
3028
|
-
var package_namespaceObject = JSON.parse('{"rE":"1.10.4-beta-
|
|
3028
|
+
var package_namespaceObject = JSON.parse('{"rE":"1.10.4-beta-20260710115744.0"}');
|
|
3029
3029
|
var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
|
|
3030
3030
|
const MAX_PATTERN_LENGTH = 65536;
|
|
3031
3031
|
const assertValidPattern = (pattern)=>{
|
|
@@ -10723,6 +10723,7 @@ var __webpack_modules__ = {
|
|
|
10723
10723
|
throw new Error(`Failed to parse config YAML: ${error}`);
|
|
10724
10724
|
}
|
|
10725
10725
|
if (!configYaml?.files || !Array.isArray(configYaml?.files)) throw new Error('Config YAML must contain a "files" array');
|
|
10726
|
+
resolveWebTarget(configYaml);
|
|
10726
10727
|
const files = await expandFilePatterns(configYaml?.files, basePath);
|
|
10727
10728
|
if (0 === files.length) throw new Error('No YAML files found matching the patterns in "files"');
|
|
10728
10729
|
const setup = await resolveSetupFile(configYaml.setup, basePath);
|
|
@@ -10735,7 +10736,10 @@ var __webpack_modules__ = {
|
|
|
10735
10736
|
retry: configYaml.retry ?? config_factory_defaultConfig.retry,
|
|
10736
10737
|
summary: configYaml.summary ?? defaultSummary,
|
|
10737
10738
|
shareBrowserContext: configYaml.shareBrowserContext ?? config_factory_defaultConfig.shareBrowserContext,
|
|
10739
|
+
page: configYaml.page,
|
|
10740
|
+
browser: configYaml.browser,
|
|
10738
10741
|
web: configYaml.web,
|
|
10742
|
+
target: configYaml.target,
|
|
10739
10743
|
android: configYaml.android,
|
|
10740
10744
|
ios: configYaml.ios,
|
|
10741
10745
|
patterns: configYaml.files,
|
|
@@ -10751,14 +10755,19 @@ var __webpack_modules__ = {
|
|
|
10751
10755
|
async function createConfig(configYamlPath, options) {
|
|
10752
10756
|
const parsedConfig = await parseConfigYaml(configYamlPath);
|
|
10753
10757
|
const globalConfig = lodash_merge({
|
|
10758
|
+
page: parsedConfig.page,
|
|
10759
|
+
browser: parsedConfig.browser,
|
|
10754
10760
|
web: parsedConfig.web,
|
|
10755
10761
|
android: parsedConfig.android,
|
|
10756
10762
|
ios: parsedConfig.ios,
|
|
10757
10763
|
target: parsedConfig.target
|
|
10758
10764
|
}, {
|
|
10765
|
+
page: options?.page,
|
|
10766
|
+
browser: options?.browser,
|
|
10759
10767
|
web: options?.web,
|
|
10760
10768
|
android: options?.android,
|
|
10761
|
-
ios: options?.ios
|
|
10769
|
+
ios: options?.ios,
|
|
10770
|
+
target: options?.target
|
|
10762
10771
|
});
|
|
10763
10772
|
const keepWindow = options?.keepWindow ?? parsedConfig.keepWindow;
|
|
10764
10773
|
const headed = options?.headed ?? parsedConfig.headed;
|
|
@@ -10813,7 +10822,10 @@ var __webpack_modules__ = {
|
|
|
10813
10822
|
dotenvOverride: options.dotenvOverride ?? config_factory_defaultConfig.dotenvOverride,
|
|
10814
10823
|
dotenvDebug: options.dotenvDebug ?? config_factory_defaultConfig.dotenvDebug,
|
|
10815
10824
|
globalConfig: {
|
|
10825
|
+
page: options.page,
|
|
10826
|
+
browser: options.browser,
|
|
10816
10827
|
web: options.web,
|
|
10828
|
+
target: options.target,
|
|
10817
10829
|
android: options.android,
|
|
10818
10830
|
ios: options.ios
|
|
10819
10831
|
}
|
|
@@ -10886,7 +10898,7 @@ Usage:
|
|
|
10886
10898
|
type: 'boolean',
|
|
10887
10899
|
description: `Turn on logging to help debug why certain keys or values are not being set as you expect, default is ${config_factory_defaultConfig.dotenvDebug}`
|
|
10888
10900
|
}
|
|
10889
|
-
}).version('version', 'Show version number', "1.10.4-beta-
|
|
10901
|
+
}).version('version', 'Show version number', "1.10.4-beta-20260710115744.0").help().epilogue(`For complete list of configuration options, please visit:
|
|
10890
10902
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
10891
10903
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
10892
10904
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|
|
@@ -11331,9 +11343,10 @@ Examples:
|
|
|
11331
11343
|
};
|
|
11332
11344
|
const player = new ScriptPlayer(clonedYamlScript, async ()=>{
|
|
11333
11345
|
const freeFn = [];
|
|
11334
|
-
const
|
|
11346
|
+
const resolvedWebTarget = resolveWebTarget(clonedYamlScript);
|
|
11347
|
+
const webTarget = resolvedWebTarget?.target;
|
|
11335
11348
|
const targetCount = [
|
|
11336
|
-
void 0 !==
|
|
11349
|
+
void 0 !== resolvedWebTarget,
|
|
11337
11350
|
void 0 !== clonedYamlScript.android,
|
|
11338
11351
|
void 0 !== clonedYamlScript.ios,
|
|
11339
11352
|
void 0 !== clonedYamlScript.harmony,
|
|
@@ -11342,17 +11355,17 @@ Examples:
|
|
|
11342
11355
|
].filter(Boolean).length;
|
|
11343
11356
|
if (targetCount > 1) {
|
|
11344
11357
|
const specifiedTargets = [
|
|
11345
|
-
|
|
11358
|
+
resolvedWebTarget?.source ?? null,
|
|
11346
11359
|
void 0 !== clonedYamlScript.android ? 'android' : null,
|
|
11347
11360
|
void 0 !== clonedYamlScript.ios ? 'ios' : null,
|
|
11348
11361
|
void 0 !== clonedYamlScript.harmony ? 'harmony' : null,
|
|
11349
11362
|
void 0 !== clonedYamlScript.computer ? 'computer' : null,
|
|
11350
11363
|
void 0 !== clonedYamlScript.interface ? 'interface' : null
|
|
11351
11364
|
].filter(Boolean);
|
|
11352
|
-
throw new Error(`Only one target type can be specified, but found multiple: ${specifiedTargets.join(', ')}. Please specify only one of: web, android, ios, harmony, computer, or interface.`);
|
|
11365
|
+
throw new Error(`Only one target type can be specified, but found multiple: ${specifiedTargets.join(', ')}. Please specify only one of: page, browser, web, android, ios, harmony, computer, or interface.`);
|
|
11353
11366
|
}
|
|
11354
11367
|
if (void 0 !== webTarget) {
|
|
11355
|
-
if (
|
|
11368
|
+
if (resolvedWebTarget?.source === 'target') console.warn("target is deprecated, please use page or browser instead. See https://midscenejs.com/automate-with-scripts-in-yaml for more information. Sorry for the inconvenience.");
|
|
11356
11369
|
let localServer;
|
|
11357
11370
|
let urlToVisit;
|
|
11358
11371
|
if (webTarget.serve) {
|
|
@@ -11367,6 +11380,7 @@ Examples:
|
|
|
11367
11380
|
webTarget.url = urlToVisit;
|
|
11368
11381
|
}
|
|
11369
11382
|
if (webTarget.cdpEndpoint && webTarget.bridgeMode) throw new Error('cdpEndpoint and bridgeMode are mutually exclusive. Please specify only one.');
|
|
11383
|
+
if ('browser' === webTarget.mode && webTarget.bridgeMode) throw new Error('[midscene] browser mode does not support bridgeMode. Use page: or web.mode: page for bridge mode.');
|
|
11370
11384
|
if (webTarget.cdpEndpoint) {
|
|
11371
11385
|
const cdpBrowser = options?.browser ?? await puppeteer.connect({
|
|
11372
11386
|
browserWSEndpoint: webTarget.cdpEndpoint,
|
|
@@ -12009,9 +12023,9 @@ Examples:
|
|
|
12009
12023
|
setupContext,
|
|
12010
12024
|
...fileContextList
|
|
12011
12025
|
] : fileContextList;
|
|
12012
|
-
const needsBrowser = allContexts.some((ctx)=>
|
|
12026
|
+
const needsBrowser = allContexts.some((ctx)=>void 0 !== resolveWebTarget(ctx.executionConfig));
|
|
12013
12027
|
if (needsBrowser && this.config.shareBrowserContext) {
|
|
12014
|
-
const globalWebConfig = this.config.globalConfig?.
|
|
12028
|
+
const globalWebConfig = resolveWebTarget(this.config.globalConfig ?? {})?.target;
|
|
12015
12029
|
if (globalWebConfig?.cdpEndpoint) browser = await puppeteer.connect({
|
|
12016
12030
|
browserWSEndpoint: globalWebConfig.cdpEndpoint,
|
|
12017
12031
|
defaultViewport: null,
|
|
@@ -12049,7 +12063,7 @@ Examples:
|
|
|
12049
12063
|
this.results = await this.processResults(executedResults, notExecutedContexts);
|
|
12050
12064
|
} finally{
|
|
12051
12065
|
if (browser && !this.config.keepWindow) {
|
|
12052
|
-
const isCdp = !!this.config.globalConfig?.
|
|
12066
|
+
const isCdp = !!resolveWebTarget(this.config.globalConfig ?? {})?.target.cdpEndpoint;
|
|
12053
12067
|
if (isCdp) browser.disconnect();
|
|
12054
12068
|
else await browser.close();
|
|
12055
12069
|
}
|
|
@@ -12060,20 +12074,6 @@ Examples:
|
|
|
12060
12074
|
async createFileContext(file, fileConfig, options) {
|
|
12061
12075
|
const { globalConfig } = this.config;
|
|
12062
12076
|
const clonedFileConfig = JSON.parse(JSON.stringify(fileConfig));
|
|
12063
|
-
if (clonedFileConfig.target) {
|
|
12064
|
-
clonedFileConfig.web = {
|
|
12065
|
-
...clonedFileConfig.target,
|
|
12066
|
-
...clonedFileConfig.web
|
|
12067
|
-
};
|
|
12068
|
-
delete clonedFileConfig.target;
|
|
12069
|
-
}
|
|
12070
|
-
if (globalConfig?.target) {
|
|
12071
|
-
globalConfig.web = {
|
|
12072
|
-
...globalConfig.target,
|
|
12073
|
-
...globalConfig.web
|
|
12074
|
-
};
|
|
12075
|
-
delete globalConfig.target;
|
|
12076
|
-
}
|
|
12077
12077
|
const executionConfig = lodash_merge(clonedFileConfig, globalConfig);
|
|
12078
12078
|
return {
|
|
12079
12079
|
file,
|