diff --git a/addon/ng2/blueprints/ng2/files/README.md b/addon/ng2/blueprints/ng2/files/README.md index 33838bbe3127..79c75dd19e76 100755 --- a/addon/ng2/blueprints/ng2/files/README.md +++ b/addon/ng2/blueprints/ng2/files/README.md @@ -7,7 +7,7 @@ Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app w ## Code scaffolding -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/route/class`. +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class`. ## Build diff --git a/addon/ng2/blueprints/ng2/files/__path__/app/environments/environment.ts b/addon/ng2/blueprints/ng2/files/__path__/app/environments/environment.ts index 79ee96fdfdbd..e63359828bb1 100644 --- a/addon/ng2/blueprints/ng2/files/__path__/app/environments/environment.ts +++ b/addon/ng2/blueprints/ng2/files/__path__/app/environments/environment.ts @@ -1,5 +1,5 @@ // The file for the current environment will overwrite this one during build -// Different environments can be found in config/environment.{dev|prod}.ts +// Different environments can be found in ./environment.{dev|prod}.ts // The build system defaults to the dev environment export const environment = { diff --git a/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json b/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json index 5acc3c417061..538b19d67754 100644 --- a/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json +++ b/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json @@ -4,13 +4,11 @@ "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, + "mapRoot": "./", "module": "es6", "moduleResolution": "node", - "outDir": "./dist/", - "rootDir": ".", "sourceMap": true, - "target": "es5", - "mapRoot": "/" + "target": "es5" }, "compileOnSave": false, "buildOnSave": false, diff --git a/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json b/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json index 93a6038f60b4..eb5d88ecd0bc 100644 --- a/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json +++ b/addon/ng2/blueprints/ng2/files/e2e/tsconfig.json @@ -6,9 +6,6 @@ "experimentalDecorators": true, "module": "commonjs", "moduleResolution": "node", - "noEmitOnError": true, - "noImplicitAny": false, - "rootDir": ".", "sourceMap": true, "target": "es5" } diff --git a/addon/ng2/commands/build.ts b/addon/ng2/commands/build.ts index 1fe80828d0af..d564de57362b 100644 --- a/addon/ng2/commands/build.ts +++ b/addon/ng2/commands/build.ts @@ -1,6 +1,6 @@ -const Command = require('ember-cli/lib/models/command'); -const WebpackBuild = require('../tasks/build-webpack'); -const WebpackBuildWatch = require('../tasks/build-webpack-watch'); +import * as Command from 'ember-cli/lib/models/command'; +import * as WebpackBuild from '../tasks/build-webpack'; +import * as WebpackBuildWatch from '../tasks/build-webpack-watch'; interface BuildOptions { environment?: string; diff --git a/addon/ng2/commands/serve.ts b/addon/ng2/commands/serve.ts index 396e167a56ce..b800af766f3f 100644 --- a/addon/ng2/commands/serve.ts +++ b/addon/ng2/commands/serve.ts @@ -1,9 +1,10 @@ -const assign = require('lodash/assign'); -const Command = require('ember-cli/lib/models/command'); -const Promise = require('ember-cli/lib/ext/promise'); -const SilentError = require('silent-error'); -const PortFinder = require('portfinder'); -const EOL = require('os').EOL; +import * as assign from 'lodash/assign'; +import * as Command from 'ember-cli/lib/models/command'; +import * as Promise from 'ember-cli/lib/ext/promise'; +import * as SilentError from 'silent-error'; +import * as PortFinder from 'portfinder'; +import * as EOL from 'os'; +import * as ServeWebpackTask from '../tasks/serve-webpack.ts'; PortFinder.basePort = 49152; @@ -53,7 +54,6 @@ module.exports = Command.extend({ run: function(commandOptions: ServeTaskOptions) { - commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host; return this._checkExpressPort(commandOptions) @@ -71,8 +71,6 @@ module.exports = Command.extend({ } } - const ServeWebpackTask = (require('../tasks/serve-webpack.ts')) - var serve = new ServeWebpackTask({ ui: this.ui, analytics: this.analytics, diff --git a/addon/ng2/commands/test.js b/addon/ng2/commands/test.ts similarity index 83% rename from addon/ng2/commands/test.js rename to addon/ng2/commands/test.ts index e94af33be298..5d62c7ba486f 100644 --- a/addon/ng2/commands/test.js +++ b/addon/ng2/commands/test.ts @@ -1,8 +1,6 @@ -'use strict'; - -const TestCommand = require('ember-cli/lib/commands/test'); -const config = require('../models/config'); -const TestTask = require('../tasks/test'); +import * as TestCommand from 'ember-cli/lib/commands/test'; +import * as config from '../models/config'; +import * as TestTask from '../tasks/test'; module.exports = TestCommand.extend({ availableOptions: [ @@ -27,7 +25,7 @@ module.exports = TestCommand.extend({ if (!commandOptions.watch) { // if not watching ensure karma is doing a single run commandOptions.singleRun = true; - } + } return testTask.run(commandOptions); } }); diff --git a/addon/ng2/models/config.ts b/addon/ng2/models/config.ts index e37ea8b760ef..8b41a2e2dc49 100644 --- a/addon/ng2/models/config.ts +++ b/addon/ng2/models/config.ts @@ -7,7 +7,6 @@ const schema = require(schemaPath); export const CLI_CONFIG_FILE_NAME = 'angular-cli.json'; export const ARRAY_METHODS = ['push', 'splice', 'sort', 'reverse', 'pop', 'shift']; - function _findUp(name: string, from: string) { let currentDir = from; while (currentDir && currentDir !== path.parse(currentDir).root) { diff --git a/addon/ng2/models/webpack-build-common.ts b/addon/ng2/models/webpack-build-common.ts index 4d3e5ca27513..dd184195cac1 100644 --- a/addon/ng2/models/webpack-build-common.ts +++ b/addon/ng2/models/webpack-build-common.ts @@ -1,12 +1,11 @@ +import * as path from 'path'; +import * as CopyWebpackPlugin from 'copy-webpack-plugin'; +import * as HtmlWebpackPlugin from 'html-webpack-plugin'; import * as webpack from 'webpack'; -import {LoaderConfig, PathsPlugin} from '../utilities/ts-path-mappings-webpack-plugin'; +import { ForkCheckerPlugin } from 'awesome-typescript-loader'; +import { LoaderConfig, PathsPlugin } from '../utilities/ts-path-mappings-webpack-plugin'; import { CliConfig } from './config'; -const path = require('path'); -const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); - export function getWebpackCommonConfig(projectRoot: string, sourceDir: string) { const awesomeTypescriptLoaderConfig: LoaderConfig | any = { useWebpackText: true, diff --git a/addon/ng2/models/webpack-build-production.ts b/addon/ng2/models/webpack-build-production.ts index 391f22805fb2..af0bfe8bb055 100644 --- a/addon/ng2/models/webpack-build-production.ts +++ b/addon/ng2/models/webpack-build-production.ts @@ -1,11 +1,10 @@ +import * as path from 'path'; +import * as webpackMerge from 'webpack-merge'; // used to merge webpack configs +import * as WebpackMd5Hash from 'webpack-md5-hash'; +import * as CompressionPlugin from 'compression-webpack-plugin'; import * as webpack from 'webpack'; import { CliConfig } from './config'; -const path = require('path'); -const webpackMerge = require('webpack-merge'); // used to merge webpack configs -const WebpackMd5Hash = require('webpack-md5-hash'); -const CompressionPlugin = require("compression-webpack-plugin"); - export const getWebpackProdConfigPartial = function(projectRoot: string, sourceDir: string) { return { debug: false, @@ -27,8 +26,8 @@ export const getWebpackProdConfigPartial = function(projectRoot: string, sourceD comments: false //prod }), new CompressionPlugin({ - asset: "[path].gz[query]", - algorithm: "gzip", + asset: '[path].gz[query]', + algorithm: 'gzip', test: /\.js$|\.html$/, threshold: 10240, minRatio: 0.8 diff --git a/addon/ng2/models/webpack-build-test.ts b/addon/ng2/models/webpack-build-test.ts index 42ee2bf45dbc..7c63e6e2299a 100644 --- a/addon/ng2/models/webpack-build-test.ts +++ b/addon/ng2/models/webpack-build-test.ts @@ -1,8 +1,7 @@ import * as webpack from 'webpack'; +import * as path from 'path'; import { CliConfig } from './config'; -const path = require('path'); - export const getWebpackTestConfig = function(projectRoot: string, sourceDir: string) { return { devtool: 'inline-source-map', diff --git a/addon/ng2/models/webpack-build-utils.ts b/addon/ng2/models/webpack-build-utils.ts index 572567d1e638..dcaa15558593 100644 --- a/addon/ng2/models/webpack-build-utils.ts +++ b/addon/ng2/models/webpack-build-utils.ts @@ -1,4 +1,4 @@ -const path = require('path'); +import * as path from 'path'; export const ngAppResolve = (resolvePath: string): string => { return path.resolve(process.cwd(), resolvePath); diff --git a/addon/ng2/models/webpack-config.ts b/addon/ng2/models/webpack-config.ts index 5dc9541bb333..f4d9beeedf6a 100644 --- a/addon/ng2/models/webpack-config.ts +++ b/addon/ng2/models/webpack-config.ts @@ -1,3 +1,5 @@ +import * as path from 'path'; +import * as webpackMerge from 'webpack-merge'; import { CliConfig } from './config'; import { NgCliEnvironmentPlugin } from '../utilities/environment-plugin'; import { @@ -8,9 +10,6 @@ import { getWebpackMobileProdConfigPartial } from './'; -const webpackMerge = require('webpack-merge'); -const path = require('path'); - export class NgCliWebpackConfig { // TODO: When webpack2 types are finished lets replace all these any types // so this is more maintainable in the future for devs @@ -58,7 +57,7 @@ export class NgCliWebpackConfig { default: //TODO: Not sure what to put here. We have a default env passed anyways. - this.ngCliProject.ui.writeLine("Envrionment could not be determined while configuring your build system.", 3) + this.ngCliProject.ui.writeLine("Environment could not be determined while configuring your build system.", 3) break; } } diff --git a/addon/ng2/tasks/build-watch.ts b/addon/ng2/tasks/build-watch.ts deleted file mode 100644 index d816d47a3fe2..000000000000 --- a/addon/ng2/tasks/build-watch.ts +++ /dev/null @@ -1,30 +0,0 @@ -const chalk = require('chalk'); -const Task = require('ember-cli/lib/models/task'); -const Watcher = require('ember-cli/lib/models/watcher'); -const Promise = require('ember-cli/lib/ext/promise'); - -const Builder = require('../models/builder'); - - -module.exports = Task.extend({ - run: function(options) { - console.log(2); - this.ui.startProgress( - chalk.green('Building'), chalk.green('.') - ); - - return new Watcher({ - ui: this.ui, - builder: new Builder({ - ui: this.ui, - outputPath: options.outputPath, - environment: options.environment, - project: this.project - }), - analytics: this.analytics, - options: options - }).then(function() { - return new Promise(function () {}); // Run until failure or signal to exit - }); - } -}); diff --git a/addon/ng2/tasks/build.ts b/addon/ng2/tasks/build.ts deleted file mode 100644 index 8af2961d35b3..000000000000 --- a/addon/ng2/tasks/build.ts +++ /dev/null @@ -1,55 +0,0 @@ -const chalk = require('chalk'); -const Task = require('ember-cli/lib/models/task'); - -const Builder = require('../models/builder'); - - -module.exports = Task.extend({ - // Options: String outputPath - run: function(options) { - var ui = this.ui; - var analytics = this.analytics; - - ui.startProgress(chalk.green('Building'), chalk.green('.')); - - var builder = new Builder({ - ui: ui, - outputPath: options.outputPath, - environment: options.environment, - project: this.project - }); - - return builder.build() - .then(function(results) { - if (!results) { - return; - } - var totalTime = results.totalTime / 1e6; - - analytics.track({ - name: 'ember build', - message: totalTime + 'ms' - }); - - analytics.trackTiming({ - category: 'rebuild', - variable: 'build time', - label: 'broccoli build time', - value: parseInt(totalTime, 10) - }); - }) - .finally(function() { - ui.stopProgress(); - return builder.cleanup(); - }) - .then(function() { - ui.writeLine(chalk.green('Built project successfully. Stored in "' + - options.outputPath + '".')); - }) - .catch(function(err) { - ui.writeLine(chalk.red('Build failed.')); - - throw err; - }); - } -}); diff --git a/addon/ng2/tasks/serve-webpack.ts b/addon/ng2/tasks/serve-webpack.ts index 176af5388902..277047af405a 100644 --- a/addon/ng2/tasks/serve-webpack.ts +++ b/addon/ng2/tasks/serve-webpack.ts @@ -1,24 +1,18 @@ -import {webpackDevServerOutputOptions} from '../models/'; -import {NgCliWebpackConfig} from '../models/webpack-config'; -import {ServeTaskOptions} from '../commands/serve'; +import * as path from 'path'; +import * as chalk from 'chalk'; +import * as Task from 'ember-cli/lib/models/task'; +import * as webpack from 'webpack'; +import * as WebpackDevServer from 'webpack-dev-server'; +import * as ProgressPlugin from 'webpack/lib/ProgressPlugin'; +import { webpackDevServerOutputOptions } from '../models/'; +import { NgCliWebpackConfig } from '../models/webpack-config'; +import { ServeTaskOptions } from '../commands/serve'; import { CliConfig } from '../models/config'; -const path = require('path'); -const chalk = require('chalk'); - - -const Task = require('ember-cli/lib/models/task'); -const webpack = require('webpack'); -const WebpackDevServer = require('webpack-dev-server'); -const ProgressPlugin = require('webpack/lib/ProgressPlugin'); - - - -let lastHash = null; - module.exports = Task.extend({ run: function(commandOptions: ServeTaskOptions) { - + + let lastHash = null; let webpackCompiler: any; var config: NgCliWebpackConfig = new NgCliWebpackConfig(this.project, commandOptions.environment).config; @@ -44,7 +38,7 @@ module.exports = Task.extend({ const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration); return new Promise((resolve, reject) => { - server.listen(commandOptions.port, "localhost", function(err, stats) { + server.listen(commandOptions.port, 'localhost', function(err, stats) { if(err) { lastHash = null; console.error(err.stack || err); @@ -54,7 +48,7 @@ module.exports = Task.extend({ if(stats && stats.hash && stats.hash !== lastHash) { lastHash = stats.hash; - process.stdout.write(stats.toString(webpackOutputOptions) + "\n" + serveMessage + "\n"); + process.stdout.write(stats.toString(webpackOutputOptions) + '\n' + serveMessage + '\n'); } process.stdout.write(serveMessage); diff --git a/addon/ng2/tasks/serve.ts b/addon/ng2/tasks/serve.ts deleted file mode 100644 index b283942396fc..000000000000 --- a/addon/ng2/tasks/serve.ts +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -var existsSync = require('exists-sync'); -var path = require('path'); -var LiveReloadServer = require('ember-cli/lib/tasks/server/livereload-server'); -var ExpressServer = require('ember-cli/lib/tasks/server/express-server'); -var Promise = require('ember-cli/lib/ext/promise'); -var Task = require('ember-cli/lib/models/task'); -var Watcher = require('ember-cli/lib/models/watcher'); -var Builder = require('../models/builder'); -var ServerWatcher = require('ember-cli/lib/models/server-watcher'); - -module.exports = Task.extend({ - run: function(options) { - var builder = new Builder({ - ui: this.ui, - outputPath: options.outputPath, - project: this.project, - environment: options.environment - }); - - var watcher = new Watcher({ - ui: this.ui, - builder: builder, - analytics: this.analytics, - options: options - }); - - var serverRoot = './server'; - var serverWatcher = null; - if (existsSync(serverRoot)) { - serverWatcher = new ServerWatcher({ - ui: this.ui, - analytics: this.analytics, - watchedDir: path.resolve(serverRoot) - }); - } - - var expressServer = new ExpressServer({ - ui: this.ui, - project: this.project, - watcher: watcher, - serverRoot: serverRoot, - serverWatcher: serverWatcher - }); - - var liveReloadServer = new LiveReloadServer({ - ui: this.ui, - analytics: this.analytics, - project: this.project, - watcher: watcher, - expressServer: expressServer - }); - - return Promise.all([ - liveReloadServer.start(options), - expressServer.start(options) - ]).then(function() { - return new Promise(function() { - // hang until the user exits. - }); - }); - } -}); diff --git a/addon/ng2/tasks/test.ts b/addon/ng2/tasks/test.ts index 4a92a23eb577..8ef8268f9b15 100644 --- a/addon/ng2/tasks/test.ts +++ b/addon/ng2/tasks/test.ts @@ -1,7 +1,7 @@ -const Promise = require('ember-cli/lib/ext/promise'); -const Task = require('ember-cli/lib/models/task'); -const path = require('path'); -const webpackTestConfig = require('../models/webpack-build-test').getWebpackTestConfig; +import * as Promise from 'ember-cli/lib/ext/promise'; +import * as Task from 'ember-cli/lib/models/task'; +import * as path from 'path'; +import { getWebpackTestConfig } from '../models/webpack-build-test'; // require dependencies within the target project function requireDependency(root, moduleName) { @@ -34,7 +34,7 @@ module.exports = Task.extend({ // Single test entry file. Will run the test.ts bundle and track it. options.files = [{ pattern: testFile, watched: false }]; options.preprocessors = { [testFile]: ['webpack','sourcemap'] }; - options.webpack = webpackTestConfig(projectRoot, this.project.ngConfig.defaults.sourceDir); + options.webpack = getWebpackTestConfig(projectRoot, this.project.ngConfig.defaults.sourceDir); options.webpackMiddleware = { noInfo: true, // Hide webpack output because its noisy. stats: { // Also prevent chunk and module display output, cleaner look. Only emit errors. diff --git a/addon/ng2/utilities/sw-install.js b/addon/ng2/utilities/sw-install.js index d2e341852813..eadc268397fc 100644 --- a/addon/ng2/utilities/sw-install.js +++ b/addon/ng2/utilities/sw-install.js @@ -1 +1,3 @@ +// this file is used in ../models/webpack-build-mobile.ts to add +// service worker functionality to mobile projects require('offline-plugin/runtime').install(); \ No newline at end of file