From 74e3115686cce452a281f79b120e07e976ea2b09 Mon Sep 17 00:00:00 2001 From: Jesus Rodriguez Date: Thu, 14 Dec 2017 15:02:49 +0100 Subject: [PATCH] build(aio): make zipper work correctly with CLI projects --- .../examples/dependency-injection/plnkr.json | 2 +- .../examples/ngmodule/src/index.0.html | 11 --------- .../examples/ngmodule/src/index.1.html | 11 --------- .../examples/ngmodule/src/index.1b.html | 11 --------- .../examples/ngmodule/src/index.2.html | 11 --------- .../examples/ngmodule/src/index.3.html | 11 --------- .../examples/reactive-forms/final.plnkr.json | 12 ++++++---- .../reactive-forms/src/index-final.html | 12 ---------- .../customizer/package-json/cli.json | 1 + aio/tools/example-zipper/exampleZipper.js | 24 ++++++++++++++++--- 10 files changed, 31 insertions(+), 75 deletions(-) diff --git a/aio/content/examples/dependency-injection/plnkr.json b/aio/content/examples/dependency-injection/plnkr.json index f4cd0e9b38..b52578894a 100644 --- a/aio/content/examples/dependency-injection/plnkr.json +++ b/aio/content/examples/dependency-injection/plnkr.json @@ -5,7 +5,7 @@ "!**/*.d.ts", "!**/*.js", "!**/*.[0,1,2].*", - "**/dummy.module.ts" + "!**/dummy.module.ts" ], "tags": ["dependency", "di"] } diff --git a/aio/content/examples/ngmodule/src/index.0.html b/aio/content/examples/ngmodule/src/index.0.html index 0bea26963c..2da2e67b4b 100644 --- a/aio/content/examples/ngmodule/src/index.0.html +++ b/aio/content/examples/ngmodule/src/index.0.html @@ -5,17 +5,6 @@ NgModule Minimal - - - - - - - - - diff --git a/aio/content/examples/ngmodule/src/index.1.html b/aio/content/examples/ngmodule/src/index.1.html index 1b0c1f8fb1..2da2e67b4b 100644 --- a/aio/content/examples/ngmodule/src/index.1.html +++ b/aio/content/examples/ngmodule/src/index.1.html @@ -5,17 +5,6 @@ NgModule Minimal - - - - - - - - - diff --git a/aio/content/examples/ngmodule/src/index.1b.html b/aio/content/examples/ngmodule/src/index.1b.html index 8d47dd9a0e..2da2e67b4b 100644 --- a/aio/content/examples/ngmodule/src/index.1b.html +++ b/aio/content/examples/ngmodule/src/index.1b.html @@ -5,17 +5,6 @@ NgModule Minimal - - - - - - - - - diff --git a/aio/content/examples/ngmodule/src/index.2.html b/aio/content/examples/ngmodule/src/index.2.html index 9f552615e7..2da2e67b4b 100644 --- a/aio/content/examples/ngmodule/src/index.2.html +++ b/aio/content/examples/ngmodule/src/index.2.html @@ -5,17 +5,6 @@ NgModule Minimal - - - - - - - - - diff --git a/aio/content/examples/ngmodule/src/index.3.html b/aio/content/examples/ngmodule/src/index.3.html index 0fcae8a39f..2da2e67b4b 100644 --- a/aio/content/examples/ngmodule/src/index.3.html +++ b/aio/content/examples/ngmodule/src/index.3.html @@ -5,17 +5,6 @@ NgModule Minimal - - - - - - - - - diff --git a/aio/content/examples/reactive-forms/final.plnkr.json b/aio/content/examples/reactive-forms/final.plnkr.json index 41481acc99..28e756ded5 100644 --- a/aio/content/examples/reactive-forms/final.plnkr.json +++ b/aio/content/examples/reactive-forms/final.plnkr.json @@ -5,13 +5,17 @@ "styles.css", "app/app.component.ts", + "app/app.component.html", + "app/app.component.css", "app/app.module.ts", "app/data-model.ts", "app/hero.service.ts", - "app/hero-detail.component.html", - "app/hero-detail.component.ts", - "app/hero-list.component.html", - "app/hero-list.component.ts", + "app/hero-detail/hero-detail.component.html", + "app/hero-detail/hero-detail.component.ts", + "app/hero-detail/hero-detail.component.css", + "app/hero-list/hero-list.component.html", + "app/hero-list/hero-list.component.ts", + "app/hero-list/hero-list.component.css", "main-final.ts", "index-final.html" diff --git a/aio/content/examples/reactive-forms/src/index-final.html b/aio/content/examples/reactive-forms/src/index-final.html index 6abb00da3b..7121ad3455 100644 --- a/aio/content/examples/reactive-forms/src/index-final.html +++ b/aio/content/examples/reactive-forms/src/index-final.html @@ -6,18 +6,6 @@ - - - - - - - - - - diff --git a/aio/tools/example-zipper/customizer/package-json/cli.json b/aio/tools/example-zipper/customizer/package-json/cli.json index 8e689c7d49..ca5fc2be05 100644 --- a/aio/tools/example-zipper/customizer/package-json/cli.json +++ b/aio/tools/example-zipper/customizer/package-json/cli.json @@ -1,6 +1,7 @@ { "scripts": [ { "name": "ng", "command": "ng" }, + { "name": "build", "command": "ng build" }, { "name": "start", "command": "ng serve" }, { "name": "test", "command": "ng test" }, { "name": "lint", "command": "ng lint" }, diff --git a/aio/tools/example-zipper/exampleZipper.js b/aio/tools/example-zipper/exampleZipper.js index f6072e4113..26af7dfd08 100644 --- a/aio/tools/example-zipper/exampleZipper.js +++ b/aio/tools/example-zipper/exampleZipper.js @@ -54,6 +54,19 @@ class ExampleZipper { } } + // rename a custom main.ts or index.html file + _renameFile(file) { + if (/src\/main[-.]\w+\.ts$/.test(file)) { + return 'src/main.ts'; + } + + if (/src\/index[-.]\w+\.html$/.test(file)) { + return 'src/index.html'; + } + + return file; + } + _zipExample(configFileName, sourceDirName, outputDirName) { let json = require(configFileName, 'utf-8'); const basePath = json.basePath || ''; @@ -79,12 +92,16 @@ class ExampleZipper { 'tslint.json', 'karma-test-shim.js', 'karma.conf.js', + 'tsconfig.json', 'src/testing/**/*', 'src/.babelrc', 'src/favicon.ico', - 'src/typings.d.ts' + 'src/polyfills.ts', + 'src/typings.d.ts', + 'src/environments/**/*', + 'src/tsconfig.*' ]; - var defaultExcludes = [ + var alwaysExcludes = [ '!**/bs-config.e2e.json', '!**/*plnkr.*', '!**/*zipper.*', @@ -132,13 +149,14 @@ class ExampleZipper { } }); - Array.prototype.push.apply(gpaths, defaultExcludes); + Array.prototype.push.apply(gpaths, alwaysExcludes); let fileNames = globby.sync(gpaths, { ignore: ['**/node_modules/**']}); let zip = this._createZipArchive(outputFileName); fileNames.forEach((fileName) => { let relativePath = path.relative(exampleDirName, fileName); + relativePath = this._renameFile(relativePath); let content = fs.readFileSync(fileName, 'utf8'); let extn = path.extname(fileName).substr(1); // if we don't need to clean up the file then we can do the following.