diff --git a/build/command/index.js b/build/command/index.js index d6d7de9b..c12e42a8 100644 --- a/build/command/index.js +++ b/build/command/index.js @@ -20526,6 +20526,9 @@ async function easBuild(cmd) { } return JSON.parse(stdout); } +/** + * Create an new EAS build using the user-provided command. + */ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { let stdout = ''; let cmd = command; @@ -20548,6 +20551,9 @@ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { } return JSON.parse(stdout); } +/** + * Cancel an EAS build. + */ async function cancelEasBuildAsync(cwd, buildId) { try { await getExecOutput(await which('eas', true), ['build:cancel', buildId], { cwd }); @@ -20556,6 +20562,20 @@ async function cancelEasBuildAsync(cwd, buildId) { info(`Failed to cancel build ${buildId}: ${errorMessage(e)}`); } } +/** + * Query the EAS BuildInfo from given buildId. + */ +async function queryEasBuildInfoAsync(cwd, buildId) { + try { + const { stdout } = await getExecOutput(await which('eas', true), ['build:show', buildId, '--json'], { + cwd, + silent: true, + }); + return JSON.parse(stdout); + } + catch { } + return null; +} /** * Try to resolve the project info, by running 'expo config --type prebuild'. */ diff --git a/build/fingerprint-post/index.js b/build/fingerprint-post/index.js index a92bc0e0..e0cf6a42 100644 --- a/build/fingerprint-post/index.js +++ b/build/fingerprint-post/index.js @@ -75829,6 +75829,9 @@ class FingerprintDbManager_FingerprintDbManager { for (const index of FingerprintDbManager_FingerprintDbManager.INDEXES) { await db.runAsync(index); } + for (const extraStatement of FingerprintDbManager_FingerprintDbManager.EXTRA_CREATE_DB_STATEMENTS) { + await db.runAsync(extraStatement); + } await db.runAsync(`PRAGMA fingerprint_schema_version = ${FingerprintDbManager_FingerprintDbManager.SCHEMA_VERSION}`); this.db = db; return db; @@ -75849,6 +75852,18 @@ class FingerprintDbManager_FingerprintDbManager { const rows = await this.db.allAsync(`SELECT eas_build_id FROM ${FingerprintDbManager_FingerprintDbManager.TABLE_NAME} WHERE fingerprint_hash = ?`, fingerprintHash); return rows.map(row => row['eas_build_id']); } + /** + * Get the latest entity from the fingerprint hash where the eas_build_id is not null. + */ + async getLatestEasEntityFromFingerprintAsync(fingerprintHash) { + if (!this.db) { + throw new Error('Database not initialized. Call initAsync() first.'); + } + const row = await this.db.getAsync(`SELECT * FROM ${FingerprintDbManager_FingerprintDbManager.TABLE_NAME} + WHERE eas_build_id IS NOT NULL AND eas_build_id != "" AND fingerprint_hash = ? + ORDER BY updated_at DESC LIMIT 1`, fingerprintHash); + return row ? FingerprintDbManager_FingerprintDbManager.serialize(row) : null; + } async getEntityFromGitCommitHashAsync(gitCommitHash) { if (!this.db) { throw new Error('Database not initialized. Call initAsync() first.'); @@ -75893,11 +75908,19 @@ class FingerprintDbManager_FingerprintDbManager { 'git_commit_hash TEXT NOT NULL', 'fingerprint_hash TEXT NOT NULL', 'fingerprint TEXT NOT NULL', + "created_at TEXT NOT NULL DEFAULT (DATETIME('now', 'utc'))", + "updated_at TEXT NOT NULL DEFAULT (DATETIME('now', 'utc'))", ])); - static INDEXES = (/* unused pure expression or super */ null && ([ - 'CREATE UNIQUE INDEX IF NOT EXISTS idx_git_commit_hash ON fingerprint (git_commit_hash)', - 'CREATE INDEX IF NOT EXISTS idx_fingerprint_hash ON fingerprint (fingerprint_hash)', - ])); + static INDEXES = [ + `CREATE UNIQUE INDEX IF NOT EXISTS idx_git_commit_hash ON ${this.TABLE_NAME} (git_commit_hash)`, + `CREATE INDEX IF NOT EXISTS idx_fingerprint_hash ON ${this.TABLE_NAME} (fingerprint_hash)`, + ]; + static EXTRA_CREATE_DB_STATEMENTS = [ + `CREATE TRIGGER IF NOT EXISTS update_fingerprint_updated_at AFTER UPDATE ON ${this.TABLE_NAME} +BEGIN + UPDATE ${this.TABLE_NAME} SET updated_at = DATETIME('now', 'utc') WHERE id = NEW.id; +END`, + ]; db = null; static serialize(rawEntity) { return { @@ -75906,6 +75929,8 @@ class FingerprintDbManager_FingerprintDbManager { gitCommitHash: rawEntity.git_commit_hash, fingerprintHash: rawEntity.fingerprint_hash, fingerprint: JSON.parse(rawEntity.fingerprint), + createdAt: rawEntity.created_at, + updatedAt: rawEntity.updated_at, }; } } diff --git a/build/fingerprint/index.js b/build/fingerprint/index.js index f0a92617..7bc09365 100644 --- a/build/fingerprint/index.js +++ b/build/fingerprint/index.js @@ -75852,6 +75852,9 @@ class FingerprintDbManager { for (const index of FingerprintDbManager.INDEXES) { await db.runAsync(index); } + for (const extraStatement of FingerprintDbManager.EXTRA_CREATE_DB_STATEMENTS) { + await db.runAsync(extraStatement); + } await db.runAsync(`PRAGMA fingerprint_schema_version = ${FingerprintDbManager.SCHEMA_VERSION}`); this.db = db; return db; @@ -75872,6 +75875,18 @@ class FingerprintDbManager { const rows = await this.db.allAsync(`SELECT eas_build_id FROM ${FingerprintDbManager.TABLE_NAME} WHERE fingerprint_hash = ?`, fingerprintHash); return rows.map(row => row['eas_build_id']); } + /** + * Get the latest entity from the fingerprint hash where the eas_build_id is not null. + */ + async getLatestEasEntityFromFingerprintAsync(fingerprintHash) { + if (!this.db) { + throw new Error('Database not initialized. Call initAsync() first.'); + } + const row = await this.db.getAsync(`SELECT * FROM ${FingerprintDbManager.TABLE_NAME} + WHERE eas_build_id IS NOT NULL AND eas_build_id != "" AND fingerprint_hash = ? + ORDER BY updated_at DESC LIMIT 1`, fingerprintHash); + return row ? FingerprintDbManager.serialize(row) : null; + } async getEntityFromGitCommitHashAsync(gitCommitHash) { if (!this.db) { throw new Error('Database not initialized. Call initAsync() first.'); @@ -75916,10 +75931,18 @@ class FingerprintDbManager { 'git_commit_hash TEXT NOT NULL', 'fingerprint_hash TEXT NOT NULL', 'fingerprint TEXT NOT NULL', + "created_at TEXT NOT NULL DEFAULT (DATETIME('now', 'utc'))", + "updated_at TEXT NOT NULL DEFAULT (DATETIME('now', 'utc'))", ]; static INDEXES = [ - 'CREATE UNIQUE INDEX IF NOT EXISTS idx_git_commit_hash ON fingerprint (git_commit_hash)', - 'CREATE INDEX IF NOT EXISTS idx_fingerprint_hash ON fingerprint (fingerprint_hash)', + `CREATE UNIQUE INDEX IF NOT EXISTS idx_git_commit_hash ON ${this.TABLE_NAME} (git_commit_hash)`, + `CREATE INDEX IF NOT EXISTS idx_fingerprint_hash ON ${this.TABLE_NAME} (fingerprint_hash)`, + ]; + static EXTRA_CREATE_DB_STATEMENTS = [ + `CREATE TRIGGER IF NOT EXISTS update_fingerprint_updated_at AFTER UPDATE ON ${this.TABLE_NAME} +BEGIN + UPDATE ${this.TABLE_NAME} SET updated_at = DATETIME('now', 'utc') WHERE id = NEW.id; +END`, ]; db = null; static serialize(rawEntity) { @@ -75929,6 +75952,8 @@ class FingerprintDbManager { gitCommitHash: rawEntity.git_commit_hash, fingerprintHash: rawEntity.fingerprint_hash, fingerprint: JSON.parse(rawEntity.fingerprint), + createdAt: rawEntity.created_at, + updatedAt: rawEntity.updated_at, }; } } diff --git a/build/preview-build/index.js b/build/preview-build/index.js index 7b4d25a2..558de64c 100644 --- a/build/preview-build/index.js +++ b/build/preview-build/index.js @@ -75851,6 +75851,9 @@ async function easBuild(cmd) { } return JSON.parse(stdout); } +/** + * Create an new EAS build using the user-provided command. + */ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { let stdout = ''; let cmd = command; @@ -75873,6 +75876,9 @@ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { } return JSON.parse(stdout); } +/** + * Cancel an EAS build. + */ async function cancelEasBuildAsync(cwd, buildId) { try { await (0,lib_exec.getExecOutput)(await (0,io.which)('eas', true), ['build:cancel', buildId], { cwd }); @@ -75881,6 +75887,20 @@ async function cancelEasBuildAsync(cwd, buildId) { (0,core.info)(`Failed to cancel build ${buildId}: ${utils_errorMessage(e)}`); } } +/** + * Query the EAS BuildInfo from given buildId. + */ +async function queryEasBuildInfoAsync(cwd, buildId) { + try { + const { stdout } = await (0,lib_exec.getExecOutput)(await (0,io.which)('eas', true), ['build:show', buildId, '--json'], { + cwd, + silent: true, + }); + return JSON.parse(stdout); + } + catch { } + return null; +} /** * Try to resolve the project info, by running 'expo config --type prebuild'. */ @@ -76060,6 +76080,9 @@ class FingerprintDbManager { for (const index of FingerprintDbManager.INDEXES) { await db.runAsync(index); } + for (const extraStatement of FingerprintDbManager.EXTRA_CREATE_DB_STATEMENTS) { + await db.runAsync(extraStatement); + } await db.runAsync(`PRAGMA fingerprint_schema_version = ${FingerprintDbManager.SCHEMA_VERSION}`); this.db = db; return db; @@ -76080,6 +76103,18 @@ class FingerprintDbManager { const rows = await this.db.allAsync(`SELECT eas_build_id FROM ${FingerprintDbManager.TABLE_NAME} WHERE fingerprint_hash = ?`, fingerprintHash); return rows.map(row => row['eas_build_id']); } + /** + * Get the latest entity from the fingerprint hash where the eas_build_id is not null. + */ + async getLatestEasEntityFromFingerprintAsync(fingerprintHash) { + if (!this.db) { + throw new Error('Database not initialized. Call initAsync() first.'); + } + const row = await this.db.getAsync(`SELECT * FROM ${FingerprintDbManager.TABLE_NAME} + WHERE eas_build_id IS NOT NULL AND eas_build_id != "" AND fingerprint_hash = ? + ORDER BY updated_at DESC LIMIT 1`, fingerprintHash); + return row ? FingerprintDbManager.serialize(row) : null; + } async getEntityFromGitCommitHashAsync(gitCommitHash) { if (!this.db) { throw new Error('Database not initialized. Call initAsync() first.'); @@ -76124,10 +76159,18 @@ class FingerprintDbManager { 'git_commit_hash TEXT NOT NULL', 'fingerprint_hash TEXT NOT NULL', 'fingerprint TEXT NOT NULL', + "created_at TEXT NOT NULL DEFAULT (DATETIME('now', 'utc'))", + "updated_at TEXT NOT NULL DEFAULT (DATETIME('now', 'utc'))", ]; static INDEXES = [ - 'CREATE UNIQUE INDEX IF NOT EXISTS idx_git_commit_hash ON fingerprint (git_commit_hash)', - 'CREATE INDEX IF NOT EXISTS idx_fingerprint_hash ON fingerprint (fingerprint_hash)', + `CREATE UNIQUE INDEX IF NOT EXISTS idx_git_commit_hash ON ${this.TABLE_NAME} (git_commit_hash)`, + `CREATE INDEX IF NOT EXISTS idx_fingerprint_hash ON ${this.TABLE_NAME} (fingerprint_hash)`, + ]; + static EXTRA_CREATE_DB_STATEMENTS = [ + `CREATE TRIGGER IF NOT EXISTS update_fingerprint_updated_at AFTER UPDATE ON ${this.TABLE_NAME} +BEGIN + UPDATE ${this.TABLE_NAME} SET updated_at = DATETIME('now', 'utc') WHERE id = NEW.id; +END`, ]; db = null; static serialize(rawEntity) { @@ -76137,6 +76180,8 @@ class FingerprintDbManager { gitCommitHash: rawEntity.git_commit_hash, fingerprintHash: rawEntity.fingerprint_hash, fingerprint: JSON.parse(rawEntity.fingerprint), + createdAt: rawEntity.created_at, + updatedAt: rawEntity.updated_at, }; } } @@ -76330,7 +76375,11 @@ async function previewAction(input = collectPreviewBuildActionInput()) { await maybeCancelPreviousBuildsAsync(config, input); const variables = getVariables(config, []); const messageId = template(input.commentId, variables); - const messageBody = createMessageBodyFingerprintCompatible(); + const latestEasEntity = await dbManager.getLatestEasEntityFromFingerprintAsync(currentFingerprint.hash); + const latestEasBuildInfo = latestEasEntity?.easBuildId + ? await queryEasBuildInfoAsync(input.workingDirectory, latestEasEntity.easBuildId) + : null; + const messageBody = createMessageBodyFingerprintCompatible(latestEasBuildInfo); await maybeCreateCommentAsync(input, messageId, messageBody); setOutputs(variables, messageId, messageBody); return; @@ -76481,9 +76530,13 @@ function createMessageBodyInBuilding(builds, fingerprintDiff, input) { `> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview-build#example-workflows)`, ].join('\n'); } -function createMessageBodyFingerprintCompatible() { +function createMessageBodyFingerprintCompatible(latestEasBuildInfo) { + const easBuildMessage = latestEasBuildInfo != null + ? `Latest compatible build on EAS found. You can download the build from ${getBuildLogsUrl(latestEasBuildInfo)}.` + : 'Unable to find a compatible build on EAS.'; return [ `Fingerprint is compatible, no new builds are required.`, + easBuildMessage, '', `> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview-build#example-workflows)`, ].join('\n'); diff --git a/build/preview-comment/index.js b/build/preview-comment/index.js index d7a43d6a..e6d5e150 100644 --- a/build/preview-comment/index.js +++ b/build/preview-comment/index.js @@ -20527,6 +20527,9 @@ async function easBuild(cmd) { } return JSON.parse(stdout); } +/** + * Create an new EAS build using the user-provided command. + */ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { let stdout = ''; let cmd = command; @@ -20549,6 +20552,9 @@ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { } return JSON.parse(stdout); } +/** + * Cancel an EAS build. + */ async function cancelEasBuildAsync(cwd, buildId) { try { await getExecOutput(await which('eas', true), ['build:cancel', buildId], { cwd }); @@ -20557,6 +20563,20 @@ async function cancelEasBuildAsync(cwd, buildId) { info(`Failed to cancel build ${buildId}: ${errorMessage(e)}`); } } +/** + * Query the EAS BuildInfo from given buildId. + */ +async function queryEasBuildInfoAsync(cwd, buildId) { + try { + const { stdout } = await getExecOutput(await which('eas', true), ['build:show', buildId, '--json'], { + cwd, + silent: true, + }); + return JSON.parse(stdout); + } + catch { } + return null; +} /** * Try to resolve the project info, by running 'expo config --type prebuild'. */ diff --git a/build/setup/index.js b/build/setup/index.js index dfae4a07..6734f060 100644 --- a/build/setup/index.js +++ b/build/setup/index.js @@ -75810,6 +75810,9 @@ async function easBuild(cmd) { } return JSON.parse(stdout); } +/** + * Create an new EAS build using the user-provided command. + */ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { let stdout = ''; let cmd = command; @@ -75832,6 +75835,9 @@ async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) { } return JSON.parse(stdout); } +/** + * Cancel an EAS build. + */ async function cancelEasBuildAsync(cwd, buildId) { try { await getExecOutput(await which('eas', true), ['build:cancel', buildId], { cwd }); @@ -75840,6 +75846,20 @@ async function cancelEasBuildAsync(cwd, buildId) { info(`Failed to cancel build ${buildId}: ${errorMessage(e)}`); } } +/** + * Query the EAS BuildInfo from given buildId. + */ +async function queryEasBuildInfoAsync(cwd, buildId) { + try { + const { stdout } = await getExecOutput(await which('eas', true), ['build:show', buildId, '--json'], { + cwd, + silent: true, + }); + return JSON.parse(stdout); + } + catch { } + return null; +} /** * Try to resolve the project info, by running 'expo config --type prebuild'. */