Sven SAULEAU b445b79734 Refactor move docs (#8108) 6 tahun lalu
..
docs.js c3654d83c8 Generate TypeScript typings, and improve generated Flow typings (#7101) 6 tahun lalu
flow.js fa5eb4f605 Make comment props more consistent (#7246) 6 tahun lalu
readmes.js b445b79734 Refactor move docs (#8108) 6 tahun lalu
typescript.js c3654d83c8 Generate TypeScript typings, and improve generated Flow typings (#7101) 6 tahun lalu
utils.js c3654d83c8 Generate TypeScript typings, and improve generated Flow typings (#7101) 6 tahun lalu

readmes.js

/**
* Since we moved our documentation to our website repo, we want to point to the
* website from the docs in this repo
*
* This script write the link to the website in every READMEs.
*/

const { join } = require("path");
const { readdirSync, writeFileSync } = require("fs");

const cwd = process.cwd();

const packageDir = join(cwd, "packages");

const packages = readdirSync(packageDir);
const getWebsiteLink = n => `https://new.babeljs.io/docs/en/next/${n}.html`;
const getPackageJson = pkg => require(join(packageDir, pkg, "package.json"));

const generateReadme = ({ link, name, description }) =>
`# ${name}

> ${description}

See our website [${name}](${link}) for more information.

## Install

Using npm:

\`\`\`sh
npm install --save ${name}
\`\`\`

or using yarn:

\`\`\`sh
yarn add --save ${name}
\`\`\`
`;

packages
.filter(x => x !== "README.md") // ignore root readme
.forEach(id => {
const { name, description } = getPackageJson(id);
const readmePath = join(packageDir, id, "README.md");

// generate
const link = getWebsiteLink(id);
const readme = generateReadme({ link, name, description });

// write
writeFileSync(readmePath, readme);

console.log("OK", id);
});