Skip to content

Commit

Permalink
Tweak pin cdn script to account for differing versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Scott committed Mar 15, 2021
1 parent 91db3dd commit f36db33
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scripts/pin-cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ const ROOT = path.resolve(__dirname, '..');
const UPSCALERJS_ROOT = path.resolve(ROOT, 'packages/upscalerjs');

const ROOT_PACKAGE = require(path.resolve(ROOT, 'package.json'));
const UPSCALERJS_PACKAGE = require(path.resolve(ROOT, 'packages/upscalerjs/package.json'));
const MODELS_PACKAGE = require(path.resolve(ROOT, 'packages/models/package.json'));

const peerDependencies = ROOT_PACKAGE['peerDependencies'];
const version = ROOT_PACKAGE['version'];
const upscalerVersion = UPSCALERJS_PACKAGE['version'];
const modelsVersion = MODELS_PACKAGE['version'];

console.log(`Pinning version ${version} in CDN definition`);
console.log(`Pinning version ${modelsVersion} in CDN definition`);

const writeConstantsFile = (version) => {
const constants = [
Expand All @@ -28,7 +32,7 @@ const writeConstantsFile = (version) => {
`/*****\nThis is an autogenerated file. See scripts/pin-cdn.js for more information.\n*****/\n\n${contents}`
);
}
writeConstantsFile(version);
writeConstantsFile(modelsVersion);

const updatePackageJSON = (packagePath, version, callback) => {
const package = require(packagePath);
Expand All @@ -46,11 +50,11 @@ examples.forEach(example => {
const dirPath = path.resolve(examplesPath, example);
if (fs.lstatSync(dirPath).isDirectory()) {
const examplePackagePath = path.resolve(dirPath, 'package.json');
updatePackageJSON(examplePackagePath, version, package => {
updatePackageJSON(examplePackagePath, upscalerVersion, package => {
if (!package.dependencies) {
package.dependencies = {};
}
package.dependencies.upscaler = version;
package.dependencies.upscaler = upscalerVersion;

package.dependencies['@tensorflow/tfjs'] = peerDependencies['@tensorflow/tfjs'];
});
Expand Down

0 comments on commit f36db33

Please sign in to comment.