build(aio): check for obsolete `plnkr.json` and missing `main` files (#20165)
Also, remove `plnkr.json` for `service-worker-getting-started` guide, since it is not used and ServiceWorker cannot work correctly in plnkr/stackblitz anyway (e.g. no build step to re-compute hashes). A zipper might be useful and can be added in a subsequent PR, but it is currently broken (e.g. no dependency on `@angular/service-worker`). PR Close #20165
This commit is contained in:
parent
8522546a8a
commit
15c2a93f14
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"description": "Bootstrapping",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"!**/*.d.ts",
|
||||
"!**/*.js",
|
||||
"!**/*.[1,2].*"
|
||||
],
|
||||
"open": "app/app.component.ts",
|
||||
"file": "src/app/app.component.ts",
|
||||
"tags": ["ngmodules"]
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"description": "Feature Modules",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"!**/*.d.ts",
|
||||
"!**/*.js",
|
||||
"!**/*.[1,2].*"
|
||||
],
|
||||
"open": "app/app.component.ts",
|
||||
"file": "src/app/app.component.ts",
|
||||
"tags": ["feature modules"]
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"description": "Lazy Loading Feature Modules",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"!**/*.d.ts",
|
||||
"!**/*.js",
|
||||
"!**/*.[1,2].*"
|
||||
],
|
||||
"open": "app/app.component.ts",
|
||||
"file": "src/app/app.component.ts",
|
||||
"tags": ["lazy loading"]
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"description": "Contact NgModule v.1",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/app.component.1b.ts",
|
||||
"app/app.module.1b.ts",
|
||||
"app/highlight.directive.ts",
|
||||
"app/title.component.html",
|
||||
"app/title.component.ts",
|
||||
"app/user.service.ts",
|
||||
|
||||
"app/contact/awesome.pipe.ts",
|
||||
"app/contact/contact.component.css",
|
||||
"app/contact/contact.component.html",
|
||||
"app/contact/contact.component.3.ts",
|
||||
"app/contact/contact.service.ts",
|
||||
"app/contact/contact-highlight.directive.ts",
|
||||
|
||||
"main.1b.ts",
|
||||
"styles.css",
|
||||
"index.1b.html"
|
||||
],
|
||||
"main": "index.1b.html",
|
||||
"tags": ["NgModule"]
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"description": "Contact NgModule v.2",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/app.component.2.ts",
|
||||
"app/app.module.2.ts",
|
||||
"app/highlight.directive.ts",
|
||||
"app/title.component.html",
|
||||
"app/title.component.ts",
|
||||
"app/user.service.ts",
|
||||
|
||||
"app/contact/contact.component.css",
|
||||
"app/contact/contact.component.html",
|
||||
"app/contact/contact.service.ts",
|
||||
|
||||
"app/contact/awesome.pipe.ts",
|
||||
"app/contact/contact.component.3.ts",
|
||||
"app/contact/contact.module.2.ts",
|
||||
"app/contact/contact-highlight.directive.ts",
|
||||
|
||||
"main.2.ts",
|
||||
"styles.css",
|
||||
"index.2.html"
|
||||
],
|
||||
"main": "index.2.html",
|
||||
"tags": ["NgModule"]
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"description": "Minimal NgModule",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/app.component.0.ts",
|
||||
"app/app.module.0.ts",
|
||||
"main.0.ts",
|
||||
"styles.css",
|
||||
"index.0.html"
|
||||
],
|
||||
"main": "index.0.html",
|
||||
"tags": ["NgModule"]
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"description": "NgModule Final",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/app.component.ts",
|
||||
"app/app.module.ts",
|
||||
"app/app-routing.module.ts",
|
||||
|
||||
"app/contact/contact.component.css",
|
||||
"app/contact/contact.component.html",
|
||||
"app/contact/contact.service.ts",
|
||||
|
||||
"app/contact/contact.component.ts",
|
||||
"app/contact/contact.module.ts",
|
||||
"app/contact/contact-routing.module.ts",
|
||||
|
||||
"app/crisis/*.ts",
|
||||
|
||||
"app/hero/hero-detail.component.ts",
|
||||
"app/hero/hero-list.component.ts",
|
||||
"app/hero/hero.service.ts",
|
||||
|
||||
"app/hero/hero.component.ts",
|
||||
"app/hero/hero.module.ts",
|
||||
"app/hero/hero-routing.module.ts",
|
||||
|
||||
"app/core/*.css",
|
||||
"app/core/*.html",
|
||||
"app/core/*.ts",
|
||||
|
||||
"app/shared/*.css",
|
||||
"app/shared/*.html",
|
||||
"app/shared/*.ts",
|
||||
|
||||
"main.ts",
|
||||
"styles.css",
|
||||
"index.html"
|
||||
],
|
||||
"main": "index.html",
|
||||
"tags": ["NgModule"]
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"description": "NgModule v.3",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/app.component.3.ts",
|
||||
"app/app.module.3.ts",
|
||||
"app/app-routing.module.3.ts",
|
||||
|
||||
"app/highlight.directive.ts",
|
||||
"app/title.component.html",
|
||||
"app/title.component.ts",
|
||||
"app/user.service.ts",
|
||||
|
||||
"app/contact/contact.component.css",
|
||||
"app/contact/contact.component.html",
|
||||
"app/contact/contact.service.ts",
|
||||
|
||||
"app/contact/awesome.pipe.ts",
|
||||
"app/contact/contact.component.3.ts",
|
||||
"app/contact/contact.module.3.ts",
|
||||
"app/contact/contact-routing.module.3.ts",
|
||||
"app/contact/contact-highlight.directive.ts",
|
||||
|
||||
"app/crisis/*.ts",
|
||||
|
||||
"app/hero/hero-detail.component.ts",
|
||||
"app/hero/hero-list.component.ts",
|
||||
"app/hero/hero.service.ts",
|
||||
|
||||
"app/hero/hero.component.3.ts",
|
||||
"app/hero/hero.module.3.ts",
|
||||
"app/hero/hero-routing.module.3.ts",
|
||||
"app/hero/highlight.directive.ts",
|
||||
|
||||
"main.3.ts",
|
||||
"styles.css",
|
||||
"index.3.html"
|
||||
],
|
||||
"main": "index.3.html",
|
||||
"tags": ["NgModule"]
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"description": "NgModules",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"!**/*.d.ts",
|
||||
"!**/*.js",
|
||||
"!**/*.[1,2].*"
|
||||
],
|
||||
"open": "app/app.component.ts",
|
||||
"file": "src/app/app.component.ts",
|
||||
"tags": ["NgModules"]
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"description": "Providers",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"!**/*.d.ts",
|
||||
"!**/*.js",
|
||||
"!**/*.[1,2].*"
|
||||
],
|
||||
"open": "app/app.component.ts",
|
||||
"file": "src/app/app.component.ts",
|
||||
"tags": ["providers"]
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"description": "QuickStart",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/app.component.ts",
|
||||
"app/app.module.ts",
|
||||
"main.ts",
|
||||
"index.html"
|
||||
],
|
||||
"open": "app/app.component.ts",
|
||||
"tags": ["quickstart"]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"description": "QuickStart",
|
||||
"files": [
|
||||
"src/app/app.component.ts",
|
||||
"src/app/app.module.ts",
|
||||
"src/main.ts",
|
||||
"src/index.html"
|
||||
],
|
||||
"file": "src/app/app.component.ts",
|
||||
"tags": ["quickstart"]
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"description": "Angular Reactive Forms (final)",
|
||||
"basePath": "src/",
|
||||
"files":[
|
||||
"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/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"
|
||||
],
|
||||
"main": "index-final.html",
|
||||
"tags": ["reactive", "forms"]
|
||||
}
|
|
@ -4,13 +4,17 @@
|
|||
"src/styles.css",
|
||||
|
||||
"src/app/app.component.ts",
|
||||
"src/app/app.component.html",
|
||||
"src/app/app.component.css",
|
||||
"src/app/app.module.ts",
|
||||
"src/app/data-model.ts",
|
||||
"src/app/hero.service.ts",
|
||||
"src/app/hero-detail.component.html",
|
||||
"src/app/hero-detail.component.ts",
|
||||
"src/app/hero-list.component.html",
|
||||
"src/app/hero-list.component.ts",
|
||||
"src/app/hero-detail/hero-detail.component.html",
|
||||
"src/app/hero-detail/hero-detail.component.ts",
|
||||
"src/app/hero-detail/hero-detail.component.css",
|
||||
"src/app/hero-list/hero-list.component.html",
|
||||
"src/app/hero-list/hero-list.component.ts",
|
||||
"src/app/hero-list/hero-list.component.css",
|
||||
|
||||
"src/main-final.ts",
|
||||
"src/index-final.html"
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"description": "Service Worker",
|
||||
"basePath": "src/",
|
||||
"tags": ["service worker"]
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"description": "QuickStart Setup",
|
||||
"basePath": "src/",
|
||||
"files": [
|
||||
"app/app.component.ts",
|
||||
"app/app.module.ts",
|
||||
"index.html",
|
||||
"main.ts",
|
||||
"styles.css"
|
||||
],
|
||||
"open": "app/app.component.ts",
|
||||
"tags": ["quickstart", "setup", "seed"]
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"description": "Quickstart AppComponent Testing",
|
||||
"basePath": "src/",
|
||||
"files":[
|
||||
"browser-test-shim.js",
|
||||
"app/app.component.ts",
|
||||
"app/app.component.spec.ts",
|
||||
"quickstart-specs.html"
|
||||
],
|
||||
"main": "quickstart-specs.html",
|
||||
"open": "app/app.component.spec.ts",
|
||||
"tags": ["quickstart", "setup", "testing"]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"description": "Quickstart AppComponent Testing",
|
||||
"files":[
|
||||
"src/browser-test-shim.js",
|
||||
"src/app/app.component.ts",
|
||||
"src/app/app.component.spec.ts",
|
||||
"src/quickstart-specs.html"
|
||||
],
|
||||
"main": "src/quickstart-specs.html",
|
||||
"file": "src/app/app.component.spec.ts",
|
||||
"tags": ["quickstart", "setup", "testing"]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"description": "QuickStart Setup",
|
||||
"files": [
|
||||
"src/app/app.component.ts",
|
||||
"src/app/app.module.ts",
|
||||
"src/index.html",
|
||||
"src/main.ts",
|
||||
"src/styles.css"
|
||||
],
|
||||
"file": "src/app/app.component.ts",
|
||||
"tags": ["quickstart", "setup", "seed"]
|
||||
}
|
|
@ -29,6 +29,8 @@ class StackblitzBuilder {
|
|||
}
|
||||
|
||||
build() {
|
||||
this._checkForOutdatedConfig();
|
||||
|
||||
// When testing it sometimes helps to look a just one example directory like so:
|
||||
// var stackblitzPaths = path.join(this.basePath, '**/testing/*stackblitz.json');
|
||||
var stackblitzPaths = path.join(this.basePath, '**/*stackblitz.json');
|
||||
|
@ -62,7 +64,7 @@ class StackblitzBuilder {
|
|||
// description: string - description of this stackblitz - defaults to the title in the index.html page.
|
||||
// tags: string[] - optional array of stackblitz tags (for searchability)
|
||||
// main: string - name of file that will become index.html in the stackblitz - defaults to index.html
|
||||
// file: string - name of file to display within the stackblitz as in "open": "app/app.module.ts"
|
||||
// file: string - name of file to display within the stackblitz (e.g. `"file": "app/app.module.ts"`)
|
||||
_buildStackblitzFrom(configFileName) {
|
||||
// replace ending 'stackblitz.json' with 'stackblitz.no-link.html' to create output file name;
|
||||
var outputFileName = `stackblitz.no-link.html`;
|
||||
|
@ -74,7 +76,7 @@ class StackblitzBuilder {
|
|||
}
|
||||
try {
|
||||
var config = this._initConfigAndCollectFileNames(configFileName);
|
||||
var postData = this._createPostData(config);
|
||||
var postData = this._createPostData(config, configFileName);
|
||||
this._addDependencies(postData);
|
||||
var html = this._createStackblitzHtml(config, postData);
|
||||
fs.writeFileSync(outputFileName, html, 'utf-8');
|
||||
|
@ -95,6 +97,24 @@ class StackblitzBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
_checkForOutdatedConfig() {
|
||||
// Ensure that nobody is trying to use the old config filenames (i.e. `plnkr.json`).
|
||||
var plunkerPaths = path.join(this.basePath, '**/*plnkr.json');
|
||||
var fileNames = globby.sync(plunkerPaths, { ignore: ['**/node_modules/**'] });
|
||||
|
||||
if (fileNames.length) {
|
||||
const readmePath = path.join(__dirname, 'README.md');
|
||||
const errorMessage =
|
||||
'One or more examples are still trying to use \'plnkr.json\' files for configuring ' +
|
||||
'live examples. This is not supported any more. \'stackblitz.json\' should be used ' +
|
||||
'instead.\n' +
|
||||
`(Slight modifications may be required. See '${readmePath}' for more info.\n\n` +
|
||||
fileNames.map(name => `- ${name}`).join('\n');
|
||||
|
||||
throw Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
_createBaseStackblitzHtml(config) {
|
||||
var file = '';
|
||||
|
||||
|
@ -122,8 +142,14 @@ class StackblitzBuilder {
|
|||
return html;
|
||||
}
|
||||
|
||||
_createPostData(config) {
|
||||
_createPostData(config, configFileName) {
|
||||
var postData = {};
|
||||
|
||||
// If `config.main` is specified, ensure that it points to an existing file.
|
||||
if (config.main && !this._existsSync(path.join(config.basePath, config.main))) {
|
||||
throw Error(`The main file ('${config.main}') specified in '${configFileName}' does not exist.`);
|
||||
}
|
||||
|
||||
config.fileNames.forEach((fileName) => {
|
||||
var content;
|
||||
var extn = path.extname(fileName);
|
||||
|
|
Loading…
Reference in New Issue