also looking at this
fix(android): recover remote loads after connectivity returns
#265
4 files
+130
-11
| @@ -1,4 +1,4 @@ | ||
| 1 | import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' | |
| 1 | import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs' | |
| 2 | 2 | import { tmpdir } from 'node:os' |
| 3 | 3 | import { dirname, join } from 'node:path' |
| 4 | 4 | import { fileURLToPath } from 'node:url' |
| @@ -13,10 +13,13 @@ interface CompileFixture { | ||
| 13 | 13 | |
| 14 | 14 | const scriptDirectory = dirname(fileURLToPath(import.meta.url)) |
| 15 | 15 | const packageDirectory = dirname(scriptDirectory) |
| 16 | const permissionTestTemplate = readFileSync( | |
| 17 | join(packageDirectory, 'compile-fixtures/CraftPermissionPolicyTest.kt'), | |
| 18 | 'utf8', | |
| 19 | ) | |
| 16 | const compileFixtureDirectory = join(packageDirectory, 'compile-fixtures') | |
| 17 | const compileTestTemplates = readdirSync(compileFixtureDirectory, { withFileTypes: true }) | |
| 18 | .filter(entry => entry.isFile() && entry.name.endsWith('Test.kt')) | |
| 19 | .map(entry => ({ | |
| 20 | name: entry.name, | |
| 21 | source: readFileSync(join(compileFixtureDirectory, entry.name), 'utf8'), | |
| 22 | })) | |
| 20 | 23 | const gradleExecutable = process.env.GRADLE_EXECUTABLE || 'gradle' |
| 21 | 24 | const keepProjects = process.argv.includes('--keep') |
| 22 | 25 | const workspace = mkdtempSync(join(tmpdir(), 'craft-android-templates-')) |
| @@ -92,10 +95,12 @@ try { | ||
| 92 | 95 | fixture.packageName.replaceAll('.', '/'), |
| 93 | 96 | ) |
| 94 | 97 | mkdirSync(testDirectory, { recursive: true }) |
| 95 | writeFileSync( | |
| 96 | join(testDirectory, 'CraftPermissionPolicyTest.kt'), | |
| 97 | permissionTestTemplate.replaceAll('', fixture.packageName), | |
| 98 | ) | |
| 98 | for (const testTemplate of compileTestTemplates) { | |
| 99 | writeFileSync( | |
| 100 | join(testDirectory, testTemplate.name), | |
| 101 | testTemplate.source.replaceAll('', fixture.packageName), | |
| 102 | ) | |
| 103 | } | |
| 99 | 104 | |
| 100 | 105 | console.log(`\nCompiling generated Android fixture: ${fixture.name}`) |
| 101 | 106 | const result = Bun.spawnSync([ |