Skip to content

Commit 2beb41d

Browse files
committed
First draft of the all package
1 parent ac86ddf commit 2beb41d

Some content is hidden

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

82 files changed

+338
-930
lines changed

scripts/ci/forbidden-identifiers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function isRelativeScopeImport(fileName, line) {
185185

186186
// Creates a valid import statement, which uses the correct scope package.
187187
let importFilePath = path.relative(importScope.path, importPath);
188-
let validImportPath = `@angular2-material/${importScope.name}/${importFilePath}`;
188+
let validImportPath = `@angular/material/${importScope.name}/${importFilePath}`;
189189

190190
return {
191191
fileScope: fileScope.name,

scripts/release/inline-resources.js

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ const writeFile = promiseify(fs.writeFile);
3030

3131

3232
function inlineResources(globs) {
33+
if (typeof globs == 'string') {
34+
globs = [globs];
35+
}
36+
3337
/**
3438
* For every argument, inline the templates and styles under it and write the new file.
3539
*/
36-
for (let pattern of globs) {
40+
return Promise.all(globs.map(pattern => {
3741
if (pattern.indexOf('*') < 0) {
3842
// Argument is a directory target, add glob patterns to include every files.
3943
pattern = path.join(pattern, '**', '*');
@@ -43,17 +47,32 @@ function inlineResources(globs) {
4347
.filter(name => /\.js$/.test(name)); // Matches only JavaScript files.
4448

4549
// Generate all files content with inlined templates.
46-
files.forEach(filePath => {
47-
readFile(filePath, 'utf-8')
48-
.then(content => inlineTemplate(filePath, content))
49-
.then(content => inlineStyle(filePath, content))
50-
.then(content => removeModuleId(filePath, content))
50+
return Promise.all(files.map(filePath => {
51+
return readFile(filePath, 'utf-8')
52+
.then(content => inlineResourcesFromString(content, url => {
53+
return path.join(path.dirname(filePath), url);
54+
}))
5155
.then(content => writeFile(filePath, content))
5256
.catch(err => {
5357
console.error('An error occured: ', err);
5458
});
55-
});
56-
}
59+
}));
60+
}));
61+
}
62+
63+
/**
64+
* Inline resources from a string content.
65+
* @param content {string} The source file's content.
66+
* @param urlResolver {Function} A resolver that takes a URL and return a path.
67+
* @returns {string} The content with resources inlined.
68+
*/
69+
function inlineResourcesFromString(content, urlResolver) {
70+
// Curry through the inlining functions.
71+
return [
72+
inlineTemplate,
73+
inlineStyle,
74+
removeModuleId
75+
].reduce((content, fn) => fn(content, urlResolver), content);
5776
}
5877

5978
if (require.main === module) {
@@ -64,13 +83,13 @@ if (require.main === module) {
6483
/**
6584
* Inline the templates for a source file. Simply search for instances of `templateUrl: ...` and
6685
* replace with `template: ...` (with the content of the file included).
67-
* @param filePath {string} The path of the source file.
6886
* @param content {string} The source file's content.
87+
* @param urlResolver {Function} A resolver that takes a URL and return a path.
6988
* @return {string} The content with all templates inlined.
7089
*/
71-
function inlineTemplate(filePath, content) {
90+
function inlineTemplate(content, urlResolver) {
7291
return content.replace(/templateUrl:\s*'([^']+?\.html)'/g, function(m, templateUrl) {
73-
const templateFile = path.join(path.dirname(filePath), templateUrl);
92+
const templateFile = urlResolver(templateUrl);
7493
const templateContent = fs.readFileSync(templateFile, 'utf-8');
7594
const shortenedTemplate = templateContent
7695
.replace(/([\n\r]\s*)+/gm, ' ')
@@ -83,16 +102,16 @@ function inlineTemplate(filePath, content) {
83102
/**
84103
* Inline the styles for a source file. Simply search for instances of `styleUrls: [...]` and
85104
* replace with `styles: [...]` (with the content of the file included).
86-
* @param filePath {string} The path of the source file.
105+
* @param urlResolver {Function} A resolver that takes a URL and return a path.
87106
* @param content {string} The source file's content.
88107
* @return {string} The content with all styles inlined.
89108
*/
90-
function inlineStyle(filePath, content) {
109+
function inlineStyle(content, urlResolver) {
91110
return content.replace(/styleUrls:\s*(\[[\s\S]*?\])/gm, function(m, styleUrls) {
92111
const urls = eval(styleUrls);
93112
return 'styles: ['
94113
+ urls.map(styleUrl => {
95-
const styleFile = path.join(path.dirname(filePath), styleUrl);
114+
const styleFile = urlResolver(styleUrl);
96115
const styleContent = fs.readFileSync(styleFile, 'utf-8');
97116
const shortenedStyle = styleContent
98117
.replace(/([\n\r]\s*)+/gm, ' ')
@@ -107,13 +126,13 @@ function inlineStyle(filePath, content) {
107126

108127
/**
109128
* Remove every mention of `moduleId: module.id`.
110-
* @param _ {string} The file path of the source file, currently ignored.
111129
* @param content {string} The source file's content.
112130
* @returns {string} The content with all moduleId: mentions removed.
113131
*/
114-
function removeModuleId(_, content) {
132+
function removeModuleId(content) {
115133
return content.replace(/\s*moduleId:\s*module\.id\s*,?\s*/gm, '');
116134
}
117135

118136

119137
module.exports = inlineResources;
138+
module.exports.inlineResourcesFromString = inlineResourcesFromString;

src/demo-app/button-toggle/button-toggle-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MdUniqueSelectionDispatcher} from '@angular2-material/core';
2+
import {MdUniqueSelectionDispatcher} from '@angular/material';
33

44
@Component({
55
moduleId: module.id,

src/demo-app/demo-app-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {HttpModule} from '@angular/http';
44
import {FormsModule} from '@angular/forms';
55
import {DemoApp, Home} from './demo-app/demo-app';
66
import {RouterModule} from '@angular/router';
7-
import {MaterialModule} from '@angular2-material/all';
7+
import {MaterialModule} from '@angular/material';
88
import {DEMO_APP_ROUTES} from './demo-app/routes';
99
import {ProgressBarDemo} from './progress-bar/progress-bar-demo';
1010
import {JazzDialog, DialogDemo} from './dialog/dialog-demo';

src/demo-app/dialog/dialog-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, ViewContainerRef} from '@angular/core';
2-
import {MdDialog, MdDialogConfig, MdDialogRef} from '@angular2-material/dialog';
2+
import {MdDialog, MdDialogConfig, MdDialogRef} from '@angular/material';
33

44
@Component({
55
moduleId: module.id,

src/demo-app/grid-list/grid-list-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MdIconRegistry} from '@angular2-material/icon';
2+
import {MdIconRegistry} from '@angular/material';
33

44

55
@Component({

src/demo-app/icon/icon-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, ViewEncapsulation} from '@angular/core';
2-
import {MdIconRegistry} from '@angular2-material/icon';
2+
import {MdIconRegistry} from '@angular/material';
33

44
@Component({
55
moduleId: module.id,

src/demo-app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<link rel="icon" type="image/x-icon" href="favicon.ico">
1010
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
11-
<link href="@angular2-material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
11+
<link href="@angular/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
1212

1313
<!-- FontAwesome for md-icon demo. -->
1414
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

src/demo-app/live-announcer/live-announcer-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MdLiveAnnouncer} from '@angular2-material/core';
2+
import {MdLiveAnnouncer} from '@angular/material';
33

44
@Component({
55
moduleId: module.id,

src/demo-app/overlay/overlay-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ComponentPortal,
1414
Portal,
1515
TemplatePortalDirective,
16-
} from '@angular2-material/core';
16+
} from '@angular/material';
1717

1818

1919
@Component({

src/demo-app/portal/portal-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
Portal,
44
ComponentPortal,
55
TemplatePortalDirective,
6-
} from '@angular2-material/core';
6+
} from '@angular/material';
77

88

99
@Component({

src/demo-app/ripple/ripple-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, ViewChild} from '@angular/core';
2-
import {MdRipple} from '@angular2-material/core';
2+
import {MdRipple} from '@angular/material';
33

44

55
@Component({

src/demo-app/system-config.ts

Lines changed: 35 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,17 @@
22
* User Configuration.
33
**********************************************************************************************/
44

5-
const components = [
6-
'all',
7-
'button',
8-
'card',
9-
'checkbox',
10-
'dialog',
11-
'grid-list',
12-
'icon',
13-
'input',
14-
'list',
15-
'menu',
16-
'progress-bar',
17-
'progress-circle',
18-
'radio',
19-
'select',
20-
'sidenav',
21-
'slider',
22-
'slide-toggle',
23-
'button-toggle',
24-
'tabs',
25-
'toolbar',
26-
'tooltip',
27-
];
28-
29-
30-
/** User packages configuration. */
31-
const packages: any = {
32-
'@angular2-material/core': {
33-
format: 'cjs',
34-
main: 'core.umd.js'
35-
},
36-
// Set the default extension for the root package, because otherwise the demo-app can't
37-
// be built within the production mode. Due to missing file extensions.
38-
'.': {
39-
defaultExtension: 'js'
40-
}
41-
};
42-
components.forEach(name => {
43-
packages[`@angular2-material/${name}`] = {
44-
format: 'cjs',
45-
main: `${name}.umd.js`
46-
};
47-
});
48-
49-
50-
////////////////////////////////////////////////////////////////////////////////////////////////
51-
/***********************************************************************************************
52-
* Everything underneath this line is managed by the CLI.
53-
**********************************************************************************************/
54-
const angularPackages = {
5+
const angularDeps = [
556
// Angular specific barrels.
56-
'@angular/core': { main: 'bundles/core.umd.js'},
57-
'@angular/core/testing': { main: 'bundles/core-testing.umd.js'},
58-
'@angular/common': { main: 'bundles/common.umd.js'},
59-
'@angular/compiler': { main: 'bundles/compiler.umd.js'},
60-
'@angular/http': { main: 'bundles/http.umd.js'},
61-
'@angular/forms': { main: 'bundles/forms.umd.js'},
62-
'@angular/router': { main: 'bundles/router.umd.js'},
63-
'@angular/platform-browser': { main: 'bundles/platform-browser.umd.js'},
64-
'@angular/platform-browser-dynamic': { main: 'bundles/platform-browser-dynamic.umd.js'},
65-
'@angular/platform-browser-dynamic/testing': {
66-
main: 'bundles/platform-browser-dynamic-testing.umd.js'
67-
},
68-
};
7+
'@angular/core',
8+
'@angular/common',
9+
'@angular/compiler',
10+
'@angular/http',
11+
'@angular/forms',
12+
'@angular/router',
13+
'@angular/platform-browser',
14+
'@angular/platform-browser-dynamic',
15+
];
6916

7017
const barrels: string[] = [
7118
// Thirdparty barrels.
@@ -78,27 +25,40 @@ const barrels: string[] = [
7825
'live-announcer',
7926
'portal',
8027
'overlay',
81-
...components
82-
/** @cli-barrel */
8328
];
8429

85-
const _cliSystemConfig: any = angularPackages;
30+
31+
const angularPackages: any = angularDeps.reduce((config: any, pkg: string) => {
32+
config[pkg] = { main: `bundles/${pkg.replace('@angular/', '')}.umd.js` };
33+
return config;
34+
}, {});
8635
barrels.forEach((barrelName: string) => {
87-
_cliSystemConfig[barrelName] = { main: 'index' };
36+
angularPackages[barrelName] = { main: 'index' };
8837
});
8938

39+
const angularMaps: any = angularDeps.reduce((config: any, pkg: string) => {
40+
config[pkg] = `vendor/${pkg}`;
41+
return config;
42+
}, {});
43+
9044
/** Type declaration for ambient System. */
9145
declare var System: any;
9246

9347
// Apply the CLI SystemJS configuration.
9448
System.config({
95-
map: {
96-
'@angular': 'vendor/@angular',
49+
map: Object.assign({
9750
'rxjs': 'vendor/rxjs',
98-
'main': 'main.js'
99-
},
100-
packages: _cliSystemConfig
51+
'main': 'main.js',
52+
}, angularMaps),
53+
packages: Object.assign({
54+
'@angular/material': {
55+
format: 'cjs',
56+
main: 'material.umd.js'
57+
},
58+
// Set the default extension for the root package, because otherwise the demo-app can't
59+
// be built within the production mode. Due to missing file extensions.
60+
'.': {
61+
defaultExtension: 'js'
62+
}
63+
}, angularPackages)
10164
});
102-
103-
// Apply the user's configuration.
104-
System.config({ packages });

src/demo-app/tooltip/tooltip-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {TooltipPosition} from '@angular2-material/tooltip';
2+
import {TooltipPosition} from '@angular/material';
33

44

55
@Component({

src/demo-app/tsconfig.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
"stripInternal": true,
1616
"baseUrl": "",
1717
"typeRoots": [
18-
"../../node_modules/@types",
19-
"../../node_modules"
18+
"../../node_modules/@types"
2019
],
2120
"paths": {
22-
"@angular2-material/*": [
23-
"../../dist/@angular2-material/*"
21+
"@angular/material": [
22+
"../../dist/@angular/material"
2423
]
2524
},
2625
"types": [

src/e2e-app/e2e-app-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {IconE2E} from './icon/icon-e2e';
66
import {ButtonE2E} from './button/button-e2e';
77
import {MenuE2E} from './menu/menu-e2e';
88
import {BasicTabs} from './tabs/tabs-e2e';
9-
import {MaterialModule} from '@angular2-material/all';
9+
import {MaterialModule} from '@angular/material';
1010
import {E2E_APP_ROUTES} from './e2e-app/routes';
1111

1212

src/e2e-app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<link rel="icon" type="image/x-icon" href="favicon.ico">
1010
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
11-
<link href="@angular2-material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
11+
<link href="@angular/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
1212

1313
<!-- FontAwesome for md-icon demo. -->
1414
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

0 commit comments

Comments
 (0)