forked from facebookarchive/WebDriverAgent
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add module version to the /status output (#878)
- Loading branch information
1 parent
8e7f17b
commit a9603f8
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const {plist} = require('@appium/support'); | ||
const path = require('node:path'); | ||
const semver = require('semver'); | ||
const log = require('fancy-log'); | ||
|
||
/** | ||
* @param {string} argName | ||
* @returns {string|null} | ||
*/ | ||
function parseArgValue (argName) { | ||
const argNamePattern = new RegExp(`^--${argName}\\b`); | ||
for (let i = 1; i < process.argv.length; ++i) { | ||
const arg = process.argv[i]; | ||
if (argNamePattern.test(arg)) { | ||
return arg.includes('=') ? arg.split('=')[1] : process.argv[i + 1]; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
async function updateWdaVersion() { | ||
const newVersion = parseArgValue('package-version'); | ||
if (!newVersion) { | ||
throw new Error('No package version argument (use `--package-version=xxx`)'); | ||
} | ||
if (!semver.valid(newVersion)) { | ||
throw new Error( | ||
`Invalid version specified '${newVersion}'. Version should be in the form '1.2.3'` | ||
); | ||
} | ||
|
||
const libManifest = path.resolve('WebDriverAgentLib', 'Info.plist'); | ||
log.info(`Updating the WebDriverAgent manifest at '${libManifest}' to version '${newVersion}'`); | ||
await plist.updatePlistFile(libManifest, { | ||
CFBundleShortVersionString: newVersion, | ||
CFBundleVersion: newVersion, | ||
}, false); | ||
} | ||
|
||
(async () => await updateWdaVersion())(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters