Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cf04a93
build: use webpack for building apps.
TheLarkInn Jul 14, 2016
7786ed3
chore(lint) Corrected any eslint errors and cleaned up unused files
TheLarkInn Jul 14, 2016
cf441a7
chore(cleanup) additional cleanup tasks performed. Removed unneeded c…
TheLarkInn Jul 15, 2016
541d698
chore: remove bind from serve command
filipesilva Jul 15, 2016
0d1c633
chore: simplify test command
filipesilva Jul 15, 2016
4189b9b
chore: fix test warnings
filipesilva Jul 15, 2016
41653cf
chore: revert whitespace changes
filipesilva Jul 15, 2016
f0e6e51
chore: re-add mapRoot to tsconfig
filipesilva Jul 15, 2016
bdb8690
chore: remove unused import
filipesilva Jul 15, 2016
8ea2e72
bugfix: fix broken tests
filipesilva Jul 15, 2016
8b6fdc9
fix: fix mobile-specific feature test
filipesilva Jul 15, 2016
87b4cbd
bugfix: fix public folder test
filipesilva Jul 15, 2016
860526c
fix: fixes for path mappings, tests, and coverage (#1359)
TheLarkInn Jul 17, 2016
435cd18
fix: add environment configuration replacement (#1364)
TheLarkInn Jul 18, 2016
18318a2
fix(tests): re-enable sass/less/stylus tests (#1363)
filipesilva Jul 19, 2016
de98a64
chore: remove systemjs (#1376)
filipesilva Jul 19, 2016
89b4dd5
chore: remove vendor.ts (#1383)
filipesilva Jul 19, 2016
a144db1
chore: remove material2 test option (#1385)
filipesilva Jul 19, 2016
30fd942
fix(build): re-add support for sourceDir (#1378)
filipesilva Jul 20, 2016
aef92b4
chore(build): remove broccoli (#1386)
filipesilva Jul 20, 2016
05b5ca3
chore: remove windows elevation check (#1384)
filipesilva Jul 20, 2016
86c425c
fix(test): add missing sourceDir (#1387)
filipesilva Jul 20, 2016
5b21617
fix: update node polyfill support properties for prod config to allow…
TheLarkInn Jul 20, 2016
e6bdf50
chore(tests): add prod env e2e test (#1394)
filipesilva Jul 20, 2016
1a68ce6
chore: cleanup of new files (#1388)
filipesilva Jul 20, 2016
4cfc463
fix(serve): disable HMR (#1402)
filipesilva Jul 21, 2016
698ba0c
chore: review docs (#1407)
filipesilva Jul 21, 2016
23e5eb9
feat(env): decouple build from env file (#1404)
filipesilva Jul 22, 2016
06fc077
fix: fix tsconfig for editors (#1420)
filipesilva Jul 22, 2016
8695be4
chore: Merge master into webpack
hansl Jul 22, 2016
6562f78
chore: fix webpack branch after merge conflicts (#1423)
hansl Jul 22, 2016
29f899c
fix: update to awesome-typescript-loader 2.1.0 (#1425)
TheLarkInn Jul 22, 2016
b8f502e
chore(blueprints): remove module.id (#1426)
filipesilva Jul 22, 2016
930785f
feat: add host flag support for ng serve (#1442)
TheLarkInn Jul 25, 2016
c3fe959
feat(test): add karma plugin (#1437)
filipesilva Jul 25, 2016
8a2e0e5
chore(blueprints): re-add outDir (#1428)
filipesilva Jul 25, 2016
3d22394
feat: use @types instead of typings (#1449)
filipesilva Jul 26, 2016
9d42071
fix: make sourcemaps work in test (#1447)
TheLarkInn Jul 26, 2016
a3b1bf4
feat: add utilities for typescript ast (#1159) (#1453)
hansl Jul 26, 2016
755fb7a
Merge branch 'master' into webpack
hansl Jul 26, 2016
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
Prev Previous commit
Next Next commit
chore: Merge master into webpack
  • Loading branch information
hansl committed Jul 22, 2016
commit 8695be4cab25893b9c305167696068181c4cbda5
4 changes: 3 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
environment:
nodejs_version: "5.0"
matrix:
- nodejs_version: "5.0"
- nodejs_version: "6.0"

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ env:
- NODE_VERSION=5 SCRIPT=lint
- NODE_VERSION=5 SCRIPT=test
- NODE_VERSION=5 SCRIPT=mobile_test
- NODE_VERSION=6 SCRIPT=test
- NODE_VERSION=6 SCRIPT=mobile_test
os:
- linux
- osx
Expand All @@ -16,6 +18,8 @@ matrix:
env: NODE_VERSION=5 SCRIPT=lint
- os: osx
env: NODE_VERSION=5 SCRIPT=mobile_test
- os: osx
env: NODE_VERSION=6 SCRIPT=mobile_test

script:
- npm run-script $SCRIPT
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<a name="1.0.0-beta.10"></a>
# [1.0.0-beta.10](https://github.com/angular/angular-cli/compare/1.0.0-beta.9...v1.0.0-beta.10) (2016-07-19)


### Bug Fixes

* **build:** don't ignore js in public ([#1129](https://github.com/angular/angular-cli/issues/1129)) ([00e111a](https://github.com/angular/angular-cli/commit/00e111a)), closes [#540](https://github.com/angular/angular-cli/issues/540)
* **mobile:** remove app/index.js from concatenated bundle ([#1267](https://github.com/angular/angular-cli/issues/1267)) ([03fd4c4](https://github.com/angular/angular-cli/commit/03fd4c4))
* Fix all versions of dependencies to Angular-CLI ([#1331](https://github.com/angular/angular-cli/issues/1331)) ([022e7f9](https://github.com/angular/angular-cli/commit/022e7f9)), closes [#1331](https://github.com/angular/angular-cli/issues/1331)
* fix versions in the shrinkwrap instead of using ranges ([#1350](https://github.com/angular/angular-cli/issues/1350)) ([72bc9d9](https://github.com/angular/angular-cli/commit/72bc9d9)), closes [#1350](https://github.com/angular/angular-cli/issues/1350)


### Features

* **router:** upgrade the router version ([#1288](https://github.com/angular/angular-cli/issues/1288)) ([2c9a371](https://github.com/angular/angular-cli/commit/2c9a371))
* add get-dependent-fils utils ([6590743](https://github.com/angular/angular-cli/commit/6590743))



**Always follow the [update guide](https://github.com/angular/angular-cli/blob/master/README.md#updating-angular-cli) when updating to a new version. The changelog does not list breaking changes that are fixed via the update procedure.**

---
Expand Down
20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,9 @@ Enum | `ng g enum my-new-enum`

### Generating a route

You can generate a new route with the following command (note the singular
used in `hero`):
Generating routes in the CLI has been disabled for the time being. A new router and new route generation blueprints are coming.

```bash
ng generate route hero
```

This will create a folder which will contain the hero component and related test and style files.

The generated route will also be registered with the parent component's `@RouteConfig` decorator.

By default the route will be designated as a **lazy** route which means that it will be loaded into the browser when needed, not upfront as part of a bundle.

In order to visually distinguish lazy routes from other routes the folder for the route will be prefixed with a `+` per the above example the folder will be named `+hero`.
This is done in accordance with the [style guide](https://angular.io/styleguide#!#prefix-lazy-loaded-folders-with-).

The default lazy nature of routes can be turned off via the lazy flag (`--lazy false`)

There is an optional flag for `skip-router-generation` which will not add the route to the parent component's `@RouteConfig` decorator.
You can read the official documentation for the new Router here: https://angular.io/docs/ts/latest/guide/router.html. Please note that even though route generation is disabled, building your projects with routing is still fully supported.

### Creating a build

Expand Down
3 changes: 1 addition & 2 deletions addon/ng2/blueprints/ng2/files/__path__/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// Typings reference file, see links for more information
// https://github.com/typings/typings
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html
Expand All @@ -10,7 +9,7 @@

<% if(!isMobile) { %>
declare var System: any;
declare var module: { id: string };
<% if(!isMobile) { %>declare var module: { id: string };<% } %>
declare var require: any;
<% } %>

1 change: 1 addition & 0 deletions addon/ng2/blueprints/ng2/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "3.0.0-beta.2",
"core-js": "^2.4.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"ts-helpers": "^1.1.1",
"zone.js": "0.6.12"
Expand Down
124 changes: 124 additions & 0 deletions addon/ng2/utilities/get-dependent-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
'use strict';

import * as fs from 'fs';
import * as ts from 'typescript';
import * as glob from 'glob';
import * as path from 'path';
import * as denodeify from 'denodeify';

import { Promise } from 'es6-promise';

/**
* Interface that represents a module specifier and its position in the source file.
* Use for storing a string literal, start position and end posittion of ImportClause node kinds.
*/
export interface ModuleImport {
specifierText: string;
pos: number;
end: number;
};

export interface ModuleMap {
[key: string]: ModuleImport[];
}

/**
* Create a SourceFile as defined by Typescript Compiler API.
* Generate a AST structure from a source file.
*
* @param fileName source file for which AST is to be extracted
*/
export function createTsSourceFile(fileName: string): Promise<ts.SourceFile> {
const readFile = denodeify(fs.readFile);
return readFile(fileName, 'utf8')
.then((contents: string) => {
return ts.createSourceFile(fileName, contents, ts.ScriptTarget.ES6, true);
});
}

/**
* Traverses through AST of a given file of kind 'ts.SourceFile', filters out child
* nodes of the kind 'ts.SyntaxKind.ImportDeclaration' and returns import clauses as
* ModuleImport[]
*
* @param {ts.SourceFile} node: Typescript Node of whose AST is being traversed
*
* @return {ModuleImport[]} traverses through ts.Node and returns an array of moduleSpecifiers.
*/
export function getImportClauses(node: ts.SourceFile): ModuleImport[] {
return node.statements
.filter(node => node.kind === ts.SyntaxKind.ImportDeclaration) // Only Imports.
.map((node: ts.ImportDeclaration) => {
let moduleSpecifier = node.moduleSpecifier;
return {
specifierText: moduleSpecifier.getText().slice(1, -1),
pos: moduleSpecifier.pos,
end: moduleSpecifier.end
};
});
}

/**
* Find the file, 'index.ts' given the directory name and return boolean value
* based on its findings.
*
* @param dirPath
*
* @return a boolean value after it searches for a barrel (index.ts by convention) in a given path
*/
export function hasIndexFile(dirPath: string): Promise<Boolean> {
const globSearch = denodeify(glob);
return globSearch(path.join(dirPath, 'index.ts'), { nodir: true })
.then((indexFile: string[]) => {
return indexFile.length > 0;
});
}

/**
* Returns a map of all dependent file/s' path with their moduleSpecifier object
* (specifierText, pos, end)
*
* @param fileName file upon which other files depend
* @param rootPath root of the project
*
* @return {Promise<ModuleMap>} ModuleMap of all dependent file/s (specifierText, pos, end)
*
*/
export function getDependentFiles(fileName: string, rootPath: string): Promise<ModuleMap> {
const globSearch = denodeify(glob);
return globSearch(path.join(rootPath, '**/*.*.ts'), { nodir: true })
.then((files: string[]) => Promise.all(files.map(file => createTsSourceFile(file)))
.then((tsFiles: ts.SourceFile[]) => tsFiles.map(file => getImportClauses(file)))
.then((moduleSpecifiers: ModuleImport[][]) => {
let allFiles: ModuleMap = {};
files.forEach((file, index) => {
let sourcePath = path.normalize(file);
allFiles[sourcePath] = moduleSpecifiers[index];
});
return allFiles;
})
.then((allFiles: ModuleMap) => {
let relevantFiles: ModuleMap = {};
Object.keys(allFiles).forEach(filePath => {
const tempModuleSpecifiers: ModuleImport[] = allFiles[filePath]
.filter(importClause => {
// Filter only relative imports
let singleSlash = importClause.specifierText.charAt(0) === '/';
let currentDirSyntax = importClause.specifierText.slice(0, 2) === './';
let parentDirSyntax = importClause.specifierText.slice(0, 3) === '../';
return singleSlash || currentDirSyntax || parentDirSyntax;
})
.filter(importClause => {
let modulePath = path.resolve(path.dirname(filePath), importClause.specifierText);
let resolvedFileName = path.resolve(fileName);
let fileBaseName = path.basename(resolvedFileName, '.ts');
let parsedFilePath = path.join(path.dirname(resolvedFileName), fileBaseName);
return (parsedFilePath === modulePath) || (resolvedFileName === modulePath);
});
if (tempModuleSpecifiers.length > 0) {
relevantFiles[filePath] = tempModuleSpecifiers;
};
});
return relevantFiles;
}));
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-cli",
"version": "1.0.0-beta.9",
"version": "1.0.0-beta.10",
"description": "CLI tool for Angular",
"main": "lib/cli/index.js",
"trackingCode": "UA-8594346-19",
Expand Down
154 changes: 154 additions & 0 deletions tests/acceptance/get-dependent-files.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
'use strict';

// This needs to be first so fs module can be mocked correctly.
let mockFs = require('mock-fs');
import { expect, assert } from 'chai';
import * as path from 'path';
import * as ts from 'typescript';
import * as dependentFilesUtils from '../../addon/ng2/utilities/get-dependent-files';

describe('Get Dependent Files: ', () => {
let rootPath = 'src/app';

beforeEach(() => {
let mockDrive = {
'src/app': {
'foo': {
'foo.component.ts': `import * from '../bar/baz/baz.component'
import * from '../bar/bar.component'`,
'index.ts': `export * from './foo.component'`
},
'bar': {
'baz': {
'baz.component.ts': 'import * from "../bar.component"',
'baz.html': '<h1> Hello </h1>'
},
'bar.component.ts': `import * from './baz/baz.component'
import * from '../foo'`
},
'foo-baz': {
'no-module.component.ts': ''
},
'empty-dir': {}
}
};
mockFs(mockDrive);
});
afterEach(() => {
mockFs.restore();
});

describe('getImportClauses', () => {
it('returns import specifiers when there is a single import statement', () => {
let sourceFile = path.join(rootPath, 'bar/baz/baz.component.ts');
return dependentFilesUtils.createTsSourceFile(sourceFile)
.then((tsFile: ts.SourceFile) => {
let contents = dependentFilesUtils.getImportClauses(tsFile);
let expectedContents = [{
specifierText: '../bar.component',
pos: 13,
end: 32
}];
assert.deepEqual(contents, expectedContents);
});
});
it('returns imports specifiers when there are multiple import statements', () => {
let sourceFile = path.join(rootPath, 'foo/foo.component.ts');
return dependentFilesUtils.createTsSourceFile(sourceFile)
.then((tsFile: ts.SourceFile) => {
let contents = dependentFilesUtils.getImportClauses(tsFile);
let expectedContents = [
{
specifierText: '../bar/baz/baz.component',
pos: 13,
end: 40
},
{
specifierText: '../bar/bar.component',
pos: 85,
end: 108
}
];
assert.deepEqual(contents, expectedContents);
});
});
});

describe('createTsSourceFile', () => {
it('creates ts.SourceFile give a file path', () => {
let sourceFile = path.join(rootPath, 'foo/foo.component.ts');
return dependentFilesUtils.createTsSourceFile(sourceFile)
.then((tsFile: ts.SourceFile) => {
let isTsSourceFile = (tsFile.kind === ts.SyntaxKind.SourceFile);
expect(isTsSourceFile).to.be.true;
});
});
});

describe('hasIndexFile', () => {
it('returns true when there is a index file', () => {
let sourceFile = path.join(rootPath, 'foo');
dependentFilesUtils.hasIndexFile(sourceFile)
.then((booleanValue: boolean) => {
expect(booleanValue).to.be.true;
});
});
it('returns false when there is no index file', () => {
let sourceFile = path.join(rootPath, 'bar');
dependentFilesUtils.hasIndexFile(sourceFile)
.then((booleanValue: boolean) => {
expect(booleanValue).to.be.false;
});
});
});

describe('returns a map of all files which depend on a given file ', () => {
it('when the given component unit has no index file', () => {
let sourceFile = path.join(rootPath, 'bar/bar.component.ts');
return dependentFilesUtils.getDependentFiles(sourceFile, rootPath)
.then((contents: dependentFilesUtils.ModuleMap) => {
let bazFile = path.join(rootPath, 'bar/baz/baz.component.ts');
let fooFile = path.join(rootPath, 'foo/foo.component.ts');
let expectedContents: dependentFilesUtils.ModuleMap = {};
expectedContents[bazFile] = [{
specifierText: '../bar.component',
pos: 13,
end: 32
}];
expectedContents[fooFile] = [{
specifierText: '../bar/bar.component',
pos: 85,
end: 108
}];
assert.deepEqual(contents, expectedContents);
});
});
it('when the given component unit has no index file [More Test]', () => {
let sourceFile = path.join(rootPath, 'bar/baz/baz.component.ts');
return dependentFilesUtils.getDependentFiles(sourceFile, rootPath)
.then((contents: dependentFilesUtils.ModuleMap) => {
let expectedContents: dependentFilesUtils.ModuleMap = {};
let barFile = path.join(rootPath, 'bar/bar.component.ts');
let fooFile = path.join(rootPath, 'foo/foo.component.ts');
expectedContents[barFile] = [{
specifierText: './baz/baz.component',
pos: 13,
end: 35
}];
expectedContents[fooFile] = [{
specifierText: '../bar/baz/baz.component',
pos: 13,
end: 40
}];
assert.deepEqual(contents, expectedContents);
});
});
it('when there are no dependent files', () => {
let sourceFile = path.join(rootPath, 'foo-baz/no-module.component.ts');
return dependentFilesUtils.getDependentFiles(sourceFile, rootPath)
.then((contents: dependentFilesUtils.ModuleMap) => {
assert.deepEqual(contents, {});
});
});
});
});
4 changes: 3 additions & 1 deletion typings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"dependencies": {},
"dependencies": {
"es6-promise": "registry:npm/es6-promise#3.0.0+20160211003958"
},
"devDependencies": {
"chalk": "github:typings/typed-chalk#a7e422c5455e70292e5675a727d43a7b05fc3e58"
},
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.