@midscene/cli 0.28.1-beta-20250909042036.0 → 0.28.1
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/index.mjs +51 -8
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/index.js +51 -7
- package/dist/lib/index.js.map +1 -1
- package/package.json +5 -5
package/dist/es/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! For license information please see index.mjs.LICENSE.txt */
|
|
2
|
-
import { basename, dirname, extname, join, posix, relative as external_node_path_relative, resolve as external_node_path_resolve, win32 } from "node:path";
|
|
2
|
+
import node_path, { basename, dirname, extname, join, posix, relative as external_node_path_relative, resolve as external_node_path_resolve, win32 } from "node:path";
|
|
3
3
|
import { ScriptPlayer, interpolateEnvVars, parseYamlScript } from "@midscene/core/yaml";
|
|
4
4
|
import { getMidsceneRunSubDir } from "@midscene/shared/common";
|
|
5
5
|
import lodash_merge from "lodash.merge";
|
|
@@ -7,11 +7,12 @@ import puppeteer from "puppeteer";
|
|
|
7
7
|
import { createServer } from "http-server";
|
|
8
8
|
import node_assert from "node:assert";
|
|
9
9
|
import { agentFromAdbDevice } from "@midscene/android";
|
|
10
|
+
import { createAgent } from "@midscene/core/agent";
|
|
11
|
+
import { getDebug } from "@midscene/shared/logger";
|
|
10
12
|
import { AgentOverChromeBridge } from "@midscene/web/bridge-mode";
|
|
11
13
|
import { puppeteerAgentForTarget } from "@midscene/web/puppeteer-agent-launcher";
|
|
12
14
|
import { stripVTControlCharacters } from "node:util";
|
|
13
15
|
import node_process, { cwd as external_node_process_cwd } from "node:process";
|
|
14
|
-
import { getDebug } from "@midscene/shared/logger";
|
|
15
16
|
import { fileURLToPath } from "node:url";
|
|
16
17
|
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
17
18
|
import { EventEmitter } from "node:events";
|
|
@@ -3021,7 +3022,9 @@ var __webpack_modules__ = {
|
|
|
3021
3022
|
"./src/index.ts": function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
|
|
3022
3023
|
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
3023
3024
|
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
3024
|
-
var package_namespaceObject =
|
|
3025
|
+
var package_namespaceObject = {
|
|
3026
|
+
i8: "0.28.1"
|
|
3027
|
+
};
|
|
3025
3028
|
class Node {
|
|
3026
3029
|
value;
|
|
3027
3030
|
next;
|
|
@@ -3139,6 +3142,7 @@ var __webpack_modules__ = {
|
|
|
3139
3142
|
function validateConcurrency(concurrency) {
|
|
3140
3143
|
if (!((Number.isInteger(concurrency) || concurrency === 1 / 0) && concurrency > 0)) throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
3141
3144
|
}
|
|
3145
|
+
const debug = getDebug('create-yaml-player');
|
|
3142
3146
|
const launchServer = async (dir)=>new Promise((resolve)=>{
|
|
3143
3147
|
const server = createServer({
|
|
3144
3148
|
root: dir
|
|
@@ -3159,6 +3163,19 @@ var __webpack_modules__ = {
|
|
|
3159
3163
|
const player = new ScriptPlayer(yamlScript, async ()=>{
|
|
3160
3164
|
const freeFn = [];
|
|
3161
3165
|
const webTarget = yamlScript.web || yamlScript.target;
|
|
3166
|
+
const targetCount = [
|
|
3167
|
+
void 0 !== webTarget,
|
|
3168
|
+
void 0 !== yamlScript.android,
|
|
3169
|
+
void 0 !== yamlScript.interface
|
|
3170
|
+
].filter(Boolean).length;
|
|
3171
|
+
if (targetCount > 1) {
|
|
3172
|
+
const specifiedTargets = [
|
|
3173
|
+
void 0 !== webTarget ? 'web' : null,
|
|
3174
|
+
void 0 !== yamlScript.android ? 'android' : null,
|
|
3175
|
+
void 0 !== yamlScript.interface ? 'interface' : null
|
|
3176
|
+
].filter(Boolean);
|
|
3177
|
+
throw new Error(`Only one target type can be specified, but found multiple: ${specifiedTargets.join(', ')}. Please specify only one of: web, android, or interface.`);
|
|
3178
|
+
}
|
|
3162
3179
|
if (void 0 !== webTarget) {
|
|
3163
3180
|
if (void 0 !== yamlScript.target) console.warn("target is deprecated, please use web instead. See https://midscenejs.com/automate-with-scripts-in-yaml for more information. Sorry for the inconvenience.");
|
|
3164
3181
|
let localServer;
|
|
@@ -3215,7 +3232,33 @@ var __webpack_modules__ = {
|
|
|
3215
3232
|
freeFn
|
|
3216
3233
|
};
|
|
3217
3234
|
}
|
|
3218
|
-
|
|
3235
|
+
if (void 0 !== yamlScript.interface) {
|
|
3236
|
+
const interfaceTarget = yamlScript.interface;
|
|
3237
|
+
const moduleSpecifier = interfaceTarget.module;
|
|
3238
|
+
let finalModuleSpecifier;
|
|
3239
|
+
if (moduleSpecifier.startsWith('./') || moduleSpecifier.startsWith('../') || node_path.isAbsolute(moduleSpecifier)) {
|
|
3240
|
+
const resolvedPath = join(process.cwd(), moduleSpecifier);
|
|
3241
|
+
finalModuleSpecifier = resolvedPath;
|
|
3242
|
+
} else finalModuleSpecifier = moduleSpecifier;
|
|
3243
|
+
debug('importing module config', interfaceTarget.module, 'with export config', interfaceTarget.export, 'final module specifier', finalModuleSpecifier);
|
|
3244
|
+
const importedModule = await import(finalModuleSpecifier);
|
|
3245
|
+
const DeviceClass = interfaceTarget.export ? importedModule[interfaceTarget.export] : importedModule.default || importedModule;
|
|
3246
|
+
debug('DeviceClass', DeviceClass, 'with param', interfaceTarget.param);
|
|
3247
|
+
const device = new DeviceClass(interfaceTarget.param || {});
|
|
3248
|
+
debug('creating agent from device', device);
|
|
3249
|
+
const agent = createAgent(device, yamlScript.agent || {});
|
|
3250
|
+
freeFn.push({
|
|
3251
|
+
name: 'destroy_general_interface_agent',
|
|
3252
|
+
fn: ()=>{
|
|
3253
|
+
agent.destroy();
|
|
3254
|
+
}
|
|
3255
|
+
});
|
|
3256
|
+
return {
|
|
3257
|
+
agent,
|
|
3258
|
+
freeFn
|
|
3259
|
+
};
|
|
3260
|
+
}
|
|
3261
|
+
throw new Error('No valid interface configuration found in the yaml script, should be either "web", "android", or "interface"');
|
|
3219
3262
|
}, void 0, file);
|
|
3220
3263
|
return player;
|
|
3221
3264
|
}
|
|
@@ -3843,7 +3886,7 @@ var __webpack_modules__ = {
|
|
|
3843
3886
|
}
|
|
3844
3887
|
async loadFileConfig(file) {
|
|
3845
3888
|
const content = (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.readFileSync)(file, 'utf8');
|
|
3846
|
-
return parseYamlScript(content, file
|
|
3889
|
+
return parseYamlScript(content, file);
|
|
3847
3890
|
}
|
|
3848
3891
|
getSummaryAbsolutePath() {
|
|
3849
3892
|
return external_node_path_resolve(getMidsceneRunSubDir('output'), this.config.summary);
|
|
@@ -11714,7 +11757,7 @@ var __webpack_modules__ = {
|
|
|
11714
11757
|
}
|
|
11715
11758
|
};
|
|
11716
11759
|
}
|
|
11717
|
-
const
|
|
11760
|
+
const cli_utils_debug = getDebug('midscene:cli');
|
|
11718
11761
|
const parseProcessArgs = async ()=>{
|
|
11719
11762
|
const args = yargs(hideBin(process.argv)).usage(`Midscene.js helps you automate browser actions, assertions, and data extraction by AI.
|
|
11720
11763
|
Homepage: https://midscenejs.com
|
|
@@ -11785,9 +11828,9 @@ Usage:
|
|
|
11785
11828
|
type: 'string',
|
|
11786
11829
|
description: 'Override device ID for Android environments.'
|
|
11787
11830
|
}
|
|
11788
|
-
}).version('version', 'Show version number', "0.28.1
|
|
11831
|
+
}).version('version', 'Show version number', "0.28.1").help().wrap(yargs().terminalWidth());
|
|
11789
11832
|
const argv = await args.argv;
|
|
11790
|
-
|
|
11833
|
+
cli_utils_debug('argv', argv);
|
|
11791
11834
|
return {
|
|
11792
11835
|
path: argv._[0],
|
|
11793
11836
|
files: argv.files,
|