Created
April 1, 2021 11:05
-
-
Save alexwilson/b71be252050c7eb5f37811796b285eaa to your computer and use it in GitHub Desktop.
Origami package.json managed build-service URLs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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