Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (unsupportedPackages[dep]) {
delete packageJson.dependencies[dep];
unsupportedPackagesUsed.push(dep);
}
});
// TODO: we don't actually support index.android.js and index.ios.js right now!
if (
projectEntryPoint !== 'index.*.js' &&
projectEntryPoint !== 'index.js' &&
projectEntryPoint !== 'index.ios.js' &&
projectEntryPoint !== 'index.android.js'
) {
packageJson.main = projectEntryPoint;
}
await JsonFile.writeAsync(packageJsonTargetPath, packageJson);
console.log('Updated package.json');
// TODO: Add import Expo from 'expo'; at the top of main file
// Copy babelrc
await JsonFile.writeAsync(babelRcTargetPath, babelRcTemplate);
console.log('Updated .babelrc');
// Save next steps to a file, display, exit
await installAndInstructAsync(projectDir, unsupportedPackagesUsed);
});
// TODO: we don't actually support index.android.js and index.ios.js right now!
if (
projectEntryPoint !== 'index.*.js' &&
projectEntryPoint !== 'index.js' &&
projectEntryPoint !== 'index.ios.js' &&
projectEntryPoint !== 'index.android.js'
) {
packageJson.main = projectEntryPoint;
}
await JsonFile.writeAsync(packageJsonTargetPath, packageJson);
console.log('Updated package.json');
// TODO: Add import Expo from 'expo'; at the top of main file
// Copy babelrc
await JsonFile.writeAsync(babelRcTargetPath, babelRcTemplate);
console.log('Updated .babelrc');
// Save next steps to a file, display, exit
await installAndInstructAsync(projectDir, unsupportedPackagesUsed);
});
{ projectName, projectDescription, projectEntryPoint }: params
) {
let projectSlug = slug(projectName.toLowerCase());
let expJsonTargetPath = path.join(projectDir, '/exp.json');
let babelRcTargetPath = path.join(projectDir, '/.babelrc');
let packageJsonSourcePath = path.join(projectDir, '/package.json');
let packageJsonTargetPath = path.join(projectDir, '/package.json');
// Add values to exp.json, save to given path
let expJson = { ...expJsonTemplate };
expJson.name = projectName;
expJson.description = projectDescription || 'No description';
expJson.slug = projectSlug;
await JsonFile.writeAsync(expJsonTargetPath, expJson);
console.log('Wrote exp.json');
// Add entry point and dependencies to package.json
let unsupportedPackagesUsed = [];
let packageJson = await JsonFile.readAsync(packageJsonSourcePath);
packageJson.dependencies = { ...packageJson.dependencies, ...dependencies };
// Remove
Object.keys(packageJson.dependencies).forEach(dep => {
if (unsupportedPackages[dep]) {
delete packageJson.dependencies[dep];
unsupportedPackagesUsed.push(dep);
}
});
export async function writeConfigJsonAsync(
projectRoot: string,
options: Object
): Promise {
const { configPath } = findConfigFile(projectRoot);
let { exp, pkg, rootConfig } = await readConfigJsonAsync(projectRoot);
exp = { ...exp, ...options };
rootConfig = { ...rootConfig, expo: exp };
await JsonFile.writeAsync(configPath, rootConfig, { json5: false });
return {
exp,
pkg,
rootConfig,
};
}
if (!pkg) {
throw new Error(`Couldn't read package.json`);
}
exp = {
...exp,
...options,
};
if (configNamespace) {
config[configNamespace] = exp;
} else {
config = exp;
}
await JsonFile.writeAsync(configPath, config, { json5: false });
return {
exp,
pkg,
rootConfig,
};
}