Skip to content

Commit

Permalink
refactor!: separate components into npm packages in monorepo; add log…
Browse files Browse the repository at this point in the history
…istration-redirect (#97)

BREAKING CHANGE: refactor to split ui components into separate packages using Lerna
  • Loading branch information
adamstankiewicz committed May 6, 2021
1 parent 25d080b commit 3e2a3ac
Show file tree
Hide file tree
Showing 106 changed files with 62,036 additions and 27,484 deletions.
29 changes: 0 additions & 29 deletions .eslintrc.js

This file was deleted.

59 changes: 32 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
name: node_js CI
name: CI

on: [push, pull_request]
on: [push]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Nodejs
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm run test
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Preview semantic-release version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
run: npx semantic-release --dry-run --branches=${{ steps.extract_branch.outputs.branch }}
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Nodejs
uses: actions/setup-node@v1
with:
node-version: 12
# lerna expects to be authenticated for publishing to NPM. This step will fail CI if NPM is not
# authenticated, even though this build does _not_ attempt to publish, as an extra check before merge
# that Lerna is set to publish.
- name: Check NPM authentication
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}" >> .npmrc
npm whoami
- name: Install Dependencies
run: npm ci
- name: Lerna Bootstrap
run: npm run bootstrap
- name: Lint
run: npm run ci:lint
- name: Test
run: npm run ci:test
- name: Coverage Report
uses: codecov/codecov-action@v1
- name: Build
run: npm run ci:build
- name: Preview Changed Packages
run: npm run changed
36 changes: 25 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
with:
fetch-depth: 0
- name: Setup Nodejs
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install dependencies
# lerna expects to be authenticated for publishing to NPM. This step will fail CI if NPM is not authenticated
- name: Check NPM authentication
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}" >> .npmrc
npm whoami
- name: Install Dependencies
run: npm ci
- name: Run Lerna Bootstrap
run: npm run bootstrap
- name: Lint
run: npm run ci:lint
- name: Test
run: npm run test
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Release
run: npm run ci:test
- name: Coverage Report
uses: codecov/codecov-action@v1
- name: Build
run: npm run ci:build
- name: Preview Changed Packages
run: npm run changed
- name: Publish Changed Packages
run: npm run publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
run: npx semantic-release
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.vscode
.idea
coverage
dist
node_modules
*~
lerna-debug.log
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.10.0
12
27 changes: 0 additions & 27 deletions .releaserc

This file was deleted.

69 changes: 39 additions & 30 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
frontend-enterprise
=============

|Build Status| |Coveralls| |npm_version| |npm_downloads| |license| |semantic-release|
|Build Status| |Codecov|

frontend-enterprise contains utility functions for supporting enterprise features.
``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.

- ``@edx/frontend-enterprise-catalog-search``
- ``@edx/frontend-enterprise-logistration``
- ``@edx/frontend-enterprise-utils``

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`` development, clone the repo and run the following commands to create production builds for each package:

::

npm install
npm run bootstrap
npm run lint
npm run test
npm run build

These NPM scripts are running Lerna commands behind the scenes to run only the scripts for any packages that have changed since the last release. To run NPM scripts for a single package in the monorepo, you may run Lerna commands directly. For example, to only run tests for a specific package:

::

lerna run test --scope=@edx/frontend-enterprise-catalog-search

See https://github.com/lerna/lerna for full documentation of Lerna commands.

Dependency notes
-----

* eslint-plugin-import needed at least 2.22.1 to avoid failures with an infinity symbol (see https://stackoverflow.com/questions/64790681/eslint-error-configuration-for-rule-import-no-cycle-is-invalid). This can be removed from here once frontend-build PR is merged: https://github.com/edx/frontend-build/pull/137
* ``eslint-plugin-import`` needed at least 2.22.1 to avoid failures with an infinity symbol (see https://stackoverflow.com/questions/64790681/eslint-error-configuration-for-rule-import-no-cycle-is-invalid). This can be removed from here once frontend-build PR is merged: https://github.com/edx/frontend-build/pull/137

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

```
type: subject
Expand All @@ -21,31 +47,14 @@ type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style,

Versioning and Releases
-----
This library has its version automatically updated by semantic-versioning when the release is published to npm. The source code package.json file should remain at "1.0.0-semantically-released". The below Usage instructions will install the latest version from npm. Please see the repository Releases for earlier package versions.
This library has its version automatically updated by Lerna using semantic-versioning under-the-hood when the release is published to npm. The source code package.json file versions should 0.0.0.

Preview next release version from Pull Requests
Preview changed packages in CI with Github Actions
*****

As a convenience, the "node_js CI / build (push)" check on Pull Requests includes a step to analyze the commit(s) and outputs a preview of what version semantic-release will publish if a PR gets merged. This is done using the "--dry-run" option for the semantic-release CLI, which will skip the publish/release steps. Look for a message in this CI step along the lines of "The next release version is <NEXT_RELEASE_VERSION>".

Usage
-----

To install frontend-enterprise into your project:

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

npm i --save @edx/frontend-enterprise

.. |Build Status| image:: https://api.travis-ci.com/edx/frontend-enterprise.svg?branch=master
:target: https://travis-ci.com/edx/frontend-enterprise
.. |Coveralls| image:: https://img.shields.io/coveralls/edx/frontend-enterprise.svg?branch=master
:target: https://coveralls.io/github/edx/frontend-enterprise
.. |npm_version| image:: https://img.shields.io/npm/v/@edx/frontend-enterprise.svg
:target: @edx/frontend-enterprise
.. |npm_downloads| image:: https://img.shields.io/npm/dt/@edx/frontend-enterprise.svg
:target: @edx/frontend-enterprise
.. |license| image:: https://img.shields.io/npm/l/@edx/frontend-enterprise.svg
:target: @edx/frontend-enterprise
.. |semantic-release| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
:target: https://github.com/semantic-release/semantic-release
.. |Build Status| image:: https://github.com/edx/frontend-enterprise/actions/workflows/release.yml/badge.svg
:target: https://github.com/edx/frontend-enterprise/actions
.. |Codecov| image:: https://codecov.io/gh/edx/frontend-enterprise/branch/master/graph/badge.svg?token=lBHoe5P4Q3
:target: https://codecov.io/gh/edx/frontend-enterprise
37 changes: 37 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
coverage:
status:
project:
default:
target: auto
threshold: 0.10%
catalog-search:
target: auto
threshold: 0.10%
flags:
- catalog-search
logistration:
target: auto
threshold: 0.10%
flags:
- logistration
utils:
target: auto
threshold: 0.10%
flags:
- utils

flags:
catalog-search:
paths:
- packages/catalog-search/src
logistration:
paths:
- packages/logistration/src
utils:
paths:
- packages/utils/src

comment:
layout: "reach,diff,flags,files,footer"
behavior: default
require_changes: no
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-angular'],
extends: ['@commitlint/config-conventional'],
};
37 changes: 37 additions & 0 deletions docs/decisions/0001-architecture-decision-records.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
================================
1. Record Architecture Decisions
================================

******
Status
******

Accepted

*******
Context
*******

We would like to keep a historical record on the architectural decisions we make with this app as it evolves over time.

********
Decision
********

We will use Architecture Decision Records, as described by
Michael Nygard in `Documenting Architecture Decisions`_

.. _Documenting Architecture Decisions: http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions

************
Consequences
************

See Michael Nygard's article, linked above.

**********
References
**********

* https://resources.sei.cmu.edu/asset_files/Presentation/2017_017_001_497746.pdf
* https://github.com/npryce/adr-tools/tree/master/doc/adr

0 comments on commit 3e2a3ac

Please sign in to comment.