diff --git a/package.json b/package.json index 7414f1d41647..ac1a72a429a8 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,13 @@ "build": "node ./scripts/publish/build.js", "build:patch": "node ./scripts/patch.js", "build:packages": "for PKG in packages/*; do echo Building $PKG...; tsc -p $PKG; done", - "test": "npm-run-all -c test:packages test:cli", + "test": "npm-run-all -c test:packages test:cli test:deps", "e2e": "npm run test:e2e", "e2e:nightly": "node tests/e2e_runner.js --nightly", "mobile_test": "mocha tests/e2e/e2e_workflow.spec.js", "test:e2e": "node tests/e2e_runner.js", "test:cli": "node tests/runner", + "test:deps": "node scripts/publish/validate_dependencies.js", "test:inspect": "node --inspect --debug-brk tests/runner", "test:packages": "node scripts/run-packages-spec.js", "build-config-interface": "dtsgen packages/angular-cli/lib/config/schema.json --out packages/angular-cli/lib/config/schema.d.ts", @@ -51,7 +52,6 @@ "chalk": "^1.1.3", "common-tags": "^1.3.1", "configstore": "^2.0.0", - "core-js": "^2.4.0", "css-loader": "^0.23.1", "debug": "^2.1.3", "denodeify": "^1.2.1", @@ -73,19 +73,18 @@ "inquirer": "^0.12.0", "is-git-url": "^0.2.0", "isbinaryfile": "^2.0.3", - "istanbul-instrumenter-loader": "^0.2.0", "json-loader": "^0.5.4", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^1.8.0", "leek": "0.0.21", "less": "^2.7.1", "less-loader": "^2.2.3", + "loader-utils": "^0.2.16", "lodash": "^4.11.1", "magic-string": "^0.16.0", "markdown-it": "4.3.0", "markdown-it-terminal": "0.0.3", "minimatch": "^3.0.0", - "mkdirp": "^0.5.1", "node-modules-path": "^1.0.0", "node-sass": "^3.10.1", "nopt": "^3.0.1", @@ -93,11 +92,9 @@ "offline-plugin": "^3.4.1", "opn": "4.0.1", "ora": "^0.2.0", - "parse5": "^2.1.5", "portfinder": "1.0.9", "postcss-discard-comments": "^2.0.4", "postcss-loader": "^0.9.1", - "protractor": "^3.3.0", "quick-temp": "0.1.5", "raw-loader": "^0.5.1", "readline2": "0.1.1", @@ -106,7 +103,6 @@ "resolve": "^1.1.7", "rimraf": "^2.5.3", "rsvp": "^3.0.17", - "rxjs": "5.0.0-beta.12", "sass-loader": "^3.2.0", "script-loader": "^0.7.0", "semver": "^5.1.0", @@ -114,13 +110,11 @@ "source-map": "^0.5.6", "source-map-loader": "^0.1.5", "sourcemap-istanbul-instrumenter-loader": "^0.2.0", - "string-replace-loader": "^1.0.5", "style-loader": "^0.13.1", "stylus": "^0.54.5", "stylus-loader": "^2.1.0", "temp": "0.8.3", "through": "^2.3.6", - "ts-loader": "^0.8.2", "tslint": "^3.15.1", "tslint-loader": "^3.3.0", "typescript": "~2.0.3", @@ -131,8 +125,8 @@ "webpack-dev-server": "2.1.0-beta.9", "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", - "yam": "0.0.18", - "zone.js": "^0.6.23" + "webpack-sources": "^0.1.3", + "yam": "0.0.18" }, "ember-addon": { "paths": [ diff --git a/packages/@ngtools/webpack/package.json b/packages/@ngtools/webpack/package.json index 161cea5dd261..865b2a9863bb 100644 --- a/packages/@ngtools/webpack/package.json +++ b/packages/@ngtools/webpack/package.json @@ -25,14 +25,18 @@ "npm": ">= 3.0.0" }, "dependencies": { - "@angular-cli/ast-tools": "^1.0.0", + "enhanced-resolve": "^2.3.0", + "loader-utils": "^0.2.16", "magic-string": "^0.16.0", "source-map": "^0.5.6" }, "peerDependencies": { - "typescript": "^2.0.2", + "@angular/compiler": "2.2.3", "@angular/compiler-cli": "2.2.3", "@angular/core": "2.2.3", - "reflect-metadata": "^0.1.8" + "@angular/tsc-wrapped": "0.4.0", + "typescript": "^2.0.2", + "reflect-metadata": "^0.1.8", + "webpack": "^2.1.0-beta.25" } } diff --git a/packages/@ngtools/webpack/tsconfig.json b/packages/@ngtools/webpack/tsconfig.json index 44d39b25f634..2712fb19d82d 100644 --- a/packages/@ngtools/webpack/tsconfig.json +++ b/packages/@ngtools/webpack/tsconfig.json @@ -15,7 +15,6 @@ "sourceRoot": "/", "baseUrl": "./", "paths": { - "@angular-cli/ast-tools": [ "../../../dist/ast-tools/src" ] }, "typeRoots": [ "../../node_modules/@types" diff --git a/packages/angular-cli/blueprints/ng2/files/package.json b/packages/angular-cli/blueprints/ng2/files/package.json index 2d65e56e2cbf..1cadc809ac30 100644 --- a/packages/angular-cli/blueprints/ng2/files/package.json +++ b/packages/angular-cli/blueprints/ng2/files/package.json @@ -26,14 +26,7 @@ "ts-helpers": "^1.1.1", "zone.js": "^0.6.23" }, - "devDependencies": {<% if(isMobile) { %> - "@angular/platform-server": "2.2.3", - "@angular/service-worker": "0.2.0", - "@angular/app-shell": "0.0.0", - "angular2-universal":"0.104.5", - "angular2-universal-polyfills": "0.4.1", - "preboot": "2.1.2", - "parse5": "1.5.1",<% } %> + "devDependencies": { "@angular/compiler-cli": "2.2.3", "@types/jasmine": "2.5.38", "@types/node": "^6.0.42", diff --git a/packages/angular-cli/ember-cli/lib/cli/cli.js b/packages/angular-cli/ember-cli/lib/cli/cli.js index 4eb143364666..052fc7fc5b58 100644 --- a/packages/angular-cli/ember-cli/lib/cli/cli.js +++ b/packages/angular-cli/ember-cli/lib/cli/cli.js @@ -2,7 +2,6 @@ var lookupCommand = require('./lookup-command'); var Promise = require('../ext/promise'); -var UpdateChecker = require('../models/update-checker'); var getOptionArgs = require('../utilities/get-option-args'); var debug = require('debug')('ember-cli:cli'); var debugTesting = require('debug')('ember-cli:testing'); @@ -66,11 +65,6 @@ CLI.prototype.run = function(environment) { debug('command: %s', commandName); - if (commandName !== 'update' && !this.testing) { - var a = new UpdateChecker(this.ui, environment.settings); - update = a.checkForUpdates(); - } - if (!this.testing) { process.chdir(environment.project.root); var skipInstallationCheck = commandArgs.indexOf('--skip-installation-check') !== -1; diff --git a/packages/angular-cli/ember-cli/lib/models/addon.js b/packages/angular-cli/ember-cli/lib/models/addon.js index 9a3f718b777f..f0dc2b504f3a 100644 --- a/packages/angular-cli/ember-cli/lib/models/addon.js +++ b/packages/angular-cli/ember-cli/lib/models/addon.js @@ -22,8 +22,6 @@ var AddonsFactory = require('../models/addons-factory'); var CoreObject = require('../ext/core-object'); var Project = require('./project'); -// var upstreamMergeTrees = require('broccoli-merge-trees'); -// var Funnel = require('broccoli-funnel'); var walkSync = require('walk-sync'); @@ -111,7 +109,6 @@ Addon.prototype._requireBuildPackages = function() { } this.transpileModules = deprecatedAddonFilters(this, 'this.transpileModules', 'broccoli-es6modules', function(tree, options) { - return new (require('broccoli-es6modules'))(tree, options); }); this.pickFiles = deprecatedAddonFilters(this, 'this.pickFiles', 'broccoli-funnel', function(tree, options) { @@ -123,7 +120,6 @@ Addon.prototype._requireBuildPackages = function() { return new Funnel(tree, options); }); - // this.mergeTrees = deprecatedAddonFilters(this, 'this.mergeTrees', 'broccoli-merge-trees', mergeTrees); this.walkSync = deprecatedAddonFilters(this, 'this.walkSync', 'node-walk-sync', walkSync); }; @@ -152,8 +148,6 @@ function deprecatedAddonFilters(addon, name, insteadUse, fn) { @return {tree} Modified tree */ Addon.prototype.concatFiles = function(tree, options) { - options.sourceMapConfig = this.app.options.sourcemaps; - return require('broccoli-concat')(tree, options); }; /** diff --git a/packages/angular-cli/ember-cli/lib/models/update-checker.js b/packages/angular-cli/ember-cli/lib/models/update-checker.js deleted file mode 100644 index 2fa371c075b4..000000000000 --- a/packages/angular-cli/ember-cli/lib/models/update-checker.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -var Promise = require('../ext/promise'); -var versionUtils = require('../utilities/version-utils'); -var chalk = require('chalk'); -var debug = require('debug')('ember-cli:update-checker'); -var emberCLIVersion = versionUtils.emberCLIVersion; - -module.exports = UpdateChecker; - -function UpdateChecker(ui, settings, localVersion) { - this.ui = ui; - this.settings = settings; - this.localVersion = localVersion || emberCLIVersion(); - this.versionConfig = null; - - debug('version: %s', this.localVersion); - debug('version: %o', this.settings); -} - -/** -* Checks local config or npm for most recent version of ember-cli -*/ -UpdateChecker.prototype.checkForUpdates = function() { - // if 'checkForUpdates' is true, check for an updated ember-cli version - debug('checkingcheckForUpdates: %o', this.settings.checkingcheckForUpdates); - if (this.settings.checkForUpdates) { - return this.doCheck().then(function(updateInfo) { - debug('updatedNeeded %o', updateInfo.updateNeeded); - if (updateInfo.updateNeeded) { - this.ui.writeLine(''); - this.ui.writeLine('A new version of ember-cli is available (' + - updateInfo.newestVersion + ').'); - } - return updateInfo; - }.bind(this)); - } else { - return Promise.resolve({ - updateNeeded: false - }); - } -}; - -UpdateChecker.prototype.doCheck = function() { - this.versionConfig = this.versionConfig || new (require('configstore'))('ember-cli-version'); - var lastVersionCheckAt = this.versionConfig.get('lastVersionCheckAt'); - var now = new Date().getTime(); - - return new Promise(function(resolve, reject) { - // if the last check was less than a day ago, don't remotely check version - if (lastVersionCheckAt && lastVersionCheckAt > (now - 86400000)) { - resolve(this.versionConfig.get('newestVersion')); - } - - reject(); - }.bind(this)).catch(function() { - return this.checkNPM(); - }.bind(this)).then(function(version) { - var isDevBuild = versionUtils.isDevelopment(this.localVersion); - var updateNeeded = false; - - if (!isDevBuild) { - updateNeeded = version && require('semver').lt(this.localVersion, version); - } - - return { - updateNeeded: updateNeeded, - newestVersion: version - }; - }.bind(this)); -}; - -UpdateChecker.prototype.checkNPM = function() { - // use npm to determine the currently availabe ember-cli version - var loadNPM = Promise.denodeify(require('npm').load); - var fetchEmberCliVersion = function(npm) { - return Promise.denodeify(npm.commands.view)(['ember-cli', 'version']); - }; - var extractVersion = function(data) { return Object.keys(data)[0]; }; - - return loadNPM({ - 'loglevel': 'silent', - 'fetch-retries': 1, - 'cache-min': 1, - 'cache-max': 0 - }) - .then(fetchEmberCliVersion) - .then(extractVersion) - .then(this.saveVersionInformation.bind(this)) - .catch(function() { - this.ui.writeLine(chalk.red('An error occurred while checking for Ember CLI updates. ' + - 'Please verify your internet connectivity and npm configurations.')); - return false; - }.bind(this)); -}; - -UpdateChecker.prototype.saveVersionInformation = function(version) { - var versionConfig = this.versionConfig; - var now = new Date().getTime(); - - // save version so we don't have to check again for another day - versionConfig.set('newestVersion', version); - versionConfig.set('lastVersionCheckAt', now); -}; diff --git a/packages/angular-cli/ember-cli/lib/models/watcher.js b/packages/angular-cli/ember-cli/lib/models/watcher.js index edee470d9a20..16daec0a53fe 100644 --- a/packages/angular-cli/ember-cli/lib/models/watcher.js +++ b/packages/angular-cli/ember-cli/lib/models/watcher.js @@ -14,11 +14,6 @@ var Watcher = Task.extend({ var options = this.buildOptions(); debug('initialize %o', options); - - this.watcher = this.watcher || new (require('broccoli-sane-watcher'))(this.builder, options); - - this.watcher.on('error', this.didError.bind(this)); - this.watcher.on('change', this.didChange.bind(this)); }, didError: function(error) { @@ -30,7 +25,7 @@ var Watcher = Task.extend({ }, then: function() { - return this.watcher.then.apply(this.watcher, arguments); + // return this.watcher.then.apply(this.watcher, arguments); }, didChange: function(results) { @@ -54,11 +49,11 @@ var Watcher = Task.extend({ }, on: function() { - this.watcher.on.apply(this.watcher, arguments); + // this.watcher.on.apply(this.watcher, arguments); }, off: function() { - this.watcher.off.apply(this.watcher, arguments); + // this.watcher.off.apply(this.watcher, arguments); }, buildOptions: function() { var watcher = this.options && this.options.watcher; diff --git a/packages/angular-cli/ember-cli/lib/tasks.js b/packages/angular-cli/ember-cli/lib/tasks.js index d8016a453791..efb5b22acbaf 100644 --- a/packages/angular-cli/ember-cli/lib/tasks.js +++ b/packages/angular-cli/ember-cli/lib/tasks.js @@ -8,5 +8,4 @@ module.exports = { NpmInstall: require('./tasks/npm-install'), NpmTask: require('./tasks/npm-task'), NpmUninstall: require('./tasks/npm-uninstall'), - Update: require('./tasks/update') }; diff --git a/packages/angular-cli/ember-cli/lib/tasks/update.js b/packages/angular-cli/ember-cli/lib/tasks/update.js deleted file mode 100644 index df64550200ae..000000000000 --- a/packages/angular-cli/ember-cli/lib/tasks/update.js +++ /dev/null @@ -1,118 +0,0 @@ -'use strict'; - -var Promise = require('../ext/promise'); -var chalk = require('chalk'); -var Task = require('../models/task'); -var fs = require('fs'); -var path = require('path'); - -function npmInstall(npm) { - return Promise.denodeify(npm.commands.install)(['ember-cli']); -} - -module.exports = Task.extend({ - init: function() { - this.npm = this.npm || require('npm'); - }, - - run: function(options, updateInfo) { - var env = options.environment || 'development'; - - process.env.EMBER_ENV = process.env.EMBER_ENV || env; - - this.ui.writeLine(''); - this.ui.writeLine(chalk.yellow('A new version of ember-cli is available (' + - updateInfo.newestVersion + ').')); - - var updatePrompt = { - type: 'confirm', - name: 'answer', - message: 'Are you sure you want to update ember-cli?', - choices: [ - { key: 'y', name: 'Yes, update', value: 'yes' }, - { key: 'n', name: 'No, cancel', value: 'no' } - ] - }; - - return this.ui.prompt(updatePrompt).then(function(response) { - if (response.answer === true) { - return this.runNpmUpdate(updateInfo.newestVersion); - } - }.bind(this)); - }, - - runNpmUpdate: function(newestVersion) { - this.ui.startProgress(chalk.green('Updating ember-cli'), chalk.green('.')); - - // first, run `npm install -g ember-cli` - var npm = this.npm; - var loadNPM = Promise.denodeify(npm.load); - - var stopProgress = (function() { - this.ui.stopProgress(); - }.bind(this)); - - var reportFailure = (function(reason) { - this.ui.writeLine('There was an error – possibly a permissions issue. You ' + - 'may need to manually run ' + - chalk.green('npm install -g ember-cli') + '.'); - throw reason; - }.bind(this)); - - var updateDependencies = (function() { - var pkg = this.project.pkg; - var packagePath = path.join(this.project.root, 'package.json'); - - if (!pkg) { - this.ui.write('There was an error locating your package.json file.'); - return false; - } - - pkg.devDependencies['ember-cli'] = newestVersion; - fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2)); - this.ui.writeLine(''); - this.ui.writeLine(chalk.green('✓ ember-cli was successfully updated!')); - - return this.showEmberInitPrompt(); - }.bind(this)); - - return loadNPM({ - loglevel: 'silent', - global: true - }) - .then(npmInstall) - .then(updateDependencies) - .catch(reportFailure) - .finally(stopProgress); - }, - - showEmberInitPrompt: function() { - this.ui.writeLine('To complete the update, you need to run ' + - chalk.green('ember init') + ' in your project directory.'); - - var initPrompt = { - type: 'confirm', - name: 'answer', - message: 'Would you like to run ' + chalk.green('ember init') + ' now?', - choices: [ - { key: 'y', name: 'Yes', value: 'yes' }, - { key: 'n', name: 'No', value: 'no' } - ] - }; - - return this.ui.prompt(initPrompt).then(function(response) { - if (response.answer === true) { - var InitCommand = this.commands.Init; - - var initCommand = new InitCommand({ - ui: this.ui, - analytics: this.analytics, - tasks: this.tasks, - project: this.project - }); - - return initCommand.run({}, []); - } - }.bind(this)); - } -}); diff --git a/packages/angular-cli/ember-cli/lib/utilities/npm.js b/packages/angular-cli/ember-cli/lib/utilities/npm.js deleted file mode 100644 index a5be7e82466b..000000000000 --- a/packages/angular-cli/ember-cli/lib/utilities/npm.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var Promise = require('../ext/promise'); - -// - -/** - Runs the npm command `command` with the supplied args and load options. - - Please note that the loaded module appears to retain some state, so do not - expect multiple invocations within the same process to work without quirks. - This problem is likely fixable. - - @method npm - @param {String} command The npm command to run. - @param {Array} npmArgs The arguments passed to the npm command. - @param {Array} options The options passed when loading npm. - @param {Module} [npm] A reference to the npm module. -*/ -module.exports = function npm(command, npmArgs, options/*, npm*/) { - var lib; - if (arguments.length === 4) { - lib = arguments[3]; - } else { - lib = require('npm'); - } - - var load = Promise.denodeify(lib.load); - - return load(options) - .then(function() { - // if install is denodeified outside load.then(), - // it throws "Call npm.load(config, cb) before using this command." - var operation = Promise.denodeify(lib.commands[command]); - - return operation(npmArgs || []); - }); -}; diff --git a/packages/angular-cli/lib/cli/index.js b/packages/angular-cli/lib/cli/index.js index c94d8af20601..9c0eebed47ab 100644 --- a/packages/angular-cli/lib/cli/index.js +++ b/packages/angular-cli/lib/cli/index.js @@ -20,26 +20,6 @@ module.exports = function(options) { return Promise.resolve(options); } - const oldStdoutWrite = process.stdout.write; - process.stdout.write = function (line) { - line = line.toString(); - if (line.match(/ember-cli-(inject-)?live-reload/)) { - // don't replace 'ember-cli-live-reload' on ng init diffs - return oldStdoutWrite.apply(process.stdout, arguments); - } - line = line.replace(/ember-cli(?!.com)/g, 'angular-cli') - .replace(/\bember\b(?!-cli.com)/g, 'ng'); - return oldStdoutWrite.apply(process.stdout, arguments); - }; - - const oldStderrWrite = process.stderr.write; - process.stderr.write = function (line) { - line = line.toString() - .replace(/ember-cli(?!.com)/g, 'angular-cli') - .replace(/\bember\b(?!-cli.com)/g, 'ng'); - return oldStderrWrite.apply(process.stdout, arguments); - }; - options.cli = { name: 'ng', root: path.join(__dirname, '..', '..'), diff --git a/packages/angular-cli/models/webpack-build-common.ts b/packages/angular-cli/models/webpack-build-common.ts index fe75b1561c35..a226f7ef051d 100644 --- a/packages/angular-cli/models/webpack-build-common.ts +++ b/packages/angular-cli/models/webpack-build-common.ts @@ -6,6 +6,28 @@ import {BaseHrefWebpackPlugin} from '@angular-cli/base-href-webpack'; const ProgressPlugin = require('webpack/lib/ProgressPlugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const SilentError = require('silent-error'); + +/** + * Enumerate loaders and their dependencies from this file to let the dependency validator + * know they are used. + * + * require('source-map-loader') + * require('raw-loader') + * require('postcss-loader') + * require('stylus-loader') + * require('less-loader') + * require('sass-loader') + * require('script-loader') + * require('json-loader') + * require('url-loader') + * require('file-loader') + * + * require('node-sass') + * require('less') + * require('stylus') + */ + export function getWebpackCommonConfig( projectRoot: string, @@ -33,6 +55,10 @@ export function getWebpackCommonConfig( main: [appMain] }; + if (!(environment in appConfig.environments)) { + throw new SilentError(`Environment "${environment}" does not exist.`); + } + // Only add styles/scripts if there's actually entries there if (appConfig.styles.length > 0) { entry['styles'] = styles; } if (appConfig.scripts.length > 0) { entry['scripts'] = scripts; } diff --git a/packages/angular-cli/models/webpack-build-development.ts b/packages/angular-cli/models/webpack-build-development.ts index d38748abdf2a..cb0229af6066 100644 --- a/packages/angular-cli/models/webpack-build-development.ts +++ b/packages/angular-cli/models/webpack-build-development.ts @@ -1,5 +1,16 @@ const path = require('path'); +/** + * Enumerate loaders and their dependencies from this file to let the dependency validator + * know they are used. + * + * require('style-loader') + * require('css-loader') + * require('stylus-loader') + * require('less-loader') + * require('sass-loader') + */ + export const getWebpackDevConfigPartial = function(projectRoot: string, appConfig: any) { const appRoot = path.resolve(projectRoot, appConfig.root); const styles = appConfig.styles diff --git a/packages/angular-cli/models/webpack-build-test.js b/packages/angular-cli/models/webpack-build-test.js index a82057506a8c..edc93a0105e7 100644 --- a/packages/angular-cli/models/webpack-build-test.js +++ b/packages/angular-cli/models/webpack-build-test.js @@ -12,6 +12,20 @@ const webpackLoader = g['angularCliIsLocal'] const ProgressPlugin = require('webpack/lib/ProgressPlugin'); + +/** + * Enumerate loaders and their dependencies from this file to let the dependency validator + * know they are used. + * + * require('tslint-loader') + * require('source-map-loader') + * require('sourcemap-istanbul-instrumenter-loader') + * + * require('remap-istanbul') + * require('tslint') + */ + + const getWebpackTestConfig = function (projectRoot, environment, appConfig, testConfig) { const appRoot = path.resolve(projectRoot, appConfig.root); diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index bc0d76ec0e5d..84c6909bfa7f 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -31,12 +31,11 @@ "@angular/compiler-cli": "2.2.3", "@angular/core": "2.2.3", "@ngtools/webpack": "^1.0.0", - "angular2-template-loader": "^0.5.0", "async": "^2.1.4", + "autoprefixer": "^6.5.3", "chalk": "^1.1.3", "common-tags": "^1.3.1", "configstore": "^2.0.0", - "core-js": "^2.4.0", "css-loader": "^0.23.1", "debug": "^2.1.3", "denodeify": "^1.2.1", @@ -44,7 +43,6 @@ "ember-cli-normalize-entity-name": "^1.0.0", "ember-cli-preprocess-registry": "^2.0.0", "ember-cli-string-utils": "^1.0.0", - "enhanced-resolve": "^2.3.0", "exists-sync": "0.0.3", "extract-text-webpack-plugin": "^2.0.0-beta.4", "file-loader": "^0.8.5", @@ -58,7 +56,6 @@ "inquirer": "^0.12.0", "is-git-url": "^0.2.0", "isbinaryfile": "^2.0.3", - "istanbul-instrumenter-loader": "^0.2.0", "json-loader": "^0.5.4", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^1.8.0", @@ -69,40 +66,33 @@ "markdown-it": "4.3.0", "markdown-it-terminal": "0.0.3", "minimatch": "^3.0.0", - "mkdirp": "^0.5.1", "node-modules-path": "^1.0.0", "node-sass": "^3.10.1", "nopt": "^3.0.1", - "npm-run-all": "^3.0.0", "offline-plugin": "^3.4.1", "opn": "4.0.1", "ora": "^0.2.0", - "parse5": "^2.1.5", "portfinder": "1.0.9", + "postcss-discard-comments": "^2.0.4", "postcss-loader": "^0.9.1", - "protractor": "^3.3.0", "quick-temp": "0.1.5", "raw-loader": "^0.5.1", "readline2": "0.1.1", - "reflect-metadata": "^0.1.8", "remap-istanbul": "^0.6.4", "resolve": "^1.1.7", "rimraf": "^2.5.3", "rsvp": "^3.0.17", - "rxjs": "5.0.0-beta.12", "sass-loader": "^3.2.0", "script-loader": "^0.7.0", "semver": "^5.1.0", "silent-error": "^1.0.0", "source-map-loader": "^0.1.5", "sourcemap-istanbul-instrumenter-loader": "^0.2.0", - "string-replace-loader": "^1.0.3", "style-loader": "^0.13.1", "stylus": "^0.54.5", "stylus-loader": "^2.1.0", "temp": "0.8.3", "through": "^2.3.6", - "ts-loader": "^0.8.2", "tslint": "^3.15.1", "tslint-loader": "^2.1.4", "typescript": "~2.0.3", @@ -113,8 +103,8 @@ "webpack-dev-server": "2.1.0-beta.9", "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0", - "yam": "0.0.18", - "zone.js": "^0.6.23" + "webpack-sources": "^0.1.3", + "yam": "0.0.18" }, "ember-addon": { "paths": [ diff --git a/scripts/publish/build.js b/scripts/publish/build.js index c617c3efccdc..898fb97a8cd9 100755 --- a/scripts/publish/build.js +++ b/scripts/publish/build.js @@ -1,7 +1,7 @@ #!/usr/bin/env node 'use strict'; -/*eslint-disable no-console */ +/* eslint-disable no-console */ const chalk = require('chalk'); const denodeify = require('denodeify'); const fs = require('fs'); diff --git a/scripts/publish/validate_dependencies.js b/scripts/publish/validate_dependencies.js new file mode 100644 index 000000000000..80e22adab645 --- /dev/null +++ b/scripts/publish/validate_dependencies.js @@ -0,0 +1,125 @@ +#!/usr/bin/env node +'use strict'; + +/* eslint-disable no-console */ +const chalk = require('chalk'); +const fs = require('fs'); +const glob = require('glob'); +const packages = require('../../lib/packages'); +const path = require('path'); + + +const IMPORT_RE = /(^|\n)\s*import\b(?:.|\n)*?\'[^\']*\'/g; +const REQUIRE_RE = /\brequire\('[^)]+?'\)/g; +const NODE_PACKAGES = [ + 'child_process', + 'fs', + 'https', + 'os', + 'path', + 'process', + 'url', + 'vm', + 'zlib' +]; +const ANGULAR_PACKAGES = [ + '@angular/compiler', + '@angular/compiler-cli', + '@angular/core' +]; + + +function listImportedModules(source) { + const imports = source.match(IMPORT_RE); + + return (imports || []) + .map(match => { + const m = match.match(/'(.*)'/); + return m && m[1]; + }) + .filter(x => !!x) + .filter(modulePath => modulePath[0] != '.') + .map(fullImportPath => { + if (fullImportPath[0] == '@') { + // Need to get the scope as well. + return fullImportPath.split('/').slice(0, 2).join('/'); + } else { + return fullImportPath.split('/')[0]; + } + }); +} + +function listRequiredModules(source) { + const requires = source.match(REQUIRE_RE); + + return (requires || []) + .map(match => { + const m = match.match(/'([^']*)'/); + return m && m[1]; + }) + .filter(x => !!x) + .filter(modulePath => modulePath[0] != '.') + .map(fullImportPath => { + if (fullImportPath[0] == '@') { + // Need to get the scope as well. + return fullImportPath.split('/').slice(0, 2).join('/'); + } else { + return fullImportPath.split('/')[0]; + } + }); +} + + +let exitCode = 0; +for (const packageName of Object.keys(packages)) { + console.log(chalk.green(`Reading dependencies of "${packageName}".`)); + + const allSources = glob.sync(path.join(__dirname, '../../packages/', packageName, '**/*')) + .filter(p => p.match(/\.(js|ts)$/)) + .filter(p => !p.match(/\.spec\./)) + .filter(p => !p.match(/\/blueprints\//)); + + const importMap = {}; + allSources.forEach(function(filePath) { + const source = fs.readFileSync(filePath, 'utf8'); + + listImportedModules(source) + .forEach(modulePath => importMap[modulePath] = true); + listRequiredModules(source) + .forEach(modulePath => importMap[modulePath] = true); + }); + + const dependencies = Object.keys(importMap) + // Filter out the node packages that should not be depended on. + .filter(x => NODE_PACKAGES.indexOf(x) == -1); + + console.log(chalk.green(` found ${dependencies.length} dependencies...`)); + const packageJson = JSON.parse(fs.readFileSync(packages[packageName].packageJson, 'utf8')); + const allDeps = [] + .concat(Object.keys(packageJson['dependencies'] || {})) + .concat(Object.keys(packageJson['devDependencies'] || {})) + .concat(Object.keys(packageJson['peerDependencies'] || {})); + + const missingDeps = dependencies.filter(d => allDeps.indexOf(d) == -1); + if (missingDeps.length == 0) { + console.log(chalk.green(' no dependency missing from package.json.')); + } else { + console.log(chalk.yellow(` ${missingDeps.length} missing from package.json:`)); + missingDeps.forEach(md => console.log(` ${md}`)); + exitCode = 1; + } + + const overDeps = allDeps.filter(d => dependencies.indexOf(d) == -1) + .filter(x => ANGULAR_PACKAGES.indexOf(x) == -1); + if (overDeps.length == 0) { + console.log(chalk.green(' no excessive dependencies in package.json.')); + } else { + console.log(chalk.yellow(` ${overDeps.length} excessive dependencies in package.json:`)); + overDeps.forEach(md => console.log(` ${md}`)); + exitCode = 1; + } + + console.log(''); +} + +process.exit(exitCode);