Skip to content

Commit

Permalink
Migrate to yarn workspace (#6)
Browse files Browse the repository at this point in the history
* inital code with placehlder modules added

* update readme. add steps to using remote module

* Login component extracted into core-module

* runtime config for modules remotes

* theme, language added n teacher apps. Login component imported from core into teacher app

* logn flow + eventbus + layout

* My Classes page added

* layout fixes

* My Classes page added

* teacher app theme fixes.dependency updatted

* default theme, menu comp added

* My Classes and Class Details added

* attendance module added

* My classes and class details added

* import fix

* changed to yarm workspace

* readme updated

Co-authored-by: Arun Rajput <[email protected]>
  • Loading branch information
arajput and Arun Rajput authored Mar 11, 2022
1 parent 0b35028 commit 632eb77
Show file tree
Hide file tree
Showing 144 changed files with 55,640 additions and 35 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ module.exports = {
name: "[module-name]",
...
```
# Run All Modules and Host Application
* Install dependency
```
yarn install
```
* Run all modules
```
yarn start
```

# Build Application for Production
```
yarn build
```

# Run Module as Standalone Application
Expand All @@ -38,15 +53,26 @@ lerna run start --scope=[module-name]
```

# Use Module in Host Application
* Add remote module url url to remotes in ```packages/[host-app]/moduleFederation.config.js ```
* Add remote module url to remotes in ```packages/[host-app]/moduleFederation.config.js ```
```
# e.g. core module is runninig on localhost:3001 then
remotes: {
core: 'core@http://localhost:3001/moduleEntry.js',
core: 'core@[window.appModules.core.url]/remoteEntry.js',
},
```
* Add entry to ```moodules.json```
```
# e.g. core module is runninig on localhost:3001 then
{
"core":{
"url": "http://localhost:3001"
},
...
}
```

* To use exposed component from remote module in react.
The lazy load componennt must be enclosed within ```<React.Suspense>```
Expand Down
7 changes: 3 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"packages": [
"packages/*"
],
"version": "0.0.0"
"version": "0.0.0",
"npmClient": "yarn",
"useWorkspaces": true
}
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
{
"name": "root",
"private": true,
"workspaces": {
"packages": [
"packages/*"
]
},
"scripts": {
"start": "lerna run --parallel start",
"build": "lerna run build",
"serve": "lerna run --parallel serve",
"clean": "lerna run --parallel clean",
"cls-dep": "npx rimraf ./**/node_modules"
},
"devDependencies": {
"lerna": "^4.0.0"
"lerna": "4.0.0"
}
}
23 changes: 23 additions & 0 deletions packages/attendance/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
17 changes: 17 additions & 0 deletions packages/attendance/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Dependency directories
node_modules/

# dependencies
package.json
package-lock.json

# testing
/coverage

# production
/build

.github/
/public
.min.js
.min.css
6 changes: 6 additions & 0 deletions packages/attendance/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"useTabs": false
}
13 changes: 13 additions & 0 deletions packages/attendance/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/preset-create-react-app",
],
framework: "@storybook/react",
core: {
builder: "webpack5",
},
};
9 changes: 9 additions & 0 deletions packages/attendance/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
202 changes: 202 additions & 0 deletions packages/attendance/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
# Contributing

We welcome contributions in several forms, e.g.

- Improve end user documenting on the [Wiki](https://github.com/Samagra-Development/Worksheet-Module/wiki)

- Write unit tests and learn how the code works

- Verify available [patches (pull requests)](https://github.com/Samagra-Development/Worksheet-Module/pulls)

- Working on [issues](https://github.com/Samagra-Development/Worksheet-Module/issues)

- Fix a bug
- Add a new feature

- etc.

## Reporting Bugs

Worksheet Module uses GitHub's issue tracker. All bugs and enhancements should be
entered so that we don't lose track of them, can prioritize, assign, and so code
fixes can refer to the bug number in its check-in comments.

The issue usually contains much more detail (including test cases) than can be
reasonably put in check-in comments, so being able to correlate the two is
important.

Consider the usual best practice for writing issues, among them:

- More verbosity rather than one liners
- Screenshots are a great help
- Providing example files (in case for example scanning crashes)
- Please determine the version, better the commit id
- Details on the operating system you are using

## Git Guidelines

Not familiar with git, see [Git basic commands](https://git-scm.com/)

### Workflow

We are using the [Feature Branch Workflow (also known as GitHub Flow)](https://guides.github.com/introduction/flow/),
and prefer delivery as pull requests.

Create a feature branch:

```sh
git checkout -B feat/tune-vagrant-vm
```

### Git Commit

The cardinal rule for creating good commits is to ensure there is only one
"logical change" per commit. Why is this an important rule?

- The smaller the amount of code being changed, the quicker & easier it is to
review & identify potential flaws.

- If a change is found to be flawed later, it may be necessary to revert the
broken commit. This is much easier to do if there are no other unrelated
code changes entangled with the original commit.

- When troubleshooting problems using Git's bisect capability, small well
defined changes will aid in isolating exactly where the code problem was
introduced.

- When browsing history using Git annotate/blame, small well defined changes
also aid in isolating exactly where & why a piece of code came from.

Things to avoid when creating commits

- Mixing whitespace changes with functional code changes.
- Mixing two unrelated functional changes.
- Sending large new features in a single giant commit.

### Git Commit Conventions

We use git commit as per [Conventional Changelog](https://www.conventionalcommits.org/en/v1.0.0/):

```none
<type>(<scope>): <subject>
```

Example:

```none
feat(vagrant): increase upload size
```

Allowed types:

- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, newline, line endings, etc)
- **refactor**: A code change that neither fixes a bug or adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests
- **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation

You can add additional details after a new line to describe the change in detail or automatically close an issue on Github.

```none
feat(CONTRIBUTING.md): create initial CONTRIBUTING.md
makes the following wiki Page obsolete:
- https://github.com/Samagra-Development/Worksheet-Module/wiki/Reporting-bugs
This closes #22
```

### Developer Certificate of Origin (DCO)

All commits not submitted via GitHub pull request shall contain a
Signed-off-by line, also known as the **Developer Certificate of Origin (DCO)**
as we know it from the Linux Kernel [Documenation/SubmittingPatches](https://www.kernel.org/doc/Documentation/process/submitting-patches.rst)

```none
Signed-off-by: Peace Fun Ingenium <[email protected]>
```

Additional tags in addition to Signed-off-by shall be used as long as it makes
sense for any commit, e.g.

```none
Reviewed-by:
Tested-by:
Reviewed-by:
Suggested-by:
Acked-by:
Sponsored-by:
```

## Pull requests

Pull requests with patches, improvements, new features are a great help.
Please keep them clean from unwanted commits.

Follow the steps to get your work included in the project.

1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork,
and add the Worksheet-Module remote:

```bash
# Clone your fork of the repo into the current directory
git clone https://github.com/<your-username>/Worksheet-Module.git
# Navigate to the cloned directory
cd Worksheet-Module
# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/Samagra-Development/Worksheet-Module.git
```

2. Get the latest changes from upstream:

```bash
git checkout main
git pull upstream main
```

3. Create a new branch from the main branch to contain your changes.
Best way is to call is to follow the type described in **Git Commit Conventions**
stated above: `<githubId>/#<issueNr>/<description/scope/topic>`

```bash
git checkout -b <topic-branch-name>
```

Example:

```bash
git checkout -b john/138/buckets-undefined-index
```

Or

```bash
git checkout -b john/fix/138
```

4) It's coding time!
Please respect the coding convention: [Coding guidelines](https://github.com/Samagra-Development/Worksheet-Module/wiki)

Commit your changes in logical chunks. Please adhere to **Git Commit Conventions**
and [Coding guidelines](https://github.com/Samagra-Development/Worksheet-Module/wiki)
or your code is unlikely to be merged into the main project.
Use Git's [interactive rebase](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase)
feature to tidy up your commits before making them public.

5) Locally rebase the upstream main branch into your topic branch:

```bash
git pull --rebase upstream main
```

6) Push your topic branch up to your fork:

```bash
git push origin <topic-branch-name>
```

7) [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
with a clear title and description against the `main` branch.
8 changes: 8 additions & 0 deletions packages/attendance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Core Module
This modules containes common features used across Shiksha Apps e.g.

## Exposed Components
| Module | Description |
| ----------- | ----------- |
| AppShell | Application Shell with header ,footer and navigation |
| ... | ... |
12 changes: 12 additions & 0 deletions packages/attendance/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const cracoModuleFederation = require("craco-module-federation");

module.exports = {
devServer: {
port: 3002,
},
plugins: [
{
plugin: cracoModuleFederation,
},
],
};
6 changes: 6 additions & 0 deletions packages/attendance/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Loading

0 comments on commit 632eb77

Please sign in to comment.