Skip to content

Commit c98e22f

Browse files
committed
fix
1 parent ebedcb6 commit c98e22f

File tree

7 files changed

+52
-49
lines changed

7 files changed

+52
-49
lines changed

.changeset/spotty-bananas-glow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
\- No more distinction between multiremote and single remote during the addCommand step
66

7-
\- Distinction between multiremote and single remote inside the commande function (loop for each instance or directly call the function)
7+
\- Inside browser command, the OCR functions are called directly with secured context instead of calling the browser function itself (to avoir loop from issue 657)
88

9-
- Inside browser command, call OCR functions directly with secured context instead of the browser function (to avoir loop from issue 657)
9+
\- Inside browser command, the OCR functions are called only for the concerned instance instead of all existing instances from the capabilities (similar than the issue 983)

packages/ocr-service/src/commands/ocrClickOnText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ export default async function ocrClickOnText(this: WebdriverIO.Browser, options:
3030
.pause(clickDuration as number)
3131
.up({ button: 0 })
3232
.perform()
33-
}
33+
}

packages/ocr-service/src/commands/ocrGetElementPositionByText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ export default async function ocrGetElementPositionByText(
6363
score,
6464
searchValue: text,
6565
}
66-
}
66+
}

packages/ocr-service/src/commands/ocrGetText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export default async function ocrGetText(this: WebdriverIO.Browser, options: Ocr
55
const { text } = await getData(this, options)
66

77
return text.replace(/\n\s*\n/g, '\n')
8-
}
8+
}

packages/ocr-service/src/commands/ocrSetValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ export default async function ocrSetValue(this: WebdriverIO.Browser, options: Oc
5353
// Keyboard is not present or not hidden
5454
}
5555
}
56-
}
56+
}

packages/ocr-service/src/commands/ocrWaitForTextDisplayed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export default async function ocrWaitForTextDisplayed(
1414
timeoutMsg: timeoutMsg || `Could not find the text "${options.text}" within the requested time.`,
1515
}
1616
)
17-
}
17+
}

scripts/update.packages.mjs

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,61 @@
11
#!/usr/bin/env node
2-
import { confirm, select } from '@inquirer/prompts'
3-
import { execSync } from 'node:child_process'
4-
import { readdirSync, lstatSync } from 'node:fs'
5-
import { join } from 'node:path'
6-
import { rimraf } from 'rimraf'
7-
8-
const currentPath = process.cwd()
9-
const packagesDir = join(currentPath, 'packages')
2+
import { confirm, select } from '@inquirer/prompts';
3+
import { execSync } from 'node:child_process';
4+
import { readdirSync, lstatSync } from 'node:fs';
5+
import { join } from 'node:path';
6+
import {rimraf} from 'rimraf';
7+
8+
const currentPath = process.cwd();
9+
const packagesDir = join(currentPath, 'packages');
1010
const header = `
1111
==========================
1212
🤖 Package update Wizard 🧙
1313
==========================
1414
`
1515

1616
async function updatePackages(dir, target, updateFiles) {
17-
console.log(`${updateFiles ? 'Updating' : 'Checking' } packages for ${target} updates in ${dir}...`)
18-
const command = `npx npm-check-updates ${updateFiles ? '-u' : ''} --target ${target}`
19-
execSync(command, { stdio: 'inherit', cwd: dir })
17+
console.log(`${updateFiles ? 'Updating' : 'Checking' } packages for ${target} updates in ${dir}...`);
18+
const command = `npx npm-check-updates ${updateFiles ? '-u' : ''} --target ${target}`;
19+
execSync(command, { stdio: 'inherit', cwd: dir });
2020
}
2121

2222
function removeDependencies(dir) {
23-
console.log(`Removing root dependencies in ${dir}...`)
24-
const rootNodeModulesPath = join(dir, 'node_modules')
25-
rimraf.sync(rootNodeModulesPath)
23+
console.log(`Removing root dependencies in ${dir}...`);
24+
const rootNodeModulesPath = join(dir, 'node_modules');
25+
rimraf.sync(rootNodeModulesPath);
2626

27-
const packagesDir = join(dir, 'packages')
27+
const packagesDir = join(dir, 'packages');
2828

2929
readdirSync(packagesDir).forEach(packageDir => {
30-
const fullPath = join(packagesDir, packageDir)
30+
const fullPath = join(packagesDir, packageDir);
3131

3232
if (lstatSync(fullPath).isDirectory()) {
33-
console.log(`Removing dependencies in ${packageDir}...`)
34-
const nodeModulesPath = join(fullPath, 'node_modules')
35-
rimraf.sync(nodeModulesPath)
33+
console.log(`Removing dependencies in ${packageDir}...`);
34+
const nodeModulesPath = join(fullPath, 'node_modules');
35+
rimraf.sync(nodeModulesPath);
3636
}
37-
})
37+
});
3838
}
3939

40+
41+
4042
function installDependencies(dir) {
41-
console.log(`Installing dependencies in ${dir}...`)
42-
execSync('pnpm pnpm.install.workaround', { stdio: 'inherit', cwd: dir })
43+
console.log(`Installing dependencies in ${dir}...`);
44+
execSync('pnpm pnpm.install.workaround', { stdio: 'inherit', cwd: dir });
4345
}
4446

47+
4548
function isPnpmInstalled() {
4649
try {
47-
execSync('pnpm --version', { stdio: 'ignore' })
48-
return true
50+
execSync('pnpm --version', { stdio: 'ignore' });
51+
return true;
4952
} catch {
50-
return false
53+
return false;
5154
}
5255
}
5356

5457
async function main() {
55-
console.log(header)
58+
console.log(header);
5659

5760
const target = await select({
5861
message: 'Which version target would you like to update to?',
@@ -61,50 +64,50 @@ async function main() {
6164
{ name: 'Latest', value: 'latest' }
6265
],
6366
default: 'minor'
64-
})
67+
});
6568

6669
const updateFiles = await confirm({
6770
message: 'Do you want to update the package.json files?',
6871
default: true
69-
})
72+
});
7073

71-
console.log(`${updateFiles ? 'Updating' : 'Checking' } root 'package.json' for ${target} updates...`)
72-
await updatePackages(currentPath, target, updateFiles)
74+
console.log(`${updateFiles ? 'Updating' : 'Checking' } root 'package.json' for ${target} updates...`);
75+
await updatePackages(currentPath, target, updateFiles);
7376

7477
readdirSync(packagesDir).forEach(async (packageDir) => {
75-
const fullPath = join(packagesDir, packageDir)
78+
const fullPath = join(packagesDir, packageDir);
7679
if (lstatSync(fullPath).isDirectory()) {
77-
await updatePackages(fullPath, target, updateFiles)
80+
await updatePackages(fullPath, target, updateFiles);
7881
}
79-
})
82+
});
8083

8184
if (updateFiles) {
8285
const removeNodeModules = await confirm({
8386
message: 'Do you want to remove all "node_modules" and reinstall dependencies?',
8487
default: true
85-
})
88+
});
8689

8790
if (removeNodeModules) {
88-
removeDependencies(currentPath)
91+
removeDependencies(currentPath);
8992
const usePnpm = await confirm({
9093
message: 'Would you like reinstall the dependencies?',
9194
default: true
92-
})
95+
});
9396

9497
if (usePnpm) {
9598
if (isPnpmInstalled()) {
96-
installDependencies(currentPath)
99+
installDependencies(currentPath);
97100
} else {
98-
console.error('pnpm is not installed. Please install pnpm and try again.')
101+
console.error('pnpm is not installed. Please install pnpm and try again.');
99102
}
100103
}
101104
}
102105
}
103106

104-
console.log(`All packages ${updateFiles ? 'updated': 'checked'}!`)
107+
console.log(`All packages ${updateFiles ? 'updated': 'checked'}!`);
105108
}
106109

107110
main().catch((error) => {
108-
console.error('An unexpected error occurred:', error)
109-
process.exit(1)
110-
})
111+
console.error('An unexpected error occurred:', error);
112+
process.exit(1);
113+
});

0 commit comments

Comments
 (0)