Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function action() {
// Get from staging
Config.api.host = STAGING_HOST;
const versionsStaging = await Versions.versionsAsync();
// since there is only one versions cache, we need to wait a small
// amount of time so that the cache is invalidated before fetching from prod
await new Promise(resolve => setTimeout(resolve, 10));
Config.api.host = PRODUCTION_HOST;
const versionsProd = await Versions.versionsAsync();
const delta = jsondiffpatch.diff(versionsProd, versionsStaging);
if (!delta) {
console.log(chalk.yellow('There are no changes to apply in the configuration.'));
return;
}
console.log(`Here is the diff from ${chalk.green('staging')} -> ${chalk.green('production')}:`);
console.log(jsondiffpatch.formatters.console.format(delta, versionsProd));
const { isCorrect } = await inquirer.prompt<{ isCorrect: boolean }>([
{
type: 'confirm',
name: 'isCorrect',
message: `Does this look correct? Type \`y\` to update ${chalk.green('production')} config.`,
async function action() {
// Get from staging
Config.api.host = STAGING_HOST;
const versionsStaging = await Versions.versionsAsync();
// since there is only one versions cache, we need to wait a small
// amount of time so that the cache is invalidated before fetching from prod
await new Promise(resolve => setTimeout(resolve, 10));
Config.api.host = PRODUCTION_HOST;
const versionsProd = await Versions.versionsAsync();
const delta = jsondiffpatch.diff(versionsProd, versionsStaging);
if (!delta) {
console.log(chalk.yellow('There are no changes to apply in the configuration.'));
return;
}
console.log(`Here is the diff from ${chalk.green('staging')} -> ${chalk.green('production')}:`);
Analytics.setSegmentNodeKey('vGu92cdmVaggGA26s3lBX6Y5fILm8SQ7');
Analytics.setVersionName(packageJSON.version);
_registerLogs();
UserManager.setInteractiveAuthenticationCallback(loginOrRegisterIfLoggedOut);
if (process.env.SERVER_URL) {
let serverUrl = process.env.SERVER_URL;
if (!serverUrl.startsWith('http')) {
serverUrl = `http://${serverUrl}`;
}
let parsedUrl = url.parse(serverUrl);
const port = parseInt(parsedUrl.port || '');
if (parsedUrl.hostname && port) {
Config.api.host = parsedUrl.hostname;
Config.api.port = port;
} else {
throw new Error('Environment variable SERVER_URL is not a valid url');
}
}
Config.developerTool = packageJSON.name;
// Setup our commander instance
program.name(programName);
program
.version(packageJSON.version)
.option('-o, --output [format]', 'Output format. pretty (default), raw')
.option(
'--non-interactive',
'Fail, if an interactive prompt would be required to continue. Enabled by default if stdin is not a TTY.'
);
async function action(options) {
const { sdk, platform } = options;
// (dsokal) commander.js doesn't check if required options are supplied, lol
if (!sdk || !platform) {
throw new Error('Must run with `--sdk SDK_VERSION --platform PLATFORM`');
}
if (!['android', 'ios', 'both'].includes(platform)) {
throw new Error('Invalid platform (only `android`, `ios` and `both` are allowed here)');
}
Config.api.host = 'staging.exp.host';
await UpdateVersions.updateTurtleVersionAsync(sdk, platform);
}
// Setup analytics
Analytics.setSegmentNodeKey('vGu92cdmVaggGA26s3lBX6Y5fILm8SQ7');
Analytics.setVersionName(packageJSON.version);
_registerLogs();
UserManager.setInteractiveAuthenticationCallback(loginOrRegisterIfLoggedOut);
if (process.env.SERVER_URL) {
let serverUrl = process.env.SERVER_URL;
if (!serverUrl.startsWith('http')) {
serverUrl = `http://${serverUrl}`;
}
let parsedUrl = url.parse(serverUrl);
const port = parseInt(parsedUrl.port || '');
if (parsedUrl.hostname && port) {
Config.api.host = parsedUrl.hostname;
Config.api.port = port;
} else {
throw new Error('Environment variable SERVER_URL is not a valid url');
}
}
Config.developerTool = packageJSON.name;
// Setup our commander instance
program.name(programName);
program
.version(packageJSON.version)
.option('-o, --output [format]', 'Output format. pretty (default), raw')
.option(
'--non-interactive',
'Fail, if an interactive prompt would be required to continue. Enabled by default if stdin is not a TTY.'
async function action(options: ActionOptions) {
Config.api.host = STAGING_HOST;
const versions = await Versions.versionsAsync();
const sdkVersions = Object.keys(versions.sdkVersions).sort(semver.rcompare);
const sdkVersion = options.sdkVersion || (await chooseSdkVersionAsync(sdkVersions));
const containsSdk = sdkVersions.includes(sdkVersion);
if (!semver.valid(sdkVersion)) {
console.error(chalk.red(`Provided SDK version ${chalk.cyan(sdkVersion)} is invalid.`));
return;
}
if (!containsSdk) {
const { addNewSdk } = await inquirer.prompt<{ addNewSdk: boolean }>([
{
type: 'confirm',
name: 'addNewSdk',
message: `Configuration for SDK ${chalk.cyan(
sdkVersion
destination: path.join('app', 'src', 'main', 'AndroidManifest.xml'),
},
{
isFile: true,
source: path.join(androidDir, 'app', 'google-services.json'),
destination: path.join('app', 'google-services.json'),
},
{
isFile: true,
source: path.join(androidDir, 'app', 'fabric.properties'),
destination: path.join('app', 'fabric.properties'),
},
]);
process.env.EXPO_STAGING = '1';
Config.api.host = 'staging.exp.host';
let versions = await Versions.versionsAsync();
if (!versions.sdkVersions[sdkVersion]) {
throw new Error(`SDK version ${sdkVersion} not found in versions JSON`);
}
const expokitNpmPackageDir = path.join(expoDir, `expokit-npm-package`);
const npmVersionArg = expokitVersion || 'patch';
await spawnAsync(`npm`, ['version', npmVersionArg, '--allow-same-version'], {
stdio: 'inherit',
cwd: expokitNpmPackageDir,
});
let expokitPackageJson = new JsonFile(path.join(expokitNpmPackageDir, 'package.json'));
let expokitNpmVersion = await expokitPackageJson.getAsync('version', null);