mirror of
https://github.com/expo/expo-github-action.git
synced 2026-11-15 17:32:45 -10:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
797ca3ff98 | ||
|
|
307c27c7a9 | ||
|
|
d4168c8daa | ||
|
|
e0e47bd675 | ||
|
|
22249fe923 | ||
|
|
acdaed5331 | ||
|
|
2c3d3e742c | ||
|
|
ce8a6fbb9a | ||
|
|
d503f52472 | ||
|
|
4a743ff152 | ||
|
|
75066e8b08 |
No files matched your search
@@ -84,6 +84,10 @@ jobs:
|
||||
- name: 🏗 Setup project
|
||||
run: bun create expo ./temp --template blank
|
||||
|
||||
- name: 🏗 Setup `expo-dev-client`
|
||||
working-directory: ./temp
|
||||
run: bun expo install expo-dev-client
|
||||
|
||||
- name: 👷 Configure project
|
||||
working-directory: ./temp
|
||||
run: |
|
||||
@@ -165,27 +169,49 @@ jobs:
|
||||
throw new Error('Message output is empty');
|
||||
}
|
||||
|
||||
- name: 🚀 Create preview (with custom app scheme)
|
||||
- name: 🚀 Create preview (with "dev-build" QR target)
|
||||
if: ${{ env.hasAuth == 'true' }}
|
||||
uses: ./preview
|
||||
id: custom-app-scheme
|
||||
id: dev-build-qr
|
||||
env:
|
||||
EXPO_TEST_GITHUB_PULL: 206
|
||||
with:
|
||||
app-scheme: thisisacustomscheme
|
||||
working-directory: ./temp
|
||||
command: eas update --branch test --message "This is a test"
|
||||
comment: false
|
||||
|
||||
- name: 🧪 Comment has custom app scheme
|
||||
- name: 🧪 Comment has "dev-build" QR
|
||||
if: ${{ env.hasAuth == 'true' }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const comment = `${{ steps.custom-app-scheme.outputs.comment }}`
|
||||
if (!comment || !comment.includes('thisisacustomscheme')) {
|
||||
console.log({ comment });
|
||||
throw new Error('Message output does not include the app scheme from action input');
|
||||
const qrUrl = `${{ steps.dev-build-qr.outputs.qr }}`
|
||||
if (!qrUrl || !qrUrl.includes('appScheme')) {
|
||||
console.log({ qrUrl });
|
||||
throw new Error('QR URL is missing "appScheme" to point to a dev build');
|
||||
}
|
||||
|
||||
- name: 🚀 Create preview (with "expo-go" QR target from input)
|
||||
if: ${{ env.hasAuth == 'true' }}
|
||||
uses: ./preview
|
||||
id: expo-go-qr
|
||||
env:
|
||||
EXPO_TEST_GITHUB_PULL: 206
|
||||
with:
|
||||
working-directory: ./temp
|
||||
qr-target: expo-go
|
||||
command: eas update --branch test --message "This is a test"
|
||||
comment: false
|
||||
|
||||
- name: 🧪 Comment has "expo-go" QR code
|
||||
if: ${{ env.hasAuth == 'true' }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const qrUrl = `${{ steps.expo-go-qr.outputs.qr }}`
|
||||
if (!qrUrl || qrUrl.includes('appScheme')) {
|
||||
console.log({ qrUrl });
|
||||
throw new Error('QR URL points to a dev build, not Expo Go');
|
||||
}
|
||||
|
||||
preview-comment:
|
||||
|
||||
+27
-2
@@ -38691,16 +38691,20 @@ function createBuildComment(builds) {
|
||||
/***/ }),
|
||||
|
||||
/***/ 2489:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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;
|
||||
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;
|
||||
const core_1 = __nccwpck_require__(2186);
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const io_1 = __nccwpck_require__(7436);
|
||||
const assert_1 = __nccwpck_require__(9491);
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
var AppPlatform;
|
||||
(function (AppPlatform) {
|
||||
@@ -38869,6 +38873,27 @@ async function projectInfo(dir) {
|
||||
return { name, slug, owner };
|
||||
}
|
||||
exports.projectInfo = projectInfo;
|
||||
/**
|
||||
* Determine if the current project is using `dev-build` or `expo-go`.
|
||||
* This is based on the `@expo/cli` check to enable dev client mode.
|
||||
*
|
||||
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
|
||||
*/
|
||||
function projectAppType(dir) {
|
||||
const packageFile = path_1.default.resolve(dir, 'package.json');
|
||||
let packageJson = {};
|
||||
try {
|
||||
packageJson = require(packageFile);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
|
||||
}
|
||||
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
|
||||
return 'dev-build';
|
||||
}
|
||||
return 'expo-go';
|
||||
}
|
||||
exports.projectAppType = projectAppType;
|
||||
/**
|
||||
* Create a QR code for an update on project, with an optional release channel.
|
||||
*/
|
||||
|
||||
@@ -89233,16 +89233,20 @@ exports.handleCacheError = handleCacheError;
|
||||
/***/ }),
|
||||
|
||||
/***/ 2489:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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;
|
||||
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;
|
||||
const core_1 = __nccwpck_require__(2186);
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const io_1 = __nccwpck_require__(7436);
|
||||
const assert_1 = __nccwpck_require__(9491);
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
var AppPlatform;
|
||||
(function (AppPlatform) {
|
||||
@@ -89411,6 +89415,27 @@ async function projectInfo(dir) {
|
||||
return { name, slug, owner };
|
||||
}
|
||||
exports.projectInfo = projectInfo;
|
||||
/**
|
||||
* Determine if the current project is using `dev-build` or `expo-go`.
|
||||
* This is based on the `@expo/cli` check to enable dev client mode.
|
||||
*
|
||||
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
|
||||
*/
|
||||
function projectAppType(dir) {
|
||||
const packageFile = path_1.default.resolve(dir, 'package.json');
|
||||
let packageJson = {};
|
||||
try {
|
||||
packageJson = require(packageFile);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
|
||||
}
|
||||
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
|
||||
return 'dev-build';
|
||||
}
|
||||
return 'expo-go';
|
||||
}
|
||||
exports.projectAppType = projectAppType;
|
||||
/**
|
||||
* Create a QR code for an update on project, with an optional release channel.
|
||||
*/
|
||||
|
||||
@@ -38635,16 +38635,20 @@ exports.commentAction = commentAction;
|
||||
/***/ }),
|
||||
|
||||
/***/ 2489:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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;
|
||||
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;
|
||||
const core_1 = __nccwpck_require__(2186);
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const io_1 = __nccwpck_require__(7436);
|
||||
const assert_1 = __nccwpck_require__(9491);
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
var AppPlatform;
|
||||
(function (AppPlatform) {
|
||||
@@ -38813,6 +38817,27 @@ async function projectInfo(dir) {
|
||||
return { name, slug, owner };
|
||||
}
|
||||
exports.projectInfo = projectInfo;
|
||||
/**
|
||||
* Determine if the current project is using `dev-build` or `expo-go`.
|
||||
* This is based on the `@expo/cli` check to enable dev client mode.
|
||||
*
|
||||
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
|
||||
*/
|
||||
function projectAppType(dir) {
|
||||
const packageFile = path_1.default.resolve(dir, 'package.json');
|
||||
let packageJson = {};
|
||||
try {
|
||||
packageJson = require(packageFile);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
|
||||
}
|
||||
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
|
||||
return 'dev-build';
|
||||
}
|
||||
return 'expo-go';
|
||||
}
|
||||
exports.projectAppType = projectAppType;
|
||||
/**
|
||||
* Create a QR code for an update on project, with an optional release channel.
|
||||
*/
|
||||
|
||||
+315
-27
@@ -41838,22 +41838,28 @@ try {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createSummary = exports.getSchemeFromConfig = exports.getVariables = exports.previewAction = exports.previewInput = exports.MESSAGE_ID = void 0;
|
||||
exports.createSummary = exports.getSchemesInOrderFromConfig = exports.getQrTarget = exports.getVariables = exports.previewAction = exports.previewInput = exports.MESSAGE_ID = void 0;
|
||||
const core_1 = __nccwpck_require__(2186);
|
||||
const eas_1 = __nccwpck_require__(3251);
|
||||
const expo_1 = __nccwpck_require__(2489);
|
||||
const github_1 = __nccwpck_require__(978);
|
||||
const project_1 = __nccwpck_require__(7191);
|
||||
const utils_1 = __nccwpck_require__(1314);
|
||||
const worker_1 = __nccwpck_require__(8912);
|
||||
exports.MESSAGE_ID = 'projectId:{projectId}';
|
||||
function previewInput() {
|
||||
const qrTarget = (0, core_1.getInput)('qr-target') || undefined;
|
||||
if (qrTarget && !['expo-go', 'dev-client'].includes(qrTarget)) {
|
||||
throw new Error(`Invalid QR code target: "${qrTarget}", expected "expo-go" or "dev-build"`);
|
||||
}
|
||||
return {
|
||||
command: (0, core_1.getInput)('command'),
|
||||
shouldComment: !(0, core_1.getInput)('comment') || (0, core_1.getBooleanInput)('comment'),
|
||||
commentId: (0, core_1.getInput)('comment-id') || exports.MESSAGE_ID,
|
||||
workingDirectory: (0, core_1.getInput)('working-directory'),
|
||||
githubToken: (0, core_1.getInput)('github-token'),
|
||||
appScheme: (0, core_1.getInput)('app-scheme'),
|
||||
// Note, `dev-build` is prefered, but `dev-client` is supported to aovid confusion
|
||||
qrTarget: qrTarget,
|
||||
};
|
||||
}
|
||||
exports.previewInput = previewInput;
|
||||
@@ -41923,22 +41929,25 @@ function sanitizeCommand(input) {
|
||||
/**
|
||||
* Generate useful variables for the message body, and as step outputs.
|
||||
*/
|
||||
function getVariables(config, updates, input) {
|
||||
function getVariables(config, updates, options) {
|
||||
const projectId = config.extra?.eas?.projectId;
|
||||
const android = updates.find(update => update.platform === 'android');
|
||||
const ios = updates.find(update => update.platform === 'ios');
|
||||
const appScheme = input.appScheme || getSchemeFromConfig(config) || '';
|
||||
const appSchemes = getSchemesInOrderFromConfig(config) || [];
|
||||
const appSlug = config.slug;
|
||||
const qrTarget = getQrTarget(options);
|
||||
return {
|
||||
// EAS / Expo specific
|
||||
projectId,
|
||||
projectName: config.name,
|
||||
projectSlug: config.slug,
|
||||
projectScheme: appScheme,
|
||||
projectSlug: appSlug,
|
||||
projectScheme: appSchemes[0] || '', // This is the longest scheme from one or more custom app schemes
|
||||
projectSchemes: JSON.stringify(appSchemes), // These are all custom app schemes, in order from longest to shortest as JSON
|
||||
// Shared update properties
|
||||
// Note, only use these properties when the update groups are identical
|
||||
groupId: updates[0].group,
|
||||
runtimeVersion: updates[0].runtimeVersion,
|
||||
qr: (0, eas_1.getUpdateGroupQr)({ projectId, updateGroupId: updates[0].group, appScheme }),
|
||||
qr: (0, eas_1.getUpdateGroupQr)({ projectId, updateGroupId: updates[0].group, appSlug, qrTarget }),
|
||||
link: (0, eas_1.getUpdateGroupWebsite)({ projectId, updateGroupId: updates[0].group }),
|
||||
// These are safe to access regardless of the update groups
|
||||
branchName: updates[0].branch,
|
||||
@@ -41952,7 +41961,7 @@ function getVariables(config, updates, input) {
|
||||
androidManifestPermalink: android?.manifestPermalink || '',
|
||||
androidMessage: android?.message || '',
|
||||
androidRuntimeVersion: android?.runtimeVersion || '',
|
||||
androidQR: android ? (0, eas_1.getUpdateGroupQr)({ projectId, updateGroupId: android.group, appScheme }) : '',
|
||||
androidQR: android ? (0, eas_1.getUpdateGroupQr)({ projectId, updateGroupId: android.group, appSlug, qrTarget }) : '',
|
||||
androidLink: android ? (0, eas_1.getUpdateGroupWebsite)({ projectId, updateGroupId: android.group }) : '',
|
||||
// iOS update
|
||||
iosId: ios?.id || '',
|
||||
@@ -41961,27 +41970,47 @@ function getVariables(config, updates, input) {
|
||||
iosManifestPermalink: ios?.manifestPermalink || '',
|
||||
iosMessage: ios?.message || '',
|
||||
iosRuntimeVersion: ios?.runtimeVersion || '',
|
||||
iosQR: ios ? (0, eas_1.getUpdateGroupQr)({ projectId, updateGroupId: ios.group, appScheme }) : '',
|
||||
iosQR: ios ? (0, eas_1.getUpdateGroupQr)({ projectId, updateGroupId: ios.group, appSlug, qrTarget }) : '',
|
||||
iosLink: ios ? (0, eas_1.getUpdateGroupWebsite)({ projectId, updateGroupId: ios.group }) : '',
|
||||
};
|
||||
}
|
||||
exports.getVariables = getVariables;
|
||||
/**
|
||||
* Retrieve the app scheme from project config, using the following criteria:
|
||||
* - If the scheme is a string, return that.
|
||||
* - If the scheme is an array, return the longest scheme.
|
||||
*/
|
||||
function getSchemeFromConfig(config) {
|
||||
if (typeof config.scheme === 'string') {
|
||||
return config.scheme;
|
||||
function getQrTarget(input) {
|
||||
if (!input.qrTarget) {
|
||||
const appType = (0, expo_1.projectAppType)(input.workingDirectory);
|
||||
(0, core_1.debug)(`Using inferred QR code target: "${appType}"`);
|
||||
return appType;
|
||||
}
|
||||
if (Array.isArray(config.scheme) && config.scheme.length > 0) {
|
||||
const longestToShortest = config.scheme.sort((a, b) => b.length - a.length);
|
||||
return longestToShortest[0];
|
||||
switch (input.qrTarget) {
|
||||
// Note, `dev-build` is prefered, but `dev-client` is supported to aovid confusion
|
||||
case 'dev-client':
|
||||
case 'dev-build':
|
||||
(0, core_1.debug)(`Using QR code target: "dev-build"`);
|
||||
return 'dev-build';
|
||||
case 'expo-go':
|
||||
(0, core_1.debug)(`Using QR code target: "expo-go"`);
|
||||
return 'expo-go';
|
||||
default:
|
||||
throw new Error(`Invalid QR code target: "${input.qrTarget}", expected "expo-go" or "dev-build"`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.getSchemeFromConfig = getSchemeFromConfig;
|
||||
exports.getQrTarget = getQrTarget;
|
||||
/**
|
||||
* Retrieve the app schemes, in correct priority order, from project config.
|
||||
* - If the scheme is a string, return `[scheme]`.
|
||||
* - If the scheme is an array, return the schemes sorted by length, longest first.
|
||||
* - If the scheme is empty/incorrect, return an empty array.
|
||||
*/
|
||||
function getSchemesInOrderFromConfig(config) {
|
||||
if (typeof config.scheme === 'string') {
|
||||
return [config.scheme];
|
||||
}
|
||||
if (Array.isArray(config.scheme)) {
|
||||
return config.scheme.sort((a, b) => b.length - a.length);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
exports.getSchemesInOrderFromConfig = getSchemesInOrderFromConfig;
|
||||
/**
|
||||
* Generate the message body for a single update.
|
||||
* Note, this is not configurable, but you can use the variables used to construct your own.
|
||||
@@ -42001,12 +42030,12 @@ function createSummaryHeader(updates, vars) {
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.map(platform => `**${platform}**`)
|
||||
.join(', ');
|
||||
const appScheme = vars.projectScheme ? `- Scheme → **${vars.projectScheme}**` : '';
|
||||
const appSchemes = vars.projectScheme ? `- Scheme → **${JSON.parse(vars.projectSchemes).join('**, **')}**` : '';
|
||||
return `🚀 Expo preview is ready!
|
||||
|
||||
- Project → **${vars.projectSlug}**
|
||||
- ${platformName} → ${platformValue}
|
||||
${appScheme}`.trim();
|
||||
${appSchemes}`.trim();
|
||||
}
|
||||
function createSingleQrSummary(updates, vars) {
|
||||
return `${createSummaryHeader(updates, vars)}
|
||||
@@ -42099,10 +42128,12 @@ exports.createUpdate = createUpdate;
|
||||
/**
|
||||
* Create a QR code link for an EAS Update.
|
||||
*/
|
||||
function getUpdateGroupQr({ projectId, updateGroupId, appScheme, }) {
|
||||
function getUpdateGroupQr({ projectId, updateGroupId, appSlug, qrTarget, }) {
|
||||
const url = new url_1.URL('https://qr.expo.dev/eas-update');
|
||||
if (appScheme) {
|
||||
url.searchParams.append('appScheme', appScheme);
|
||||
if (qrTarget === 'dev-build') {
|
||||
// While the parameter is called `appScheme`, it's actually the app's slug
|
||||
// This should only be added when using dev clients as target
|
||||
url.searchParams.append('appScheme', appSlug);
|
||||
}
|
||||
url.searchParams.append('projectId', projectId);
|
||||
url.searchParams.append('groupId', updateGroupId);
|
||||
@@ -42116,6 +42147,263 @@ function getUpdateGroupWebsite({ projectId, updateGroupId, }) {
|
||||
exports.getUpdateGroupWebsite = getUpdateGroupWebsite;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2489:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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;
|
||||
const core_1 = __nccwpck_require__(2186);
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const io_1 = __nccwpck_require__(7436);
|
||||
const assert_1 = __nccwpck_require__(9491);
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
var AppPlatform;
|
||||
(function (AppPlatform) {
|
||||
AppPlatform["Android"] = "ANDROID";
|
||||
AppPlatform["Ios"] = "IOS";
|
||||
})(AppPlatform || (exports.AppPlatform = AppPlatform = {}));
|
||||
exports.appPlatformDisplayNames = {
|
||||
[AppPlatform.Android]: 'Android',
|
||||
[AppPlatform.Ios]: 'iOS',
|
||||
};
|
||||
exports.appPlatformEmojis = {
|
||||
[AppPlatform.Ios]: '🍎',
|
||||
[AppPlatform.Android]: '🤖',
|
||||
};
|
||||
const CommandRegExp = /^#(eas|expo)\s+(.+)?$/im;
|
||||
function parseCommand(input) {
|
||||
const matches = CommandRegExp.exec(input);
|
||||
if (matches != null) {
|
||||
return {
|
||||
cli: matches[1],
|
||||
raw: input.trimStart().substring(1).trim(),
|
||||
args: matches[2]
|
||||
?.split(' ')
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean) ?? [],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.parseCommand = parseCommand;
|
||||
/**
|
||||
* Try to authenticate the user using either Expo or EAS CLI.
|
||||
* This method tries to invoke 'whoami' to validate if the token is valid.
|
||||
* If that passes, the token is exported as EXPO_TOKEN for all steps within the job.
|
||||
*/
|
||||
async function authenticate(token, cli = 'expo') {
|
||||
if (!cli) {
|
||||
(0, core_1.info)(`Skipped token validation: no CLI installed, can't run 'whoami'.`);
|
||||
}
|
||||
else {
|
||||
await (0, exec_1.exec)(await (0, io_1.which)(cli), ['whoami'], {
|
||||
env: { ...process.env, EXPO_TOKEN: token },
|
||||
});
|
||||
}
|
||||
(0, core_1.exportVariable)('EXPO_TOKEN', token);
|
||||
}
|
||||
exports.authenticate = authenticate;
|
||||
/**
|
||||
* Try to resolve the project owner, by running 'eas|expo whoami'.
|
||||
*/
|
||||
async function projectOwner(cli = 'expo') {
|
||||
let stdout = '';
|
||||
try {
|
||||
({ stdout } = await (0, exec_1.getExecOutput)(await (0, io_1.which)(cli), ['whoami'], { silent: true }));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not fetch the project owner`, { cause: error });
|
||||
}
|
||||
if (!stdout) {
|
||||
throw new Error(`Could not fetch the project owner, not authenticated`);
|
||||
}
|
||||
else if (stdout.endsWith(' (robot)')) {
|
||||
throw new Error(`Could not fetch the project owner, used robot account`);
|
||||
}
|
||||
return stdout.trim();
|
||||
}
|
||||
exports.projectOwner = projectOwner;
|
||||
async function runCommand(cmd) {
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
try {
|
||||
({ stderr, stdout } = await (0, exec_1.getExecOutput)(await (0, io_1.which)(cmd.cli), cmd.args.concat('--non-interactive'), {
|
||||
silent: false,
|
||||
}));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not run command ${cmd.args.join(' ')}`, { cause: error });
|
||||
}
|
||||
return [stdout.trim(), stderr.trim()];
|
||||
}
|
||||
exports.runCommand = runCommand;
|
||||
async function easBuild(cmd) {
|
||||
let stdout = '';
|
||||
try {
|
||||
const args = cmd.args.concat('--json', '--non-interactive', '--no-wait');
|
||||
({ stdout } = await (0, exec_1.getExecOutput)(await (0, io_1.which)('eas', true), args, {
|
||||
silent: false,
|
||||
}));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not run command eas build`, { cause: error });
|
||||
}
|
||||
return JSON.parse(stdout);
|
||||
}
|
||||
exports.easBuild = easBuild;
|
||||
/**
|
||||
* Create an new EAS build using the user-provided command.
|
||||
*/
|
||||
async function createEasBuildFromRawCommandAsync(cwd, command, extraArgs = []) {
|
||||
let stdout = '';
|
||||
let cmd = command;
|
||||
if (!cmd.includes('--json')) {
|
||||
cmd += ' --json';
|
||||
}
|
||||
if (!cmd.includes('--non-interactive')) {
|
||||
cmd += ' --non-interactive';
|
||||
}
|
||||
if (!cmd.includes('--no-wait')) {
|
||||
cmd += ' --no-wait';
|
||||
}
|
||||
try {
|
||||
({ stdout } = await (0, exec_1.getExecOutput)((await (0, io_1.which)('eas', true)) + ` ${cmd}`, extraArgs, {
|
||||
cwd,
|
||||
}));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not run command eas build`, { cause: error });
|
||||
}
|
||||
return JSON.parse(stdout);
|
||||
}
|
||||
exports.createEasBuildFromRawCommandAsync = createEasBuildFromRawCommandAsync;
|
||||
/**
|
||||
* Cancel an EAS build.
|
||||
*/
|
||||
async function cancelEasBuildAsync(cwd, buildId) {
|
||||
try {
|
||||
await (0, exec_1.getExecOutput)(await (0, io_1.which)('eas', true), ['build:cancel', buildId], { cwd });
|
||||
}
|
||||
catch (error) {
|
||||
(0, core_1.info)(`Failed to cancel build ${buildId}: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
exports.cancelEasBuildAsync = cancelEasBuildAsync;
|
||||
/**
|
||||
* Query the EAS BuildInfo from given buildId.
|
||||
*/
|
||||
async function queryEasBuildInfoAsync(cwd, buildId) {
|
||||
try {
|
||||
const { stdout } = await (0, exec_1.getExecOutput)(await (0, io_1.which)('eas', true), ['build:view', buildId, '--json'], {
|
||||
cwd,
|
||||
silent: true,
|
||||
});
|
||||
return JSON.parse(stdout);
|
||||
}
|
||||
catch (error) {
|
||||
(0, core_1.info)(`Failed to query eas build ${buildId}: ${String(error)}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
exports.queryEasBuildInfoAsync = queryEasBuildInfoAsync;
|
||||
/**
|
||||
* Try to resolve the project info, by running 'expo config --type prebuild'.
|
||||
*/
|
||||
async function projectInfo(dir) {
|
||||
let stdout = '';
|
||||
try {
|
||||
({ stdout } = await (0, exec_1.getExecOutput)(await (0, io_1.which)('expo', true), ['config', '--json', '--type', 'prebuild'], {
|
||||
cwd: dir,
|
||||
silent: true,
|
||||
}));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not fetch the project info from ${dir}`, { cause: error });
|
||||
}
|
||||
const { name, slug, owner } = JSON.parse(stdout);
|
||||
return { name, slug, owner };
|
||||
}
|
||||
exports.projectInfo = projectInfo;
|
||||
/**
|
||||
* Determine if the current project is using `dev-build` or `expo-go`.
|
||||
* This is based on the `@expo/cli` check to enable dev client mode.
|
||||
*
|
||||
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
|
||||
*/
|
||||
function projectAppType(dir) {
|
||||
const packageFile = path_1.default.resolve(dir, 'package.json');
|
||||
let packageJson = {};
|
||||
try {
|
||||
packageJson = require(packageFile);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
|
||||
}
|
||||
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
|
||||
return 'dev-build';
|
||||
}
|
||||
return 'expo-go';
|
||||
}
|
||||
exports.projectAppType = projectAppType;
|
||||
/**
|
||||
* Create a QR code for an update on project, with an optional release channel.
|
||||
*/
|
||||
function projectQR(project, channel) {
|
||||
(0, assert_1.ok)(project.owner, 'Could not create a QR code for project without owner');
|
||||
const url = new url_1.URL('https://qr.expo.dev/expo-go');
|
||||
url.searchParams.append('owner', project.owner);
|
||||
url.searchParams.append('slug', project.slug);
|
||||
if (channel) {
|
||||
url.searchParams.append('releaseChannel', channel);
|
||||
}
|
||||
return url.toString();
|
||||
}
|
||||
exports.projectQR = projectQR;
|
||||
/**
|
||||
* Create a link for the project in Expo.
|
||||
*/
|
||||
function projectLink(project, channel) {
|
||||
(0, assert_1.ok)(project.owner, 'Could not create a QR code for project without owner');
|
||||
const url = new url_1.URL(`https://expo.dev/@${project.owner}/${project.slug}`);
|
||||
if (channel) {
|
||||
url.searchParams.append('release-channel', channel);
|
||||
}
|
||||
return url.toString();
|
||||
}
|
||||
exports.projectLink = projectLink;
|
||||
/**
|
||||
* Create a deep link to open the project in Expo Go
|
||||
*/
|
||||
function projectDeepLink(project, channel) {
|
||||
(0, assert_1.ok)(project.owner, 'Could not create a deep link for project without owner');
|
||||
const url = new url_1.URL(`exp://exp.host/@${project.owner}/${project.slug}`);
|
||||
if (channel) {
|
||||
url.searchParams.append('release-channel', channel);
|
||||
}
|
||||
return url.toString();
|
||||
}
|
||||
exports.projectDeepLink = projectDeepLink;
|
||||
function getBuildLogsUrl(build) {
|
||||
// TODO: reuse this function from the original source
|
||||
// see: https://github.com/expo/eas-cli/blob/896f7f038582347c57dc700be9ea7d092b5a3a21/packages/eas-cli/src/build/utils/url.ts#L13-L21
|
||||
const { project } = build;
|
||||
const path = project
|
||||
? `/accounts/${project.ownerAccount.name}/projects/${project.slug}/builds/${build.id}`
|
||||
: `/builds/${build.id}`;
|
||||
const url = new url_1.URL(path, 'https://expo.dev');
|
||||
return url.toString();
|
||||
}
|
||||
exports.getBuildLogsUrl = getBuildLogsUrl;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 978:
|
||||
|
||||
+27
-2
@@ -88912,16 +88912,20 @@ exports.handleCacheError = handleCacheError;
|
||||
/***/ }),
|
||||
|
||||
/***/ 2489:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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;
|
||||
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;
|
||||
const core_1 = __nccwpck_require__(2186);
|
||||
const exec_1 = __nccwpck_require__(1514);
|
||||
const io_1 = __nccwpck_require__(7436);
|
||||
const assert_1 = __nccwpck_require__(9491);
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const url_1 = __nccwpck_require__(7310);
|
||||
var AppPlatform;
|
||||
(function (AppPlatform) {
|
||||
@@ -89090,6 +89094,27 @@ async function projectInfo(dir) {
|
||||
return { name, slug, owner };
|
||||
}
|
||||
exports.projectInfo = projectInfo;
|
||||
/**
|
||||
* Determine if the current project is using `dev-build` or `expo-go`.
|
||||
* This is based on the `@expo/cli` check to enable dev client mode.
|
||||
*
|
||||
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
|
||||
*/
|
||||
function projectAppType(dir) {
|
||||
const packageFile = path_1.default.resolve(dir, 'package.json');
|
||||
let packageJson = {};
|
||||
try {
|
||||
packageJson = require(packageFile);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
|
||||
}
|
||||
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
|
||||
return 'dev-build';
|
||||
}
|
||||
return 'expo-go';
|
||||
}
|
||||
exports.projectAppType = projectAppType;
|
||||
/**
|
||||
* Create a QR code for an update on project, with an optional release channel.
|
||||
*/
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
/** @type {import('@jest/types').Config.InitialOptions} */
|
||||
/** @type {import('jest').Config} */
|
||||
module.exports = {
|
||||
verbose: true,
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
prettierPath: require.resolve('jest-snapshot-prettier'),
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
transform: {
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
"eslint-config-universe": "^12.0.0",
|
||||
"getenv": "^1.0.0",
|
||||
"jest": "^29.3.1",
|
||||
"jest-snapshot-prettier": "npm:prettier@^2.8.8",
|
||||
"prettier": "^3.1.0",
|
||||
"semantic-release": "^19.0.5",
|
||||
"sqlite3": "^5.1.6",
|
||||
|
||||
+18
-16
@@ -42,28 +42,29 @@ It can help speed up the review process by letting the reviewer load the app dir
|
||||
This action is customizable through variables defined in the [`action.yml`](action.yml).
|
||||
Here is a summary of all the input options you can use.
|
||||
|
||||
| variable | default | description |
|
||||
| --------------------- | --------------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| **command** | - | EAS CLI command to run when creating updates |
|
||||
| **working-directory** | - | The relative directory of your Expo app |
|
||||
| **app-scheme** | - | The (custom) app scheme to use when creating the preview QR code |
|
||||
| **comment** | `true` | If the action should summarize the EAS Update information as comment on a pull request |
|
||||
| **comment-id** | _[see code][code-defaults]_ | unique id template to prevent duplicate comments ([read more](#preventing-duplicate-comments)) |
|
||||
| **github-token** | `github.token` | GitHub token to use when commenting on PR ([read more](#github-tokens)) |
|
||||
| variable | default | description |
|
||||
| --------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **command** | - | EAS CLI command to run when creating updates |
|
||||
| **working-directory** | - | The relative directory of your Expo app |
|
||||
| **comment** | `true` | If the action should summarize the EAS Update information as comment on a pull request |
|
||||
| **comment-id** | _[see code][code-defaults]_ | Unique id template to prevent duplicate comments ([read more](#preventing-duplicate-comments)) |
|
||||
| **qr-target** | _inferred from project_ | Either `dev-build` or `expo-go`, affects how the EAS Update is opened through the QR code. <br /> Defaults to `dev-build` when `expo-dev-client` is detected within the project. |
|
||||
| **github-token** | `github.token` | GitHub token to use when commenting on PR ([read more](#github-tokens)) |
|
||||
|
||||
## Available outputs
|
||||
|
||||
There are a few variables available that you can use to set up your own notifications.
|
||||
These variables are strings; some may be empty because of your project configuration.
|
||||
|
||||
| output name | description |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| **projectId** | The resolved EAS project ID |
|
||||
| **projectName** | The name of your project ([read more](https://docs.expo.dev/versions/latest/config/app/#name)) |
|
||||
| **projectSlug** | The slug of your project ([read more](https://docs.expo.dev/versions/latest/config/app/#slug)) |
|
||||
| **projectScheme** | The (custom) app scheme ([read more](https://docs.expo.dev/versions/latest/config/app/#scheme)) |
|
||||
| **commentId** | The unique comment ID to prevent duplicate comments ([read more](#preventing-duplicate-comments)) |
|
||||
| **comment** | The comment with information about the updates |
|
||||
| output name | description |
|
||||
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| **projectId** | The resolved EAS project ID |
|
||||
| **projectName** | The name of your project ([read more](https://docs.expo.dev/versions/latest/config/app/#name)) |
|
||||
| **projectSlug** | The slug of your project ([read more](https://docs.expo.dev/versions/latest/config/app/#slug)) |
|
||||
| **projectScheme** | The longest (custom) app scheme ([read more](https://docs.expo.dev/versions/latest/config/app/#scheme)) |
|
||||
| **projectSchemes** | All (custom) app schemes in order of longest to shortest, as JSON string ([read more](https://docs.expo.dev/versions/latest/config/app/#scheme)) |
|
||||
| **commentId** | The unique comment ID to prevent duplicate comments ([read more](#preventing-duplicate-comments)) |
|
||||
| **comment** | The comment with information about the updates |
|
||||
|
||||
### Update information
|
||||
|
||||
@@ -124,6 +125,7 @@ You can read more about this in the [GitHub Actions documentation][link-actions]
|
||||
|
||||
This workflow creates a new EAS Update every time a pull request is created or updated.
|
||||
We are using the `--auto`, together with the `--branch`, flag in this example.
|
||||
|
||||
- `--auto` will automatically create an update using the current git commit message and git branch.
|
||||
- `--branch` will overwrite this value infere from git with our own value.
|
||||
|
||||
|
||||
+8
-3
@@ -12,15 +12,15 @@ inputs:
|
||||
command:
|
||||
description: EAS CLI command to run when creating updates
|
||||
required: true
|
||||
app-scheme:
|
||||
description: The (custom) app scheme to use when creating the preview QR code
|
||||
required: false
|
||||
comment:
|
||||
description: If the action should summarize the EAS Update information as comment on a pull request
|
||||
required: false
|
||||
default: true
|
||||
comment-id:
|
||||
description: unique id template to prevent duplicate comments
|
||||
qr-target:
|
||||
description: How the EAS Update is opened through the QR code, either `dev-build` or `expo-go`. Defaults to `dev-build` if `expo-dev-client` is used in project.
|
||||
required: false
|
||||
working-directory:
|
||||
description: The relative directory of your Expo app
|
||||
required: false
|
||||
@@ -29,6 +29,11 @@ inputs:
|
||||
description: GitHub token to use when commenting on PR
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
# Below are deprecated and won't be supported anymore
|
||||
app-scheme:
|
||||
deprecated: true
|
||||
description: The (custom) app scheme to use when creating the preview QR code
|
||||
required: false
|
||||
outputs:
|
||||
projectId:
|
||||
description: The resolved EAS project ID
|
||||
|
||||
+53
-20
@@ -1,7 +1,8 @@
|
||||
import { getBooleanInput, getInput, setOutput, group, setFailed, info } from '@actions/core';
|
||||
import { getBooleanInput, getInput, setOutput, group, setFailed, info, debug } from '@actions/core';
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
|
||||
import { assertEasVersion, createUpdate, EasUpdate, getUpdateGroupQr, getUpdateGroupWebsite } from '../eas';
|
||||
import { projectAppType } from '../expo';
|
||||
import { createIssueComment, hasPullContext, pullContext } from '../github';
|
||||
import { loadProjectConfig } from '../project';
|
||||
import { template } from '../utils';
|
||||
@@ -10,13 +11,19 @@ import { executeAction } from '../worker';
|
||||
export const MESSAGE_ID = 'projectId:{projectId}';
|
||||
|
||||
export function previewInput() {
|
||||
const qrTarget = getInput('qr-target') || undefined;
|
||||
if (qrTarget && !['expo-go', 'dev-client'].includes(qrTarget)) {
|
||||
throw new Error(`Invalid QR code target: "${qrTarget}", expected "expo-go" or "dev-build"`);
|
||||
}
|
||||
|
||||
return {
|
||||
command: getInput('command'),
|
||||
shouldComment: !getInput('comment') || getBooleanInput('comment'),
|
||||
commentId: getInput('comment-id') || MESSAGE_ID,
|
||||
workingDirectory: getInput('working-directory'),
|
||||
githubToken: getInput('github-token'),
|
||||
appScheme: getInput('app-scheme'),
|
||||
// Note, `dev-build` is prefered, but `dev-client` is supported to aovid confusion
|
||||
qrTarget: qrTarget as undefined | 'expo-go' | 'dev-build' | 'dev-client',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,24 +103,27 @@ function sanitizeCommand(input: string): string {
|
||||
/**
|
||||
* Generate useful variables for the message body, and as step outputs.
|
||||
*/
|
||||
export function getVariables(config: ExpoConfig, updates: EasUpdate[], input: ReturnType<typeof previewInput>) {
|
||||
export function getVariables(config: ExpoConfig, updates: EasUpdate[], options: ReturnType<typeof previewInput>) {
|
||||
const projectId: string = config.extra?.eas?.projectId;
|
||||
const android = updates.find(update => update.platform === 'android');
|
||||
const ios = updates.find(update => update.platform === 'ios');
|
||||
|
||||
const appScheme = input.appScheme || getSchemeFromConfig(config) || '';
|
||||
const appSchemes = getSchemesInOrderFromConfig(config) || [];
|
||||
const appSlug = config.slug;
|
||||
const qrTarget = getQrTarget(options);
|
||||
|
||||
return {
|
||||
// EAS / Expo specific
|
||||
projectId,
|
||||
projectName: config.name,
|
||||
projectSlug: config.slug,
|
||||
projectScheme: appScheme,
|
||||
projectSlug: appSlug,
|
||||
projectScheme: appSchemes[0] || '', // This is the longest scheme from one or more custom app schemes
|
||||
projectSchemes: JSON.stringify(appSchemes), // These are all custom app schemes, in order from longest to shortest as JSON
|
||||
// Shared update properties
|
||||
// Note, only use these properties when the update groups are identical
|
||||
groupId: updates[0].group,
|
||||
runtimeVersion: updates[0].runtimeVersion,
|
||||
qr: getUpdateGroupQr({ projectId, updateGroupId: updates[0].group, appScheme }),
|
||||
qr: getUpdateGroupQr({ projectId, updateGroupId: updates[0].group, appSlug, qrTarget }),
|
||||
link: getUpdateGroupWebsite({ projectId, updateGroupId: updates[0].group }),
|
||||
// These are safe to access regardless of the update groups
|
||||
branchName: updates[0].branch,
|
||||
@@ -127,7 +137,7 @@ export function getVariables(config: ExpoConfig, updates: EasUpdate[], input: Re
|
||||
androidManifestPermalink: android?.manifestPermalink || '',
|
||||
androidMessage: android?.message || '',
|
||||
androidRuntimeVersion: android?.runtimeVersion || '',
|
||||
androidQR: android ? getUpdateGroupQr({ projectId, updateGroupId: android.group, appScheme }) : '',
|
||||
androidQR: android ? getUpdateGroupQr({ projectId, updateGroupId: android.group, appSlug, qrTarget }) : '',
|
||||
androidLink: android ? getUpdateGroupWebsite({ projectId, updateGroupId: android.group }) : '',
|
||||
// iOS update
|
||||
iosId: ios?.id || '',
|
||||
@@ -136,27 +146,50 @@ export function getVariables(config: ExpoConfig, updates: EasUpdate[], input: Re
|
||||
iosManifestPermalink: ios?.manifestPermalink || '',
|
||||
iosMessage: ios?.message || '',
|
||||
iosRuntimeVersion: ios?.runtimeVersion || '',
|
||||
iosQR: ios ? getUpdateGroupQr({ projectId, updateGroupId: ios.group, appScheme }) : '',
|
||||
iosQR: ios ? getUpdateGroupQr({ projectId, updateGroupId: ios.group, appSlug, qrTarget }) : '',
|
||||
iosLink: ios ? getUpdateGroupWebsite({ projectId, updateGroupId: ios.group }) : '',
|
||||
};
|
||||
}
|
||||
|
||||
export function getQrTarget(input: Pick<ReturnType<typeof previewInput>, 'qrTarget' | 'workingDirectory'>) {
|
||||
if (!input.qrTarget) {
|
||||
const appType = projectAppType(input.workingDirectory);
|
||||
debug(`Using inferred QR code target: "${appType}"`);
|
||||
return appType;
|
||||
}
|
||||
|
||||
switch (input.qrTarget) {
|
||||
// Note, `dev-build` is prefered, but `dev-client` is supported to aovid confusion
|
||||
case 'dev-client':
|
||||
case 'dev-build':
|
||||
debug(`Using QR code target: "dev-build"`);
|
||||
return 'dev-build';
|
||||
|
||||
case 'expo-go':
|
||||
debug(`Using QR code target: "expo-go"`);
|
||||
return 'expo-go';
|
||||
|
||||
default:
|
||||
throw new Error(`Invalid QR code target: "${input.qrTarget}", expected "expo-go" or "dev-build"`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the app scheme from project config, using the following criteria:
|
||||
* - If the scheme is a string, return that.
|
||||
* - If the scheme is an array, return the longest scheme.
|
||||
* Retrieve the app schemes, in correct priority order, from project config.
|
||||
* - If the scheme is a string, return `[scheme]`.
|
||||
* - If the scheme is an array, return the schemes sorted by length, longest first.
|
||||
* - If the scheme is empty/incorrect, return an empty array.
|
||||
*/
|
||||
export function getSchemeFromConfig(config: ExpoConfig) {
|
||||
export function getSchemesInOrderFromConfig(config: ExpoConfig) {
|
||||
if (typeof config.scheme === 'string') {
|
||||
return config.scheme;
|
||||
return [config.scheme];
|
||||
}
|
||||
|
||||
if (Array.isArray(config.scheme) && config.scheme.length > 0) {
|
||||
const longestToShortest = config.scheme.sort((a, b) => b.length - a.length);
|
||||
return longestToShortest[0];
|
||||
if (Array.isArray(config.scheme)) {
|
||||
return config.scheme.sort((a, b) => b.length - a.length);
|
||||
}
|
||||
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,13 +213,13 @@ function createSummaryHeader(updates: EasUpdate[], vars: ReturnType<typeof getVa
|
||||
.map(platform => `**${platform}**`)
|
||||
.join(', ');
|
||||
|
||||
const appScheme = vars.projectScheme ? `- Scheme → **${vars.projectScheme}**` : '';
|
||||
const appSchemes = vars.projectScheme ? `- Scheme → **${JSON.parse(vars.projectSchemes).join('**, **')}**` : '';
|
||||
|
||||
return `🚀 Expo preview is ready!
|
||||
|
||||
- Project → **${vars.projectSlug}**
|
||||
- ${platformName} → ${platformValue}
|
||||
${appScheme}`.trim();
|
||||
${appSchemes}`.trim();
|
||||
}
|
||||
|
||||
function createSingleQrSummary(updates: EasUpdate[], vars: ReturnType<typeof getVariables>) {
|
||||
|
||||
+8
-4
@@ -71,16 +71,20 @@ export async function createUpdate(cwd: string, command: string): Promise<EasUpd
|
||||
export function getUpdateGroupQr({
|
||||
projectId,
|
||||
updateGroupId,
|
||||
appScheme,
|
||||
appSlug,
|
||||
qrTarget,
|
||||
}: {
|
||||
projectId: string;
|
||||
updateGroupId: string;
|
||||
appScheme?: string;
|
||||
appSlug: string;
|
||||
qrTarget: 'expo-go' | 'dev-build';
|
||||
}): string {
|
||||
const url = new URL('https://qr.expo.dev/eas-update');
|
||||
|
||||
if (appScheme) {
|
||||
url.searchParams.append('appScheme', appScheme);
|
||||
if (qrTarget === 'dev-build') {
|
||||
// While the parameter is called `appScheme`, it's actually the app's slug
|
||||
// This should only be added when using dev clients as target
|
||||
url.searchParams.append('appScheme', appSlug);
|
||||
}
|
||||
|
||||
url.searchParams.append('projectId', projectId);
|
||||
|
||||
+24
@@ -2,6 +2,7 @@ import { info, exportVariable } from '@actions/core';
|
||||
import { exec, getExecOutput } from '@actions/exec';
|
||||
import { which } from '@actions/io';
|
||||
import { ok as assert } from 'assert';
|
||||
import path from 'path';
|
||||
import { URL } from 'url';
|
||||
|
||||
export type CliName = 'expo' | 'eas';
|
||||
@@ -216,6 +217,29 @@ export async function projectInfo(dir: string): Promise<ProjectInfo> {
|
||||
return { name, slug, owner };
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current project is using `dev-build` or `expo-go`.
|
||||
* This is based on the `@expo/cli` check to enable dev client mode.
|
||||
*
|
||||
* @see https://github.com/expo/expo/blob/190a80f393bc730eb3f300df52d82b701e4b8ff5/packages/%40expo/cli/src/utils/analytics/getDevClientProperties.ts#L12-L15
|
||||
*/
|
||||
export function projectAppType(dir: string): 'expo-go' | 'dev-build' {
|
||||
const packageFile = path.resolve(dir, 'package.json');
|
||||
let packageJson: any = {};
|
||||
|
||||
try {
|
||||
packageJson = require(packageFile);
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Could not load the project package file in: ${packageFile}`, { cause: error });
|
||||
}
|
||||
|
||||
if (packageJson?.dependencies?.['expo-dev-client'] || packageJson?.devDependencies?.['expo-dev-client']) {
|
||||
return 'dev-build';
|
||||
}
|
||||
|
||||
return 'expo-go';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a QR code for an update on project, with an optional release channel.
|
||||
*/
|
||||
|
||||
+112
-69
@@ -1,9 +1,20 @@
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
|
||||
import { createSummary, getSchemeFromConfig, getVariables, previewInput } from '../../src/actions/preview';
|
||||
import {
|
||||
createSummary,
|
||||
getQrTarget,
|
||||
getSchemesInOrderFromConfig,
|
||||
getVariables,
|
||||
previewInput,
|
||||
} from '../../src/actions/preview';
|
||||
import { EasUpdate } from '../../src/eas';
|
||||
import { projectAppType } from '../../src/expo';
|
||||
|
||||
const fakeInput = {} as unknown as ReturnType<typeof previewInput>;
|
||||
jest.mock('../../src/expo');
|
||||
|
||||
const fakeOptions = {
|
||||
qrTarget: 'dev-client',
|
||||
} as unknown as ReturnType<typeof previewInput>;
|
||||
|
||||
const fakeExpoConfig = {
|
||||
slug: 'fake-project',
|
||||
@@ -39,24 +50,57 @@ const fakeUpdatesSingle: EasUpdate[] = [
|
||||
|
||||
const fakeUpdatesMultiple = fakeUpdatesSingle.map(update => ({ ...update, group: `fake-group-${update.id}` }));
|
||||
|
||||
describe(getSchemeFromConfig, () => {
|
||||
it('returns `null` when not defined', () => {
|
||||
expect(getSchemeFromConfig({} as ExpoConfig)).toBeNull();
|
||||
describe(getQrTarget, () => {
|
||||
it('returns `dev-build` for `qr-target: dev-build`', () => {
|
||||
expect(getQrTarget({ ...fakeOptions, qrTarget: 'dev-build' })).toBe('dev-build');
|
||||
});
|
||||
|
||||
it('returns scheme when defined as string', () => {
|
||||
expect(getSchemeFromConfig({ scheme: 'ega' } as ExpoConfig)).toBe('ega');
|
||||
it('returns `dev-build` for `qr-target: dev-client`', () => {
|
||||
expect(getQrTarget({ ...fakeOptions, qrTarget: 'dev-client' })).toBe('dev-build');
|
||||
});
|
||||
|
||||
it('returns longest scheme when defined as array', () => {
|
||||
expect(getSchemeFromConfig({ scheme: ['ega', 'expogithubaction'] } as ExpoConfig)).toBe('expogithubaction');
|
||||
it('returns `expo-go` for `qr-target: expo-go`', () => {
|
||||
expect(getQrTarget({ ...fakeOptions, qrTarget: 'expo-go' })).toBe('expo-go');
|
||||
});
|
||||
|
||||
it('throws for unknown `qr-target`', () => {
|
||||
expect(() => getQrTarget({ ...fakeOptions, qrTarget: 'unknown' } as any)).toThrow(
|
||||
`Invalid QR code target: "unknown", expected "expo-go" or "dev-build"`
|
||||
);
|
||||
});
|
||||
|
||||
it('returns infered `dev-build` when input is omitted', () => {
|
||||
jest.mocked(projectAppType).mockReturnValue('dev-build');
|
||||
expect(getQrTarget({ ...fakeOptions, qrTarget: undefined })).toBe('dev-build');
|
||||
});
|
||||
|
||||
it('returns infered `expo-go` when input is omitted', () => {
|
||||
jest.mocked(projectAppType).mockReturnValue('expo-go');
|
||||
expect(getQrTarget({ ...fakeOptions, qrTarget: undefined })).toBe('expo-go');
|
||||
});
|
||||
});
|
||||
|
||||
describe(getSchemesInOrderFromConfig, () => {
|
||||
it('returns empty array when not defined', () => {
|
||||
expect(getSchemesInOrderFromConfig({} as ExpoConfig)).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns scheme as array when defined as string', () => {
|
||||
expect(getSchemesInOrderFromConfig({ scheme: 'ega' } as ExpoConfig)).toEqual(['ega']);
|
||||
});
|
||||
|
||||
it('returns schemes in order when defined as array', () => {
|
||||
expect(getSchemesInOrderFromConfig({ scheme: ['ega', 'expogithubaction'] } as ExpoConfig)).toEqual([
|
||||
'expogithubaction',
|
||||
'ega',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe(createSummary, () => {
|
||||
describe('single update group', () => {
|
||||
it('returns expected message for both platforms', () => {
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(fakeExpoConfig, fakeUpdatesSingle, fakeInput)))
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(fakeExpoConfig, fakeUpdatesSingle, fakeOptions)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
@@ -65,7 +109,7 @@ describe(createSummary, () => {
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
@@ -73,35 +117,17 @@ describe(createSummary, () => {
|
||||
|
||||
it('returns expected message for both platforms with custom app scheme', () => {
|
||||
const customSchemeConfig = { ...fakeExpoConfig, scheme: ['ega', 'expogithubaction'] };
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(customSchemeConfig, fakeUpdatesSingle, fakeInput)))
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(customSchemeConfig, fakeUpdatesSingle, fakeOptions)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platforms → **android**, **ios**
|
||||
- Scheme → **expogithubaction**
|
||||
- Scheme → **expogithubaction**, **ega**
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=expogithubaction&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=expogithubaction&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
|
||||
it('returns expected message for both platforms with overwriten app scheme', () => {
|
||||
const customInput = { ...fakeInput, appScheme: 'expogithubaction' };
|
||||
expect(createSummary(fakeUpdatesSingle, getVariables(fakeExpoConfig, fakeUpdatesSingle, customInput)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platforms → **android**, **ios**
|
||||
- Scheme → **expogithubaction**
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=expogithubaction&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=expogithubaction&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
@@ -109,7 +135,7 @@ describe(createSummary, () => {
|
||||
|
||||
it('returns expected message for android only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'android');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeOptions))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
@@ -117,7 +143,7 @@ describe(createSummary, () => {
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
@@ -125,7 +151,7 @@ describe(createSummary, () => {
|
||||
|
||||
it('returns expected message for ios only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'ios');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeOptions))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
@@ -133,7 +159,7 @@ describe(createSummary, () => {
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
@@ -142,7 +168,56 @@ describe(createSummary, () => {
|
||||
|
||||
describe('mutliple update groups', () => {
|
||||
it('returns expected message for both platforms', () => {
|
||||
expect(createSummary(fakeUpdatesMultiple, getVariables(fakeExpoConfig, fakeUpdatesMultiple, fakeInput)))
|
||||
expect(createSummary(fakeUpdatesMultiple, getVariables(fakeExpoConfig, fakeUpdatesMultiple, fakeOptions)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platforms → **android**, **ios**
|
||||
|
||||
Android <br /> _(exposdk:47.0.0)_ <br /> **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-fake-android-id)** | iOS <br /> _(exposdk:47.0.0)_ <br /> **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-fake-ios-id)**
|
||||
--- | ---
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-fake-android-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-fake-android-id" width="250px" height="250px" /></a> | <a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-fake-ios-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-fake-ios-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
|
||||
it('returns expected message for android only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'android');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeOptions))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platform → **android**
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
|
||||
it('returns expected message for ios only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'ios');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeOptions))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platform → **ios**
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?appScheme=fake-project&projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
|
||||
it('returns Expo Go compatible QR code when forced', () => {
|
||||
const customOptions: typeof fakeOptions = { ...fakeOptions, qrTarget: 'expo-go' };
|
||||
expect(createSummary(fakeUpdatesMultiple, getVariables(fakeExpoConfig, fakeUpdatesMultiple, customOptions)))
|
||||
.toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
@@ -156,37 +231,5 @@ describe(createSummary, () => {
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
|
||||
it('returns expected message for android only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'android');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platform → **android**
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
|
||||
it('returns expected message for ios only', () => {
|
||||
const fakeUpdate = fakeUpdatesSingle.filter(update => update.platform === 'ios');
|
||||
expect(createSummary(fakeUpdate, getVariables(fakeExpoConfig, fakeUpdate, fakeInput))).toMatchInlineSnapshot(`
|
||||
"🚀 Expo preview is ready!
|
||||
|
||||
- Project → **fake-project**
|
||||
- Platform → **ios**
|
||||
- Runtime Version → **exposdk:47.0.0**
|
||||
- **[More info](https://expo.dev/projects/fake-project-id/updates/fake-group-id)**
|
||||
|
||||
<a href="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id"><img src="https://qr.expo.dev/eas-update?projectId=fake-project-id&groupId=fake-group-id" width="250px" height="250px" /></a>
|
||||
|
||||
> Learn more about [𝝠 Expo Github Action](https://github.com/expo/expo-github-action/tree/main/preview#example-workflows)"
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import { getUpdateGroupQr } from '../src/eas';
|
||||
|
||||
describe(getUpdateGroupQr, () => {
|
||||
it('returns url for expo-go', () => {
|
||||
expect(
|
||||
getUpdateGroupQr({
|
||||
qrTarget: 'expo-go',
|
||||
projectId: 'projectId',
|
||||
updateGroupId: 'updateGroupId',
|
||||
appSlug: 'appslug',
|
||||
})
|
||||
).toBe('https://qr.expo.dev/eas-update?projectId=projectId&groupId=updateGroupId');
|
||||
});
|
||||
|
||||
it('returns url for dev-build', () => {
|
||||
expect(
|
||||
getUpdateGroupQr({
|
||||
qrTarget: 'dev-build',
|
||||
projectId: 'projectId',
|
||||
updateGroupId: 'updateGroupId',
|
||||
appSlug: 'appslug',
|
||||
})
|
||||
).toBe('https://qr.expo.dev/eas-update?appScheme=appslug&projectId=projectId&groupId=updateGroupId');
|
||||
});
|
||||
|
||||
it('returns url for dev-build, with `_` in appSlug', () => {
|
||||
expect(
|
||||
getUpdateGroupQr({
|
||||
qrTarget: 'dev-build',
|
||||
projectId: 'projectId',
|
||||
updateGroupId: 'updateGroupId',
|
||||
appSlug: 'hello_world',
|
||||
})
|
||||
).toBe('https://qr.expo.dev/eas-update?appScheme=helloworld&projectId=projectId&groupId=updateGroupId');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user