Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('docs', function() {
var docVersion = argv['doc-version'] || 'nightly';
if (docVersion != 'nightly' && !semver.valid(docVersion)) {
console.log('Usage: gulp docs --doc-version=(nightly|versionName)');
return process.exit(1);
}
var config = dgeni.loadConfig(path.resolve(projectRoot, 'config/docs/docs.config.js'));
config.set('currentVersion', docVersion);
config.set(
'rendering.outputFolder',
argv.dist ? argv.dist : path.resolve(projectRoot, '..', 'ionic-site')
);
return dgeni.generator(config)().then(function() {
gutil.log('Docs for', gutil.colors.cyan(docVersion), 'generated!');
});
});
var through2 = require('through2');
var extend = require('extend');
var _ = require('lodash');
var gutil = require('gulp-util');
var File = gutil.File;
var PluginError = gutil.PluginError;
var path = require('canonical-path');
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
var merge = require('merge-stream');
var setup = {sections: {}, pages: [], apis: {}};
var fakeDest = '_FAKE_DEST_';
var templates = path.resolve(__dirname, 'src/templates');
var nodeModules = path.resolve(__dirname, 'node_modules');
var flattenedNodeModules = path.resolve(__dirname, '../');
function copyTemplates() {
return function () {
return vfs.src(['**/*', '!**/*.tmpl'], {cwd: templates});
};
}
function streamFile(src, dir, dest, name) {
return function () {
return vfs.src(src).pipe(through2.obj(function (file, enc, callback) {
name = name === undefined ? path.normalize(file.path).split('/').pop() : name;
this.push(new File({
base: dest,
cwd: dest,
path: path.join(dest, dir, name),
contents: file.contents
it("should not calculate module if the doc is not in 'api' area", function() {
var tagDef = tagDefFactory();
var relativePath = 'guide/concepts.ngdoc';
expect(tagDef.defaultFn({ area: 'guide', fileInfo: { filePath: path.resolve(relativePath), relativePath: relativePath } })).toBeUndefined();
});
it('should use copySync and chmodSync', () => {
spyOn(fs, 'copySync');
spyOn(fs, 'chmodSync');
exampleBoilerPlate.copyFile('source/folder', 'destination/folder', 'some/file/path');
expect(fs.copySync).toHaveBeenCalledWith(
path.resolve('source/folder/some/file/path'),
path.resolve('destination/folder/some/file/path'),
{ overwrite: true });
expect(fs.chmodSync).toHaveBeenCalledWith(path.resolve('destination/folder/some/file/path'), 444);
});
});
it('should process all the example folders', () => {
const examplesDir = path.resolve(__dirname, '../../content/examples');
exampleBoilerPlate.add();
expect(exampleBoilerPlate.getFoldersContaining)
.toHaveBeenCalledWith(examplesDir, 'example-config.json', 'node_modules');
});
function normalizeSourceInfo(basePath, sourceInfo) {
if ( _.isString(sourceInfo) ) {
sourceInfo = { include: sourceInfo };
} else if ( !_.isObject(sourceInfo) ) {
throw new Error('Invalid sourceFiles parameter. ' +
'You must pass an array of items, each of which is either a string or an object of the form ' +
'{ include: "...", basePath: "...", exclude: "...", fileReader: "..." }');
}
sourceInfo.basePath = path.resolve(basePath, sourceInfo.basePath || '.');
sourceInfo.include = path.resolve(sourceInfo.basePath, sourceInfo.include);
sourceInfo.exclude = sourceInfo.exclude && path.resolve(sourceInfo.basePath, sourceInfo.exclude);
return sourceInfo;
}
var getVersion = function(component, sourceFolder, packageFile) {
sourceFolder = sourceFolder || './bower_components';
packageFile = packageFile || 'bower.json';
return require(path.resolve(sourceFolder,component,packageFile)).version;
};
{
include: 'bindings/angular1/directives/*.js',
basePath: path.resolve(__dirname, '/bindings/angular1/directives')
},
{
include: 'bindings/angular1/js/*.js',
basePath: path.resolve(__dirname, '/bindings/angular1/js')
},
{
include: 'docs/guides/*.ngdoc',
basePath: path.resolve(__dirname, '/docs/guides')
}
];
templateFinder.templateFolders.unshift(
path.resolve(__dirname, 'templates')
);
templateFinder.templatePatterns.unshift('${ doc.docType }.template.html');
})
.config(function(writeFilesProcessor, parseTagsProcessor, templateEngine, checkAnchorLinksProcessor) {
function Reporter(options) {
var _defaultOutputFile = path.resolve(process.cwd(), './_test-output', 'protractor-results.txt');
options.outputFile = options.outputFile || _defaultOutputFile;
initOutputFile(options.outputFile);
options.appDir = options.appDir || './';
var _root = {appDir: options.appDir, suites: []};
log('AppDir: ' + options.appDir, +1);
var _currentSuite;
this.suiteStarted = function (suite) {
_currentSuite = {description: suite.description, status: null, specs: []};
_root.suites.push(_currentSuite);
log('Suite: ' + suite.description, +1);
};
this.suiteDone = function (suite) {
var statuses = _currentSuite.specs.map(function (spec) {
/*eslint-env es6*/
const chalk = require('chalk');
const fs = require('fs-extra');
const path = require('canonical-path');
const shelljs = require('shelljs');
const yargs = require('yargs');
const PACKAGE_JSON = 'package.json';
const LOCAL_MARKER_PATH = 'node_modules/_local_.json';
const PACKAGE_JSON_REGEX = /^[^/]+\/package\.json$/;
const ANGULAR_ROOT_DIR = path.resolve(__dirname, '../../..');
const ANGULAR_DIST_PACKAGES = path.resolve(ANGULAR_ROOT_DIR, 'dist/package');
/**
* A tool that can install Angular dependencies for a project from NPM or from the
* locally built distributables.
*
* This tool is used to change dependencies of the `aio` application and the example
* applications.
*/
class NgPackagesInstaller {
/**
* Create a new installer for a project in the specified directory.
*
* @param {string} projectDir - the path to the directory containing the project.
* @param {object} options - a hash of options for the install
* * `debug` (`boolean`) - whether to display debug messages.