Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli] Improve readability of asyncActionProjectDir #1989

Merged
merged 3 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions packages/expo-cli/src/commands/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ export default function(program: Command) {
.command('android [project-dir]')
.description(chalk.yellow`Deprecated: Opens your app in Expo on a connected Android device`)
.allowOffline()
.asyncActionProjectDir(
() => {
// Deprecate after July 24, 2020 (3 months)
console.log(
boxen(
chalk.yellow(
`${chalk.bold(
`expo android`
)} is deprecated. You can open your project by:\n- Pressing ${chalk.bold`a`} in the ${chalk.bold`expo start`} terminal UI\n- Or by running ${chalk.bold`expo start --android`}`
),
{ borderColor: 'yellow', padding: 1 }
)
);
},
/* skipProjectValidation: */ true,
/* skipAuthCheck: */ true
);
.asyncActionProjectDir(() => {
// Deprecate after July 24, 2020 (3 months)
console.log(
boxen(
chalk.yellow(
`${chalk.bold(
`expo android`
)} is deprecated. You can open your project by:\n- Pressing ${chalk.bold`a`} in the ${chalk.bold`expo start`} terminal UI\n- Or by running ${chalk.bold`expo start --android`}`
),
{ borderColor: 'yellow', padding: 1 }
)
);
});
}
24 changes: 10 additions & 14 deletions packages/expo-cli/src/commands/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@ export default function(program: Command) {
.description(
'Take the configuration from app.json or app.config.js and apply it to a native project.'
)
.asyncActionProjectDir(
async (projectDir: string, options: Options) => {
if (!options.platform || options.platform === 'ios') {
await configureIOSProjectAsync(projectDir);
logConfigWarningsIOS();
}
.asyncActionProjectDir(async (projectDir: string, options: Options) => {
if (!options.platform || options.platform === 'ios') {
await configureIOSProjectAsync(projectDir);
logConfigWarningsIOS();
}

if (!options.platform || options.platform === 'android') {
await configureAndroidProjectAsync(projectDir);
logConfigWarningsAndroid();
}
},
/* skipProjectValidation: */ true,
/* skipAuthCheck: */ true
);
if (!options.platform || options.platform === 'android') {
await configureAndroidProjectAsync(projectDir);
logConfigWarningsAndroid();
}
});
}
4 changes: 2 additions & 2 deletions packages/expo-cli/src/commands/build-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export default function(program: Command) {
'Build an app binary for your project, signed and ready for submission to the Google Play Store / App Store.'
)
.option('-p --platform <platform>', 'Platform: [android|ios]', /^(android|ios)$/i)
.asyncActionProjectDir(buildAction);
.asyncActionProjectDir(buildAction, { checkConfig: true });

program
.command('build:status')
.description(`Get the status of the latest builds for your project.`)
.asyncAction(statusAction);
.asyncAction(statusAction, { checkConfig: true });
}
84 changes: 44 additions & 40 deletions packages/expo-cli/src/commands/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,27 @@ export default function(program: Command) {
.description(
'Build a standalone IPA for your project, signed and ready for submission to the Apple App Store.'
)
.asyncActionProjectDir(async (projectDir: string, options: IosOptions) => {
if (options.publicUrl && !UrlUtils.isHttps(options.publicUrl)) {
throw new CommandError('INVALID_PUBLIC_URL', '--public-url must be a valid HTTPS URL.');
}
let channelRe = new RegExp(/^[a-z\d][a-z\d._-]*$/);
if (!channelRe.test(options.releaseChannel)) {
log.error(
'Release channel name can only contain lowercase letters, numbers and special characters . _ and -'
);
process.exit(1);
}
options.type = await askBuildType(options.type, {
archive: 'Deploy the build to the store',
simulator: 'Run the build on a simulator',
});
const iosBuilder = new IOSBuilder(projectDir, options);
return iosBuilder.command();
});
.asyncActionProjectDir(
async (projectDir: string, options: IosOptions) => {
if (options.publicUrl && !UrlUtils.isHttps(options.publicUrl)) {
throw new CommandError('INVALID_PUBLIC_URL', '--public-url must be a valid HTTPS URL.');
}
let channelRe = new RegExp(/^[a-z\d][a-z\d._-]*$/);
if (!channelRe.test(options.releaseChannel)) {
log.error(
'Release channel name can only contain lowercase letters, numbers and special characters . _ and -'
);
process.exit(1);
}
options.type = await askBuildType(options.type, {
archive: 'Deploy the build to the store',
simulator: 'Run the build on a simulator',
});
const iosBuilder = new IOSBuilder(projectDir, options);
return iosBuilder.command();
},
{ checkConfig: true }
);

program
.command('build:android [project-dir]')
Expand All @@ -83,24 +86,27 @@ export default function(program: Command) {
.description(
'Build a standalone APK or App Bundle for your project, signed and ready for submission to the Google Play Store.'
)
.asyncActionProjectDir(async (projectDir: string, options: AndroidOptions) => {
if (options.publicUrl && !UrlUtils.isHttps(options.publicUrl)) {
throw new CommandError('INVALID_PUBLIC_URL', '--public-url must be a valid HTTPS URL.');
}
let channelRe = new RegExp(/^[a-z\d][a-z\d._-]*$/);
if (!channelRe.test(options.releaseChannel)) {
log.error(
'Release channel name can only contain lowercase letters, numbers and special characters . _ and -'
);
process.exit(1);
}
options.type = await askBuildType(options.type, {
apk: 'Build a package to deploy to the store or install directly on Android devices',
'app-bundle': 'Build an optimized bundle for the store',
});
const androidBuilder = new AndroidBuilder(projectDir, options);
return androidBuilder.command();
});
.asyncActionProjectDir(
async (projectDir: string, options: AndroidOptions) => {
if (options.publicUrl && !UrlUtils.isHttps(options.publicUrl)) {
throw new CommandError('INVALID_PUBLIC_URL', '--public-url must be a valid HTTPS URL.');
}
let channelRe = new RegExp(/^[a-z\d][a-z\d._-]*$/);
if (!channelRe.test(options.releaseChannel)) {
log.error(
'Release channel name can only contain lowercase letters, numbers and special characters . _ and -'
);
process.exit(1);
}
options.type = await askBuildType(options.type, {
apk: 'Build a package to deploy to the store or install directly on Android devices',
'app-bundle': 'Build an optimized bundle for the store',
});
const androidBuilder = new AndroidBuilder(projectDir, options);
return androidBuilder.command();
},
{ checkConfig: true }
);

program
.command('build:web [project-dir]')
Expand All @@ -117,9 +123,7 @@ export default function(program: Command) {
...options,
dev: typeof options.dev === 'undefined' ? false : options.dev,
});
},
/* skipProjectValidation: */ false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im purposefully skipping this check now as it doesn't need to happen.

/* skipAuthCheck: */ true
}
);

program
Expand All @@ -136,5 +140,5 @@ export default function(program: Command) {
}
const builder = new BaseBuilder(projectDir, options);
return builder.commandCheckStatus();
}, /* skipProjectValidation: */ true);
});
}
2 changes: 1 addition & 1 deletion packages/expo-cli/src/commands/bundle-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export default function(program: Command) {
.description(
'Bundles assets for a detached app. This command should be executed from xcode or gradle.'
)
.asyncActionProjectDir(action, true);
.asyncActionProjectDir(action);
}
7 changes: 3 additions & 4 deletions packages/expo-cli/src/commands/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ export default function(program: Command) {
log(chalk.green(`${result.statusUrl}`));
}
log.newLine();
},
true
}
);

program
Expand Down Expand Up @@ -358,7 +357,7 @@ export default function(program: Command) {
if (await Simulator.upgradeExpoAsync(targetClient.clientUrl)) {
log('Done!');
}
}, true);
});

program
.command('client:install:android')
Expand Down Expand Up @@ -443,5 +442,5 @@ export default function(program: Command) {
if (await Android.upgradeExpoAsync(targetClient.clientUrl)) {
log('Done!');
}
}, true);
});
}
2 changes: 1 addition & 1 deletion packages/expo-cli/src/commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export default function(program: Command) {
program
.command('doctor [project-dir]')
.description('Diagnoses issues with your Expo project.')
.asyncActionProjectDir(action, /* skipProjectValidation: */ true);
.asyncActionProjectDir(action);
}
2 changes: 1 addition & 1 deletion packages/expo-cli/src/commands/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ export default function(program: Command) {
'-f --force',
'Will attempt to generate an iOS project even when the system is not running macOS. Unsafe and may fail.'
)
.asyncActionProjectDir(action, /* skipProjectValidation: */ false, /* skipAuthCheck: */ true);
.asyncActionProjectDir(action, { checkConfig: true });
}
2 changes: 1 addition & 1 deletion packages/expo-cli/src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,5 @@ export default function(program: Command) {
[]
)
.option('--max-workers [num]', 'Maximum number of tasks to allow Metro to spawn.')
.asyncActionProjectDir(action, false, true);
.asyncActionProjectDir(action, { checkConfig: true });
}
8 changes: 4 additions & 4 deletions packages/expo-cli/src/commands/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ export default function(program: Command) {
.description(
`Fetch this project's iOS certificates/keys and provisioning profile. Writes files to the PROJECT_DIR and prints passwords to stdout.`
)
.asyncActionProjectDir(fetchIosCerts, true);
.asyncActionProjectDir(fetchIosCerts);

program
.command('fetch:android:keystore [project-dir]')
.description(
"Fetch this project's Android keystore. Writes keystore to PROJECT_DIR/PROJECT_NAME.jks and prints passwords to stdout."
)
.asyncActionProjectDir(fetchAndroidKeystoreAsync, true);
.asyncActionProjectDir(fetchAndroidKeystoreAsync);

program
.command('fetch:android:hashes [project-dir]')
.description(
"Fetch this project's Android key hashes needed to set up Google/Facebook authentication. Note: if you are using Google Play signing, this app will be signed with a different key after publishing to the store, and you'll need to use the hashes displayed in the Google Play console."
)
.asyncActionProjectDir(fetchAndroidHashesAsync, true);
.asyncActionProjectDir(fetchAndroidHashesAsync);

program
.command('fetch:android:upload-cert [project-dir]')
.description(
"Fetch this project's upload certificate needed after opting in to app signing by Google Play or after resetting a previous upload certificate."
)
.asyncActionProjectDir(fetchAndroidUploadCertAsync, true);
.asyncActionProjectDir(fetchAndroidUploadCertAsync);
}
30 changes: 13 additions & 17 deletions packages/expo-cli/src/commands/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,17 @@ export default function(program: Command) {
chalk.yellow`Deprecated: Opens your app in Expo in an iOS simulator on your computer`
)
.allowOffline()
.asyncActionProjectDir(
() => {
// Deprecate after July 24, 2020 (3 months)
console.log(
boxen(
chalk.yellow(
`${chalk.bold(
`expo ios`
)} is deprecated. You can open your project by:\n- Pressing ${chalk.bold`i`} in the ${chalk.bold`expo start`} terminal UI\n- Or by running ${chalk.bold`expo start --ios`}`
),
{ borderColor: 'yellow', padding: 1 }
)
);
},
/* skipProjectValidation: */ true,
/* skipAuthCheck: */ true
);
.asyncActionProjectDir(() => {
// Deprecate after July 24, 2020 (3 months)
console.log(
boxen(
chalk.yellow(
`${chalk.bold(
`expo ios`
)} is deprecated. You can open your project by:\n- Pressing ${chalk.bold`i`} in the ${chalk.bold`expo start`} terminal UI\n- Or by running ${chalk.bold`expo start --ios`}`
),
{ borderColor: 'yellow', padding: 1 }
)
);
});
}
11 changes: 7 additions & 4 deletions packages/expo-cli/src/commands/opt-into-google-play-signing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ export default function(program: Command) {
.description(
'Switch from the old method of signing APKs to the new App Signing by Google Play. The APK will be signed with an upload key and after uploading it to the store, app will be re-signed with the key from the original keystore.'
)
.asyncActionProjectDir(async (projectDir: string) => {
const optInProcess = new AppSigningOptInProcess(projectDir);
await optInProcess.run();
});
.asyncActionProjectDir(
async (projectDir: string) => {
const optInProcess = new AppSigningOptInProcess(projectDir);
await optInProcess.run();
},
{ checkConfig: true }
);
}
2 changes: 1 addition & 1 deletion packages/expo-cli/src/commands/prepare-detached-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export default function(program: Command) {
.option('--platform [platform]', 'detached project platform')
.option('--skipXcodeConfig [bool]', '[iOS only] if true, do not configure Xcode project')
.description('Prepares a detached project for building')
.asyncActionProjectDir(action, true);
.asyncActionProjectDir(action);
}
Loading