-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Financial-Times/make_npm_compatible
CON-903 Make library npm-compatible
- Loading branch information
Showing
6 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fs = require('fs'); | ||
const bowerPackage = require('../bower.json'); | ||
const npmPackage = require('../package.json'); | ||
|
||
function standardNpmPackage (version, name) { | ||
return `npm:@financial-times/${name}@${version}`; | ||
} | ||
|
||
const resolutionMap = { | ||
'n-ui-foundations': () => 'github:financial-times/n-ui-foundations#nobower', | ||
'next-session-client': (version) => `${version}`, | ||
'o-buttons': standardNpmPackage, | ||
'o-overlay': standardNpmPackage, | ||
'o-tracking': standardNpmPackage, | ||
'o-visual-effects': standardNpmPackage, | ||
'o-message': standardNpmPackage, | ||
}; | ||
|
||
for (const dependency in bowerPackage.dependencies) { | ||
if (!resolutionMap[dependency]) { | ||
throw new Error(`Please update fromBowerToNpm resolution map with the Bower package ${dependency}, so it will be usable also from NPM consumers` | ||
); | ||
} else { | ||
npmPackage.dependencies[dependency] = resolutionMap[dependency]( | ||
bowerPackage.dependencies[dependency], | ||
dependency | ||
); | ||
} | ||
} | ||
|
||
fs.writeFileSync('package.json', JSON.stringify(npmPackage, null, 2)); |
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