@xcanwin/manyoyo 5.4.12 → 5.4.14
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/bin/manyoyo.js +38 -1
- package/docker/manyoyo.Dockerfile +11 -10
- package/lib/plugin/playwright.js +26 -7
- package/package.json +1 -1
package/bin/manyoyo.js
CHANGED
|
@@ -570,6 +570,42 @@ function addEnvFile(envFile) {
|
|
|
570
570
|
return addEnvFileTo(CONTAINER_ENVS, envFile);
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
+
function expandHomeAliasPath(filePath) {
|
|
574
|
+
const text = String(filePath || '').trim();
|
|
575
|
+
const homeDir = process.env.HOME || os.homedir();
|
|
576
|
+
|
|
577
|
+
if (text === '~') {
|
|
578
|
+
return homeDir;
|
|
579
|
+
}
|
|
580
|
+
if (text.startsWith('~/')) {
|
|
581
|
+
return path.join(homeDir, text.slice(2));
|
|
582
|
+
}
|
|
583
|
+
if (text === '$HOME') {
|
|
584
|
+
return homeDir;
|
|
585
|
+
}
|
|
586
|
+
if (text.startsWith('$HOME/')) {
|
|
587
|
+
return path.join(homeDir, text.slice('$HOME/'.length));
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
return text;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function normalizeVolume(volume) {
|
|
594
|
+
const text = String(volume || '').trim();
|
|
595
|
+
if (!text.startsWith('~') && !text.startsWith('$HOME')) {
|
|
596
|
+
return text;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const separatorIndex = text.indexOf(':');
|
|
600
|
+
if (separatorIndex === -1) {
|
|
601
|
+
return expandHomeAliasPath(text);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const hostPath = text.slice(0, separatorIndex);
|
|
605
|
+
const rest = text.slice(separatorIndex);
|
|
606
|
+
return `${expandHomeAliasPath(hostPath)}${rest}`;
|
|
607
|
+
}
|
|
608
|
+
|
|
573
609
|
function hasEnvKey(targetEnvs, key) {
|
|
574
610
|
for (let i = 0; i < targetEnvs.length; i += 2) {
|
|
575
611
|
if (targetEnvs[i] !== '--env') {
|
|
@@ -1380,7 +1416,8 @@ Notes:
|
|
|
1380
1416
|
|
|
1381
1417
|
applyPlaywrightCliSessionIntegration(config, runConfig);
|
|
1382
1418
|
|
|
1383
|
-
const volumeList = mergeArrayConfig(config.volumes, runConfig.volumes, options.volume)
|
|
1419
|
+
const volumeList = mergeArrayConfig(config.volumes, runConfig.volumes, options.volume)
|
|
1420
|
+
.map(normalizeVolume);
|
|
1384
1421
|
volumeList.forEach(v => addVolume(v));
|
|
1385
1422
|
|
|
1386
1423
|
const portList = mergeArrayConfig(config.ports, runConfig.ports, options.port);
|
|
@@ -203,19 +203,20 @@ RUN <<EOX
|
|
|
203
203
|
;; esac
|
|
204
204
|
|
|
205
205
|
# 安装 Playwright CLI skills(不在镜像构建阶段下载浏览器)
|
|
206
|
-
PLAYWRIGHT_CLI_VERSION=$(node -p "const pkg = require('/tmp/manyoyo-package.json'); const value = String(pkg.playwrightCliVersion || '').trim(); if (!value) { throw new Error('package.json.playwrightCliVersion is required'); } value")
|
|
207
|
-
npm install -g "@playwright/cli@${PLAYWRIGHT_CLI_VERSION}"
|
|
208
206
|
PLAYWRIGHT_CLI_INSTALL_DIR=/tmp/playwright-cli-install
|
|
209
|
-
mkdir -p "$
|
|
207
|
+
mkdir -p "$PLAYWRIGHT_CLI_INSTALL_DIR/.playwright"
|
|
210
208
|
echo '{"browser":{"browserName":"chromium","launchOptions":{"channel":"chromium"}}}' > "${PLAYWRIGHT_CLI_INSTALL_DIR}/.playwright/cli.config.json"
|
|
211
|
-
cd "$
|
|
209
|
+
cd "$PLAYWRIGHT_CLI_INSTALL_DIR"
|
|
210
|
+
PLAYWRIGHT_CLI_VERSION=$(node -p "const pkg = require('/tmp/manyoyo-package.json'); const value = String(pkg.playwrightCliVersion || '').trim(); if (!value) { throw new Error('package.json.playwrightCliVersion is required'); } value")
|
|
211
|
+
npm install -g "@playwright/cli@${PLAYWRIGHT_CLI_VERSION}"
|
|
212
212
|
playwright-cli --config="${PLAYWRIGHT_CLI_INSTALL_DIR}/.playwright/cli.config.json" install --skills
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
213
|
+
PLAYWRIGHT_CLI_SKILL_SOURCE="$PLAYWRIGHT_CLI_INSTALL_DIR/.claude/skills/playwright-cli"
|
|
214
|
+
for target in ~/.claude/skills/playwright-cli ~/.codex/skills/playwright-cli ~/.gemini/skills/playwright-cli; do
|
|
215
|
+
mkdir -p "$target"
|
|
216
|
+
cp -R "$PLAYWRIGHT_CLI_SKILL_SOURCE/." "$target/"
|
|
217
|
+
done
|
|
218
|
+
cd "$OLDPWD"
|
|
219
|
+
rm -rf "$PLAYWRIGHT_CLI_INSTALL_DIR"
|
|
219
220
|
|
|
220
221
|
# 清理
|
|
221
222
|
npm cache clean --force
|
package/lib/plugin/playwright.js
CHANGED
|
@@ -291,6 +291,7 @@ class PlaywrightPlugin {
|
|
|
291
291
|
const homeDir = os.homedir();
|
|
292
292
|
const pluginRootDir = path.join(homeDir, '.manyoyo', 'plugin', 'playwright');
|
|
293
293
|
const defaultConfig = {
|
|
294
|
+
homeDir,
|
|
294
295
|
runtime: 'mixed',
|
|
295
296
|
enabledScenes: [...SCENE_ORDER],
|
|
296
297
|
cliSessionScene: 'cli-host-headless',
|
|
@@ -391,11 +392,16 @@ class PlaywrightPlugin {
|
|
|
391
392
|
return;
|
|
392
393
|
}
|
|
393
394
|
this.writeStdout('[tip] 如果希望容器内 manyoyo run 自动附着到当前 CLI 宿主场景,请在 ~/.manyoyo/manyoyo.json 中设置:');
|
|
395
|
+
this.writeStdout('{');
|
|
396
|
+
this.writeStdout(' "volumes": [');
|
|
397
|
+
this.writeStdout(' "~/.manyoyo/.cache/ms-playwright:/root/.cache/ms-playwright"');
|
|
398
|
+
this.writeStdout(' ],');
|
|
394
399
|
this.writeStdout(' "plugins": {');
|
|
395
400
|
this.writeStdout(' "playwright": {');
|
|
396
401
|
this.writeStdout(' "cliSessionScene": "cli-host-headed"');
|
|
397
402
|
this.writeStdout(' }');
|
|
398
403
|
this.writeStdout(' }');
|
|
404
|
+
this.writeStdout('}');
|
|
399
405
|
}
|
|
400
406
|
|
|
401
407
|
randomAlnum(length = 16) {
|
|
@@ -624,11 +630,22 @@ class PlaywrightPlugin {
|
|
|
624
630
|
}
|
|
625
631
|
|
|
626
632
|
extensionDirPath() {
|
|
627
|
-
return path.join(
|
|
633
|
+
return path.join(this.config.homeDir, '.manyoyo', 'plugin', 'playwright', 'extensions');
|
|
628
634
|
}
|
|
629
635
|
|
|
630
636
|
extensionTmpDirPath() {
|
|
631
|
-
return path.join(
|
|
637
|
+
return path.join(this.config.homeDir, '.manyoyo', 'plugin', 'playwright', 'tmp-crx');
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
cliBrowserCacheDirPath() {
|
|
641
|
+
return path.join(this.config.homeDir, '.manyoyo', '.cache', 'ms-playwright');
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
ensureCliHostHeadedCacheDir(sceneName) {
|
|
645
|
+
if (sceneName !== 'cli-host-headed') {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
fs.mkdirSync(this.cliBrowserCacheDirPath(), { recursive: true });
|
|
632
649
|
}
|
|
633
650
|
|
|
634
651
|
resolveTargets(sceneName = 'all') {
|
|
@@ -1223,6 +1240,7 @@ class PlaywrightPlugin {
|
|
|
1223
1240
|
|
|
1224
1241
|
async startHost(sceneName, options = {}) {
|
|
1225
1242
|
try {
|
|
1243
|
+
this.ensureCliHostHeadedCacheDir(sceneName);
|
|
1226
1244
|
this.ensureHostScenePrerequisites(sceneName);
|
|
1227
1245
|
} catch (error) {
|
|
1228
1246
|
this.writeStderr(`[up] ${sceneName} failed: ${error.message || String(error)}`);
|
|
@@ -1567,11 +1585,12 @@ class PlaywrightPlugin {
|
|
|
1567
1585
|
'cd "$PLAYWRIGHT_CLI_INSTALL_DIR"',
|
|
1568
1586
|
`npm install -g @playwright/cli@${PLAYWRIGHT_CLI_VERSION}`,
|
|
1569
1587
|
'playwright-cli install --skills',
|
|
1570
|
-
'
|
|
1571
|
-
'
|
|
1572
|
-
'
|
|
1573
|
-
'cp -R "$
|
|
1574
|
-
'
|
|
1588
|
+
'PLAYWRIGHT_CLI_SKILL_SOURCE="$PLAYWRIGHT_CLI_INSTALL_DIR/.claude/skills/playwright-cli"',
|
|
1589
|
+
'for target in ~/.claude/skills/playwright-cli ~/.codex/skills/playwright-cli ~/.gemini/skills/playwright-cli; do',
|
|
1590
|
+
' mkdir -p "$target"',
|
|
1591
|
+
' cp -R "$PLAYWRIGHT_CLI_SKILL_SOURCE/." "$target/"',
|
|
1592
|
+
'done',
|
|
1593
|
+
'cd "$OLDPWD"',
|
|
1575
1594
|
'rm -rf "$PLAYWRIGHT_CLI_INSTALL_DIR"'
|
|
1576
1595
|
];
|
|
1577
1596
|
this.writeStdout(lines.join('\n'));
|