Skip to content

Commit 54efbfd

Browse files
authored
feature(preview): add qr-target and use proper QR codes for expo-go and dev-build (#247)
* fix(preview): use app slug to generate proper EAS Update preview * ci(test): remove faulty implemented test case for app schemes * chore: add jest snapshot workaround for prettier v2 See https://jestjs.io/docs/configuration/\#prettierpath-string * chore(preview): rebuild preview subaction * fix(preview): allow users to force EAS Update QR codes to Expo Go * refactor(preview): use `qr-target` with automatically inferred value instead of `expo-go` * chore: rebuild files * refactor(preview): use `dev-build` instead of `dev-client` and validate input * chore: rebuild files * test(preview): add e2e test for infered `dev-build` qr code
1 parent ccfad6f commit 54efbfd

15 files changed

Lines changed: 653 additions & 126 deletions

File tree

.github/workflows/test.yml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ jobs:
8484
- name: 🏗 Setup project
8585
run: bun create expo ./temp --template blank
8686

87+
- name: 🏗 Setup `expo-dev-client`
88+
working-directory: ./temp
89+
run: bun expo install expo-dev-client
90+
8791
- name: 👷 Configure project
8892
working-directory: ./temp
8993
run: |
@@ -165,27 +169,49 @@ jobs:
165169
throw new Error('Message output is empty');
166170
}
167171
168-
- name: 🚀 Create preview (with custom app scheme)
172+
- name: 🚀 Create preview (with "dev-build" QR target)
169173
if: ${{ env.hasAuth == 'true' }}
170174
uses: ./preview
171-
id: custom-app-scheme
175+
id: dev-build-qr
172176
env:
173177
EXPO_TEST_GITHUB_PULL: 206
174178
with:
175-
app-scheme: thisisacustomscheme
176179
working-directory: ./temp
177180
command: eas update --branch test --message "This is a test"
178181
comment: false
179182

180-
- name: 🧪 Comment has custom app scheme
183+
- name: 🧪 Comment has "dev-build" QR
181184
if: ${{ env.hasAuth == 'true' }}
182185
uses: actions/github-script@v7
183186
with:
184187
script: |
185-
const comment = `${{ steps.custom-app-scheme.outputs.comment }}`
186-
if (!comment || !comment.includes('thisisacustomscheme')) {
187-
console.log({ comment });
188-
throw new Error('Message output does not include the app scheme from action input');
188+
const qrUrl = `${{ steps.dev-build-qr.outputs.qr }}`
189+
if (!qrUrl || !qrUrl.includes('appScheme')) {
190+
console.log({ qrUrl });
191+
throw new Error('QR URL is missing "appScheme" to point to a dev build');
192+
}
193+
194+
- name: 🚀 Create preview (with "expo-go" QR target from input)
195+
if: ${{ env.hasAuth == 'true' }}
196+
uses: ./preview
197+
id: expo-go-qr
198+
env:
199+
EXPO_TEST_GITHUB_PULL: 206
200+
with:
201+
working-directory: ./temp
202+
qr-target: expo-go
203+
command: eas update --branch test --message "This is a test"
204+
comment: false
205+
206+
- name: 🧪 Comment has "expo-go" QR code
207+
if: ${{ env.hasAuth == 'true' }}
208+
uses: actions/github-script@v7
209+
with:
210+
script: |
211+
const qrUrl = `${{ steps.expo-go-qr.outputs.qr }}`
212+
if (!qrUrl || qrUrl.includes('appScheme')) {
213+
console.log({ qrUrl });
214+
throw new Error('QR URL points to a dev build, not Expo Go');
189215
}
190216
191217
preview-comment:

build/command/index.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38691,16 +38691,20 @@ function createBuildComment(builds) {
3869138691
/***/ }),
3869238692

3869338693
/***/ 2489:
38694-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
38694+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3869538695

3869638696
"use strict";
3869738697

38698+
var __importDefault = (this && this.__importDefault) || function (mod) {
38699+
return (mod && mod.__esModule) ? mod : { "default": mod };
38700+
};
3869838701
Object.defineProperty(exports, "__esModule", ({ value: true }));
38699-
exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0;
38702+
exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0;
3870038703
const core_1 = __nccwpck_require__(2186);
3870138704
const exec_1 = __nccwpck_require__(1514);
3870238705
const io_1 = __nccwpck_require__(7436);
3870338706
const assert_1 = __nccwpck_require__(9491);
38707+
const path_1 = __importDefault(__nccwpck_require__(1017));
3870438708
const url_1 = __nccwpck_require__(7310);
3870538709
var AppPlatform;
3870638710
(function (AppPlatform) {
@@ -38869,6 +38873,27 @@ async function projectInfo(dir) {
3886938873
return { name, slug, owner };
3887038874
}
3887138875
exports.projectInfo = projectInfo;
38876+
/**
38877+
* Determine if the current project is using `dev-build` or `expo-go`.
38878+
* This is based on the `@expo/cli` check to enable dev client mode.
38879+
*
38880+
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
38881+
*/
38882+
function projectAppType(dir) {
38883+
const packageFile = path_1.default.resolve(dir, 'package.json');
38884+
let packageJson = {};
38885+
try {
38886+
packageJson = require(packageFile);
38887+
}
38888+
catch (error) {
38889+
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
38890+
}
38891+
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
38892+
return 'dev-build';
38893+
}
38894+
return 'expo-go';
38895+
}
38896+
exports.projectAppType = projectAppType;
3887238897
/**
3887338898
* Create a QR code for an update on project, with an optional release channel.
3887438899
*/

build/preview-build/index.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89233,16 +89233,20 @@ exports.handleCacheError = handleCacheError;
8923389233
/***/ }),
8923489234

8923589235
/***/ 2489:
89236-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
89236+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
8923789237

8923889238
"use strict";
8923989239

89240+
var __importDefault = (this && this.__importDefault) || function (mod) {
89241+
return (mod && mod.__esModule) ? mod : { "default": mod };
89242+
};
8924089243
Object.defineProperty(exports, "__esModule", ({ value: true }));
89241-
exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0;
89244+
exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0;
8924289245
const core_1 = __nccwpck_require__(2186);
8924389246
const exec_1 = __nccwpck_require__(1514);
8924489247
const io_1 = __nccwpck_require__(7436);
8924589248
const assert_1 = __nccwpck_require__(9491);
89249+
const path_1 = __importDefault(__nccwpck_require__(1017));
8924689250
const url_1 = __nccwpck_require__(7310);
8924789251
var AppPlatform;
8924889252
(function (AppPlatform) {
@@ -89411,6 +89415,27 @@ async function projectInfo(dir) {
8941189415
return { name, slug, owner };
8941289416
}
8941389417
exports.projectInfo = projectInfo;
89418+
/**
89419+
* Determine if the current project is using `dev-build` or `expo-go`.
89420+
* This is based on the `@expo/cli` check to enable dev client mode.
89421+
*
89422+
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
89423+
*/
89424+
function projectAppType(dir) {
89425+
const packageFile = path_1.default.resolve(dir, 'package.json');
89426+
let packageJson = {};
89427+
try {
89428+
packageJson = require(packageFile);
89429+
}
89430+
catch (error) {
89431+
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
89432+
}
89433+
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
89434+
return 'dev-build';
89435+
}
89436+
return 'expo-go';
89437+
}
89438+
exports.projectAppType = projectAppType;
8941489439
/**
8941589440
* Create a QR code for an update on project, with an optional release channel.
8941689441
*/

build/preview-comment/index.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38635,16 +38635,20 @@ exports.commentAction = commentAction;
3863538635
/***/ }),
3863638636

3863738637
/***/ 2489:
38638-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
38638+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
3863938639

3864038640
"use strict";
3864138641

38642+
var __importDefault = (this && this.__importDefault) || function (mod) {
38643+
return (mod && mod.__esModule) ? mod : { "default": mod };
38644+
};
3864238645
Object.defineProperty(exports, "__esModule", ({ value: true }));
38643-
exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0;
38646+
exports.getBuildLogsUrl = exports.projectDeepLink = exports.projectLink = exports.projectQR = exports.projectAppType = exports.projectInfo = exports.queryEasBuildInfoAsync = exports.cancelEasBuildAsync = exports.createEasBuildFromRawCommandAsync = exports.easBuild = exports.runCommand = exports.projectOwner = exports.authenticate = exports.parseCommand = exports.appPlatformEmojis = exports.appPlatformDisplayNames = exports.AppPlatform = void 0;
3864438647
const core_1 = __nccwpck_require__(2186);
3864538648
const exec_1 = __nccwpck_require__(1514);
3864638649
const io_1 = __nccwpck_require__(7436);
3864738650
const assert_1 = __nccwpck_require__(9491);
38651+
const path_1 = __importDefault(__nccwpck_require__(1017));
3864838652
const url_1 = __nccwpck_require__(7310);
3864938653
var AppPlatform;
3865038654
(function (AppPlatform) {
@@ -38813,6 +38817,27 @@ async function projectInfo(dir) {
3881338817
return { name, slug, owner };
3881438818
}
3881538819
exports.projectInfo = projectInfo;
38820+
/**
38821+
* Determine if the current project is using `dev-build` or `expo-go`.
38822+
* This is based on the `@expo/cli` check to enable dev client mode.
38823+
*
38824+
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
38825+
*/
38826+
function projectAppType(dir) {
38827+
const packageFile = path_1.default.resolve(dir, 'package.json');
38828+
let packageJson = {};
38829+
try {
38830+
packageJson = require(packageFile);
38831+
}
38832+
catch (error) {
38833+
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
38834+
}
38835+
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
38836+
return 'dev-build';
38837+
}
38838+
return 'expo-go';
38839+
}
38840+
exports.projectAppType = projectAppType;
3881638841
/**
3881738842
* Create a QR code for an update on project, with an optional release channel.
3881838843
*/

0 commit comments

Comments
 (0)