fix: update/insert readme open-wc header via script

This commit is contained in:
Thomas Allmer
2019-02-02 15:27:12 +01:00
parent 83b3d84375
commit be84d36cb2
3 changed files with 45 additions and 15 deletions

View File

@@ -1,12 +1,6 @@
# Demoing via storybook
> Part of Open Web Component Recommendation [open-wc](https://github.com/open-wc/open-wc/)
Open Web Components provides a set of defaults, recommendations and tools to help facilitate your web component project. Our recommendations include: developing, linting, testing, building, tooling, demoing, publishing and automating.
[![CircleCI](https://circleci.com/gh/open-wc/open-wc.svg?style=shield)](https://circleci.com/gh/open-wc/open-wc)
[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=M2UrSFVRang2OWNuZXlWSlhVc3FUVlJtTDkxMnp6eGFDb2pNakl4bGxnbz0tLUE5RjhCU0NUT1ZWa0NuQ3MySFFWWnc9PQ==--86f7fac07cdbd01dd2b26ae84dc6c8ca49e45b50)](https://www.browserstack.com/automate/public-build/M2UrSFVRang2OWNuZXlWSlhVc3FUVlJtTDkxMnp6eGFDb2pNakl4bGxnbz0tLUE5RjhCU0NUT1ZWa0NuQ3MySFFWWnc9PQ==--86f7fac07cdbd01dd2b26ae84dc6c8ca49e45b50)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
[//]: # (AUTO INSERT HEADER PREPUBLISH)
For demoing and showcasing different states of your Web Component, we recommend using [storybook](https://storybook.js.org/).

View File

@@ -9,19 +9,22 @@
"access": "public"
},
"repository": "https://github.com/open-wc/open-wc/tree/master/packages/storybook",
"scripts": {
"prepublishOnly": "../../scripts/insert-header.js"
},
"dependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@storybook/addon-actions": "^4.0.0-alpha.25",
"@storybook/addon-backgrounds": "^4.0.0-alpha.25",
"@storybook/addon-links": "^4.0.0-alpha.25",
"@storybook/addon-notes": "^4.0.0-alpha.25",
"@storybook/addon-options": "^4.0.0-alpha.25",
"@storybook/addon-storysource": "^4.0.0-alpha.25",
"@storybook/addon-viewport": "^4.0.0-alpha.25",
"@storybook/polymer": "^4.0.0-alpha.25",
"@storybook/addon-actions": "^4.0.0",
"@storybook/addon-backgrounds": "^4.0.0",
"@storybook/addon-links": "^4.0.0",
"@storybook/addon-notes": "^4.0.0",
"@storybook/addon-options": "^4.0.0",
"@storybook/addon-storysource": "^4.0.0",
"@storybook/addon-viewport": "^4.0.0",
"@storybook/polymer": "^4.0.0",
"@types/storybook__addon-actions": "^3.4.1",
"@types/storybook__addon-backgrounds": "^3.2.1",
"@types/storybook__addon-knobs": "^3.4.1",

33
scripts/insert-header.js Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env node
/* eslint-disable consistent-return, no-console */
const fs = require('fs');
function escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
const filePath = `${process.cwd()}/README.md`;
const findPattern = escapeRegExp('[//]: # (AUTO INSERT HEADER PREPUBLISH)');
const text = `
> Part of Open Web Components [open-wc](https://github.com/open-wc/open-wc/)
Open Web Components provides a set of defaults, recommendations and tools to help facilitate your web component project. Our recommendations include: developing, linting, testing, building, tooling, demoing, publishing and automating.
[![CircleCI](https://circleci.com/gh/open-wc/open-wc.svg?style=shield)](https://circleci.com/gh/open-wc/open-wc)
[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=M2UrSFVRang2OWNuZXlWSlhVc3FUVlJtTDkxMnp6eGFDb2pNakl4bGxnbz0tLUE5RjhCU0NUT1ZWa0NuQ3MySFFWWnc9PQ==--86f7fac07cdbd01dd2b26ae84dc6c8ca49e45b50)](https://www.browserstack.com/automate/public-build/M2UrSFVRang2OWNuZXlWSlhVc3FUVlJtTDkxMnp6eGFDb2pNakl4bGxnbz0tLUE5RjhCU0NUT1ZWa0NuQ3MySFFWWnc9PQ==--86f7fac07cdbd01dd2b26ae84dc6c8ca49e45b50)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
`.trim();
fs.readFile(filePath, 'utf8', (readError, data) => {
if (readError) {
return console.log(readError);
}
const result = data.replace(new RegExp(findPattern), text);
fs.writeFile(filePath, result, 'utf8', writeError => {
if (writeError) {
return console.log(writeError);
}
});
});