chore(): modify dist paths (#1213)

* chore(): modify dist paths

* fixes
This commit is contained in:
Ibby Hadeed 2017-03-22 19:51:59 -04:00 committed by GitHub
parent fdffb055be
commit edf4c75bbd
9 changed files with 183 additions and 199 deletions

View File

@ -40,7 +40,7 @@
"build": "npm run clean && npm run lint && npm run build:core && npm run build:modules", "build": "npm run clean && npm run lint && npm run build:core && npm run build:modules",
"build:core": "ngc -p scripts/build/tsconfig-core.json", "build:core": "ngc -p scripts/build/tsconfig-core.json",
"build:modules": "node scripts/build/build.js", "build:modules": "node scripts/build/build.js",
"clean": "rimraf dist", "clean": "rimraf dist .tmp",
"shipit": "npm run build && gulp readmes && npm run npmpub", "shipit": "npm run build && gulp readmes && npm run npmpub",
"npmpub": "node scripts/build/publish.js", "npmpub": "node scripts/build/publish.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0" "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"

View File

@ -12,8 +12,7 @@ const ROOT = path.resolve(path.join(__dirname, '../../')), // root ionic-native
PLUGIN_PACKAGE_JSON = require(path.resolve(__dirname, 'plugin-package.json')), // plugin package.json template PLUGIN_PACKAGE_JSON = require(path.resolve(__dirname, 'plugin-package.json')), // plugin package.json template
PLUGIN_TS_CONFIG = require(path.resolve(__dirname, 'tsconfig-plugin.json')), // plugin tsconfig template PLUGIN_TS_CONFIG = require(path.resolve(__dirname, 'tsconfig-plugin.json')), // plugin tsconfig template
BUILD_TMP = path.resolve(ROOT, '.tmp'), // tmp directory path BUILD_TMP = path.resolve(ROOT, '.tmp'), // tmp directory path
BUILD_DIST_ROOT = path.resolve(ROOT, 'dist/packages-dist/@ionic-native'), // dist directory root path BUILD_DIST_ROOT = path.resolve(ROOT, 'dist/@ionic-native'), // dist directory root path
BUILD_PLUGINS_DIST = path.resolve(BUILD_DIST_ROOT, 'plugins'), // plugins dist directory path
BUILD_CORE_DIST = path.resolve(BUILD_DIST_ROOT, 'core'); // core dist directory path BUILD_CORE_DIST = path.resolve(BUILD_DIST_ROOT, 'core'); // core dist directory path
@ -37,13 +36,6 @@ const PLUGIN_PEER_DEPS = {
// set peer dependencies for all plugins // set peer dependencies for all plugins
PLUGIN_PACKAGE_JSON.peerDependencies = PLUGIN_PEER_DEPS; PLUGIN_PACKAGE_JSON.peerDependencies = PLUGIN_PEER_DEPS;
// Delete dist directory and any temporary files
console.log('Removing old TMP directory');
fs.removeSync(BUILD_TMP);
fs.removeSync(BUILD_PLUGINS_DIST);
// Create tmp/dist directories // Create tmp/dist directories
console.log('Making new TMP directory'); console.log('Making new TMP directory');
fs.mkdirpSync(BUILD_TMP); fs.mkdirpSync(BUILD_TMP);
@ -79,7 +71,7 @@ const addPluginToQueue = pluginName => {
let tsConfigPath; let tsConfigPath;
fs.mkdirpAsync(PLUGIN_BUILD_DIR) // create tmp build dir fs.mkdirpAsync(PLUGIN_BUILD_DIR) // create tmp build dir
.then(() => fs.mkdirpAsync(path.resolve(BUILD_PLUGINS_DIST, pluginName))) // create dist dir .then(() => fs.mkdirpAsync(path.resolve(BUILD_DIST_ROOT, pluginName))) // create dist dir
.then(() => { .then(() => {
// Write tsconfig.json // Write tsconfig.json
@ -98,7 +90,7 @@ const addPluginToQueue = pluginName => {
packageJson.name = `@ionic-native/${pluginName}`; packageJson.name = `@ionic-native/${pluginName}`;
packageJson.version = IONIC_NATIVE_VERSION; packageJson.version = IONIC_NATIVE_VERSION;
return fs.writeJsonAsync(path.resolve(BUILD_PLUGINS_DIST, pluginName, 'package.json'), packageJson); return fs.writeJsonAsync(path.resolve(BUILD_DIST_ROOT, pluginName, 'package.json'), packageJson);
}) })
.then(() => { .then(() => {

View File

@ -7,51 +7,38 @@ const fs = require('fs-extra-promise').useFs(require('fs-extra')),
const ROOT = path.resolve(path.join(__dirname, '../../')), const ROOT = path.resolve(path.join(__dirname, '../../')),
DIST = path.resolve(ROOT, 'dist', 'packages-dist', '@ionic-native'), DIST = path.resolve(ROOT, 'dist', '@ionic-native');
PLUGINS_ROOT = path.resolve(DIST, 'plugins'),
CORE = path.resolve(DIST, 'core');
const FLAGS = '--access public'; // add any flags here if you want... (example: --tag alpha) const FLAGS = '--access public'; // add any flags here if you want... (example: --tag alpha)
console.log('Publishing @ionic-native/core'); const PACKAGES = fs.readdirSync(DIST);
exec(`npm publish ${CORE} ${FLAGS}`)
.then(() => {
const PLUGINS = fs.readdirSync(PLUGINS_ROOT);
const QUEUE = queue({ const QUEUE = queue({
concurrency: 10 concurrency: 10
}); });
PLUGINS.forEach(pluginName => { PACKAGES.forEach(packageName => {
QUEUE.push(done => { QUEUE.push(done => {
console.log(`Publishing plugin ${pluginName}`); console.log(`Publishing @ionic-native/${packageName}`);
const pluginPath = path.resolve(PLUGINS_ROOT, pluginName); const packagePath = path.resolve(DIST, packageName);
exec(`npm publish ${packagePath} ${FLAGS}`)
exec(`npm publish ${pluginPath} ${FLAGS}`) .then(() => done())
.then(() => done()) .catch(done);
.catch(done);
});
});
QUEUE.start((err) => {
if (err) {
console.log('Error publishing ionic-native. ', err);
} else {
console.log('Done publishing ionic-native!');
}
});
})
.catch(e => {
console.log('Publish failed');
console.log(e);
}); });
});
QUEUE.start((err) => {
if (err) {
console.log('Error publishing ionic-native. ', err);
} else {
console.log('Done publishing ionic-native!');
}
});

View File

@ -7,7 +7,7 @@
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"module": "es2015", "module": "es2015",
"moduleResolution": "node", "moduleResolution": "node",
"outDir": "../../dist/packages-dist/", "outDir": "../../dist/",
"rootDir": "../../src/", "rootDir": "../../src/",
"target": "es5", "target": "es5",
"skipLibCheck": true, "skipLibCheck": true,

View File

@ -7,16 +7,14 @@
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"module": "es2015", "module": "es2015",
"moduleResolution": "node", "moduleResolution": "node",
"outDir": "../../../dist/packages-dist/", "outDir": "../../../dist/@ionic-native/",
"paths": { "paths": {
"@ionic-native/core": ["../../../dist/packages-dist/@ionic-native/core"] "@ionic-native/core": ["../../../dist/@ionic-native/core"]
}, },
"rootDir": "../../../src/", "rootDir": "../../../src/@ionic-native/plugins/",
"target": "es5", "target": "es5",
"skipLibCheck": true, "skipLibCheck": true,
"lib": ["es2015", "dom"] "lib": ["es2015", "dom"]
}, },
"files": [ "files": []
"../../../src/@ionic-native/plugins/{{PLUGIN}}/index.ts"
]
} }

View File

@ -2,5 +2,5 @@
"sitePath": "../ionic-site", "sitePath": "../ionic-site",
"v2DocsDir": "docs/v2/native", "v2DocsDir": "docs/v2/native",
"docsDest": "../ionic-site/content/docs/v2/native", "docsDest": "../ionic-site/content/docs/v2/native",
"pluginDir": "dist/packages-dist/@ionic-native/plugins" "pluginDir": "dist/@ionic-native"
} }

View File

@ -17,162 +17,163 @@ module.exports = function(currentVersion) {
return new Package('ionic-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage]) return new Package('ionic-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
// .processor(require('./processors/latest-version')) // .processor(require('./processors/latest-version'))
.processor(require('./processors/readmes')) .processor(require('./processors/readmes'))
.processor(require('./processors/npm-id')) .processor(require('./processors/npm-id'))
.processor(require('./processors/remove-private-members')) .processor(require('./processors/remove-private-members'))
.processor(require('./processors/hide-private-api')) .processor(require('./processors/hide-private-api'))
// .processor(require('./processors/collect-inputs-outputs')) // .processor(require('./processors/collect-inputs-outputs'))
// for debugging docs // for debugging docs
// .processor(function test(){ // .processor(function test(){
// return { // return {
// //
// $runBefore: ['rendering-docs'], // $runBefore: ['rendering-docs'],
// $process: function(docs){ // $process: function(docs){
// docs.forEach(function(doc){ // docs.forEach(function(doc){
// if (doc.name == "Camera"){ // if (doc.name == "Camera"){
// //
// // console.log(doc.tags); // // console.log(doc.tags);
// // doc.tags.forEach(function(tag){ // // doc.tags.forEach(function(tag){
// // if(tag.tagName == 'classes'){ // // if(tag.tagName == 'classes'){
// // // //
// // } // // }
// // }); // // });
// //
// // doc.moduleDoc.exports.forEach(function(d,i){ // // doc.moduleDoc.exports.forEach(function(d,i){
// // if(d.name === 'CameraOptions') { // // if(d.name === 'CameraOptions') {
// // console.log('Name: ' + d.name); // // console.log('Name: ' + d.name);
// // console.log('Type: ' + d.docType); // // console.log('Type: ' + d.docType);
// // console.log('First member: ', d.members[0]); // // console.log('First member: ', d.members[0]);
// // } // // }
// // }); // // });
// //
// //
// // var exports = doc.exportSymbol.parent.exports; // // var exports = doc.exportSymbol.parent.exports;
// // for(var p in exports) { // // for(var p in exports) {
// // if(p == 'CameraOptions') // // if(p == 'CameraOptions')
// // { // // {
// // var x = exports[p]; // // var x = exports[p];
// // console.log(x.members.quality); // // console.log(x.members.quality);
// // } // // }
// // } // // }
// // doc.members.forEach(function(method){ // // doc.members.forEach(function(method){
// // if (method.name === "getPicture") { // // if (method.name === "getPicture") {
// // console.log(method); // // console.log(method);
// // } // // }
// // }) // // })
// } // }
// }) // })
// } // }
// } // }
// }) // })
.config(function(log) { .config(function(log) {
log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error' log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error'
}) })
.config(function(renderDocsProcessor, computePathsProcessor) { .config(function(renderDocsProcessor, computePathsProcessor) {
versions = []; versions = [];
// new version, add it to the versions list // new version, add it to the versions list
if (currentVersion != 'nightly' && !_.includes(versions, currentVersion)) { if (currentVersion != 'nightly' && !_.includes(versions, currentVersion)) {
versions.unshift(currentVersion); versions.unshift(currentVersion);
} }
//First semver valid version is latest //First semver valid version is latest
var latestVersion = _.find(versions, semver.valid); var latestVersion = _.find(versions, semver.valid);
versions = versions.map(function(version) { versions = versions.map(function(version) {
// We don't separate by versions so always put the docs in the root // We don't separate by versions so always put the docs in the root
var folder = ''; var folder = '';
return { return {
href: '/' + config.v2DocsDir.replace('content/', ''), href: '/' + config.v2DocsDir.replace('content/', ''),
folder: folder, folder: folder,
name: version name: version
}; };
}); });
var versionData = { var versionData = {
list: versions, list: versions,
current: _.find(versions, {name: currentVersion}), current: _.find(versions, {name: currentVersion}),
latest: _.find(versions, {name: latestVersion}) || _.first(versions) latest: _.find(versions, {name: latestVersion}) || _.first(versions)
}; };
renderDocsProcessor.extraData.version = versionData; renderDocsProcessor.extraData.version = versionData;
computePathsProcessor.pathTemplates = [{ computePathsProcessor.pathTemplates = [{
docTypes: ['class'], docTypes: ['class'],
getOutputPath: function(doc) { getOutputPath: function(doc) {
return doc.originalModule.replace(config.pluginDir + '/', '') return doc.originalModule.replace(config.pluginDir + '/', '')
.replace('/index', '') + '/README.md'; .replace('/plugins', '')
} .replace('/index', '') + '/README.md';
}]; }
}) }];
})
//configure file reading //configure file reading
.config(function(readFilesProcessor, readTypeScriptModules) { .config(function(readFilesProcessor, readTypeScriptModules) {
// Don't run unwanted processors since we are not using the normal file reading processor // Don't run unwanted processors since we are not using the normal file reading processor
readFilesProcessor.$enabled = false; readFilesProcessor.$enabled = false;
readFilesProcessor.basePath = path.resolve(__dirname, '../..'); readFilesProcessor.basePath = path.resolve(__dirname, '../..');
readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../..')); readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../..'));
readTypeScriptModules.sourceFiles = ['./src/@ionic-native/plugins/**/*.ts']; readTypeScriptModules.sourceFiles = ['./src/@ionic-native/plugins/**/*.ts'];
}) })
.config(function(parseTagsProcessor) { .config(function(parseTagsProcessor) {
parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions
.concat(require('./tag-defs/tag-defs')); .concat(require('./tag-defs/tag-defs'));
}) })
// .config(function(parseTagsProcessor) { // .config(function(parseTagsProcessor) {
// // We actually don't want to parse param docs in this package as we are // // We actually don't want to parse param docs in this package as we are
// // getting the data out using TS // // getting the data out using TS
// parseTagsProcessor.tagDefinitions.forEach(function(tagDef) { // parseTagsProcessor.tagDefinitions.forEach(function(tagDef) {
// console.log(tagDef); // console.log(tagDef);
// if (tagDef.name === 'param') { // if (tagDef.name === 'param') {
// tagDef.docProperty = 'paramData'; // tagDef.docProperty = 'paramData';
// tagDef.transforms = []; // tagDef.transforms = [];
// } // }
// }); // });
// }) // })
// Configure links // Configure links
.config(function(getLinkInfo) { .config(function(getLinkInfo) {
getLinkInfo.useFirstAmbiguousLink = false; getLinkInfo.useFirstAmbiguousLink = false;
}) })
// Configure file writing // Configure file writing
.config(function(writeFilesProcessor) { .config(function(writeFilesProcessor) {
writeFilesProcessor.outputFolder = './dist/packages-dist/'; writeFilesProcessor.outputFolder = './dist/';
}) })
// Configure rendering // Configure rendering
.config(function(templateFinder, templateEngine) { .config(function(templateFinder, templateEngine) {
// Nunjucks and Angular conflict in their template bindings so change the Nunjucks // Nunjucks and Angular conflict in their template bindings so change the Nunjucks
// Also conflict with Jekyll // Also conflict with Jekyll
templateEngine.config.tags = { templateEngine.config.tags = {
variableStart: '<$', variableStart: '<$',
variableEnd: '$>', variableEnd: '$>',
blockStart: '<@', blockStart: '<@',
blockEnd: '@>', blockEnd: '@>',
commentStart: '<#', commentStart: '<#',
commentEnd: '#>' commentEnd: '#>'
}; };
// add custom filters to nunjucks // add custom filters to nunjucks
templateEngine.filters.push( templateEngine.filters.push(
require('./filters/capital'), require('./filters/capital'),
require('./filters/code'), require('./filters/code'),
require('./filters/dump') require('./filters/dump')
); );
templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates')); templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates'));
// Specify how to match docs to templates. // Specify how to match docs to templates.
templateFinder.templatePatterns = [ templateFinder.templatePatterns = [
'${ doc.template }', '${ doc.template }',
'${ doc.docType }.template.md', '${ doc.docType }.template.md',
'readme.template.md' 'readme.template.md'
]; ];
}); });
}; };

View File

@ -1,5 +1,8 @@
var config = require('../config.json'); var config = require('../config.json');
var projectPackage = require('../../package.json'); var projectPackage = require('../../package.json');
var path = require('path');
var fs = require('fs-extra-promise').useFs(require('fs-extra'));
module.exports = function(gulp) { module.exports = function(gulp) {
gulp.task('docs', [], function() { gulp.task('docs', [], function() {
var Dgeni = require('dgeni'); var Dgeni = require('dgeni');
@ -18,6 +21,9 @@ module.exports = function(gulp) {
gulp.task('readmes', [], function() { gulp.task('readmes', [], function() {
var Dgeni = require('dgeni'); var Dgeni = require('dgeni');
var semver = require('semver'); var semver = require('semver');
fs.copySync(path.resolve(__dirname, '..', '..', 'README.md'), path.resolve(__dirname, '..', '..', config.pluginDir, 'core', 'README.md'));
try { try {
var ionicPackage = require('./dgeni-readmes-config')(projectPackage.version); var ionicPackage = require('./dgeni-readmes-config')(projectPackage.version);
var dgeni = new Dgeni([ionicPackage]); var dgeni = new Dgeni([ionicPackage]);

View File

@ -8,7 +8,7 @@
"module": "es2015", "module": "es2015",
"moduleResolution": "node", "moduleResolution": "node",
"paths": { "paths": {
"@ionic-native/core": ["./dist/packages-dist/@ionic-native/core"] "@ionic-native/core": ["./dist/@ionic-native/core"]
}, },
"rootDir": ".", "rootDir": ".",
"target": "es5", "target": "es5",