Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Financial-Times/origami-component-converter

Repository files navigation

Origami Component Converter

What is this?

This is a tool used during build process of Origami components, to prepare them for publish on npm.

how does it do that?

It gets run in the project directory of a component.

First, it converts the bower.json to an npm-ready package.json and writes it to disk.

  • append @financial-times/ to the name, to place it under our npm organisation
  • rewrite dependencies from the bower.json to their npm names
  • create a map of aliases for the upcoming compile step

Then, it compiles the javascript to esm using babel. The babel-plugin-import-rewrite plugin uses the generated aliases field to rewrite any dependencies whose names differ between bower and npm.

We remove the aliases field, and then the package is ready to publish.

How do I use it?

Oh? You've got an Origami component you want to put on npm?

Great! 😊

$ cd o-component
$ latest_version=$(git tag | sort -V | tail -1 | grep -Eo '\d+\.\d+\.\d+')
$ npx occ $latest
$ npm publish --access public

If the above code does not work for your component, please contact Origami via Slack (#origami-support) or opening an issue on this repository.