Docs build script (#3332)

* Remove artifacts from repo

* Remove docs stuff from build script

* Add new docs build script

* Add 'third-party' shim in playground worker

* Build from src if it's a PR

* Add command to package.json and remove old stuff from travis
master
Lucas Duailibe 2017-11-27 19:27:25 -03:00 committed by Lucas Azzola
parent 56951a71b4
commit f514d1e93f
16 changed files with 88 additions and 35470 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@
/website/node_modules
/website/build
/website/i18n
/website/static/lib
.DS_Store
coverage
.idea

View File

@ -23,10 +23,3 @@ script:
- yarn lint-docs
- AST_COMPARE=1 yarn test -- --runInBand
- if [ "${NODE_ENV}" = "development" ]; then yarn codecov; fi
deploy:
provider: script
script: website/deploy.sh
skip_cleanup: true
on:
branch: master
node: stable

View File

@ -88,6 +88,7 @@
"lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
"lint-docs": "prettylint {.,docs,website}/*.md",
"build": "node ./scripts/build/build.js",
"build-docs": "node ./scripts/build/build-docs.js",
"check-deps": "node ./scripts/check-deps.js"
}
}

View File

@ -0,0 +1,81 @@
#!/usr/bin/env node
"use strict";
const path = require("path");
const shell = require("shelljs");
const rootDir = path.join(__dirname, "..", "..");
const docs = path.join(rootDir, "website/static/lib");
const parsers = [
"babylon",
"flow",
"typescript",
"graphql",
"postcss",
"parse5",
"markdown"
];
function pipe(string) {
return new shell.ShellString(string);
}
const isPullRequest = process.env.PULL_REQUEST === "true";
const prettierPath = isPullRequest ? "dist" : "node_modules/prettier/";
// --- Build prettier for PR ---
if (isPullRequest) {
const pkg = require("../../package.json");
pkg.version = `preview-${process.env.REVIEW_ID}`;
pipe(JSON.stringify(pkg, null, 2)).to("package.json");
shell.exec("node scripts/build/build.js");
}
// --- Docs ---
shell.mkdir("-p", docs);
shell.echo("Bundling docs index...");
shell.cp(`${prettierPath}/index.js`, `${docs}/index.js`);
shell.exec(
`node_modules/babel-cli/bin/babel.js ${docs}/index.js --out-file ${
docs
}/index.js --presets=es2015`
);
shell.echo("Bundling docs babylon...");
shell.exec(
`rollup -c scripts/build/rollup.docs.config.js --environment filepath:parser-babylon.js -i ${
prettierPath
}/parser-babylon.js`
);
shell.exec(
`node_modules/babel-cli/bin/babel.js ${docs}/parser-babylon.js --out-file ${
docs
}/parser-babylon.js --presets=es2015`
);
for (const parser of parsers) {
if (parser === "babylon") {
continue;
}
shell.echo(`Bundling docs ${parser}...`);
shell.exec(
`rollup -c scripts/build/rollup.docs.config.js --environment filepath:parser-${
parser
}.js -i ${prettierPath}/parser-${parser}.js`
);
}
shell.echo("Copy sw-toolbox.js to docs");
shell.cp("node_modules/sw-toolbox/sw-toolbox.js", `${docs}/sw-toolbox.js`);
// --- Site ---
shell.cd("website");
shell.echo("Building website...");
shell.exec("yarn install");
shell.exec("yarn build");
shell.echo();

View File

@ -8,7 +8,6 @@ const formatMarkdown = require("../../website/static/markdown");
const shell = require("shelljs");
const rootDir = path.join(__dirname, "..", "..");
const docs = path.join(rootDir, "website/static/lib");
const parsers = [
"babylon",
"flow",
@ -28,8 +27,7 @@ function pipe(string) {
shell.set("-e");
shell.cd(rootDir);
shell.rm("-Rf", "dist/", docs);
shell.mkdir("-p", docs);
shell.rm("-Rf", "dist/");
// --- Lib ---
@ -66,44 +64,6 @@ pipe(`module.exports = ${content}`).to("dist/parser-postcss.js");
shell.echo();
// --- Docs ---
shell.echo("Bundling docs index...");
shell.exec(
`rollup -c scripts/build/rollup.index.config.js --environment BUILD_TARGET:website -o ${
docs
}/index.js`
);
shell.exec(
`node_modules/babel-cli/bin/babel.js ${docs}/index.js --out-file ${
docs
}/index.js --presets=es2015`
);
shell.echo("Bundling docs babylon...");
shell.exec(
"rollup -c scripts/build/rollup.docs.config.js --environment filepath:parser-babylon.js"
);
shell.exec(
`node_modules/babel-cli/bin/babel.js ${docs}/parser-babylon.js --out-file ${
docs
}/parser-babylon.js --presets=es2015`
);
for (const parser of parsers) {
if (parser === "babylon") {
continue;
}
shell.echo(`Bundling docs ${parser}...`);
shell.exec(
`rollup -c scripts/build/rollup.docs.config.js --environment filepath:parser-${
parser
}.js`
);
}
shell.echo();
// --- Misc ---
shell.echo("Remove eval");
@ -133,9 +93,6 @@ const newIssueTemplate = issueTemplate.replace(
);
pipe(newIssueTemplate).to(".github/ISSUE_TEMPLATE.md");
shell.echo("Copy sw-toolbox.js to docs");
shell.cp("node_modules/sw-toolbox/sw-toolbox.js", `${docs}/sw-toolbox.js`);
shell.echo("Copy package.json");
const pkgWithoutDependencies = Object.assign({}, pkg);
delete pkgWithoutDependencies.dependencies;

View File

@ -9,7 +9,7 @@ const filename = filepath.replace(/.+\//, "");
const basename = filename.replace(/\..+/, "");
export default Object.assign(baseConfig, {
entry: "dist/" + filepath,
entry: "node_modules/prettier/" + filepath,
dest: "website/static/lib/" + filename,
format: "iife",
plugins: [json(), resolve({ preferBuiltins: true }), commonjs(), globals()],

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -22,6 +22,9 @@ self.require = function require(path) {
if (path === "stream") {
return { PassThrough() {} };
}
if (path === "./third-party") {
return {};
}
return self[path.replace(/.+-/, "")];
};