Skip to content

Instantly share code, notes, and snippets.

@gregfenton
Last active Feb 26, 2021
Embed
What would you like to do?
EXPO: configuration of standard-version-expo for a code base that has multiple configuration files
/* What?
* A configuration for standard-version-expo that updates multiple config files
* by dynamically identifying them from a sub-directory when you bump the
* version using the `standard-version` tool
*
* How?
* Modelled from the post by @bycedric: https://dev.to/bycedric/simplify-expo-releases-with-standard-version-2f4o
* Follow the setup instructions listed at the URL above or at https://github.com/expo-community/standard-version-expo
*
* Why?
* My expo app code is being used to generate different flavours of the app per corporate client - which means, in fact,
* generating different apps per client. To keep all of our clients' apps current, we force all app configs to update
* at the same time.
* Each client has their own configuration stored in <PROJECT_ROOT>/app-configs/<CLIENT_NAME>/app.config.js
* So this code is run by `standard-version` and dynamically identifies all of the `app.config.js` in the `app-configs`
* subdirectory.
*/
let fs = require('fs');
let bumps = [{ filename: 'package.json' }]; // update the global project
let CONFIGS_DIR = './app-configs';
try {
let entries = fs.readdirSync(CONFIGS_DIR, { withFileTypes: true });
for (let i = 0; i < entries.length; i++) {
let entry = entries[i];
let confFile = `${CONFIGS_DIR}/${entry.name}/app.json`;
if (entry?.isDirectory()) {
if (fs.existsSync(confFile)) {
// updates `expo.version`
bumps.push({
filename: confFile,
updater: require.resolve('standard-version-expo'),
});
// updates `expo.android.versionCode`
// see: https://github.com/expo-community/standard-version-expo/blob/master/src/helpers.ts
bumps.push({
filename: confFile,
updater: require.resolve('standard-version-expo/android'),
});
// updates `expo.ios.buildNumber`
// see: https://github.com/expo-community/standard-version-expo/blob/master/src/helpers.ts
bumps.push({
filename: confFile,
updater: require.resolve('standard-version-expo/ios'),
});
}
}
}
} catch (ex) {
console.log(`EXCEPTION with readdir: ${ex.message}`);
throw ex;
}
module.exports = {
bumpFiles: [...bumps],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment