-
Notifications
You must be signed in to change notification settings - Fork 12k
Style guide #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Style guide #427
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
13 changes: 7 additions & 6 deletions
13
...component/files/__path__/__name__.spec.ts → ...files/__path__/__name__.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
addon/ng2/blueprints/component/files/__path__/__name__.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Component, OnInit} from 'angular2/core'; | ||
|
||
@Component({ | ||
moduleId: __moduleName, | ||
selector: '<%= dasherizedModuleName %>', | ||
templateUrl: '<%= dasherizedModuleName %>.component.html', | ||
styleUrls: ['<%= dasherizedModuleName %>.component.<%= styleExt %>'] | ||
}) | ||
export class <%= classifiedModuleName %>Component implements OnInit { | ||
|
||
constructor() {} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {<%= classifiedModuleName %>Component} from './<%= dasherizedModuleName %>.component'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
var path = require('path'); | ||
var Blueprint = require('ember-cli/lib/models/blueprint'); | ||
var dynamicPathParser = require('../../utilities/dynamic-path-parser'); | ||
|
||
var getFiles = Blueprint.prototype.files; | ||
|
||
module.exports = { | ||
description: '', | ||
|
||
availableOptions: [ | ||
{ name: 'flat', type: Boolean, default: false, aliases: ['f'] } | ||
{ name: 'flat', type: Boolean, default: false } | ||
], | ||
|
||
normalizeEntityName: function (entityName) { | ||
|
@@ -16,22 +19,60 @@ module.exports = { | |
}, | ||
|
||
locals: function (options) { | ||
//TODO: pull value from config | ||
this.styleExt = 'css'; | ||
|
||
return { | ||
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''), | ||
flat: options.flat | ||
flat: options.flat, | ||
styleExt: this.styleExt, | ||
isLazyRoute: !!options.isLazyRoute, | ||
isAppComponent: !!options.isAppComponent | ||
}; | ||
}, | ||
|
||
files: function() { | ||
var fileList = getFiles.call(this); | ||
|
||
if (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; | ||
|
||
if (options.locals.isLazyRoute) { | ||
var dirParts = dir.split(path.sep); | ||
dirParts[dirParts.length - 1] = `+${dirParts[dirParts.length - 1]}`; | ||
dir = dirParts.join(path.sep); | ||
} | ||
} | ||
this.appDir = dir.replace(`src${path.sep}client${path.sep}`, ''); | ||
return dir; | ||
}, | ||
__styleext__: () => { | ||
return options.locals.styleExt; | ||
} | ||
}; | ||
}, | ||
|
||
afterInstall: function(options) { | ||
if (!options.flat) { | ||
var filePath = path.join('src', 'client', 'system-config.ts'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a point of removing In general we need a better way to find the client source folder. Could be part of the configuration. |
||
var barrelUrl = this.appDir.replace(path.sep, '/'); | ||
return this.insertIntoFile( | ||
filePath, | ||
` '${barrelUrl}',`, | ||
{ before: ' /** @cli-barrel */' } | ||
); | ||
} | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
...ints/directive/files/__path__/__name__.ts → ...tive/files/__path__/__name__.directive.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,59 @@ | ||
/*global jasmine, __karma__, window*/ | ||
Error.stackTraceLimit = Infinity; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; | ||
|
||
__karma__.loaded = function () { | ||
}; | ||
|
||
System.config({ | ||
packages: { | ||
'base/dist/app': { | ||
defaultExtension: false, | ||
format: 'register', | ||
map: Object.keys(window.__karma__.files) | ||
.filter(onlyAppFiles) | ||
.reduce(function (pathsMapping, appPath) { | ||
var moduleName = appPath.replace(/^\/base\/dist\/app\//, './').replace(/\.js$/, ''); | ||
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]; | ||
return pathsMapping; | ||
}, {}) | ||
} | ||
} | ||
}); | ||
var distPath = '/base/dist/'; | ||
var appPath = distPath + 'app/'; | ||
|
||
System.import('angular2/testing').then(function (testing) { | ||
return System.import('angular2/platform/testing/browser').then(function (providers) { | ||
testing.setBaseTestProviders(providers.TEST_BROWSER_PLATFORM_PROVIDERS, | ||
providers.TEST_BROWSER_APPLICATION_PROVIDERS); | ||
}); | ||
}).then(function () { | ||
return Promise.all( | ||
Object.keys(window.__karma__.files) | ||
.filter(onlySpecFiles) | ||
.map(function (moduleName) { | ||
return System.import(moduleName); | ||
})); | ||
}).then(function () { | ||
__karma__.start(); | ||
}, function (error) { | ||
__karma__.error(error.stack || error); | ||
}); | ||
|
||
function onlyAppFiles(filePath) { | ||
return /^\/base\/dist\/app\/(?!.*\.spec\.js$)([a-z0-9-_\.\/]+)\.js$/.test(filePath); | ||
function isJsFile(path) { | ||
return path.slice(-3) == '.js'; | ||
} | ||
|
||
function onlySpecFiles(path) { | ||
return /\.spec\.js$/.test(path); | ||
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.import('base/dist/system-config.js').then(function(systemJsConfig) { | ||
// We need to add the distPrefix to our system config packages. | ||
var config = systemJsConfig.config; | ||
Object.keys(config.packages).forEach(function(pkgName) { | ||
if (pkgName[0] != '/' && pkgName[0] != '.') { | ||
var pkg = config.packages[pkgName]; | ||
delete config.packages[pkgName]; | ||
config.packages[distPath + pkgName] = pkg; | ||
} | ||
}); | ||
|
||
System.config(config); | ||
}).then(function() { | ||
// Load and configure the TestComponentBuilder. | ||
return Promise.all([ | ||
System.import('angular2/testing'), | ||
System.import('angular2/platform/testing/browser') | ||
]).then(function (providers) { | ||
var testing = providers[0]; | ||
var testingBrowser = providers[1]; | ||
|
||
testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_PLATFORM_PROVIDERS, | ||
testingBrowser.TEST_BROWSER_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); |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
addon/ng2/blueprints/ng2/files/src/client/system-config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const barrels: string[] = [ | ||
'app', | ||
/** @cli-barrel */ | ||
]; | ||
|
||
function createPackageConfig(barrels: string[]): any { | ||
return barrels.reduce((barrelConfig: any, barrelName: string) => { | ||
barrelConfig[barrelName] = { | ||
format: 'register', | ||
defaultExtension: 'js', | ||
main: 'index' | ||
}; | ||
return barrelConfig; | ||
}, {}); | ||
} | ||
|
||
|
||
// Add your custom SystemJS configuration here. | ||
export const config: any = { | ||
packages: Object.assign({ | ||
// Add your custom SystemJS packages here. | ||
}, createPackageConfig(barrels)) | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/// <reference path="../../typings/browser.d.ts" /> | ||
|
||
declare var __moduleName: string; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
<%= classifiedModuleName %>Component
better than addingComponent
to themoduleName
instead? Just curious.We could even do logic to see if the user is saying
ng g component my-comp.component
we don't add a second component to it. WDYT?