Skip to content

Commit d00177c

Browse files
committed
chore(test): e2e css preprocessor tests
1 parent de3c89b commit d00177c

18 files changed

+513
-370
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addon/ng2/blueprints/ng2/files/src/config/system.config.js

addon/ng2/commands/install.js renamed to addon/ng2/commands/install.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
/* jshint node: true, esnext: true */
2-
'use strict';
3-
4-
const Command = require('ember-cli/lib/models/command');
5-
const SilentError = require('silent-error');
6-
const Promise = require('ember-cli/lib/ext/promise');
7-
const InstallTask = require('../tasks/install');
1+
import * as Command from 'ember-cli/lib/models/command';
2+
import * as SlientError from 'silent-error';
3+
import * as InstallTask from '../tasks/install';
84

95
module.exports = Command.extend({
106
name: 'install',
117
description: 'Adds 3rd party library to existing project',
128
works: 'insideProject',
139

14-
availableOptions: [
15-
{ name: 'typings', type: String, aliases: ['t'], description: 'Installs specified typings' }
16-
],
17-
1810
run: function (commandOptions, rawArgs) {
1911
if (!rawArgs.length) {
2012
const msg = 'The `ng install` command must take an argument with ' +
@@ -30,8 +22,7 @@ module.exports = Command.extend({
3022
});
3123

3224
return installTask.run({
33-
packages: rawArgs,
34-
typings: commandOptions.typings || null
25+
packages: rawArgs
3526
});
3627
}
3728
});

addon/ng2/commands/uninstall.js renamed to addon/ng2/commands/uninstall.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
/* jshint node: true, esnext: true */
2-
'use strict';
3-
4-
const Command = require('ember-cli/lib/models/command');
5-
const SilentError = require('silent-error');
6-
const Promise = require('ember-cli/lib/ext/promise');
7-
const UninstallTask = require('../tasks/uninstall');
1+
import * as Command from 'ember-cli/lib/models/command';
2+
import * as SilentError from 'silent-error';
3+
import * as UninstallTask from '../tasks/uninstall';
84

95
module.exports = Command.extend({
106
name: 'uninstall',
117
description: 'Removes 3rd party library from existing project',
128
works: 'insideProject',
139

14-
availableOptions: [
15-
{ name: 'typings', type: String, aliases: ['t'], description: 'Removes specified typings' }
16-
],
17-
1810
run: function (commandOptions, rawArgs) {
1911
if (!rawArgs.length) {
2012
const msg = 'The `ng uninstall` command must take an argument with ' +
@@ -30,8 +22,7 @@ module.exports = Command.extend({
3022
});
3123

3224
return uninstallTask.run({
33-
packages: rawArgs,
34-
typings: commandOptions.typings || null
25+
packages: rawArgs
3526
});
3627
}
3728
});

addon/ng2/tasks/install.js

Lines changed: 0 additions & 82 deletions
This file was deleted.

addon/ng2/tasks/install.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import * as Task from 'ember-cli/lib/models/task';
2+
import * as npmTask from 'ember-cli/lib/tasks/npm-task';
3+
import * as chalk from 'chalk';
4+
import * as path from 'path';
5+
import { EventEmitter } from 'events';
6+
import * as search from 'typings-core/dist/search';
7+
import * as typings from 'typings-core/dist/install';
8+
import * as systemJS from '../utilities/systemjs-helper';
9+
10+
module.exports = Task.extend({
11+
completionOKMessage: 'Successfully installed.',
12+
completionErrorMessage: 'Error installing package.',
13+
14+
run: function(options) {
15+
this.packages = options.packages;
16+
17+
if (this.packages.indexOf('sass') !== -1) {
18+
this.packages[this.packages.indexOf('sass')] = 'node-sass';
19+
}
20+
21+
if (this.packages.indexOf('compass') !== -1) {
22+
this.packages[this.packages.indexOf('compass')] = 'compass-importer';
23+
if (this.packages.indexOf('sass') === -1 || this.packages.indexOf('node-sass')) {
24+
this.packages.push('node-sass');
25+
}
26+
}
27+
28+
return this.installProcedure();
29+
},
30+
31+
installProcedure: function() {
32+
const that = this;
33+
34+
const NpmTask = new npmTask({
35+
command: 'install',
36+
ui: this.ui,
37+
analytics: this.analytics,
38+
project: this.project,
39+
startProgressMessage: 'Installing packages: ' + this.packages,
40+
completionMessage: 'Packages successfully installed.'
41+
});
42+
43+
return NpmTask.run({
44+
packages: this.packages,
45+
verbose: false
46+
})
47+
.then(() => this.storeInSystemJSConfig(this.packages))
48+
.then(() => this.installTypings());
49+
},
50+
51+
installTypings: function() {
52+
this.ui.startProgress(chalk.green('Searching and installing typings'), chalk.green('.'));
53+
this.packages = this.packages.filter(p => !/node-sass|stylus|less|compass-importer/.test(p));
54+
55+
let typingsList = [];
56+
57+
return Promise.all(this.packages.map(p => {
58+
return new Promise(res => {
59+
search.search({ name: p }).then(resp => {
60+
if (resp.results.length) {
61+
let names = resp.results.map(x => {
62+
if (x.source === 'dt') { return x.name; }
63+
}).filter(x => !!x);
64+
typingsList = typingsList.concat(names);
65+
}
66+
res();
67+
});
68+
});
69+
}))
70+
.then(() => {
71+
return Promise.all(typingsList.map(t => {
72+
return new Promise(res => {
73+
let installOpts = { cwd: process.env.PWD, save: true, ambient: true };
74+
typings.installDependencyRaw(t, installOpts).then(() => { res(); });
75+
});
76+
}))
77+
.then(() => {
78+
return this.ui.stopProgress();
79+
})
80+
});
81+
},
82+
83+
storeInSystemJSConfig: function(packages) {
84+
const systemPath = path.resolve(process.cwd(), 'src', 'config', 'system.config.js');
85+
let json = systemJS.loadSystemJson(systemPath);
86+
87+
packages = packages.filter(p => {
88+
return (!/node-sass|stylus|less|compass-importer/.test(p));
89+
});
90+
91+
let mappings = json.map || {};
92+
packages.forEach(pkg => {
93+
mappings[pkg] = 'libs/' + pkg + '/' + pkg + '.js';
94+
});
95+
json.map = mappings;
96+
systemJS.saveSystemJson(systemPath, json);
97+
98+
return Promise.resolve();
99+
}
100+
101+
});

addon/ng2/tasks/typings-install.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

addon/ng2/tasks/typings-uninstall.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

addon/ng2/tasks/uninstall.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)