Skip to content

Commit 235a48e

Browse files
authored
Merge branch 'master' into push-to-github-with-token
2 parents d94042c + 142c518 commit 235a48e

27 files changed

+146
-176
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
"json-loader": "^0.5.4",
7676
"karma-sourcemap-loader": "^0.3.7",
7777
"karma-webpack": "^1.8.0",
78-
"leek": "0.0.21",
7978
"less": "^2.7.1",
8079
"less-loader": "^2.2.3",
8180
"loader-utils": "^0.2.16",

packages/angular-cli/bin/ng

+1-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ process.title = 'angular-cli';
66

77
const resolve = require('resolve');
88
const packageJson = require('../package.json');
9-
const Leek = require('leek');
109
const Version = require('../upgrade/version').Version;
1110

1211

@@ -35,18 +34,9 @@ resolve('angular-cli', { basedir: process.cwd() },
3534
cli({
3635
cliArgs: process.argv.slice(2),
3736
inputStream: process.stdin,
38-
outputStream: process.stdout,
39-
Leek: CustomLeek
37+
outputStream: process.stdout
4038
}).then(function (result) {
4139
var exitCode = typeof result === 'object' ? result.exitCode : result;
4240
process.exit(exitCode);
4341
});
44-
45-
function CustomLeek(options) {
46-
options.trackingCode = packageJson.trackingCode;
47-
options.globalName = packageJson.name;
48-
options.name = packageJson.name;
49-
options.version = packageJson.version;
50-
return new Leek(options);
51-
}
5242
});

packages/angular-cli/commands/doc.ts

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const DocCommand = Command.extend({
1515

1616
const docTask = new DocTask({
1717
ui: this.ui,
18-
analytics: this.analytics,
1918
project: this.project
2019
});
2120

packages/angular-cli/commands/e2e.ts

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const E2eCommand = Command.extend({
1111

1212
const e2eTask = new E2eTask({
1313
ui: this.ui,
14-
analytics: this.analytics,
1514
project: this.project
1615
});
1716

packages/angular-cli/commands/github-pages-deploy.ts

-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const githubPagesDeployCommand = Command.extend({
109109

110110
const buildTask = new WebpackBuild({
111111
ui: this.ui,
112-
analytics: this.analytics,
113112
cliProject: this.project,
114113
target: options.target,
115114
environment: options.environment,
@@ -133,7 +132,6 @@ const githubPagesDeployCommand = Command.extend({
133132

134133
const createGithubRepoTask = new CreateGithubRepo({
135134
ui: this.ui,
136-
analytics: this.analytics,
137135
project: this.project
138136
});
139137

packages/angular-cli/commands/init.ts

-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const InitCommand: any = Command.extend({
3939

4040
const installBlueprint = new this.tasks.InstallBlueprint({
4141
ui: this.ui,
42-
analytics: this.analytics,
4342
project: this.project
4443
});
4544

@@ -57,7 +56,6 @@ const InitCommand: any = Command.extend({
5756
if (!commandOptions.skipNpm) {
5857
npmInstall = new NpmInstall({
5958
ui: this.ui,
60-
analytics: this.analytics,
6159
project: this.project
6260
});
6361
}
@@ -66,7 +64,6 @@ const InitCommand: any = Command.extend({
6664
if (commandOptions.linkCli) {
6765
linkCli = new LinkCli({
6866
ui: this.ui,
69-
analytics: this.analytics,
7067
project: this.project
7168
});
7269
}

packages/angular-cli/commands/lint.ts

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default Command.extend({
88
run: function () {
99
const lintTask = new LintTask({
1010
ui: this.ui,
11-
analytics: this.analytics,
1211
project: this.project
1312
});
1413

packages/angular-cli/commands/new.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ const NewCommand = Command.extend({
7272
}
7373

7474
const createAndStepIntoDirectory =
75-
new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics });
75+
new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui });
7676

7777
const initCommand = new InitCommand({
7878
ui: this.ui,
79-
analytics: this.analytics,
8079
tasks: this.tasks,
8180
project: Project.nullProject(this.ui, this.cli)
8281
});

packages/angular-cli/commands/serve.ts

-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ const ServeCommand = Command.extend({
135135

136136
const serve = new ServeWebpackTask({
137137
ui: this.ui,
138-
analytics: this.analytics,
139138
project: this.project,
140139
});
141140

packages/angular-cli/commands/test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const NgCliTestCommand = TestCommand.extend({
3939

4040
const testTask = new TestTask({
4141
ui: this.ui,
42-
analytics: this.analytics,
4342
project: this.project
4443
});
4544

packages/angular-cli/ember-cli/lib/cli/cli.js

-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var InstallationChecker = require('../models/installation-checker');
1111
function CLI(options) {
1212
this.name = options.name;
1313
this.ui = options.ui;
14-
this.analytics = options.analytics;
1514
this.testing = options.testing;
1615
this.disableDependencyChecker = options.disableDependencyChecker;
1716
this.root = options.root;
@@ -47,7 +46,6 @@ CLI.prototype.run = function(environment) {
4746

4847
var command = new CurrentCommand({
4948
ui: this.ui,
50-
analytics: this.analytics,
5149
commands: environment.commands,
5250
tasks: environment.tasks,
5351
project: environment.project,
@@ -134,7 +132,6 @@ CLI.prototype.callHelp = function(options) {
134132

135133
var help = new HelpCommand({
136134
ui: this.ui,
137-
analytics: this.analytics,
138135
commands: environment.commands,
139136
tasks: environment.tasks,
140137
project: environment.project,

packages/angular-cli/ember-cli/lib/cli/index.js

-28
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ function clientId() {
3131
// Options: Array cliArgs, Stream inputStream, Stream outputStream
3232
module.exports = function(options) {
3333
var UI = options.UI || require('../ui');
34-
var Leek = options.Leek || require('leek');
3534
var Yam = options.Yam || require('yam');
3635

3736
// TODO: one UI (lib/models/project.js also has one for now...)
@@ -48,39 +47,12 @@ module.exports = function(options) {
4847
primary: Project.getProjectRoot()
4948
});
5049

51-
var leekOptions;
52-
53-
var disableAnalytics = options.cliArgs &&
54-
(options.cliArgs.indexOf('--disable-analytics') > -1 ||
55-
options.cliArgs.indexOf('-v') > -1 ||
56-
options.cliArgs.indexOf('--version') > -1) ||
57-
config.get('disableAnalytics');
58-
59-
var defaultLeekOptions = {
60-
trackingCode: trackingCode,
61-
globalName: name,
62-
name: clientId(),
63-
version: version,
64-
silent: disableAnalytics
65-
};
66-
6750
var defaultUpdateCheckerOptions = {
6851
checkForUpdates: false
6952
};
7053

71-
if (config.get('leekOptions')) {
72-
leekOptions = merge(defaultLeekOptions, config.get('leekOptions'));
73-
} else {
74-
leekOptions = defaultLeekOptions;
75-
}
76-
77-
debug('leek: %o', leekOptions);
78-
79-
var leek = new Leek(leekOptions);
80-
8154
var cli = new CLI({
8255
ui: ui,
83-
analytics: leek,
8456
testing: options.testing,
8557
name: options.cli ? options.cli.name : 'ember',
8658
disableDependencyChecker: options.disableDependencyChecker,

packages/angular-cli/ember-cli/lib/commands/generate.js

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module.exports = Command.extend({
4242
var Task = this.tasks.GenerateFromBlueprint;
4343
var task = new Task({
4444
ui: this.ui,
45-
analytics: this.analytics,
4645
project: this.project,
4746
testing: this.testing,
4847
settings: this.settings

packages/angular-cli/ember-cli/lib/commands/unknown.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ module.exports = Command.extend({
1515
validateAndRun: function() {
1616
throw new SilentError('The specified command ' + this.name +
1717
' is invalid. For available options, see' +
18-
' `ember help`.');
18+
' `ng help`.');
1919
}
2020
});

packages/angular-cli/ember-cli/lib/models/blueprint.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,7 @@ Blueprint.prototype.taskFor = function(dasherizedName) {
10001000

10011001
return new Task({
10021002
ui: this.ui,
1003-
project: this.project,
1004-
analytics: this.analytics
1003+
project: this.project
10051004
});
10061005
};
10071006

packages/angular-cli/ember-cli/lib/models/command.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ Command.prototype.validateAndRun = function(args) {
116116
return Promise.resolve('callHelp');
117117
}
118118

119-
this.analytics.track({
120-
name: 'ember ',
121-
message: this.name
122-
});
123-
124119
if (commandOptions === null) {
125120
return Promise.resolve();
126121
}
@@ -430,7 +425,7 @@ Command.prototype.printBasicHelp = function() {
430425
if (this.isRoot) {
431426
output = 'Usage: ' + this.name;
432427
} else {
433-
output = 'ember ' + this.name;
428+
output = 'ng ' + this.name;
434429
}
435430

436431
output += this._printCommand();

packages/angular-cli/ember-cli/lib/models/watcher.js

-15
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ var Watcher = Task.extend({
1919
didError: function(error) {
2020
debug('didError %o', error);
2121
this.ui.writeError(error);
22-
this.analytics.trackError({
23-
description: error && error.message
24-
});
2522
},
2623

2724
then: function() {
@@ -34,18 +31,6 @@ var Watcher = Task.extend({
3431

3532
this.ui.writeLine('');
3633
this.ui.writeLine(chalk.green('Build successful - ' + Math.round(totalTime) + 'ms.'));
37-
38-
this.analytics.track({
39-
name: 'ember rebuild',
40-
message: 'broccoli rebuild time: ' + totalTime + 'ms'
41-
});
42-
43-
this.analytics.trackTiming({
44-
category: 'rebuild',
45-
variable: 'rebuild time',
46-
label: 'broccoli rebuild time',
47-
value: parseInt(totalTime, 10)
48-
});
4934
},
5035

5136
on: function() {

packages/angular-cli/ember-cli/lib/tasks/generate-from-blueprint.js

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ module.exports = Task.extend({
4747
target: this.project.root,
4848
entity: entity,
4949
ui: this.ui,
50-
analytics: this.analytics,
5150
project: this.project,
5251
settings: this.settings,
5352
testing: this.testing,

packages/angular-cli/ember-cli/lib/tasks/install-blueprint.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ module.exports = Task.extend({
2626
target: target,
2727
entity: { name: name },
2828
ui: this.ui,
29-
analytics: this.analytics,
3029
project: this.project,
3130
dryRun: options.dryRun,
3231
targetFiles: options.targetFiles,

packages/angular-cli/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"json-loader": "^0.5.4",
6060
"karma-sourcemap-loader": "^0.3.7",
6161
"karma-webpack": "^1.8.0",
62-
"leek": "0.0.21",
6362
"less": "^2.7.1",
6463
"less-loader": "^2.2.3",
6564
"lodash": "^4.11.1",

packages/angular-cli/plugins/karma.js

+20
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const init = (config) => {
1111
}
1212
const angularCliConfig = require(path.join(config.basePath, config.angularCli.config));
1313
const appConfig = angularCliConfig.apps[0];
14+
const appRoot = path.join(config.basePath, appConfig.root);
1415
const environment = config.angularCli.environment || 'dev';
1516
const testConfig = {
1617
codeCoverage: config.angularCli.codeCoverage || false,
@@ -66,6 +67,25 @@ const init = (config) => {
6667
.filter((file) => config.preprocessors[file].indexOf('angular-cli') !== -1)
6768
.map((file) => config.preprocessors[file])
6869
.map((arr) => arr.splice(arr.indexOf('angular-cli'), 1, 'webpack', 'sourcemap'));
70+
71+
// Add global scripts
72+
if (appConfig.scripts && appConfig.scripts.length > 0) {
73+
const globalScriptPatterns = appConfig.scripts
74+
.map(script => typeof script === 'string' ? { input: script } : script)
75+
// Neither renamed nor lazy scripts are currently supported
76+
.filter(script => !(script.output || script.lazy))
77+
.map(script => ({
78+
pattern: path.resolve(appRoot, script.input),
79+
included: true,
80+
served: true,
81+
watched: true
82+
}));
83+
84+
// Unshift elements onto the beginning of the files array.
85+
// It's important to not replace the array, because
86+
// karma already has a reference to the existing array.
87+
Array.prototype.unshift.apply(config.files, globalScriptPatterns);
88+
}
6989
}
7090

7191
init.$inject = ['config'];

tests/e2e/tests/test/test-assets.ts

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { writeMultipleFiles } from '../../utils/fs';
2+
import { ng } from '../../utils/process';
3+
import { updateJsonFile } from '../../utils/project';
4+
import { expectToFail } from '../../utils/utils';
5+
import { stripIndent } from 'common-tags';
6+
7+
// Make sure asset files are served
8+
export default function () {
9+
return Promise.resolve()
10+
.then(() => writeMultipleFiles({
11+
'src/assets/file.txt': 'assets-folder-content',
12+
'src/file.txt': 'file-content',
13+
// Not using `async()` in tests as it seemed to swallow `fetch()` errors
14+
'src/app/app.component.spec.ts': stripIndent`
15+
describe('Test Runner', () => {
16+
const fetch = global['fetch'];
17+
it('should serve files in assets folder', (done) => {
18+
fetch('/assets/file.txt')
19+
.then(response => response.text())
20+
.then(fileText => {
21+
expect(fileText).toMatch('assets-folder-content');
22+
done();
23+
});
24+
});
25+
it('should serve files explicitly added to assets array', (done) => {
26+
fetch('/file.txt')
27+
.then(response => response.text())
28+
.then(fileText => {
29+
expect(fileText).toMatch('file-content');
30+
done();
31+
});
32+
});
33+
});
34+
`
35+
}))
36+
// Test failure condition (no assets in angular-cli.json)
37+
.then(() => updateJsonFile('angular-cli.json', configJson => {
38+
const app = configJson['apps'][0];
39+
app['assets'] = [];
40+
}))
41+
.then(() => expectToFail(() => ng('test', '--single-run'),
42+
'Should fail because the assets to serve were not in the angular-cli config'))
43+
// Test passing condition (assets are included)
44+
.then(() => updateJsonFile('angular-cli.json', configJson => {
45+
const app = configJson['apps'][0];
46+
app['assets'] = ['assets', 'file.txt'];
47+
}))
48+
.then(() => ng('test', '--single-run'));
49+
}

0 commit comments

Comments
 (0)