diff --git a/package.json b/package.json index c1121480..c8b03cef 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "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:modules": "node scripts/build/build.js", - "clean": "rimraf dist", + "clean": "rimraf dist .tmp", "shipit": "npm run build && gulp readmes && npm run npmpub", "npmpub": "node scripts/build/publish.js", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0" diff --git a/scripts/build/build.js b/scripts/build/build.js index c919f2bd..7b986968 100644 --- a/scripts/build/build.js +++ b/scripts/build/build.js @@ -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_TS_CONFIG = require(path.resolve(__dirname, 'tsconfig-plugin.json')), // plugin tsconfig template 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_PLUGINS_DIST = path.resolve(BUILD_DIST_ROOT, 'plugins'), // plugins dist directory path + BUILD_DIST_ROOT = path.resolve(ROOT, 'dist/@ionic-native'), // dist directory root 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 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 console.log('Making new TMP directory'); fs.mkdirpSync(BUILD_TMP); @@ -79,7 +71,7 @@ const addPluginToQueue = pluginName => { let tsConfigPath; 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(() => { // Write tsconfig.json @@ -98,7 +90,7 @@ const addPluginToQueue = pluginName => { packageJson.name = `@ionic-native/${pluginName}`; 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(() => { diff --git a/scripts/build/publish.js b/scripts/build/publish.js index ab2675da..7dea1cca 100644 --- a/scripts/build/publish.js +++ b/scripts/build/publish.js @@ -7,51 +7,38 @@ const fs = require('fs-extra-promise').useFs(require('fs-extra')), const ROOT = path.resolve(path.join(__dirname, '../../')), - DIST = path.resolve(ROOT, 'dist', 'packages-dist', '@ionic-native'), - PLUGINS_ROOT = path.resolve(DIST, 'plugins'), - CORE = path.resolve(DIST, 'core'); + DIST = path.resolve(ROOT, 'dist', '@ionic-native'); const FLAGS = '--access public'; // add any flags here if you want... (example: --tag alpha) -console.log('Publishing @ionic-native/core'); -exec(`npm publish ${CORE} ${FLAGS}`) - .then(() => { +const PACKAGES = fs.readdirSync(DIST); - const PLUGINS = fs.readdirSync(PLUGINS_ROOT); - const QUEUE = queue({ - concurrency: 10 - }); +const QUEUE = queue({ + concurrency: 10 +}); - PLUGINS.forEach(pluginName => { +PACKAGES.forEach(packageName => { - QUEUE.push(done => { + QUEUE.push(done => { - console.log(`Publishing plugin ${pluginName}`); - const pluginPath = path.resolve(PLUGINS_ROOT, pluginName); - - exec(`npm publish ${pluginPath} ${FLAGS}`) - .then(() => 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); + console.log(`Publishing @ionic-native/${packageName}`); + const packagePath = path.resolve(DIST, packageName); + exec(`npm publish ${packagePath} ${FLAGS}`) + .then(() => done()) + .catch(done); }); + +}); + +QUEUE.start((err) => { + + if (err) { + console.log('Error publishing ionic-native. ', err); + } else { + console.log('Done publishing ionic-native!'); + } + +}); + diff --git a/scripts/build/tsconfig-core.json b/scripts/build/tsconfig-core.json index 7d9890ed..da5635f6 100644 --- a/scripts/build/tsconfig-core.json +++ b/scripts/build/tsconfig-core.json @@ -7,7 +7,7 @@ "emitDecoratorMetadata": true, "module": "es2015", "moduleResolution": "node", - "outDir": "../../dist/packages-dist/", + "outDir": "../../dist/", "rootDir": "../../src/", "target": "es5", "skipLibCheck": true, diff --git a/scripts/build/tsconfig-plugin.json b/scripts/build/tsconfig-plugin.json index 0de7d7fa..fba4e627 100644 --- a/scripts/build/tsconfig-plugin.json +++ b/scripts/build/tsconfig-plugin.json @@ -7,16 +7,14 @@ "emitDecoratorMetadata": true, "module": "es2015", "moduleResolution": "node", - "outDir": "../../../dist/packages-dist/", + "outDir": "../../../dist/@ionic-native/", "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", "skipLibCheck": true, "lib": ["es2015", "dom"] }, - "files": [ - "../../../src/@ionic-native/plugins/{{PLUGIN}}/index.ts" - ] + "files": [] } diff --git a/scripts/config.json b/scripts/config.json index 8b4b8a51..b39f8cb9 100644 --- a/scripts/config.json +++ b/scripts/config.json @@ -2,5 +2,5 @@ "sitePath": "../ionic-site", "v2DocsDir": "docs/v2/native", "docsDest": "../ionic-site/content/docs/v2/native", - "pluginDir": "dist/packages-dist/@ionic-native/plugins" + "pluginDir": "dist/@ionic-native" } diff --git a/scripts/docs/dgeni-readmes-config.js b/scripts/docs/dgeni-readmes-config.js index 77cbe300..13cd4957 100644 --- a/scripts/docs/dgeni-readmes-config.js +++ b/scripts/docs/dgeni-readmes-config.js @@ -17,162 +17,163 @@ module.exports = function(currentVersion) { return new Package('ionic-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage]) -// .processor(require('./processors/latest-version')) -.processor(require('./processors/readmes')) -.processor(require('./processors/npm-id')) -.processor(require('./processors/remove-private-members')) -.processor(require('./processors/hide-private-api')) -// .processor(require('./processors/collect-inputs-outputs')) + // .processor(require('./processors/latest-version')) + .processor(require('./processors/readmes')) + .processor(require('./processors/npm-id')) + .processor(require('./processors/remove-private-members')) + .processor(require('./processors/hide-private-api')) + // .processor(require('./processors/collect-inputs-outputs')) -// for debugging docs -// .processor(function test(){ -// return { -// -// $runBefore: ['rendering-docs'], -// $process: function(docs){ -// docs.forEach(function(doc){ -// if (doc.name == "Camera"){ -// -// // console.log(doc.tags); -// // doc.tags.forEach(function(tag){ -// // if(tag.tagName == 'classes'){ -// // -// // } -// // }); -// -// // doc.moduleDoc.exports.forEach(function(d,i){ -// // if(d.name === 'CameraOptions') { -// // console.log('Name: ' + d.name); -// // console.log('Type: ' + d.docType); -// // console.log('First member: ', d.members[0]); -// // } -// // }); -// -// -// // var exports = doc.exportSymbol.parent.exports; -// // for(var p in exports) { -// // if(p == 'CameraOptions') -// // { -// // var x = exports[p]; -// // console.log(x.members.quality); -// // } -// // } -// // doc.members.forEach(function(method){ -// // if (method.name === "getPicture") { -// // console.log(method); -// // } -// // }) -// } -// }) -// } -// } -// }) -.config(function(log) { - log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error' -}) + // for debugging docs + // .processor(function test(){ + // return { + // + // $runBefore: ['rendering-docs'], + // $process: function(docs){ + // docs.forEach(function(doc){ + // if (doc.name == "Camera"){ + // + // // console.log(doc.tags); + // // doc.tags.forEach(function(tag){ + // // if(tag.tagName == 'classes'){ + // // + // // } + // // }); + // + // // doc.moduleDoc.exports.forEach(function(d,i){ + // // if(d.name === 'CameraOptions') { + // // console.log('Name: ' + d.name); + // // console.log('Type: ' + d.docType); + // // console.log('First member: ', d.members[0]); + // // } + // // }); + // + // + // // var exports = doc.exportSymbol.parent.exports; + // // for(var p in exports) { + // // if(p == 'CameraOptions') + // // { + // // var x = exports[p]; + // // console.log(x.members.quality); + // // } + // // } + // // doc.members.forEach(function(method){ + // // if (method.name === "getPicture") { + // // console.log(method); + // // } + // // }) + // } + // }) + // } + // } + // }) + .config(function(log) { + log.level = 'error'; //'silly', 'debug', 'info', 'warn', 'error' + }) -.config(function(renderDocsProcessor, computePathsProcessor) { + .config(function(renderDocsProcessor, computePathsProcessor) { - versions = []; - // new version, add it to the versions list - if (currentVersion != 'nightly' && !_.includes(versions, currentVersion)) { - versions.unshift(currentVersion); - } - //First semver valid version is latest - var latestVersion = _.find(versions, semver.valid); - versions = versions.map(function(version) { - // We don't separate by versions so always put the docs in the root - var folder = ''; - return { - href: '/' + config.v2DocsDir.replace('content/', ''), - folder: folder, - name: version - }; - }); + versions = []; + // new version, add it to the versions list + if (currentVersion != 'nightly' && !_.includes(versions, currentVersion)) { + versions.unshift(currentVersion); + } + //First semver valid version is latest + var latestVersion = _.find(versions, semver.valid); + versions = versions.map(function(version) { + // We don't separate by versions so always put the docs in the root + var folder = ''; + return { + href: '/' + config.v2DocsDir.replace('content/', ''), + folder: folder, + name: version + }; + }); - var versionData = { - list: versions, - current: _.find(versions, {name: currentVersion}), - latest: _.find(versions, {name: latestVersion}) || _.first(versions) - }; + var versionData = { + list: versions, + current: _.find(versions, {name: currentVersion}), + latest: _.find(versions, {name: latestVersion}) || _.first(versions) + }; - renderDocsProcessor.extraData.version = versionData; - computePathsProcessor.pathTemplates = [{ - docTypes: ['class'], - getOutputPath: function(doc) { - return doc.originalModule.replace(config.pluginDir + '/', '') - .replace('/index', '') + '/README.md'; - } - }]; -}) + renderDocsProcessor.extraData.version = versionData; + computePathsProcessor.pathTemplates = [{ + docTypes: ['class'], + getOutputPath: function(doc) { + return doc.originalModule.replace(config.pluginDir + '/', '') + .replace('/plugins', '') + .replace('/index', '') + '/README.md'; + } + }]; + }) -//configure file reading -.config(function(readFilesProcessor, readTypeScriptModules) { + //configure file reading + .config(function(readFilesProcessor, readTypeScriptModules) { - // Don't run unwanted processors since we are not using the normal file reading processor - readFilesProcessor.$enabled = false; - readFilesProcessor.basePath = path.resolve(__dirname, '../..'); + // Don't run unwanted processors since we are not using the normal file reading processor + readFilesProcessor.$enabled = false; + readFilesProcessor.basePath = path.resolve(__dirname, '../..'); - readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../..')); - readTypeScriptModules.sourceFiles = ['./src/@ionic-native/plugins/**/*.ts']; -}) + readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../..')); + readTypeScriptModules.sourceFiles = ['./src/@ionic-native/plugins/**/*.ts']; + }) -.config(function(parseTagsProcessor) { - parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions - .concat(require('./tag-defs/tag-defs')); -}) + .config(function(parseTagsProcessor) { + parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions + .concat(require('./tag-defs/tag-defs')); + }) -// .config(function(parseTagsProcessor) { -// // We actually don't want to parse param docs in this package as we are -// // getting the data out using TS -// parseTagsProcessor.tagDefinitions.forEach(function(tagDef) { -// console.log(tagDef); -// if (tagDef.name === 'param') { -// tagDef.docProperty = 'paramData'; -// tagDef.transforms = []; -// } -// }); -// }) + // .config(function(parseTagsProcessor) { + // // We actually don't want to parse param docs in this package as we are + // // getting the data out using TS + // parseTagsProcessor.tagDefinitions.forEach(function(tagDef) { + // console.log(tagDef); + // if (tagDef.name === 'param') { + // tagDef.docProperty = 'paramData'; + // tagDef.transforms = []; + // } + // }); + // }) -// Configure links -.config(function(getLinkInfo) { - getLinkInfo.useFirstAmbiguousLink = false; -}) + // Configure links + .config(function(getLinkInfo) { + getLinkInfo.useFirstAmbiguousLink = false; + }) -// Configure file writing -.config(function(writeFilesProcessor) { - writeFilesProcessor.outputFolder = './dist/packages-dist/'; -}) + // Configure file writing + .config(function(writeFilesProcessor) { + writeFilesProcessor.outputFolder = './dist/'; + }) -// Configure rendering -.config(function(templateFinder, templateEngine) { + // Configure rendering + .config(function(templateFinder, templateEngine) { - // Nunjucks and Angular conflict in their template bindings so change the Nunjucks - // Also conflict with Jekyll - templateEngine.config.tags = { - variableStart: '<$', - variableEnd: '$>', - blockStart: '<@', - blockEnd: '@>', - commentStart: '<#', - commentEnd: '#>' - }; + // Nunjucks and Angular conflict in their template bindings so change the Nunjucks + // Also conflict with Jekyll + templateEngine.config.tags = { + variableStart: '<$', + variableEnd: '$>', + blockStart: '<@', + blockEnd: '@>', + commentStart: '<#', + commentEnd: '#>' + }; - // add custom filters to nunjucks - templateEngine.filters.push( - require('./filters/capital'), - require('./filters/code'), - require('./filters/dump') - ); + // add custom filters to nunjucks + templateEngine.filters.push( + require('./filters/capital'), + require('./filters/code'), + require('./filters/dump') + ); - templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates')); + templateFinder.templateFolders.unshift(path.resolve(__dirname, 'templates')); - // Specify how to match docs to templates. - templateFinder.templatePatterns = [ - '${ doc.template }', - '${ doc.docType }.template.md', - 'readme.template.md' - ]; -}); + // Specify how to match docs to templates. + templateFinder.templatePatterns = [ + '${ doc.template }', + '${ doc.docType }.template.md', + 'readme.template.md' + ]; + }); }; diff --git a/scripts/docs/gulp-tasks.js b/scripts/docs/gulp-tasks.js index 58a3a8a6..cf44602f 100644 --- a/scripts/docs/gulp-tasks.js +++ b/scripts/docs/gulp-tasks.js @@ -1,5 +1,8 @@ var config = require('../config.json'); var projectPackage = require('../../package.json'); +var path = require('path'); +var fs = require('fs-extra-promise').useFs(require('fs-extra')); + module.exports = function(gulp) { gulp.task('docs', [], function() { var Dgeni = require('dgeni'); @@ -18,6 +21,9 @@ module.exports = function(gulp) { gulp.task('readmes', [], function() { var Dgeni = require('dgeni'); var semver = require('semver'); + + fs.copySync(path.resolve(__dirname, '..', '..', 'README.md'), path.resolve(__dirname, '..', '..', config.pluginDir, 'core', 'README.md')); + try { var ionicPackage = require('./dgeni-readmes-config')(projectPackage.version); var dgeni = new Dgeni([ionicPackage]); diff --git a/tsconfig.json b/tsconfig.json index d5607c05..30a6d65e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "module": "es2015", "moduleResolution": "node", "paths": { - "@ionic-native/core": ["./dist/packages-dist/@ionic-native/core"] + "@ionic-native/core": ["./dist/@ionic-native/core"] }, "rootDir": ".", "target": "es5",