chore(devguide-tooling): add enforce-example-boilerplate gulp task

closes #485 and 479
removal all package.json from _example subdirs and add an example-config.json to each. Update add-example-symlinks to use new fns
updated gitignore, package.json
add tests to QuickStart
This commit is contained in:
Jay Traband 2015-12-11 11:59:57 -08:00 committed by Ward Bell
parent 393987bdf5
commit 296b501483
43 changed files with 124 additions and 409 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ public/docs/xref-*.*
_zip-output
www
/npm-debug.log
npm-debug.log.*
*.plnkr.html
plnkr.html
*plnkr.no-link.html

View File

@ -54,8 +54,7 @@ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
return new Minimatch(excludePattern)
});
var _exampleBoilerplateFiles = ['package.json', 'tsconfig.json', 'karma.conf.js', 'karma-test-shim.js' ]
// Public tasks
@ -69,7 +68,8 @@ gulp.task('help', taskListing.withFilters(function(taskName) {
return shouldRemove;
}));
gulp.task('add-example-symlinks', function() {
// requires admin access
gulp.task('add-example-boilerplate', function() {
var realPath = path.join(EXAMPLES_PATH, '/node_modules');
var nodeModulesPaths = getNodeModulesPaths(EXAMPLES_PATH);
@ -77,13 +77,20 @@ gulp.task('add-example-symlinks', function() {
gutil.log("symlinking " + linkPath + ' -> ' + realPath)
fsUtils.addSymlink(realPath, linkPath);
});
var sourceFiles = _exampleBoilerplateFiles.map(function(fn) {
return path.join(EXAMPLES_PATH, fn);
});
var examplePaths = getExamplePaths(EXAMPLES_PATH);
return copyFiles(sourceFiles, examplePaths );
});
gulp.task('remove-example-symlinks', function() {
gulp.task('remove-example-boilerplate', function() {
var nodeModulesPaths = getNodeModulesPaths(EXAMPLES_PATH);
nodeModulesPaths.forEach(function(linkPath) {
fsUtils.removeSymlink(linkPath);
});
var examplePaths = getExamplePaths(EXAMPLES_PATH);
return deleteFiles(_exampleBoilerplateFiles, examplePaths );
});
gulp.task('serve-and-sync', ['build-docs'], function (cb) {
@ -230,15 +237,51 @@ gulp.task('_zip-examples', function() {
// Helper functions
function getNodeModulesPaths(basePath) {
var jsonPattern = path.join(basePath, "**/package.json");
var exceptJsonPattern = "!" + path.join(basePath, "/package.json");
// returns a promise
function copyFiles(fileNames, destPaths) {
var copy = Q.denodeify(fsExtra.copy);
var copyPromises = [];
destPaths.forEach(function(destPath) {
fileNames.forEach(function(fileName) {
var baseName = path.basename(fileName);
var destName = path.join(destPath, baseName);
var p = copy(fileName, destName, { clobber: true});
copyPromises.push(p);
});
});
return Q.all(copyPromises);
}
function deleteFiles(baseFileNames, destPaths) {
var remove = Q.denodeify(fsExtra.remove);
var delPromises = [];
destPaths.forEach(function(destPath) {
baseFileNames.forEach(function(baseFileName) {
var destFileName = path.join(destPath, baseFileName);
var p = remove(destFileName);
delPromises.push(p);
});
});
return Q.all(delPromises);
}
function getExamplePaths(basePath) {
var jsonPattern = path.join(basePath, "**/example-config.json");
// ignore (skip) the top level version.
var exceptJsonPattern = "!" + path.join(basePath, "/example-config.json");
var nmPattern = path.join(basePath, "**/node_modules/**");
var fileNames = globby.sync( [ jsonPattern, exceptJsonPattern ], { ignore: [nmPattern] } );
// same as above but perf can differ.
// var fileNames = globby.sync( [jsonPattern, "!" + nmPattern]);
var paths = fileNames.map(function(fileName) {
return path.join(path.dirname(fileName), "/node_modules");
return path.dirname(fileName);
});
return paths;
}
function getNodeModulesPaths(basePath) {
var paths = getExamplePaths(basePath).map(function(examplePath) {
return path.join(examplePath, "/node_modules");
});
return paths;
}

View File

@ -1,2 +1,6 @@
typings
*.js.map
*.js.map
package.json
karma.conf.js
karma-test-shim.js
tsconfig.json

View File

@ -1,40 +0,0 @@
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\wardb\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'tsc:w' ]
2 info using npm@2.14.7
3 info using node@v4.2.1
4 verbose run-script [ 'pretsc:w', 'tsc:w', 'posttsc:w' ]
5 info pretsc:w angular2-template-syntax@1.0.0
6 info tsc:w angular2-template-syntax@1.0.0
7 verbose unsafe-perm in lifecycle true
8 info angular2-template-syntax@1.0.0 Failed to exec tsc:w script
9 verbose stack Error: angular2-template-syntax@1.0.0 tsc:w: `tsc -w`
9 verbose stack Exit status 3221225786
9 verbose stack at EventEmitter.<anonymous> (C:\Users\wardb\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:214:16)
9 verbose stack at emitTwo (events.js:87:13)
9 verbose stack at EventEmitter.emit (events.js:172:7)
9 verbose stack at ChildProcess.<anonymous> (C:\Users\wardb\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:24:14)
9 verbose stack at emitTwo (events.js:87:13)
9 verbose stack at ChildProcess.emit (events.js:172:7)
9 verbose stack at maybeClose (internal/child_process.js:818:16)
9 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid angular2-template-syntax@1.0.0
11 verbose cwd c:\github\angular.io.ideablade\public\docs\_examples\architecture\ts
12 error Windows_NT 10.0.10586
13 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\wardb\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "tsc:w"
14 error node v4.2.1
15 error npm v2.14.7
16 error code ELIFECYCLE
17 error angular2-template-syntax@1.0.0 tsc:w: `tsc -w`
17 error Exit status 3221225786
18 error Failed at the angular2-template-syntax@1.0.0 tsc:w script 'tsc -w'.
18 error This is most likely a problem with the angular2-template-syntax package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error tsc -w
18 error You can get their info via:
18 error npm owner ls angular2-template-syntax
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

View File

@ -1,15 +0,0 @@
{
"name": "angular2-template-syntax",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"both": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@ -1,16 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules"
]
}

View File

@ -1,15 +0,0 @@
{
"name": "angular2-attribute-directive",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"both": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@ -1,16 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules"
]
}

View File

@ -1,15 +0,0 @@
{
"name": "angular2-displaying-data",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"both": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@ -1,16 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules"
]
}

View File

@ -1,15 +0,0 @@
{
"name": "angular2-getting-started",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"both": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@ -1,16 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules"
]
}

View File

@ -1,15 +0,0 @@
{
"name": "angular2-hierarchical-injection",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"both": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@ -1,16 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules"
]
}

View File

@ -0,0 +1 @@
// PLACEHOLDER UNTIL JAY PROVIDES THE REAL ONE

View File

@ -1,73 +1,43 @@
// Karma configuration
// Generated on Mon Aug 10 2015 11:36:40 GMT-0700 (Pacific Daylight Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
{ pattern: 'https://code.angularjs.org/2.0.0-alpha.34/angular2.sfx.dev.js', watched: false },
{ pattern: 'https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js', watched: false },
{ pattern: 'https://jspm.io/system@0.16.js', watched: false },
'**/spec.js',
'**/*.spec.js',
'**/js/*.js',
{ pattern: '**/ts/*.js', included: false },
// paths loaded by Karma
{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true},
{pattern: 'node_modules/angular2/bundles/testing.js', included: true, watched: true},
{pattern: 'karma-test-shim.js', included: true, watched: true},
{pattern: 'src/test/matchers.js', included: true, watched: true},
// paths loaded via module imports
{pattern: 'src/**/*.js', included: false, watched: true},
// paths loaded via Angular's component compiler
// (these paths need to be rewritten, see proxies section)
{pattern: 'src/**/*.html', included: false, watched: true},
{pattern: 'src/**/*.css', included: false, watched: true},
// paths to support debugging with source maps in dev tools
{pattern: 'src/**/*.ts', included: false, watched: false},
{pattern: 'src/**/*.js.map', included: false, watched: false}
],
// list of files to exclude
exclude: [
'**/e2e-spec.js',
'**/*.e2e-spec.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
// proxied base paths
proxies: {
// required for component assests fetched by Angular's compiler
"/app/": "/base/src/app/"
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
port: 9877,
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
singleRun: true
})
}

View File

@ -9,7 +9,9 @@
"lite": "lite-server",
"live": "live-server",
"start": "npm run lite",
"both": "concurrent \"npm run tsc:w\" \"npm run start\" "
"both": "concurrent \"npm run tsc:w\" \"npm run start\" ",
"test": "karma start karma.conf.js",
"build-and-test": "npm run tsc && npm run test"
},
"keywords": [],
"author": "",
@ -28,6 +30,13 @@
"concurrently": "^1.0.0",
"lite-server": "^1.3.1",
"live-server": "^0.8.2",
"typescript": "^1.7.3"
"typescript": "^1.7.3",
"jasmine-core":"~2.1.0",
"karma": "^0.12.23",
"karma-chrome-launcher": "^0.1.4",
"karma-cli": "^0.0.4",
"karma-jasmine": "^0.3.6",
"rimraf": "^2.4.3"
}
}

View File

@ -1,21 +0,0 @@
{
"name": "angular2-pipes",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc -p src -w",
"start": "live-server --open=src"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-alpha.44",
"systemjs": "0.19.2"
},
"devDependencies": {
"live-server": "^0.8.1",
"typescript": "^1.6.2"
}
}

View File

@ -1,11 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}

View File

@ -1,18 +0,0 @@
{
"name": "angular2-getting-started",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "live-server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-alpha.44"
},
"devDependencies": {
"live-server": "^0.8.1"
}
}

View File

@ -0,0 +1,19 @@
import { iit,it, ddescribe, describe, expect, injectAsync, TestComponentBuilder, beforeEachProviders } from 'angular2/testing';
import { provide, Type } from 'angular2/core';
import { AppComponent } from './app';
type TCB = TestComponentBuilder;
describe('AppComponent', () => {
beforeEachProviders(() => <Type[]> []);
it('should have correct text', injectAsync([TestComponentBuilder], (tcb: TCB) => {
return tcb.createAsync(AppComponent).then((fixture) => {
// fixture.detectChanges();
var compiled = fixture.debugElement.nativeElement;
expect(compiled).toContainText('My First Angular 2 App');
expect(compiled.querySelector('h1')).toHaveText('My First Angular 2 App');
});
}));
});

View File

@ -0,0 +1,11 @@
describe('universal truths', () => {
it('should do math', () => {
expect(1 + 1).toEqual(2);
expect(5).toBeGreaterThan(4);
});
xit('should skip this', () => {
expect(4).toEqual(40);
});
});

View File

@ -1,11 +0,0 @@
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"both": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"license": "ISC"
}

View File

@ -1,15 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}

View File

@ -1,14 +0,0 @@
{
"name": "getting-started",
"version": "0.0.1",
"dependencies": {
"angular2": "2.0.0-alpha.37",
"systemjs": "^0.18.17",
"traceur": "0.0.91"
},
"scripts": {
"postinstall": "cd src && tsd reinstall -r -o && cd ..",
"tsc": "tsc -p src -w",
"start": "live-server --open=src"
}
}

View File

@ -1,14 +0,0 @@
{
"name": "angular2-template-syntax",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc -p src -w",
"start": "live-server --open=src",
"both": "concurrent \"npm run tsc\" \"npm run start\" "
},
"keywords": [],
"author": "",
"license": "ISC"
}

View File

@ -1,12 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}

View File

@ -1,21 +0,0 @@
{
"name": "angular2-template-syntax",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"tsc": "tsc -p src -w",
"start": "live-server --open=src"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-alpha.44",
"systemjs": "0.19.2"
},
"devDependencies": {
"live-server": "^0.8.1",
"typescript": "^1.6.2"
}
}

View File

@ -9,7 +9,7 @@
System.config({
packages: {'app': {defaultExtension: 'js'}}
});
System.import('app/app');
System.import('app/boot');
</script>
</head>

View File

@ -1,11 +0,0 @@
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}