build(docs-infra): update dgeni-packages dependency (#31368)

The new version 0.27.5 now has the `post-process-html` package, so we
don't need it in angular/angular any more.

PR Close #31368
This commit is contained in:
Pete Bacon Darwin 2019-07-01 15:37:51 +01:00 committed by Alex Rickabaugh
parent 02491a6ce8
commit 1db3ac457c
6 changed files with 98 additions and 144 deletions

View File

@ -112,7 +112,7 @@
"cross-spawn": "^5.1.0",
"css-selector-parser": "^1.3.0",
"dgeni": "^0.4.11",
"dgeni-packages": "^0.27.1",
"dgeni-packages": "^0.27.5",
"entities": "^1.1.1",
"eslint": "^3.19.0",
"eslint-plugin-jasmine": "^2.2.0",

View File

@ -14,7 +14,7 @@ const linksPackage = require('../links-package');
const examplesPackage = require('../examples-package');
const targetPackage = require('../target-package');
const remarkPackage = require('../remark-package');
const postProcessPackage = require('../post-process-package');
const postProcessPackage = require('dgeni-packages/post-process-html');
const { PROJECT_ROOT, CONTENTS_PATH, OUTPUT_PATH, DOCS_OUTPUT_PATH, TEMPLATES_PATH, AIO_PATH, requireFolder } = require('../config');

View File

@ -1,5 +0,0 @@
var Package = require('dgeni').Package;
var base = require('dgeni-packages/base');
module.exports = new Package('post-process-package', [base])
.processor(require('./processors/post-process-html'));

View File

@ -1,49 +0,0 @@
const rehype = require('rehype');
/**
* @dgProcessor postProcessHtml
*
* @description
* Use the rehype processing engine to manipulate the
* `renderedContent` HTML via rehype "plugins" that work with HTML ASTs (HASTs).
* See https://github.com/wooorm/rehype
*
* Each plugin is a factory function that will be called with the "rehype" engine as `this`.
* The factory should return a "transform" function that takes a HAST and returns a `boolean` or `undefined`.
* The HAST can be mutated by the "transform" function.
* If `false` is returned then the processing stops with that plugin.
*
* @property docTypes {string[]} the `docTypes` of docs that should be post-processed
* @property plugins {Function[]} the rehype plugins that will modify the HAST.
*
*/
module.exports = function postProcessHtml(log, createDocMessage) {
return {
$runAfter: ['docs-rendered'],
$runBefore: ['writing-files'],
docTypes: [],
plugins: [],
$process(docs) {
const engine = rehype()
.data('settings', { fragment: true });
this.plugins.forEach(plugin => engine.use(plugin));
let vFile;
docs
.filter(doc => this.docTypes.indexOf(doc.docType) !== -1)
.forEach(doc => {
try {
vFile = engine.processSync(doc.renderedContent);
doc.renderedContent = vFile.contents;
vFile.messages.forEach(m => {
log.warn(createDocMessage(m.message, doc));
});
doc.vFile = vFile;
} catch(e) {
throw new Error(createDocMessage(e.message, doc));
}
});
}
};
};

View File

@ -1,84 +0,0 @@
const testPackage = require('../../helpers/test-package');
const Dgeni = require('dgeni');
describe('postProcessHtml', function() {
let dgeni, injector, processor, createDocMessage;
beforeEach(function() {
dgeni = new Dgeni([testPackage('post-process-package', true)]);
injector = dgeni.configureInjector();
createDocMessage = injector.get('createDocMessage');
processor = injector.get('postProcessHtml');
processor.docTypes = ['a', 'b'];
});
it('should be available from the injector', () => {
expect(processor).toBeDefined();
});
it('should only process docs that match the specified docTypes', () => {
const elements = [];
const captureFirstElement = ast => {
elements.push(ast.children[0].tagName);
};
processor.plugins = [() => captureFirstElement];
const docs = [
{ docType: 'a', renderedContent: '<a></a>' },
{ docType: 'b', renderedContent: '<b></b>' },
{ docType: 'c', renderedContent: '<c></c>' },
{ docType: 'd', renderedContent: '<d></d>' },
];
processor.$process(docs);
expect(elements).toEqual(['a', 'b']);
});
it('should run all the plugins on each doc', () => {
const capitalizeFirstElement = ast => {
ast.children[0].tagName = ast.children[0].tagName.toUpperCase();
};
const addOneToFirstElement = ast => {
ast.children[0].tagName = ast.children[0].tagName + '1';
};
const elements = [];
const captureFirstElement = ast => {
elements.push(ast.children[0].tagName);
};
const docs = [
{ docType: 'a', renderedContent: '<a></a>' },
{ docType: 'b', renderedContent: '<b></b>' },
{ docType: 'c', renderedContent: '<c></c>' },
{ docType: 'd', renderedContent: '<d></d>' },
];
processor.plugins = [
() => capitalizeFirstElement,
() => addOneToFirstElement,
() => captureFirstElement
];
processor.$process(docs);
expect(elements).toEqual(['A1', 'B1']);
});
it('should report non-fatal errors', () => {
const log = injector.get('log');
const addWarning = (ast, file) => {
file.message('There was a problem');
};
processor.plugins = [() => addWarning];
processor.$process([{ docType: 'a', renderedContent: '' }]);
expect(log.warn).toHaveBeenCalledWith('There was a problem - doc (a) ');
});
it('should throw on fatal errors', () => {
const log = injector.get('log');
const addError = (ast, file) => {
file.fail('There was an error');
};
const doc = { docType: 'a', renderedContent: '' };
processor.plugins = [() => addError];
expect(() => processor.$process([doc])).toThrowError(createDocMessage('There was an error', doc));
expect(log.error).not.toHaveBeenCalled();
});
});

View File

@ -2947,10 +2947,10 @@ dezalgo@^1.0.0:
asap "^2.0.0"
wrappy "1"
dgeni-packages@^0.27.1:
version "0.27.2"
resolved "https://registry.yarnpkg.com/dgeni-packages/-/dgeni-packages-0.27.2.tgz#ca1b40147a56668db2f4a2f09a374c6355f45cfa"
integrity sha512-hLZz5FeUTw50+yYE3nVHjpuWSve3YasqcDqq3t6ACxIfy0l/L60jzmBFjTGBbNYvn2qBAVzUEGNOQ2gzbFXBGQ==
dgeni-packages@^0.27.5:
version "0.27.5"
resolved "https://registry.yarnpkg.com/dgeni-packages/-/dgeni-packages-0.27.5.tgz#65b2ed1be6e85937c502d94df0ad16108bcaa801"
integrity sha512-GHLRu/CZoqQDfSKAWis5GkZFSAcK1jQos0P/f0mbZTWGCZpqicSRWTfzCjNAOYdk660jp/fab5/EvRX1um1Bdw==
dependencies:
canonical-path "^1.0.0"
catharsis "^0.8.1"
@ -2967,6 +2967,7 @@ dgeni-packages@^0.27.1:
mkdirp-promise "^5.0.0"
node-html-encoder "0.0.2"
nunjucks "^3.1.6"
rehype "^8.0.0"
semver "^5.2.0"
shelljs "^0.7.0"
source-map-support "^0.4.15"
@ -4727,6 +4728,17 @@ hast-util-from-parse5@^4.0.0:
web-namespaces "^1.1.2"
xtend "^4.0.1"
hast-util-from-parse5@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/hast-util-from-parse5/-/hast-util-from-parse5-5.0.1.tgz#7da8841d707dcf7be73715f7f3b14e021c4e469a"
integrity sha512-UfPzdl6fbxGAxqGYNThRUhRlDYY7sXu6XU9nQeX4fFZtV+IHbyEJtd+DUuwOqNV4z3K05E/1rIkoVr/JHmeWWA==
dependencies:
ccount "^1.0.3"
hastscript "^5.0.0"
property-information "^5.0.0"
web-namespaces "^1.1.2"
xtend "^4.0.1"
hast-util-has-property@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/hast-util-has-property/-/hast-util-has-property-1.0.2.tgz#4c9c3c6122fcc84a5b7c40a573940aaa4b8a8278"
@ -4762,6 +4774,22 @@ hast-util-to-html@^4.0.0:
unist-util-is "^2.0.0"
xtend "^4.0.1"
hast-util-to-html@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/hast-util-to-html/-/hast-util-to-html-6.0.1.tgz#46f4f8d4d2e39c0510268c873a82c360766a0366"
integrity sha512-9LjLAsO2gPO9H6N0VxZsK4sqNZY1A0lMNDfdpMseryV18Hri2++guFfPmjY58PzmtBlBvDflqktxjSm2I1o1yg==
dependencies:
ccount "^1.0.0"
comma-separated-tokens "^1.0.1"
hast-util-is-element "^1.0.0"
hast-util-whitespace "^1.0.0"
html-void-elements "^1.0.0"
property-information "^5.0.0"
space-separated-tokens "^1.0.0"
stringify-entities "^2.0.0"
unist-util-is "^3.0.0"
xtend "^4.0.1"
hast-util-to-string@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hast-util-to-string/-/hast-util-to-string-1.0.1.tgz#b28055cdca012d3c8fd048757c8483d0de0d002c"
@ -4779,6 +4807,16 @@ hastscript@^4.0.0:
property-information "^4.0.0"
space-separated-tokens "^1.0.0"
hastscript@^5.0.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/hastscript/-/hastscript-5.1.0.tgz#a19b3cca6a26a2bcd0f1b1eac574af9427c1c7df"
integrity sha512-7mOQX5VfVs/gmrOGlN8/EDfp1GqV6P3gTNVt+KnX4gbYhpASTM8bklFdFQCbFRAadURXAmw0R1QQdBdqp7jswQ==
dependencies:
comma-separated-tokens "^1.0.0"
hast-util-parse-selector "^2.2.0"
property-information "^5.0.1"
space-separated-tokens "^1.0.0"
hawk@~6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038"
@ -5353,6 +5391,11 @@ is-decimal@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-decimal/-/is-decimal-1.0.1.tgz#f5fb6a94996ad9e8e3761fbfbd091f1fca8c4e82"
is-decimal@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/is-decimal/-/is-decimal-1.0.3.tgz#381068759b9dc807d8c0dc0bfbae2b68e1da48b7"
integrity sha512-bvLSwoDg2q6Gf+E2LEPiklHZxxiSi3XAh4Mav65mKqTfCO1HM3uBs24TjEH8iJX3bbDdLXKJXBTmGzuTUuAEjQ==
is-descriptor@^0.1.0:
version "0.1.6"
resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca"
@ -8187,6 +8230,13 @@ property-information@^4.0.0:
dependencies:
xtend "^4.0.1"
property-information@^5.0.0, property-information@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/property-information/-/property-information-5.1.0.tgz#e4755eee5319f03f7f6f5a9bc1a6a7fea6609e2c"
integrity sha512-tODH6R3+SwTkAQckSp2S9xyYX8dEKYkeXw+4TmJzTxnNzd6mQPu1OD4f9zPrvw/Rm4wpPgI+Zp63mNSGNzUgHg==
dependencies:
xtend "^4.0.1"
protochain@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/protochain/-/protochain-1.0.5.tgz#991c407e99de264aadf8f81504b5e7faf7bfa260"
@ -8715,6 +8765,15 @@ rehype-parse@^5.0.0:
parse5 "^5.0.0"
xtend "^4.0.1"
rehype-parse@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/rehype-parse/-/rehype-parse-6.0.1.tgz#a5401d7f4144d5e17cbb69be11f05a2a7ba87e27"
integrity sha512-FrGSbOzcGxIvWty1qHjKTvHT4WBTt7C6JLs65EkvFPa7ZKraSmsoDDj6al1eBxaXS1t/kiGdPYazUe58Mgflgw==
dependencies:
hast-util-from-parse5 "^5.0.0"
parse5 "^5.0.0"
xtend "^4.0.1"
rehype-slug@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/rehype-slug/-/rehype-slug-2.0.2.tgz#a0d5a4118548ee6165b1f911a213a13e284d91ba"
@ -8733,6 +8792,14 @@ rehype-stringify@^4.0.0:
hast-util-to-html "^4.0.0"
xtend "^4.0.1"
rehype-stringify@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/rehype-stringify/-/rehype-stringify-6.0.0.tgz#a8a573b6f9bf98916955978acd746c37cfd88ac0"
integrity sha512-grV/hhA7z9GbUJZk0ILzprSE0YY9lvTmYuvgRjXdFXrrag5gNeqXBQIuG1m4zFW6PFm0YYnJ/qgf5y6yui4VsA==
dependencies:
hast-util-to-html "^6.0.0"
xtend "^4.0.1"
rehype@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/rehype/-/rehype-6.0.0.tgz#873d4686c52d694560cf5d3f9e4440115840491d"
@ -8741,6 +8808,15 @@ rehype@^6.0.0:
rehype-stringify "^4.0.0"
unified "^7.0.0"
rehype@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/rehype/-/rehype-8.0.0.tgz#d0776cfcc353dd15c4c03b2de76d78a6c302e69c"
integrity sha512-fqcYo/q4Xka0ZvS6abiHtZsN7/TauTzTZQfXqtWACo9Qz76Vv/8uzhOizAfDBjVPhbnDl3xPIMRArUdcV/xFaA==
dependencies:
rehype-parse "^6.0.0"
rehype-stringify "^6.0.0"
unified "^7.0.0"
remark-html@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/remark-html/-/remark-html-8.0.0.tgz#9fcb859a6f3cb40f3ef15402950f1a62ec301b3a"
@ -9997,6 +10073,17 @@ stringify-entities@^1.0.1:
is-alphanumerical "^1.0.0"
is-hexadecimal "^1.0.0"
stringify-entities@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/stringify-entities/-/stringify-entities-2.0.0.tgz#fa7ca6614b355fb6c28448140a20c4ede7462827"
integrity sha512-fqqhZzXyAM6pGD9lky/GOPq6V4X0SeTAFBl0iXb/BzOegl40gpf/bV3QQP7zULNYvjr6+Dx8SCaDULjVoOru0A==
dependencies:
character-entities-html4 "^1.0.0"
character-entities-legacy "^1.0.0"
is-alphanumerical "^1.0.0"
is-decimal "^1.0.2"
is-hexadecimal "^1.0.0"
stringmap@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/stringmap/-/stringmap-0.2.2.tgz#556c137b258f942b8776f5b2ef582aa069d7d1b1"
@ -10728,6 +10815,11 @@ unist-util-is@^2.1.2:
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-2.1.2.tgz#1193fa8f2bfbbb82150633f3a8d2eb9a1c1d55db"
integrity sha512-YkXBK/H9raAmG7KXck+UUpnKiNmUdB+aBGrknfQ4EreE1banuzrKABx3jP6Z5Z3fMSPMQQmeXBlKpCbMwBkxVw==
unist-util-is@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-3.0.0.tgz#d9e84381c2468e82629e4a5be9d7d05a2dd324cd"
integrity sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==
unist-util-modify-children@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/unist-util-modify-children/-/unist-util-modify-children-1.1.1.tgz#66d7e6a449e6f67220b976ab3cb8b5ebac39e51d"