build(aio): refactor dgeni packages
This is to tidy up the `author-packagse`, which currently duplicates a lot of the configuration in the main packages. We need to DRY this up so that we don't fall foul of a change in one being missed in the other.
This commit is contained in:

committed by
Pete Bacon Darwin

parent
7a8bd99ab1
commit
3cad5da5a4
@ -5,22 +5,38 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
const Package = require('dgeni').Package;
|
||||
const { basePackage, CONTENTS_PATH, getBoilerPlateExcludes } = require('./base-package');
|
||||
|
||||
function createPackage() {
|
||||
return new Package('author-tutorial', [basePackage])
|
||||
const Package = require('dgeni').Package;
|
||||
const contentPackage = require('../angular-content-package');
|
||||
const { readFileSync } = require('fs');
|
||||
const { resolve } = require('canonical-path');
|
||||
const { CONTENTS_PATH } = require('../config');
|
||||
|
||||
/* eslint no-console: "off" */
|
||||
|
||||
function createPackage(tutorialName) {
|
||||
|
||||
const tutorialFilePath = `${CONTENTS_PATH}/tutorial/${tutorialName}.md`;
|
||||
const tutorialFile = readFileSync(tutorialFilePath, 'utf8');
|
||||
const examples = [];
|
||||
tutorialFile.replace(/<code-(?:pane|example) [^>]*path="([^"]+)"/g, (_, path) => examples.push('examples/' + path));
|
||||
|
||||
if (examples.length) {
|
||||
console.log('The following example files are referenced in this tutorial:');
|
||||
console.log(examples.map(example => ' - ' + example).join('\n'));
|
||||
}
|
||||
|
||||
return new Package('author-tutorial', [contentPackage])
|
||||
.config(function(readFilesProcessor) {
|
||||
readFilesProcessor.sourceFiles = [
|
||||
{
|
||||
basePath: CONTENTS_PATH,
|
||||
include: CONTENTS_PATH + '/tutorial/**/*.md',
|
||||
include: tutorialFilePath,
|
||||
fileReader: 'contentFileReader'
|
||||
},
|
||||
{
|
||||
basePath: CONTENTS_PATH,
|
||||
include: CONTENTS_PATH + '/examples/toh-*/**/*',
|
||||
exclude: getBoilerPlateExcludes(),
|
||||
include: examples.map(example => resolve(CONTENTS_PATH, example)),
|
||||
fileReader: 'exampleFileReader'
|
||||
}
|
||||
];
|
||||
|
Reference in New Issue
Block a user