2017-04-16 15:48:22 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-04-16 15:48:22 -04:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2017-04-20 15:33:47 -04:00
|
|
|
|
|
|
|
/* eslint no-console: "off" */
|
|
|
|
|
2017-04-16 15:48:22 -04:00
|
|
|
const Package = require('dgeni').Package;
|
2017-04-21 08:10:52 -04:00
|
|
|
const contentPackage = require('../angular-content-package');
|
2017-04-20 15:33:47 -04:00
|
|
|
const { readFileSync } = require('fs');
|
|
|
|
const { resolve } = require('canonical-path');
|
2017-04-21 08:10:52 -04:00
|
|
|
const { CONTENTS_PATH } = require('../config');
|
2017-04-20 15:33:47 -04:00
|
|
|
|
|
|
|
function createPackage(guideName) {
|
|
|
|
|
|
|
|
const guideFilePath = `${CONTENTS_PATH}/guide/${guideName}.md`;
|
|
|
|
const guideFile = readFileSync(guideFilePath, 'utf8');
|
|
|
|
const examples = [];
|
|
|
|
guideFile.replace(/<code-(?:pane|example) [^>]*path="([^"]+)"/g, (_, path) => examples.push('examples/' + path));
|
|
|
|
|
|
|
|
if (examples.length) {
|
|
|
|
console.log('The following example files are referenced in this guide:');
|
|
|
|
console.log(examples.map(example => ' - ' + example).join('\n'));
|
|
|
|
}
|
2017-04-16 15:48:22 -04:00
|
|
|
|
2017-04-21 08:10:52 -04:00
|
|
|
return new Package('author-guide', [contentPackage])
|
2017-04-16 15:48:22 -04:00
|
|
|
.config(function(readFilesProcessor) {
|
|
|
|
readFilesProcessor.sourceFiles = [
|
|
|
|
{
|
|
|
|
basePath: CONTENTS_PATH,
|
2017-04-20 15:33:47 -04:00
|
|
|
include: guideFilePath,
|
2017-04-16 15:48:22 -04:00
|
|
|
fileReader: 'contentFileReader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
basePath: CONTENTS_PATH,
|
2017-04-20 15:33:47 -04:00
|
|
|
include: examples.map(example => resolve(CONTENTS_PATH, example)),
|
2017-04-16 15:48:22 -04:00
|
|
|
fileReader: 'exampleFileReader'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-05-19 15:08:49 -04:00
|
|
|
module.exports = { createPackage };
|