Skip to content

chore: cleanup of new files #1388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon/ng2/blueprints/ng2/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
6 changes: 2 additions & 4 deletions addon/ng2/blueprints/ng2/files/__path__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions addon/ng2/blueprints/ng2/files/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"rootDir": ".",
"sourceMap": true,
"target": "es5"
}
Expand Down
6 changes: 3 additions & 3 deletions addon/ng2/commands/build.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
16 changes: 7 additions & 9 deletions addon/ng2/commands/serve.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -53,7 +54,6 @@ module.exports = Command.extend({

run: function(commandOptions: ServeTaskOptions) {


commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host;

return this._checkExpressPort(commandOptions)
Expand All @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions addon/ng2/commands/test.js → addon/ng2/commands/test.ts
Original file line number Diff line number Diff line change
@@ -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: [
Expand All @@ -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);
}
});
Expand Down
1 change: 0 additions & 1 deletion addon/ng2/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 5 additions & 6 deletions addon/ng2/models/webpack-build-common.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
13 changes: 6 additions & 7 deletions addon/ng2/models/webpack-build-production.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions addon/ng2/models/webpack-build-test.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion addon/ng2/models/webpack-build-utils.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
7 changes: 3 additions & 4 deletions addon/ng2/models/webpack-config.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down
30 changes: 0 additions & 30 deletions addon/ng2/tasks/build-watch.ts

This file was deleted.

55 changes: 0 additions & 55 deletions addon/ng2/tasks/build.ts

This file was deleted.

32 changes: 13 additions & 19 deletions addon/ng2/tasks/serve-webpack.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading