appium-webdriveragent 4.10.17 → 4.10.18

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [4.10.18](https://github.com/appium/WebDriverAgent/compare/v4.10.17...v4.10.18) (2022-12-30)
2
+
3
+
4
+ ### Miscellaneous Chores
5
+
6
+ * simplify Script/build-webdriveragent.js ([#647](https://github.com/appium/WebDriverAgent/issues/647)) ([81dab6c](https://github.com/appium/WebDriverAgent/commit/81dab6ca0645f9925a8515abfb4851d6e85da7e9))
7
+
1
8
  ## [4.10.17](https://github.com/appium/WebDriverAgent/compare/v4.10.16...v4.10.17) (2022-12-30)
2
9
 
3
10
 
@@ -1,88 +1,53 @@
1
1
  const path = require('path');
2
- const os = require('os');
3
2
  const { asyncify } = require('asyncbox');
4
- const { logger, fs, mkdirp, zip } = require('@appium/support');
3
+ const { logger, fs } = require('@appium/support');
5
4
  const { exec } = require('teen_process');
6
5
  const xcode = require('appium-xcode');
7
6
 
8
- const log = new logger.getLogger('WDABuild');
9
- const rootDir = path.resolve(__dirname, '..');
7
+ const LOG = new logger.getLogger('WDABuild');
8
+ const ROOT_DIR = path.resolve(__dirname, '..');
9
+ const DERIVED_DATA_PATH = `${ROOT_DIR}/wdaBuild`;
10
+ const WDA_BUNDLE = 'WebDriverAgentRunner-Runner.app';
11
+ const WDA_BUNDLE_PATH = path.join(DERIVED_DATA_PATH, 'Build', 'Products', 'Debug-iphonesimulator');
10
12
 
11
13
  async function buildWebDriverAgent (xcodeVersion) {
14
+ LOG.info(`Cleaning ${DERIVED_DATA_PATH} if exists`);
15
+ try {
16
+ await exec('xcodebuild', ['clean', '-derivedDataPath', DERIVED_DATA_PATH, '-scheme', 'WebDriverAgentRunner'], {
17
+ cwd: ROOT_DIR
18
+ });
19
+ } catch (ign) {}
20
+
12
21
  // Get Xcode version
13
22
  xcodeVersion = xcodeVersion || await xcode.getVersion();
14
- log.info(`Building bundle for Xcode version '${xcodeVersion}'`);
15
-
16
- // Clear WebDriverAgent from derived data
17
- const derivedDataPath = path.resolve(os.homedir(), 'Library', 'Developer',
18
- 'Xcode', 'DerivedData');
19
- log.info(`Clearing contents of '${derivedDataPath}/WebDriverAgent-*'`);
20
- for (const wdaPath of
21
- await fs.glob('WebDriverAgent-*', {cwd: derivedDataPath, absolute: true})
22
- ) {
23
- log.info(`Deleting existing WDA: '${wdaPath}'`);
24
- await fs.rimraf(wdaPath);
25
- }
23
+ LOG.info(`Building WebDriverAgent for iOS using Xcode version '${xcodeVersion}'`);
26
24
 
27
25
  // Clean and build
28
- log.info('Running ./Scripts/build.sh');
29
- let env = {TARGET: 'runner', SDK: 'sim'};
30
26
  try {
31
- await exec('/bin/bash', ['./Scripts/build.sh'], {env, cwd: rootDir});
27
+ await exec('/bin/bash', ['./Scripts/build.sh'], {
28
+ env: {TARGET: 'runner', SDK: 'sim', DERIVED_DATA_PATH},
29
+ cwd: ROOT_DIR
30
+ });
32
31
  } catch (e) {
33
- log.error(`===FAILED TO BUILD FOR ${xcodeVersion}`);
34
- log.error(e.stdout);
35
- log.error(e.stderr);
36
- log.error(e.message);
32
+ LOG.error(`===FAILED TO BUILD FOR ${xcodeVersion}`);
33
+ LOG.error(e.stderr);
37
34
  throw e;
38
35
  }
39
36
 
40
- // Create bundles folder
41
- const pathToBundles = path.resolve(rootDir, 'bundles');
42
- await mkdirp(pathToBundles);
43
-
44
- // Start creating zip
45
- const uncompressedDir = path.resolve(rootDir, 'uncompressed');
46
- await fs.rimraf(uncompressedDir);
47
- await mkdirp(uncompressedDir);
48
- log.info('Creating zip');
49
-
50
- // Move contents of the root to folder called "uncompressed"
51
- await exec('rsync', [
52
- '-av', '.', uncompressedDir,
53
- '--exclude', 'node_modules',
54
- '--exclude', 'build',
55
- '--exclude', 'ci-jobs',
56
- '--exclude', 'lib',
57
- '--exclude', 'test',
58
- '--exclude', 'bundles',
59
- '--exclude', 'azure-templates',
60
- ], {cwd: rootDir});
61
-
62
- // Move DerivedData/WebDriverAgent-* from Library to "uncompressed" folder
63
- const wdaPath = (await fs.glob(`${derivedDataPath}/WebDriverAgent-*`))[0];
64
- await mkdirp(path.resolve(uncompressedDir, 'DerivedData'));
65
- await fs.rename(wdaPath, path.resolve(uncompressedDir, 'DerivedData', 'WebDriverAgent'));
66
-
67
- // Compress the "uncompressed" bundle as a Zip
68
- const pathToZip = path.resolve(pathToBundles, `webdriveragent-xcode_${xcodeVersion}.zip`);
69
- await zip.toArchive(
70
- pathToZip, {cwd: path.join(rootDir, 'uncompressed')}
71
- );
72
- log.info(`Zip bundled at "${pathToZip}"`);
73
-
74
- // Now just zip the .app and place it in the root directory
75
- // This zip file will be published to NPM
76
- const wdaAppBundle = 'WebDriverAgentRunner-Runner.app';
77
- const appBundlePath = path.join(uncompressedDir, 'DerivedData', 'WebDriverAgent',
78
- 'Build', 'Products', 'Debug-iphonesimulator', wdaAppBundle);
79
- const appBundleZipPath = path.join(rootDir, `${wdaAppBundle}.zip`);
37
+ const zipName = `WebDriverAgentRunner-Runner-Sim-${xcodeVersion}.zip`;
38
+ LOG.info(`Creating ${zipName} which includes ${WDA_BUNDLE}`);
39
+ const appBundleZipPath = path.join(ROOT_DIR, zipName);
80
40
  await fs.rimraf(appBundleZipPath);
81
- log.info(`Created './${wdaAppBundle}.zip'`);
82
- await zip.toArchive(appBundleZipPath, {cwd: appBundlePath});
83
- log.info(`Zip bundled at "${appBundleZipPath}"`);
84
- // Clean up the uncompressed directory
85
- await fs.rimraf(uncompressedDir);
41
+ LOG.info(`Created './${zipName}'`);
42
+ try {
43
+ await exec('xattr', ['-cr', WDA_BUNDLE], {cwd: WDA_BUNDLE_PATH});
44
+ await exec('zip', ['-qr', appBundleZipPath, WDA_BUNDLE], {cwd: WDA_BUNDLE_PATH});
45
+ } catch (e) {
46
+ LOG.error(`===FAILED TO ZIP ARCHIVE`);
47
+ LOG.error(e.stderr);
48
+ throw e;
49
+ }
50
+ LOG.info(`Zip bundled at "${appBundleZipPath}"`);
86
51
  }
87
52
 
88
53
  if (require.main === module) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.10.17",
3
+ "version": "4.10.18",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {