2019-03-20 11:10:47 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2019-03-20 11:10:47 -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
|
|
|
|
*/
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
2019-04-02 02:12:55 -04:00
|
|
|
const tutorialFilePath = `${CONTENTS_PATH}/start/${tutorialName}.md`;
|
2019-03-20 11:10:47 -04:00
|
|
|
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 getting-started:');
|
|
|
|
console.log(examples.map(example => ' - ' + example).join('\n'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Package('author-getting-started', [contentPackage])
|
|
|
|
.config(function(readFilesProcessor) {
|
|
|
|
readFilesProcessor.sourceFiles = [
|
|
|
|
{
|
|
|
|
basePath: CONTENTS_PATH,
|
|
|
|
include: tutorialFilePath,
|
|
|
|
fileReader: 'contentFileReader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
basePath: CONTENTS_PATH,
|
|
|
|
include: examples.map(example => resolve(CONTENTS_PATH, example)),
|
|
|
|
fileReader: 'exampleFileReader'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-19 15:08:49 -04:00
|
|
|
module.exports = { createPackage };
|