Skip to content

(WIP) Implement application decoupling #926

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

Closed
wants to merge 4 commits into from
Closed

(WIP) Implement application decoupling #926

wants to merge 4 commits into from

Conversation

TheDonDope
Copy link
Contributor

@TheDonDope TheDonDope commented May 26, 2016

Hey guys,

i went ahead and started working on implementing the application decoupling as discussed in #913.
The PR is still a a work in progress:

  • rename src/client to src/browser <- IF browser is now fine for everyone :D I could change it if you want
  • move karma.conf.js to src/browser/karma.conf.js
  • move test-main.js to src/browser/test-main.js
  • move protractor.conf.js to src/browser/protractor.conf.js
  • make sure $ npm start is still running fine (update seed.config.ts)
  • make sure $ npm test is still running fine (updating the paths in karma.start.ts, karma.conf.js and test-main.js
  • exclude karma.conf.js, protractor.conf.js and test-main.js from the copy process to dist/**
  • make sure $ npm run webdriver-start && $ npm run serve.e2e && $ npm run e2e still runs fine should work now with the updates of commit 4b2ca0b
  • implement dedicated package.json in src/browser
  • update build tasks / configuration to create dist/browser/dev|prod|test|tmp directories

Any feedback/help/change requests are welcome as always :)

Have a nice day!

// cc @mgechev @ludohenin @d3viant0ne @NathanWalker @Shyam-Chen

Implements the application decoupling as discussed in #913.
@@ -47,7 +47,7 @@ module.exports = function(config) {
// suppress annoying 404 warnings for resources, images, etc.
{ pattern: 'dist/dev/assets/**/*', watched: false, included: false, served: true },

'test-main.js'
'src/browser/test-main.js'
Copy link
Contributor Author

@TheDonDope TheDonDope May 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently test-main.js gets copied over to dist/dev/test-main.js. Should that be? Or should it be excluded from the copy task (Don't know right now, which task does the copying)
Question: Should it point to the copied test-main.js in dist/dev or the source test-main.js in src/browser?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be copied because it is not used there. We should use the version in src/browser.

Copy link
Contributor Author

@TheDonDope TheDonDope May 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info! I updated the build task accordingly with the commit 0129dac

@mgechev
Copy link
Owner

mgechev commented May 26, 2016

@TheDonDope awesome job!

Excludes karma.conf.js, protractor.conf.js and test-main.js from the copy
build task, so that those files will not be copied over to /dist/** directory.
Furthermore also excludes the tsconfig.json from this copy process, as it was
copied over before too.
@TheDonDope
Copy link
Contributor Author

@Shyam-Chen I already tried that, but it did not have an effect. I think there is another change neccessary in https://github.com/mgechev/angular2-seed/blob/master/package.json#L16

Currently, if you run $ npm run e2e protractor gets called directly, but not through the tools/tasks/seed/e2e.ts.

@Shyam-Chen
Copy link
Contributor

@TheDonDope

e2e has two parts, one is CI, the other is a local

@Shyam-Chen
Copy link
Contributor

see #837

@TheDonDope
Copy link
Contributor Author

@Shyam-Chen yes thank you i found that one too through the history of package.json.
However on current master it is:

    "e2e": "protractor",

for the local protractor run.

Shouldnt this command needed to be update to something like:

   "e2e": "gulp build.e2e --color && gulp build.js.e2e --color && gulp e2e --color",

@Shyam-Chen
Copy link
Contributor

@TheDonDope
Copy link
Contributor Author

@Shyam-Chen
Haha, thanks! But now i am completely confused.
Currently (on current master) in the package.json there are 4 different protractor related scripts:

  "scripts": {
    [...]
    "e2e": "protractor",
    "e2e.live": "protractor --elementExplorer",
    [...]
    "e2e.ci": "gulp build.prod --color && gulp build.js.e2e --color && gulp e2e --color",
    "tests.all": "npm test && npm run e2e.ci",
    [...]
  },

According to the README.md, if you want to execute the e2e tests locally, you have to:

# e2e (aka. end-to-end, integration) - In three different shell windows
# Make sure you don't have a global instance of Protractor

# npm run webdriver-update <- You will need to run this the first time
npm run webdriver-start
npm run serve.e2e
npm run e2e

# e2e live mode - Protractor interactive mode
# Instead of last command above, you can use:
npm run e2e.live

Is this still correct?

If it is correct, then the gulp script e2e would be triggered, which would then execute protractor directly, which then would fail since the protractor.conf.js has moved to src/browser/protractor.conf.js.

So, since we do have a dedicated gulp task tools/tasks/seed/e2e.ts shouldn't be the "e2e" script be updated? Or even completely removed and only the e2e.ci task be used? (Since it is also included in tests.all).

To sum it up: If i understood everything correctly, my guessed solution to the problem would be the following:

In package.json:

  "scripts": {
    [...]
    "e2e": "gulp build.prod --color && gulp build.js.e2e --color && gulp e2e --color",
    [...]
    "tests.all": "npm test && npm run e2e",
    [...]
  },
  • Drop the dedicated e2e.ci script and include it into the e2e script. (Which is also used in tests.all then)

What do you think?

@Shyam-Chen
Copy link
Contributor

e2e.ci It is a single run for e2e tests.

@Shyam-Chen
Copy link
Contributor

Shyam-Chen commented May 26, 2016

rename e2e.ci to e2e.singleRun (IMO)

Updates the protractor configuration and associated gulp task.
@TheDonDope TheDonDope changed the title (WIP) Implement application decoupling (Fix #913) Implement application decoupling May 26, 2016
@TheDonDope
Copy link
Contributor Author

🎉 Alright, from my side i'm finished, looking forward for a code review :)

@mgechev
Copy link
Owner

mgechev commented May 26, 2016

LGMT. I'll take a better look in the afternoon and merge.

Guys great job!

@mgechev mgechev self-assigned this May 26, 2016
"e2e.live": "protractor --elementExplorer",
"e2e": "protractor src/browser/protractor.conf.js",
"e2e.live": "protractor src/browser/protractor.conf.js --elementExplorer",
"e2e.singleRun": "gulp build.prod --color && gulp build.js.e2e --color && gulp e2e --color",
"gulp": "gulp",
"karma": "karma",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it going to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Shyam-Chen, what do you mean?

About "e2e" -> I had to add the src/browser/protractror.conf.js to it, since it has been moved to src/browser. The same for "e2e.live".

About "e2e.singleRun" i renamed "e2e.cli" as you suggested to "e2e.singleRun" and sorted it alphabetically under "e2e.live"(since all other scripts are also in alphabetical order)

@TheDonDope
Copy link
Contributor Author

TheDonDope commented May 26, 2016

@mgechev Thanks! :) I just wanted to update the README.md to include the new directory structure and discovered that the coverage directory now gets generated within src/browser. I guess that should not be the case, should it? This must have been a side effect of moving the *.conf.js files to src/browser. I'll take another look at it to make sure it gets generated in its original place.
Update: After another look i found that it get generated in the root directory correctly (must have been the leftovers of some previous experiment).

@Shyam-Chen
Copy link
Contributor

Shyam-Chen commented May 26, 2016

add new task?

// gulpfile.ts
gulp.task('e2e.singleRun', (done: any) =>
  runSequence('build.prod',
              'build.js.e2e',
              'e2e',
              done));
"e2e.singleRun": "gulp e2e.singleRun --color",  // package.json

Adds a e2e.singleRun gulp task to the gulpfile to leave the script
in the package.json more compact. Also updates the README to include
the new folder and file structure.
@TheDonDope
Copy link
Contributor Author

@Shyam-Chen Thanks for the suggestion, i updated it and added this with the commit 8ad5161 :)

@ludohenin
Copy link
Collaborator

Awesome guys.
I think one important bit is missing, package.json ?

@TheDonDope
Copy link
Contributor Author

Hey @ludohenin what about the package.json? What is missing?

@TheDonDope
Copy link
Contributor Author

TheDonDope commented May 26, 2016

@ludohenin Oh sh**, i just had another look at the original proposal of #913, and you are totally right! There was a separate package.json proposed inside src/browser. Sorry, i completely forgot about that one!

@ludohenin
Copy link
Collaborator

In @mgechev's proposal, the client platform app comes with its own package.json file.

@TheDonDope
Copy link
Contributor Author

@ludohenin I guess it will not be as easy as to just transfer the browser app specific dependencies to the src/browser/package.json and then "it just works", would it? Which build scripts would need an update?

@TheDonDope
Copy link
Contributor Author

TheDonDope commented May 26, 2016

Also: Would this mean that in consequence that there would be a separete node_modules directory within src/browser? And furthermore: Would there need to be another typings.json within the src/browser directory as well as the corresponding src/browser/typings directory?
And even futher: Would there need to be a dedicated dist/browser/dev|prod|test|tmp output directory? (since there could be potentially multiple applications within src?)
Oh my god i hope this is not a bottomless pit 👻 I think i need a 🍺 now :D

@mgechev
Copy link
Owner

mgechev commented May 26, 2016

Hahah, I agree about the 🍺, and about the changes that need to be made.

The build needs to be changed to create dist/browser/dev|prod|test|tmp. I think we can live with the current set of typings but package.json is something that needs to be moved to src/browser because otherwise we need to install all the dependencies for all the applications when having many platforms.

@TheDonDope
Copy link
Contributor Author

🚑 Alright, i hereby call for help on the last necessary changes: 🚑

  • Implementing the dedicated `src/browser/package.json
  • Updating the necessary build tasks / configuration

Any snippets / commits / fork branches are welcome :)

Thanks guys!

@TheDonDope TheDonDope changed the title Implement application decoupling (WIP) Implement application decoupling May 26, 2016
@mgechev
Copy link
Owner

mgechev commented May 27, 2016

I'll put this in my schedule for the next week/during the weekend.

@TheDonDope
Copy link
Contributor Author

Continued in #959 which has this commits pushed to the issue/913-application-decoupling branch of this repository.

@TheDonDope TheDonDope closed this Jun 3, 2016
@TheDonDope TheDonDope deleted the issue/913-application-decoupling branch June 3, 2016 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants