From 6e928ae68e71e5eef85e655d09ba89276fd0d10c Mon Sep 17 00:00:00 2001 From: Hansen Date: Tue, 24 May 2016 16:19:42 -0500 Subject: [PATCH 01/24] 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/24] 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/24] 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/24] 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/24] 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/24] 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 699ba9c0927c461fcd6a177b77d22a29f7e8d235 Mon Sep 17 00:00:00 2001 From: Hansen Date: Thu, 26 May 2016 11:41:41 -0500 Subject: [PATCH 07/24] add newfromjson command --- addon/ng2/commands/newFromJSON.ts | 102 ++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 addon/ng2/commands/newFromJSON.ts diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts new file mode 100644 index 000000000000..29efd2a8757a --- /dev/null +++ b/addon/ng2/commands/newFromJSON.ts @@ -0,0 +1,102 @@ +import * as chalk from 'chalk'; +import * as Command from 'ember-cli/lib/models/command'; +import * as Project from 'ember-cli/lib/models/project'; +import * as SilentError from 'silent-error'; +import * as validProjectName from 'ember-cli/lib/utilities/valid-project-name'; + +const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); +//const InitCommand = require('./init'); +const NewCommand = require('./new'); +const GenerateCommand = require('./generate'); +const fs = require('fs'); + +const NewFromJSONCommand = Command.extend({ + name: 'newfromjson', + description: `Creates a new directory and runs ${chalk.green('ng init')} in it.`, + works: 'outsideProject', + + availableOptions: [ + { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] }, + { name: 'verbose', type: Boolean, default: false, aliases: ['v'] }, + { name: 'blueprint', type: String, default: 'ng2', aliases: ['b'] }, + { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] }, + { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] }, + { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, + { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] }, + { name: 'directory', type: String, aliases: ['dir'] }, + { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'style', type: String, default: 'css' }, + { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, + { name: 'mobile', type: Boolean, default: false } + ], + + run: function (commandOptions, rawArgs) { + let newProject = new NewCommand({ ui: this.ui, analytics: this.analytics }); + + const projectJSON: JSON = require('./ng-project.json'); + + if (!projectJSON) { + return newProject.run.bind(newProject, commandOptions, rawArgs); + } + const packageName = projectJSON.package.name; + + commandOptions = projectJSON.package.options || commandOptions || {}; + commandOptions.name = packageName; + + if (commandOptions.dryRun) { + commandOptions.skipGit = true; + } + + if (packageName === '.') { + return Promise.reject(new SilentError( + `Trying to generate an application structure in this directory? Use "ng init" ` + + `instead.`)); + } + + if (!validProjectName(packageName)) { + return Promise.reject( + new SilentError(`We currently do not support a name of "${packageName}".`)); + } + + commandOptions.blueprint = normalizeBlueprint(commandOptions.blueprint); + + if (!commandOptions.directory) { + commandOptions.directory = packageName; + } + + rawArgs.push(packageName); + + return newProject.run.bind(newProject, commandOptions, rawArgs) + .then( + () => { + var cwd = process.cwd(); + process.chdir(`${packageName}/app`); + const createAndStepIntoDirectory = + new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); + + if (projectJSON.routes && projectJSON.routes.length) { + createAndStepIntoDirectory + .run({ + directoryName: 'routes', + dryRun: commandOptions.dryRun + }) + .then(() => { + projectJSON.routes.forEach((route) => { + let newRoute = new GenerateCommand(); + newRoute.beforeRun(['route', route]); + }) + }) + }; + if (projectJSON.components && projectJSON.components.length) { }; + if (projectJSON.directives && projectJSON.directives.length) { }; + if (projectJSON.services && projectJSON.services.length) { }; + if (projectJSON.pipes && projectJSON.pipes.length) { }; + if (projectJSON.classes && projectJSON.classes.length) { }; + if (projectJSON.enums && projectJSON.enums.length) { }; + return { initialDirectory: cwd }; + }) + } +}); + +module.exports = NewFromJSONCommand; +module.exports.overrideCore = true; From 0eb603580bfd8f75669168f93cd941c4bfacc87a Mon Sep 17 00:00:00 2001 From: Hansen Date: Thu, 26 May 2016 11:50:41 -0500 Subject: [PATCH 08/24] add newfromjson command --- addon/ng2/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/ng2/index.js b/addon/ng2/index.js index cb5a3b548acc..d3cc062e15bd 100644 --- a/addon/ng2/index.js +++ b/addon/ng2/index.js @@ -13,6 +13,7 @@ module.exports = { includedCommands: function () { return { 'new': require('./commands/new'), + 'newfromjson': require('./commands/newFromJSON'), 'generate': require('./commands/generate'), 'init': require('./commands/init'), 'test': require('./commands/test'), From 3aa99c2289af068924000f3d7fe99f077e3946b7 Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 14:41:07 -0500 Subject: [PATCH 09/24] add newfromjson command to parse json file --- addon/ng2/commands/generate.ts | 6 +- addon/ng2/commands/new.ts | 5 +- addon/ng2/commands/newFromJSON.ts | 221 ++++++++++++++++++++------ addon/ng2/models/newFromJSON.model.ts | 44 +++++ package.json | 2 +- typings.json | 5 +- 6 files changed, 227 insertions(+), 56 deletions(-) create mode 100644 addon/ng2/models/newFromJSON.model.ts diff --git a/addon/ng2/commands/generate.ts b/addon/ng2/commands/generate.ts index 80b34ceca9b7..72521ed84571 100644 --- a/addon/ng2/commands/generate.ts +++ b/addon/ng2/commands/generate.ts @@ -10,13 +10,15 @@ const GenerateCommand = EmberGenerateCommand.extend({ name: 'generate', beforeRun: function(rawArgs) { + this.ui.writeLine(chalk.green(`The raw arguments are now ${rawArgs}`)); + this.ui.writeLine(chalk.green(`The current path is ${process.cwd()}`)); if (!rawArgs.length) { return; } // map the blueprint name to allow for aliases rawArgs[0] = mapBlueprintName(rawArgs[0]); - + this.ui.writeLine(chalk.green(`The blueprint is now ${rawArgs[0]}`)); if (rawArgs[0] !== '--help' && !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`); @@ -38,7 +40,7 @@ const GenerateCommand = EmberGenerateCommand.extend({ this.ui.writeLine(chalk.cyan(' Available blueprints')); this.ui.writeLine(output); }; - + this.ui.writeLine(chalk.green(`The raw arguments are now ${arguments}`)); return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments); } }); diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index 685e4e3e1124..f33339ab5cec 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -1,3 +1,5 @@ +/// + import * as chalk from 'chalk'; import * as Command from 'ember-cli/lib/models/command'; import * as Project from 'ember-cli/lib/models/project'; @@ -29,7 +31,8 @@ const NewCommand = Command.extend({ run: function (commandOptions, rawArgs) { const packageName = rawArgs.shift(); - + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); if (!packageName) { return Promise.reject(new SilentError( `The "ng ${this.name}" command requires a name argument to be specified. ` + diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts index 29efd2a8757a..1a4e0f4665cc 100644 --- a/addon/ng2/commands/newFromJSON.ts +++ b/addon/ng2/commands/newFromJSON.ts @@ -1,18 +1,25 @@ +/// + import * as chalk from 'chalk'; import * as Command from 'ember-cli/lib/models/command'; import * as Project from 'ember-cli/lib/models/project'; import * as SilentError from 'silent-error'; import * as validProjectName from 'ember-cli/lib/utilities/valid-project-name'; +import * as GenerateCommand from './generate'; +import {NgAppStructure} from '../models/newFromJSON.model'; const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); -//const InitCommand = require('./init'); -const NewCommand = require('./new'); -const GenerateCommand = require('./generate'); const fs = require('fs'); +const exec = require('child_process').execSync; +const async = require('async'); +const NewCommand = require('./new'); +const InitCommand = require('./init'); + +const projectJSON: NgAppStructure = JSON.parse(fs.readFileSync('ng-project.json', 'utf8')); +let generatedItemCount: number = 0; const NewFromJSONCommand = Command.extend({ name: 'newfromjson', - description: `Creates a new directory and runs ${chalk.green('ng init')} in it.`, works: 'outsideProject', availableOptions: [ @@ -31,70 +38,182 @@ const NewFromJSONCommand = Command.extend({ ], run: function (commandOptions, rawArgs) { - let newProject = new NewCommand({ ui: this.ui, analytics: this.analytics }); - - const projectJSON: JSON = require('./ng-project.json'); if (!projectJSON) { - return newProject.run.bind(newProject, commandOptions, rawArgs); + return Promise.reject(new SilentError( + `The "ng ${this.name}" command requires a ng-project.json file. ` + + `For more details, use "ng help".`)); } + + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + const packageName = projectJSON.package.name; + const packageOptions = { + 'blueprint': projectJSON.package.blueprint || commandOptions.blueprint || undefined, + 'dryRun': projectJSON.package.dryRun || commandOptions.dryRun, + 'directory': projectJSON.package.directory || commandOptions.directory || undefined, + 'verbose': projectJSON.package.verbose || commandOptions.verbose, + 'skipNpm': projectJSON.package.skipNpm || commandOptions.skipNpm, + 'skipGit': projectJSON.package.skipGit || commandOptions.skipGit + } + const commandAliases = { + 'classes': 'cl', + 'components': 'c', + 'directives': 'd', + 'enums': 'e', + 'pipes': 'p', + 'routes': 'r', + 'services': 's' + }; + const createAndStepIntoDirectory = + new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); + + let executeCommand = ( + data: { + command: string, + options?: {} + }) => { + let child = exec(data.command, data.options); + }; + + let generatePackage = (options: {}) => { + let commandstring = `ng new ${options.name}`; + if (options.dryRun) { + commandstring += ' --dry-run'; + } + if (options.verbose) { + commandstring += ' --verbose'; + } + if (options.skipNpm) { + commandstring += ' --skip-npm'; + } + if (options.skipGit) { + commandstring += ' --skip-git'; + } + if (options.directory) { + commandstring += ` --directory=${options.directory}`; + } + if (options.blueprint) { + commandstring += ` --blueprint=${options.blueprint}`; + } + let packageGenerator = executeCommand({ + command: commandstring, + options: { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + } + }) + } - commandOptions = projectJSON.package.options || commandOptions || {}; - commandOptions.name = packageName; + let generateItems = ( + data: { + projectJSONProperty: string[], + directoryName: string + }) => { + + this.ui.writeLine(chalk.red(`The current directory is ${process.cwd()}`)); + data.projectJSONProperty.forEach((item: {}, index: number) => { + this.ui.writeLine(chalk.green(`The ${data.directoryName} name is ${item.name}`)); + let commandstring = `ng generate ${commandAliases[data.directoryName]} /${data.directoryName}/${item.name}`; + if (item.flat) { + commandstring += ' --flat'; + } + if (item.default) { + commandstring += ' --default'; + } + if (item.skipRouterGeneration) { + commandstring += ' --skip-router-generation'; + } + if (item.lazy === false) { + commandstring += ' --lazy'; + } + if (item.route) { + commandstring += ` --route=${item.route}`; + } + let itemGenerator = executeCommand( + { + command: commandstring, + options: { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + } + }); + }); + }; + const generateItemsFromJSON = (obj: NgAppStructure) => { + let itemsToGenerateExist = false; + for (let prop in obj) { + let objProp = obj[prop]; + if (prop !== 'package' && objProp.length > 0) { + itemsToGenerateExist = true; + createAndStepIntoDirectory + .run({ + directoryName: prop, + dryRun: commandOptions.dryRun + }) + .then((dirName: string) => { + this.ui.writeLine(chalk.green(`The ${prop} name is ${dirName}`)); + generateItems( + { + projectJSONProperty: objProp, + directoryName: prop + }); + }) + .catch(() => { + generateItems( + { + projectJSONProperty: objProp, + directoryName: prop + }); + }); + } + } + if (!itemsToGenerateExist) { + return; + } + } - if (commandOptions.dryRun) { - commandOptions.skipGit = true; + if (packageOptions) { + if (packageOptions.dryRun) { + commandOptions.dryRun = true; + } + + if (packageOptions.blueprint) { + commandOptions.blueprint = packageOptions.blueprint; + } + + if (packageOptions.directory) { + commandOptions.directory = packageOptions.directory; + } } - if (packageName === '.') { + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); + if (!packageName) { return Promise.reject(new SilentError( - `Trying to generate an application structure in this directory? Use "ng init" ` + - `instead.`)); + `The "ng ${this.name}" command requires a name argument to be specified. ` + + `For more details, use "ng help".`)); } - if (!validProjectName(packageName)) { - return Promise.reject( - new SilentError(`We currently do not support a name of "${packageName}".`)); + commandOptions.name = packageName; + if (commandOptions.dryRun) { + commandOptions.skipGit = true; } commandOptions.blueprint = normalizeBlueprint(commandOptions.blueprint); - if (!commandOptions.directory) { - commandOptions.directory = packageName; + const runCommand = (options: {}, ngAppObj:NgAppStructure, callback) => { + generatePackage(options); + process.chdir(`${packageName}/src/app`); + generateItemsFromJSON(ngAppObj); + callback('Items Generated!'); } - rawArgs.push(packageName); - - return newProject.run.bind(newProject, commandOptions, rawArgs) - .then( - () => { - var cwd = process.cwd(); - process.chdir(`${packageName}/app`); - const createAndStepIntoDirectory = - new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); - - if (projectJSON.routes && projectJSON.routes.length) { - createAndStepIntoDirectory - .run({ - directoryName: 'routes', - dryRun: commandOptions.dryRun - }) - .then(() => { - projectJSON.routes.forEach((route) => { - let newRoute = new GenerateCommand(); - newRoute.beforeRun(['route', route]); - }) - }) - }; - if (projectJSON.components && projectJSON.components.length) { }; - if (projectJSON.directives && projectJSON.directives.length) { }; - if (projectJSON.services && projectJSON.services.length) { }; - if (projectJSON.pipes && projectJSON.pipes.length) { }; - if (projectJSON.classes && projectJSON.classes.length) { }; - if (projectJSON.enums && projectJSON.enums.length) { }; - return { initialDirectory: cwd }; - }) + return runCommand(commandOptions, projectJSON, (result: string) => { + this.ui.writeLine(chalk.green(result)); + }); } }); diff --git a/addon/ng2/models/newFromJSON.model.ts b/addon/ng2/models/newFromJSON.model.ts new file mode 100644 index 000000000000..387caeb00831 --- /dev/null +++ b/addon/ng2/models/newFromJSON.model.ts @@ -0,0 +1,44 @@ +export interface NgAppStructure extends JSON{ + package: { + name: string, + blueprint?: string, + dryRun?: boolean, + verbose?: boolean, + skipNpm?: boolean, + skipGit?: boolean, + directory?: string + }, + routes?: { + name: string, + flat?: boolean, + default?: boolean, + lazy?: boolean, + skipRouterGeneration?: boolean, + route?: string + }[], + components?: { + name: string, + flat?: boolean, + route?: string + }[], + pipes?: { + name: string, + flat?: boolean + }[], + services?: { + name: string, + flat?: boolean + }[], + directives?: { + name: string, + flat?: boolean + }[], + classes?: { + name: string, + flat?: boolean + }[], + enums?: { + name: string, + flat?: boolean + }[] +} \ No newline at end of file diff --git a/package.json b/package.json index 2e40130cc93a..1375980de33c 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "symlink-or-copy": "^1.0.3", "systemjs-builder": "0.15.17", "typescript": "^1.8.10", - "typings": "^0.8.1" + "typings": "^1.0.4" }, "ember-addon": { "paths": [ diff --git a/typings.json b/typings.json index e9093d1857fc..e179ebc5b89a 100644 --- a/typings.json +++ b/typings.json @@ -3,7 +3,7 @@ "devDependencies": { "chalk": "github:typings/typed-chalk#a7e422c5455e70292e5675a727d43a7b05fc3e58" }, - "ambientDevDependencies": { + "globalDevDependencies": { "assertion-error": "github:DefinitelyTyped/DefinitelyTyped/assertion-error/assertion-error.d.ts#800a7047cf275cc9f695cbd116748cd408a09d6d", "chai": "github:DefinitelyTyped/DefinitelyTyped/chai/chai.d.ts#9c25433c84251bfe72bf0030a95edbbb2c81c9d5", "glob": "github:DefinitelyTyped/DefinitelyTyped/glob/glob.d.ts#a14d724826174d1669d4df04c80f4838b7e71fdf", @@ -12,5 +12,8 @@ "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#8cf8164641be73e8f1e652c2a5b967c7210b6729", "shelljs": "github:DefinitelyTyped/DefinitelyTyped/shelljs/shelljs.d.ts#ce14ae27a020194da3d35aa3468ca1e9e5296316", "through": "github:DefinitelyTyped/DefinitelyTyped/through/through.d.ts#4ffee4a839f36d4f13ea7b0bc03ed2ca853e79d5" + }, + "globalDependencies": { + "ember": "registry:dt/ember#1.11.3+20160317120654" } } From d16a2996a8b4eadc67c9793c7c8affb84214effd Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 14:59:27 -0500 Subject: [PATCH 10/24] remove custom thingy --- .../CustomMaster/files/.clang-format | 3 - .../CustomMaster/files/.editorconfig | 14 -- .../files/__path__/CustomMaster.html | 145 ------------------ .../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 5430 -> 0 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 | 53 ------- .../CustomMaster/files/public/.gitignore | 0 .../CustomMaster/files/public/.npmignore | 0 .../blueprints/CustomMaster/files/tslint.json | 72 --------- .../CustomMaster/files/typings.json | 12 -- addon/ng2/blueprints/CustomMaster/index.js | 67 -------- 35 files changed, 831 deletions(-) delete mode 100644 addon/ng2/blueprints/CustomMaster/files/.clang-format delete mode 100644 addon/ng2/blueprints/CustomMaster/files/.editorconfig delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/index.html delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/main.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/gitignore delete mode 100644 addon/ng2/blueprints/CustomMaster/files/package.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.gitignore delete mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.npmignore delete mode 100644 addon/ng2/blueprints/CustomMaster/files/tslint.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/typings.json delete 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 deleted file mode 100644 index 8d1c3c310286..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/.clang-format +++ /dev/null @@ -1,3 +0,0 @@ -Language: JavaScript -BasedOnStyle: Google -ColumnLimit: 100 diff --git a/addon/ng2/blueprints/CustomMaster/files/.editorconfig b/addon/ng2/blueprints/CustomMaster/files/.editorconfig deleted file mode 100644 index 20380c701c90..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -# 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 deleted file mode 100644 index e44113e34a6d..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
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. -
- - - -
-
-
- - <% 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__/app/__name__.component.__styleext__ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html deleted file mode 100644 index b6931b538a2c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html +++ /dev/null @@ -1,3 +0,0 @@ -

- {{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 deleted file mode 100644 index dff262b07022..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index eee28ef5b129..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 79ee96fdfdbd..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 deleted file mode 100644 index f0f2d38acd4b..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico b/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico deleted file mode 100644 index 8081c7ceaf2be08bf59010158c586170d9d2d517..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 deleted file mode 100644 index 7e3a658095d0..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index cc549606a2a4..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts +++ /dev/null @@ -1,55 +0,0 @@ -/*********************************************************************************************** - * 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 deleted file mode 100644 index bc7e4503c6b1..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "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 deleted file mode 100644 index df29a85ca4a3..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -<% 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 deleted file mode 100644 index e4480f7b7802..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js +++ /dev/null @@ -1,17 +0,0 @@ -/* global require, module */ - -var Angular2SharePointApp = require('angular-cli/lib/broccoli/angular2-sharepoint-app'); - -module.exports = function(defaults) { - return new Angular2SharePointApp(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 deleted file mode 100644 index 5b96ba0ba88c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/angular-cli.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "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 deleted file mode 100644 index ffe8aed76642..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 4fa28880da9f..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/environment.js +++ /dev/null @@ -1,10 +0,0 @@ -/* 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 deleted file mode 100644 index 3612073bc31c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index c1693a0baa95..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js +++ /dev/null @@ -1,51 +0,0 @@ -/*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 deleted file mode 100644 index d39036fa52ff..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js +++ /dev/null @@ -1,42 +0,0 @@ -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 deleted file mode 100644 index 57f4f87dd7b4..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js +++ /dev/null @@ -1,29 +0,0 @@ -/*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 deleted file mode 100644 index 5b020693bc2a..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index c68572d8a7d9..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index 29de61073fac..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "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 deleted file mode 100644 index 9c2f2d0252ef..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/addon/ng2/blueprints/CustomMaster/files/gitignore b/addon/ng2/blueprints/CustomMaster/files/gitignore deleted file mode 100644 index 3422917e0af7..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# 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 deleted file mode 100644 index 8519d699a918..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "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", - "@angular/http": "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 deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/public/.npmignore b/addon/ng2/blueprints/CustomMaster/files/public/.npmignore deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/tslint.json b/addon/ng2/blueprints/CustomMaster/files/tslint.json deleted file mode 100644 index e32421f56763..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/tslint.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "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 deleted file mode 100644 index 2d27535cd43c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/typings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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", - "sharepoint": "registry:dt/sharepoint" - }, - "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 deleted file mode 100644 index 146ef7c50023..000000000000 --- a/addon/ng2/blueprints/CustomMaster/index.js +++ /dev/null @@ -1,67 +0,0 @@ -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 5c7cb95c0763f1dbe569a074cd4608e57fcec770 Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 15:06:04 -0500 Subject: [PATCH 11/24] remove extra write line commands used for debugging --- addon/ng2/commands/new.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index f33339ab5cec..6a2ebbd2d53c 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -31,8 +31,7 @@ const NewCommand = Command.extend({ run: function (commandOptions, rawArgs) { const packageName = rawArgs.shift(); - this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); - this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); + if (!packageName) { return Promise.reject(new SilentError( `The "ng ${this.name}" command requires a name argument to be specified. ` + From 3c686389ab5983bc9b4c775011227b2e1f9cdcb2 Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 15:07:50 -0500 Subject: [PATCH 12/24] remove extra write line commands used for debugging --- .../files/__path__/__name__.service.spec.ts | 17 ----- .../files/__path__/__name__.service.ts | 8 --- .../service/files/__path__/index.ts | 1 - addon/ng2/blueprints/service/index.js | 64 ------------------- addon/ng2/commands/generate.ts | 2 - 5 files changed, 92 deletions(-) delete mode 100644 addon/ng2/blueprints/service/files/__path__/__name__.service.spec.ts delete mode 100644 addon/ng2/blueprints/service/files/__path__/__name__.service.ts delete mode 100644 addon/ng2/blueprints/service/files/__path__/index.ts delete mode 100644 addon/ng2/blueprints/service/index.js diff --git a/addon/ng2/blueprints/service/files/__path__/__name__.service.spec.ts b/addon/ng2/blueprints/service/files/__path__/__name__.service.spec.ts deleted file mode 100644 index 22388d3435ec..000000000000 --- a/addon/ng2/blueprints/service/files/__path__/__name__.service.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { - beforeEachProviders, - it, - describe, - expect, - inject -} from '@angular/core/testing'; -import { <%= classifiedModuleName %>Service } from './<%= dasherizedModuleName %>.service'; - -describe('<%= classifiedModuleName %> Service', () => { - beforeEachProviders(() => [<%= classifiedModuleName %>Service]); - - it('should ...', - inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => { - expect(service).toBeTruthy(); - })); -}); diff --git a/addon/ng2/blueprints/service/files/__path__/__name__.service.ts b/addon/ng2/blueprints/service/files/__path__/__name__.service.ts deleted file mode 100644 index af543328afe0..000000000000 --- a/addon/ng2/blueprints/service/files/__path__/__name__.service.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable() -export class <%= classifiedModuleName %>Service { - - constructor() {} - -} diff --git a/addon/ng2/blueprints/service/files/__path__/index.ts b/addon/ng2/blueprints/service/files/__path__/index.ts deleted file mode 100644 index 78b9dc378f5e..000000000000 --- a/addon/ng2/blueprints/service/files/__path__/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service'; diff --git a/addon/ng2/blueprints/service/index.js b/addon/ng2/blueprints/service/index.js deleted file mode 100644 index 38c87ecf8799..000000000000 --- a/addon/ng2/blueprints/service/index.js +++ /dev/null @@ -1,64 +0,0 @@ -var path = require('path'); -var Blueprint = require('ember-cli/lib/models/blueprint'); -var dynamicPathParser = require('../../utilities/dynamic-path-parser'); -var addBarrelRegistration = require('../../utilities/barrel-management'); -var getFiles = Blueprint.prototype.files; - -module.exports = { - description: '', - - availableOptions: [ - { name: 'flat', type: Boolean, default: true } - ], - - normalizeEntityName: function (entityName) { - var parsedPath = dynamicPathParser(this.project, entityName); - - this.dynamicPath = parsedPath; - return parsedPath.name; - }, - - locals: function (options) { - return { - dynamicPath: this.dynamicPath.dir, - flat: options.flat - }; - }, - - files: function() { - var fileList = getFiles.call(this); - - if (this.options && this.options.flat) { - fileList = fileList.filter(p => p.indexOf('index.ts') <= 0); - } - - return fileList; - }, - - fileMapTokens: function (options) { - // Return custom template variables here. - return { - __path__: () => { - var dir = this.dynamicPath.dir; - if (!options.locals.flat) { - dir += path.sep + options.dasherizedModuleName; - } - this.generatePath = dir; - return dir; - } - }; - }, - - afterInstall: function(options) { - if (!options.flat) { - return addBarrelRegistration( - this, - this.generatePath); - } else { - return addBarrelRegistration( - this, - this.generatePath, - options.entity.name + '.service'); - } - } -}; diff --git a/addon/ng2/commands/generate.ts b/addon/ng2/commands/generate.ts index 72521ed84571..14c6eeb75e1f 100644 --- a/addon/ng2/commands/generate.ts +++ b/addon/ng2/commands/generate.ts @@ -10,8 +10,6 @@ const GenerateCommand = EmberGenerateCommand.extend({ name: 'generate', beforeRun: function(rawArgs) { - this.ui.writeLine(chalk.green(`The raw arguments are now ${rawArgs}`)); - this.ui.writeLine(chalk.green(`The current path is ${process.cwd()}`)); if (!rawArgs.length) { return; } From d0e0b72ad0d2febaeb68faa00984012b8e9748bf Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 15:10:08 -0500 Subject: [PATCH 13/24] add --- .../files/__path__/__name__.service.spec.ts | 17 +++++ .../files/__path__/__name__.service.ts | 8 +++ .../service/files/__path__/index.ts | 1 + .../blueprints/route-test/service/index.js | 64 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts create mode 100644 addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts create mode 100644 addon/ng2/blueprints/route-test/service/files/__path__/index.ts create mode 100644 addon/ng2/blueprints/route-test/service/index.js diff --git a/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts new file mode 100644 index 000000000000..22388d3435ec --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts @@ -0,0 +1,17 @@ +import { + beforeEachProviders, + it, + describe, + expect, + inject +} from '@angular/core/testing'; +import { <%= classifiedModuleName %>Service } from './<%= dasherizedModuleName %>.service'; + +describe('<%= classifiedModuleName %> Service', () => { + beforeEachProviders(() => [<%= classifiedModuleName %>Service]); + + it('should ...', + inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts new file mode 100644 index 000000000000..af543328afe0 --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@angular/core'; + +@Injectable() +export class <%= classifiedModuleName %>Service { + + constructor() {} + +} diff --git a/addon/ng2/blueprints/route-test/service/files/__path__/index.ts b/addon/ng2/blueprints/route-test/service/files/__path__/index.ts new file mode 100644 index 000000000000..78b9dc378f5e --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/files/__path__/index.ts @@ -0,0 +1 @@ +export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service'; diff --git a/addon/ng2/blueprints/route-test/service/index.js b/addon/ng2/blueprints/route-test/service/index.js new file mode 100644 index 000000000000..38c87ecf8799 --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/index.js @@ -0,0 +1,64 @@ +var path = require('path'); +var Blueprint = require('ember-cli/lib/models/blueprint'); +var dynamicPathParser = require('../../utilities/dynamic-path-parser'); +var addBarrelRegistration = require('../../utilities/barrel-management'); +var getFiles = Blueprint.prototype.files; + +module.exports = { + description: '', + + availableOptions: [ + { name: 'flat', type: Boolean, default: true } + ], + + normalizeEntityName: function (entityName) { + var parsedPath = dynamicPathParser(this.project, entityName); + + this.dynamicPath = parsedPath; + return parsedPath.name; + }, + + locals: function (options) { + return { + dynamicPath: this.dynamicPath.dir, + flat: options.flat + }; + }, + + files: function() { + var fileList = getFiles.call(this); + + if (this.options && this.options.flat) { + fileList = fileList.filter(p => p.indexOf('index.ts') <= 0); + } + + return fileList; + }, + + fileMapTokens: function (options) { + // Return custom template variables here. + return { + __path__: () => { + var dir = this.dynamicPath.dir; + if (!options.locals.flat) { + dir += path.sep + options.dasherizedModuleName; + } + this.generatePath = dir; + return dir; + } + }; + }, + + afterInstall: function(options) { + if (!options.flat) { + return addBarrelRegistration( + this, + this.generatePath); + } else { + return addBarrelRegistration( + this, + this.generatePath, + options.entity.name + '.service'); + } + } +}; From ea8cb1cf37dd93967c53dca90c1180e1b3320211 Mon Sep 17 00:00:00 2001 From: Ken Date: Wed, 8 Jun 2016 10:34:27 -0500 Subject: [PATCH 14/24] change --lazy flag to --lazy=false in generate route command --- addon/ng2/commands/newFromJSON.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts index 1a4e0f4665cc..285e7089f882 100644 --- a/addon/ng2/commands/newFromJSON.ts +++ b/addon/ng2/commands/newFromJSON.ts @@ -126,7 +126,7 @@ const NewFromJSONCommand = Command.extend({ commandstring += ' --skip-router-generation'; } if (item.lazy === false) { - commandstring += ' --lazy'; + commandstring += ' --lazy=false'; } if (item.route) { commandstring += ` --route=${item.route}`; From adf21fb09196c21234f6129fc7c9b36cb55d44b0 Mon Sep 17 00:00:00 2001 From: Ken Date: Wed, 8 Jun 2016 11:56:03 -0500 Subject: [PATCH 15/24] remove sharepoint app from broccoli --- lib/broccoli/angular2-sharepoint-app.js | 472 ------------------------ 1 file changed, 472 deletions(-) delete mode 100644 lib/broccoli/angular2-sharepoint-app.js diff --git a/lib/broccoli/angular2-sharepoint-app.js b/lib/broccoli/angular2-sharepoint-app.js deleted file mode 100644 index 759d85da0e2f..000000000000 --- a/lib/broccoli/angular2-sharepoint-app.js +++ /dev/null @@ -1,472 +0,0 @@ -'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 3afeb3f282fc73a31712d35ed0311098835bb8fe Mon Sep 17 00:00:00 2001 From: Hansen Date: Thu, 26 May 2016 11:41:41 -0500 Subject: [PATCH 16/24] add newfromjson command --- addon/ng2/commands/newFromJSON.ts | 102 ++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 addon/ng2/commands/newFromJSON.ts diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts new file mode 100644 index 000000000000..29efd2a8757a --- /dev/null +++ b/addon/ng2/commands/newFromJSON.ts @@ -0,0 +1,102 @@ +import * as chalk from 'chalk'; +import * as Command from 'ember-cli/lib/models/command'; +import * as Project from 'ember-cli/lib/models/project'; +import * as SilentError from 'silent-error'; +import * as validProjectName from 'ember-cli/lib/utilities/valid-project-name'; + +const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); +//const InitCommand = require('./init'); +const NewCommand = require('./new'); +const GenerateCommand = require('./generate'); +const fs = require('fs'); + +const NewFromJSONCommand = Command.extend({ + name: 'newfromjson', + description: `Creates a new directory and runs ${chalk.green('ng init')} in it.`, + works: 'outsideProject', + + availableOptions: [ + { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] }, + { name: 'verbose', type: Boolean, default: false, aliases: ['v'] }, + { name: 'blueprint', type: String, default: 'ng2', aliases: ['b'] }, + { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] }, + { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] }, + { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, + { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] }, + { name: 'directory', type: String, aliases: ['dir'] }, + { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'style', type: String, default: 'css' }, + { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, + { name: 'mobile', type: Boolean, default: false } + ], + + run: function (commandOptions, rawArgs) { + let newProject = new NewCommand({ ui: this.ui, analytics: this.analytics }); + + const projectJSON: JSON = require('./ng-project.json'); + + if (!projectJSON) { + return newProject.run.bind(newProject, commandOptions, rawArgs); + } + const packageName = projectJSON.package.name; + + commandOptions = projectJSON.package.options || commandOptions || {}; + commandOptions.name = packageName; + + if (commandOptions.dryRun) { + commandOptions.skipGit = true; + } + + if (packageName === '.') { + return Promise.reject(new SilentError( + `Trying to generate an application structure in this directory? Use "ng init" ` + + `instead.`)); + } + + if (!validProjectName(packageName)) { + return Promise.reject( + new SilentError(`We currently do not support a name of "${packageName}".`)); + } + + commandOptions.blueprint = normalizeBlueprint(commandOptions.blueprint); + + if (!commandOptions.directory) { + commandOptions.directory = packageName; + } + + rawArgs.push(packageName); + + return newProject.run.bind(newProject, commandOptions, rawArgs) + .then( + () => { + var cwd = process.cwd(); + process.chdir(`${packageName}/app`); + const createAndStepIntoDirectory = + new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); + + if (projectJSON.routes && projectJSON.routes.length) { + createAndStepIntoDirectory + .run({ + directoryName: 'routes', + dryRun: commandOptions.dryRun + }) + .then(() => { + projectJSON.routes.forEach((route) => { + let newRoute = new GenerateCommand(); + newRoute.beforeRun(['route', route]); + }) + }) + }; + if (projectJSON.components && projectJSON.components.length) { }; + if (projectJSON.directives && projectJSON.directives.length) { }; + if (projectJSON.services && projectJSON.services.length) { }; + if (projectJSON.pipes && projectJSON.pipes.length) { }; + if (projectJSON.classes && projectJSON.classes.length) { }; + if (projectJSON.enums && projectJSON.enums.length) { }; + return { initialDirectory: cwd }; + }) + } +}); + +module.exports = NewFromJSONCommand; +module.exports.overrideCore = true; From c7d90979a430655648772c187dca42e45bbbd144 Mon Sep 17 00:00:00 2001 From: Hansen Date: Thu, 26 May 2016 11:50:41 -0500 Subject: [PATCH 17/24] add newfromjson command --- addon/ng2/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addon/ng2/index.js b/addon/ng2/index.js index cb5a3b548acc..d3cc062e15bd 100644 --- a/addon/ng2/index.js +++ b/addon/ng2/index.js @@ -13,6 +13,7 @@ module.exports = { includedCommands: function () { return { 'new': require('./commands/new'), + 'newfromjson': require('./commands/newFromJSON'), 'generate': require('./commands/generate'), 'init': require('./commands/init'), 'test': require('./commands/test'), From c0476c071f975299b8fc501fe4283ae6ca83142f Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 14:41:07 -0500 Subject: [PATCH 18/24] add newfromjson command to parse json file --- addon/ng2/commands/generate.ts | 6 +- addon/ng2/commands/new.ts | 5 +- addon/ng2/commands/newFromJSON.ts | 221 ++++++++++++++++++++------ addon/ng2/models/newFromJSON.model.ts | 44 +++++ package.json | 2 +- typings.json | 5 +- 6 files changed, 227 insertions(+), 56 deletions(-) create mode 100644 addon/ng2/models/newFromJSON.model.ts diff --git a/addon/ng2/commands/generate.ts b/addon/ng2/commands/generate.ts index 80b34ceca9b7..72521ed84571 100644 --- a/addon/ng2/commands/generate.ts +++ b/addon/ng2/commands/generate.ts @@ -10,13 +10,15 @@ const GenerateCommand = EmberGenerateCommand.extend({ name: 'generate', beforeRun: function(rawArgs) { + this.ui.writeLine(chalk.green(`The raw arguments are now ${rawArgs}`)); + this.ui.writeLine(chalk.green(`The current path is ${process.cwd()}`)); if (!rawArgs.length) { return; } // map the blueprint name to allow for aliases rawArgs[0] = mapBlueprintName(rawArgs[0]); - + this.ui.writeLine(chalk.green(`The blueprint is now ${rawArgs[0]}`)); if (rawArgs[0] !== '--help' && !fs.existsSync(path.join(__dirname, '..', 'blueprints', rawArgs[0]))) { SilentError.debugOrThrow('angular-cli/commands/generate', `Invalid blueprint: ${rawArgs[0]}`); @@ -38,7 +40,7 @@ const GenerateCommand = EmberGenerateCommand.extend({ this.ui.writeLine(chalk.cyan(' Available blueprints')); this.ui.writeLine(output); }; - + this.ui.writeLine(chalk.green(`The raw arguments are now ${arguments}`)); return EmberGenerateCommand.prototype.beforeRun.apply(this, arguments); } }); diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index 685e4e3e1124..f33339ab5cec 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -1,3 +1,5 @@ +/// + import * as chalk from 'chalk'; import * as Command from 'ember-cli/lib/models/command'; import * as Project from 'ember-cli/lib/models/project'; @@ -29,7 +31,8 @@ const NewCommand = Command.extend({ run: function (commandOptions, rawArgs) { const packageName = rawArgs.shift(); - + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); if (!packageName) { return Promise.reject(new SilentError( `The "ng ${this.name}" command requires a name argument to be specified. ` + diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts index 29efd2a8757a..1a4e0f4665cc 100644 --- a/addon/ng2/commands/newFromJSON.ts +++ b/addon/ng2/commands/newFromJSON.ts @@ -1,18 +1,25 @@ +/// + import * as chalk from 'chalk'; import * as Command from 'ember-cli/lib/models/command'; import * as Project from 'ember-cli/lib/models/project'; import * as SilentError from 'silent-error'; import * as validProjectName from 'ember-cli/lib/utilities/valid-project-name'; +import * as GenerateCommand from './generate'; +import {NgAppStructure} from '../models/newFromJSON.model'; const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); -//const InitCommand = require('./init'); -const NewCommand = require('./new'); -const GenerateCommand = require('./generate'); const fs = require('fs'); +const exec = require('child_process').execSync; +const async = require('async'); +const NewCommand = require('./new'); +const InitCommand = require('./init'); + +const projectJSON: NgAppStructure = JSON.parse(fs.readFileSync('ng-project.json', 'utf8')); +let generatedItemCount: number = 0; const NewFromJSONCommand = Command.extend({ name: 'newfromjson', - description: `Creates a new directory and runs ${chalk.green('ng init')} in it.`, works: 'outsideProject', availableOptions: [ @@ -31,70 +38,182 @@ const NewFromJSONCommand = Command.extend({ ], run: function (commandOptions, rawArgs) { - let newProject = new NewCommand({ ui: this.ui, analytics: this.analytics }); - - const projectJSON: JSON = require('./ng-project.json'); if (!projectJSON) { - return newProject.run.bind(newProject, commandOptions, rawArgs); + return Promise.reject(new SilentError( + `The "ng ${this.name}" command requires a ng-project.json file. ` + + `For more details, use "ng help".`)); } + + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + const packageName = projectJSON.package.name; + const packageOptions = { + 'blueprint': projectJSON.package.blueprint || commandOptions.blueprint || undefined, + 'dryRun': projectJSON.package.dryRun || commandOptions.dryRun, + 'directory': projectJSON.package.directory || commandOptions.directory || undefined, + 'verbose': projectJSON.package.verbose || commandOptions.verbose, + 'skipNpm': projectJSON.package.skipNpm || commandOptions.skipNpm, + 'skipGit': projectJSON.package.skipGit || commandOptions.skipGit + } + const commandAliases = { + 'classes': 'cl', + 'components': 'c', + 'directives': 'd', + 'enums': 'e', + 'pipes': 'p', + 'routes': 'r', + 'services': 's' + }; + const createAndStepIntoDirectory = + new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); + + let executeCommand = ( + data: { + command: string, + options?: {} + }) => { + let child = exec(data.command, data.options); + }; + + let generatePackage = (options: {}) => { + let commandstring = `ng new ${options.name}`; + if (options.dryRun) { + commandstring += ' --dry-run'; + } + if (options.verbose) { + commandstring += ' --verbose'; + } + if (options.skipNpm) { + commandstring += ' --skip-npm'; + } + if (options.skipGit) { + commandstring += ' --skip-git'; + } + if (options.directory) { + commandstring += ` --directory=${options.directory}`; + } + if (options.blueprint) { + commandstring += ` --blueprint=${options.blueprint}`; + } + let packageGenerator = executeCommand({ + command: commandstring, + options: { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + } + }) + } - commandOptions = projectJSON.package.options || commandOptions || {}; - commandOptions.name = packageName; + let generateItems = ( + data: { + projectJSONProperty: string[], + directoryName: string + }) => { + + this.ui.writeLine(chalk.red(`The current directory is ${process.cwd()}`)); + data.projectJSONProperty.forEach((item: {}, index: number) => { + this.ui.writeLine(chalk.green(`The ${data.directoryName} name is ${item.name}`)); + let commandstring = `ng generate ${commandAliases[data.directoryName]} /${data.directoryName}/${item.name}`; + if (item.flat) { + commandstring += ' --flat'; + } + if (item.default) { + commandstring += ' --default'; + } + if (item.skipRouterGeneration) { + commandstring += ' --skip-router-generation'; + } + if (item.lazy === false) { + commandstring += ' --lazy'; + } + if (item.route) { + commandstring += ` --route=${item.route}`; + } + let itemGenerator = executeCommand( + { + command: commandstring, + options: { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + } + }); + }); + }; + const generateItemsFromJSON = (obj: NgAppStructure) => { + let itemsToGenerateExist = false; + for (let prop in obj) { + let objProp = obj[prop]; + if (prop !== 'package' && objProp.length > 0) { + itemsToGenerateExist = true; + createAndStepIntoDirectory + .run({ + directoryName: prop, + dryRun: commandOptions.dryRun + }) + .then((dirName: string) => { + this.ui.writeLine(chalk.green(`The ${prop} name is ${dirName}`)); + generateItems( + { + projectJSONProperty: objProp, + directoryName: prop + }); + }) + .catch(() => { + generateItems( + { + projectJSONProperty: objProp, + directoryName: prop + }); + }); + } + } + if (!itemsToGenerateExist) { + return; + } + } - if (commandOptions.dryRun) { - commandOptions.skipGit = true; + if (packageOptions) { + if (packageOptions.dryRun) { + commandOptions.dryRun = true; + } + + if (packageOptions.blueprint) { + commandOptions.blueprint = packageOptions.blueprint; + } + + if (packageOptions.directory) { + commandOptions.directory = packageOptions.directory; + } } - if (packageName === '.') { + this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); + if (!packageName) { return Promise.reject(new SilentError( - `Trying to generate an application structure in this directory? Use "ng init" ` + - `instead.`)); + `The "ng ${this.name}" command requires a name argument to be specified. ` + + `For more details, use "ng help".`)); } - if (!validProjectName(packageName)) { - return Promise.reject( - new SilentError(`We currently do not support a name of "${packageName}".`)); + commandOptions.name = packageName; + if (commandOptions.dryRun) { + commandOptions.skipGit = true; } commandOptions.blueprint = normalizeBlueprint(commandOptions.blueprint); - if (!commandOptions.directory) { - commandOptions.directory = packageName; + const runCommand = (options: {}, ngAppObj:NgAppStructure, callback) => { + generatePackage(options); + process.chdir(`${packageName}/src/app`); + generateItemsFromJSON(ngAppObj); + callback('Items Generated!'); } - rawArgs.push(packageName); - - return newProject.run.bind(newProject, commandOptions, rawArgs) - .then( - () => { - var cwd = process.cwd(); - process.chdir(`${packageName}/app`); - const createAndStepIntoDirectory = - new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); - - if (projectJSON.routes && projectJSON.routes.length) { - createAndStepIntoDirectory - .run({ - directoryName: 'routes', - dryRun: commandOptions.dryRun - }) - .then(() => { - projectJSON.routes.forEach((route) => { - let newRoute = new GenerateCommand(); - newRoute.beforeRun(['route', route]); - }) - }) - }; - if (projectJSON.components && projectJSON.components.length) { }; - if (projectJSON.directives && projectJSON.directives.length) { }; - if (projectJSON.services && projectJSON.services.length) { }; - if (projectJSON.pipes && projectJSON.pipes.length) { }; - if (projectJSON.classes && projectJSON.classes.length) { }; - if (projectJSON.enums && projectJSON.enums.length) { }; - return { initialDirectory: cwd }; - }) + return runCommand(commandOptions, projectJSON, (result: string) => { + this.ui.writeLine(chalk.green(result)); + }); } }); diff --git a/addon/ng2/models/newFromJSON.model.ts b/addon/ng2/models/newFromJSON.model.ts new file mode 100644 index 000000000000..387caeb00831 --- /dev/null +++ b/addon/ng2/models/newFromJSON.model.ts @@ -0,0 +1,44 @@ +export interface NgAppStructure extends JSON{ + package: { + name: string, + blueprint?: string, + dryRun?: boolean, + verbose?: boolean, + skipNpm?: boolean, + skipGit?: boolean, + directory?: string + }, + routes?: { + name: string, + flat?: boolean, + default?: boolean, + lazy?: boolean, + skipRouterGeneration?: boolean, + route?: string + }[], + components?: { + name: string, + flat?: boolean, + route?: string + }[], + pipes?: { + name: string, + flat?: boolean + }[], + services?: { + name: string, + flat?: boolean + }[], + directives?: { + name: string, + flat?: boolean + }[], + classes?: { + name: string, + flat?: boolean + }[], + enums?: { + name: string, + flat?: boolean + }[] +} \ No newline at end of file diff --git a/package.json b/package.json index 2e40130cc93a..1375980de33c 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "symlink-or-copy": "^1.0.3", "systemjs-builder": "0.15.17", "typescript": "^1.8.10", - "typings": "^0.8.1" + "typings": "^1.0.4" }, "ember-addon": { "paths": [ diff --git a/typings.json b/typings.json index e9093d1857fc..e179ebc5b89a 100644 --- a/typings.json +++ b/typings.json @@ -3,7 +3,7 @@ "devDependencies": { "chalk": "github:typings/typed-chalk#a7e422c5455e70292e5675a727d43a7b05fc3e58" }, - "ambientDevDependencies": { + "globalDevDependencies": { "assertion-error": "github:DefinitelyTyped/DefinitelyTyped/assertion-error/assertion-error.d.ts#800a7047cf275cc9f695cbd116748cd408a09d6d", "chai": "github:DefinitelyTyped/DefinitelyTyped/chai/chai.d.ts#9c25433c84251bfe72bf0030a95edbbb2c81c9d5", "glob": "github:DefinitelyTyped/DefinitelyTyped/glob/glob.d.ts#a14d724826174d1669d4df04c80f4838b7e71fdf", @@ -12,5 +12,8 @@ "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#8cf8164641be73e8f1e652c2a5b967c7210b6729", "shelljs": "github:DefinitelyTyped/DefinitelyTyped/shelljs/shelljs.d.ts#ce14ae27a020194da3d35aa3468ca1e9e5296316", "through": "github:DefinitelyTyped/DefinitelyTyped/through/through.d.ts#4ffee4a839f36d4f13ea7b0bc03ed2ca853e79d5" + }, + "globalDependencies": { + "ember": "registry:dt/ember#1.11.3+20160317120654" } } From 80d930926727050372413577ca5a48f8384bbd1e Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 14:59:27 -0500 Subject: [PATCH 19/24] remove custom thingy --- .../CustomMaster/files/.clang-format | 3 - .../CustomMaster/files/.editorconfig | 14 -- .../files/__path__/CustomMaster.html | 145 ------------------ .../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 5430 -> 0 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 | 53 ------- .../CustomMaster/files/public/.gitignore | 0 .../CustomMaster/files/public/.npmignore | 0 .../blueprints/CustomMaster/files/tslint.json | 72 --------- .../CustomMaster/files/typings.json | 12 -- addon/ng2/blueprints/CustomMaster/index.js | 67 -------- 35 files changed, 831 deletions(-) delete mode 100644 addon/ng2/blueprints/CustomMaster/files/.clang-format delete mode 100644 addon/ng2/blueprints/CustomMaster/files/.editorconfig delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/app/shared/index.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/index.html delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/main.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/angular-cli.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts delete mode 100644 addon/ng2/blueprints/CustomMaster/files/gitignore delete mode 100644 addon/ng2/blueprints/CustomMaster/files/package.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.gitignore delete mode 100644 addon/ng2/blueprints/CustomMaster/files/public/.npmignore delete mode 100644 addon/ng2/blueprints/CustomMaster/files/tslint.json delete mode 100644 addon/ng2/blueprints/CustomMaster/files/typings.json delete 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 deleted file mode 100644 index 8d1c3c310286..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/.clang-format +++ /dev/null @@ -1,3 +0,0 @@ -Language: JavaScript -BasedOnStyle: Google -ColumnLimit: 100 diff --git a/addon/ng2/blueprints/CustomMaster/files/.editorconfig b/addon/ng2/blueprints/CustomMaster/files/.editorconfig deleted file mode 100644 index 20380c701c90..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -# 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 deleted file mode 100644 index e44113e34a6d..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/CustomMaster.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
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. -
- - - -
-
-
- - <% 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__/app/__name__.component.__styleext__ b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.__styleext__ deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html b/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html deleted file mode 100644 index b6931b538a2c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.html +++ /dev/null @@ -1,3 +0,0 @@ -

- {{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 deleted file mode 100644 index dff262b07022..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index eee28ef5b129..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/__name__.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 79ee96fdfdbd..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/environment.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 deleted file mode 100644 index f0f2d38acd4b..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/app/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico b/addon/ng2/blueprints/CustomMaster/files/__path__/favicon.ico deleted file mode 100644 index 8081c7ceaf2be08bf59010158c586170d9d2d517..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 deleted file mode 100644 index 7e3a658095d0..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/main.ts +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index cc549606a2a4..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/system-config.ts +++ /dev/null @@ -1,55 +0,0 @@ -/*********************************************************************************************** - * 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 deleted file mode 100644 index bc7e4503c6b1..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "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 deleted file mode 100644 index df29a85ca4a3..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/__path__/typings.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -<% 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 deleted file mode 100644 index e4480f7b7802..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/angular-cli-build.js +++ /dev/null @@ -1,17 +0,0 @@ -/* global require, module */ - -var Angular2SharePointApp = require('angular-cli/lib/broccoli/angular2-sharepoint-app'); - -module.exports = function(defaults) { - return new Angular2SharePointApp(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 deleted file mode 100644 index 5b96ba0ba88c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/angular-cli.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "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 deleted file mode 100644 index ffe8aed76642..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/environment.dev.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 4fa28880da9f..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/environment.js +++ /dev/null @@ -1,10 +0,0 @@ -/* 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 deleted file mode 100644 index 3612073bc31c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/environment.prod.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index c1693a0baa95..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/karma-test-shim.js +++ /dev/null @@ -1,51 +0,0 @@ -/*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 deleted file mode 100644 index d39036fa52ff..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/karma.conf.js +++ /dev/null @@ -1,42 +0,0 @@ -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 deleted file mode 100644 index 57f4f87dd7b4..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/config/protractor.conf.js +++ /dev/null @@ -1,29 +0,0 @@ -/*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 deleted file mode 100644 index 5b020693bc2a..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/app.e2e.ts +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index c68572d8a7d9..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/app.po.ts +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index 29de61073fac..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "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 deleted file mode 100644 index 9c2f2d0252ef..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/e2e/typings.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/addon/ng2/blueprints/CustomMaster/files/gitignore b/addon/ng2/blueprints/CustomMaster/files/gitignore deleted file mode 100644 index 3422917e0af7..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# 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 deleted file mode 100644 index 8519d699a918..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "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", - "@angular/http": "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 deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/public/.npmignore b/addon/ng2/blueprints/CustomMaster/files/public/.npmignore deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/addon/ng2/blueprints/CustomMaster/files/tslint.json b/addon/ng2/blueprints/CustomMaster/files/tslint.json deleted file mode 100644 index e32421f56763..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/tslint.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "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 deleted file mode 100644 index 2d27535cd43c..000000000000 --- a/addon/ng2/blueprints/CustomMaster/files/typings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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", - "sharepoint": "registry:dt/sharepoint" - }, - "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 deleted file mode 100644 index 146ef7c50023..000000000000 --- a/addon/ng2/blueprints/CustomMaster/index.js +++ /dev/null @@ -1,67 +0,0 @@ -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 45ba110bf71c651787272a31847543a27e8781ee Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 15:06:04 -0500 Subject: [PATCH 20/24] remove extra write line commands used for debugging --- addon/ng2/commands/new.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index f33339ab5cec..6a2ebbd2d53c 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -31,8 +31,7 @@ const NewCommand = Command.extend({ run: function (commandOptions, rawArgs) { const packageName = rawArgs.shift(); - this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); - this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); + if (!packageName) { return Promise.reject(new SilentError( `The "ng ${this.name}" command requires a name argument to be specified. ` + From 30035ce36887b9d8dbaaad7b97bb27d571c7bcfe Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 7 Jun 2016 15:10:08 -0500 Subject: [PATCH 21/24] add --- .../files/__path__/__name__.service.spec.ts | 17 +++++ .../files/__path__/__name__.service.ts | 8 +++ .../service/files/__path__/index.ts | 1 + .../blueprints/route-test/service/index.js | 64 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts create mode 100644 addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts create mode 100644 addon/ng2/blueprints/route-test/service/files/__path__/index.ts create mode 100644 addon/ng2/blueprints/route-test/service/index.js diff --git a/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts new file mode 100644 index 000000000000..22388d3435ec --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.spec.ts @@ -0,0 +1,17 @@ +import { + beforeEachProviders, + it, + describe, + expect, + inject +} from '@angular/core/testing'; +import { <%= classifiedModuleName %>Service } from './<%= dasherizedModuleName %>.service'; + +describe('<%= classifiedModuleName %> Service', () => { + beforeEachProviders(() => [<%= classifiedModuleName %>Service]); + + it('should ...', + inject([<%= classifiedModuleName %>Service], (service: <%= classifiedModuleName %>Service) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts new file mode 100644 index 000000000000..af543328afe0 --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/files/__path__/__name__.service.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@angular/core'; + +@Injectable() +export class <%= classifiedModuleName %>Service { + + constructor() {} + +} diff --git a/addon/ng2/blueprints/route-test/service/files/__path__/index.ts b/addon/ng2/blueprints/route-test/service/files/__path__/index.ts new file mode 100644 index 000000000000..78b9dc378f5e --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/files/__path__/index.ts @@ -0,0 +1 @@ +export {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service'; diff --git a/addon/ng2/blueprints/route-test/service/index.js b/addon/ng2/blueprints/route-test/service/index.js new file mode 100644 index 000000000000..38c87ecf8799 --- /dev/null +++ b/addon/ng2/blueprints/route-test/service/index.js @@ -0,0 +1,64 @@ +var path = require('path'); +var Blueprint = require('ember-cli/lib/models/blueprint'); +var dynamicPathParser = require('../../utilities/dynamic-path-parser'); +var addBarrelRegistration = require('../../utilities/barrel-management'); +var getFiles = Blueprint.prototype.files; + +module.exports = { + description: '', + + availableOptions: [ + { name: 'flat', type: Boolean, default: true } + ], + + normalizeEntityName: function (entityName) { + var parsedPath = dynamicPathParser(this.project, entityName); + + this.dynamicPath = parsedPath; + return parsedPath.name; + }, + + locals: function (options) { + return { + dynamicPath: this.dynamicPath.dir, + flat: options.flat + }; + }, + + files: function() { + var fileList = getFiles.call(this); + + if (this.options && this.options.flat) { + fileList = fileList.filter(p => p.indexOf('index.ts') <= 0); + } + + return fileList; + }, + + fileMapTokens: function (options) { + // Return custom template variables here. + return { + __path__: () => { + var dir = this.dynamicPath.dir; + if (!options.locals.flat) { + dir += path.sep + options.dasherizedModuleName; + } + this.generatePath = dir; + return dir; + } + }; + }, + + afterInstall: function(options) { + if (!options.flat) { + return addBarrelRegistration( + this, + this.generatePath); + } else { + return addBarrelRegistration( + this, + this.generatePath, + options.entity.name + '.service'); + } + } +}; From 48193248a08ed5df225b801919a41c26feae4a82 Mon Sep 17 00:00:00 2001 From: Ken Date: Wed, 8 Jun 2016 10:34:27 -0500 Subject: [PATCH 22/24] change --lazy flag to --lazy=false in generate route command --- addon/ng2/commands/newFromJSON.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts index 1a4e0f4665cc..285e7089f882 100644 --- a/addon/ng2/commands/newFromJSON.ts +++ b/addon/ng2/commands/newFromJSON.ts @@ -126,7 +126,7 @@ const NewFromJSONCommand = Command.extend({ commandstring += ' --skip-router-generation'; } if (item.lazy === false) { - commandstring += ' --lazy'; + commandstring += ' --lazy=false'; } if (item.route) { commandstring += ` --route=${item.route}`; From b554b1cd404d5ca89116a91ce1a2797a6d2d75d9 Mon Sep 17 00:00:00 2001 From: Ken Date: Wed, 8 Jun 2016 11:56:03 -0500 Subject: [PATCH 23/24] remove sharepoint app from broccoli --- lib/broccoli/angular2-sharepoint-app.js | 472 ------------------------ 1 file changed, 472 deletions(-) delete mode 100644 lib/broccoli/angular2-sharepoint-app.js diff --git a/lib/broccoli/angular2-sharepoint-app.js b/lib/broccoli/angular2-sharepoint-app.js deleted file mode 100644 index 759d85da0e2f..000000000000 --- a/lib/broccoli/angular2-sharepoint-app.js +++ /dev/null @@ -1,472 +0,0 @@ -'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 5553a02ce603b5c2791e9587004b3ef325e964eb Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 14 Jul 2016 09:11:47 -0500 Subject: [PATCH 24/24] update --- addon/ng2/commands/newFromJSON.ts | 320 ++++++++++++++---------------- 1 file changed, 152 insertions(+), 168 deletions(-) diff --git a/addon/ng2/commands/newFromJSON.ts b/addon/ng2/commands/newFromJSON.ts index 285e7089f882..587dd57f4f03 100644 --- a/addon/ng2/commands/newFromJSON.ts +++ b/addon/ng2/commands/newFromJSON.ts @@ -1,61 +1,43 @@ /// -import * as chalk from 'chalk'; import * as Command from 'ember-cli/lib/models/command'; -import * as Project from 'ember-cli/lib/models/project'; import * as SilentError from 'silent-error'; +import { execSync, exec } from 'child_process'; +import * as Promise from 'ember-cli/lib/ext/promise'; +import * as chalk from 'chalk'; +import * as fs from 'fs'; +import * as fse from 'fs-extra'; import * as validProjectName from 'ember-cli/lib/utilities/valid-project-name'; import * as GenerateCommand from './generate'; import {NgAppStructure} from '../models/newFromJSON.model'; const normalizeBlueprint = require('ember-cli/lib/utilities/normalize-blueprint-option'); -const fs = require('fs'); -const exec = require('child_process').execSync; -const async = require('async'); -const NewCommand = require('./new'); -const InitCommand = require('./init'); +const fsReadFile = Promise.denodeify(fs.readFile); +const fsWriteFile = Promise.denodeify(fs.writeFile); +const fsReadDir = Promise.denodeify(fs.readdir); +const fsCopy = Promise.denodeify(fse.copy); +const fileStats = Promise.denodeify(fs.stat); +const execPromise = Promise.denodeify(exec); -const projectJSON: NgAppStructure = JSON.parse(fs.readFileSync('ng-project.json', 'utf8')); -let generatedItemCount: number = 0; const NewFromJSONCommand = Command.extend({ name: 'newfromjson', works: 'outsideProject', availableOptions: [ - { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] }, - { name: 'verbose', type: Boolean, default: false, aliases: ['v'] }, - { name: 'blueprint', type: String, default: 'ng2', aliases: ['b'] }, - { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] }, - { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] }, - { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, - { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] }, - { name: 'directory', type: String, aliases: ['dir'] }, - { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, - { name: 'style', type: String, default: 'css' }, - { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, - { name: 'mobile', type: Boolean, default: false } ], - + run: function (commandOptions, rawArgs) { - if (!projectJSON) { - return Promise.reject(new SilentError( - `The "ng ${this.name}" command requires a ng-project.json file. ` + - `For more details, use "ng help".`)); - } - - this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); + let projectJSON: NgAppStructure; - const packageName = projectJSON.package.name; - const packageOptions = { - 'blueprint': projectJSON.package.blueprint || commandOptions.blueprint || undefined, - 'dryRun': projectJSON.package.dryRun || commandOptions.dryRun, - 'directory': projectJSON.package.directory || commandOptions.directory || undefined, - 'verbose': projectJSON.package.verbose || commandOptions.verbose, - 'skipNpm': projectJSON.package.skipNpm || commandOptions.skipNpm, - 'skipGit': projectJSON.package.skipGit || commandOptions.skipGit - } + const ui = this.ui; + const chDir = process.chdir; + const execOptions = { + cwd: process.cwd(), + maxBuffer: 2000 * 1024, + stdio: [0, 1, 2] + }; const commandAliases = { 'classes': 'cl', 'components': 'c', @@ -65,155 +47,157 @@ const NewFromJSONCommand = Command.extend({ 'routes': 'r', 'services': 's' }; + const createAndStepIntoDirectory = new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics }); - let executeCommand = ( - data: { - command: string, - options?: {} - }) => { - let child = exec(data.command, data.options); + let checkForExisting = (path: string) => { + return fileStats(path); }; - let generatePackage = (options: {}) => { - let commandstring = `ng new ${options.name}`; - if (options.dryRun) { - commandstring += ' --dry-run'; - } - if (options.verbose) { - commandstring += ' --verbose'; - } - if (options.skipNpm) { - commandstring += ' --skip-npm'; - } - if (options.skipGit) { - commandstring += ' --skip-git'; - } - if (options.directory) { - commandstring += ` --directory=${options.directory}`; - } - if (options.blueprint) { - commandstring += ` --blueprint=${options.blueprint}`; - } - let packageGenerator = executeCommand({ - command: commandstring, - options: { - cwd: process.cwd(), - maxBuffer: 2000 * 1024, - stdio: [0, 1, 2] - } - }) - } + let checkForPackage = (packageName: string) => { + return checkForExisting(`${packageName}/angular-cli.json`) + }; - let generateItems = ( - data: { - projectJSONProperty: string[], - directoryName: string - }) => { - - this.ui.writeLine(chalk.red(`The current directory is ${process.cwd()}`)); - data.projectJSONProperty.forEach((item: {}, index: number) => { - this.ui.writeLine(chalk.green(`The ${data.directoryName} name is ${item.name}`)); - let commandstring = `ng generate ${commandAliases[data.directoryName]} /${data.directoryName}/${item.name}`; - if (item.flat) { - commandstring += ' --flat'; - } - if (item.default) { - commandstring += ' --default'; - } - if (item.skipRouterGeneration) { - commandstring += ' --skip-router-generation'; - } - if (item.lazy === false) { - commandstring += ' --lazy=false'; - } - if (item.route) { - commandstring += ` --route=${item.route}`; - } - let itemGenerator = executeCommand( - { - command: commandstring, - options: { - cwd: process.cwd(), - maxBuffer: 2000 * 1024, - stdio: [0, 1, 2] - } - }); - }); + let checkForItem = (typeOfItem: string, itemName: string) => { + return checkForExisting(`${typeOfItem}/${itemName}`) + }; + + let newPackage = (packageObject: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) => { + return checkForPackage(packageObject.name) + .then(() => { + let msg = `${packageObject.name} already exists, changing directories.` + ui.writeLine(chalk.yellow(msg)); + Promise.resolve(); + }) + .catch(() => { + let commandString = execCommandString('package', packageObject); + //return execSync(commandString, execOptions); + //p_list.push({ process: packageChildProcess, content: "" }); + return execPromise(commandString, execOptions); + }) }; - const generateItemsFromJSON = (obj: NgAppStructure) => { - let itemsToGenerateExist = false; - for (let prop in obj) { - let objProp = obj[prop]; - if (prop !== 'package' && objProp.length > 0) { - itemsToGenerateExist = true; - createAndStepIntoDirectory - .run({ - directoryName: prop, - dryRun: commandOptions.dryRun - }) - .then((dirName: string) => { - this.ui.writeLine(chalk.green(`The ${prop} name is ${dirName}`)); - generateItems( - { - projectJSONProperty: objProp, - directoryName: prop - }); - }) - .catch(() => { - generateItems( - { - projectJSONProperty: objProp, - directoryName: prop - }); - }); - } - } - if (!itemsToGenerateExist) { - return; - } - } - if (packageOptions) { - if (packageOptions.dryRun) { - commandOptions.dryRun = true; - } + let generateItem = (typeOfItem: string, itemObject: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) => { + let itemObjectName = itemObject.lazy === false ? itemObject.name : `+${itemObject.name}`; + return checkForItem(typeOfItem, itemObjectName) + .then(() => { + let msg = `${itemObject.name} already exists, moving on.`; + ui.writeLine(chalk.yellow(msg)); + Promise.resolve(); + }) + .catch(() => { + let commandString = execCommandString(typeOfItem, itemObject); + //return execSync(commandString, execOptions); + return execPromise(commandString, execOptions); + }); + }; + const itemTypes = ['routes', 'components', 'pipes', 'services', 'directives', 'classes', 'enums']; + + return getJSONFile() + .then(newProject) + .then(changeToProjectDirectory) + .then(makeItemDirectories) + .then(generateProjectItems) + .then(ui.writeLine(chalk.blue(`This should only happen when I'm finished.`))) + .catch((err) => { + ui.writeLine(chalk.red(`This command requires a file named ng-project.json`)); + }); - if (packageOptions.blueprint) { - commandOptions.blueprint = packageOptions.blueprint; - } + function getJSONFile() { + return fsReadFile('ng-project.json', 'utf8') + .then((data: string) => { + projectJSON = JSON.parse(data); + }) + } + + function newProject() { + return newPackage(projectJSON.package) + .then(() => { + ui.writeLine(chalk.green(`${projectJSON.package.name} project complete.`)); + }); + } - if (packageOptions.directory) { - commandOptions.directory = packageOptions.directory; - } + function changeToProjectDirectory() { + return (() => { + chDir(`${projectJSON.package.name}/src/app`) + ui.writeLine(chalk.cyan(`Now in "${projectJSON.package.name}/src/app"...`)); + })(); } - this.ui.writeLine(chalk.cyan(`The raw arguments are ${rawArgs}`)); - this.ui.writeLine(chalk.red(`The packageName is ${packageName}`)); - if (!packageName) { - return Promise.reject(new SilentError( - `The "ng ${this.name}" command requires a name argument to be specified. ` + - `For more details, use "ng help".`)); + function createProjectDirectories(directoryName: string) { + return createAndStepIntoDirectory + .run({ + directoryName: directoryName, + dryRun: projectJSON.package.dryRun + }) } - commandOptions.name = packageName; - if (commandOptions.dryRun) { - commandOptions.skipGit = true; + function createEachItem(typeOfItem: string, item: {}) { + return generateItem(typeOfItem, item) + //.then(() => { + // ui.writeLine(chalk.green(`${item.name} has been created`)); + //}); } - commandOptions.blueprint = normalizeBlueprint(commandOptions.blueprint); + function makeItemDirectories() { + return itemTypes.forEach((type: string) => { + if (projectJSON[type] && projectJSON[type].length) { + return createProjectDirectories(type) + .then((dirName: string) => { + chDir('..'); + ui.writeLine(chalk.cyan(`Now in "${process.cwd()}"...`)); + }) + .catch(() => { + ui.writeLine(chalk.magenta(`Directory "${type}" already exists.`)); + Promise.resolve(); + }); + } + else { return; } + }); + } - const runCommand = (options: {}, ngAppObj:NgAppStructure, callback) => { - generatePackage(options); - process.chdir(`${packageName}/src/app`); - generateItemsFromJSON(ngAppObj); - callback('Items Generated!'); + function generateProjectItems() { + return itemTypes.forEach((type: string) => { + let items: {}[] = projectJSON[type] && projectJSON[type].length ? projectJSON[type] : null; + + if (!!items) { + return items.forEach((item) => { + return generateItem(type, item) + .then(() => { + ui.writeLine(chalk.green(`${item.name} has been created`)); + }) + .catch((err) => { + ui.writeLine(chalk.red(`${item.name} creation has failed with ${err.message}`)); + }); + }); + } + else { return; } + }); } - return runCommand(commandOptions, projectJSON, (result: string) => { - this.ui.writeLine(chalk.green(result)); - }); + function execCommandString(property: string, objectToCreate: { + name: string, blueprint?: string, dryRun?: boolean, verbose?: boolean, skipNpm?: boolean, skipGit?: boolean, directory?: string, flat?: boolean, default?: boolean, lazy?: boolean, skipRouterGeneration?: boolean, route?: string + }) { + let commandstring = property === 'package' ? `ng new ${objectToCreate.name}` : `ng generate ${commandAliases[property]} /${property}/${objectToCreate.name}`; + if (objectToCreate.dryRun) { commandstring += ' --dry-run'; } + if (objectToCreate.verbose) { commandstring += ' --verbose'; } + if (objectToCreate.skipNpm) { commandstring += ' --skip-npm'; } + if (objectToCreate.skipGit) { commandstring += ' --skip-git'; } + if (objectToCreate.directory) { commandstring += ` --directory=${objectToCreate.directory}`; } + if (objectToCreate.blueprint) { commandstring += ` --blueprint=${objectToCreate.blueprint}`; } + if (objectToCreate.flat) { commandstring += ' --flat'; } + if (objectToCreate.default) { commandstring += ' --default'; } + if (objectToCreate.skipRouterGeneration) { commandstring += ' --skip-router-generation'; } + if (objectToCreate.lazy === false) { commandstring += ' --lazy=false'; } + if (objectToCreate.route) { commandstring += ` --route=${objectToCreate.route}`; } + + return commandstring; + } } });