Giter Site home page Giter Site logo

frontend-enterprise's Introduction

frontend-enterprise

Build Status Codecov

frontend-enterprise is a monorepo powered by Lerna containing several JavaScript packages that are independently published to NPM. These packages, listed below, contain shared enterprise-related UI components and utility functions.

Each of these packages is published to NPM and have their own README files. The packages can be found in the packages/* folder.

Getting started with development

To get started with frontend-enterprise local development, clone the repo and run the following commands:

npm run setup

The above command will install package dependencies using NPM workspaces, hoisting all packages to node_modules at the root of the repository for performance reasons (e.g., there will only be one copy of React). By using NPM workspaces, npm install knows that when importing a package that is part of this monorepo (e.g., @edx/frontend-enterprise-utils), it should look at the local package folder and creates symlinks accordingly.

Other useful commands for linting and testing may include:

npm run lint
npm run test

The above NPM scripts are run via NPM workspaces behind-the-scenes. By default, it will run the associated NPM command in each package in the monorepo. However, NPM workspaces does provide a mechanism to only run tests for a specific package, for example:

npm run test -w @edx/frontend-enterprise-catalog-search

To clean your local monorepo of any installed node_modules and symlinked packages to start fresh, you may run:

npm run clean

Installing new NPM modules in the workspace packages

To install a new NPM module in all workspace packages, use the --workspaces argument, e.g.:

npm install @openedx/paragon@latest --workspaces

To install a new NPM module in one or more specific workspace package(s), use the --workspace argument, e.g.:

npm install -D @openedx/paragon@latest --workspace=@edx/frontend-enterprise-catalog-search

Installing local monorepo package(s) into an Open edX micro-frontend

For any micro-frontend using @openedx/frontend-build <https://github.com/openedx/frontend-build> that consumes any packages from this monorepo may want to use a local copy of one or more packages during development rather than relying solely on the published NPM packages. To do this, you may modify your module.config.js file (create module.config.js if it does not already exist) to create Webpack aliases to your local checkout of the monorepo packages:

module.exports = {
  localModules: [
    {
      moduleName: '@edx/frontend-enterprise-catalog-search',
      dir: '../frontend-enterprise/packages/catalog-search',
      dist: 'src',
    },
  ],
};

By configuring the module.config.js as such, when running npm start, the consuming micro-frontend will instead import from the ../frontend-enterprise/packages/catalog-search/src rather than the published @edx/frontend-enterprise-catalog-search NPM package. This allows contributors to test any local changes to packages in this monorepo inside of consuming applications.

Note that the dist configuration option in the above example is set to src vs. dist. By using src here, any changes made to package source files will be picked up and hot reloaded by the consuming micro-frontend.

Conversely, if this option is dist, it expects a dist directory to exist in the package. To ensure these dist directories exist, you may run npm run dev in another terminal window/tab to watch for changes in any package source files and re-transpile them into dist such that the consuming micro-frontend will always be using the build with the latest source file changes.

Considerations for updating existing packages or adding a new package

When making updates in this monorepo, be sure to consider whether your changes should belong in an existing NPM package or a brand new NPM package. The purpose of the monorepo is to keep clear separation of concerns between packages so that each package owns a smaller domain of functionality or components to avoid package bloat.

However, we do run the risk of packages becoming a "catch-all" package (e.g., @edx/frontend-enterprise-utils) for anything that doesn't fit in existing packages. Contributors to the monorepo should consider whether any new functionality is related to the domains established in existing packages.

Managing package dependencies

Each package in the monorepo contains its own package.json file and unique set of dependencies depending on their needs. However, issues may arise when importing conflicting versions of external packages (e.g., React) in multiple monorepo packages. This is because some dependencies only properly work when there is a single copy of the dependency to ensure the same version is used throughout an application. For example, react and react-dom are common offenders here as there can only be one copy of React used at any given time. If a library/app attempts to use more than one copy or differening versions of React, there will be unintended behavior and warnings.

To get around this issue of common/shared dependencies, we can rely on how NPM finds installed packages. If a package does not exist in node_modules for an individual package, NPM will look in node_modules further up the directory tree until it finds the package, or gets to the root of the repository.

NPM workspaces helps with this by hoisting installed packages to the root node_modules folder where they will be accessible to any package in the monorepo to ensure there is only one copy used throughout. These dependencies are still noted in each individual package.json file as both a peer dependency and a dev dependency.

Writing a commit

There is a precommit plugin (commitlint) which requires commit messages formatted using conventional commits. See https://github.com/conventional-changelog/commitlint#what-is-commitlint for more details. In general you need something like the following:

type: subject

where type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style, test]

Note: only fix, feat, and perf will trigger a new NPM release, as this is the default behavior for semantic-release.

Versioning and releases

This library has its version automatically updated by Lerna using semantic versioning under-the-hood when publishing to NPM. Lerna is configured to use independent versioning with conventional commits, as opposed to keeping all package versions in sync.

When your contribution's PR is approved/merged, you'll need to instruct Lerna to create a new release commit (i.e., chore(release): publish new versions), as outlined in the steps below. In this release commit, Lerna increments the versions in the appropriate package.json files for any changed packages, creates Git tags, and updates the CHANGELOG file(s).

To create the Lerna release commit once your contribution's PR is approved/merged, please perform the following steps:

  1. Pull latest changes on your local checkout of master, ensuring your merged commit is included. It's also recommended to ensure you have the latest Git tags (i.e., git fetch --tags).
  2. Checkout a new branch and execute npm run lerna:version. Verify the recognized changed packages and their associated versions are correct. Once confirmed, Lerna will create a release commit and Git tags.
  3. Open a new PR with the release commit; do not push the Git tags yet. Once approved, merge the release commit PR to master.
  4. After the release commit is merged, ensure your local checkout of master includes the release commit. Because the release commit was squashed before merging, the Git tags generated by Lerna are associated with an orphaned commit SHA. The Git tags will need to be re-created for the correct commit SHA on master. The Git tags may be re-created for the latest commit by executing git tag -fa <tag-name> for each of the generated tags (e.g., git tag -fa @edx/[email protected]). Once you've re-created the Git tags for the correct commit SHA, you may verify them by executing git log --oneline --decorate to ensure the Git tags are associated with the latest commit on the master branch.
  5. Once the Git tags are verified to be associated with the latest release commit on master, push the Git tags to the remote repository by executing git push --tags. Confirm the Git tags have been created by verifying the tags in GitHub.
  6. To publish packages that had their versions incremented per the above steps, you must manually trigger the Publish from package.json Github Action workflow found here. It will publish any versions denoted in the package.json files that are not currently published on the NPM registry, publishing the incremented versions from the aforementioned release commit.
  7. Finally, we also recommend creating a GitHub release for the recently pushed Git tags to document the releases.

Preview changed packages in CI with Github Actions

As a convenience, a dry run of the lerna version command is run for each push to determine which packages in the monorepo will be published should a PR get merged.

frontend-enterprise's People

Contributors

adamstankiewicz avatar alex-sheehan-edx avatar bbaker6225 avatar bilalqamar95 avatar binodpant avatar chavesj avatar christopappas avatar edx-abolger avatar georgebabey avatar github-actions[bot] avatar hammadahmadwaqas avatar iloveagent57 avatar jajjibhai008 avatar jawayria avatar jlajoie avatar katrinan029 avatar kiram15 avatar long74100 avatar macdiesel avatar mahamakifdar19 avatar mashal-m avatar muhammad-ammar avatar muneebgh avatar nedbat avatar renovate-bot avatar renovate[bot] avatar saleem-latif avatar sameenfatima78 avatar syed-ali-abbas-zaidi avatar zamanafzal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frontend-enterprise's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Upgrade React JS to v17

This repo is currently using React JS v16. We need to upgrade it to React 17 before moving to latest React version(v18).
React 17 doesn’t add any new developer-facing features, so its upgrade might not cause any breaking changes. Our end goal is to upgrade React to v18 but v18 no longer support enzyme, so we are upgrading to React 17 and then we’ll migrate from enzyme.

Epic Link

React 17 upgrade

Re-enable `openedx/cla` status check for the `master` branch

All repos in the openedx Github organization now require the openedx/cla check to pass for commits to master. This repo, however, relies on Lerna to publish the various packages within this JS monorepo to NPM. Lerna utilitizes semantic-release to commit directly to master, which will not pass the openedx/cla check.

As a temporary work around, we have disabled the required openedx/cla status check for this repository.

We will address the issue of committing directly to master by finding another workaround (e.g., opening a new PR that gets automerged with the changes, giving an opportunity for the openedx/cla status check to occur).

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm react-instantsearch-dom Unavailable

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @edx/frontend-platform to v8.1.1
  • chore(deps): update dependency @openedx/frontend-build to v14.1.0
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update codecov/codecov-action action to v4
  • chore(deps): update dependency @commitlint/config-conventional to v19
  • chore(deps): update dependency @openedx/paragon to v22
  • chore(deps): update dependency conventional-changelog-conventionalcommits to v8
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lerna to v8
  • chore(deps): update dependency node to v20
  • chore(deps): update fregante/setup-git-user action to v2
  • chore(deps): update peter-evans/create-pull-request action to v6
  • chore(deps): update peter-evans/enable-pull-request-automerge action to v3
  • chore(deps): update testing-library monorepo (major) (@testing-library/jest-dom, @testing-library/react, @testing-library/react-hooks, @testing-library/user-event)
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/add-depr-ticket-to-depr-board.yml
.github/workflows/add-remove-label-on-comment.yml
.github/workflows/ci.yml
  • actions/checkout v2
  • actions/setup-node v3
  • codecov/codecov-action v3
.github/workflows/commitlint.yml
.github/workflows/lockfileversion-check.yml
.github/workflows/publish-from-package.yml
  • actions/checkout v2
  • fregante/setup-git-user v1
  • actions/setup-node v3
  • codecov/codecov-action v3
.github/workflows/release.yml
  • actions/checkout v2
  • fregante/setup-git-user v1
  • actions/setup-node v3
  • codecov/codecov-action v3
  • peter-evans/create-pull-request v4
  • peter-evans/enable-pull-request-automerge v2
.github/workflows/self-assign-issue.yml
npm
package.json
  • @commitlint/config-conventional 17.6.0
  • conventional-changelog-conventionalcommits ^5.0.0
  • husky 6.0.0
  • lerna 6.6.1
packages/catalog-search/package.json
  • @edx/frontend-enterprise-utils ^9.1.0
  • classnames 2.2.5
  • lodash.debounce 4.0.8
  • prop-types 15.7.2
  • @edx/browserslist-config 1.1.0
  • @edx/frontend-platform 8.0.0
  • @openedx/frontend-build 14.0.3
  • @openedx/paragon 21.13.1
  • @testing-library/jest-dom 5.11.6
  • @testing-library/react 12.1.4
  • @testing-library/react-hooks 3.4.2
  • @testing-library/user-event 13.1.8
  • react 17.0.2
  • react-dom 17.0.2
  • react-instantsearch-dom 6.8.3
  • react-router-dom 6.14.2
  • react-test-renderer 17.0.2
  • @edx/frontend-platform ^7.0.0 || ^8.0.0
  • @openedx/paragon ^21.0.0
  • react ^16.12.0 || ^17.0.0
  • react-dom ^16.12.0 || ^17.0.0
  • react-instantsearch-dom ^6.8.3
  • react-router-dom ^6.0.0
packages/hotjar/package.json
  • @edx/browserslist-config 1.1.0
  • @openedx/frontend-build 14.0.3
  • react 17.0.2
  • react-dom 17.0.2
  • react-router-dom 6.14.2
  • react ^16.12.0 || ^17.0.0
  • react-dom ^16.12.0 || ^17.0.0
  • react-router-dom ^6.0.0
packages/logistration/package.json
  • @edx/frontend-enterprise-utils ^9.1.0
  • prop-types 15.7.2
  • @edx/browserslist-config 1.1.0
  • @edx/frontend-platform 8.0.0
  • @openedx/frontend-build 14.0.3
  • @testing-library/jest-dom 5.11.6
  • @testing-library/react 12.1.4
  • react 17.0.2
  • react-dom 17.0.2
  • react-router-dom 6.14.2
  • react-test-renderer 17.0.2
  • @edx/frontend-platform ^7.0.0 || ^8.0.0
  • react ^16.12.0 || ^17.0.0
  • react-dom ^16.12.0 || ^17.0.0
  • react-router-dom ^6.0.0
packages/utils/package.json
  • @testing-library/react 12.1.4
  • history 4.10.1
  • @edx/browserslist-config 1.1.0
  • @edx/frontend-platform 8.0.0
  • @openedx/frontend-build 14.0.3
  • react 17.0.2
  • react-dom 17.0.2
  • react-router-dom 6.14.2
  • react-test-renderer 17.0.2
  • @edx/frontend-platform ^7.0.0 || ^8.0.0
  • react ^16.12.0 || ^17.0.0
  • react-dom ^16.12.0 || ^17.0.0
  • react-router-dom ^6.0.0
nvm
.nvmrc
  • node 18

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.