Skip to content
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

Fixes #27074 - Migrate to @theforeman/vendor and @theforeman/vendor-dev pkg #6605

Merged
merged 1 commit into from Jul 16, 2019

Conversation

sharvit
Copy link
Contributor

@sharvit sharvit commented Mar 21, 2019

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 4ee4b81 must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@Ron-Lavi
Copy link
Member

What's the status of this PR? thanks :)

@sharvit
Copy link
Contributor Author

sharvit commented May 21, 2019

What's the status of this PR? thanks :)

I'm working on releasing a new version of @theforeman/vendor and then rebasing this PR.
Thanks for caring about vendor @LaViro 👍

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 1f6f9df must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@sharvit sharvit marked this pull request as ready for review May 27, 2019 09:26
@sharvit
Copy link
Contributor Author

sharvit commented May 28, 2019

  1. dev-server is working well atm
  2. production build and server working well atm
  3. need to fix some small testing issues

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 805807d must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@waldenraines
Copy link

I created a redmine issue for this - https://projects.theforeman.org/issues/27074

@coveralls
Copy link

coveralls commented Jun 24, 2019

Coverage Status

Coverage increased (+0.2%) to 72.862% when pulling 7fb1165 on sharvit:feature/foreman-vendor into ce287cf on theforeman:develop.

@sharvit
Copy link
Contributor Author

sharvit commented Jun 24, 2019

Status Update

I have just released @theforeman/vendor version 0.1.0-alpha.6 and updated this PR to use it.

You can test it by simply run:

rm -rf node_modules/
rm -rf package-lock.json
npm install

# running test should work
npm test

# running development server should work
foreman start

# building and running production should work
RAILS_ENV=production bundle exec rake assets:precompile
RAILS_ENV=production bundle exec rake webpack:compile
RAILS_ENV=production foreman start rails

There is one issue when running npm run lint

Yesterday, eslint-plugin-react released version 7.14.0 which break patternfly-react-eslint.
PR opend in patternfly-react to fix it:
patternfly/patternfly-react#2334

@sharvit
Copy link
Contributor Author

sharvit commented Jun 24, 2019

There is one issue when running npm run lint

Yesterday, eslint-plugin-react released version 7.14.0 which break patternfly-react-eslint.
PR opend in patternfly-react to fix it:
patternfly/patternfly-react#2334

This is been fixed in eslint-plugin-react version 7.14.1.
The PR in patternfly-react closed.

@sharvit
Copy link
Contributor Author

sharvit commented Jun 24, 2019

#6858 created to fix the linting issue

@sharvit
Copy link
Contributor Author

sharvit commented Jul 9, 2019

We decided to solve this issue by pushing forward #6748
https://community.theforeman.org/t/rfc-changing-how-we-handle-webpack-building/11491/78?u=sharvit

#6748 is merged now so I'm rebasing this PR and the ruby test error should be resolved.
Thanks @ezr-ondrej @tbrisker

@sharvit
Copy link
Contributor Author

sharvit commented Jul 9, 2019

Looks like the failed test is not related?

@sharvit
Copy link
Contributor Author

sharvit commented Jul 9, 2019

Update

  1. I have just released @theforeman/vendor version 0.1.0-alpha.9 and this PR use it now.
    It fixes the issue that blocked the packaging: [WIP] Add nodejs-theforeman-vendor foreman-packaging#3882

  2. This PR rebased and contains Fixes #21592 - uses headless chrome instead of phantomjs  #6748 so the ruby test errors should be fixed now.

Ready for another session of reviews.

app/views/layouts/base.html.erb Show resolved Hide resolved
config/webpack.config.js Outdated Show resolved Hide resolved
jest.config.js Outdated Show resolved Hide resolved
collections: true,
flattening: true,
shorthands: true
}),
Copy link
Member

Choose a reason for hiding this comment

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

Reading this plugin's description, i think it may have been the cause of the unexpected hash changes we were seeing in the past:

Create smaller Lodash builds by replacing feature sets of modules with noop, identity, or simpler alternatives.

which is exactly what I discovered when trying to isolate the changes - modules that were being replaced by noop and identity.
Are we still using it in the vendor build? if so, I think we shouldn't - even though we may get a larger build, we want to make all of lodash available to consumers since we can't tell which modules aren't used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, the new vendor don't use this plugin anymore so it contains the full lodash lib.
Once we stabilize the build, I'm open-minded trying more optimizations.


FOREMAN_JS_LOCATION="../${FOREMAN_JS_LOCATION}"
FOREMAN_JS_PACKAGES_LOCATION="${FOREMAN_JS_LOCATION}/packages"
FOREMAN_JS_INSTALL_LOCATION="./node_modules/@theforeman"
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be "../node_modules/@theforeman"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because you run this script from the root by using npm run foreman-js:link.
See webpack/stories/docs/addingDependencies.md

script/npm_link_foreman_js.sh Show resolved Hide resolved
webpack/assets/javascripts/bundle.js Outdated Show resolved Hide resolved
@sharvit
Copy link
Contributor Author

sharvit commented Jul 10, 2019

@tbrisker can you revisit please?

exit 1
fi

FOREMAN_JS_LOCATION="../${FOREMAN_JS_LOCATION}"
Copy link
Member

Choose a reason for hiding this comment

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

this will make it ../../foreman-js with the default, and add a ../ to the path given by the user which would be confusing

Copy link
Contributor Author

@sharvit sharvit Jul 10, 2019

Choose a reason for hiding this comment

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

imo it will make it easier because you will define FOREMAN_JS_LOCATION relatively to foreman root so you can have:

home/foreman
home/foreman-js

So inside foreman you can run:

FOREMAN_JS_LOCATION="../foreman-js" npm run foreman-js:lint

imo it will be confusing if you will need to set FOREMAN_JS_LOCATION relatively to the scripts folder.

Copy link
Member

Choose a reason for hiding this comment

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

didn't you reply below that this script runs from the foreman root because it is executed by npm? in that case ../../foreman-js would be the wrong folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there is a difference in how the rm and ln commands are working and their parameters.
You can try the script, I have just verified it is working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is only the second parameter of the ln that need to be relative to root.

Copy link
Member

Choose a reason for hiding this comment

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

ah, i see, it's is because ln creates the link relative to the link location, not to the cwd. you could unite this line with the next but not critical.

@@ -25,22 +25,8 @@ import * as configReportsModalDiff from './foreman_config_reports_modal_diff';
import * as classEditor from './foreman_class_edit';
import * as dashboard from './dashboard';
import * as spice from './spice';
import './bundle_datatables';
import './bundle_lodash';
Copy link
Member

Choose a reason for hiding this comment

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

I may be missing it, where are we making window._ available if the bundle is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lodash put it there automatically once you require it, the bundle_lodash just replaced the window._ with another leaner object.

tbrisker
tbrisker previously approved these changes Jul 11, 2019
Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Thanks @sharvit ! code looks good, tested and everything seems to work well including several plugins both in development and production mode. This is ready to merge on my side once we figure out the packaging side.

@tbrisker tbrisker added Waiting on Packaging PRs that shouldn't be merged until packaging side is merged and removed Needs testing labels Jul 11, 2019
@tbrisker
Copy link
Member

@sharvit looks like there is a conflict in package.json, please rebase on latest develop

@sharvit
Copy link
Contributor Author

sharvit commented Jul 11, 2019

@sharvit looks like there is a conflict in package.json, please rebase on latest develop

This conflict will be solved only by updating the foreman-js project. (and releasing a new @theforeman/vendor to npm)

Notice there is another issue that should get fixed:
theforeman/foreman-packaging#3882 (comment)

@tbrisker
Copy link
Member

@sharvit besides the packaging issue, this can't be merged right now because of a merge conflict with the current package.json in develop branch. rebasing should fix that.

@sharvit
Copy link
Contributor Author

sharvit commented Jul 13, 2019

Thanks @tbrisker

  1. @theforeman/vendor version 0.1.0-alpha.10 has released.
    https://github.com/theforeman/foreman-js/compare/@theforeman/vendor@0.1.0-alpha.9...@theforeman/vendor@0.1.0-alpha.10
  2. This PR updated to use the new vendor version.
  3. The babel issue fixed.
  4. This PR as rebased.

tbrisker
tbrisker previously approved these changes Jul 14, 2019
@sharvit sharvit force-pushed the feature/foreman-vendor branch 2 times, most recently from c8eb72e to 123e561 Compare July 16, 2019 08:37
@sharvit
Copy link
Contributor Author

sharvit commented Jul 16, 2019

Updates

  1. @theforeman/vendor version 0.1.0-alpha.11 has released.
    https://github.com/theforeman/foreman-js/compare/@theforeman/vendor@0.1.0-alpha.10...@theforeman/vendor@0.1.0-alpha.11
  2. This PR updated to use the new vendor version.
  3. This PR updated with some scss cleanups

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Thanks @sharvit !

@tbrisker tbrisker merged commit 0220eaa into theforeman:develop Jul 16, 2019
@sharvit sharvit deleted the feature/foreman-vendor branch August 5, 2019 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UI Waiting on Packaging PRs that shouldn't be merged until packaging side is merged
Projects
None yet
9 participants