Skip to content
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

fix: fix compilation errors for the whole project #1864

Merged
merged 6 commits into from
Aug 28, 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# /node_modules and /bower_components ignored by default
dist/
.git/
tmp/
typings/
Expand Down
12 changes: 7 additions & 5 deletions addon/ng2/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Command from 'ember-cli/lib/models/command';
import * as WebpackBuild from '../tasks/build-webpack';
import * as WebpackBuildWatch from '../tasks/build-webpack-watch';
const Command = require('ember-cli/lib/models/command');
import WebpackBuild from '../tasks/build-webpack';
import WebpackBuildWatch from '../tasks/build-webpack-watch';

export interface BuildOptions {
target?: string;
Expand All @@ -12,7 +12,7 @@ export interface BuildOptions {
baseHref?: string;
}

module.exports = Command.extend({
const BuildCommand = Command.extend({
name: 'build',
description: 'Builds your app and places it into the output path (dist/ by default).',
aliases: ['b'],
Expand Down Expand Up @@ -64,4 +64,6 @@ module.exports = Command.extend({
}
});

module.exports.overrideCore = true;

BuildCommand.overrideCore = true;
export default BuildCommand;
8 changes: 4 additions & 4 deletions addon/ng2/commands/doc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Command from 'ember-cli/lib/models/command';
import * as DocTask from '../tasks/doc';
const Command = require('ember-cli/lib/models/command');
import { DocTask } from '../tasks/doc';

const DocCommand = Command.extend({
name: 'doc',
Expand All @@ -10,7 +10,7 @@ const DocCommand = Command.extend({
'<keyword>'
],

run: function(commandOptions, rawArgs: Array<string>) {
run: function(commandOptions: any, rawArgs: Array<string>) {
const keyword = rawArgs[0];

const docTask = new DocTask({
Expand All @@ -23,4 +23,4 @@ const DocCommand = Command.extend({
}
});

module.exports = DocCommand;
export default DocCommand;
11 changes: 7 additions & 4 deletions addon/ng2/commands/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as Command from 'ember-cli/lib/models/command';
import * as E2ETask from '../tasks/e2e';
const Command = require('ember-cli/lib/models/command');
import {E2eTask} from '../tasks/e2e';
import {CliConfig} from '../models/config';

module.exports = Command.extend({
const E2eCommand = Command.extend({
name: 'e2e',
description: 'Run e2e tests in existing project',
works: 'insideProject',
run: function () {
this.project.ngConfig = this.project.ngConfig || CliConfig.fromProject();

const e2eTask = new E2ETask({
const e2eTask = new E2eTask({
ui: this.ui,
analytics: this.analytics,
project: this.project
Expand All @@ -18,3 +18,6 @@ module.exports = Command.extend({
return e2eTask.run();
}
});


export default E2eCommand;
11 changes: 5 additions & 6 deletions addon/ng2/commands/easter-egg.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Command from 'ember-cli/lib/models/command';
import * as Promise from 'ember-cli/lib/ext/promise';
import * as stringUtils from 'ember-cli-string-utils';
const Command = require('ember-cli/lib/models/command');
const stringUtils = require('ember-cli-string-utils');
import * as chalk from 'chalk';


Expand All @@ -9,13 +8,13 @@ function pickOne(of: string[]): string {
}


module.exports = function(name) {
export default function(name: string) {
return Command.extend({
name: name,
works: 'insideProject',

run: function (commandOptions, rawArgs): Promise<void> {
this[stringUtils.camelize(this.name)](commandOptions, rawArgs);
run: function (commandOptions: any, rawArgs: string[]): Promise<void> {
(this as any)[stringUtils.camelize(this.name)](commandOptions, rawArgs);

return Promise.resolve();
},
Expand Down
26 changes: 14 additions & 12 deletions addon/ng2/commands/generate.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import * as EmberGenerateCommand from 'ember-cli/lib/commands/generate';
import * as fs from 'fs';
import * as path from 'path';
import * as SilentError from 'silent-error';
import * as Blueprint from 'ember-cli/lib/models/blueprint';
import * as os from 'os';

const chalk = require('chalk');
const EOL = require('os').EOL;
const EmberGenerateCommand = require('ember-cli/lib/commands/generate');
const Blueprint = require('ember-cli/lib/models/blueprint');
const SilentError = require('silent-error');


const GenerateCommand = EmberGenerateCommand.extend({
name: 'generate',

beforeRun: function(rawArgs) {
beforeRun: function(rawArgs: string[]) {
if (!rawArgs.length) {
return;
}
Expand All @@ -23,7 +25,7 @@ const GenerateCommand = EmberGenerateCommand.extend({
}

// Override default help to hide ember blueprints
EmberGenerateCommand.prototype.printDetailedHelp = function (options) {
EmberGenerateCommand.prototype.printDetailedHelp = function() {
const blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
const blueprints = blueprintList
.filter(bp => bp.indexOf('-test') === -1)
Expand All @@ -33,7 +35,7 @@ const GenerateCommand = EmberGenerateCommand.extend({
let output = '';
blueprints
.forEach(function (bp) {
output += bp.printBasicHelp(false) + EOL;
output += bp.printBasicHelp(false) + os.EOL;
});
this.ui.writeLine(chalk.cyan(' Available blueprints'));
this.ui.writeLine(output);
Expand All @@ -43,12 +45,12 @@ const GenerateCommand = EmberGenerateCommand.extend({
}
});

function mapBlueprintName(name) {
let mappedName = aliasMap[name];
function mapBlueprintName(name: string): string {
let mappedName: string = aliasMap[name];
return mappedName ? mappedName : name;
}

const aliasMap = {
const aliasMap: { [alias: string]: string } = {
'cl': 'class',
'c': 'component',
'd': 'directive',
Expand All @@ -59,5 +61,5 @@ const aliasMap = {
's': 'service'
};

module.exports = GenerateCommand;
module.exports.overrideCore = true;
export default GenerateCommand;
GenerateCommand.overrideCore = true;
6 changes: 3 additions & 3 deletions addon/ng2/commands/get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as chalk from 'chalk';
import * as Command from 'ember-cli/lib/models/command';
import {CliConfig} from '../models/config';

const Command = require('ember-cli/lib/models/command');

const GetCommand = Command.extend({
name: 'get',
Expand All @@ -10,7 +10,7 @@ const GetCommand = Command.extend({

availableOptions: [],

run: function (commandOptions, rawArgs): Promise<void> {
run: function (commandOptions: any, rawArgs: string[]): Promise<void> {
return new Promise(resolve => {
const config = CliConfig.fromProject();
const value = config.get(rawArgs[0]);
Expand All @@ -27,4 +27,4 @@ const GetCommand = Command.extend({
}
});

module.exports = GetCommand;
export default GetCommand;
34 changes: 19 additions & 15 deletions addon/ng2/commands/github-pages-deploy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import * as Command from 'ember-cli/lib/models/command';
import * as SilentError from 'silent-error';
const Command = require('ember-cli/lib/models/command');
const SilentError = require('silent-error');
import denodeify = require('denodeify');

import { exec } from 'child_process';
import * as Promise from 'ember-cli/lib/ext/promise';
import * as chalk from 'chalk';
import * as fs from 'fs';
import * as fse from 'fs-extra';
import * as path from 'path';
import * as WebpackBuild from '../tasks/build-webpack';
import * as CreateGithubRepo from '../tasks/create-github-repo';
import WebpackBuild from '../tasks/build-webpack';
import CreateGithubRepo from '../tasks/create-github-repo';
import { CliConfig } from '../models/config';
import { oneLine } from 'common-tags';

const fsReadDir = Promise.denodeify(fs.readdir);
const fsCopy = Promise.denodeify(fse.copy);
const fsReadDir = <any>denodeify(fs.readdir);
const fsCopy = <any>denodeify(fse.copy);

interface GithubPagesDeployOptions {
message?: string;
Expand All @@ -25,7 +26,7 @@ interface GithubPagesDeployOptions {
baseHref?: string;
}

module.exports = Command.extend({
const githubPagesDeployCommand = Command.extend({
name: 'github-pages:deploy',
aliases: ['gh-pages:deploy'],
description: oneLine`
Expand Down Expand Up @@ -77,7 +78,7 @@ module.exports = Command.extend({
aliases: ['bh']
}],

run: function(options: GithubPagesDeployOptions, rawArgs) {
run: function(options: GithubPagesDeployOptions, rawArgs: string[]) {
const ui = this.ui;
const root = this.project.root;
const execOptions = {
Expand All @@ -99,10 +100,10 @@ module.exports = Command.extend({

let ghPagesBranch = 'gh-pages';
let destinationBranch = options.userPage ? 'master' : ghPagesBranch;
let initialBranch;
let initialBranch: string;

// declared here so that tests can stub exec
const execPromise = Promise.denodeify(exec);
const execPromise = <(cmd: string, options?: any) => Promise<string>>denodeify(exec);

const buildTask = new WebpackBuild({
ui: this.ui,
Expand Down Expand Up @@ -155,7 +156,7 @@ module.exports = Command.extend({

function checkForPendingChanges() {
return execPromise('git status --porcelain')
.then(stdout => {
.then((stdout: string) => {
if (/\w+/m.test(stdout)) {
let msg = 'Uncommitted file changes found! Please commit all changes before deploying.';
return Promise.reject(new SilentError(msg));
Expand All @@ -170,7 +171,7 @@ module.exports = Command.extend({

function saveStartingBranchName() {
return execPromise('git rev-parse --abbrev-ref HEAD')
.then((stdout) => initialBranch = stdout.replace(/\s/g, ''));
.then((stdout: string) => initialBranch = stdout.replace(/\s/g, ''));
}

function createGitHubRepoIfNeeded() {
Expand Down Expand Up @@ -205,7 +206,7 @@ module.exports = Command.extend({

function copyFiles() {
return fsReadDir(outDir)
.then((files) => Promise.all(files.map((file) => {
.then((files: string[]) => Promise.all(files.map((file) => {
if (file === '.gitignore') {
// don't overwrite the .gitignore file
return Promise.resolve();
Expand Down Expand Up @@ -245,7 +246,7 @@ module.exports = Command.extend({
});
}

function failGracefully(error) {
function failGracefully(error: Error) {
if (error && (/git clean/.test(error.message) || /Permission denied/.test(error.message))) {
ui.writeLine(error.message);
let msg = 'There was a permissions error during git file operations, ' +
Expand All @@ -258,3 +259,6 @@ module.exports = Command.extend({
}
}
});


export default githubPagesDeployCommand;
Loading