From 6e928ae68e71e5eef85e655d09ba89276fd0d10c Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:19:42 -0500 Subject: [PATCH 01/12] copy angular2-app change index.html to CustomMaster.html --- lib/broccoli/angular2-sharepoint-app.js | 472 ++++++++++++++++++++++++ 1 file changed, 472 insertions(+) create mode 100644 lib/broccoli/angular2-sharepoint-app.js diff --git a/lib/broccoli/angular2-sharepoint-app.js b/lib/broccoli/angular2-sharepoint-app.js new file mode 100644 index 000000000000..759d85da0e2f --- /dev/null +++ b/lib/broccoli/angular2-sharepoint-app.js @@ -0,0 +1,472 @@ +'use strict'; +const path = require('path'); +const fs = require('fs'); + +const BroccoliPlugin = require('broccoli-writer'); +const BroccoliTypescript = require('./broccoli-typescript'); +const BundlePlugin = require('./angular-broccoli-bundle'); +const BroccoliFunnel = require('broccoli-funnel'); +const BroccoliMergeTrees = require('broccoli-merge-trees'); +const BroccoliSource = require('broccoli-source'); +const UnwatchedDir = BroccoliSource.UnwatchedDir; +const Project = require('ember-cli/lib/models/project'); +const HandlebarReplace = require('./broccoli-handlebars'); +const config = require('../../addon/ng2/models/config'); +const loadEnvironment = require('./environment'); +const concat = require('broccoli-concat'); +const uglify = require('broccoli-uglify-js'); + +class Angular2SharePointApp extends BroccoliPlugin { + constructor(project, inputNode, options) { + super(); + this.ngConfig = config.CliConfig.fromProject(); + + if (!options) { + options = inputNode; + inputNode = null; + } + + options = options || {}; + + this._options = options; + this._sourceDir = options.sourceDir + || (this.ngConfig.defaults && this.ngConfig.defaults.sourceDir) + || 'src'; + this._options.polyfills = this._options.polyfills || [ + 'vendor/es6-shim/es6-shim.js', + 'vendor/reflect-metadata/Reflect.js', + 'vendor/systemjs/dist/system.src.js', + 'vendor/zone.js/dist/zone.js' + ]; + + this._destDir = options.destDir || ''; + + // By default, add all spec files to the tsCompiler. + this._tsCompiler = options.tsCompiler || { + additionalFiles: ['**/*.spec.ts'] + }; + + this._initProject(); + this._notifyAddonIncluded(); + this._inputNode = inputNode || this._buildInputTree(); + + this._tree = this._buildTree(); + } + + /** + * For backward compatibility. + * @public + * @method toTree + * @return {BroccoliPlugin} A broccoli plugin. + */ + toTree() { + // eslint-disable-next-line no-console + console.warn('Angular2App is now a broccoli plugin. Calling toTree() is deprecated.'); + return this; + } + + /** + * @override + */ + read(readTree) { + return this._tree.read(readTree); + } + + /** + * @override + */ + cleanup() { + return this._tree.cleanup(); + } + + _buildInputTree() { + const inputTreeArray = [ + new BroccoliFunnel(this._sourceDir, { destDir: this._sourceDir }), + new BroccoliFunnel('typings', { destDir: 'typings' }), + this._getConfigTree() + ]; + + if (fs.existsSync('public')) { + inputTreeArray.push(new BroccoliFunnel('public', { destDir: 'public' })); + } + + if (fs.existsSync('icons')) { + inputTreeArray.push(new BroccoliFunnel('icons', { destDir: 'icons' })); + } + + return new BroccoliMergeTrees(inputTreeArray, { overwrite: true }); + } + + /** + * Create and return the app build system tree that: + * - Get the `assets` tree + * - Get the TS tree + * - Get the TS src tree + * - Get the CustomMaster.html tree + * - Get the NPM modules tree + * - Apply/remove stuff based on the environment (dev|prod) + * - Return the app trees to be extended + * + * @private + * @method _buildTree + * @return {BroccoliFunnel} The app trees that can be used to extend the build. + */ + _buildTree() { + var assetTree = this._getAssetsTree(); + var tsTree = this._getTsTree(); + var indexTree = this._getIndexTree(); + var vendorNpmTree = this._getVendorNpmTree(); + + var buildTrees = [assetTree, tsTree, indexTree, vendorNpmTree]; + + // Add available and supported CSS plugins. + for (const suffix of ['sass', 'less', 'stylus', 'compass']) { + const plugin = require(`./angular-broccoli-${suffix}`); + const tree = plugin.makeBroccoliTree(this._inputNode, this._options[`${suffix}Compiler`]); + + if (!tree) { + continue; + } + + buildTrees.push(new BroccoliFunnel(tree, { + include: ['**/*'], + getDestinationPath: (n) => { + if (n.startsWith(this._sourceDir)) { + return n.substr(this._sourceDir.length); + } + return n; + } + })); + } + + // Add the public folder in. + buildTrees.push(new BroccoliFunnel(this._inputNode, { + allowEmpty: true, + srcDir: 'public', + name: 'PublicFolderFunnel' + })); + + var merged = new BroccoliMergeTrees(buildTrees, { overwrite: true }); + + if (this.ngConfig.apps[0].mobile) { + let AppShellPlugin = require('angular2-broccoli-prerender').AppShellPlugin; + merged = new BroccoliMergeTrees([merged, new AppShellPlugin(merged, 'CustomMaster.html', 'main-app-shell')], { + overwrite: true + }); + } + + if (loadEnvironment(this.project).production) { + merged = this._getBundleTree(merged); + } + + return new BroccoliFunnel(merged, { + destDir: this._destDir, + overwrite: true + }); + } + + + /** + * @private + * @method _initProject + * @param {Object} options + */ + _initProject() { + this.project = Project.closestSync(process.cwd()); + + // project root dir env used on angular-cli side for including packages from project + process.env.PROJECT_ROOT = process.env.PROJECT_ROOT || this.project.root; + } + + /** + * @private + * @method _notifyAddonIncluded + */ + _notifyAddonIncluded() { + this.initializeAddons(); + this.project.addons = this.project.addons.filter(function (addon) { + addon.app = this; + + if (!addon.isEnabled || addon.isEnabled()) { + if (addon.included) { + addon.included(this); + } + + return addon; + } + }, this); + } + + /** + * Loads and initializes addons for this project. + * Calls initializeAddons on the Project. + * + * @private + * @method initializeAddons + */ + initializeAddons() { + this.project.initializeAddons(); + } + + /** + * Returns the content for a specific type (section) for CustomMaster.html. + * + * Currently supported types: + * - 'head' + * //- 'config-module' + * //- 'app' + * //- 'head-footer' + * //- 'test-header-footer' + * //- 'body-footer' + * //- 'test-body-footer' + * + * Addons can also implement this method and could also define additional + * types (eg. 'some-addon-section'). + * + * @private + * @method _contentFor + * @param {RegExP} match Regular expression to match against + * @param {String} type Type of content + * @return {String} The content. + */ + _contentFor(match, type) { + var content = []; + + /*switch (type) { + case 'head': this._contentForHead(content, config); break; + case 'config-module': this._contentForConfigModule(content, config); break; + case 'app-boot': this._contentForAppBoot(content, config); break; + }*/ + content = this.project.addons.reduce(function (content, addon) { + var addonContent = addon.contentFor ? addon.contentFor(type) : null; + if (addonContent) { + return content.concat(addonContent); + } + + return content; + }, content); + + return content.join('\n'); + } + + /** + * Returns the tree for app/CustomMasterhtml. + * + * @private + * @method _getIndexTree + * @return {Tree} Tree for app/CustomMaster.html. + */ + _getIndexTree() { + var files = [ + 'CustomMaster.html' + ]; + var mobile; + + let indexTree = new BroccoliFunnel(this._inputNode, { + include: files.map(name => path.join(this._sourceDir, name)), + getDestinationPath: (n) => { + if (n.startsWith(this._sourceDir)) { + return n.substr(this._sourceDir.length); + } + return n; + } + }); + + if (this.ngConfig.apps[0].mobile) { + mobile = { + icons: [ + { rel: 'apple-touch-icon', href: '/icons/apple-touch-icon.png' }, + { rel: 'apple-touch-icon', sizes: '57x57', href: '/icons/apple-touch-icon-57x57.png' }, + { rel: 'apple-touch-icon', sizes: '60x60', href: '/icons/apple-touch-icon-60x60.png' }, + { rel: 'apple-touch-icon', sizes: '72x72', href: '/icons/apple-touch-icon-72x72.png' }, + { rel: 'apple-touch-icon', sizes: '76x76', href: '/icons/apple-touch-icon-76x76.png' }, + { rel: 'apple-touch-icon', sizes: '114x114', href: '/icons/apple-touch-icon-114x114.png' }, + { rel: 'apple-touch-icon', sizes: '120x120', href: '/icons/apple-touch-icon-120x120.png' }, + { rel: 'apple-touch-icon', sizes: '144x144', href: '/icons/apple-touch-icon-144x144.png' }, + { rel: 'apple-touch-icon', sizes: '152x152', href: '/icons/apple-touch-icon-152x152.png' }, + { rel: 'apple-touch-icon', sizes: '180x180', href: '/icons/apple-touch-icon-180x180.png' }, + { rel: 'apple-touch-startup-image', href: '/icons/apple-touch-icon-180x180.png' } + ] + } + } + + return new HandlebarReplace(indexTree, { + config: this.ngConfig, + environment: loadEnvironment(this.project), + scripts: { + polyfills: this._options.polyfills + }, + mobile: mobile + }, { + helpers: { + 'content-for': (name) => { + // TODO: remove content-for. + // eslint-disable-next-line no-console + console.warn('"{{content-for}}" has been deprecated and will be removed before RC.'); + return this._contentFor(null, name); + } + } + }); + } + + /** + * Returns the TS tree. + * + * @private + * @method _getTsTree + * @return {Tree} Tree for TypeScript files. + */ + _getTsTree() { + var tsConfigPath = path.join(this._sourceDir, 'tsconfig.json'); + var tsTree = new BroccoliTypescript(this._inputNode, tsConfigPath, this._tsCompiler); + + var tsTreeExcludes = ['*.d.ts', 'tsconfig.json']; + var excludeSpecFiles = '**/*.spec.*'; + + if (loadEnvironment(this.project).production) { + tsTreeExcludes.push(excludeSpecFiles); + } + + tsTree = new BroccoliFunnel(tsTree, { + srcDir: this._sourceDir, + exclude: tsTreeExcludes + }); + + return tsTree; + } + + + /** + * Returns the `vendorNpm` tree by merging the CLI dependencies plus the ones + * passed by the user. + * + * @private + * @method _getVendorNpmTree + * @return {Tree} The NPM tree. + */ + _getVendorNpmTree() { + var vendorNpmFiles = [ + ]; + + if (this.ngConfig.apps[0].mobile) { + vendorNpmFiles.push('@angular/service-worker/dist/worker.js') + } + + if (this._options.vendorNpmFiles) { + vendorNpmFiles = vendorNpmFiles.concat(this._options.vendorNpmFiles); + } + + return new BroccoliFunnel(new UnwatchedDir('node_modules'), { + include: vendorNpmFiles, + destDir: 'vendor', + name: 'vendor' + }); + } + + /** + * Returns the `assets` tree. + * + * @private + * @method _getAssetsTree + * @return {Tree} The assets tree. + */ + _getAssetsTree() { + return new BroccoliFunnel(this._inputNode, { + srcDir: this._sourceDir, + exclude: [ + '**/*.ts', + '**/*.scss', + '**/*.sass', + '**/*.less', + '**/*.styl', + '**/tsconfig.json' + ], + allowEmpty: true + }); + } + + /** + * Returns the config files tree. + * + * @private + * @method _getConfigTree + * @return {Tree} The config files tree. + */ + _getConfigTree() { + const isProduction = loadEnvironment(this.project).production; + var envConfigFile = isProduction ? 'environment.prod.ts' : 'environment.dev.ts'; + + return new BroccoliFunnel('config', { + include: [envConfigFile], + destDir: `${this._sourceDir}/app`, + getDestinationPath: () => 'environment.ts' + }); + } + + _getBundleTree(preBundleTree){ + var vendorTree = this._getVendorNpmTree(); + var assetsTree = this._getAssetsTree(); + + var scriptTree = new BroccoliFunnel(preBundleTree, { + include: this._options.polyfills + }); + + var nonJsTree = new BroccoliFunnel(preBundleTree, { + exclude: ['**/*.js', '**/*.js.map'] + }); + var jsTree = new BroccoliFunnel(preBundleTree, { + include: ['**/*.js', '**/*.js.map'] + }); + + var bundleTree = new BundlePlugin([jsTree]); + + if (this.ngConfig.apps[0].mobile) { + bundleTree = concat(BroccoliMergeTrees([vendorTree, jsTree, scriptTree, bundleTree], { + overwrite: true + }), { + headerFiles: this._options.polyfills.concat([ + 'system-config.js', + 'main.js', + 'app/CustomMaster.js' + ]), + inputFiles: [ + 'system-import.js' + ], + header: ';(function() {', + footer: '}());', + sourceMapConfig: { enabled: true }, + allowNone: false, + outputFile: '/app-concat.js' + }); + + bundleTree = uglify(bundleTree, { + mangle: false + }); + + // Required here since the package isn't installed for non-mobile apps. + var ServiceWorkerPlugin = require('@angular/service-worker').ServiceWorkerPlugin; + // worker.js is needed so it can be copied to dist + var workerJsTree = new BroccoliFunnel(jsTree, { + include: ['vendor/@angular/service-worker/dist/worker.js'] + }); + /** + * ServiceWorkerPlugin will automatically pre-fetch and cache every file + * in the tree it receives, so it should only receive the app bundle, + * and non-JS static files from the app. The plugin also needs to have + * the worker.js file available so it can copy it to dist. + **/ + var swTree = new ServiceWorkerPlugin(BroccoliMergeTrees([ + bundleTree, + assetsTree, + workerJsTree + ])); + bundleTree = BroccoliMergeTrees([bundleTree, swTree], { + overwrite: true + }); + } + + return BroccoliMergeTrees([nonJsTree, scriptTree, bundleTree], { overwrite: true }); + } +} + +module.exports = Angular2App; From 184c44b255b0095cd9b94ea8a9deba15204cd8d0 Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:36:11 -0500 Subject: [PATCH 02/12] add custom master files, copy from ng2 files --- .../CustomMaster/files/.clang-format | 3 + .../CustomMaster/files/.editorconfig | 14 ++ .../files/__path__/CustomMaster.html | 127 ++++++++++++++++++ .../app/__name__.component.__styleext__ | 0 .../__path__/app/__name__.component.html | 3 + .../__path__/app/__name__.component.spec.ts | 22 +++ .../files/__path__/app/__name__.component.ts | 18 +++ .../files/__path__/app/environment.ts | 7 + .../CustomMaster/files/__path__/app/index.ts | 2 + .../files/__path__/app/shared/index.ts | 0 .../CustomMaster/files/__path__/favicon.ico | Bin 0 -> 5430 bytes .../CustomMaster/files/__path__/index.html | 65 +++++++++ .../CustomMaster/files/__path__/main.ts | 11 ++ .../files/__path__/system-config.ts | 55 ++++++++ .../CustomMaster/files/__path__/tsconfig.json | 23 ++++ .../CustomMaster/files/__path__/typings.d.ts | 2 + .../CustomMaster/files/angular-cli-build.js | 17 +++ .../CustomMaster/files/angular-cli.json | 32 +++++ .../files/config/environment.dev.ts | 3 + .../CustomMaster/files/config/environment.js | 10 ++ .../files/config/environment.prod.ts | 3 + .../files/config/karma-test-shim.js | 51 +++++++ .../CustomMaster/files/config/karma.conf.js | 42 ++++++ .../files/config/protractor.conf.js | 29 ++++ .../CustomMaster/files/e2e/app.e2e.ts | 14 ++ .../CustomMaster/files/e2e/app.po.ts | 9 ++ .../CustomMaster/files/e2e/tsconfig.json | 17 +++ .../CustomMaster/files/e2e/typings.d.ts | 1 + .../blueprints/CustomMaster/files/gitignore | 29 ++++ .../CustomMaster/files/package.json | 52 +++++++ .../CustomMaster/files/public/.gitignore | 0 .../CustomMaster/files/public/.npmignore | 0 .../blueprints/CustomMaster/files/tslint.json | 72 ++++++++++ .../CustomMaster/files/typings.json | 11 ++ addon/ng2/blueprints/CustomMaster/index.js | 67 +++++++++ 35 files changed, 811 insertions(+) create mode 100644 addon/ng2/blueprints/CustomMaster/files/.clang-format create mode 100644 addon/ng2/blueprints/CustomMaster/files/.editorconfig create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/index.html create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/main.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/gitignore create mode 100644 addon/ng2/blueprints/CustomMaster/files/package.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.gitignore create mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.npmignore create mode 100644 addon/ng2/blueprints/CustomMaster/files/tslint.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/typings.json create mode 100644 addon/ng2/blueprints/CustomMaster/index.js diff --git a/addon/ng2/blueprints/CustomMaster/files/.clang-format b/addon/ng2/blueprints/CustomMaster/files/.clang-format new file mode 100644 index 000000000000..8d1c3c310286 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/.clang-format @@ -0,0 +1,3 @@ +Language: JavaScript +BasedOnStyle: Google +ColumnLimit: 100 diff --git a/addon/ng2/blueprints/CustomMaster/files/.editorconfig b/addon/ng2/blueprints/CustomMaster/files/.editorconfig new file mode 100644 index 000000000000..20380c701c90 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/.editorconfig @@ -0,0 +1,14 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html new file mode 100644 index 000000000000..6d554e75856a --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
In true previews of your site, the SharePoint ribbon will be here.
+ + + +
+ <<%= htmlComponentName %>-app>Loading...-app> +
+
+ + + + +
+ This area will be filled in by content you create in your page layouts. +
+ + + +
+
+
+ + + + + + + + + diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html new file mode 100644 index 000000000000..b6931b538a2c --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html @@ -0,0 +1,3 @@ +

+ {{title}} +

diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts new file mode 100644 index 000000000000..dff262b07022 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts @@ -0,0 +1,22 @@ +import { + beforeEachProviders, + describe, + expect, + it, + inject +} from '@angular/core/testing'; +import { <%= jsComponentName %>AppComponent } from '../app/<%= htmlComponentName %>.component'; + +beforeEachProviders(() => [<%= jsComponentName %>AppComponent]); + +describe('App: <%= jsComponentName %>', () => { + it('should create the app', + inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => { + expect(app).toBeTruthy(); + })); + + it('should have as title \'<%= htmlComponentName %> works!\'', + inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => { + expect(app.title).toEqual('<%= htmlComponentName %> works!'); + })); +}); diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts new file mode 100644 index 000000000000..eee28ef5b129 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core';<% if (isMobile) { %> +import { APP_SHELL_DIRECTIVES } from '@angular/app-shell';<% } %> + +@Component({ + moduleId: module.id, + selector: '<%= htmlComponentName %>-app', + <% if (isMobile) { %>template: ` +

+ {{title}} +

+ `, + styles: [], + directives: [APP_SHELL_DIRECTIVES]<% } else { %>templateUrl: '<%= htmlComponentName %>.component.html', + styleUrls: ['<%= dasherizedModuleName %>.component.css']<% } %> +}) +export class <%= jsComponentName %>AppComponent { + title = '<%= htmlComponentName %> works!'; +} diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts new file mode 100644 index 000000000000..79ee96fdfdbd --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts @@ -0,0 +1,7 @@ +// The file for the current environment will overwrite this one during build +// Different environments can be found in config/environment.{dev|prod}.ts +// The build system defaults to the dev environment + +export const environment = { + production: false +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts new file mode 100644 index 000000000000..f0f2d38acd4b --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts @@ -0,0 +1,2 @@ +export * from './environment'; +export * from './<%= htmlComponentName %>.component'; diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico b/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8081c7ceaf2be08bf59010158c586170d9d2d517 GIT binary patch literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- + + + + <%= jsComponentName %> + + + {{#unless environment.production}} + + {{/unless}} + + <% if (isMobile) { %> + + + + {{#each mobile.icons}} + + {{/each}} + + {{#if environment.production}} + + {{/if}} + <% } %> + + + <<%= htmlComponentName %>-app>Loading...-app> + + <% if (isMobile) { %> + + {{#if environment.production}} + + {{else}} + {{#each scripts.polyfills}} + + {{/each}} + + {{/if}} + + <% } else { %> + + {{#each scripts.polyfills}} + + {{/each}} + + + <% } %> + + + + + diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts new file mode 100644 index 000000000000..7e3a658095d0 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts @@ -0,0 +1,11 @@ +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { enableProdMode } from '@angular/core'; +import { <%= jsComponentName %>AppComponent, environment } from './app/';<% if(isMobile) { %> +import { APP_SHELL_RUNTIME_PROVIDERS } from '@angular/app-shell';<% } %> + +if (environment.production) { + enableProdMode(); +} + +bootstrap(<%= jsComponentName %>AppComponent<% if(isMobile) { %>, [ APP_SHELL_RUNTIME_PROVIDERS ]<% } %>); + diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts new file mode 100644 index 000000000000..cc549606a2a4 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts @@ -0,0 +1,55 @@ +/*********************************************************************************************** + * User Configuration. + **********************************************************************************************/ +/** Map relative paths to URLs. */ +const map: any = { +}; + +/** User packages configuration. */ +const packages: any = { +}; + +//////////////////////////////////////////////////////////////////////////////////////////////// +/*********************************************************************************************** + * Everything underneath this line is managed by the CLI. + **********************************************************************************************/ +const barrels: string[] = [ + // Angular specific barrels. + '@angular/core', + '@angular/common', + '@angular/compiler', + '@angular/http', + '@angular/router', + '@angular/platform-browser', + '@angular/platform-browser-dynamic',<% if(isMobile) { %> + '@angular/app-shell',<% } %> + + // Thirdparty barrels. + 'rxjs', + + // App specific barrels. + 'app', + 'app/shared', + /** @cli-barrel */ +]; + +const cliSystemConfigPackages: any = {}; +barrels.forEach((barrelName: string) => { + cliSystemConfigPackages[barrelName] = { main: 'index' }; +}); + +/** Type declaration for ambient System. */ +declare var System: any; + +// Apply the CLI SystemJS configuration. +System.config({ + map: { + '@angular': 'vendor/@angular', + 'rxjs': 'vendor/rxjs', + 'main': 'main.js' + }, + packages: cliSystemConfigPackages +}); + +// Apply the user's configuration. +System.config({ map, packages }); diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json b/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json new file mode 100644 index 000000000000..bc7e4503c6b1 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": false, + "outDir": "../dist/", + "rootDir": ".", + "sourceMap": true, + "target": "es5", + "inlineSources": true + }, + + "files": [ + "main.ts",<% if (isMobile) { %> + "main-app-shell.ts",<% } %> + "typings.d.ts" + ] +} diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts new file mode 100644 index 000000000000..df29a85ca4a3 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts @@ -0,0 +1,2 @@ +/// +<% if(!isMobile) { %>declare var module: { id: string };<% } %> diff --git a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js new file mode 100644 index 000000000000..dad887ff3dba --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js @@ -0,0 +1,17 @@ +/* global require, module */ + +var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); + +module.exports = function(defaults) { + return new Angular2App(defaults, { + vendorNpmFiles: [ + 'systemjs/dist/system-polyfills.js', + 'systemjs/dist/system.src.js', + 'zone.js/dist/**/*.+(js|js.map)', + 'es6-shim/es6-shim.js', + 'reflect-metadata/**/*.+(js|js.map)', + 'rxjs/**/*.+(js|js.map)', + '@angular/**/*.+(js|js.map)' + ] + }); +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/angular-cli.json b/addon/ng2/blueprints/CustomMaster/files/angular-cli.json new file mode 100644 index 000000000000..5b96ba0ba88c --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/angular-cli.json @@ -0,0 +1,32 @@ +{ + "project": { + "version": "<%= version %>", + "name": "<%= htmlComponentName %>" + }, + "apps": [ + { + "main": "<%= sourceDir %>/main.ts", + "tsconfig": "<%= sourceDir %>/tsconfig.json", + "mobile": <%= isMobile %> + } + ], + "addons": [], + "packages": [], + "e2e": { + "protractor": { + "config": "config/protractor.conf.js" + } + }, + "test": { + "karma": { + "config": "config/karma.conf.js" + } + }, + "defaults": { + "prefix": "<%= prefix %>", + "sourceDir": "<%= sourceDir %>", + "styleExt": "<%= styleExt %>", + "prefixInterfaces": false, + "lazyRoutePrefix": "+" + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts b/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts new file mode 100644 index 000000000000..ffe8aed76642 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts @@ -0,0 +1,3 @@ +export const environment = { + production: false +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/config/environment.js b/addon/ng2/blueprints/CustomMaster/files/config/environment.js new file mode 100644 index 000000000000..4fa28880da9f --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/environment.js @@ -0,0 +1,10 @@ +/* jshint node: true */ + +module.exports = function(environment) { + return { + environment: environment, + baseURL: '/', + locationType: 'auto' + }; +}; + diff --git a/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts b/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts new file mode 100644 index 000000000000..3612073bc31c --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js b/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js new file mode 100644 index 000000000000..c1693a0baa95 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js @@ -0,0 +1,51 @@ +/*global jasmine, __karma__, window*/ +Error.stackTraceLimit = Infinity; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; + +__karma__.loaded = function () { +}; + +var distPath = '/base/dist/'; +var appPath = distPath + 'app/'; + +function isJsFile(path) { + return path.slice(-3) == '.js'; +} + +function isSpecFile(path) { + return path.slice(-8) == '.spec.js'; +} + +function isAppFile(path) { + return isJsFile(path) && (path.substr(0, appPath.length) == appPath); +} + +var allSpecFiles = Object.keys(window.__karma__.files) + .filter(isSpecFile) + .filter(isAppFile); + +// Load our SystemJS configuration. +System.config({ + baseURL: distPath +}); + +System.import('system-config.js').then(function() { + // Load and configure the TestComponentBuilder. + return Promise.all([ + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]).then(function (providers) { + var testing = providers[0]; + var testingBrowser = providers[1]; + + testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + }); +}).then(function() { + // Finally, load all spec files. + // This will run the tests directly. + return Promise.all( + allSpecFiles.map(function (moduleName) { + return System.import(moduleName); + })); +}).then(__karma__.start, __karma__.error); \ No newline at end of file diff --git a/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js b/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js new file mode 100644 index 000000000000..d39036fa52ff --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js @@ -0,0 +1,42 @@ +module.exports = function (config) { + config.set({ + basePath: '..', + frameworks: ['jasmine'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher') + ], + customLaunchers: { + // chrome setup for travis CI using chromium + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + files: [ + { pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false }, + { pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false }, + { pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false }, + { pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false }, + { pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false }, + { pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false }, + + { pattern: 'config/karma-test-shim.js', included: true, watched: true }, + + // Distribution folder. + { pattern: 'dist/**/*', included: false, watched: true } + ], + exclude: [ + // Vendor packages might include spec files. We don't want to use those. + 'dist/vendor/**/*.spec.js' + ], + preprocessors: {}, + reporters: ['progress'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js b/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js new file mode 100644 index 000000000000..57f4f87dd7b4 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js @@ -0,0 +1,29 @@ +/*global jasmine */ +var SpecReporter = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + '../e2e/**/*.e2e.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + useAllAngular2AppRoots: true, + beforeLaunch: function() { + require('ts-node').register({ + project: 'e2e' + }); + }, + onPrepare: function() { + jasmine.getEnv().addReporter(new SpecReporter()); + } +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts b/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts new file mode 100644 index 000000000000..5b020693bc2a --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts @@ -0,0 +1,14 @@ +import { <%= jsComponentName %>Page } from './app.po'; + +describe('<%= htmlComponentName %> App', function() { + let page: <%= jsComponentName %>Page; + + beforeEach(() => { + page = new <%= jsComponentName %>Page(); + }); + + it('should display message saying app works', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('<%= htmlComponentName %> works!'); + }); +}); diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts b/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts new file mode 100644 index 000000000000..c68572d8a7d9 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts @@ -0,0 +1,9 @@ +export class <%= jsComponentName %>Page { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('<%= htmlComponentName %>-app h1')).getText(); + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json b/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json new file mode 100644 index 000000000000..29de61073fac --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "mapRoot": "", + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": false, + "rootDir": ".", + "sourceMap": true, + "sourceRoot": "/", + "target": "es5" + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts b/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts new file mode 100644 index 000000000000..9c2f2d0252ef --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts @@ -0,0 +1 @@ +/// diff --git a/addon/ng2/blueprints/CustomMaster/files/gitignore b/addon/ng2/blueprints/CustomMaster/files/gitignore new file mode 100644 index 000000000000..3422917e0af7 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/gitignore @@ -0,0 +1,29 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp + +# dependencies +/node_modules +/bower_components + +# IDEs and editors +/.idea + +# misc +/.sass-cache +/connect.lock +/coverage/* +/libpeerconnection.log +npm-debug.log +testem.log +/typings + +# e2e +/e2e/*.js +/e2e/*.map + +#System Files +.DS_Store +Thumbs.db diff --git a/addon/ng2/blueprints/CustomMaster/files/package.json b/addon/ng2/blueprints/CustomMaster/files/package.json new file mode 100644 index 000000000000..8c9823b92cfb --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/package.json @@ -0,0 +1,52 @@ +{ + "name": "<%= htmlComponentName %>", + "version": "0.0.0", + "license": "MIT", + "angular-cli": {}, + "scripts": { + "start": "ng serve", + "postinstall": "typings install", + "lint": "tslint \"<%= sourceDir %>/**/*.ts\"", + "test": "ng test", + "pree2e": "webdriver-manager update", + "e2e": "protractor" + }, + "private": true, + "dependencies": { + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", + "es6-shim": "^0.35.0", + "reflect-metadata": "0.1.3", + "rxjs": "5.0.0-beta.6", + "systemjs": "0.19.26", + "zone.js": "^0.6.12" + }, + "devDependencies": {<% if(isMobile) { %> + "@angular/platform-server": "2.0.0-rc.1", + "@angular/router-deprecated": "2.0.0-rc.1", + "@angular/service-worker": "^0.2.0", + "@angular/app-shell": "^0.0.0", + "angular2-broccoli-prerender": "^0.11.0", + "angular2-universal":"^0.100.3", + "angular2-universal-polyfills": "^0.4.1", + "preboot": "^2.0.10",<% } %> + "angular-cli": "^<%= version %>", + "codelyzer": "0.0.19", + "ember-cli-inject-live-reload": "^1.4.0", + "jasmine-core": "^2.4.1", + "jasmine-spec-reporter": "^2.4.0", + "karma": "^0.13.15", + "karma-chrome-launcher": "^0.2.3", + "karma-jasmine": "^0.3.8", + "protractor": "^3.3.0", + "ts-node": "^0.5.5", + "tslint": "^3.6.0", + "typescript": "^1.8.10", + "typings": "^0.8.1" + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/public/.gitignore b/addon/ng2/blueprints/CustomMaster/files/public/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/public/.npmignore b/addon/ng2/blueprints/CustomMaster/files/public/.npmignore new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/tslint.json b/addon/ng2/blueprints/CustomMaster/files/tslint.json new file mode 100644 index 000000000000..e32421f56763 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/tslint.json @@ -0,0 +1,72 @@ +{ + "rulesDirectory": ["node_modules/codelyzer"], + "rules": { + "max-line-length": [true, 100], + "no-inferrable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "eofline": true, + "no-duplicate-variable": true, + "no-eval": true, + "no-arg": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-bitwise": true, + "no-shadowed-variable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "one-line": [ + true, + "check-catch", + "check-else", + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "semicolon": [true, "always"], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "curly": true, + "variable-name": [ + true, + "ban-keywords", + "check-format", + "allow-trailing-underscore" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "component-selector-name": [true, "kebab-case"], + "component-selector-type": [true, "element"], + "use-host-property-decorator": true, + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "no-attribute-parameter-decorator": true, + "no-input-rename": true, + "no-output-rename": true + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/typings.json b/addon/ng2/blueprints/CustomMaster/files/typings.json new file mode 100644 index 000000000000..21f9888ab067 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/typings.json @@ -0,0 +1,11 @@ +{ + "ambientDevDependencies": { + "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459", + "jasmine": "registry:dt/jasmine#2.2.0+20160412134438", + "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654" + }, + "ambientDependencies": { + "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"<% if (isMobile) {%>, + "node": "registry:dt/node#4.0.0+20160509154515" <% } %> + } +} diff --git a/addon/ng2/blueprints/CustomMaster/index.js b/addon/ng2/blueprints/CustomMaster/index.js new file mode 100644 index 000000000000..146ef7c50023 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/index.js @@ -0,0 +1,67 @@ +const Blueprint = require('ember-cli/lib/models/blueprint'); +const path = require('path'); +const stringUtils = require('ember-cli-string-utils'); +const getFiles = Blueprint.prototype.files; + +module.exports = { + description: '', + + availableOptions: [ + { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, + { name: 'style', type: String, default: 'css' }, + { name: 'mobile', type: Boolean, default: false } + ], + + afterInstall: function (options) { + if (options.mobile) { + return Blueprint.load(path.join(__dirname, '../mobile')).install(options); + } + }, + + locals: function(options) { + this.styleExt = options.style; + this.version = require(path.resolve(__dirname, '..', '..', '..', '..', 'package.json')).version; + + // Join with / not path.sep as reference to typings require forward slashes. + const refToTypings = options.sourceDir.split(path.sep).map(() => '..').join('/'); + const fullAppName = stringUtils.dasherize(options.entity.name) + .replace(/-(.)/g, (_, l) => ' ' + l.toUpperCase()) + .replace(/^./, (l) => l.toUpperCase()); + + return { + htmlComponentName: stringUtils.dasherize(options.entity.name), + jsComponentName: stringUtils.classify(options.entity.name), + fullAppName: fullAppName, + version: this.version, + sourceDir: options.sourceDir, + prefix: options.prefix, + styleExt: this.styleExt, + refToTypings: refToTypings, + isMobile: options.mobile + }; + }, + + files: function() { + var fileList = getFiles.call(this); + + if (this.options && this.options.mobile) { + fileList = fileList.filter(p => p.indexOf('__name__.component.html') < 0); + fileList = fileList.filter(p => p.indexOf('__name__.component.__styleext__') < 0); + } + + return fileList; + }, + + fileMapTokens: function (options) { + // Return custom template variables here. + return { + __path__: () => { + return options.locals.sourceDir; + }, + __styleext__: () => { + return this.styleExt; + } + }; + } +}; From 57ea11cf7e7d19ea62c029f85cb1fd62e4c28718 Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:44:17 -0500 Subject: [PATCH 03/12] add sharepoint typings --- addon/ng2/blueprints/CustomMaster/files/typings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/ng2/blueprints/CustomMaster/files/typings.json b/addon/ng2/blueprints/CustomMaster/files/typings.json index 21f9888ab067..2d27535cd43c 100644 --- a/addon/ng2/blueprints/CustomMaster/files/typings.json +++ b/addon/ng2/blueprints/CustomMaster/files/typings.json @@ -2,7 +2,8 @@ "ambientDevDependencies": { "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459", "jasmine": "registry:dt/jasmine#2.2.0+20160412134438", - "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654" + "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654", + "sharepoint": "registry:dt/sharepoint" }, "ambientDependencies": { "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"<% if (isMobile) {%>, From d0280b758028963812d13254574f3e4801f47b7d Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:46:57 -0500 Subject: [PATCH 04/12] change module to new broccoli angular2-sharepoint-app --- addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js index dad887ff3dba..e4480f7b7802 100644 --- a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js +++ b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js @@ -1,9 +1,9 @@ /* global require, module */ -var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); +var Angular2SharePointApp = require('angular-cli/lib/broccoli/angular2-sharepoint-app'); module.exports = function(defaults) { - return new Angular2App(defaults, { + return new Angular2SharePointApp(defaults, { vendorNpmFiles: [ 'systemjs/dist/system-polyfills.js', 'systemjs/dist/system.src.js', From e024a36170ebb22dd446aae7ed4d8ecae8d299c1 Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:49:41 -0500 Subject: [PATCH 05/12] add @angular/http dependency --- addon/ng2/blueprints/CustomMaster/files/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/ng2/blueprints/CustomMaster/files/package.json b/addon/ng2/blueprints/CustomMaster/files/package.json index 8c9823b92cfb..8519d699a918 100644 --- a/addon/ng2/blueprints/CustomMaster/files/package.json +++ b/addon/ng2/blueprints/CustomMaster/files/package.json @@ -20,6 +20,7 @@ "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/router": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", From d8e5cefa116ce695b62946dd94c5fb9e5c88e141 Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:54:44 -0500 Subject: [PATCH 06/12] copy file loading scrpt from index --- .../files/__path__/CustomMaster.html | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html index 6d554e75856a..e44113e34a6d 100644 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html @@ -112,16 +112,34 @@
- - - - + <% if (isMobile) { %> + + {{#if environment.production}} + + {{else}} + {{#each scripts.polyfills}} + + {{/each}} + + {{/if}} + + <% } else { %> + + {{#each scripts.polyfills}} + + {{/each}} + <% } %> + From 315ea5e977826ec91466a70b2646ffadcf3418f6 Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:19:42 -0500 Subject: [PATCH 07/12] copy angular2-app change index.html to CustomMaster.html --- lib/broccoli/angular2-sharepoint-app.js | 472 ++++++++++++++++++++++++ 1 file changed, 472 insertions(+) create mode 100644 lib/broccoli/angular2-sharepoint-app.js diff --git a/lib/broccoli/angular2-sharepoint-app.js b/lib/broccoli/angular2-sharepoint-app.js new file mode 100644 index 000000000000..759d85da0e2f --- /dev/null +++ b/lib/broccoli/angular2-sharepoint-app.js @@ -0,0 +1,472 @@ +'use strict'; +const path = require('path'); +const fs = require('fs'); + +const BroccoliPlugin = require('broccoli-writer'); +const BroccoliTypescript = require('./broccoli-typescript'); +const BundlePlugin = require('./angular-broccoli-bundle'); +const BroccoliFunnel = require('broccoli-funnel'); +const BroccoliMergeTrees = require('broccoli-merge-trees'); +const BroccoliSource = require('broccoli-source'); +const UnwatchedDir = BroccoliSource.UnwatchedDir; +const Project = require('ember-cli/lib/models/project'); +const HandlebarReplace = require('./broccoli-handlebars'); +const config = require('../../addon/ng2/models/config'); +const loadEnvironment = require('./environment'); +const concat = require('broccoli-concat'); +const uglify = require('broccoli-uglify-js'); + +class Angular2SharePointApp extends BroccoliPlugin { + constructor(project, inputNode, options) { + super(); + this.ngConfig = config.CliConfig.fromProject(); + + if (!options) { + options = inputNode; + inputNode = null; + } + + options = options || {}; + + this._options = options; + this._sourceDir = options.sourceDir + || (this.ngConfig.defaults && this.ngConfig.defaults.sourceDir) + || 'src'; + this._options.polyfills = this._options.polyfills || [ + 'vendor/es6-shim/es6-shim.js', + 'vendor/reflect-metadata/Reflect.js', + 'vendor/systemjs/dist/system.src.js', + 'vendor/zone.js/dist/zone.js' + ]; + + this._destDir = options.destDir || ''; + + // By default, add all spec files to the tsCompiler. + this._tsCompiler = options.tsCompiler || { + additionalFiles: ['**/*.spec.ts'] + }; + + this._initProject(); + this._notifyAddonIncluded(); + this._inputNode = inputNode || this._buildInputTree(); + + this._tree = this._buildTree(); + } + + /** + * For backward compatibility. + * @public + * @method toTree + * @return {BroccoliPlugin} A broccoli plugin. + */ + toTree() { + // eslint-disable-next-line no-console + console.warn('Angular2App is now a broccoli plugin. Calling toTree() is deprecated.'); + return this; + } + + /** + * @override + */ + read(readTree) { + return this._tree.read(readTree); + } + + /** + * @override + */ + cleanup() { + return this._tree.cleanup(); + } + + _buildInputTree() { + const inputTreeArray = [ + new BroccoliFunnel(this._sourceDir, { destDir: this._sourceDir }), + new BroccoliFunnel('typings', { destDir: 'typings' }), + this._getConfigTree() + ]; + + if (fs.existsSync('public')) { + inputTreeArray.push(new BroccoliFunnel('public', { destDir: 'public' })); + } + + if (fs.existsSync('icons')) { + inputTreeArray.push(new BroccoliFunnel('icons', { destDir: 'icons' })); + } + + return new BroccoliMergeTrees(inputTreeArray, { overwrite: true }); + } + + /** + * Create and return the app build system tree that: + * - Get the `assets` tree + * - Get the TS tree + * - Get the TS src tree + * - Get the CustomMaster.html tree + * - Get the NPM modules tree + * - Apply/remove stuff based on the environment (dev|prod) + * - Return the app trees to be extended + * + * @private + * @method _buildTree + * @return {BroccoliFunnel} The app trees that can be used to extend the build. + */ + _buildTree() { + var assetTree = this._getAssetsTree(); + var tsTree = this._getTsTree(); + var indexTree = this._getIndexTree(); + var vendorNpmTree = this._getVendorNpmTree(); + + var buildTrees = [assetTree, tsTree, indexTree, vendorNpmTree]; + + // Add available and supported CSS plugins. + for (const suffix of ['sass', 'less', 'stylus', 'compass']) { + const plugin = require(`./angular-broccoli-${suffix}`); + const tree = plugin.makeBroccoliTree(this._inputNode, this._options[`${suffix}Compiler`]); + + if (!tree) { + continue; + } + + buildTrees.push(new BroccoliFunnel(tree, { + include: ['**/*'], + getDestinationPath: (n) => { + if (n.startsWith(this._sourceDir)) { + return n.substr(this._sourceDir.length); + } + return n; + } + })); + } + + // Add the public folder in. + buildTrees.push(new BroccoliFunnel(this._inputNode, { + allowEmpty: true, + srcDir: 'public', + name: 'PublicFolderFunnel' + })); + + var merged = new BroccoliMergeTrees(buildTrees, { overwrite: true }); + + if (this.ngConfig.apps[0].mobile) { + let AppShellPlugin = require('angular2-broccoli-prerender').AppShellPlugin; + merged = new BroccoliMergeTrees([merged, new AppShellPlugin(merged, 'CustomMaster.html', 'main-app-shell')], { + overwrite: true + }); + } + + if (loadEnvironment(this.project).production) { + merged = this._getBundleTree(merged); + } + + return new BroccoliFunnel(merged, { + destDir: this._destDir, + overwrite: true + }); + } + + + /** + * @private + * @method _initProject + * @param {Object} options + */ + _initProject() { + this.project = Project.closestSync(process.cwd()); + + // project root dir env used on angular-cli side for including packages from project + process.env.PROJECT_ROOT = process.env.PROJECT_ROOT || this.project.root; + } + + /** + * @private + * @method _notifyAddonIncluded + */ + _notifyAddonIncluded() { + this.initializeAddons(); + this.project.addons = this.project.addons.filter(function (addon) { + addon.app = this; + + if (!addon.isEnabled || addon.isEnabled()) { + if (addon.included) { + addon.included(this); + } + + return addon; + } + }, this); + } + + /** + * Loads and initializes addons for this project. + * Calls initializeAddons on the Project. + * + * @private + * @method initializeAddons + */ + initializeAddons() { + this.project.initializeAddons(); + } + + /** + * Returns the content for a specific type (section) for CustomMaster.html. + * + * Currently supported types: + * - 'head' + * //- 'config-module' + * //- 'app' + * //- 'head-footer' + * //- 'test-header-footer' + * //- 'body-footer' + * //- 'test-body-footer' + * + * Addons can also implement this method and could also define additional + * types (eg. 'some-addon-section'). + * + * @private + * @method _contentFor + * @param {RegExP} match Regular expression to match against + * @param {String} type Type of content + * @return {String} The content. + */ + _contentFor(match, type) { + var content = []; + + /*switch (type) { + case 'head': this._contentForHead(content, config); break; + case 'config-module': this._contentForConfigModule(content, config); break; + case 'app-boot': this._contentForAppBoot(content, config); break; + }*/ + content = this.project.addons.reduce(function (content, addon) { + var addonContent = addon.contentFor ? addon.contentFor(type) : null; + if (addonContent) { + return content.concat(addonContent); + } + + return content; + }, content); + + return content.join('\n'); + } + + /** + * Returns the tree for app/CustomMasterhtml. + * + * @private + * @method _getIndexTree + * @return {Tree} Tree for app/CustomMaster.html. + */ + _getIndexTree() { + var files = [ + 'CustomMaster.html' + ]; + var mobile; + + let indexTree = new BroccoliFunnel(this._inputNode, { + include: files.map(name => path.join(this._sourceDir, name)), + getDestinationPath: (n) => { + if (n.startsWith(this._sourceDir)) { + return n.substr(this._sourceDir.length); + } + return n; + } + }); + + if (this.ngConfig.apps[0].mobile) { + mobile = { + icons: [ + { rel: 'apple-touch-icon', href: '/icons/apple-touch-icon.png' }, + { rel: 'apple-touch-icon', sizes: '57x57', href: '/icons/apple-touch-icon-57x57.png' }, + { rel: 'apple-touch-icon', sizes: '60x60', href: '/icons/apple-touch-icon-60x60.png' }, + { rel: 'apple-touch-icon', sizes: '72x72', href: '/icons/apple-touch-icon-72x72.png' }, + { rel: 'apple-touch-icon', sizes: '76x76', href: '/icons/apple-touch-icon-76x76.png' }, + { rel: 'apple-touch-icon', sizes: '114x114', href: '/icons/apple-touch-icon-114x114.png' }, + { rel: 'apple-touch-icon', sizes: '120x120', href: '/icons/apple-touch-icon-120x120.png' }, + { rel: 'apple-touch-icon', sizes: '144x144', href: '/icons/apple-touch-icon-144x144.png' }, + { rel: 'apple-touch-icon', sizes: '152x152', href: '/icons/apple-touch-icon-152x152.png' }, + { rel: 'apple-touch-icon', sizes: '180x180', href: '/icons/apple-touch-icon-180x180.png' }, + { rel: 'apple-touch-startup-image', href: '/icons/apple-touch-icon-180x180.png' } + ] + } + } + + return new HandlebarReplace(indexTree, { + config: this.ngConfig, + environment: loadEnvironment(this.project), + scripts: { + polyfills: this._options.polyfills + }, + mobile: mobile + }, { + helpers: { + 'content-for': (name) => { + // TODO: remove content-for. + // eslint-disable-next-line no-console + console.warn('"{{content-for}}" has been deprecated and will be removed before RC.'); + return this._contentFor(null, name); + } + } + }); + } + + /** + * Returns the TS tree. + * + * @private + * @method _getTsTree + * @return {Tree} Tree for TypeScript files. + */ + _getTsTree() { + var tsConfigPath = path.join(this._sourceDir, 'tsconfig.json'); + var tsTree = new BroccoliTypescript(this._inputNode, tsConfigPath, this._tsCompiler); + + var tsTreeExcludes = ['*.d.ts', 'tsconfig.json']; + var excludeSpecFiles = '**/*.spec.*'; + + if (loadEnvironment(this.project).production) { + tsTreeExcludes.push(excludeSpecFiles); + } + + tsTree = new BroccoliFunnel(tsTree, { + srcDir: this._sourceDir, + exclude: tsTreeExcludes + }); + + return tsTree; + } + + + /** + * Returns the `vendorNpm` tree by merging the CLI dependencies plus the ones + * passed by the user. + * + * @private + * @method _getVendorNpmTree + * @return {Tree} The NPM tree. + */ + _getVendorNpmTree() { + var vendorNpmFiles = [ + ]; + + if (this.ngConfig.apps[0].mobile) { + vendorNpmFiles.push('@angular/service-worker/dist/worker.js') + } + + if (this._options.vendorNpmFiles) { + vendorNpmFiles = vendorNpmFiles.concat(this._options.vendorNpmFiles); + } + + return new BroccoliFunnel(new UnwatchedDir('node_modules'), { + include: vendorNpmFiles, + destDir: 'vendor', + name: 'vendor' + }); + } + + /** + * Returns the `assets` tree. + * + * @private + * @method _getAssetsTree + * @return {Tree} The assets tree. + */ + _getAssetsTree() { + return new BroccoliFunnel(this._inputNode, { + srcDir: this._sourceDir, + exclude: [ + '**/*.ts', + '**/*.scss', + '**/*.sass', + '**/*.less', + '**/*.styl', + '**/tsconfig.json' + ], + allowEmpty: true + }); + } + + /** + * Returns the config files tree. + * + * @private + * @method _getConfigTree + * @return {Tree} The config files tree. + */ + _getConfigTree() { + const isProduction = loadEnvironment(this.project).production; + var envConfigFile = isProduction ? 'environment.prod.ts' : 'environment.dev.ts'; + + return new BroccoliFunnel('config', { + include: [envConfigFile], + destDir: `${this._sourceDir}/app`, + getDestinationPath: () => 'environment.ts' + }); + } + + _getBundleTree(preBundleTree){ + var vendorTree = this._getVendorNpmTree(); + var assetsTree = this._getAssetsTree(); + + var scriptTree = new BroccoliFunnel(preBundleTree, { + include: this._options.polyfills + }); + + var nonJsTree = new BroccoliFunnel(preBundleTree, { + exclude: ['**/*.js', '**/*.js.map'] + }); + var jsTree = new BroccoliFunnel(preBundleTree, { + include: ['**/*.js', '**/*.js.map'] + }); + + var bundleTree = new BundlePlugin([jsTree]); + + if (this.ngConfig.apps[0].mobile) { + bundleTree = concat(BroccoliMergeTrees([vendorTree, jsTree, scriptTree, bundleTree], { + overwrite: true + }), { + headerFiles: this._options.polyfills.concat([ + 'system-config.js', + 'main.js', + 'app/CustomMaster.js' + ]), + inputFiles: [ + 'system-import.js' + ], + header: ';(function() {', + footer: '}());', + sourceMapConfig: { enabled: true }, + allowNone: false, + outputFile: '/app-concat.js' + }); + + bundleTree = uglify(bundleTree, { + mangle: false + }); + + // Required here since the package isn't installed for non-mobile apps. + var ServiceWorkerPlugin = require('@angular/service-worker').ServiceWorkerPlugin; + // worker.js is needed so it can be copied to dist + var workerJsTree = new BroccoliFunnel(jsTree, { + include: ['vendor/@angular/service-worker/dist/worker.js'] + }); + /** + * ServiceWorkerPlugin will automatically pre-fetch and cache every file + * in the tree it receives, so it should only receive the app bundle, + * and non-JS static files from the app. The plugin also needs to have + * the worker.js file available so it can copy it to dist. + **/ + var swTree = new ServiceWorkerPlugin(BroccoliMergeTrees([ + bundleTree, + assetsTree, + workerJsTree + ])); + bundleTree = BroccoliMergeTrees([bundleTree, swTree], { + overwrite: true + }); + } + + return BroccoliMergeTrees([nonJsTree, scriptTree, bundleTree], { overwrite: true }); + } +} + +module.exports = Angular2App; From 159fdb91f1a83517473633ad6a33ad3a48216adf Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:36:11 -0500 Subject: [PATCH 08/12] add custom master files, copy from ng2 files --- .../CustomMaster/files/.clang-format | 3 + .../CustomMaster/files/.editorconfig | 14 ++ .../files/__path__/CustomMaster.html | 127 ++++++++++++++++++ .../app/__name__.component.__styleext__ | 0 .../__path__/app/__name__.component.html | 3 + .../__path__/app/__name__.component.spec.ts | 22 +++ .../files/__path__/app/__name__.component.ts | 18 +++ .../files/__path__/app/environment.ts | 7 + .../CustomMaster/files/__path__/app/index.ts | 2 + .../files/__path__/app/shared/index.ts | 0 .../CustomMaster/files/__path__/favicon.ico | Bin 0 -> 5430 bytes .../CustomMaster/files/__path__/index.html | 65 +++++++++ .../CustomMaster/files/__path__/main.ts | 11 ++ .../files/__path__/system-config.ts | 55 ++++++++ .../CustomMaster/files/__path__/tsconfig.json | 23 ++++ .../CustomMaster/files/__path__/typings.d.ts | 2 + .../CustomMaster/files/angular-cli-build.js | 17 +++ .../CustomMaster/files/angular-cli.json | 32 +++++ .../files/config/environment.dev.ts | 3 + .../CustomMaster/files/config/environment.js | 10 ++ .../files/config/environment.prod.ts | 3 + .../files/config/karma-test-shim.js | 51 +++++++ .../CustomMaster/files/config/karma.conf.js | 42 ++++++ .../files/config/protractor.conf.js | 29 ++++ .../CustomMaster/files/e2e/app.e2e.ts | 14 ++ .../CustomMaster/files/e2e/app.po.ts | 9 ++ .../CustomMaster/files/e2e/tsconfig.json | 17 +++ .../CustomMaster/files/e2e/typings.d.ts | 1 + .../blueprints/CustomMaster/files/gitignore | 29 ++++ .../CustomMaster/files/package.json | 52 +++++++ .../CustomMaster/files/public/.gitignore | 0 .../CustomMaster/files/public/.npmignore | 0 .../blueprints/CustomMaster/files/tslint.json | 72 ++++++++++ .../CustomMaster/files/typings.json | 11 ++ addon/ng2/blueprints/CustomMaster/index.js | 67 +++++++++ 35 files changed, 811 insertions(+) create mode 100644 addon/ng2/blueprints/CustomMaster/files/.clang-format create mode 100644 addon/ng2/blueprints/CustomMaster/files/.editorconfig create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/index.html create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/main.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts create mode 100644 addon/ng2/blueprints/CustomMaster/files/gitignore create mode 100644 addon/ng2/blueprints/CustomMaster/files/package.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.gitignore create mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.npmignore create mode 100644 addon/ng2/blueprints/CustomMaster/files/tslint.json create mode 100644 addon/ng2/blueprints/CustomMaster/files/typings.json create mode 100644 addon/ng2/blueprints/CustomMaster/index.js diff --git a/addon/ng2/blueprints/CustomMaster/files/.clang-format b/addon/ng2/blueprints/CustomMaster/files/.clang-format new file mode 100644 index 000000000000..8d1c3c310286 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/.clang-format @@ -0,0 +1,3 @@ +Language: JavaScript +BasedOnStyle: Google +ColumnLimit: 100 diff --git a/addon/ng2/blueprints/CustomMaster/files/.editorconfig b/addon/ng2/blueprints/CustomMaster/files/.editorconfig new file mode 100644 index 000000000000..20380c701c90 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/.editorconfig @@ -0,0 +1,14 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html new file mode 100644 index 000000000000..6d554e75856a --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
In true previews of your site, the SharePoint ribbon will be here.
+ + + +
+ <<%= htmlComponentName %>-app>Loading...-app> +
+
+ + + + +
+ This area will be filled in by content you create in your page layouts. +
+ + + +
+
+
+ + + + + + + + + diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html new file mode 100644 index 000000000000..b6931b538a2c --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html @@ -0,0 +1,3 @@ +

+ {{title}} +

diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts new file mode 100644 index 000000000000..dff262b07022 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts @@ -0,0 +1,22 @@ +import { + beforeEachProviders, + describe, + expect, + it, + inject +} from '@angular/core/testing'; +import { <%= jsComponentName %>AppComponent } from '../app/<%= htmlComponentName %>.component'; + +beforeEachProviders(() => [<%= jsComponentName %>AppComponent]); + +describe('App: <%= jsComponentName %>', () => { + it('should create the app', + inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => { + expect(app).toBeTruthy(); + })); + + it('should have as title \'<%= htmlComponentName %> works!\'', + inject([<%= jsComponentName %>AppComponent], (app: <%= jsComponentName %>AppComponent) => { + expect(app.title).toEqual('<%= htmlComponentName %> works!'); + })); +}); diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts new file mode 100644 index 000000000000..eee28ef5b129 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts @@ -0,0 +1,18 @@ +import { Component } from '@angular/core';<% if (isMobile) { %> +import { APP_SHELL_DIRECTIVES } from '@angular/app-shell';<% } %> + +@Component({ + moduleId: module.id, + selector: '<%= htmlComponentName %>-app', + <% if (isMobile) { %>template: ` +

+ {{title}} +

+ `, + styles: [], + directives: [APP_SHELL_DIRECTIVES]<% } else { %>templateUrl: '<%= htmlComponentName %>.component.html', + styleUrls: ['<%= dasherizedModuleName %>.component.css']<% } %> +}) +export class <%= jsComponentName %>AppComponent { + title = '<%= htmlComponentName %> works!'; +} diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts new file mode 100644 index 000000000000..79ee96fdfdbd --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts @@ -0,0 +1,7 @@ +// The file for the current environment will overwrite this one during build +// Different environments can be found in config/environment.{dev|prod}.ts +// The build system defaults to the dev environment + +export const environment = { + production: false +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts new file mode 100644 index 000000000000..f0f2d38acd4b --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts @@ -0,0 +1,2 @@ +export * from './environment'; +export * from './<%= htmlComponentName %>.component'; diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico b/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8081c7ceaf2be08bf59010158c586170d9d2d517 GIT binary patch literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- + + + + <%= jsComponentName %> + + + {{#unless environment.production}} + + {{/unless}} + + <% if (isMobile) { %> + + + + {{#each mobile.icons}} + + {{/each}} + + {{#if environment.production}} + + {{/if}} + <% } %> + + + <<%= htmlComponentName %>-app>Loading...-app> + + <% if (isMobile) { %> + + {{#if environment.production}} + + {{else}} + {{#each scripts.polyfills}} + + {{/each}} + + {{/if}} + + <% } else { %> + + {{#each scripts.polyfills}} + + {{/each}} + + + <% } %> + + + + + diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts new file mode 100644 index 000000000000..7e3a658095d0 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts @@ -0,0 +1,11 @@ +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { enableProdMode } from '@angular/core'; +import { <%= jsComponentName %>AppComponent, environment } from './app/';<% if(isMobile) { %> +import { APP_SHELL_RUNTIME_PROVIDERS } from '@angular/app-shell';<% } %> + +if (environment.production) { + enableProdMode(); +} + +bootstrap(<%= jsComponentName %>AppComponent<% if(isMobile) { %>, [ APP_SHELL_RUNTIME_PROVIDERS ]<% } %>); + diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts new file mode 100644 index 000000000000..cc549606a2a4 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts @@ -0,0 +1,55 @@ +/*********************************************************************************************** + * User Configuration. + **********************************************************************************************/ +/** Map relative paths to URLs. */ +const map: any = { +}; + +/** User packages configuration. */ +const packages: any = { +}; + +//////////////////////////////////////////////////////////////////////////////////////////////// +/*********************************************************************************************** + * Everything underneath this line is managed by the CLI. + **********************************************************************************************/ +const barrels: string[] = [ + // Angular specific barrels. + '@angular/core', + '@angular/common', + '@angular/compiler', + '@angular/http', + '@angular/router', + '@angular/platform-browser', + '@angular/platform-browser-dynamic',<% if(isMobile) { %> + '@angular/app-shell',<% } %> + + // Thirdparty barrels. + 'rxjs', + + // App specific barrels. + 'app', + 'app/shared', + /** @cli-barrel */ +]; + +const cliSystemConfigPackages: any = {}; +barrels.forEach((barrelName: string) => { + cliSystemConfigPackages[barrelName] = { main: 'index' }; +}); + +/** Type declaration for ambient System. */ +declare var System: any; + +// Apply the CLI SystemJS configuration. +System.config({ + map: { + '@angular': 'vendor/@angular', + 'rxjs': 'vendor/rxjs', + 'main': 'main.js' + }, + packages: cliSystemConfigPackages +}); + +// Apply the user's configuration. +System.config({ map, packages }); diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json b/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json new file mode 100644 index 000000000000..bc7e4503c6b1 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": false, + "outDir": "../dist/", + "rootDir": ".", + "sourceMap": true, + "target": "es5", + "inlineSources": true + }, + + "files": [ + "main.ts",<% if (isMobile) { %> + "main-app-shell.ts",<% } %> + "typings.d.ts" + ] +} diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts b/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts new file mode 100644 index 000000000000..df29a85ca4a3 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts @@ -0,0 +1,2 @@ +/// +<% if(!isMobile) { %>declare var module: { id: string };<% } %> diff --git a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js new file mode 100644 index 000000000000..dad887ff3dba --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js @@ -0,0 +1,17 @@ +/* global require, module */ + +var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); + +module.exports = function(defaults) { + return new Angular2App(defaults, { + vendorNpmFiles: [ + 'systemjs/dist/system-polyfills.js', + 'systemjs/dist/system.src.js', + 'zone.js/dist/**/*.+(js|js.map)', + 'es6-shim/es6-shim.js', + 'reflect-metadata/**/*.+(js|js.map)', + 'rxjs/**/*.+(js|js.map)', + '@angular/**/*.+(js|js.map)' + ] + }); +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/angular-cli.json b/addon/ng2/blueprints/CustomMaster/files/angular-cli.json new file mode 100644 index 000000000000..5b96ba0ba88c --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/angular-cli.json @@ -0,0 +1,32 @@ +{ + "project": { + "version": "<%= version %>", + "name": "<%= htmlComponentName %>" + }, + "apps": [ + { + "main": "<%= sourceDir %>/main.ts", + "tsconfig": "<%= sourceDir %>/tsconfig.json", + "mobile": <%= isMobile %> + } + ], + "addons": [], + "packages": [], + "e2e": { + "protractor": { + "config": "config/protractor.conf.js" + } + }, + "test": { + "karma": { + "config": "config/karma.conf.js" + } + }, + "defaults": { + "prefix": "<%= prefix %>", + "sourceDir": "<%= sourceDir %>", + "styleExt": "<%= styleExt %>", + "prefixInterfaces": false, + "lazyRoutePrefix": "+" + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts b/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts new file mode 100644 index 000000000000..ffe8aed76642 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts @@ -0,0 +1,3 @@ +export const environment = { + production: false +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/config/environment.js b/addon/ng2/blueprints/CustomMaster/files/config/environment.js new file mode 100644 index 000000000000..4fa28880da9f --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/environment.js @@ -0,0 +1,10 @@ +/* jshint node: true */ + +module.exports = function(environment) { + return { + environment: environment, + baseURL: '/', + locationType: 'auto' + }; +}; + diff --git a/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts b/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts new file mode 100644 index 000000000000..3612073bc31c --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js b/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js new file mode 100644 index 000000000000..c1693a0baa95 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js @@ -0,0 +1,51 @@ +/*global jasmine, __karma__, window*/ +Error.stackTraceLimit = Infinity; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; + +__karma__.loaded = function () { +}; + +var distPath = '/base/dist/'; +var appPath = distPath + 'app/'; + +function isJsFile(path) { + return path.slice(-3) == '.js'; +} + +function isSpecFile(path) { + return path.slice(-8) == '.spec.js'; +} + +function isAppFile(path) { + return isJsFile(path) && (path.substr(0, appPath.length) == appPath); +} + +var allSpecFiles = Object.keys(window.__karma__.files) + .filter(isSpecFile) + .filter(isAppFile); + +// Load our SystemJS configuration. +System.config({ + baseURL: distPath +}); + +System.import('system-config.js').then(function() { + // Load and configure the TestComponentBuilder. + return Promise.all([ + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]).then(function (providers) { + var testing = providers[0]; + var testingBrowser = providers[1]; + + testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + }); +}).then(function() { + // Finally, load all spec files. + // This will run the tests directly. + return Promise.all( + allSpecFiles.map(function (moduleName) { + return System.import(moduleName); + })); +}).then(__karma__.start, __karma__.error); \ No newline at end of file diff --git a/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js b/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js new file mode 100644 index 000000000000..d39036fa52ff --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js @@ -0,0 +1,42 @@ +module.exports = function (config) { + config.set({ + basePath: '..', + frameworks: ['jasmine'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher') + ], + customLaunchers: { + // chrome setup for travis CI using chromium + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + files: [ + { pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false }, + { pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false }, + { pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false }, + { pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false }, + { pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false }, + { pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false }, + + { pattern: 'config/karma-test-shim.js', included: true, watched: true }, + + // Distribution folder. + { pattern: 'dist/**/*', included: false, watched: true } + ], + exclude: [ + // Vendor packages might include spec files. We don't want to use those. + 'dist/vendor/**/*.spec.js' + ], + preprocessors: {}, + reporters: ['progress'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js b/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js new file mode 100644 index 000000000000..57f4f87dd7b4 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js @@ -0,0 +1,29 @@ +/*global jasmine */ +var SpecReporter = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + '../e2e/**/*.e2e.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + useAllAngular2AppRoots: true, + beforeLaunch: function() { + require('ts-node').register({ + project: 'e2e' + }); + }, + onPrepare: function() { + jasmine.getEnv().addReporter(new SpecReporter()); + } +}; diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts b/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts new file mode 100644 index 000000000000..5b020693bc2a --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts @@ -0,0 +1,14 @@ +import { <%= jsComponentName %>Page } from './app.po'; + +describe('<%= htmlComponentName %> App', function() { + let page: <%= jsComponentName %>Page; + + beforeEach(() => { + page = new <%= jsComponentName %>Page(); + }); + + it('should display message saying app works', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('<%= htmlComponentName %> works!'); + }); +}); diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts b/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts new file mode 100644 index 000000000000..c68572d8a7d9 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts @@ -0,0 +1,9 @@ +export class <%= jsComponentName %>Page { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('<%= htmlComponentName %>-app h1')).getText(); + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json b/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json new file mode 100644 index 000000000000..29de61073fac --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "mapRoot": "", + "module": "commonjs", + "moduleResolution": "node", + "noEmitOnError": true, + "noImplicitAny": false, + "rootDir": ".", + "sourceMap": true, + "sourceRoot": "/", + "target": "es5" + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts b/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts new file mode 100644 index 000000000000..9c2f2d0252ef --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts @@ -0,0 +1 @@ +/// diff --git a/addon/ng2/blueprints/CustomMaster/files/gitignore b/addon/ng2/blueprints/CustomMaster/files/gitignore new file mode 100644 index 000000000000..3422917e0af7 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/gitignore @@ -0,0 +1,29 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp + +# dependencies +/node_modules +/bower_components + +# IDEs and editors +/.idea + +# misc +/.sass-cache +/connect.lock +/coverage/* +/libpeerconnection.log +npm-debug.log +testem.log +/typings + +# e2e +/e2e/*.js +/e2e/*.map + +#System Files +.DS_Store +Thumbs.db diff --git a/addon/ng2/blueprints/CustomMaster/files/package.json b/addon/ng2/blueprints/CustomMaster/files/package.json new file mode 100644 index 000000000000..8c9823b92cfb --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/package.json @@ -0,0 +1,52 @@ +{ + "name": "<%= htmlComponentName %>", + "version": "0.0.0", + "license": "MIT", + "angular-cli": {}, + "scripts": { + "start": "ng serve", + "postinstall": "typings install", + "lint": "tslint \"<%= sourceDir %>/**/*.ts\"", + "test": "ng test", + "pree2e": "webdriver-manager update", + "e2e": "protractor" + }, + "private": true, + "dependencies": { + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", + "es6-shim": "^0.35.0", + "reflect-metadata": "0.1.3", + "rxjs": "5.0.0-beta.6", + "systemjs": "0.19.26", + "zone.js": "^0.6.12" + }, + "devDependencies": {<% if(isMobile) { %> + "@angular/platform-server": "2.0.0-rc.1", + "@angular/router-deprecated": "2.0.0-rc.1", + "@angular/service-worker": "^0.2.0", + "@angular/app-shell": "^0.0.0", + "angular2-broccoli-prerender": "^0.11.0", + "angular2-universal":"^0.100.3", + "angular2-universal-polyfills": "^0.4.1", + "preboot": "^2.0.10",<% } %> + "angular-cli": "^<%= version %>", + "codelyzer": "0.0.19", + "ember-cli-inject-live-reload": "^1.4.0", + "jasmine-core": "^2.4.1", + "jasmine-spec-reporter": "^2.4.0", + "karma": "^0.13.15", + "karma-chrome-launcher": "^0.2.3", + "karma-jasmine": "^0.3.8", + "protractor": "^3.3.0", + "ts-node": "^0.5.5", + "tslint": "^3.6.0", + "typescript": "^1.8.10", + "typings": "^0.8.1" + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/public/.gitignore b/addon/ng2/blueprints/CustomMaster/files/public/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/public/.npmignore b/addon/ng2/blueprints/CustomMaster/files/public/.npmignore new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/addon/ng2/blueprints/CustomMaster/files/tslint.json b/addon/ng2/blueprints/CustomMaster/files/tslint.json new file mode 100644 index 000000000000..e32421f56763 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/tslint.json @@ -0,0 +1,72 @@ +{ + "rulesDirectory": ["node_modules/codelyzer"], + "rules": { + "max-line-length": [true, 100], + "no-inferrable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "eofline": true, + "no-duplicate-variable": true, + "no-eval": true, + "no-arg": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-bitwise": true, + "no-shadowed-variable": true, + "no-unused-expression": true, + "no-unused-variable": true, + "one-line": [ + true, + "check-catch", + "check-else", + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "single", + "avoid-escape" + ], + "semicolon": [true, "always"], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "curly": true, + "variable-name": [ + true, + "ban-keywords", + "check-format", + "allow-trailing-underscore" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "component-selector-name": [true, "kebab-case"], + "component-selector-type": [true, "element"], + "use-host-property-decorator": true, + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "no-attribute-parameter-decorator": true, + "no-input-rename": true, + "no-output-rename": true + } +} diff --git a/addon/ng2/blueprints/CustomMaster/files/typings.json b/addon/ng2/blueprints/CustomMaster/files/typings.json new file mode 100644 index 000000000000..21f9888ab067 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/files/typings.json @@ -0,0 +1,11 @@ +{ + "ambientDevDependencies": { + "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459", + "jasmine": "registry:dt/jasmine#2.2.0+20160412134438", + "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654" + }, + "ambientDependencies": { + "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"<% if (isMobile) {%>, + "node": "registry:dt/node#4.0.0+20160509154515" <% } %> + } +} diff --git a/addon/ng2/blueprints/CustomMaster/index.js b/addon/ng2/blueprints/CustomMaster/index.js new file mode 100644 index 000000000000..146ef7c50023 --- /dev/null +++ b/addon/ng2/blueprints/CustomMaster/index.js @@ -0,0 +1,67 @@ +const Blueprint = require('ember-cli/lib/models/blueprint'); +const path = require('path'); +const stringUtils = require('ember-cli-string-utils'); +const getFiles = Blueprint.prototype.files; + +module.exports = { + description: '', + + availableOptions: [ + { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, + { name: 'style', type: String, default: 'css' }, + { name: 'mobile', type: Boolean, default: false } + ], + + afterInstall: function (options) { + if (options.mobile) { + return Blueprint.load(path.join(__dirname, '../mobile')).install(options); + } + }, + + locals: function(options) { + this.styleExt = options.style; + this.version = require(path.resolve(__dirname, '..', '..', '..', '..', 'package.json')).version; + + // Join with / not path.sep as reference to typings require forward slashes. + const refToTypings = options.sourceDir.split(path.sep).map(() => '..').join('/'); + const fullAppName = stringUtils.dasherize(options.entity.name) + .replace(/-(.)/g, (_, l) => ' ' + l.toUpperCase()) + .replace(/^./, (l) => l.toUpperCase()); + + return { + htmlComponentName: stringUtils.dasherize(options.entity.name), + jsComponentName: stringUtils.classify(options.entity.name), + fullAppName: fullAppName, + version: this.version, + sourceDir: options.sourceDir, + prefix: options.prefix, + styleExt: this.styleExt, + refToTypings: refToTypings, + isMobile: options.mobile + }; + }, + + files: function() { + var fileList = getFiles.call(this); + + if (this.options && this.options.mobile) { + fileList = fileList.filter(p => p.indexOf('__name__.component.html') < 0); + fileList = fileList.filter(p => p.indexOf('__name__.component.__styleext__') < 0); + } + + return fileList; + }, + + fileMapTokens: function (options) { + // Return custom template variables here. + return { + __path__: () => { + return options.locals.sourceDir; + }, + __styleext__: () => { + return this.styleExt; + } + }; + } +}; From 971c9fa7ab9fe19566435fbf609480b3989975a8 Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:44:17 -0500 Subject: [PATCH 09/12] add sharepoint typings --- addon/ng2/blueprints/CustomMaster/files/typings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/ng2/blueprints/CustomMaster/files/typings.json b/addon/ng2/blueprints/CustomMaster/files/typings.json index 21f9888ab067..2d27535cd43c 100644 --- a/addon/ng2/blueprints/CustomMaster/files/typings.json +++ b/addon/ng2/blueprints/CustomMaster/files/typings.json @@ -2,7 +2,8 @@ "ambientDevDependencies": { "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459", "jasmine": "registry:dt/jasmine#2.2.0+20160412134438", - "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654" + "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654", + "sharepoint": "registry:dt/sharepoint" }, "ambientDependencies": { "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"<% if (isMobile) {%>, From 3d4510ae7f4e2dec5cecd2a09896b1b3631f12be Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:46:57 -0500 Subject: [PATCH 10/12] change module to new broccoli angular2-sharepoint-app --- addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js index dad887ff3dba..e4480f7b7802 100644 --- a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js +++ b/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js @@ -1,9 +1,9 @@ /* global require, module */ -var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); +var Angular2SharePointApp = require('angular-cli/lib/broccoli/angular2-sharepoint-app'); module.exports = function(defaults) { - return new Angular2App(defaults, { + return new Angular2SharePointApp(defaults, { vendorNpmFiles: [ 'systemjs/dist/system-polyfills.js', 'systemjs/dist/system.src.js', From d330f5f3a855b624fe42827b5ff4ba932b2cc14c Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:49:41 -0500 Subject: [PATCH 11/12] add @angular/http dependency --- addon/ng2/blueprints/CustomMaster/files/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/ng2/blueprints/CustomMaster/files/package.json b/addon/ng2/blueprints/CustomMaster/files/package.json index 8c9823b92cfb..8519d699a918 100644 --- a/addon/ng2/blueprints/CustomMaster/files/package.json +++ b/addon/ng2/blueprints/CustomMaster/files/package.json @@ -20,6 +20,7 @@ "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/router": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.3", "rxjs": "5.0.0-beta.6", From ba84aaefb726d19009fbac730ae98ea1d1ca2ce9 Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:54:44 -0500 Subject: [PATCH 12/12] copy file loading scrpt from index --- .../files/__path__/CustomMaster.html | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html index 6d554e75856a..e44113e34a6d 100644 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html +++ b/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html @@ -112,16 +112,34 @@
- - - - + <% if (isMobile) { %> + + {{#if environment.production}} + + {{else}} + {{#each scripts.polyfills}} + + {{/each}} + + {{/if}} + + <% } else { %> + + {{#each scripts.polyfills}} + + {{/each}} + <% } %> +