Compare commits

...
16 Commits
Author SHA1 Message Date
Wojciech Kozyra d92a2ae3f4 v0.7.0 2021-03-22 13:33:34 +01:00
Dominik Sokal b7dea35da4 better message when build was canceled 2021-03-22 12:02:08 +01:00
Wojciech Kozyra 5a5f11752d Update @expo/eas-build-job 2021-03-22 12:02:08 +01:00
Wojciech Kozyra b6c300b5c2 [eas-json] Detect dependency cycle for build profiles (#283)
* [eas-json] Detect dependency cycle for build profiles

* Update CHANGELOG.md

* review feedback
2021-03-22 11:15:38 +01:00
Wojciech Kozyra 0117dbfa5f [eas-cli] verify that "name" in app.sjon can be used as iOS target name (#280) 2021-03-18 12:15:52 +01:00
Dominik Sokal c106f8a1a4 fix project utils calls after merge 2021-03-18 09:55:55 +01:00
Dominik Sokal 8b9741a70c refactor project utils (#278) 2021-03-18 09:51:30 +01:00
Juwan Wheatley 271b85fd74 [eas-cli] create commands for managing environment secrets (#275)
* set up graphql queries and mutations

* add secrets: list command

* add create command

* list all secrets

* add deletion command, add ID to list, add EAS check to create

* update changelog

* fix typo

* use target enum

* use US cancel

* move AccountResolver to generic place

* secret isn't reassigned

* check for eas in delete

* make mutation inputs required

* update generated graphql files

* use findAccountByName directly instead of AccountResolver

* update list format

* move accountresolver back into device manager file

* restore old devicemanager source

* lint
2021-03-17 14:50:40 -04:00
Dominik Sokal 21a481790b [ENG-438] allow for installing custom bundler version (#277)
* allow for installing custom bundler version

* update CHANGELOG.md

* bump @expo/eas-build-job to 0.2.20

* fix printing docs url
2021-03-17 13:52:52 +01:00
Wojciech Kozyra ab5d9237f1 [eas-cli] update external errors logic (#276) 2021-03-16 17:10:37 +01:00
Wojciech Kozyra 756853f2f3 [eas-cli] autmatically commit when EAS_BUILD_AUTOCOMMIT is set (#271) 2021-03-15 09:23:30 +01:00
Bartłomiej Klocek 5eb80d15f6 [ENG-509][submit] Fix local archive prompt (#273) 2021-03-12 11:34:31 +01:00
Dominik Sokal a98043b4ad print common error messages when builds fail (#272)
* print common error messages when builds fail

* update CHANGELOG

* address PR feedback

* address more PR feedback
2021-03-12 10:29:33 +01:00
jkh d0818932e7 [eas-cli] add --republish and --group flags to branch:publish command. (#253) 2021-03-11 05:37:18 -08:00
Dominik Sokal 23b60ed385 fix typo 2021-03-09 11:08:39 +01:00
Dominik Sokal 5d2811bf21 update CHANGELOG 2021-03-09 11:05:14 +01:00
56 changed files with 1988 additions and 1209 deletions

No files matched your search

+19 -2
View File
@@ -6,6 +6,25 @@ This is the log of notable changes to EAS CLI and related packages.
### 🛠 Breaking changes
### 🎉 New features
- Print common error messages when builds fail. ([#272](https://github.com/expo/eas-cli/pull/272) by [@dsokal](https://github.com/dsokal))
- Commit automatically if `EAS_BUILD_AUTOCOMMIT` is set. ([#271](https://github.com/expo/eas-cli/pull/271) by [@wkozyra95](https://github.com/wkozyra95))
- Allow for installing custom `bundler` version on EAS Build. ([#277](https://github.com/expo/eas-cli/pull/277) by [@dsokal](https://github.com/dsokal))
- Add support for managing environment secrets. ([#275](https://github.com/expo/eas-cli/pull/275) by [@fiberjw](https://github.com/fiberjw))
### 🐛 Bug fixes
- Fix `eas submit` local archive prompt for `.aab` files when submitting for iOS. ([#273](https://github.com/expo/eas-cli/pull/273) by [@barthap](https://github.com/barthap))
- Verify whether "name" field in app.json contains any alphanumeric characters. ([#280](https://github.com/expo/eas-cli/pull/280) by [@wkozyra95](https://github.com/wkozyra95))
- Detect dependency cycles in eas.json build profiles. ([#283](https://github.com/expo/eas-cli/pull/283) by [@wkozyra95](https://github.com/wkozyra95))
### 🧹 Chores
## [0.6.0](https://github.com/expo/eas-cli/releases/tag/v0.6.0) - 2021-03-09
### 🛠 Breaking changes
- Generic iOS projects: build release builds by default. ([#266](https://github.com/expo/eas-cli/pull/266) by [@dsokal](https://github.com/dsokal))
### 🎉 New features
@@ -20,8 +39,6 @@ This is the log of notable changes to EAS CLI and related packages.
- Print Apple Team ID in the output of `device:list` when the team name is unknown. ([#268](https://github.com/expo/eas-cli/pull/268) by [@wkozyra95](https://github.com/wkozyra95))
### 🧹 Chores
## [0.5.0](https://github.com/expo/eas-cli/releases/tag/v0.5.0) - 2021-03-02
### 🎉 New features
+1 -1
View File
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.6.0"
"version": "0.7.0"
}
+26 -15
View File
@@ -46,6 +46,7 @@ eas --help COMMAND
* [`eas device:list`](#eas-devicelist)
* [`eas device:view [UDID]`](#eas-deviceview-udid)
* [`eas help [COMMAND]`](#eas-help-command)
* [`eas secrets:list`](#eas-secretslist)
* [`eas submit --platform=(android|ios)`](#eas-submit---platformandroidios)
## `eas account:login`
@@ -60,7 +61,7 @@ ALIASES
$ eas login
```
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/account/login.ts)_
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/account/login.ts)_
## `eas account:logout`
@@ -74,7 +75,7 @@ ALIASES
$ eas logout
```
_See code: [build/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/account/logout.ts)_
_See code: [build/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/account/logout.ts)_
## `eas account:view`
@@ -88,7 +89,7 @@ ALIASES
$ eas whoami
```
_See code: [build/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/account/view.ts)_
_See code: [build/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/account/view.ts)_
## `eas build`
@@ -107,7 +108,7 @@ OPTIONS
--[no-]wait Wait for build(s) to complete
```
_See code: [build/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/build/index.ts)_
_See code: [build/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/build/index.ts)_
## `eas build:cancel [BUILD_ID]`
@@ -118,7 +119,7 @@ USAGE
$ eas build:cancel [BUILD_ID]
```
_See code: [build/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/build/cancel.ts)_
_See code: [build/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/build/cancel.ts)_
## `eas build:configure`
@@ -133,7 +134,7 @@ OPTIONS
--allow-experimental Enable experimental configuration steps.
```
_See code: [build/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/build/configure.ts)_
_See code: [build/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/build/configure.ts)_
## `eas build:list`
@@ -149,7 +150,7 @@ OPTIONS
--status=(in-queue|in-progress|errored|finished|canceled)
```
_See code: [build/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/build/list.ts)_
_See code: [build/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/build/list.ts)_
## `eas build:view [BUILD_ID]`
@@ -160,7 +161,7 @@ USAGE
$ eas build:view [BUILD_ID]
```
_See code: [build/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/build/view.ts)_
_See code: [build/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/build/view.ts)_
## `eas credentials`
@@ -171,7 +172,7 @@ USAGE
$ eas credentials
```
_See code: [build/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/credentials.ts)_
_See code: [build/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/credentials.ts)_
## `eas device:create`
@@ -182,7 +183,7 @@ USAGE
$ eas device:create
```
_See code: [build/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/device/create.ts)_
_See code: [build/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/device/create.ts)_
## `eas device:list`
@@ -196,7 +197,7 @@ OPTIONS
--apple-team-id=apple-team-id
```
_See code: [build/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/device/list.ts)_
_See code: [build/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/device/list.ts)_
## `eas device:view [UDID]`
@@ -207,7 +208,7 @@ USAGE
$ eas device:view [UDID]
```
_See code: [build/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/device/view.ts)_
_See code: [build/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/device/view.ts)_
## `eas help [COMMAND]`
@@ -226,6 +227,17 @@ OPTIONS
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.0/src/commands/help.ts)_
## `eas secrets:list`
Lists environment secrets available for your current app
```
USAGE
$ eas secrets:list
```
_See code: [build/commands/secrets/list.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/secrets/list.ts)_
## `eas submit --platform=(android|ios)`
Submits build artifact to app store
@@ -250,8 +262,7 @@ OPTIONS
iOS specific options=asc-app-id App Store Connect unique application Apple ID
number. Providing this param results in skipping
app creation step. Learn more:
https://expo.fyi/asc-app-id
app creation step. Learn more.
iOS specific options=bundle-identifier Your iOS Bundle Identifier (default:
expo.ios.bundleIdentifier from app config)
@@ -304,5 +315,5 @@ EXAMPLES
and provide its App ID
```
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.6.0/build/commands/submit.ts)_
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.7.0/build/commands/submit.ts)_
<!-- commandsstop -->
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -1,7 +1,7 @@
{
"name": "eas-cli",
"description": "EAS command line tool",
"version": "0.6.0",
"version": "0.7.0",
"author": "Expo <[email protected]>",
"bin": {
"eas": "./bin/run"
@@ -11,8 +11,8 @@
"@expo/apple-utils": "0.0.0-alpha.17",
"@expo/config": "~3.3.19",
"@expo/config-plugins": "1.0.21-alpha.0",
"@expo/eas-build-job": "0.2.16",
"@expo/eas-json": "^0.6.0",
"@expo/eas-build-job": "0.2.21",
"@expo/eas-json": "^0.7.0",
"@expo/json-file": "^8.2.24",
"@expo/plist": "^0.0.11",
"@expo/plugin-warn-if-update-available": "^1.7.0",
@@ -24,8 +24,12 @@ function isApplicationIdValid(applicationId: string): boolean {
return /^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*)+$/.test(applicationId);
}
export async function ensureApplicationIdIsValidAsync(projectDir: string) {
const applicationId = await ensureAppIdentifierIsDefinedAsync(projectDir, Platform.ANDROID);
export async function ensureApplicationIdIsValidAsync(projectDir: string, exp: ExpoConfig) {
const applicationId = await ensureAppIdentifierIsDefinedAsync({
projectDir,
platform: Platform.ANDROID,
exp,
});
if (!isApplicationIdValid(applicationId)) {
const configDescription = getProjectConfigDescription(projectDir);
Log.error(
+1 -1
View File
@@ -60,7 +60,7 @@ This means that it will most likely produce an AAB and you will not be able to i
}
}
await ensureApplicationIdIsValidAsync(commandCtx.projectDir);
await ensureApplicationIdIsValidAsync(commandCtx.projectDir, commandCtx.exp);
return await prepareBuildRequestForPlatformAsync({
ctx: buildCtx,
@@ -15,7 +15,7 @@ export async function configureAndroidAsync(ctx: ConfigureContext): Promise<void
}
await AndroidConfig.EasBuild.configureEasBuildAsync(ctx.projectDir);
await configureApplicationIdAsync(ctx.projectDir, ctx.exp, ctx.allowExperimental);
await ensureApplicationIdIsValidAsync(ctx.projectDir);
await ensureApplicationIdIsValidAsync(ctx.projectDir, ctx.exp);
const easGradlePath = AndroidConfig.EasBuild.getEasBuildGradlePath(ctx.projectDir);
await gitAddAsync(easGradlePath, { intentToAdd: true });
@@ -114,7 +114,7 @@ async function prepareManagedJobAsync(
): Promise<Partial<Android.ManagedJob>> {
const projectRootDirectory =
path.relative(await gitRootDirectoryAsync(), ctx.commandCtx.projectDir) || '.';
const accountName = await getProjectAccountNameAsync(ctx.commandCtx.projectDir);
const accountName = await getProjectAccountNameAsync(ctx.commandCtx.exp);
return {
...(await prepareJobCommonAsync(ctx, jobData)),
type: Workflow.MANAGED,
+7 -1
View File
@@ -15,6 +15,7 @@ import { AnalyticsEvent, Platform, TrackingContext } from './types';
import Analytics from './utils/analytics';
import { printDeprecationWarnings } from './utils/printBuildInfo';
import {
commitChangedFilesAsync,
commitPromptAsync,
isGitStatusCleanAsync,
makeProjectTarballAsync,
@@ -189,9 +190,14 @@ async function reviewAndCommitChangesAsync(
initialCommitMessage: string,
{ nonInteractive, askedFirstTime = true }: { nonInteractive: boolean; askedFirstTime?: boolean }
): Promise<void> {
if (process.env.EAS_BUILD_AUTOCOMMIT) {
await commitChangedFilesAsync(initialCommitMessage);
Log.withTick('Committed changes.');
return;
}
if (nonInteractive) {
throw new Error(
'Cannot commit changes when --non-interactive is specified. Run the command in interactive mode to review and commit changes.'
'Cannot commit changes when --non-interactive is specified. Run the command in interactive mode or set EAS_BUILD_AUTOCOMMIT=1 in your environment.'
);
}
const { selected } = await promptAsync({
+3 -2
View File
@@ -1,4 +1,4 @@
import { ExpoConfig, getConfig } from '@expo/config';
import { ExpoConfig } from '@expo/config';
import { AndroidBuildProfile, EasConfig, iOSBuildProfile } from '@expo/eas-json';
import { getProjectAccountName } from '../project/projectUtils';
@@ -25,6 +25,7 @@ export interface CommandContext {
export async function createCommandContextAsync({
requestedPlatform,
profile,
exp,
projectDir,
projectId,
trackingCtx,
@@ -35,6 +36,7 @@ export async function createCommandContextAsync({
}: {
requestedPlatform: RequestedPlatform;
profile: string;
exp: ExpoConfig;
projectId: string;
projectDir: string;
trackingCtx: TrackingContext;
@@ -44,7 +46,6 @@ export async function createCommandContextAsync({
waitForBuildEnd: boolean;
}): Promise<CommandContext> {
const user = await ensureLoggedInAsync();
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = getProjectAccountName(exp, user);
const projectName = exp.slug;
+15 -3
View File
@@ -26,8 +26,8 @@ export async function buildAsync(commandCtx: CommandContext): Promise<void> {
commandCtx,
scheduledBuilds.map(i => i.buildId)
);
Log.newLine();
printBuildResults(commandCtx.accountName, builds);
exitWithNonZeroCodeIfSomeBuildsFailed(builds);
}
}
@@ -88,7 +88,8 @@ async function waitForBuildEndAsync(
})
);
if (builds.length === 1) {
switch (builds[0]?.status) {
const build = builds[0] as Build;
switch (build.status) {
case BuildStatus.FINISHED:
spinner.succeed('Build finished');
return builds;
@@ -104,7 +105,11 @@ async function waitForBuildEndAsync(
break;
case BuildStatus.ERRORED:
spinner.fail('Build failed');
throw new Error(`Standalone build failed!`);
if (build.error) {
return builds;
} else {
throw new Error(`Standalone build failed!`);
}
default:
spinner.warn('Unknown status.');
throw new Error(`Unknown status: ${builds} - aborting!`);
@@ -151,3 +156,10 @@ async function waitForBuildEndAsync(
'Timeout reached! It is taking longer than expected to finish the build, aborting...'
);
}
function exitWithNonZeroCodeIfSomeBuildsFailed(maybeBuilds: (Build | null)[]): void {
const failedBuilds = (maybeBuilds.filter(i => i) as Build[]).filter(i => i.status === 'errored');
if (failedBuilds.length > 0) {
process.exit(1);
}
}
+10 -2
View File
@@ -14,7 +14,7 @@ import { Platform } from '../types';
import { ensureBundleIdentifierIsValidAsync } from './bundleIdentifer';
import { validateAndSyncProjectConfigurationAsync } from './configure';
import { ensureIosCredentialsAsync } from './credentials';
import { prepareJobAsync } from './prepareJob';
import { prepareJobAsync, sanitizedTargetName } from './prepareJob';
export async function prepareIosBuildAsync(
commandCtx: CommandContext,
@@ -45,9 +45,17 @@ export async function prepareIosBuildAsync(
buildCtx.commandCtx.projectDir,
iosBuildScheme
);
} else {
if (!commandCtx.exp.name) {
throw new Error('"expo.name" is required in your app.json');
}
iosApplicationTarget = sanitizedTargetName(commandCtx.exp.name);
if (!iosApplicationTarget) {
throw new Error('"expo.name" needs to contain some alphanumeric characters');
}
}
await ensureBundleIdentifierIsValidAsync(commandCtx.projectDir);
await ensureBundleIdentifierIsValidAsync(commandCtx.projectDir, commandCtx.exp);
return await prepareBuildRequestForPlatformAsync({
ctx: buildCtx,
@@ -21,8 +21,12 @@ function isBundleIdentifierValid(bundleIdentifier: string): boolean {
return /^[a-zA-Z][a-zA-Z0-9\-.]+$/.test(bundleIdentifier);
}
export async function ensureBundleIdentifierIsValidAsync(projectDir: string) {
const bundleIdentifier = await ensureAppIdentifierIsDefinedAsync(projectDir, Platform.IOS);
export async function ensureBundleIdentifierIsValidAsync(projectDir: string, exp: ExpoConfig) {
const bundleIdentifier = await ensureAppIdentifierIsDefinedAsync({
projectDir,
platform: Platform.IOS,
exp,
});
if (!isBundleIdentifierValid(bundleIdentifier)) {
const configDescription = getProjectConfigDescription(projectDir);
Log.error(
+1 -1
View File
@@ -28,7 +28,7 @@ export async function configureIosAsync(ctx: ConfigureContext): Promise<void> {
)?.experimental?.disableIosBundleIdentifierValidation;
if (!disableIosBundleIdentifierValidation) {
await configureBundleIdentifierAsync(ctx.projectDir, ctx.exp);
await ensureBundleIdentifierIsValidAsync(ctx.projectDir);
await ensureBundleIdentifierIsValidAsync(ctx.projectDir, ctx.exp);
}
if (isExpoUpdatesInstalled(ctx.projectDir)) {
+4 -4
View File
@@ -96,6 +96,7 @@ async function prepareJobCommonAsync(
image: ctx.buildProfile.image,
node: ctx.buildProfile.node,
yarn: ctx.buildProfile.yarn,
bundler: ctx.buildProfile.bundler,
cocoapods: ctx.buildProfile.cocoapods,
fastlane: ctx.buildProfile.fastlane,
env: ctx.buildProfile.env,
@@ -150,13 +151,12 @@ async function prepareManagedJobAsync(
): Promise<Partial<Ios.ManagedJob>> {
const projectRootDirectory =
path.relative(await gitRootDirectoryAsync(), ctx.commandCtx.projectDir) || '.';
const accountName = await getProjectAccountNameAsync(ctx.commandCtx.projectDir);
const targetName = sanitizedName(ctx.commandCtx.exp.name);
const accountName = await getProjectAccountNameAsync(ctx.commandCtx.exp);
return {
...(await prepareJobCommonAsync(ctx, {
archiveBucketKey: jobData.archiveBucketKey,
credentials: jobData.credentials,
targetName,
targetName: jobData.projectConfiguration.iosApplicationTarget,
})),
type: Workflow.MANAGED,
buildType: buildProfile.buildType,
@@ -168,7 +168,7 @@ async function prepareManagedJobAsync(
// copy-pasted from expo-cli/packages/xdl/src/Exp.ts
// it's used in eject
function sanitizedName(name: string) {
export function sanitizedTargetName(name: string) {
return name
.replace(/[\W_]+/g, '')
.normalize('NFD')
+5 -1
View File
@@ -35,7 +35,11 @@ export async function collectMetadata<T extends Platform>(
distribution: ctx.buildProfile.distribution ?? 'store',
appName: ctx.commandCtx.exp.name,
appIdentifier:
(await getAppIdentifierAsync(ctx.commandCtx.projectDir, ctx.platform)) ?? undefined,
(await getAppIdentifierAsync({
projectDir: ctx.commandCtx.projectDir,
platform: ctx.platform,
exp: ctx.commandCtx.exp,
})) ?? undefined,
buildProfile: ctx.commandCtx.profile,
gitCommitHash: await gitCommitHashAsync(),
};
+2 -1
View File
@@ -1,4 +1,4 @@
import { Metadata, Platform } from '@expo/eas-build-job';
import { Metadata, Platform, errors } from '@expo/eas-build-job';
import { AndroidBuildProfile, iOSBuildProfile } from '@expo/eas-json';
export enum RequestedPlatform {
@@ -27,6 +27,7 @@ export interface Build {
updatedAt: string;
artifacts?: BuildArtifacts;
metadata?: Partial<Metadata>;
error?: errors.ExternalUserError;
}
interface BuildArtifacts {
@@ -1,7 +1,8 @@
import { errors } from '@expo/eas-build-job';
import assert from 'assert';
import chalk from 'chalk';
import Log from '../../log';
import Log, { learnMore } from '../../log';
import { platformDisplayNames, platformEmojis } from '../constants';
import { Build } from '../types';
import { getBuildLogsUrl } from './url';
@@ -34,18 +35,37 @@ export function printLogsUrls(
}
export function printBuildResults(accountName: string, builds: (Build | null)[]): void {
Log.newLine();
if (builds.length === 1) {
const [build] = builds;
assert(build, 'Build should be defined');
printBuildResult(accountName, build);
} else {
(builds.filter(i => i) as Build[])
.filter(build => build.status === 'finished')
.forEach(build => printBuildResult(accountName, build));
(builds.filter(i => i) as Build[]).forEach(build => printBuildResult(accountName, build));
}
}
function printBuildResult(accountName: string, build: Build): void {
Log.addNewLineIfNone();
if (build.status === 'errored') {
const userError = build.error;
Log.error(
`${platformEmojis[build.platform]} ${platformDisplayNames[build.platform]} build failed${
userError ? ':' : ''
}`
);
if (userError) {
printUserError(userError);
}
return;
}
if (build.status === 'canceled') {
Log.error(
`${platformEmojis[build.platform]} ${platformDisplayNames[build.platform]} build was canceled`
);
return;
}
if (build.metadata?.distribution === 'internal') {
const logsUrl = getBuildLogsUrl({
buildId: build.id,
@@ -57,14 +77,12 @@ function printBuildResult(accountName: string, build: Build): void {
} devices to install the app:`
);
Log.log(`${chalk.underline(logsUrl)}`);
Log.newLine();
} else {
// TODO: it looks like buildUrl could possibly be undefined, based on the code below.
// we should account for this case better if it is possible
const url = build.artifacts?.buildUrl ?? '';
Log.log(`${platformEmojis[build.platform]} ${platformDisplayNames[build.platform]} app:`);
Log.log(`${chalk.underline(url)}`);
Log.newLine();
}
}
@@ -87,3 +105,10 @@ export function printDeprecationWarnings(deprecationInfo?: DeprecationInfo): voi
Log.warn(deprecationInfo);
}
}
export function printUserError(error: errors.ExternalUserError): void {
Log.error(error.message);
if (error.docsUrl) {
Log.error(learnMore(error.docsUrl, { dim: false }));
}
}
+48 -58
View File
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import CliTable from 'cli-table3';
import gql from 'graphql-tag';
@@ -10,7 +11,6 @@ import {
Maybe,
Robot,
Update,
UpdateBranch,
User,
} from '../../graphql/generated';
import Log from '../../log';
@@ -18,6 +18,49 @@ import { findProjectRootAsync, getProjectFullNameAsync } from '../../project/pro
import { getActorDisplayName } from '../../user/actions';
const BRANCHES_LIMIT = 10_000;
export async function listBranchesAsync({ fullName }: { fullName: string }) {
const data = await withErrorHandlingAsync(
graphqlClient
.query<BranchesByAppQuery, BranchesByAppQueryVariables>(
gql`
query BranchesByAppQuery($fullName: String!, $limit: Int!) {
app {
byFullName(fullName: $fullName) {
id
fullName
updateBranches(offset: 0, limit: $limit) {
id
name
updates(offset: 0, limit: 1) {
id
actor {
__typename
id
... on User {
username
}
... on Robot {
firstName
}
}
updatedAt
message
}
}
}
}
}
`,
{
fullName,
limit: BRANCHES_LIMIT,
}
)
.toPromise()
);
return data?.app?.byFullName.updateBranches ?? [];
}
export default class BranchList extends Command {
static hidden = true;
@@ -38,8 +81,9 @@ export default class BranchList extends Command {
if (!projectDir) {
throw new Error('Please run this command inside a project directory.');
}
const fullName = await getProjectFullNameAsync(projectDir);
const branches = await this.listBranchesAsync({ fullName });
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const fullName = await getProjectFullNameAsync(exp);
const branches = await listBranchesAsync({ fullName });
if (flags.json) {
Log.log(JSON.stringify(branches, null, 2));
} else {
@@ -51,63 +95,9 @@ export default class BranchList extends Command {
}
}
}
async listBranchesAsync({
fullName,
}: {
fullName: string;
}): Promise<
(Pick<UpdateBranch, 'id' | 'name'> & {
updates: (Pick<Update, 'id' | 'updatedAt' | 'message'> & {
actor?: Maybe<Pick<User, 'username' | 'id'> | Pick<Robot, 'firstName' | 'id'>>;
})[];
})[]
> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<BranchesByAppQuery, BranchesByAppQueryVariables>(
gql`
query BranchesByAppQuery($fullName: String!, $limit: Int!) {
app {
byFullName(fullName: $fullName) {
id
fullName
updateBranches(offset: 0, limit: $limit) {
id
name
updates(offset: 0, limit: 1) {
id
actor {
__typename
id
... on User {
username
}
... on Robot {
firstName
}
}
updatedAt
message
}
}
}
}
}
`,
{
fullName,
limit: BRANCHES_LIMIT,
}
)
.toPromise()
);
return data?.app?.byFullName.updateBranches ?? [];
}
}
function formatUpdate(
export function formatUpdate(
update: Pick<Update, 'id' | 'updatedAt' | 'message'> & {
actor?: Maybe<Pick<User, 'username' | 'id'> | Pick<Robot, 'firstName' | 'id'>>;
}
+157 -48
View File
@@ -1,51 +1,98 @@
import { getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import assert from 'assert';
import chalk from 'chalk';
import Table from 'cli-table3';
import dateFormat from 'dateformat';
import gql from 'graphql-tag';
import { uniqBy } from 'lodash';
import ora from 'ora';
import { graphqlClient, withErrorHandlingAsync } from '../../graphql/client';
import {
Actor,
GetUpdateGroupAsyncQuery,
RootQueryUpdatesByGroupArgs,
Update,
UpdateInfoGroup,
} from '../../graphql/generated';
import { PublishMutation } from '../../graphql/mutations/PublishMutation';
import Log from '../../log';
import { ensureProjectExistsAsync } from '../../project/ensureProjectExists';
import {
findProjectRootAsync,
getBranchByNameAsync,
getProjectAccountNameAsync,
} from '../../project/projectUtils';
import { findProjectRootAsync, getProjectAccountNameAsync } from '../../project/projectUtils';
import {
buildBundlesAsync,
buildUpdateInfoGroupAsync,
collectAssets,
uploadAssetsAsync,
} from '../../project/publish';
import { promptAsync } from '../../prompts';
import { promptAsync, selectAsync } from '../../prompts';
import { getLastCommitMessageAsync } from '../../utils/git';
import { formatUpdate, listBranchesAsync } from './list';
import { viewUpdateBranchAsync } from './view';
type PublishPlatforms = 'android' | 'ios';
async function getUpdateGroupAsync({
group,
}: RootQueryUpdatesByGroupArgs): Promise<GetUpdateGroupAsyncQuery['updatesByGroup']> {
const { updatesByGroup } = await withErrorHandlingAsync(
graphqlClient
.query<GetUpdateGroupAsyncQuery, RootQueryUpdatesByGroupArgs>(
gql`
query getUpdateGroupAsync($group: ID!) {
updatesByGroup(group: $group) {
id
group
runtimeVersion
manifestFragment
platform
message
}
}
`,
{
group,
}
)
.toPromise()
);
return updatesByGroup;
}
export default class BranchPublish extends Command {
static hidden = true;
static description = 'Publish an update group to a branch.';
static flags = {
'input-dir': flags.string({
description: 'location of the bundle',
default: 'dist',
required: false,
}),
branch: flags.string({
description: 'current name of the branch.',
description: 'name of the branch to publish on.',
}),
message: flags.string({
description: 'Short message describing the updates.',
required: false,
}),
json: flags.boolean({
description: `return a json with the edited branch's ID and name.`,
default: false,
republish: flags.boolean({
description: 'republish an update group',
exclusive: ['input-dir', 'skip-bundler'],
}),
group: flags.string({
description: 'update group to republish',
exclusive: ['input-dir', 'skip-bundler'],
}),
'input-dir': flags.string({
description: 'location of the bundle',
default: 'dist',
required: false,
}),
'skip-bundler': flags.boolean({
description: `skip running Expo CLI to bundle the app before publishing`,
default: false,
}),
json: flags.boolean({
description: `return a json with the new update group.`,
default: false,
}),
};
async run() {
@@ -54,20 +101,23 @@ export default class BranchPublish extends Command {
json: jsonFlag,
branch: name,
message,
republish,
group,
'input-dir': inputDir,
'skip-bundler': skipBundler,
},
} = this.parse(BranchPublish);
// If a group was specified, that means we are republishing it.
republish = group ? true : republish;
const projectDir = await findProjectRootAsync(process.cwd());
if (!projectDir) {
throw new Error('Please run this command inside a project directory.');
}
const accountName = await getProjectAccountNameAsync(projectDir);
const {
exp: { slug, runtimeVersion },
} = getConfig(projectDir, { skipSDKVersionRequirement: true });
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const { slug, runtimeVersion } = exp;
if (!runtimeVersion) {
throw new Error(
"Couldn't find 'runtimeVersion'. Please specify it under the 'expo' key in 'app.json'"
@@ -83,12 +133,79 @@ export default class BranchPublish extends Command {
if (jsonFlag) {
throw new Error(validationMessage);
}
({ name } = await promptAsync({
type: 'text',
name: 'name',
message: 'Please enter the name of the branch to publish on:',
validate: value => (value ? true : validationMessage),
}));
const branches = await listBranchesAsync({ fullName: `@${accountName}/${slug}` });
name = await selectAsync<string>(
'which branch would you like to publish on?',
branches.map(branch => {
return {
title: `${branch.name} ${chalk.grey(
`- current update: ${formatUpdate(branch.updates[0])}`
)}`,
value: branch.name,
};
})
);
}
assert(name, 'branch name must be specified.');
const { id: branchId, updates } = await viewUpdateBranchAsync({
appId: projectId,
name,
});
let updateInfoGroup: UpdateInfoGroup = {};
let oldMessage: string, oldRuntimeVersion: string;
if (republish) {
// If we are republishing, we don't need to worry about building the bundle or uploading the assets.
// Instead we get the `updateInfoGroup` from the update we wish to republish.
let updatesToRepublish: Pick<
Update,
'group' | 'message' | 'runtimeVersion' | 'manifestFragment' | 'platform'
>[];
if (group) {
updatesToRepublish = await getUpdateGroupAsync({ group });
} else {
const updateGroups = uniqBy(updates, u => u.group).map(update => ({
title: formatUpdateTitle(update),
value: update.group,
}));
if (updateGroups.length === 0) {
throw new Error(
`There are no updates on branch "${name}". Did you mean to do a regular publish?`
);
}
const updateGroup = await selectAsync<string>(
'which update would you like to republish?',
updateGroups
);
updatesToRepublish = updates.filter(update => update.group === updateGroup);
}
for (const update of updatesToRepublish) {
const { platform, manifestFragment } = update;
updateInfoGroup[platform as PublishPlatforms] = JSON.parse(manifestFragment);
}
// These are the same for each member of an update group
group = updatesToRepublish[0].group;
oldMessage = updatesToRepublish[0].message ?? '';
oldRuntimeVersion = updatesToRepublish[0].runtimeVersion;
} else {
// build bundle and upload assets for a new publish
if (!skipBundler) {
await buildBundlesAsync({ projectDir, inputDir });
}
const assetSpinner = ora('Uploading assets...').start();
try {
const assets = collectAssets(inputDir!);
await uploadAssetsAsync(assets);
updateInfoGroup = await buildUpdateInfoGroupAsync(assets);
assetSpinner.succeed('Uploaded assets!');
} catch (e) {
assetSpinner.fail('Failed to upload assets');
throw e;
}
}
if (!message) {
@@ -100,39 +217,20 @@ export default class BranchPublish extends Command {
type: 'text',
name: 'publishMessage',
message: `Please enter a publication message.`,
initial: (await getLastCommitMessageAsync())?.trim(),
initial: republish
? `Republish "${oldMessage!}" - group: ${group}`
: (await getLastCommitMessageAsync())?.trim(),
validate: value => (value ? true : validationMessage),
}));
}
const { id: branchId } = await getBranchByNameAsync({
appId: projectId,
name: name!,
});
if (!skipBundler) {
await buildBundlesAsync({ projectDir, inputDir });
}
let updateInfoGroup;
const assetSpinner = ora('Uploading assets...').start();
try {
const assets = collectAssets(inputDir!);
await uploadAssetsAsync(assets);
updateInfoGroup = await buildUpdateInfoGroupAsync(assets);
assetSpinner.succeed('Uploaded assets!');
} catch (e) {
assetSpinner.fail('Failed to upload assets');
throw e;
}
let newUpdateGroup;
const publishSpinner = ora('Publishing...').start();
try {
newUpdateGroup = await PublishMutation.publishUpdateGroupAsync({
branchId,
updateInfoGroup,
runtimeVersion,
runtimeVersion: republish ? oldRuntimeVersion! : runtimeVersion,
message,
});
publishSpinner.succeed('Published!');
@@ -176,3 +274,14 @@ export default class BranchPublish extends Command {
}
}
}
function formatUpdateTitle(
update: Pick<Update, 'message' | 'createdAt' | 'runtimeVersion'> & {
actor?: Pick<Actor, 'firstName'> | null;
}
): string {
const { message, createdAt, actor, runtimeVersion } = update;
return `[${dateFormat(createdAt, 'mmm dd HH:MM')} by ${
actor?.firstName ?? 'unknown'
}, runtimeVersion: ${runtimeVersion}] ${message}`;
}
+12 -6
View File
@@ -24,12 +24,15 @@ const PAGE_LIMIT = 10_000;
type TruncatedUpdate = Pick<Update, 'group' | 'message' | 'createdAt' | 'actor'>;
async function viewUpdateBranchAsync({
export async function viewUpdateBranchAsync({
appId,
name,
}: Pick<ViewBranchQueryVariables, 'appId' | 'name'>): Promise<
Pick<UpdateBranch, 'id' | 'name'> & {
updates: (Pick<Update, 'id' | 'group' | 'message' | 'createdAt'> & {
updates: (Pick<
Update,
'id' | 'group' | 'message' | 'createdAt' | 'runtimeVersion' | 'platform' | 'manifestFragment'
> & {
actor?: Maybe<Pick<User, 'firstName' | 'id'> | Pick<Robot, 'firstName' | 'id'>>;
})[];
}
@@ -50,6 +53,9 @@ async function viewUpdateBranchAsync({
group
message
createdAt
runtimeVersion
platform
manifestFragment
actor {
id
... on User {
@@ -109,10 +115,10 @@ export default class BranchView extends Command {
if (!projectDir) {
throw new Error('Please run this command inside a project directory.');
}
const accountName = await getProjectAccountNameAsync(projectDir);
const {
exp: { slug },
} = getConfig(projectDir, { skipSDKVersionRequirement: true });
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const { slug } = exp;
const projectId = await ensureProjectExistsAsync({
accountName,
projectName: slug,
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command } from '@oclif/command';
import chalk from 'chalk';
import gql from 'graphql-tag';
@@ -115,8 +116,9 @@ export default class BuildCancel extends Command {
const { BUILD_ID: buildIdFromArg } = this.parse(BuildCancel).args;
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const projectId = await getProjectIdAsync(projectDir);
const projectFullName = await getProjectFullNameAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const projectId = await getProjectIdAsync(exp);
const projectFullName = await getProjectFullNameAsync(exp);
if (buildIdFromArg) {
await ensureBuildExistsAsync(buildIdFromArg);
@@ -70,10 +70,9 @@ function logSuccess(platform: RequestedPlatform) {
- Run ${chalk.bold('eas build')} when you are ready to create your first build.
- Once the build is completed, run ${chalk.bold('eas submit')} to upload the app to ${storesText}
- ${learnMore(
'https://docs.expo.io/build/introduction',
'Learn more about other capabilities of EAS Build'
)}`);
- ${learnMore('https://docs.expo.io/build/introduction', {
learnMoreMessage: 'Learn more about other capabilities of EAS Build',
})}`);
}
async function promptForPlatformAsync(): Promise<RequestedPlatform> {
+5 -2
View File
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import chalk from 'chalk';
import fs from 'fs-extra';
@@ -68,7 +69,8 @@ export default class Build extends Command {
(flags.platform as RequestedPlatform | undefined) ?? (await promptForPlatformAsync());
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const projectId = await getProjectIdAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const projectId = await getProjectIdAsync(exp);
if (!(await isEasEnabledForProjectAsync(projectId))) {
warnEasUnavailable();
@@ -76,7 +78,7 @@ export default class Build extends Command {
return;
}
const accountName = await getProjectAccountNameAsync(projectDir);
const accountName = await getProjectAccountNameAsync(exp);
const accountHasPendingBuilds = await ensureNoPendingBuildsExistAsync({
accountName,
platform,
@@ -98,6 +100,7 @@ export default class Build extends Command {
const commandCtx = await createCommandContextAsync({
requestedPlatform: platform,
profile: flags.profile,
exp,
projectDir,
projectId,
trackingCtx,
+5 -3
View File
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import chalk from 'chalk';
import ora from 'ora';
@@ -26,9 +27,10 @@ export default class BuildList extends Command {
const { platform, status, limit = 10 } = this.parse(BuildList).flags;
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const projectId = await getProjectIdAsync(projectDir);
const accountName = await getProjectAccountNameAsync(projectDir);
const projectName = await getProjectFullNameAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const projectId = await getProjectIdAsync(exp);
const accountName = await getProjectAccountNameAsync(exp);
const projectName = await getProjectFullNameAsync(exp);
const spinner = ora().start('Fetching the build list for the project…');
+5 -3
View File
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command } from '@oclif/command';
import { HTTPError } from 'got';
import ora from 'ora';
@@ -22,9 +23,10 @@ export default class BuildView extends Command {
const { BUILD_ID: buildId } = this.parse(BuildView).args;
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const projectId = await getProjectIdAsync(projectDir);
const accountName = await getProjectAccountNameAsync(projectDir);
const projectName = await getProjectFullNameAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const projectId = await getProjectIdAsync(exp);
const accountName = await getProjectAccountNameAsync(exp);
const projectName = await getProjectFullNameAsync(exp);
const spinner = ora().start('Fetching the build…');
@@ -86,10 +86,9 @@ export default class ChannelCreate extends Command {
if (!projectDir) {
throw new Error('Please run this command inside a project directory.');
}
const accountName = await getProjectAccountNameAsync(projectDir);
const {
exp: { slug },
} = getConfig(projectDir, { skipSDKVersionRequirement: true });
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const { slug } = exp;
const projectId = await ensureProjectExistsAsync({
accountName,
projectName: slug,
@@ -125,10 +125,9 @@ export default class ChannelEdit extends Command {
if (!projectDir) {
throw new Error('Please run this command inside a project directory.');
}
const accountName = await getProjectAccountNameAsync(projectDir);
const {
exp: { slug },
} = getConfig(projectDir, { skipSDKVersionRequirement: true });
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const { slug } = exp;
const projectId = await ensureProjectExistsAsync({
accountName,
projectName: slug,
@@ -81,10 +81,9 @@ export default class ChannelList extends Command {
if (!projectDir) {
throw new Error('Please run this command inside a project directory.');
}
const accountName = await getProjectAccountNameAsync(projectDir);
const {
exp: { slug },
} = getConfig(projectDir, { skipSDKVersionRequirement: true });
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const { slug } = exp;
const projectId = await ensureProjectExistsAsync({
accountName,
projectName: slug,
@@ -89,10 +89,9 @@ export default class ChannelView extends Command {
if (!projectDir) {
throw new Error('Please run this command inside a project directory.');
}
const accountName = await getProjectAccountNameAsync(projectDir);
const {
exp: { slug },
} = getConfig(projectDir, { skipSDKVersionRequirement: true });
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const { slug } = exp;
const projectId = await ensureProjectExistsAsync({
accountName,
projectName: slug,
+3 -1
View File
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import assert from 'assert';
import chalk from 'chalk';
@@ -21,7 +22,8 @@ export default class BuildList extends Command {
let appleTeamIdentifier = this.parse(BuildList).flags['apple-team-id'];
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const accountName = await getProjectAccountNameAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
let spinner: ora.Ora;
+3 -1
View File
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command } from '@oclif/command';
import ora from 'ora';
@@ -29,7 +30,8 @@ If you are not sure what is the UDID of the device you are looking for, run:
}
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const accountName = await getProjectAccountNameAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const spinner = ora().start(`Fetching device details for ${UDID}…`);
@@ -0,0 +1,154 @@
import { getConfig } from '@expo/config';
import { Command } from '@oclif/command';
import chalk from 'chalk';
import { EnvironmentSecretMutation } from '../../graphql/mutations/EnvironmentSecretMutation';
import Log from '../../log';
import { ensureProjectExistsAsync } from '../../project/ensureProjectExists';
import {
isEasEnabledForProjectAsync,
warnEasUnavailable,
} from '../../project/isEasEnabledForProject';
import { findProjectRootAsync, getProjectAccountNameAsync } from '../../project/projectUtils';
import { promptAsync } from '../../prompts';
import { findAccountByName } from '../../user/Account';
import { ensureLoggedInAsync, getActorDisplayName } from '../../user/actions';
export enum EnvironmentSecretTargetLocation {
ACCOUNT = 'account',
PROJECT = 'project',
}
export default class EnvironmentSecretCreate extends Command {
static hidden = true;
static description = 'Create an environment secret on the current project or owner account.';
static args = [
{
name: 'target',
required: false,
description: 'Target location for the secret',
options: [EnvironmentSecretTargetLocation.ACCOUNT, EnvironmentSecretTargetLocation.PROJECT],
},
{
name: 'name',
required: false,
description: 'Name of the secret',
},
{
name: 'value',
required: false,
description: 'Value of the secret',
},
];
async run() {
const user = await ensureLoggedInAsync();
let {
args: { name, value: secretValue, target },
} = this.parse(EnvironmentSecretCreate);
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const accountName = await getProjectAccountNameAsync(exp);
const { slug } = exp;
const projectId = await ensureProjectExistsAsync({
accountName,
projectName: slug,
});
if (!(await isEasEnabledForProjectAsync(projectId))) {
warnEasUnavailable();
process.exitCode = 1;
return;
}
if (!target) {
const validationMessage = 'Secret target may not be empty.';
({ target } = await promptAsync({
type: 'select',
name: 'target',
message: 'Where should this secret be used:',
choices: [
{ title: 'Account-wide', value: EnvironmentSecretTargetLocation.ACCOUNT },
{ title: 'Project-specific', value: EnvironmentSecretTargetLocation.PROJECT },
],
validate: value => (value ? true : validationMessage),
}));
}
if (!name) {
({ name } = await promptAsync({
type: 'text',
name: 'name',
message: `Secret name:`,
validate: value => {
if (!value) {
return 'Secret name may not be empty.';
}
if (value.match(/^\w+$/)) {
return 'Names may contain only letters, numbers, and underscores.';
}
return true;
},
}));
}
if (!secretValue) {
const validationMessage = 'Secret value may not be empty.';
({ secretValue } = await promptAsync({
type: 'text',
name: 'secretValue',
message: 'Secret value:',
validate: value => (value ? true : validationMessage),
}));
}
if (target === EnvironmentSecretTargetLocation.PROJECT) {
const secret = await EnvironmentSecretMutation.createForApp(
{ name, value: secretValue },
projectId
);
if (!secret) {
throw new Error(
`Could not create secret with name ${name} on project with id ${projectId}`
);
}
Log.withTick(
`️Created a new secret ${chalk.bold(name)} on project ${chalk.bold(
`@${accountName}/${slug}`
)}.`
);
} else if (target === EnvironmentSecretTargetLocation.ACCOUNT) {
const ownerAccount = findAccountByName(user.accounts, accountName);
if (!ownerAccount) {
Log.warn(
`Your account (${getActorDisplayName(user)}) doesn't have access to the ${chalk.bold(
accountName
)} account`
);
return;
}
const secret = await EnvironmentSecretMutation.createForAccount(
{ name, value: secretValue },
ownerAccount.id
);
if (!secret) {
throw new Error(
`Could not create secret with name ${name} on account with id ${ownerAccount.id}`
);
}
Log.withTick(
`️Created a new secret ${chalk.bold(name)} on account ${chalk.bold(ownerAccount.name)}.`
);
}
}
}
@@ -0,0 +1,61 @@
import { getConfig } from '@expo/config';
import { Command } from '@oclif/command';
import { EnvironmentSecretMutation } from '../../graphql/mutations/EnvironmentSecretMutation';
import Log from '../../log';
import {
isEasEnabledForProjectAsync,
warnEasUnavailable,
} from '../../project/isEasEnabledForProject';
import { findProjectRootAsync, getProjectIdAsync } from '../../project/projectUtils';
import { toggleConfirmAsync } from '../../prompts';
import { ensureLoggedInAsync } from '../../user/actions';
export default class EnvironmentSecretDelete extends Command {
static hidden = true;
static description = `
Delete an environment secret by ID.
Unsure where to find the secret's ID? Run ${'`eas secrets:list`'}
`;
static args = [
{
name: 'id',
required: true,
description: `ID of the secret to delete`,
},
];
async run() {
await ensureLoggedInAsync();
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const projectId = await getProjectIdAsync(exp);
if (!(await isEasEnabledForProjectAsync(projectId))) {
warnEasUnavailable();
process.exitCode = 1;
return;
}
const {
args: { id },
} = this.parse(EnvironmentSecretDelete);
Log.addNewLineIfNone();
Log.warn(
`You are about to permamently delete secret with id: "${id}".\nThis action is irreversable.`
);
Log.newLine();
const confirmed = await toggleConfirmAsync({ message: 'Are you sure you wish to proceed?' });
if (!confirmed) {
Log.error(`Canceled deletion of secret with id: "${id}".`);
process.exit(1);
}
await EnvironmentSecretMutation.delete(id);
Log.withTick(`️Deleted secret with id "${id}".`);
}
}
@@ -0,0 +1,69 @@
import { getConfig } from '@expo/config';
import { Command } from '@oclif/command';
import chalk from 'chalk';
import Table from 'cli-table3';
import dateFormat from 'dateformat';
import { EnvironmentSecretFragment } from '../../graphql/generated';
import { EnvironmentSecretsQuery } from '../../graphql/queries/EnvironmentSecretsQuery';
import Log from '../../log';
import {
isEasEnabledForProjectAsync,
warnEasUnavailable,
} from '../../project/isEasEnabledForProject';
import {
findProjectRootAsync,
getProjectAccountNameAsync,
getProjectFullNameAsync,
getProjectIdAsync,
} from '../../project/projectUtils';
import { ensureLoggedInAsync } from '../../user/actions';
import { EnvironmentSecretTargetLocation } from './create';
export default class EnvironmentSecretsList extends Command {
static description = 'Lists environment secrets available for your current app';
static usage = 'secrets:list';
async run(): Promise<void> {
await ensureLoggedInAsync();
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const projectId = await getProjectIdAsync(exp);
const projectFullName = await getProjectFullNameAsync(exp);
const projectAccountName = await getProjectAccountNameAsync(exp);
if (!(await isEasEnabledForProjectAsync(projectId))) {
warnEasUnavailable();
process.exitCode = 1;
return;
}
if (!projectDir) {
throw new Error("Please run this command inside your project's directory");
}
const [accountSecrets, appSecrets] = await Promise.all([
EnvironmentSecretsQuery.byAcccountNameAsync(projectAccountName),
EnvironmentSecretsQuery.byAppFullNameAsync(projectFullName),
]);
const secrets = [
...appSecrets.map(s => ({ ...s, target: EnvironmentSecretTargetLocation.PROJECT })),
...accountSecrets.map(s => ({ ...s, target: EnvironmentSecretTargetLocation.ACCOUNT })),
] as (EnvironmentSecretFragment & { target: EnvironmentSecretTargetLocation })[];
const table = new Table({
head: ['Name', 'Target', 'Updated at', 'ID'],
wordWrap: true,
});
for (const secret of secrets) {
const { name, createdAt: updatedAt, target, id } = secret;
table.push([name, target, dateFormat(updatedAt, 'mmm dd HH:MM:ss'), id]);
}
Log.log(chalk`{bold Secrets for this account and project:}`);
Log.log(table.toString());
}
}
+3 -1
View File
@@ -1,3 +1,4 @@
import { getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import { learnMore } from '../log';
@@ -168,7 +169,8 @@ export default class BuildSubmit extends Command {
const platform = platformFromParams ?? (await promptForPlatformAsync());
const projectDir = (await findProjectRootAsync()) ?? process.cwd();
const projectId = await getProjectIdAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
const projectId = await getProjectIdAsync(exp);
if (!(await isEasEnabledForProjectAsync(projectId))) {
warnEasUnavailable();
@@ -128,7 +128,7 @@ export default class IosCredentialsProvider implements CredentialsProvider {
} else if (this.options.distribution !== 'internal' && isAdHoc) {
throw new Error(
`You can't use an adhoc provisioning profile${
targetName && ` (target '${targetName})'`
targetName && ` (target '${targetName}')`
} for app store distribution`
);
}
@@ -11,7 +11,11 @@ export class UpdateCredentialsJson implements Action {
constructor(private app: AppLookupParams) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const bundleIdentifer = await ensureAppIdentifierIsDefinedAsync(ctx.projectDir, Platform.IOS);
const bundleIdentifer = await ensureAppIdentifierIsDefinedAsync({
projectDir: ctx.projectDir,
platform: Platform.IOS,
exp: ctx.exp,
});
Log.log('Updating iOS credentials in credentials.json');
await updateIosCredentialsAsync(ctx, bundleIdentifer);
Log.succeed(
+11 -1
View File
@@ -1,9 +1,12 @@
import { ExpoConfig, getConfig } from '@expo/config';
import AppStoreApi from '../credentials/ios/appstore/AppStoreApi';
import { findProjectRootAsync } from '../project/projectUtils';
import { Actor } from '../user/User';
export interface DeviceManagerContext {
appStore: AppStoreApi;
exp: ExpoConfig | null;
projectDir: string | null;
user: Actor;
}
@@ -17,9 +20,16 @@ export async function createContext({
cwd?: string;
user: Actor;
}): Promise<DeviceManagerContext> {
const projectDir = await findProjectRootAsync(cwd);
let exp: ExpoConfig | null = null;
if (projectDir) {
const config = getConfig(projectDir, { skipSDKVersionRequirement: true });
exp = config.exp;
}
return {
appStore,
projectDir: await findProjectRootAsync(cwd),
projectDir,
exp,
user,
};
}
+6 -5
View File
@@ -1,3 +1,4 @@
import { ExpoConfig } from '@expo/config';
import assert from 'assert';
import chalk from 'chalk';
@@ -39,16 +40,16 @@ export default class DeviceManager {
}
private async resolveAccountAsync(): Promise<Account> {
const resolver = new AccountResolver(this.ctx.projectDir, this.ctx.user);
const resolver = new AccountResolver(this.ctx.exp, this.ctx.user);
return await resolver.resolveAccountAsync();
}
}
export class AccountResolver {
constructor(private projectDir: string | null, private user: Actor) {}
constructor(private exp: ExpoConfig | null, private user: Actor) {}
public async resolveAccountAsync(): Promise<Account> {
if (this.projectDir) {
if (this.exp) {
const account = await this.resolveProjectAccountAsync();
if (account) {
return account;
@@ -58,9 +59,9 @@ export class AccountResolver {
}
private async resolveProjectAccountAsync(): Promise<Account | undefined> {
assert(this.projectDir, 'project directory is not set ');
assert(this.exp, 'expo config is not set');
const projectAccountName = await getProjectAccountNameAsync(this.projectDir);
const projectAccountName = await getProjectAccountNameAsync(this.exp);
const projectAccount = findAccountByName(this.user.accounts, projectAccountName);
if (!projectAccount) {
Log.warn(
+220 -117
View File
@@ -31,6 +31,8 @@ export type RootQuery = {
* @deprecated Not used.
*/
_doNotUse?: Maybe<Scalars['String']>;
/** fetch all updates in a group */
updatesByGroup: Array<Update>;
/** Top-level query object for querying Accounts. */
account: AccountQuery;
/** Top-level query object for querying Actors. */
@@ -88,6 +90,11 @@ export type RootQuery = {
};
export type RootQueryUpdatesByGroupArgs = {
group: Scalars['ID'];
};
export type RootQueryAppByAppIdArgs = {
appId: Scalars['String'];
};
@@ -126,24 +133,52 @@ export type RootQueryUserByUsernameArgs = {
username: Scalars['String'];
};
export type AccountQuery = {
__typename?: 'AccountQuery';
/** Query an Account by ID */
byId: Account;
/** Query an Account by name */
byName: Account;
export type Update = ActivityTimelineProjectActivity & {
__typename?: 'Update';
id: Scalars['ID'];
actor?: Maybe<Actor>;
activityTimestamp: Scalars['DateTime'];
branchId: Scalars['ID'];
platform: Scalars['String'];
manifestFragment: Scalars['String'];
runtimeVersion: Scalars['String'];
group: Scalars['String'];
updatedAt: Scalars['DateTime'];
createdAt: Scalars['DateTime'];
message?: Maybe<Scalars['String']>;
branch: UpdateBranch;
};
export type ActivityTimelineProjectActivity = {
id: Scalars['ID'];
actor?: Maybe<Actor>;
activityTimestamp: Scalars['DateTime'];
};
/** A user or robot that can authenticate with Expo services and be a member of accounts. */
export type Actor = {
id: Scalars['ID'];
firstName?: Maybe<Scalars['String']>;
created?: Maybe<Scalars['DateTime']>;
isExpoAdmin?: Maybe<Scalars['Boolean']>;
/** Associated accounts */
accounts: Array<Account>;
/** Access Tokens belonging to this actor */
accessTokens: Array<AccessToken>;
/**
* Server feature gate values for this actor, optionally filtering by desired gates.
* Only resolves for the viewer.
*/
featureGates: Scalars['JSONObject'];
};
export type AccountQueryByIdArgs = {
accountId: Scalars['String'];
/** A user or robot that can authenticate with Expo services and be a member of accounts. */
export type ActorFeatureGatesArgs = {
filter?: Maybe<Array<Scalars['String']>>;
};
export type AccountQueryByNameArgs = {
accountName: Scalars['String'];
};
/**
* An account is a container owning projects, credentials, billing and other organization
* data and settings. Actors may own and be members of accounts.
@@ -217,6 +252,7 @@ export type AccountSnacksArgs = {
export type AccountAppsArgs = {
offset: Scalars['Int'];
limit: Scalars['Int'];
includeUnpublished?: Maybe<Scalars['Boolean']>;
};
@@ -287,7 +323,6 @@ export type AccountEnvironmentSecretsArgs = {
filterNames?: Maybe<Array<Scalars['String']>>;
};
export type Offer = {
__typename?: 'Offer';
id: Scalars['ID'];
@@ -575,6 +610,7 @@ export type UserSnacksArgs = {
export type UserAppsArgs = {
offset: Scalars['Int'];
limit: Scalars['Int'];
includeUnpublished?: Maybe<Scalars['Boolean']>;
};
@@ -590,43 +626,6 @@ export type UserFeatureGatesArgs = {
filter?: Maybe<Array<Scalars['String']>>;
};
/** A user or robot that can authenticate with Expo services and be a member of accounts. */
export type Actor = {
id: Scalars['ID'];
firstName?: Maybe<Scalars['String']>;
created?: Maybe<Scalars['DateTime']>;
isExpoAdmin?: Maybe<Scalars['Boolean']>;
/** Associated accounts */
accounts: Array<Account>;
/** Access Tokens belonging to this actor */
accessTokens: Array<AccessToken>;
/**
* Server feature gate values for this actor, optionally filtering by desired gates.
* Only resolves for the viewer.
*/
featureGates: Scalars['JSONObject'];
};
/** A user or robot that can authenticate with Expo services and be a member of accounts. */
export type ActorFeatureGatesArgs = {
filter?: Maybe<Array<Scalars['String']>>;
};
/** A method of authentication for an Actor */
export type AccessToken = {
__typename?: 'AccessToken';
id: Scalars['ID'];
visibleTokenPrefix: Scalars['String'];
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
revokedAt?: Maybe<Scalars['DateTime']>;
lastUsedAt?: Maybe<Scalars['DateTime']>;
owner: Actor;
note?: Maybe<Scalars['String']>;
};
/** A second factor device belonging to a User */
export type UserSecondFactorDevice = {
__typename?: 'UserSecondFactorDevice';
@@ -648,6 +647,19 @@ export enum SecondFactorMethod {
Sms = 'SMS'
}
/** A method of authentication for an Actor */
export type AccessToken = {
__typename?: 'AccessToken';
id: Scalars['ID'];
visibleTokenPrefix: Scalars['String'];
createdAt: Scalars['DateTime'];
updatedAt: Scalars['DateTime'];
revokedAt?: Maybe<Scalars['DateTime']>;
lastUsedAt?: Maybe<Scalars['DateTime']>;
owner: Actor;
note?: Maybe<Scalars['String']>;
};
/** An pending invitation sent to an email granting membership on an Account. */
export type UserInvitation = {
__typename?: 'UserInvitation';
@@ -679,6 +691,7 @@ export enum Role {
NotAdmin = 'NOT_ADMIN'
}
export enum AppPlatform {
Ios = 'IOS',
Android = 'ANDROID'
@@ -727,12 +740,9 @@ export type Build = ActivityTimelineProjectActivity & {
releaseChannel?: Maybe<Scalars['String']>;
metrics?: Maybe<BuildMetrics>;
distribution?: Maybe<DistributionType>;
};
export type ActivityTimelineProjectActivity = {
id: Scalars['ID'];
actor?: Maybe<Actor>;
activityTimestamp: Scalars['DateTime'];
buildProfile?: Maybe<Scalars['String']>;
gitCommitHash?: Maybe<Scalars['String']>;
error?: Maybe<BuildError>;
};
export type BuildArtifacts = {
@@ -753,6 +763,12 @@ export enum DistributionType {
Simulator = 'SIMULATOR'
}
export type BuildError = {
__typename?: 'BuildError';
errorCode?: Maybe<Scalars['String']>;
message?: Maybe<Scalars['String']>;
};
/** Represents an Standalone App build job */
export type BuildJob = ActivityTimelineProjectActivity & {
__typename?: 'BuildJob';
@@ -1060,22 +1076,6 @@ export type UpdateBranchUpdatesArgs = {
limit: Scalars['Int'];
};
export type Update = ActivityTimelineProjectActivity & {
__typename?: 'Update';
id: Scalars['ID'];
actor?: Maybe<Actor>;
activityTimestamp: Scalars['DateTime'];
branchId: Scalars['ID'];
platform: Scalars['String'];
manifestFragment: Scalars['String'];
runtimeVersion: Scalars['String'];
group: Scalars['String'];
updatedAt: Scalars['DateTime'];
createdAt: Scalars['DateTime'];
message?: Maybe<Scalars['String']>;
branch: UpdateBranch;
};
export type EnvironmentSecret = {
__typename?: 'EnvironmentSecret';
id: Scalars['ID'];
@@ -1149,6 +1149,24 @@ export type Charge = {
receiptUrl?: Maybe<Scalars['String']>;
};
export type AccountQuery = {
__typename?: 'AccountQuery';
/** Query an Account by ID */
byId: Account;
/** Query an Account by name */
byName: Account;
};
export type AccountQueryByIdArgs = {
accountId: Scalars['String'];
};
export type AccountQueryByNameArgs = {
accountName: Scalars['String'];
};
export type ActorQuery = {
__typename?: 'ActorQuery';
/** Query an Actor by ID */
@@ -1573,19 +1591,9 @@ export type DeleteAccessTokenResult = {
export type AccountMutation = {
__typename?: 'AccountMutation';
/**
* Add user to an account
* @deprecated Use 'grantActorPermissions' mutation.
*/
grantAccess?: Maybe<Account>;
/**
* Revoke permissions for a given user
* @deprecated Use 'revokeActorPermissions' mutation.
*/
revokeAccess?: Maybe<Account>;
/** Add specified account Permissions for Actor */
/** Add specified account Permissions for Actor. Actor must already have at least one permission on the account. */
grantActorPermissions?: Maybe<Account>;
/** Revoke specified Permissions for Actor */
/** Revoke specified Permissions for Actor. Actor must already have at least one permission on the account. */
revokeActorPermissions?: Maybe<Account>;
/** Add a subscription */
subscribeToProduct?: Maybe<Account>;
@@ -1603,8 +1611,6 @@ export type AccountMutation = {
setBuildAutoRenew?: Maybe<Account>;
/** Set payment details */
setPaymentSource?: Maybe<Account>;
/** Extend offer to account */
extendOffer?: Maybe<Account>;
/** Send an email to primary account email */
sendEmail?: Maybe<Account>;
/** Require authorization to send push notifications for experiences owned by this account */
@@ -1612,20 +1618,6 @@ export type AccountMutation = {
};
export type AccountMutationGrantAccessArgs = {
accountName: Scalars['ID'];
toUser: Scalars['ID'];
accessLevels?: Maybe<Array<Maybe<Permission>>>;
};
export type AccountMutationRevokeAccessArgs = {
accountName: Scalars['ID'];
fromUser: Scalars['ID'];
accessLevels?: Maybe<Array<Maybe<Permission>>>;
};
export type AccountMutationGrantActorPermissionsArgs = {
accountID: Scalars['ID'];
actorID: Scalars['ID'];
@@ -1672,13 +1664,6 @@ export type AccountMutationSetPaymentSourceArgs = {
};
export type AccountMutationExtendOfferArgs = {
accountName: Scalars['ID'];
offer: StandardOffer;
suppressMessage?: Maybe<Scalars['Boolean']>;
};
export type AccountMutationSendEmailArgs = {
accountName: Scalars['ID'];
emailTemplate: EmailTemplate;
@@ -1690,15 +1675,6 @@ export type AccountMutationSetPushSecurityEnabledArgs = {
pushSecurityEnabled: Scalars['Boolean'];
};
export enum StandardOffer {
/** $29 USD per month, 30 day trial */
Default = 'DEFAULT',
/** $29 USD per month, 1 year trial */
YcDeals = 'YC_DEALS',
/** $800 USD per month */
Support = 'SUPPORT'
}
export enum EmailTemplate {
/** Able to purchase Developer Services */
DevServicesOfferExtended = 'DEV_SERVICES_OFFER_EXTENDED',
@@ -2352,6 +2328,11 @@ export type UserInvitationMutation = {
resendUserInvitation: UserInvitation;
/** Rescind UserInvitation by ID */
deleteUserInvitation: RescindUserInvitationResult;
/**
* Delete UserInvitation by token. Note that the viewer's email is not required to match
* the email on the invitation.
*/
deleteUserInvitationByToken: RescindUserInvitationResult;
/** Accept UserInvitation by ID. Viewer must have matching email and email must be verified. */
acceptUserInvitationAsViewer: AcceptUserInvitationResult;
/**
@@ -2380,6 +2361,11 @@ export type UserInvitationMutationDeleteUserInvitationArgs = {
};
export type UserInvitationMutationDeleteUserInvitationByTokenArgs = {
token: Scalars['ID'];
};
export type UserInvitationMutationAcceptUserInvitationAsViewerArgs = {
id: Scalars['ID'];
};
@@ -2665,6 +2651,15 @@ export type DeleteEnvironmentSecretResult = {
id: Scalars['ID'];
};
export enum StandardOffer {
/** $29 USD per month, 30 day trial */
Default = 'DEFAULT',
/** $29 USD per month, 1 year trial */
YcDeals = 'YC_DEALS',
/** $800 USD per month */
Support = 'SUPPORT'
}
export type BaseSearchResult = SearchResult & {
__typename?: 'BaseSearchResult';
/** @deprecated Use SearchResult instead */
@@ -2795,6 +2790,19 @@ export type BranchesByAppQuery = (
)> }
);
export type GetUpdateGroupAsyncQueryVariables = Exact<{
group: Scalars['ID'];
}>;
export type GetUpdateGroupAsyncQuery = (
{ __typename?: 'RootQuery' }
& { updatesByGroup: Array<(
{ __typename?: 'Update' }
& Pick<Update, 'id' | 'group' | 'runtimeVersion' | 'manifestFragment' | 'platform' | 'message'>
)> }
);
export type EditUpdateBranchMutationVariables = Exact<{
input: EditUpdateBranchInput;
}>;
@@ -2830,7 +2838,7 @@ export type ViewBranchQuery = (
& Pick<UpdateBranch, 'id' | 'name'>
& { updates: Array<(
{ __typename?: 'Update' }
& Pick<Update, 'id' | 'group' | 'message' | 'createdAt'>
& Pick<Update, 'id' | 'group' | 'message' | 'createdAt' | 'runtimeVersion' | 'platform' | 'manifestFragment'>
& { actor?: Maybe<(
{ __typename?: 'User' }
& Pick<User, 'firstName' | 'id'>
@@ -3599,6 +3607,56 @@ export type CommonIosAppCredentialsWithBuildCredentialsByAppIdentifierIdQuery =
)> }
);
export type CreateEnvironmentSecretForAccountMutationVariables = Exact<{
input: CreateEnvironmentSecretInput;
accountId: Scalars['String'];
}>;
export type CreateEnvironmentSecretForAccountMutation = (
{ __typename?: 'RootMutation' }
& { environmentSecret: (
{ __typename?: 'EnvironmentSecretMutation' }
& { createEnvironmentSecretForAccount: (
{ __typename?: 'EnvironmentSecret' }
& EnvironmentSecretFragment
) }
) }
);
export type CreateEnvironmentSecretForAppMutationVariables = Exact<{
input: CreateEnvironmentSecretInput;
appId: Scalars['String'];
}>;
export type CreateEnvironmentSecretForAppMutation = (
{ __typename?: 'RootMutation' }
& { environmentSecret: (
{ __typename?: 'EnvironmentSecretMutation' }
& { createEnvironmentSecretForApp: (
{ __typename?: 'EnvironmentSecret' }
& EnvironmentSecretFragment
) }
) }
);
export type DeleteEnvironmentSecretMutationVariables = Exact<{
id: Scalars['String'];
}>;
export type DeleteEnvironmentSecretMutation = (
{ __typename?: 'RootMutation' }
& { environmentSecret: (
{ __typename?: 'EnvironmentSecretMutation' }
& { deleteEnvironmentSecret: (
{ __typename?: 'DeleteEnvironmentSecretResult' }
& Pick<DeleteEnvironmentSecretResult, 'id'>
) }
) }
);
export type GetSignedUploadMutationVariables = Exact<{
contentTypes: Array<Scalars['String']>;
}>;
@@ -3699,6 +3757,46 @@ export type PendingBuildsForAccountAndPlatformQuery = (
) }
);
export type EnvironmentSecretsByAccountNameQueryVariables = Exact<{
accountName: Scalars['String'];
}>;
export type EnvironmentSecretsByAccountNameQuery = (
{ __typename?: 'RootQuery' }
& { account: (
{ __typename?: 'AccountQuery' }
& { byName: (
{ __typename?: 'Account' }
& Pick<Account, 'id'>
& { environmentSecrets: Array<(
{ __typename?: 'EnvironmentSecret' }
& EnvironmentSecretFragment
)> }
) }
) }
);
export type EnvironmentSecretsByAppFullNameQueryVariables = Exact<{
fullName: Scalars['String'];
}>;
export type EnvironmentSecretsByAppFullNameQuery = (
{ __typename?: 'RootQuery' }
& { app?: Maybe<(
{ __typename?: 'AppQuery' }
& { byFullName: (
{ __typename?: 'App' }
& Pick<App, 'id'>
& { environmentSecrets: Array<(
{ __typename?: 'EnvironmentSecret' }
& EnvironmentSecretFragment
)> }
) }
)> }
);
export type ProjectByUsernameAndSlugQueryVariables = Exact<{
username: Scalars['String'];
slug: Scalars['String'];
@@ -3762,6 +3860,11 @@ export type AppFragment = (
& Pick<App, 'id' | 'fullName' | 'slug'>
);
export type EnvironmentSecretFragment = (
{ __typename?: 'EnvironmentSecret' }
& Pick<EnvironmentSecret, 'id' | 'name' | 'createdAt'>
);
export type AppleAppIdentifierFragment = (
{ __typename?: 'AppleAppIdentifier' }
& Pick<AppleAppIdentifier, 'id' | 'bundleIdentifier'>
@@ -0,0 +1,93 @@
import { print } from 'graphql';
import gql from 'graphql-tag';
import { graphqlClient, withErrorHandlingAsync } from '../client';
import {
CreateEnvironmentSecretForAccountMutation,
CreateEnvironmentSecretForAppMutation,
DeleteEnvironmentSecretMutation,
EnvironmentSecretFragment,
} from '../generated';
import { EnvironmentSecretFragmentNode } from '../types/EnvironmentSecret';
export const EnvironmentSecretMutation = {
async createForAccount(
input: { name: string; value: string },
accountId: string
): Promise<EnvironmentSecretFragment> {
const data = await withErrorHandlingAsync(
graphqlClient
.mutation<CreateEnvironmentSecretForAccountMutation>(
gql`
mutation CreateEnvironmentSecretForAccount(
$input: CreateEnvironmentSecretInput!
$accountId: String!
) {
environmentSecret {
createEnvironmentSecretForAccount(
environmentSecretData: $input
accountId: $accountId
) {
id
...EnvironmentSecretFragment
}
}
}
${print(EnvironmentSecretFragmentNode)}
`,
{ input, accountId }
)
.toPromise()
);
return data.environmentSecret.createEnvironmentSecretForAccount;
},
async createForApp(
input: { name: string; value: string },
appId: string
): Promise<EnvironmentSecretFragment> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<CreateEnvironmentSecretForAppMutation>(
gql`
mutation CreateEnvironmentSecretForApp(
$input: CreateEnvironmentSecretInput!
$appId: String!
) {
environmentSecret {
createEnvironmentSecretForApp(environmentSecretData: $input, appId: $appId) {
id
...EnvironmentSecretFragment
}
}
}
${print(EnvironmentSecretFragmentNode)}
`,
{ input, appId }
)
.toPromise()
);
return data.environmentSecret.createEnvironmentSecretForApp;
},
async delete(id: string): Promise<{ id: string }> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<DeleteEnvironmentSecretMutation>(
gql`
mutation DeleteEnvironmentSecret($id: String!) {
environmentSecret {
deleteEnvironmentSecret(id: $id) {
id
}
}
}
`,
{ id }
)
.toPromise()
);
return data.environmentSecret.deleteEnvironmentSecret;
},
};
@@ -31,7 +31,7 @@ const PublishMutation = {
async publishUpdateGroupAsync(
publishUpdateGroupInput: PublishUpdateGroupInput
): Promise<Pick<Update, 'id' | 'group'>> {
): Promise<Pick<Update, 'group'>> {
const data = await withErrorHandlingAsync(
graphqlClient
.mutation<UpdatePublishMutation>(
@@ -49,7 +49,8 @@ const PublishMutation = {
)
.toPromise()
);
return data.updateBranch.publishUpdateGroup[0]!;
const { group } = data.updateBranch.publishUpdateGroup[0]!;
return { group };
},
};
@@ -0,0 +1,63 @@
import { print } from 'graphql';
import gql from 'graphql-tag';
import { graphqlClient, withErrorHandlingAsync } from '../client';
import {
EnvironmentSecretFragment,
EnvironmentSecretsByAccountNameQuery,
EnvironmentSecretsByAppFullNameQuery,
} from '../generated';
import { EnvironmentSecretFragmentNode } from '../types/EnvironmentSecret';
export const EnvironmentSecretsQuery = {
async byAcccountNameAsync(accountName: string): Promise<EnvironmentSecretFragment[]> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<EnvironmentSecretsByAccountNameQuery>(
gql`
query EnvironmentSecretsByAccountName($accountName: String!) {
account {
byName(accountName: $accountName) {
id
environmentSecrets {
id
...EnvironmentSecretFragment
}
}
}
}
${print(EnvironmentSecretFragmentNode)}
`,
{ accountName }
)
.toPromise()
);
return data.account.byName.environmentSecrets;
},
async byAppFullNameAsync(fullName: string): Promise<EnvironmentSecretFragment[]> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<EnvironmentSecretsByAppFullNameQuery>(
gql`
query EnvironmentSecretsByAppFullName($fullName: String!) {
app {
byFullName(fullName: $fullName) {
id
environmentSecrets {
id
...EnvironmentSecretFragment
}
}
}
}
${print(EnvironmentSecretFragmentNode)}
`,
{ fullName }
)
.toPromise()
);
return data.app?.byFullName.environmentSecrets ?? [];
},
};
@@ -0,0 +1,9 @@
import gql from 'graphql-tag';
export const EnvironmentSecretFragmentNode = gql`
fragment EnvironmentSecretFragment on EnvironmentSecret {
id
name
createdAt
}
`;
+9 -4
View File
@@ -78,15 +78,20 @@ export default class Log {
}
/**
* Format links as dim with an underline.
* Format links as dim (unless disabled) with an underline.
*
* @example Learn more: https://expo.io
* @param url
*/
export function learnMore(url: string, learnMoreMessage?: string): string {
export function learnMore(
url: string,
{ learnMoreMessage, dim = true }: { learnMoreMessage?: string; dim?: boolean } = {}
): string {
// Links can be disabled via env variables https://github.com/jamestalmage/supports-hyperlinks/blob/master/index.js
if (terminalLink.isSupported) {
return chalk.dim(terminalLink(learnMoreMessage ?? 'Learn more.', url));
const text = terminalLink(learnMoreMessage ?? 'Learn more.', url);
return dim ? chalk.dim(text) : text;
}
return chalk.dim(`${learnMoreMessage ?? 'Learn more'}: ${chalk.underline(url)}`);
const text = `${learnMoreMessage ?? 'Learn more'}: ${chalk.underline(url)}`;
return dim ? chalk.dim(text) : text;
}
@@ -1,4 +1,3 @@
import { getConfig } from '@expo/config';
import { vol } from 'memfs';
import { asMock } from '../../__tests__/utils';
@@ -64,6 +63,7 @@ describe(getProjectAccountName, () => {
__typename: 'User',
id: 'userId',
username: 'notbrent',
accounts: [],
});
expect(projectAccountName).toBe(expWithOwner.owner);
});
@@ -73,6 +73,7 @@ describe(getProjectAccountName, () => {
__typename: 'Robot',
id: 'userId',
firstName: 'notauser',
accounts: [],
});
expect(projectAccountName).toBe(expWithOwner.owner);
});
@@ -82,6 +83,7 @@ describe(getProjectAccountName, () => {
__typename: 'User',
id: 'userId',
username: 'dominik',
accounts: [],
});
expect(projectAccountName).toBe('dominik');
});
@@ -92,23 +94,21 @@ describe(getProjectAccountName, () => {
__typename: 'Robot',
id: 'userId',
firstName: 'notauser',
accounts: [],
});
expect(resolveProjectAccountName).toThrow('manifest property is required');
});
});
describe(getProjectAccountNameAsync, () => {
const expWithOwner: any = { owner: 'dominik' };
const expWithoutOwner: any = {};
beforeEach(() => {
asMock(getConfig).mockReset();
asMock(getUserAsync).mockReset();
});
it(`returns the owner field's value from app.json / app.config.js`, async () => {
asMock(getConfig).mockImplementation(() => ({
exp: {
owner: 'dominik',
},
}));
asMock(getUserAsync).mockImplementation((): Actor | undefined => ({
__typename: 'User',
id: 'user_id',
@@ -119,14 +119,11 @@ describe(getProjectAccountNameAsync, () => {
],
}));
const projectAccountName = await getProjectAccountNameAsync('/app');
const projectAccountName = await getProjectAccountNameAsync(expWithOwner);
expect(projectAccountName).toBe('dominik');
});
it(`returns the username if owner field is not set in app.json / app.config.js`, async () => {
asMock(getConfig).mockImplementation(() => ({
exp: {},
}));
asMock(getUserAsync).mockImplementation((): Actor | undefined => ({
__typename: 'User',
id: 'user_id',
@@ -137,25 +134,19 @@ describe(getProjectAccountNameAsync, () => {
],
}));
const projectAccountName = await getProjectAccountNameAsync('/app');
const projectAccountName = await getProjectAccountNameAsync(expWithoutOwner);
expect(projectAccountName).toBe('notnotbrent');
});
it(`throws an error if the user is not logged in`, async () => {
asMock(getConfig).mockImplementation(() => ({
exp: {
owner: 'dominik',
},
}));
asMock(getUserAsync).mockImplementation((): Actor | undefined => undefined);
await expect(getProjectAccountNameAsync('/app')).rejects.toThrow(/Failed to access user data/);
await expect(getProjectAccountNameAsync(expWithOwner)).rejects.toThrow(
/Failed to access user data/
);
});
it(`throws when project owner is undefined for robot actors`, async () => {
asMock(getConfig).mockImplementation(() => ({
exp: {},
}));
asMock(getUserAsync).mockImplementation((): Actor | undefined => ({
__typename: 'Robot',
id: 'user_id',
@@ -165,7 +156,7 @@ describe(getProjectAccountNameAsync, () => {
{ id: 'account_id_2', name: 'dominik' },
],
}));
await expect(getProjectAccountNameAsync('/app')).rejects.toThrow(
await expect(getProjectAccountNameAsync(expWithoutOwner)).rejects.toThrow(
'manifest property is required'
);
});
+24 -19
View File
@@ -1,4 +1,4 @@
import { ExpoConfig, getConfig, getConfigFilePaths } from '@expo/config';
import { ExpoConfig, getConfigFilePaths } from '@expo/config';
import { AndroidConfig, IOSConfig } from '@expo/config-plugins';
import { Platform } from '@expo/eas-build-job';
import fs from 'fs-extra';
@@ -26,8 +26,7 @@ export function getProjectAccountName(exp: ExpoConfig, user: Actor): string {
}
}
export async function getProjectAccountNameAsync(projectDir: string): Promise<string> {
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
export async function getProjectAccountNameAsync(exp: ExpoConfig): Promise<string> {
const user = await ensureLoggedInAsync();
return getProjectAccountName(exp, user);
}
@@ -37,8 +36,7 @@ export async function findProjectRootAsync(cwd?: string): Promise<string | null>
return projectRootDir ?? null;
}
export async function getProjectIdAsync(projectDir: string): Promise<string> {
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
export async function getProjectIdAsync(exp: ExpoConfig): Promise<string> {
return await ensureProjectExistsAsync({
accountName: getProjectAccountName(exp, await ensureLoggedInAsync()),
projectName: exp.slug,
@@ -46,10 +44,8 @@ export async function getProjectIdAsync(projectDir: string): Promise<string> {
});
}
export async function getProjectFullNameAsync(projectDir: string): Promise<string> {
const accountName = await getProjectAccountNameAsync(projectDir);
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
export async function getProjectFullNameAsync(exp: ExpoConfig): Promise<string> {
const accountName = await getProjectAccountNameAsync(exp);
return `@${accountName}/${exp.slug}`;
}
@@ -65,11 +61,15 @@ export async function getAndroidApplicationIdAsync(projectDir: string): Promise<
return matchResult?.[1] ?? null;
}
export async function getAppIdentifierAsync(
projectDir: string,
platform: Platform
): Promise<string | null> {
const { exp } = getConfig(projectDir, { skipSDKVersionRequirement: true });
export async function getAppIdentifierAsync({
projectDir,
platform,
exp,
}: {
projectDir: string;
platform: Platform;
exp: ExpoConfig;
}): Promise<string | null> {
switch (platform) {
case Platform.ANDROID: {
const packageNameFromConfig = AndroidConfig.Package.getPackage(exp);
@@ -89,11 +89,16 @@ export async function getAppIdentifierAsync(
}
}
export async function ensureAppIdentifierIsDefinedAsync(
projectDir: string,
platform: Platform
): Promise<string> {
const appIdentifier = await getAppIdentifierAsync(projectDir, platform);
export async function ensureAppIdentifierIsDefinedAsync({
projectDir,
platform,
exp,
}: {
projectDir: string;
platform: Platform;
exp: ExpoConfig;
}): Promise<string> {
const appIdentifier = await getAppIdentifierAsync({ projectDir, platform, exp });
if (!appIdentifier) {
const desc = getProjectConfigDescription(projectDir);
const fieldStr = platform === Platform.ANDROID ? 'android.package' : 'ios.bundleIdentifier';
@@ -210,7 +210,7 @@ async function handlePromptSourceAsync(source: ArchiveFilePromptSource): Promise
});
}
case ArchiveFileSourceType.path: {
const path = await askForArchivePathAsync();
const path = await askForArchivePathAsync(source.platform);
return getArchiveFileLocationAsync({
...source,
sourceType: ArchiveFileSourceType.path,
@@ -258,11 +258,12 @@ async function askForArchiveUrlAsync(): Promise<string> {
return url;
}
async function askForArchivePathAsync(): Promise<string> {
const defaultArchivePath = '/path/to/your/archive.aab';
async function askForArchivePathAsync(platform: SubmissionPlatform): Promise<string> {
const isIos = platform === SubmissionPlatform.iOS;
const defaultArchivePath = `/path/to/your/archive.${isIos ? 'ipa' : 'aab'}`;
const { path } = await promptAsync({
name: 'path',
message: 'Path to the app archive file (aab or apk):',
message: `Path to the app archive file (${isIos ? 'ipa' : 'aab or apk'}):`,
initial: defaultArchivePath,
type: 'text',
validate: async (path: string): Promise<boolean | string> => {
@@ -39,7 +39,8 @@ export async function ensureAppStoreConnectAppExistsAsync(
const { bundleIdentifier, appName, language } = ctx.commandFlags;
const resolvedBundleId =
bundleIdentifier ?? (await getAppIdentifierAsync(ctx.projectDir, Platform.IOS));
bundleIdentifier ??
(await getAppIdentifierAsync({ projectDir: ctx.projectDir, platform: Platform.IOS, exp }));
if (!resolvedBundleId) {
throw new Error(
`Please define "expo.ios.bundleIdentifier" in your app config or provide it using --bundle-identifier param.
@@ -60,7 +60,7 @@ class IosSubmitter extends BaseSubmitter<IosSubmissionContext, IosSubmissionOpti
'- When it’s done, you can see your build here' +
learnMore(
`https://appstoreconnect.apple.com/apps/${this.options.ascAppId}/appstore/ios`,
''
{ learnMoreMessage: '' }
)
);
}
+2 -2
View File
@@ -1,11 +1,11 @@
{
"name": "@expo/eas-json",
"description": "A library for interacting with the eas.json",
"version": "0.6.0",
"version": "0.7.0",
"author": "Expo <[email protected]>",
"bugs": "https://github.com/expo/eas-cli/issues",
"dependencies": {
"@expo/eas-build-job": "0.2.16",
"@expo/eas-build-job": "0.2.21",
"@hapi/joi": "^17.1.1",
"fs-extra": "^9.0.1",
"tslib": "^1"
+3 -4
View File
@@ -150,15 +150,14 @@ export class EasJsonReader {
if (!buildProfile) {
throw new Error(`There is no profile named ${buildProfileName} for platform ${platform}`);
}
const baseProfileName = buildProfile.extends;
delete buildProfile.extends;
const { extends: baseProfileName, ...buildProfileRest } = buildProfile;
if (baseProfileName) {
return deepMerge(
this.resolveBuildProfile(platform, baseProfileName, buildProfiles, depth + 1),
buildProfile
buildProfileRest
);
} else {
return buildProfile;
return buildProfileRest;
}
}
}
+1
View File
@@ -25,6 +25,7 @@ const IosBuilderEnvironmentSchema = Joi.object({
.default('default'),
node: Joi.string().empty(null).custom(semverSchemaCheck),
yarn: Joi.string().empty(null).custom(semverSchemaCheck),
bundler: Joi.string().empty(null).custom(semverSchemaCheck),
fastlane: Joi.string().empty(null).custom(semverSchemaCheck),
cocoapods: Joi.string().empty(null).custom(semverSchemaCheck),
env: Joi.object().pattern(Joi.string(), Joi.string().empty(null)).default({}),
+4 -4
View File
@@ -1151,10 +1151,10 @@
xcode "^3.0.0"
xml-js "^1.6.11"
"@expo/[email protected]6":
version "0.2.16"
resolved "https://registry.yarnpkg.com/@expo/eas-build-job/-/eas-build-job-0.2.16.tgz#490be96d32f4b9ef4501d117796f523680ce5a00"
integrity sha512-PJRYwk3phLDpqtIKTEBgyqvJsxCoa55CHYRJguRJ9lYHxqxL/litUruxu1Y5cjF+iGXw/ElpN2C75wuboUdjcw==
"@expo/[email protected].21":
version "0.2.21"
resolved "https://registry.yarnpkg.com/@expo/eas-build-job/-/eas-build-job-0.2.21.tgz#86c4d69d36dc4efc7a23fea97c8d6a73f27295de"
integrity sha512-H0yNXmeiLQ382gqSRBbAruew6ptmM3TPzWNPXc9yIxj0dPLOBhezu2LV7H+n1BcNp15aWeZIRb4e95vs4iy78Q==
dependencies:
"@hapi/joi" "^17.1.1"