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

NX implementation #56

Merged
merged 8 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
49 changes: 26 additions & 23 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,35 @@ name: Publish Next Version

on:
push:
branches: [ master ]
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x
registry-url: https://registry.npmjs.org/

- name: Install lib dependencies
run: cd lib && npm install

- name: Build library
run: cd lib && npm run build

- name: Publish NEXT version to npm
run: |
sed -i "s#\"version\": \"0.0.0\"#\"version\": \"0.0.0-${GITHUB_SHA:0:7}\"#" ./lib/package.json
cd lib
npm publish --tag next --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: npm install

- name: Build library
run: npx nx build halstack-react-hal

- name: Copy README
run: npx nx run copy

- name: Publish NEXT version to npm
run: |
sed -i "s#\"version\": \"0.0.0\"#\"version\": \"0.0.0-${GITHUB_SHA:0:7}\"#" ./lib/package.json
cd lib
npm publish --tag next --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
48 changes: 25 additions & 23 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,29 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x
registry-url: https://registry.npmjs.org/

- name: Install lib dependencies
run: cd lib && npm install

- name: Build library
run: cd lib && npm run build

- name: Publish RELEASE to npm
run: |
sed -i "s#\"version\": \"0.0.0\"#\"version\": \"${TAG_NAME}\"#" ./lib/package.json
cd lib
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
TAG_NAME: ${{ github.event.release.tag_name }}
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/

- name: Install lib dependencies
run: npm install

- name: Build library
run: npx nx build halstack-react-hal

- name: Copy README
run: npx nx run copy

- name: Publish RELEASE to npm
run: |
sed -i "s#\"version\": \"0.0.0\"#\"version\": \"${TAG_NAME}\"#" ./lib/package.json
cd lib
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
TAG_NAME: ${{ github.event.release.tag_name }}
11 changes: 7 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node.js 10.x
- name: Install Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 10.x
node-version: 16.x
registry-url: https://registry.npmjs.org/

- name: Install lib dependencies
run: cd lib && npm install
run: npm install

- name: Build library
run: cd lib && npm run build
run: npx nx build halstack-react-hal

- name: Copy README
run: npx nx run copy
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

# Next.js
.next
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
File renamed without changes.
32 changes: 10 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Halstack React HAL is an npm library of reusable React components. It brings tog

- Consuming HAL REST APIs implemented following the [DXC API Guidelines](https://developer.dxc.com/apis).

- Rendering these API resources as UI components that are compliant with the [DXC UX Guidelines](https://developer.dxc.com/halstack/6/).
- Rendering these API resources as UI components that are compliant with the [DXC UX Guidelines](https://developer.dxc.com/halstack/10/overview/introduction/).

We have other libraries that will help you handling these responsibilities individually ([Halstack Client](https://github.com/dxc-technology/halstack-client) / [Halstack React](https://github.com/dxc-technology/halstack-react)). Halstack React HAL uses them under the hood, but it is a higher level abstraction that puts both responsibilities together using the most common association patterns.

Expand Down Expand Up @@ -157,44 +157,32 @@ These instructions will get you a copy of the project up and running on your loc

The project is divided in two main folders. One is for the actual library, and the other one is a React application using the library.

### Library
### Project

Contained in the `lib` folder.
Install the dependencies for the library and the example project.

```bash
cd lib
npm install
```

Install the library dependencies.
### Library

```bash
npm install
```
Contained in the `lib` folder.

Run the build process into `dist` folder, detecting and automatically building changes in src.
Run the build process into `dist` folder.
Jialecl marked this conversation as resolved.
Show resolved Hide resolved

```bash
npm run build:watch # or 'npm run build' if there is no need to watch for changes
nx build halstack-react-hal
Jialecl marked this conversation as resolved.
Show resolved Hide resolved
```

### Example Application

Contained in the `app` folder.

```bash
cd app # from the root folder
```

Install the application dependencies. The Halstack React CDK dependency is linked to the local `lib` folder. This one must have been previously built.

```bash
npm install
```

Start the application.

```bash
npm start # runs create-react-app dev server
nx serve app
```

Now, anytime you make a change to the library or the app, `create-react-app` will live-reload your local dev server so you can iterate on your component in real-time.
Now, anytime you make a change to the library or the app, `nx` will live-reload your local dev server so you can iterate on your component in real-time.
19 changes: 19 additions & 0 deletions app/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": [
[
"styled-components",
{
"pure": true,
"ssr": true
}
]
]
}
18 changes: 18 additions & 0 deletions app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
23 changes: 0 additions & 23 deletions app/.gitignore

This file was deleted.

Loading
Loading