Skip to content

Commit

Permalink
fix(init): generate README.md from template
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyulin committed Nov 21, 2018
1 parent 7b00e60 commit a3fae6f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 19 deletions.
32 changes: 16 additions & 16 deletions dotfiles/component/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<p align="center">
<img alt="<package-name>" src="https://raw.githubusercontent.com/<organisation>/logo/master/<package-name>/<package-name>.svg?sanitize=true" width="160">
<img alt="{{packageName}}" src="https://raw.githubusercontent.com/{{organisationID}}/logo/master/{{packageName}}/{{packageName}}.svg?sanitize=true" width="160">
</p>

<p align="center">
<a href="https://www.npmjs.com/package/<npm-scope>/<package-name>">
<img alt="npm" src="https://img.shields.io/npm/v/<npm-scope>/<package-name>.svg">
<a href="https://www.npmjs.com/package/{{npmScope}}/{{packageName}}">
<img alt="npm" src="https://img.shields.io/npm/v/{{npmScope}}/{{packageName}}.svg">
</a>
<a href="https://travis-ci.org/<npm-scope>/<package-name>">
<img alt="Travis" src="https://img.shields.io/travis/<npm-scope>/<package-name>/master.svg">
<a href="https://travis-ci.org/{{organisationID}}/{{packageName}}">
<img alt="Travis" src="https://img.shields.io/travis/{{organisationID}}/{{packageName}}/master.svg">
</a>
<a href="https://coveralls.io/github/<npm-scope>/<package-name>?branch=master">
<img alt="Coveralls" src="https://img.shields.io/coveralls/github/<npm-scope>/<package-name>/master.svg">
<a href="https://coveralls.io/github/{{organisationID}}/{{packageName}}?branch=master">
<img alt="Coveralls" src="https://img.shields.io/coveralls/github/{{organisationID}}/{{packageName}}/master.svg">
</a>
<a href="https://github.com/semantic-release/semantic-release">
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
</a>
</p>

<p align="center">
<a href="https://snyk.io/test/github/<npm-scope>/<package-name>">
<img alt="Known Vulnerabilities" src="https://snyk.io/test/github/<npm-scope>/<package-name>/badge.svg">
<a href="https://snyk.io/test/github/{{organisationID}}/{{packageName}}">
<img alt="Known Vulnerabilities" src="https://snyk.io/test/github/{{organisationID}}/{{packageName}}/badge.svg">
</a>
<a href="https://david-dm.org/<npm-scope>/<package-name>">
<img alt="Dependencies" src="https://img.shields.io/david/<npm-scope>/<package-name>.svg">
<a href="https://david-dm.org/{{organisationID}}/{{packageName}}">
<img alt="Dependencies" src="https://img.shields.io/david/{{organisationID}}/{{packageName}}.svg">
</a>
<a href="https://david-dm.org/<npm-scope>/<package-name>?type=dev">
<img alt="devDependencies" src="https://img.shields.io/david/dev/<npm-scope>/<package-name>.svg">
<a href="https://david-dm.org/{{organisationID}}/{{packageName}}?type=dev">
<img alt="devDependencies" src="https://img.shields.io/david/dev/{{organisationID}}/{{packageName}}.svg">
</a>
<a href="https://scrutinizer-ci.com/g/<npm-scope>/<package-name>/?branch=master">
<img alt="Scrutinizer Code Quality" src="https://img.shields.io/scrutinizer/g/<npm-scope>/<package-name>.svg">
<a href="https://scrutinizer-ci.com/g/{{organisationID}}/{{packageName}}/?branch=master">
<img alt="Scrutinizer Code Quality" src="https://img.shields.io/scrutinizer/g/{{organisationID}}/{{packageName}}.svg">
</a>
</p>

<h3 align="center"><package-description></h3>
<h3 align="center">{{packageDescription}}</h3>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"cpy": "^7.0.1",
"inquirer": "^6.2.0",
"jsonfile": "^5.0.0",
"node-vault": "^0.9.0"
"node-vault": "^0.9.0",
"replace-in-file": "^3.4.2"
},
"devDependencies": {
"@babel/cli": "^7.1.5",
Expand Down
16 changes: 15 additions & 1 deletion src/actions/init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cpy from 'cpy';
import jsonfile from 'jsonfile';
import inquirer from 'inquirer';
import replace from 'replace-in-file';

import { mkdir } from 'lib/fs';
import { PACKAGE_TYPES, COMPONENT_ENVS, CWD, DOTFILES_FOLDER } from 'constants';
Expand Down Expand Up @@ -54,6 +55,13 @@ export const copyConfigFiles = async ({ packageType, packageName }) =>
`./${packageName}`,
);

export const updateReadme = async ({ packageName, organisationID, npmScope }) =>
replace({
files: `${CWD}/${packageName}/README.md`,
from: [/{{packageName}}/g, /{{organisationID}}/g, /{{npmScope}}/g],
to: [packageName, organisationID, npmScope],
});

const questions = [
{
type: 'list',
Expand All @@ -71,7 +79,7 @@ const questions = [
{
type: 'confirm',
name: 'packagePublic',
message: 'Is the component to be published?',
message: 'Is the component to be public?',
default: true,
when: ({ packageType }) => packageType === 'component',
},
Expand Down Expand Up @@ -125,6 +133,12 @@ export default () =>
authorDetail,
});
await copyConfigFiles({ packageType, packageName });
await updateReadme({
packageType,
packageName,
organisationID,
npmScope,
});
console.log(`created new [${packageType}] package ./${packageName}`);
},
);
42 changes: 41 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,11 @@ camelcase@^4.0.0, camelcase@^4.1.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=

camelcase@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42"
integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==

caniuse-lite@^1.0.30000889:
version "1.0.30000890"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000890.tgz#86a18ffcc65d79ec6a437e985761b8bf1c4efeaf"
Expand Down Expand Up @@ -2417,7 +2422,7 @@ decamelize-keys@^1.0.0:
decamelize "^1.1.0"
map-obj "^1.0.0"

decamelize@^1.1.0, decamelize@^1.1.1, decamelize@^1.1.2:
decamelize@^1.1.0, decamelize@^1.1.1, decamelize@^1.1.2, decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
Expand Down Expand Up @@ -7150,6 +7155,15 @@ repeating@^2.0.0:
dependencies:
is-finite "^1.0.0"

replace-in-file@^3.4.2:
version "3.4.2"
resolved "https://registry.yarnpkg.com/replace-in-file/-/replace-in-file-3.4.2.tgz#6d40f076ac86948e28efeb6fab73fbad5c0bfa2a"
integrity sha512-wb2EU5MBBqUty+b1xSIqa0IKs5M2/a+4Ldw8KM5Gpe1btv16K0eii6nMxyNhAmRZhCEPrge0ss5Ij9f7vJEYcw==
dependencies:
chalk "^2.4.1"
glob "^7.1.2"
yargs "^12.0.1"

request-promise-core@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
Expand Down Expand Up @@ -8578,6 +8592,14 @@ yargs-parser@^10.0.0, yargs-parser@^10.1.0:
dependencies:
camelcase "^4.1.0"

yargs-parser@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4"
integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"

yargs-parser@^9.0.2:
version "9.0.2"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-9.0.2.tgz#9ccf6a43460fe4ed40a9bb68f48d43b8a68cc077"
Expand Down Expand Up @@ -8620,3 +8642,21 @@ yargs@^12.0.0:
which-module "^2.0.0"
y18n "^3.2.1 || ^4.0.0"
yargs-parser "^10.1.0"

yargs@^12.0.1:
version "12.0.5"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==
dependencies:
cliui "^4.0.0"
decamelize "^1.2.0"
find-up "^3.0.0"
get-caller-file "^1.0.1"
os-locale "^3.0.0"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^2.0.0"
which-module "^2.0.0"
y18n "^3.2.1 || ^4.0.0"
yargs-parser "^11.1.1"

1 comment on commit a3fae6f

@zhenyulin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.