expo-test-runner 0.3.14 → 0.3.15
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/build/BundlerController.js.map +1 -1
- package/build/ConfigReader.d.ts +1 -1
- package/build/ConfigReader.js.map +1 -1
- package/build/TemplateEvaluator.d.ts +1 -1
- package/build/TemplateEvaluator.js.map +1 -1
- package/build/TemplateFile.d.ts +1 -1
- package/build/TemplateFile.js.map +1 -1
- package/build/TemplateProject.d.ts +3 -3
- package/build/TemplateProject.js.map +1 -1
- package/build/Utils.d.ts +1 -0
- package/build/Utils.js +5 -0
- package/build/Utils.js.map +1 -1
- package/build/commands/CreateProject.d.ts +1 -1
- package/build/commands/CreateProject.js +2 -2
- package/build/commands/CreateProject.js.map +1 -1
- package/build/commands/RunTest.d.ts +1 -1
- package/build/commands/RunTest.js +1 -4
- package/build/commands/RunTest.js.map +1 -1
- package/build/registerCommand.d.ts +2 -2
- package/build/registerCommand.js.map +1 -1
- package/package.json +15 -12
- package/src/BundlerController.ts +1 -2
- package/src/ConfigReader.ts +1 -1
- package/src/TemplateEvaluator.ts +1 -2
- package/src/TemplateFile.ts +1 -1
- package/src/TemplateProject.ts +3 -4
- package/src/Utils.ts +5 -0
- package/src/commands/CreateProject.ts +5 -6
- package/src/commands/RunTest.ts +4 -9
- package/src/registerCommand.ts +2 -2
- package/tsconfig.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundlerController.js","sourceRoot":"","sources":["../src/BundlerController.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"BundlerController.js","sourceRoot":"","sources":["../src/BundlerController.ts"],"names":[],"mappings":";;;;;AAAA,iDAAoD;AACpD,4DAA+B;AAE/B,mCAAgC;AAEhC,MAAqB,iBAAiB;IAGhB;IAFZ,OAAO,CAA2B;IAE1C,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEpC,KAAK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CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,uBAAuB;QACnC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,OAAO,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC;gBACH,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAK,EAAC,8BAA8B,CAAC,CAAC;gBAClE,IAAI,aAAa,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBACjC,OAAO;gBACT,CAAC;YACH,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YAEV,MAAM,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;CACF;AA3DD,oCA2DC","sourcesContent":["import { ChildProcess, spawn } from 'child_process';\nimport fetch from 'node-fetch';\n\nimport { delay } from './Utils';\n\nexport default class BundlerController {\n private process: ChildProcess | undefined;\n\n constructor(private path: string) {}\n\n async start() {\n const bundler = spawn('yarn', ['start'], { cwd: this.path, stdio: 'inherit' });\n await delay(1000);\n this.ensureBundlerWasStarted();\n this.process = bundler;\n }\n\n async stop() {\n try {\n // Fixes:\n // Error: read EIO\n // at TTY.onStreamRead (node:internal/stream_base_commons:211:20)\n // Emitted 'error' event on ReadStream\n const killProcess: (pid: number, timeout: number) => Promise<void> = (pid, timeout) =>\n new Promise<void>((resolve, reject) => {\n const signal = 'SIGTERM';\n process.kill(pid, signal);\n let count = 0;\n const interval = setInterval(() => {\n try {\n process.kill(pid, 0);\n } catch {\n clearInterval(interval);\n // the process does not exists anymore\n resolve();\n }\n if ((count += 100) > timeout) {\n clearInterval(interval);\n reject(new Error('Timeout process kill'));\n }\n }, 100);\n });\n\n await killProcess(this.process?.pid!, 2000);\n } catch (error) {\n console.log(`Cannot kill bundler: ${error}.`);\n }\n }\n\n private async ensureBundlerWasStarted() {\n let retries = 10;\n while (retries-- > 0) {\n try {\n const bundlerStatus = await fetch('http://localhost:8081/status');\n if (bundlerStatus.status === 200) {\n return;\n }\n } catch {}\n\n await delay(500);\n }\n\n throw new Error(\"Bundler isn't available.\");\n }\n}\n"]}
|
package/build/ConfigReader.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigReader.js","sourceRoot":"","sources":["../src/ConfigReader.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAI5B,MAAqB,YAAY;IACX;IAApB,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEpC,cAAc;QACZ,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAW,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAwB;QACzC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;IACpE,CAAC;CACF;AAVD,+BAUC","sourcesContent":["import { join } from 'path';\n\nimport
|
|
1
|
+
{"version":3,"file":"ConfigReader.js","sourceRoot":"","sources":["../src/ConfigReader.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAI5B,MAAqB,YAAY;IACX;IAApB,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEpC,cAAc;QACZ,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAW,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAwB;QACzC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;IACpE,CAAC;CACF;AAVD,+BAUC","sourcesContent":["import { join } from 'path';\n\nimport { Config } from './Config';\n\nexport default class ConfigReader {\n constructor(private path: string) {}\n\n readConfigFile(): Config {\n return require(this.path) as Config;\n }\n\n static getFilePath(path: string | undefined): string {\n return path ? path : join(process.cwd(), 'test-runner.config.js');\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateEvaluator.js","sourceRoot":"","sources":["../src/TemplateEvaluator.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"TemplateEvaluator.js","sourceRoot":"","sources":["../src/TemplateEvaluator.ts"],"names":[],"mappings":";;;;;AAAA,6BAA4C;AAC5C,4CAAoB;AAEpB,MAAqB,iBAAiB;IAChB;IAApB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,KAAK,CAAC,gBAAgB,CAAC,IAAY;QACjC,MAAM,WAAW,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,IAAA,cAAQ,EAAC,WAAW,EAAE;YACvC,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QAEH,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAClE,CAAC;CACF;AAXD,oCAWC","sourcesContent":["import { Definitions, template } from 'dot';\nimport fs from 'fs';\n\nexport default class TemplateEvaluator {\n constructor(private definitions: Definitions) {}\n\n async compileFileAsync(path: string) {\n const fileContent = await fs.promises.readFile(path, 'utf-8');\n const templateFn = template(fileContent, {\n strip: false,\n });\n\n await fs.promises.writeFile(path, templateFn(this.definitions));\n }\n}\n"]}
|
package/build/TemplateFile.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Platform } from './Platform';
|
|
2
|
-
import
|
|
2
|
+
import TemplateEvaluator from './TemplateEvaluator';
|
|
3
3
|
export interface ProjectFile {
|
|
4
4
|
platform: Platform;
|
|
5
5
|
copy(projectPath: string, outputPath: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateFile.js","sourceRoot":"","sources":["../src/TemplateFile.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,+BAAqC;AAErC,mCAAmC;AACnC,yCAAsC;AAStC,MAAa,YAAY;IAEd;IACA;IACA;IAHT,YACS,QAAgB,EAChB,WAAqB,mBAAQ,CAAC,IAAI,EAClC,oBAA6B,KAAK;QAFlC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAA0B;QAClC,sBAAiB,GAAjB,iBAAiB,CAAiB;IACxC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,WAAmB,EAAE,UAAkB;QAChD,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,gBAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACnE,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACnB,iHAAiH;YACjH,oFAAoF;YACpF,MAAM,IAAI,SAAS,CAAC,wBAAwB,UAAU,+BAA+B,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,OAAO,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,WAAmB,EACnB,QAAgB,EA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OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,CAAC,oBAA6B,KAAK;QACxC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC1E,CAAC;CACF;AAdD,oDAcC","sourcesContent":["import fs from 'fs';\nimport { dirname, join } from 'path';\n\nimport { SelfPath } from './Paths';\nimport { Platform } from './Platform';\nimport
|
|
1
|
+
{"version":3,"file":"TemplateFile.js","sourceRoot":"","sources":["../src/TemplateFile.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,+BAAqC;AAErC,mCAAmC;AACnC,yCAAsC;AAStC,MAAa,YAAY;IAEd;IACA;IACA;IAHT,YACS,QAAgB,EAChB,WAAqB,mBAAQ,CAAC,IAAI,EAClC,oBAA6B,KAAK;QAFlC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAA0B;QAClC,sBAAiB,GAAjB,iBAAiB,CAAiB;IACxC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,WAAmB,EAAE,UAAkB;QAChD,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,gBAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACnE,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACnB,iHAAiH;YACjH,oFAAoF;YACpF,MAAM,IAAI,SAAS,CAAC,wBAAwB,UAAU,+BAA+B,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,YAAE,CAA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AApB,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAExC,IAAI,CAAC,oBAA6B,KAAK;QACrC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC;IAED,WAAW,CAAC,oBAA6B,KAAK;QAC5C,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,CAAC,oBAA6B,KAAK;QACxC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC1E,CAAC;CACF;AAdD,oDAcC","sourcesContent":["import fs from 'fs';\nimport { dirname, join } from 'path';\n\nimport { SelfPath } from './Paths';\nimport { Platform } from './Platform';\nimport TemplateEvaluator from './TemplateEvaluator';\n\nexport interface ProjectFile {\n platform: Platform;\n copy(projectPath: string, outputPath: string): Promise<void>;\n evaluate(projectPath: string, filePath: string, evaluator: TemplateEvaluator): Promise<void>;\n}\n\nexport class TemplateFile implements ProjectFile {\n constructor(\n public template: string,\n public platform: Platform = Platform.Both,\n public shouldBeEvaluated: boolean = false\n ) {}\n\n async copy(projectPath: string, outputPath: string): Promise<void> {\n const src = join(SelfPath, 'templates', this.template, outputPath);\n const dest = join(projectPath, outputPath);\n const stat = await fs.promises.stat(src);\n if (!stat.isFile()) {\n // NOTE(@kitten): Explicit error was added when switching from fs-extra.copy, which defaults to recursive copying\n // However, this should only be used on single files, so an explicit error was added\n throw new TypeError(`Expected outputPath (${outputPath}) to be path to a single file`);\n }\n await fs.promises.mkdir(dirname(dest), { recursive: true });\n return fs.promises.copyFile(src, dest);\n }\n\n async evaluate(\n projectPath: string,\n filePath: string,\n evaluator: TemplateEvaluator\n ): Promise<void> {\n if (this.shouldBeEvaluated) {\n return evaluator.compileFileAsync(join(projectPath, filePath));\n }\n\n return Promise.resolve();\n }\n}\n\nexport class UserFile implements ProjectFile {\n constructor(\n public userFilePath: string,\n public platform: Platform = Platform.Both,\n public shouldBeEvaluated: boolean = false\n ) {}\n\n copy(projectPath: string, outputPath: string): Promise<void> {\n return fs.promises.cp(this.userFilePath, join(projectPath, outputPath), {\n recursive: true,\n });\n }\n\n evaluate(projectPath: string, filePath: string, evaluator: any): Promise<void> {\n if (this.shouldBeEvaluated) {\n return evaluator.compileFileAsync(join(projectPath, filePath));\n }\n\n return Promise.resolve();\n }\n}\n\nexport class TemplateFilesFactory {\n constructor(private template: string) {}\n\n file(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.Both, shouldBeEvaluated);\n }\n\n androidFile(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.Android, shouldBeEvaluated);\n }\n\n iosFile(shouldBeEvaluated: boolean = false): TemplateFile {\n return new TemplateFile(this.template, Platform.iOS, shouldBeEvaluated);\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Definitions } from 'dot';
|
|
2
|
+
import { Application, DetoxTest } from './Config';
|
|
3
3
|
import { Platform } from './Platform';
|
|
4
|
-
import
|
|
4
|
+
import { ProjectFile } from './TemplateFile';
|
|
5
5
|
export default class TemplateProject {
|
|
6
6
|
protected config: Application;
|
|
7
7
|
protected name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateProject.js","sourceRoot":"","sources":["../src/TemplateProject.ts"],"names":[],"mappings":";;;;;AAAA,oEAA2C;AAE3C,4CAAoB;AACpB,gDAAwB;AAExB,4EAAoD;AAEpD,yCAAsC;AACtC,4EAAoD;AAEpD,iDAAgE;AAChE,mCAAkD;AAElD,MAAqB,eAAe;IAEtB;IACA;IACA;IACA;IAJZ,YACY,MAAmB,EACnB,IAA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C;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,WAAmB,EAAE,IAAe;QAC5C,IAAI,OAAsC,CAAC;QAC3C,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,2BAAiB,CAAC,WAAW,CAAC,CAAC;YAE7C,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBACvC,MAAM,IAAA,qBAAU,EACd,MAAM,EACN,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,sBAAsB,CAAC,EACpF;oBACE,GAAG,EAAE,WAAW;oBAChB,KAAK,EAAE,SAAS;iBACjB,CACF,CAAC;gBAEF,MAAM,IAAA,+BAAuB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,qCAAqC;YACrC,MAAM,OAAO,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAnMD,kCAmMC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport type { Definitions } from 'dot';\nimport fs from 'fs';\nimport path from 'path';\n\nimport BundlerController from './BundlerController';\nimport type { Application, DetoxTest } from './Config';\nimport { Platform } from './Platform';\nimport TemplateEvaluator from './TemplateEvaluator';\nimport type { ProjectFile } from './TemplateFile';\nimport { TemplateFilesFactory, UserFile } from './TemplateFile';\nimport { killVirtualDevicesAsync } from './Utils';\n\nexport default class TemplateProject {\n constructor(\n protected config: Application,\n protected name: string,\n protected platform: Platform,\n protected configFilePath: string\n ) {}\n\n getDefinitions(): Definitions {\n return {\n name: 'devcliente2e',\n appEntryPoint: 'e2e/app/App',\n };\n }\n\n async createApplicationAsync(projectPath: string) {\n // TODO: this assumes there is a parent folder\n const parentFolder = path.resolve(projectPath, '..');\n if (!fs.existsSync(parentFolder)) {\n fs.mkdirSync(parentFolder, { recursive: true });\n }\n\n const appName = 'dev-client-e2e';\n await spawnAsync('yarn', ['create', 'expo-app', appName], {\n stdio: 'inherit',\n cwd: parentFolder,\n });\n fs.renameSync(path.join(parentFolder, appName), projectPath);\n\n const repoRoot = path.resolve(this.configFilePath, '..', '..', '..');\n const localCliBin = path.join(repoRoot, 'packages/@expo/cli/build/bin/cli');\n await spawnAsync(localCliBin, ['install', 'detox', 'jest'], {\n stdio: 'inherit',\n cwd: projectPath,\n });\n\n // add local dependencies\n let packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf-8'));\n packageJson = {\n ...packageJson,\n dependencies: {\n ...packageJson.dependencies,\n 'expo-dev-client': `file:${repoRoot}/packages/expo-dev-client`,\n 'expo-dev-menu-interface': `file:${repoRoot}/packages/expo-dev-menu-interface`,\n 'expo-status-bar': `file:${repoRoot}/packages/expo-status-bar`,\n expo: `file:${repoRoot}/packages/expo`,\n 'jest-circus': packageJson.dependencies.jest,\n },\n resolutions: {\n ...packageJson.resolutions,\n 'expo-application': `file:${repoRoot}/packages/expo-application`,\n 'expo-asset': `file:${repoRoot}/packages/expo-asset`,\n 'expo-constants': `file:${repoRoot}/packages/expo-constants`,\n 'expo-dev-launcher': `file:${repoRoot}/packages/expo-dev-launcher`,\n 'expo-dev-menu': `file:${repoRoot}/packages/expo-dev-menu`,\n 'expo-file-system': `file:${repoRoot}/packages/expo-file-system`,\n 'expo-font': `file:${repoRoot}/packages/expo-font`,\n 'expo-keep-awake': `file:${repoRoot}/packages/expo-keep-awake`,\n 'expo-manifests': `file:${repoRoot}/packages/expo-manifests`,\n 'expo-modules-autolinking': `file:${repoRoot}/packages/expo-modules-autolinking`,\n 'expo-modules-core': `file:${repoRoot}/packages/expo-modules-core`,\n 'expo-updates-interface': `file:${repoRoot}/packages/expo-updates-interface`,\n },\n };\n fs.writeFileSync(\n path.join(projectPath, 'package.json'),\n JSON.stringify(packageJson, null, 2),\n 'utf-8'\n );\n\n // configure app.json\n let appJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'app.json'), 'utf-8'));\n appJson = {\n ...appJson,\n expo: {\n ...appJson.expo,\n android: { ...appJson.android, package: 'com.testrunner' },\n ios: { ...appJson.ios, bundleIdentifier: 'com.testrunner' },\n },\n };\n fs.writeFileSync(path.join(projectPath, 'app.json'), JSON.stringify(appJson, null, 2), 'utf-8');\n\n // pack local template and prebuild\n const localTemplatePath = path.join(repoRoot, 'templates', 'expo-template-bare-minimum');\n await spawnAsync('npm', ['pack', '--pack-destination', projectPath], {\n cwd: localTemplatePath,\n stdio: 'inherit',\n });\n const templateVersion = require(path.join(localTemplatePath, 'package.json')).version;\n\n await spawnAsync(\n localCliBin,\n ['prebuild', '--template', `expo-template-bare-minimum-${templateVersion}.tgz`],\n {\n stdio: 'inherit',\n cwd: projectPath,\n }\n );\n\n const templateFiles = this.getTemplateFiles();\n await this.copyFilesAsync(projectPath, templateFiles);\n await this.evaluateFiles(projectPath, templateFiles);\n\n // workaround for instrumented unit test files not compiling in this\n // configuration (ignored in .npmignore)\n await spawnAsync('rm', ['-rf', 'node_modules/expo-dev-client/android/src/androidTest'], {\n stdio: 'inherit',\n cwd: projectPath,\n });\n }\n\n getTemplateFiles(): { [path: string]: ProjectFile } {\n const tff = new TemplateFilesFactory('detox');\n\n const additionalFiles: { [path: string]: ProjectFile } = this.config.additionalFiles?.reduce(\n (reducer, file) => ({\n ...reducer,\n [file]: new UserFile(this.userFilePath(file)),\n }),\n {}\n );\n\n if (this.config.android?.detoxTestFile) {\n additionalFiles['android/app/src/androidTest/java/com/testrunner/DetoxTest.java'] =\n new UserFile(this.userFilePath(this.config.android.detoxTestFile), Platform.Android);\n }\n\n return {\n 'android/build.gradle': tff.androidFile(),\n 'android/app/build.gradle': tff.androidFile(),\n 'android/app/src/androidTest/java/com/testrunner/DetoxTest.java': tff.androidFile(),\n 'android/app/src/main/java/com/testrunner/MainApplication.java': tff.androidFile(),\n 'index.js': tff.file(true),\n 'ios/devcliente2e/main.m': tff.iosFile(),\n [this.config.detoxConfigFile]: new UserFile(\n this.userFilePath(this.config.detoxConfigFile),\n Platform.Both,\n true\n ),\n ...additionalFiles,\n };\n }\n\n protected userFilePath(relativePath: string): string {\n return path.join(this.configFilePath, '..', relativePath);\n }\n\n protected async copyFilesAsync(projectPath: string, files: { [path: string]: ProjectFile }) {\n await Promise.all(Object.entries(files).map(([path, file]) => file.copy(projectPath, path)));\n }\n\n protected async evaluateFiles(projectPath: string, files: { [path: string]: ProjectFile }) {\n const templateEvaluator = new TemplateEvaluator(this.getDefinitions());\n await Promise.all(\n Object.entries(files).map(([path, file]) =>\n file.evaluate(projectPath, path, templateEvaluator)\n )\n );\n }\n\n async build(projectPath: string, test: DetoxTest): Promise<void> {\n for (const conf of test.configurations) {\n await spawnAsync('yarn', ['detox', 'build', '-c', conf], {\n cwd: projectPath,\n stdio: 'inherit',\n });\n }\n }\n\n async run(projectPath: string, test: DetoxTest): Promise<void> {\n let bundler: BundlerController | undefined;\n try {\n bundler = new BundlerController(projectPath);\n\n if (test.shouldRunBundler) {\n await bundler.start();\n }\n\n for (const conf of test.configurations) {\n await spawnAsync(\n 'yarn',\n ['detox', 'test', '-c', conf, '--ci', '--headless', '--gpu', 'swiftshader_indirect'],\n {\n cwd: projectPath,\n stdio: 'inherit',\n }\n );\n\n await killVirtualDevicesAsync(this.platform);\n }\n } finally {\n // If bundler wasn't started is noop.\n await bundler?.stop();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TemplateProject.js","sourceRoot":"","sources":["../src/TemplateProject.ts"],"names":[],"mappings":";;;;;AAAA,oEAA2C;AAE3C,4CAAoB;AACpB,gDAAwB;AAExB,4EAAoD;AAEpD,yCAAsC;AACtC,4EAAoD;AACpD,iDAA6E;AAC7E,mCAAkD;AAElD,MAAqB,eAAe;IAEtB;IACA;IACA;IACA;IAJZ,YACY,MAAmB,EACnB,IAAY,EACZ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CAAC;IAED,KAAK,CAAC,GAAG,CAAC,WAAmB,EAAE,IAAe;QAC5C,IAAI,OAAsC,CAAC;QAC3C,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,2BAAiB,CAAC,WAAW,CAAC,CAAC;YAE7C,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBACvC,MAAM,IAAA,qBAAU,EACd,MAAM,EACN,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,sBAAsB,CAAC,EACpF;oBACE,GAAG,EAAE,WAAW;oBAChB,KAAK,EAAE,SAAS;iBACjB,CACF,CAAC;gBAEF,MAAM,IAAA,+BAAuB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,qCAAqC;YACrC,MAAM,OAAO,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAnMD,kCAmMC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { Definitions } from 'dot';\nimport fs from 'fs';\nimport path from 'path';\n\nimport BundlerController from './BundlerController';\nimport { Application, DetoxTest } from './Config';\nimport { Platform } from './Platform';\nimport TemplateEvaluator from './TemplateEvaluator';\nimport { ProjectFile, TemplateFilesFactory, UserFile } from './TemplateFile';\nimport { killVirtualDevicesAsync } from './Utils';\n\nexport default class TemplateProject {\n constructor(\n protected config: Application,\n protected name: string,\n protected platform: Platform,\n protected configFilePath: string\n ) {}\n\n getDefinitions(): Definitions {\n return {\n name: 'devcliente2e',\n appEntryPoint: 'e2e/app/App',\n };\n }\n\n async createApplicationAsync(projectPath: string) {\n // TODO: this assumes there is a parent folder\n const parentFolder = path.resolve(projectPath, '..');\n if (!fs.existsSync(parentFolder)) {\n fs.mkdirSync(parentFolder, { recursive: true });\n }\n\n const appName = 'dev-client-e2e';\n await spawnAsync('yarn', ['create', 'expo-app', appName], {\n stdio: 'inherit',\n cwd: parentFolder,\n });\n fs.renameSync(path.join(parentFolder, appName), projectPath);\n\n const repoRoot = path.resolve(this.configFilePath, '..', '..', '..');\n const localCliBin = path.join(repoRoot, 'packages/@expo/cli/build/bin/cli');\n await spawnAsync(localCliBin, ['install', 'detox', 'jest'], {\n stdio: 'inherit',\n cwd: projectPath,\n });\n\n // add local dependencies\n let packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf-8'));\n packageJson = {\n ...packageJson,\n dependencies: {\n ...packageJson.dependencies,\n 'expo-dev-client': `file:${repoRoot}/packages/expo-dev-client`,\n 'expo-dev-menu-interface': `file:${repoRoot}/packages/expo-dev-menu-interface`,\n 'expo-status-bar': `file:${repoRoot}/packages/expo-status-bar`,\n expo: `file:${repoRoot}/packages/expo`,\n 'jest-circus': packageJson.dependencies.jest,\n },\n resolutions: {\n ...packageJson.resolutions,\n 'expo-application': `file:${repoRoot}/packages/expo-application`,\n 'expo-asset': `file:${repoRoot}/packages/expo-asset`,\n 'expo-constants': `file:${repoRoot}/packages/expo-constants`,\n 'expo-dev-launcher': `file:${repoRoot}/packages/expo-dev-launcher`,\n 'expo-dev-menu': `file:${repoRoot}/packages/expo-dev-menu`,\n 'expo-file-system': `file:${repoRoot}/packages/expo-file-system`,\n 'expo-font': `file:${repoRoot}/packages/expo-font`,\n 'expo-keep-awake': `file:${repoRoot}/packages/expo-keep-awake`,\n 'expo-manifests': `file:${repoRoot}/packages/expo-manifests`,\n 'expo-modules-autolinking': `file:${repoRoot}/packages/expo-modules-autolinking`,\n 'expo-modules-core': `file:${repoRoot}/packages/expo-modules-core`,\n 'expo-updates-interface': `file:${repoRoot}/packages/expo-updates-interface`,\n },\n };\n fs.writeFileSync(\n path.join(projectPath, 'package.json'),\n JSON.stringify(packageJson, null, 2),\n 'utf-8'\n );\n\n // configure app.json\n let appJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'app.json'), 'utf-8'));\n appJson = {\n ...appJson,\n expo: {\n ...appJson.expo,\n android: { ...appJson.android, package: 'com.testrunner' },\n ios: { ...appJson.ios, bundleIdentifier: 'com.testrunner' },\n },\n };\n fs.writeFileSync(path.join(projectPath, 'app.json'), JSON.stringify(appJson, null, 2), 'utf-8');\n\n // pack local template and prebuild\n const localTemplatePath = path.join(repoRoot, 'templates', 'expo-template-bare-minimum');\n await spawnAsync('npm', ['pack', '--pack-destination', projectPath], {\n cwd: localTemplatePath,\n stdio: 'inherit',\n });\n const templateVersion = require(path.join(localTemplatePath, 'package.json')).version;\n\n await spawnAsync(\n localCliBin,\n ['prebuild', '--template', `expo-template-bare-minimum-${templateVersion}.tgz`],\n {\n stdio: 'inherit',\n cwd: projectPath,\n }\n );\n\n const templateFiles = this.getTemplateFiles();\n await this.copyFilesAsync(projectPath, templateFiles);\n await this.evaluateFiles(projectPath, templateFiles);\n\n // workaround for instrumented unit test files not compiling in this\n // configuration (ignored in .npmignore)\n await spawnAsync('rm', ['-rf', 'node_modules/expo-dev-client/android/src/androidTest'], {\n stdio: 'inherit',\n cwd: projectPath,\n });\n }\n\n getTemplateFiles(): { [path: string]: ProjectFile } {\n const tff = new TemplateFilesFactory('detox');\n\n const additionalFiles: { [path: string]: ProjectFile } = this.config.additionalFiles?.reduce(\n (reducer, file) => ({\n ...reducer,\n [file]: new UserFile(this.userFilePath(file)),\n }),\n {}\n );\n\n if (this.config.android?.detoxTestFile) {\n additionalFiles['android/app/src/androidTest/java/com/testrunner/DetoxTest.java'] =\n new UserFile(this.userFilePath(this.config.android.detoxTestFile), Platform.Android);\n }\n\n return {\n 'android/build.gradle': tff.androidFile(),\n 'android/app/build.gradle': tff.androidFile(),\n 'android/app/src/androidTest/java/com/testrunner/DetoxTest.java': tff.androidFile(),\n 'android/app/src/main/java/com/testrunner/MainApplication.java': tff.androidFile(),\n 'index.js': tff.file(true),\n 'ios/devcliente2e/main.m': tff.iosFile(),\n [this.config.detoxConfigFile]: new UserFile(\n this.userFilePath(this.config.detoxConfigFile),\n Platform.Both,\n true\n ),\n ...additionalFiles,\n };\n }\n\n protected userFilePath(relativePath: string): string {\n return path.join(this.configFilePath, '..', relativePath);\n }\n\n protected async copyFilesAsync(projectPath: string, files: { [path: string]: ProjectFile }) {\n await Promise.all(Object.entries(files).map(([path, file]) => file.copy(projectPath, path)));\n }\n\n protected async evaluateFiles(projectPath: string, files: { [path: string]: ProjectFile }) {\n const templateEvaluator = new TemplateEvaluator(this.getDefinitions());\n await Promise.all(\n Object.entries(files).map(([path, file]) =>\n file.evaluate(projectPath, path, templateEvaluator)\n )\n );\n }\n\n async build(projectPath: string, test: DetoxTest): Promise<void> {\n for (const conf of test.configurations) {\n await spawnAsync('yarn', ['detox', 'build', '-c', conf], {\n cwd: projectPath,\n stdio: 'inherit',\n });\n }\n }\n\n async run(projectPath: string, test: DetoxTest): Promise<void> {\n let bundler: BundlerController | undefined;\n try {\n bundler = new BundlerController(projectPath);\n\n if (test.shouldRunBundler) {\n await bundler.start();\n }\n\n for (const conf of test.configurations) {\n await spawnAsync(\n 'yarn',\n ['detox', 'test', '-c', conf, '--ci', '--headless', '--gpu', 'swiftshader_indirect'],\n {\n cwd: projectPath,\n stdio: 'inherit',\n }\n );\n\n await killVirtualDevicesAsync(this.platform);\n }\n } finally {\n // If bundler wasn't started is noop.\n await bundler?.stop();\n }\n }\n}\n"]}
|
package/build/Utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Platform } from './Platform';
|
|
2
|
+
export declare function yarnInstall(path: string): void;
|
|
2
3
|
export declare const delay: (ms: number) => Promise<void>;
|
|
3
4
|
export declare function killEmulatorAsync(): Promise<void>;
|
|
4
5
|
export declare function killSimulatorAsync(): Promise<void>;
|
package/build/Utils.js
CHANGED
|
@@ -4,11 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.delay = void 0;
|
|
7
|
+
exports.yarnInstall = yarnInstall;
|
|
7
8
|
exports.killEmulatorAsync = killEmulatorAsync;
|
|
8
9
|
exports.killSimulatorAsync = killSimulatorAsync;
|
|
9
10
|
exports.killVirtualDevicesAsync = killVirtualDevicesAsync;
|
|
10
11
|
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
11
13
|
const Platform_1 = require("./Platform");
|
|
14
|
+
function yarnInstall(path) {
|
|
15
|
+
(0, child_process_1.spawnSync)('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });
|
|
16
|
+
}
|
|
12
17
|
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
18
|
exports.delay = delay;
|
|
14
19
|
async function killEmulatorAsync() {
|
package/build/Utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":";;;;;;AAKA,kCAEC;AAKD,8CASC;AAED,gDASC;AAED,0DAQC;AA1CD,oEAA2C;AAC3C,iDAA0C;AAE1C,yCAAsC;AAEtC,SAAgB,WAAW,CAAC,IAAY;IACtC,IAAA,yBAAS,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;AAEM,MAAM,KAAK,GAAkC,CAAC,EAAE,EAAE,EAAE,CACzD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AADvC,QAAA,KAAK,SACkC;AAE7C,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import { spawnSync } from 'child_process';\n\nimport { Platform } from './Platform';\n\nexport function yarnInstall(path: string) {\n spawnSync('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });\n}\n\nexport const delay: (ms: number) => Promise<void> = (ms) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\nexport async function killEmulatorAsync(): Promise<void> {\n try {\n console.log('Trying to kill emulator...');\n await spawnAsync('adb', ['-s', 'emulator-5554', 'emu', 'kill'], { stdio: 'inherit' });\n console.log('Emulator was killed.');\n } catch (e) {\n console.log(\"Couldn't kill emulator\");\n console.log(e);\n }\n}\n\nexport async function killSimulatorAsync(): Promise<void> {\n try {\n console.log('Trying to kill simulator...');\n await spawnAsync('xcrun', ['simctl', 'shutdown', 'all'], { stdio: 'inherit' });\n console.log('Simulator was killed.');\n } catch (e) {\n console.log(\"Couldn't kill simulator.\");\n console.log(e);\n }\n}\n\nexport async function killVirtualDevicesAsync(platform: Platform): Promise<void> {\n if ((platform & Platform.Android) > 0) {\n await killEmulatorAsync();\n }\n\n if ((platform & Platform.iOS) > 0) {\n await killSimulatorAsync();\n }\n}\n"]}
|
|
@@ -8,14 +8,14 @@ const TemplateProject_1 = __importDefault(require("../TemplateProject"));
|
|
|
8
8
|
const registerCommand_1 = require("../registerCommand");
|
|
9
9
|
async function createProjectAsync(config, options) {
|
|
10
10
|
const app = config.applications[options.app];
|
|
11
|
-
if (app
|
|
11
|
+
if (app.preset === 'detox') {
|
|
12
12
|
console.log(`Using ${chalk_1.default.green('detox')} preset.`);
|
|
13
13
|
const preset = new TemplateProject_1.default(app, options.app, options.platform, options.configFile);
|
|
14
14
|
console.log(`Creating test app in ${chalk_1.default.green(options.path)}.`);
|
|
15
15
|
await preset.createApplicationAsync(options.path);
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
throw new Error(`Unknown preset: ${app
|
|
18
|
+
throw new Error(`Unknown preset: ${app.preset}`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.default = (program) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateProject.js","sourceRoot":"","sources":["../../src/commands/CreateProject.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAI1B,yEAAiD;
|
|
1
|
+
{"version":3,"file":"CreateProject.js","sourceRoot":"","sources":["../../src/commands/CreateProject.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAI1B,yEAAiD;AACjD,wDAAqE;AAMrE,KAAK,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAA6B;IAC7E,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,SAAS,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,yBAAe,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE3F,OAAO,CAAC,GAAG,CAAC,wBAAwB,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,kBAAe,CAAC,OAAwB,EAAE,EAAE;IAC1C,IAAA,iCAAe,EAAC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,MAAM,CACnE,oBAAoB,EACpB,oCAAoC,CACrC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { CommanderStatic } from 'commander';\n\nimport { Config } from '../Config';\nimport TemplateProject from '../TemplateProject';\nimport { DefaultOptions, registerCommand } from '../registerCommand';\n\ninterface CreateProjectOptions extends DefaultOptions {\n app: string;\n}\n\nasync function createProjectAsync(config: Config, options: CreateProjectOptions) {\n const app = config.applications[options.app];\n\n if (app.preset === 'detox') {\n console.log(`Using ${chalk.green('detox')} preset.`);\n const preset = new TemplateProject(app, options.app, options.platform, options.configFile);\n\n console.log(`Creating test app in ${chalk.green(options.path)}.`);\n await preset.createApplicationAsync(options.path);\n } else {\n throw new Error(`Unknown preset: ${app.preset}`);\n }\n}\n\nexport default (program: CommanderStatic) => {\n registerCommand(program, 'create-project', createProjectAsync).option(\n '-a, --app [string]',\n 'Name of the application to create.'\n );\n};\n"]}
|
|
@@ -10,7 +10,7 @@ const registerCommand_1 = require("../registerCommand");
|
|
|
10
10
|
function findTest(config, test) {
|
|
11
11
|
for (const appName in config.applications) {
|
|
12
12
|
const app = config.applications[appName];
|
|
13
|
-
for (const testName in app
|
|
13
|
+
for (const testName in app.tests) {
|
|
14
14
|
if (test === testName) {
|
|
15
15
|
return [appName, app];
|
|
16
16
|
}
|
|
@@ -21,9 +21,6 @@ function findTest(config, test) {
|
|
|
21
21
|
async function runTestAsync(config, options) {
|
|
22
22
|
const [appName, app] = findTest(config, options.test);
|
|
23
23
|
const test = app.tests[options.test];
|
|
24
|
-
if (test == null) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
24
|
if (app.preset === 'detox') {
|
|
28
25
|
console.log(`Using ${chalk_1.default.green('detox')} preset.`);
|
|
29
26
|
const preset = new TemplateProject_1.default(app, appName, options.platform, options.configFile);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunTest.js","sourceRoot":"","sources":["../../src/commands/RunTest.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,4CAAoB;AAGpB,yEAAiD;
|
|
1
|
+
{"version":3,"file":"RunTest.js","sourceRoot":"","sources":["../../src/commands/RunTest.ts"],"names":[],"mappings":";;;;;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AM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEvC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC9B,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAErC,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACzB,MAAM,YAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,kBAAe,CAAC,OAAwB,EAAE,EAAE;IAC1C,IAAA,iCAAe,EAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,MAAM,CACvD,qBAAqB,EACrB,+BAA+B,CAChC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { CommanderStatic } from 'commander';\nimport fs from 'fs';\n\nimport { Application, Config } from '../Config';\nimport TemplateProject from '../TemplateProject';\nimport { DefaultOptions, registerCommand } from '../registerCommand';\n\ninterface RunTestOptions extends DefaultOptions {\n test: string;\n}\n\nfunction findTest(config: Config, test: string): [string, Application] {\n for (const appName in config.applications) {\n const app = config.applications[appName];\n\n for (const testName in app.tests) {\n if (test === testName) {\n return [appName, app];\n }\n }\n }\n\n throw new Error(`Couldn't find test: ${test}`);\n}\n\nasync function runTestAsync(config: Config, options: RunTestOptions) {\n const [appName, app] = findTest(config, options.test);\n const test = app.tests[options.test];\n\n if (app.preset === 'detox') {\n console.log(`Using ${chalk.green('detox')} preset.`);\n const preset = new TemplateProject(app, appName, options.platform, options.configFile);\n\n console.log(`Creating test app in ${chalk.green(options.path)}.`);\n await preset.createApplicationAsync(options.path);\n\n console.log(`Building app.`);\n await preset.build(options.path, test);\n\n console.log(`Running tests.`);\n await preset.run(options.path, test);\n\n if (options.shouldBeCleaned) {\n console.log(`Cleaning.`);\n await fs.promises.rm(options.path, { recursive: true, force: true });\n }\n } else {\n throw new Error(`Unknown preset: ${app.preset}`);\n }\n}\n\nexport default (program: CommanderStatic) => {\n registerCommand(program, 'run-test', runTestAsync).option(\n '-t, --test [string]',\n 'Name of the test case to run.'\n );\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { CommanderStatic } from 'commander';
|
|
2
|
+
import { Config } from './Config';
|
|
3
3
|
import { Platform } from './Platform';
|
|
4
4
|
export interface DefaultOptions {
|
|
5
5
|
configFile: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerCommand.js","sourceRoot":"","sources":["../src/registerCommand.ts"],"names":[],"mappings":";;;;;AA0BA,0CAoCC;AA3DD,kEAA0C;AAC1C,mCAA6C;AAC7C,yCAAsC;AAStC,SAAS,WAAW,CAAC,QAAgB;IACnC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,mBAAQ,CAAC,OAAO,CAAC;IAC1B,CAAC;SAAM,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC9B,OAAO,mBAAQ,CAAC,GAAG,CAAC;IACtB,CAAC;SAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QAC/B,OAAO,mBAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,eAAe,CAC7B,SAA0B,EAC1B,WAAmB,EACnB,EAA0D;IAE1D,OAAO,SAAS;SACb,OAAO,CAAC,WAAW,CAAC;SACpB,MAAM,CAAC,qBAAqB,EAAE,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,EAAE,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { CommanderStatic } from 'commander';\n\nimport { Config } from './Config';\nimport ConfigReader from './ConfigReader';\nimport { temporaryDirectory } from './Paths';\nimport { Platform } from './Platform';\n\nexport interface DefaultOptions {\n configFile: string;\n platform: Platform;\n path: string;\n shouldBeCleaned: boolean;\n}\n\nfunction mapPlatform(platform: string): Platform {\n if (platform === 'android') {\n return Platform.Android;\n } else if (platform === 'ios') {\n return Platform.iOS;\n } else if (platform === 'both') {\n return Platform.Both;\n }\n\n throw new Error(`Unknown platform: ${platform}`);\n}\n\nexport function registerCommand<OptionsType extends DefaultOptions>(\n commander: CommanderStatic,\n commandName: string,\n fn: (config: Config, options: OptionsType) => Promise<any>\n) {\n return commander\n .command(commandName)\n .option('-c, --config <path>', 'Path to the config file.')\n .option(\n '--platform <platform>',\n 'Platform for which the project should be created. Available options: `ios`, `android`, `both`.'\n )\n .option('-p, --path <string>', 'Location where the test app will be created.')\n .action(async (providedOptions) => {\n if (providedOptions.platform) {\n providedOptions.platform = mapPlatform(providedOptions.platform);\n } else {\n providedOptions.platform = Platform.Both;\n }\n\n // clean temp folder if the path wasn't provided.\n providedOptions.shouldBeCleaned = !providedOptions.path;\n providedOptions.path = providedOptions.path ?? temporaryDirectory();\n\n providedOptions.configFile = ConfigReader.getFilePath(providedOptions.configFile);\n\n const options = providedOptions as OptionsType;\n const configReader = new ConfigReader(options.configFile);\n\n try {\n await fn(configReader.readConfigFile(), options);\n } catch (e) {\n console.error(e);\n process.exit(1);\n }\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-test-runner",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"description": "Script that enchants test experience.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -17,12 +17,22 @@
|
|
|
17
17
|
"url": "https://github.com/expo/expo-test-runner/issues"
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/expo/expo-test-runner#readme",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "expo-module build",
|
|
22
|
+
"clean": "expo-module clean",
|
|
23
|
+
"lint": "expo-module lint",
|
|
24
|
+
"test": "expo-module test",
|
|
25
|
+
"prepare": "expo-module prepare",
|
|
26
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
27
|
+
"expo-module": "expo-module"
|
|
28
|
+
},
|
|
20
29
|
"devDependencies": {
|
|
21
30
|
"@babel/core": "^7.23.7",
|
|
22
31
|
"@types/node": "^22.14.0",
|
|
23
32
|
"@types/node-fetch": "^2.5.12",
|
|
24
|
-
"eslint-config-universe": "15.
|
|
25
|
-
"expo-module-scripts": "
|
|
33
|
+
"eslint-config-universe": "^15.0.4",
|
|
34
|
+
"expo-module-scripts": "^55.0.2",
|
|
35
|
+
"typescript": "^5.9.2"
|
|
26
36
|
},
|
|
27
37
|
"dependencies": {
|
|
28
38
|
"@babel/runtime": "^7.23.8",
|
|
@@ -34,12 +44,5 @@
|
|
|
34
44
|
"temp-dir": "~2.0.0",
|
|
35
45
|
"unique-string": "~2.0.0"
|
|
36
46
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
-
|
|
39
|
-
"build": "expo-module build",
|
|
40
|
-
"clean": "expo-module clean",
|
|
41
|
-
"lint": "expo-module lint",
|
|
42
|
-
"test": "expo-module test",
|
|
43
|
-
"expo-module": "expo-module"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
47
|
+
"gitHead": "0675db12d13a5309e3109e8ecf7f6011522194c6"
|
|
48
|
+
}
|
package/src/BundlerController.ts
CHANGED
package/src/ConfigReader.ts
CHANGED
package/src/TemplateEvaluator.ts
CHANGED
package/src/TemplateFile.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { dirname, join } from 'path';
|
|
|
3
3
|
|
|
4
4
|
import { SelfPath } from './Paths';
|
|
5
5
|
import { Platform } from './Platform';
|
|
6
|
-
import
|
|
6
|
+
import TemplateEvaluator from './TemplateEvaluator';
|
|
7
7
|
|
|
8
8
|
export interface ProjectFile {
|
|
9
9
|
platform: Platform;
|
package/src/TemplateProject.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import spawnAsync from '@expo/spawn-async';
|
|
2
|
-
import
|
|
2
|
+
import { Definitions } from 'dot';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
|
|
6
6
|
import BundlerController from './BundlerController';
|
|
7
|
-
import
|
|
7
|
+
import { Application, DetoxTest } from './Config';
|
|
8
8
|
import { Platform } from './Platform';
|
|
9
9
|
import TemplateEvaluator from './TemplateEvaluator';
|
|
10
|
-
import
|
|
11
|
-
import { TemplateFilesFactory, UserFile } from './TemplateFile';
|
|
10
|
+
import { ProjectFile, TemplateFilesFactory, UserFile } from './TemplateFile';
|
|
12
11
|
import { killVirtualDevicesAsync } from './Utils';
|
|
13
12
|
|
|
14
13
|
export default class TemplateProject {
|
package/src/Utils.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import spawnAsync from '@expo/spawn-async';
|
|
2
|
+
import { spawnSync } from 'child_process';
|
|
2
3
|
|
|
3
4
|
import { Platform } from './Platform';
|
|
4
5
|
|
|
6
|
+
export function yarnInstall(path: string) {
|
|
7
|
+
spawnSync('yarn', ['install', '--silent'], { stdio: 'inherit', cwd: path });
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
export const delay: (ms: number) => Promise<void> = (ms) =>
|
|
6
11
|
new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
12
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import { CommanderStatic } from 'commander';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { Config } from '../Config';
|
|
5
5
|
import TemplateProject from '../TemplateProject';
|
|
6
|
-
import
|
|
7
|
-
import { registerCommand } from '../registerCommand';
|
|
6
|
+
import { DefaultOptions, registerCommand } from '../registerCommand';
|
|
8
7
|
|
|
9
8
|
interface CreateProjectOptions extends DefaultOptions {
|
|
10
9
|
app: string;
|
|
@@ -13,14 +12,14 @@ interface CreateProjectOptions extends DefaultOptions {
|
|
|
13
12
|
async function createProjectAsync(config: Config, options: CreateProjectOptions) {
|
|
14
13
|
const app = config.applications[options.app];
|
|
15
14
|
|
|
16
|
-
if (app
|
|
15
|
+
if (app.preset === 'detox') {
|
|
17
16
|
console.log(`Using ${chalk.green('detox')} preset.`);
|
|
18
17
|
const preset = new TemplateProject(app, options.app, options.platform, options.configFile);
|
|
19
18
|
|
|
20
19
|
console.log(`Creating test app in ${chalk.green(options.path)}.`);
|
|
21
20
|
await preset.createApplicationAsync(options.path);
|
|
22
21
|
} else {
|
|
23
|
-
throw new Error(`Unknown preset: ${app
|
|
22
|
+
throw new Error(`Unknown preset: ${app.preset}`);
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
package/src/commands/RunTest.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import { CommanderStatic } from 'commander';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { Application, Config } from '../Config';
|
|
6
6
|
import TemplateProject from '../TemplateProject';
|
|
7
|
-
import
|
|
8
|
-
import { registerCommand } from '../registerCommand';
|
|
7
|
+
import { DefaultOptions, registerCommand } from '../registerCommand';
|
|
9
8
|
|
|
10
9
|
interface RunTestOptions extends DefaultOptions {
|
|
11
10
|
test: string;
|
|
@@ -15,7 +14,7 @@ function findTest(config: Config, test: string): [string, Application] {
|
|
|
15
14
|
for (const appName in config.applications) {
|
|
16
15
|
const app = config.applications[appName];
|
|
17
16
|
|
|
18
|
-
for (const testName in app
|
|
17
|
+
for (const testName in app.tests) {
|
|
19
18
|
if (test === testName) {
|
|
20
19
|
return [appName, app];
|
|
21
20
|
}
|
|
@@ -29,10 +28,6 @@ async function runTestAsync(config: Config, options: RunTestOptions) {
|
|
|
29
28
|
const [appName, app] = findTest(config, options.test);
|
|
30
29
|
const test = app.tests[options.test];
|
|
31
30
|
|
|
32
|
-
if (test == null) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
31
|
if (app.preset === 'detox') {
|
|
37
32
|
console.log(`Using ${chalk.green('detox')} preset.`);
|
|
38
33
|
const preset = new TemplateProject(app, appName, options.platform, options.configFile);
|
package/src/registerCommand.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CommanderStatic } from 'commander';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { Config } from './Config';
|
|
4
4
|
import ConfigReader from './ConfigReader';
|
|
5
5
|
import { temporaryDirectory } from './Paths';
|
|
6
6
|
import { Platform } from './Platform';
|