* feat(markdown): inital implementation
* feat(markdown): support strong
* fix: add missing default value
* feat(markdown): support inlineCode
* feat: support delete
* feat: support link
* feat: support image
* feat: support blockquote
* feat: support heading
* feat: support code
* feat: support yaml
* feat: support html
* feat: support list
* feat: support thematicBreak
* feat: support table
* feat: support linkReference
* feat: support imageReference
* feat: support definition
* feat: support footnote
* feat: support footnoteReference
* feat: support footnoteDefinition
* test(cli): update snapshots
* refactor: extract SINGLE_LINE_NODE_TYPES
* refactor: printChildren
* fix: correct newlines
* test: add trailing newline
* fix: blockquote formatting
* fix: node types
* fix: break line correctly
* fix: remove unnecessary properties to make AST_COMPARE happy
* fix: escape `|` in tableCell content
* fix: unexpected line break
* fix: ast difference from loose list
* fix: html break lines
* refactor: fix linting
* fix: normalize ast
* fix: escape specific chars
* test: add more tests
* fix: build markdown parser
* chore: remove unnecessary *.log
* fix: escape html entity
* feat: support prettier-ignore
* fix: line break for non-loose listItem
* feat: support formatting `code` based on `lang`
* fix: add `jsx` and `tsx`
* fix: use multiparser
* refactor: fix linting
* test: update test case 😉
* feat: switch to `_` style emphasis
* fix: sequence list should use different prefix
* test: add tests
* fix: do not print additional new line after `prettier-ignore`
* fix(list): enforce `1.` to avoid unnecessary git diff
* feat: enable `commonmark` option
* feat: support `break`
* fix: escape backslash
* refactor: escape html entity using backslash
* fix: respect autolink-style link
* feat: support md`...` and markdown`...`
* docs: replace ands with commas
* fix: respect indented code block
* fix: respect html entity
* docs: add docs for modified MDAST
* fix: inlineCode is breakline-able
* feat: support backtick in inlineCode
* feat: support a-lot-of-backtick in fenced code block
* feat: use `~~~`-style code block in js template
* fix: respect escaped chars
* fix: use `*`-style emphasis for invalid `_`-style output
* test: add test cases
* fix: use `- - -`-style thematicBreak to avoid conflict with yaml
* fix: remain the same content for linkReference identifier
* fix: `inlineCode` gap can be a line break
* fix: `html` should not print trailing spaces if it's in root
* refactor: fix typo
* fix: wrap `definition`'s url if there's whitespace
* fix: remove unnecessary whitespace at the end of paragraph
* fix: fix: remove unnecessary whitespace at the start of paragraph
* fix: setence children length is possible 0
* fix: support continuous ordered list
* fix: do not print addtional hardline after loose list
* fix: use double-backtick style for single-backtick value in inlineCode
* fix: support nested emphasis
* fix: support space-url in link/image
* fix: escape `)` in link/image url
* fix: support single-quote in link/image/definition title
* fix: respect alt in image/imageReference
* fix: use `*`-style thematicBreak in list
* fix: loose/tight list linebreaks
* fix: print third linebreak before indented code block with a tight list in the previous
* test: move bug cases
* fix: remove unnecessary linebreaks
* refactor: fix typo
144 lines
3.6 KiB
JavaScript
Executable File
144 lines
3.6 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
"use strict";
|
|
|
|
const path = require("path");
|
|
const pkg = require("../../package.json");
|
|
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",
|
|
"typescript",
|
|
"graphql",
|
|
"postcss",
|
|
"parse5",
|
|
"markdown"
|
|
];
|
|
|
|
process.env.PATH += path.delimiter + path.join(rootDir, "node_modules", ".bin");
|
|
|
|
function pipe(string) {
|
|
return new shell.ShellString(string);
|
|
}
|
|
|
|
shell.set("-e");
|
|
shell.cd(rootDir);
|
|
|
|
shell.rm("-Rf", "dist/", docs);
|
|
shell.mkdir("-p", docs);
|
|
|
|
// --- Lib ---
|
|
|
|
shell.echo("Bundling lib index...");
|
|
shell.exec("rollup -c scripts/build/rollup.index.config.js");
|
|
|
|
shell.echo("Bundling lib bin...");
|
|
shell.exec("rollup -c scripts/build/rollup.bin.config.js");
|
|
shell.chmod("+x", "./dist/bin/prettier.js");
|
|
|
|
for (const parser of parsers) {
|
|
if (parser === "postcss") {
|
|
continue;
|
|
}
|
|
shell.echo(`Bundling lib ${parser}...`);
|
|
shell.exec(
|
|
`rollup -c scripts/build/rollup.parser.config.js --environment parser:${parser}`
|
|
);
|
|
}
|
|
|
|
shell.echo("Bundling lib postcss...");
|
|
// PostCSS has dependency cycles and won't work correctly with rollup :(
|
|
shell.exec(
|
|
"webpack --hide-modules src/parser-postcss.js dist/parser-postcss.js"
|
|
);
|
|
// Prepend module.exports =
|
|
const content = shell.cat("dist/parser-postcss.js").stdout;
|
|
pipe(`module.exports = ${content}`).to("dist/parser-postcss.js");
|
|
|
|
shell.echo();
|
|
|
|
// --- Docs ---
|
|
|
|
shell.echo("Bundling docs index...");
|
|
shell.cp("dist/index.js", `${docs}/index.js`);
|
|
shell.exec(
|
|
`node_modules/babel-cli/bin/babel.js dist/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");
|
|
shell.sed(
|
|
"-i",
|
|
/eval\("require"\)/,
|
|
"require",
|
|
"dist/index.js",
|
|
"dist/bin/prettier.js"
|
|
);
|
|
|
|
shell.echo("Update ISSUE_TEMPLATE.md");
|
|
const issueTemplate = shell.cat(".github/ISSUE_TEMPLATE.md").stdout;
|
|
const newIssueTemplate = issueTemplate.replace(
|
|
/-->[^]*$/,
|
|
"-->\n\n" +
|
|
formatMarkdown(
|
|
"// code snippet",
|
|
"// code snippet",
|
|
"",
|
|
pkg.version,
|
|
"https://prettier.io/playground/#.....",
|
|
{ parser: "babylon" },
|
|
[["# Options (if any):", true], ["--single-quote", true]],
|
|
true
|
|
)
|
|
);
|
|
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;
|
|
pkgWithoutDependencies.scripts = {
|
|
prepublishOnly:
|
|
"node -e \"assert.equal(require('.').version, require('..').version)\""
|
|
};
|
|
pipe(JSON.stringify(pkgWithoutDependencies, null, 2)).to("dist/package.json");
|
|
|
|
shell.echo("Copy README.md");
|
|
shell.cp("README.md", "dist/README.md");
|
|
|
|
shell.echo("Done!");
|
|
shell.echo();
|
|
shell.echo("How to test against dist:");
|
|
shell.echo(" 1) yarn test:dist");
|
|
shell.echo();
|
|
shell.echo("How to publish:");
|
|
shell.echo(" 1) IMPORTANT!!! Go to dist/");
|
|
shell.echo(" 2) npm publish");
|