Skip to content

Commit 8be7096

Browse files
authored
fix: fix compilation errors for the whole project (angular#1864)
1 parent 7f70095 commit 8be7096

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+480
-383
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# /node_modules and /bower_components ignored by default
2+
dist/
23
.git/
34
tmp/
45
typings/

addon/ng2/commands/build.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as Command from 'ember-cli/lib/models/command';
2-
import * as WebpackBuild from '../tasks/build-webpack';
3-
import * as WebpackBuildWatch from '../tasks/build-webpack-watch';
1+
const Command = require('ember-cli/lib/models/command');
2+
import WebpackBuild from '../tasks/build-webpack';
3+
import WebpackBuildWatch from '../tasks/build-webpack-watch';
44

55
export interface BuildOptions {
66
target?: string;
@@ -12,7 +12,7 @@ export interface BuildOptions {
1212
baseHref?: string;
1313
}
1414

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

67-
module.exports.overrideCore = true;
67+
68+
BuildCommand.overrideCore = true;
69+
export default BuildCommand;

addon/ng2/commands/doc.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as Command from 'ember-cli/lib/models/command';
2-
import * as DocTask from '../tasks/doc';
1+
const Command = require('ember-cli/lib/models/command');
2+
import { DocTask } from '../tasks/doc';
33

44
const DocCommand = Command.extend({
55
name: 'doc',
@@ -10,7 +10,7 @@ const DocCommand = Command.extend({
1010
'<keyword>'
1111
],
1212

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

1616
const docTask = new DocTask({
@@ -23,4 +23,4 @@ const DocCommand = Command.extend({
2323
}
2424
});
2525

26-
module.exports = DocCommand;
26+
export default DocCommand;

addon/ng2/commands/e2e.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import * as Command from 'ember-cli/lib/models/command';
2-
import * as E2ETask from '../tasks/e2e';
1+
const Command = require('ember-cli/lib/models/command');
2+
import {E2eTask} from '../tasks/e2e';
33
import {CliConfig} from '../models/config';
44

5-
module.exports = Command.extend({
5+
const E2eCommand = Command.extend({
66
name: 'e2e',
77
description: 'Run e2e tests in existing project',
88
works: 'insideProject',
99
run: function () {
1010
this.project.ngConfig = this.project.ngConfig || CliConfig.fromProject();
1111

12-
const e2eTask = new E2ETask({
12+
const e2eTask = new E2eTask({
1313
ui: this.ui,
1414
analytics: this.analytics,
1515
project: this.project
@@ -18,3 +18,6 @@ module.exports = Command.extend({
1818
return e2eTask.run();
1919
}
2020
});
21+
22+
23+
export default E2eCommand;

addon/ng2/commands/easter-egg.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import * as Command from 'ember-cli/lib/models/command';
2-
import * as Promise from 'ember-cli/lib/ext/promise';
3-
import * as stringUtils from 'ember-cli-string-utils';
1+
const Command = require('ember-cli/lib/models/command');
2+
const stringUtils = require('ember-cli-string-utils');
43
import * as chalk from 'chalk';
54

65

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

1110

12-
module.exports = function(name) {
11+
export default function(name: string) {
1312
return Command.extend({
1413
name: name,
1514
works: 'insideProject',
1615

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

2019
return Promise.resolve();
2120
},

addon/ng2/commands/generate.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import * as EmberGenerateCommand from 'ember-cli/lib/commands/generate';
21
import * as fs from 'fs';
32
import * as path from 'path';
4-
import * as SilentError from 'silent-error';
5-
import * as Blueprint from 'ember-cli/lib/models/blueprint';
3+
import * as os from 'os';
4+
65
const chalk = require('chalk');
7-
const EOL = require('os').EOL;
6+
const EmberGenerateCommand = require('ember-cli/lib/commands/generate');
7+
const Blueprint = require('ember-cli/lib/models/blueprint');
8+
const SilentError = require('silent-error');
9+
810

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

12-
beforeRun: function(rawArgs) {
14+
beforeRun: function(rawArgs: string[]) {
1315
if (!rawArgs.length) {
1416
return;
1517
}
@@ -23,7 +25,7 @@ const GenerateCommand = EmberGenerateCommand.extend({
2325
}
2426

2527
// Override default help to hide ember blueprints
26-
EmberGenerateCommand.prototype.printDetailedHelp = function (options) {
28+
EmberGenerateCommand.prototype.printDetailedHelp = function() {
2729
const blueprintList = fs.readdirSync(path.join(__dirname, '..', 'blueprints'));
2830
const blueprints = blueprintList
2931
.filter(bp => bp.indexOf('-test') === -1)
@@ -33,7 +35,7 @@ const GenerateCommand = EmberGenerateCommand.extend({
3335
let output = '';
3436
blueprints
3537
.forEach(function (bp) {
36-
output += bp.printBasicHelp(false) + EOL;
38+
output += bp.printBasicHelp(false) + os.EOL;
3739
});
3840
this.ui.writeLine(chalk.cyan(' Available blueprints'));
3941
this.ui.writeLine(output);
@@ -43,12 +45,12 @@ const GenerateCommand = EmberGenerateCommand.extend({
4345
}
4446
});
4547

46-
function mapBlueprintName(name) {
47-
let mappedName = aliasMap[name];
48+
function mapBlueprintName(name: string): string {
49+
let mappedName: string = aliasMap[name];
4850
return mappedName ? mappedName : name;
4951
}
5052

51-
const aliasMap = {
53+
const aliasMap: { [alias: string]: string } = {
5254
'cl': 'class',
5355
'c': 'component',
5456
'd': 'directive',
@@ -59,5 +61,5 @@ const aliasMap = {
5961
's': 'service'
6062
};
6163

62-
module.exports = GenerateCommand;
63-
module.exports.overrideCore = true;
64+
export default GenerateCommand;
65+
GenerateCommand.overrideCore = true;

addon/ng2/commands/get.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as chalk from 'chalk';
2-
import * as Command from 'ember-cli/lib/models/command';
32
import {CliConfig} from '../models/config';
43

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

66
const GetCommand = Command.extend({
77
name: 'get',
@@ -10,7 +10,7 @@ const GetCommand = Command.extend({
1010

1111
availableOptions: [],
1212

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

30-
module.exports = GetCommand;
30+
export default GetCommand;

addon/ng2/commands/github-pages-deploy.ts

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import * as Command from 'ember-cli/lib/models/command';
2-
import * as SilentError from 'silent-error';
1+
const Command = require('ember-cli/lib/models/command');
2+
const SilentError = require('silent-error');
3+
import denodeify = require('denodeify');
4+
35
import { exec } from 'child_process';
4-
import * as Promise from 'ember-cli/lib/ext/promise';
56
import * as chalk from 'chalk';
67
import * as fs from 'fs';
78
import * as fse from 'fs-extra';
89
import * as path from 'path';
9-
import * as WebpackBuild from '../tasks/build-webpack';
10-
import * as CreateGithubRepo from '../tasks/create-github-repo';
10+
import WebpackBuild from '../tasks/build-webpack';
11+
import CreateGithubRepo from '../tasks/create-github-repo';
1112
import { CliConfig } from '../models/config';
1213
import { oneLine } from 'common-tags';
1314

14-
const fsReadDir = Promise.denodeify(fs.readdir);
15-
const fsCopy = Promise.denodeify(fse.copy);
15+
const fsReadDir = <any>denodeify(fs.readdir);
16+
const fsCopy = <any>denodeify(fse.copy);
1617

1718
interface GithubPagesDeployOptions {
1819
message?: string;
@@ -25,7 +26,7 @@ interface GithubPagesDeployOptions {
2526
baseHref?: string;
2627
}
2728

28-
module.exports = Command.extend({
29+
const githubPagesDeployCommand = Command.extend({
2930
name: 'github-pages:deploy',
3031
aliases: ['gh-pages:deploy'],
3132
description: oneLine`
@@ -77,7 +78,7 @@ module.exports = Command.extend({
7778
aliases: ['bh']
7879
}],
7980

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

100101
let ghPagesBranch = 'gh-pages';
101102
let destinationBranch = options.userPage ? 'master' : ghPagesBranch;
102-
let initialBranch;
103+
let initialBranch: string;
103104

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

107108
const buildTask = new WebpackBuild({
108109
ui: this.ui,
@@ -155,7 +156,7 @@ module.exports = Command.extend({
155156

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

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

176177
function createGitHubRepoIfNeeded() {
@@ -205,7 +206,7 @@ module.exports = Command.extend({
205206

206207
function copyFiles() {
207208
return fsReadDir(outDir)
208-
.then((files) => Promise.all(files.map((file) => {
209+
.then((files: string[]) => Promise.all(files.map((file) => {
209210
if (file === '.gitignore') {
210211
// don't overwrite the .gitignore file
211212
return Promise.resolve();
@@ -245,7 +246,7 @@ module.exports = Command.extend({
245246
});
246247
}
247248

248-
function failGracefully(error) {
249+
function failGracefully(error: Error) {
249250
if (error && (/git clean/.test(error.message) || /Permission denied/.test(error.message))) {
250251
ui.writeLine(error.message);
251252
let msg = 'There was a permissions error during git file operations, ' +
@@ -258,3 +259,6 @@ module.exports = Command.extend({
258259
}
259260
}
260261
});
262+
263+
264+
export default githubPagesDeployCommand;

0 commit comments

Comments
 (0)