build(docs-infra): always specify a landing file for StackBlitz projects (#34553)

The StackBlitz API (which we use to generate StackBlitz projects on the
fly, when a user clicks on a live example link in the docs) allows
specifying the file to open in the editor by passing a query param. If
no file is specified, StackBlitz opens a default one. In the past, it
used to be `main.ts` and nowadays it seems to be `app.component.ts`.

StackBlitz builder, the tool that we use to generate the StackBlitz
projects, allows specifying the primary file by setting the `file`
property in the corresponding `stackblitz.json`.

Previously, if the `file` property was not set, StackBlitz builder would
not specify a file, thus falling back on StackBlitz's default behavior.
This was not great, because the default behavior may change unexpectedly
is the future to something that is less useful for our users.

This commit change StackBlitz builder to always specify a primary file.
If no file is specified in `stackblitz.json`, the builder will look
for the first file that exists in the example from a list of predefined
files.

Partially addresses #22357.

PR Close #34553
This commit is contained in:
Sonu Kapoor 2019-12-23 22:29:59 -05:00 committed by Andrew Kushnir
parent 77c53559d0
commit f49b45832c
34 changed files with 39 additions and 10 deletions

View File

@ -5,6 +5,5 @@
"!**/*.js", "!**/*.js",
"!**/*.[1,2].*" "!**/*.[1,2].*"
], ],
"file": "src/app/app.component.ts",
"tags": ["Accessibility"] "tags": ["Accessibility"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1,2,3].*" "!**/*.[1,2,3].*"
], ],
"file": "src/app/app.component.ts",
"tags": ["animations"] "tags": ["animations"]
} }

View File

@ -5,5 +5,5 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/app.module.ts" "file": "src/app/hero-list.component.html"
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1,2,3].*" "!**/*.[1,2,3].*"
], ],
"file": "src/app/highlight.directive.ts",
"tags": ["attribute", "directive"] "tags": ["attribute", "directive"]
} }

View File

@ -6,5 +6,6 @@
"!**/*.native.*", "!**/*.native.*",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/hero-app.component.ts",
"tags": ["CSS"] "tags": ["CSS"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/app.component.ts",
"tags":["cookbook"] "tags":["cookbook"]
} }

View File

@ -6,5 +6,6 @@
"!**/*.[0,1,2,3,4].*", "!**/*.[0,1,2,3,4].*",
"!**/dummy.module.ts" "!**/dummy.module.ts"
], ],
"file": "src/app/app.component.ts",
"tags": ["dependency", "di"] "tags": ["dependency", "di"]
} }

View File

@ -6,5 +6,6 @@
"!**/app-ctor.component.ts", "!**/app-ctor.component.ts",
"!**/*.[1,2,3].*" "!**/*.[1,2,3].*"
], ],
"file": "src/app/app.component.ts",
"tags": ["Template"] "tags": ["Template"]
} }

View File

@ -1,8 +1,11 @@
{ {
"description": "Second authors style guide stackblitz (non-executing)", "description": "Second authors style guide stackblitz (non-executing)",
"files": [ "files": [
"src/index.2.html" "src/main.2.ts",
"src/index.2.html",
"src/styles.css"
], ],
"main": "src/index.2.html", "main": "src/index.2.html",
"file": "src/index.html",
"tags": ["author", "style guide"] "tags": ["author", "style guide"]
} }

View File

@ -4,5 +4,6 @@
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js" "!**/*.js"
], ],
"file": "src/app/app.component.ts",
"tags":["cookbook component"] "tags":["cookbook component"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/app.component.ts",
"tags":["cookbook"] "tags":["cookbook"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/popup.service.ts",
"tags":["cookbook"] "tags":["cookbook"]
} }

View File

@ -4,5 +4,6 @@
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
] ],
"file": "src/app/app.component.ts"
} }

View File

@ -3,5 +3,6 @@
"files":[ "files":[
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js" "!**/*.js"
] ],
"file": "src/app/app.component.ts"
} }

View File

@ -3,5 +3,6 @@
"files":[ "files":[
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js" "!**/*.js"
] ],
"file": "src/app/hero-form/hero-form.component.html"
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[0-9].*" "!**/*.[0-9].*"
], ],
"file": "src/app/app.component.ts",
"tags": ["Angular", "getting started", "tutorial"] "tags": ["Angular", "getting started", "tutorial"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[0-9].*" "!**/*.[0-9].*"
], ],
"file": "src/app/product-list/product-list.component.html",
"tags": ["Angular", "getting started", "tutorial"] "tags": ["Angular", "getting started", "tutorial"]
} }

View File

@ -4,5 +4,6 @@
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js" "!**/*.js"
], ],
"file": "src/app/app.component.ts",
"tags": ["dependency", "injection"] "tags": ["dependency", "injection"]
} }

View File

@ -3,10 +3,10 @@
"files":[ "files":[
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js", "!**/*.js",
"!src/testing/*.*", "!src/testing/*.*",
"!src/index-specs.html", "!src/index-specs.html",
"!src/main-specs.ts" "!src/main-specs.ts"
], ],
"file": "src/app/app.component.ts",
"tags": ["http"] "tags": ["http"]
} }

View File

@ -5,6 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1,2].*" "!**/*.[1,2].*"
], ],
"file": "src/app/app.component.ts", "file": "src/app/app-routing.module.ts",
"tags": ["lazy loading"] "tags": ["lazy loading"]
} }

View File

@ -5,6 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1,2].*" "!**/*.[1,2].*"
], ],
"file": "src/app/app.component.ts", "file": "src/app/app.module.ts",
"tags": ["NgModules"] "tags": ["NgModules"]
} }

View File

@ -11,5 +11,6 @@
"!src/app/main-final.ts", "!src/app/main-final.ts",
"!src/index-final.html" "!src/index-final.html"
], ],
"file": "src/app/app.component.ts",
"tags": ["reactive", "forms"] "tags": ["reactive", "forms"]
} }

View File

@ -7,5 +7,6 @@
"!src/app/crisis-list/*.*", "!src/app/crisis-list/*.*",
"!src/app/hero-list/*.*" "!src/app/hero-list/*.*"
], ],
"tags": ["router"] "tags": ["router"],
"file": "src/app/app-routing.module.ts"
} }

View File

@ -4,5 +4,6 @@
"!**/*.d.ts", "!**/*.d.ts",
"!**/*.js" "!**/*.js"
], ],
"file": "src/app/app.component.ts",
"tags": ["security"] "tags": ["security"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/app.component.ts",
"tags": [ "cookbook" ] "tags": [ "cookbook" ]
} }

View File

@ -5,6 +5,7 @@
"!**/*.js", "!**/*.js",
"!src/app/scrap.txt" "!src/app/scrap.txt"
], ],
"file": "src/app/app.component.ts",
"tags": [ "tags": [
"structural", "directives", "template", "ngIf", "structural", "directives", "template", "ngIf",
"ngSwitch", "ngFor" "ngSwitch", "ngFor"

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/app.component.ts",
"tags": ["tutorial", "tour", "heroes"] "tags": ["tutorial", "tour", "heroes"]
} }

View File

@ -6,5 +6,6 @@
"!**/*.[1].*", "!**/*.[1].*",
"!**/dummy.module.ts" "!**/dummy.module.ts"
], ],
"file": "src/app/heroes/heroes.component.html",
"tags": ["tutorial", "tour", "heroes"] "tags": ["tutorial", "tour", "heroes"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/heroes/heroes.component.html",
"tags": ["tutorial", "tour", "heroes"] "tags": ["tutorial", "tour", "heroes"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1].*" "!**/*.[1].*"
], ],
"file": "src/app/heroes/heroes.component.html",
"tags": ["tutorial", "tour", "heroes"] "tags": ["tutorial", "tour", "heroes"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1,2].*" "!**/*.[1,2].*"
], ],
"file": "src/app/hero.service.ts",
"tags": ["tutorial", "tour", "heroes"] "tags": ["tutorial", "tour", "heroes"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[0,1,2,3].*" "!**/*.[0,1,2,3].*"
], ],
"file": "src/app/app-routing.module.ts",
"tags": ["tutorial", "tour", "heroes", "router"] "tags": ["tutorial", "tour", "heroes", "router"]
} }

View File

@ -5,5 +5,6 @@
"!**/*.js", "!**/*.js",
"!**/*.[1,2].*" "!**/*.[1,2].*"
], ],
"file": "src/app/hero.service.ts",
"tags": ["tutorial", "tour", "heroes", "http"] "tags": ["tutorial", "tour", "heroes", "http"]
} }