Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const expJsonExists = await fileExistsAsync(path.join(projectRoot, 'exp.json'));
const appJsonExists = await fileExistsAsync(path.join(projectRoot, 'app.json'));
if (expJsonExists && appJsonExists) {
ProjectUtils.logWarning(
projectRoot,
'expo',
`Warning: Both app.json and exp.json exist in this directory. Only one should exist for a single project.`,
'doctor-both-app-and-exp-json'
);
return WARNING;
}
ProjectUtils.clearNotification(projectRoot, 'doctor-both-app-and-exp-json');
let sdkVersion = exp.sdkVersion;
const configName = configFilename(projectRoot);
// Warn if sdkVersion is UNVERSIONED
if (sdkVersion === 'UNVERSIONED' && !process.env.EXPO_SKIP_MANIFEST_VALIDATION_TOKEN) {
ProjectUtils.logError(
projectRoot,
'expo',
`Error: Using unversioned Expo SDK. Do not publish until you set sdkVersion in ${configName}`,
'doctor-unversioned'
);
return ERROR;
}
ProjectUtils.clearNotification(projectRoot, 'doctor-unversioned');
let sdkVersions = await Versions.sdkVersionsAsync();
if (!sdkVersions) {
ProjectUtils.logError(
projectRoot,
projectRoot: string,
options: {
current?: boolean;
mode?: string;
platform?: 'android' | 'ios' | 'all';
expIds?: Array;
type?: string;
releaseChannel?: string;
bundleIdentifier?: string;
publicUrl?: string;
} = {}
) {
if (!options.publicUrl) {
// get the manifest from the project directory
const { exp, pkg } = await readConfigJsonAsync(projectRoot);
const configName = configFilename(projectRoot);
return {
exp,
pkg,
configName: configFilename(projectRoot),
configPrefix: configName === 'app.json' ? 'expo.' : '',
};
} else {
// get the externally hosted manifest
return {
exp: await ThirdParty.getManifest(options.publicUrl, options),
configName: options.publicUrl,
configPrefix: '',
pkg: {},
};
}
}
platform?: 'android' | 'ios' | 'all';
expIds?: Array;
type?: string;
releaseChannel?: string;
bundleIdentifier?: string;
publicUrl?: string;
} = {}
) {
if (!options.publicUrl) {
// get the manifest from the project directory
const { exp, pkg } = await readConfigJsonAsync(projectRoot);
const configName = configFilename(projectRoot);
return {
exp,
pkg,
configName: configFilename(projectRoot),
configPrefix: configName === 'app.json' ? 'expo.' : '',
};
} else {
// get the externally hosted manifest
return {
exp: await ThirdParty.getManifest(options.publicUrl, options),
configName: options.publicUrl,
configPrefix: '',
pkg: {},
};
}
}
export async function getPublishInfoAsync(root: string): Promise {
const user = await UserManager.ensureLoggedInAsync();
if (!user) {
throw new Error('Attempted to login in offline mode. This is a bug.');
}
let { username } = user;
const { exp } = await readConfigJsonAsync(root);
const name = exp.slug;
const { version, sdkVersion } = exp;
const configName = configFilename(root);
if (!sdkVersion) {
throw new Error(`sdkVersion is missing from ${configName}`);
}
if (!name) {
// slug is made programmatically for app.json
throw new Error(`slug field is missing from exp.json.`);
}
if (!version) {
throw new Error(`Can't get version of package.`);
}
const remotePackageName = name;
const remoteUsername = username;