Skip to content

Commit cf0b502

Browse files
Ali KorabbasluAli Korabbaslu
Ali Korabbaslu
authored and
Ali Korabbaslu
committed
init
0 parents  commit cf0b502

Some content is hidden

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

86 files changed

+16305
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Builds a Docker to deliver dist/
2+
FROM nginx:latest
3+
COPY dist/ /usr/share/nginx/html

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015-2016 AngularClass LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+383
Large diffs are not rendered by default.

config/.DS_Store

6 KB
Binary file not shown.

config/github-deploy/index.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const helpers = require('../helpers');
2+
const execSync = require('child_process').execSync;
3+
4+
const REPO_NAME_RE = /Push {2}URL: https:\/\/github\.com\/.*\/(.*)\.git/;
5+
6+
function getWebpackConfigModule() {
7+
if (helpers.hasProcessFlag('github-dev')) {
8+
return require('../webpack.dev.js');
9+
} else if (helpers.hasProcessFlag('github-prod')) {
10+
return require('../webpack.prod.js');
11+
} else {
12+
throw new Error('Invalid compile option.');
13+
}
14+
}
15+
16+
function getRepoName(remoteName) {
17+
remoteName = remoteName || 'origin';
18+
19+
var stdout = execSync('git remote show ' + remoteName),
20+
match = REPO_NAME_RE.exec(stdout);
21+
22+
if (!match) {
23+
throw new Error('Could not find a repository on remote ' + remoteName);
24+
} else {
25+
return match[1];
26+
}
27+
}
28+
29+
function stripTrailing(str, char) {
30+
31+
if (str[0] === char) {
32+
str = str.substr(1);
33+
}
34+
35+
if (str.substr(-1) === char) {
36+
str = str.substr(0, str.length - 1);
37+
}
38+
39+
return str;
40+
}
41+
42+
/**
43+
* Given a string remove trailing slashes and adds 1 slash at the end of the string.
44+
*
45+
* Example:
46+
* safeUrl('/value/')
47+
* // 'value/'
48+
*
49+
* @param url
50+
* @returns {string}
51+
*/
52+
function safeUrl(url) {
53+
const stripped = stripTrailing(url || '', '/');
54+
return stripped ? stripped + '/' : '';
55+
}
56+
57+
exports.getWebpackConfigModule = getWebpackConfigModule;
58+
exports.getRepoName = getRepoName;
59+
exports.safeUrl = safeUrl;

config/head-config.common.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Configuration for head elements added during the creation of index.html.
3+
*
4+
* All href attributes are added the publicPath (if exists) by default.
5+
* You can explicitly hint to prefix a publicPath by setting a boolean value to a key that has
6+
* the same name as the attribute you want to operate on, but prefix with =
7+
*
8+
* Example:
9+
* { name: 'msapplication-TileImage', content: '/assets/icon/ms-icon-144x144.png', '=content': true },
10+
* Will prefix the publicPath to content.
11+
*
12+
* { rel: 'apple-touch-icon', sizes: '57x57', href: '/assets/icon/apple-icon-57x57.png', '=href': false },
13+
* Will not prefix the publicPath on href (href attributes are added by default
14+
*
15+
*/
16+
module.exports = {
17+
link: [
18+
/** <link> tags for 'apple-touch-icon' (AKA Web Clips). **/
19+
{ rel: 'apple-touch-icon', sizes: '57x57', href: '/assets/icon/apple-icon-57x57.png' },
20+
{ rel: 'apple-touch-icon', sizes: '60x60', href: '/assets/icon/apple-icon-60x60.png' },
21+
{ rel: 'apple-touch-icon', sizes: '72x72', href: '/assets/icon/apple-icon-72x72.png' },
22+
{ rel: 'apple-touch-icon', sizes: '76x76', href: '/assets/icon/apple-icon-76x76.png' },
23+
{ rel: 'apple-touch-icon', sizes: '114x114', href: '/assets/icon/apple-icon-114x114.png' },
24+
{ rel: 'apple-touch-icon', sizes: '120x120', href: '/assets/icon/apple-icon-120x120.png' },
25+
{ rel: 'apple-touch-icon', sizes: '144x144', href: '/assets/icon/apple-icon-144x144.png' },
26+
{ rel: 'apple-touch-icon', sizes: '152x152', href: '/assets/icon/apple-icon-152x152.png' },
27+
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/assets/icon/apple-icon-180x180.png' },
28+
29+
/** <link> tags for android web app icons **/
30+
{ rel: 'icon', type: 'image/png', sizes: '192x192', href: '/assets/icon/android-icon-192x192.png' },
31+
32+
/** <link> tags for favicons **/
33+
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: '/assets/icon/favicon-32x32.png' },
34+
{ rel: 'icon', type: 'image/png', sizes: '96x96', href: '/assets/icon/favicon-96x96.png' },
35+
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: '/assets/icon/favicon-16x16.png' },
36+
37+
/** <link> tags for a Web App Manifest **/
38+
{ rel: 'manifest', href: '/assets/manifest.json' }
39+
],
40+
meta: [
41+
{ name: 'msapplication-TileColor', content: '#00bcd4' },
42+
{ name: 'msapplication-TileImage', content: '/assets/icon/ms-icon-144x144.png', '=content': true },
43+
{ name: 'theme-color', content: '#00bcd4' }
44+
]
45+
};

config/helpers.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @author: @AngularClass
3+
*/
4+
var path = require('path');
5+
6+
// Helper functions
7+
var ROOT = path.resolve(__dirname, '..');
8+
9+
function hasProcessFlag(flag) {
10+
return process.argv.join('').indexOf(flag) > -1;
11+
}
12+
13+
function isWebpackDevServer() {
14+
return process.argv[1] && !! (/webpack-dev-server/.exec(process.argv[1]));
15+
}
16+
17+
function root(args) {
18+
args = Array.prototype.slice.call(arguments, 0);
19+
return path.join.apply(path, [ROOT].concat(args));
20+
}
21+
22+
exports.hasProcessFlag = hasProcessFlag;
23+
exports.isWebpackDevServer = isWebpackDevServer;
24+
exports.root = root;

config/html-elements-plugin/index.js

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
function HtmlElementsPlugin(locations) {
3+
this.locations = locations;
4+
}
5+
6+
HtmlElementsPlugin.prototype.apply = function(compiler) {
7+
var self = this;
8+
compiler.plugin('compilation', function(compilation) {
9+
compilation.options.htmlElements = compilation.options.htmlElements || {};
10+
11+
compilation.plugin('html-webpack-plugin-before-html-generation', function(htmlPluginData, callback) {
12+
const locations = self.locations;
13+
14+
if (locations) {
15+
const publicPath = htmlPluginData.assets.publicPath;
16+
17+
Object.getOwnPropertyNames(locations).forEach(function(loc) {
18+
compilation.options.htmlElements[loc] = getHtmlElementString(locations[loc], publicPath);
19+
});
20+
}
21+
22+
23+
callback(null, htmlPluginData);
24+
});
25+
});
26+
27+
};
28+
29+
const RE_ENDS_WITH_BS = /\/$/;
30+
31+
/**
32+
* Create an HTML tag with attributes from a map.
33+
*
34+
* Example:
35+
* createTag('link', { rel: "manifest", href: "/assets/manifest.json" })
36+
* // <link rel="manifest" href="/assets/manifest.json">
37+
* @param tagName The name of the tag
38+
* @param attrMap A Map of attribute names (keys) and their values.
39+
* @param publicPath a path to add to eh start of static asset url
40+
* @returns {string}
41+
*/
42+
function createTag(tagName, attrMap, publicPath) {
43+
publicPath = publicPath || '';
44+
45+
// add trailing slash if we have a publicPath and it doesn't have one.
46+
if (publicPath && !RE_ENDS_WITH_BS.test(publicPath)) {
47+
publicPath += '/';
48+
}
49+
50+
const attributes = Object.getOwnPropertyNames(attrMap)
51+
.filter(function(name) { return name[0] !== '='; } )
52+
.map(function(name) {
53+
var value = attrMap[name];
54+
55+
if (publicPath) {
56+
// check if we have explicit instruction, use it if so (e.g: =herf: false)
57+
// if no instruction, use public path if it's href attribute.
58+
const usePublicPath = attrMap.hasOwnProperty('=' + name) ? !!attrMap['=' + name] : name === 'href';
59+
60+
if (usePublicPath) {
61+
// remove a starting trailing slash if the value has one so we wont have //
62+
value = publicPath + (value[0] === '/' ? value.substr(1) : value);
63+
}
64+
}
65+
66+
return name + '="' + value + '"';
67+
});
68+
69+
return '<' + tagName + ' ' + attributes.join(' ') + '>';
70+
}
71+
72+
/**
73+
* Returns a string representing all html elements defined in a data source.
74+
*
75+
* Example:
76+
*
77+
* const ds = {
78+
* link: [
79+
* { rel: "apple-touch-icon", sizes: "57x57", href: "/assets/icon/apple-icon-57x57.png" }
80+
* ],
81+
* meta: [
82+
* { name: "msapplication-TileColor", content: "#00bcd4" }
83+
* ]
84+
* }
85+
*
86+
* getHeadTags(ds);
87+
* // "<link rel="apple-touch-icon" sizes="57x57" href="/assets/icon/apple-icon-57x57.png">"
88+
* "<meta name="msapplication-TileColor" content="#00bcd4">"
89+
*
90+
* @returns {string}
91+
*/
92+
function getHtmlElementString(dataSource, publicPath) {
93+
return Object.getOwnPropertyNames(dataSource)
94+
.map(function(name) {
95+
if (Array.isArray(dataSource[name])) {
96+
return dataSource[name].map(function(attrs) { return createTag(name, attrs, publicPath); } );
97+
} else {
98+
return [ createTag(name, dataSource[name], publicPath) ];
99+
}
100+
})
101+
.reduce(function(arr, curr) {
102+
return arr.concat(curr);
103+
}, [])
104+
.join('\n\t');
105+
}
106+
module.exports = HtmlElementsPlugin;

config/karma.conf.js

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* @author: @AngularClass
3+
*/
4+
5+
module.exports = function(config) {
6+
var testWebpackConfig = require('./webpack.test.js')({env: 'test'});
7+
8+
var configuration = {
9+
10+
// base path that will be used to resolve all patterns (e.g. files, exclude)
11+
basePath: '',
12+
13+
/*
14+
* Frameworks to use
15+
*
16+
* available frameworks: https://npmjs.org/browse/keyword/karma-adapter
17+
*/
18+
frameworks: ['jasmine'],
19+
20+
// list of files to exclude
21+
exclude: [ ],
22+
23+
/*
24+
* list of files / patterns to load in the browser
25+
*
26+
* we are building the test environment in ./spec-bundle.js
27+
*/
28+
files: [ { pattern: './config/spec-bundle.js', watched: false } ],
29+
30+
/*
31+
* preprocess matching files before serving them to the browser
32+
* available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
33+
*/
34+
preprocessors: { './config/spec-bundle.js': ['coverage', 'webpack', 'sourcemap'] },
35+
36+
// Webpack Config at ./webpack.test.js
37+
webpack: testWebpackConfig,
38+
39+
coverageReporter: {
40+
dir : 'coverage/',
41+
reporters: [
42+
{ type: 'text-summary' },
43+
{ type: 'json' },
44+
{ type: 'html' }
45+
]
46+
},
47+
48+
// Webpack please don't spam the console when running in karma!
49+
webpackServer: { noInfo: true },
50+
51+
/*
52+
* test results reporter to use
53+
*
54+
* possible values: 'dots', 'progress'
55+
* available reporters: https://npmjs.org/browse/keyword/karma-reporter
56+
*/
57+
reporters: [ 'mocha', 'coverage' ],
58+
59+
// web server port
60+
port: 9876,
61+
62+
// enable / disable colors in the output (reporters and logs)
63+
colors: true,
64+
65+
/*
66+
* level of logging
67+
* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
68+
*/
69+
logLevel: config.LOG_INFO,
70+
71+
// enable / disable watching file and executing tests whenever any file changes
72+
autoWatch: false,
73+
74+
/*
75+
* start these browsers
76+
* available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
77+
*/
78+
browsers: [
79+
'Chrome'
80+
],
81+
82+
customLaunchers: {
83+
ChromeTravisCi: {
84+
base: 'Chrome',
85+
flags: ['--no-sandbox']
86+
}
87+
},
88+
89+
/*
90+
* Continuous Integration mode
91+
* if true, Karma captures browsers, runs the tests and exits
92+
*/
93+
singleRun: true
94+
};
95+
96+
if (process.env.TRAVIS){
97+
configuration.browsers = ['ChromeTravisCi'];
98+
}
99+
100+
config.set(configuration);
101+
};

config/modules/angular2-hmr-prod.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exports.HmrState = function() {
2+
3+
};

0 commit comments

Comments
 (0)