-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
build(aio): migrate examples to CLI #19248
Conversation
😝 |
aio/tools/examples/shared/yarn.lock
Outdated
@@ -1,5 +1,7 @@ | |||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |||
# yarn lockfile v1 | |||
# yarn v0.25.3 | |||
# node v7.8.0 |
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.
probably didn't mean to include this change in this commit?
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.
I am not touching this file but I guess that every time I use yarn add
or yarn upgrade
it will modify the comments.
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.
Indeed. To ensure consistency, you must use the same version of yarn that we use on CI (v0.24.6 for now).
{ | ||
"build": "build", | ||
"run": "serve" | ||
} |
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.
I am guessing that this file was never copied as it didn't appear in the original list above.
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.
Someone added that file there but it doesn't do anything, won't be copied with the tool. Like a "hey, this is how it could looks like, but it is only an example"
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.
build(aio): reestructure boilerplate to allow more types
reestructure
has one too manye
s.allow more types
of what?- It would seem more expandable for the example config to be
projectType
or something, which would be, at this stage, either"systemjs"
or"cli"
, rather than thesystemjs
boolean flag.
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.
build(aio): remove cli-quickstart boilerplate
LGTM - although adding the explanation to the commit message would be helpful.
My reasoning behind the example-config not having the |
You can still have the default as |
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.
build(aio): add upgrade as a systemjs project
- I think the commit message should be "... configure upgrade projects to use systemjs".
- LGTM bearing in mind my suggestion for the
projectType
configuration property.
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.
build(aio): put webpack as systemjs temporarily
- message could be "... configure webpack example as systemjs" and then explain that it is a temporary hack as in the PR description.
- LGTM, the irony of
"run": "serve:cli"
, then"systemjs": true
.
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.
build(aio): add basic CLI artfacts
- Is this in some way tied to a version of the CLI? What is the process for upgrading the CLI version?
- Should we consider getting these boilerplate files directly from the CLI as needed, somehow, rather than checking them into the project?
- Why are we copying the
.gitignore' boilerplate (and then ignoring it as boilerplate)? Shouldn't we just include the ignore rules in our standard example
.gitignorefile and not have this
.gitignore` file in the boilerplate?
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.
build(aio): remove webpack packages due conflict
- LGTM
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.
build(aio): update router to CLI to play with it
- LGTM
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.
build(aio): add assets and environments
- LGTM
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.
Nice! 👍 Moving all examples to cli will be awesome. (Even more so, if we automatically upgrade to the latest version 😁)
I left a few (random) comments from a quick look 😁
aio/content/examples/.gitignore
Outdated
**/e2e/tsconfig.e2e.json | ||
**/.angular-cli.json | ||
**/.editorconfig | ||
**/.gitignore |
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.
Very meta 😛
@@ -83,7 +83,7 @@ describe('AngularJS to Angular Quick Reference Tests', function () { | |||
} | |||
|
|||
function testPosterButtonClick(expectedButtonText: string, isDisplayed: boolean) { | |||
let posterButton = element(by.css('movie-list tr > th > button')); | |||
let posterButton = element(by.css('app-movie-list tr > th > button')); |
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.
!@#$%^&* style guide 😛
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.
I hear you
@@ -13,7 +13,7 @@ import { | |||
import { Heroes } from './hero.service'; | |||
|
|||
@Component({ | |||
selector: 'hero-list-auto', | |||
selector: 'app-list-auto', |
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.
Wouldn't app-hero-list-auto
be more clear?
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.
And similar for the rest of this example.
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.
Fixing, that was the first example I did and did sound good but doesn't.
@@ -1,14 +1,14 @@ | |||
<!-- #docregion --> | |||
<h1>My First Attribute Directive</h1> | |||
<!-- #docregion applied --> | |||
<p myHighlight>Highlight me!</p> | |||
<p appHightlight>Highlight me!</p> |
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.
my
is a way cooler prefix 😞
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.
@gkalpak suggest it to the CLI team as the new default
System.import('main.js').catch(function(err){ console.error(err); }); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<my-app>Loading...</my-apps> |
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.
<my-app>
?
Loading...
?
😱
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.
Oh. this chapter is in the list of the dead. Will be removed.
@@ -46,7 +46,7 @@ import 'core-js/es7/reflect'; | |||
* Required to support Web Animations `@angular/animation`. | |||
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation | |||
**/ | |||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`. | |||
import 'web-animations-js'; // Run `npm install --save web-animations-js`. |
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.
Shouldn't this be included in this package.json
as a dependency?
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.
Not reaally because it is not doing much. The interesting bits of that package.json
are the scripts that comes with it. I copy them to each example for the sake of "This is a CLI package.json" but all dependencies are in the main package.json
with all packages.
But yeah, I can add it.
That being said, I put that package for the zipper, which I forgot :)
@@ -13,7 +12,7 @@ | |||
"node_modules/@types" | |||
], | |||
"lib": [ | |||
"es2016", | |||
"es2017", |
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.
Why this change?
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.
I am not sure why we have that, but the CLI tsconfig has es2017
aio/tools/plunker-builder/builder.js
Outdated
@@ -148,6 +149,11 @@ class PlunkerBuilder { | |||
} | |||
} | |||
|
|||
// Matches main.ts or main.1.ts | |||
if (/main(\.?|\-*?)\w*?\.ts/.test(relativeFileName)) { |
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.
I think the following RegExp you be more accurate:
/^main(?:[.-]\w+)?\.ts$/
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.
+1 for the $/
at the end
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.
Thanks, my regexp-fu is not that good
to: '' | ||
}, | ||
environment_check: { | ||
from: /if \(environment\.production\)\s*{\n*\s*enableProdMode\(\);\s*\n*}/mg, |
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.
\s
matches \n
, so no need for \n*
around \s*
.
Also, the m
flag seems unnecessary (since you are not using ^
or $
).
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.
Thanks
return globby(e2eSpecGlob, { cwd: basePath, nodir: true }) | ||
.then(paths => paths | ||
.filter(file => IGNORED_EXAMPLES.some(ignored => !file.startsWith(ignored))) | ||
.filter(file => !IGNORED_EXAMPLES.some(ignored => file.startsWith(ignored))) |
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.
💯
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.
That didn't work at first so I had to change it after a while playing dumb with the javascript console heh
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.
** build(aio): clean the cli-quickstart a bit more**:
- LGTM
@@ -46,7 +46,7 @@ import 'core-js/es7/reflect'; | |||
* Required to support Web Animations `@angular/animation`. | |||
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation | |||
**/ | |||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`. | |||
import 'web-animations-js'; // Run `npm install --save web-animations-js`. |
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.
// Run npm install --save web-animations-js
.
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.
Why not :)
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.
build(aio): more changes to cli boilerplate
- LGTM except the removal of the unnecessary comment
@@ -13,6 +13,9 @@ const TESTING_BASE_PATH = path.resolve(EXAMPLES_BASE_PATH, 'testing'); | |||
|
|||
const BOILERPLATE_PATHS = { | |||
cli: [ | |||
'src/environments/environment.prod.ts', |
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.
You can just remove the environment files if you want really. Remove them from the cli json as well and they won't be used.
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.
No, I don't want to. They all end in the zipper later and I want them to be as exact as possible.
<script src="node_modules/systemjs/dist/system.src.js"></script> | ||
<script src="systemjs.config.js"></script> | ||
<script> | ||
System.import('main.0.js').catch(function(err){ console.error(err); }); |
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.
How do these index pages work now? I guess that the CLI is going to do nothing with them. Is it that they are never actually run?
Each example is a CLI application that consist on |
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.
build(aio): migrate examples to CLI
- LGTM although I wonder about those ngmodule examples
background-image: url("assets/ng.png"); | ||
background-repeat: no-repeat; | ||
background-position: center center; | ||
padding: 1em 2em; | ||
} | ||
} */ |
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.
why comment this out when you deleted it in aio/content/examples/styleguide/src/04-11/app/core/nav/nav.component.css
?
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.
build(aio): fix systemjs testing:
- This commit needs some more explanation. Why these changes?
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.
build(aio): testing is now cli:
- I think this commit message should be more imperative. E.g. "Use CLI for unit testing examples", with more explanation in the message body.
- LGTM otherwise
@@ -5,6 +5,10 @@ function translate(html, rulesFile) { | |||
var rxRule = rulesFile.rules[rxDatum.pattern]; | |||
// rxFrom is a rexexp | |||
var rxFrom = rxRule.from; | |||
// check if there is an exception | |||
if (rxDatum.exceptIf) { | |||
if (html.indexOf(rxDatum.exceptIf) !== -1) return; |
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.
might be more flexible in the future for exceptIf
to be a regex?
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.
I guess you are right. But it seems I am not that good with regexp so I accept suggestions
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.
build(aio): plunker done:
- A couple of minor comments, including supporting @gkalpak's suggestions about regex changes.
- LGTM otherwise
const filePath = path.join(sourceFolder, EXAMPLE_CONFIG_NAME); | ||
try { | ||
const json = require(filePath, 'utf-8'); | ||
return json.systemjs ? 'systemjs' : 'cli'; |
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.
this code would become simpler if we switched from the boolean flag to a projectType
flag.
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.
build(aio): zipper done:
- LGTM (although it would benefit from the
projectType
flag discussed previously.
@@ -6,8 +6,7 @@ import { AppRoutingModule } from './app-routing.module'; | |||
|
|||
import { AboutComponent } from './about.component'; | |||
import { BannerComponent } from './banner.component'; | |||
import { UserService } from './model/user.service'; | |||
import { Hero } from './model/hero'; | |||
import { UserService } from './model/user.service'; | |||
import { HeroService } from './model/hero.service'; |
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.
If you are going to arrange the columns then you may as well do this one too :-)
@Foxandxss - still a few comments unaddressed; and we now have a conflict 😱 |
e663d67
to
48a496d
Compare
You can preview 48a496d at https://pr19248-48a496d.ngbuilds.io/. |
48a496d
to
52e8e31
Compare
You can preview 52e8e31 at https://pr19248-52e8e31.ngbuilds.io/. |
@@ -46,7 +46,7 @@ import 'core-js/es7/reflect'; | |||
* Required to support Web Animations `@angular/animation`. | |||
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation | |||
**/ | |||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`. | |||
import 'web-animations-js'; |
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.
why bring this in by default? I think this is wrong.
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.
We have an animations chapter and a router chapter with animations.
The boilerplate is generic so if any chapter needs something, we add it for all of them.
At least is that how the tools works for now.
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.
I'm going to approve this and merge this into master. There is still some followup work to be done though - e.g. I left a comment about the web animations polyfill.
I'm not going to cherry-pick this into the stable branch yet because that would go live rightaway, which is likely not good since the prose is missing. Please let me know if I'm wrong about this.
I don't think this PR will make the prose any different at all. On the one hand is better because now people will download actual CLI projects with a ZIP but on the other hand if a guide has a prefix hardcoded on it and now it is different, that could be a bit bad. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This small PR migrates all the examples infrastructure to CLI (prose will come in a different PR).
Since it is quite big, I am going to explain some commits and the reasoning behind them.
reestructure boilerplate to allow more types
- Modified the boilerplate to allow different kind of boilerplates. AKA systemjs and CLI (we still have some SystemJS examples like the AOT chapter)remove cli-quickstart boilerplate
- CLI had boilerplate on it, removed it so it will always receive the latest boilerplate available.put webpack as systemjs temporarily
- This chapter is going to be possibly dropped (it doesn't appear on the sidebar anymore) and it was messing with my work, so I put it as systemjs as a way to make it not bother me.remove webpack packages due conflict
- CLI is a bit picky if you have webpack and other dependencies as well (all the packages for all examples are in the same bucket). I removed them and since we are going to remove the webpack chapter, it is just an early cleanup.tune up all examples && modify each example to be CLI compliant
- All examples needed changes. Cleanup of the HTML to remove systemjs artifacts, main.ts needs to load environments, and a few more extra changed that some chapters needed.change examples to have app- prefix
- We used to havemy-
as a prefix but the default for CLI isapp
and the idea is to have our examples as default as possible. You may notice that some concrete chapters doesn't have a prefix, but it makes sense to leave it as is for the chapter. Can be changed tho.e2e support done
- Yay, super fast. Some ignored examples, read below.plunker done
- It keeps working as it should, as systemjs examples.zipper done
- I realized that there are no more systemjs zips. So we could decide about dropping the support of systemjs and simplify the tool a bit.That being said, there are some things that to notice here and to be addressed in following PRs:
No changes or minimum changes to ToH. They are going to be addressed in a different PR since Jules started a good PR for that.
There are some ignored e2e examples.
quickstart
(to be deleted),http
(to be deleted),setup
(to be deleted.
Webpack(to be deleted),
upgrade-phonecat` they are erroring quite a bit and I think it was an old issue that has nothing to do with this PR so we can fix it later.Testing chapter has 1-2 non passing tests, but the original one had broken tests as well, so to be fixed in a separete PR by @wardbell.
i18n hasn't been touch. It needs some work to be translated to
CLI
both in code and prose. So they will be done separately.Animations will fail e2e, there is a PR to fix that here at docs: animations - replace iterator with simple code style #18965.
Deployment as well as i18n hasn't been touch. Needs work. To be done as a separate PR.