-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build: separate demo-app in its own directory. #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| /.idea | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| /.sass-cache | ||
| /connect.lock | ||
| /coverage/* | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const environment = { | ||
| production: false | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const environment = { | ||
| production: true | ||
| }; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/usr/bin/env node | ||
| 'use strict'; | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const glob = require('glob'); | ||
|
|
||
| /** | ||
| * Simple Promiseify function that takes a Node API and return a version that supports promises. | ||
| * We use promises instead of synchronized functions to make the process less I/O bound and | ||
| * faster. It also simplify the code. | ||
| */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment for why you need this function in this script.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| function promiseify(fn) { | ||
| return function() { | ||
| const args = [].slice.call(arguments, 0); | ||
| return new Promise((resolve, reject) => { | ||
| fn.apply(this, args.concat([function (err, value) { | ||
| if (err) { | ||
| reject(err); | ||
| } else { | ||
| resolve(value); | ||
| } | ||
| }])); | ||
| }); | ||
| }; | ||
| } | ||
|
|
||
| const readFile = promiseify(fs.readFile); | ||
| const writeFile = promiseify(fs.writeFile); | ||
|
|
||
|
|
||
| /** | ||
| * For every argument, inline the templates and styles under it and write the new file. | ||
| */ | ||
| for (let arg of process.argv.slice(2)) { | ||
| if (arg.indexOf('*') < 0) { | ||
| // Argument is a directory target, add glob patterns to include every files. | ||
| arg = path.join(arg, '**', '*'); | ||
| } | ||
|
|
||
| const files = glob.sync(arg, {}) | ||
| .filter(name => /\.js$/.test(name)); // Matches only JavaScript files. | ||
|
|
||
| // Generate all files content with inlined templates. | ||
| files.forEach(filePath => { | ||
| readFile(filePath, 'utf-8') | ||
| .then(content => inlineTemplate(filePath, content)) | ||
| .then(content => inlineStyle(filePath, content)) | ||
| .then(content => writeFile(filePath, content)) | ||
| .catch(err => { | ||
| console.error('An error occured: ', err); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Inline the templates for a source file. Simply search for instances of `templateUrl: ...` and | ||
| * replace with `template: ...` (with the content of the file included). | ||
| * @param filePath {string} The path of the source file. | ||
| * @param content {string} The source file's content. | ||
| * @return {string} The content with all templates inlined. | ||
| */ | ||
| function inlineTemplate(filePath, content) { | ||
| return content.replace(/templateUrl:\s*'([^']+\.html)'/g, function(m, templateUrl) { | ||
| const templateFile = path.join(path.dirname(filePath), templateUrl); | ||
| const templateContent = fs.readFileSync(templateFile, 'utf-8'); | ||
| const shortenedTemplate = templateContent | ||
| .replace(/([\n\r]\s*)+/gm, ' ') | ||
| .replace(/"/g, '\\"'); | ||
| return `template: "${shortenedTemplate}"`; | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Inline the styles for a source file. Simply search for instances of `styleUrls: [...]` and | ||
| * replace with `styles: [...]` (with the content of the file included). | ||
| * @param filePath {string} The path of the source file. | ||
| * @param content {string} The source file's content. | ||
| * @return {string} The content with all styles inlined. | ||
| */ | ||
| function inlineStyle(filePath, content) { | ||
| return content.replace(/styleUrls:\s*(\[[\s\S]*?\])/gm, function(m, styleUrls) { | ||
| const urls = eval(styleUrls); | ||
| return 'styles: [' | ||
| + urls.map(styleUrl => { | ||
| const styleFile = path.join(path.dirname(filePath), styleUrl); | ||
| const styleContent = fs.readFileSync(styleFile, 'utf-8'); | ||
| const shortenedStyle = styleContent | ||
| .replace(/([\n\r]\s*)+/gm, ' ') | ||
| .replace(/"/g, '\\"'); | ||
| return `"${shortenedStyle}"`; | ||
| }) | ||
| .join(',\n') | ||
| + ']'; | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file would use some high-level comments explaining what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some.