Skip to content

Instantly share code, notes, and snippets.

@alexwilson
Created April 1, 2021 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexwilson/b71be252050c7eb5f37811796b285eaa to your computer and use it in GitHub Desktop.
Save alexwilson/b71be252050c7eb5f37811796b285eaa to your computer and use it in GitHub Desktop.
Origami package.json managed build-service URLs.
const package = require('./package.json');
const origamiDependenciesFromPackageJson = Object.keys(package.dependencies)
// Find installed Origami modules.
.filter(key => key.startsWith('@financial-times/o-'))
// Reformat them
.map(key => ({
component: key.replace('@financial-times/', ''),
version: pkg.dependencies[key]
})
// Finally transform into a URI compatible string
.map(({component, version}) => `${component}@${version}`)
.join(',');
const origami = (fileType, brand = "internal") => `https://www.ft.com/__origami/service/build/v2/bundles/${fileType}?brand=${brand}&autoinit=1&modules=${origamiDependenciesFromPackageJson}`;
console.log(origami('js'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment