Skip to content

Commit

Permalink
Merge pull request #56 from dxc-technology/jialecl-nx
Browse files Browse the repository at this point in the history
NX implementation
  • Loading branch information
kukoc authored Nov 8, 2023
2 parents 10ce6b8 + e5887d7 commit 1f7ded7
Show file tree
Hide file tree
Showing 57 changed files with 45,350 additions and 44,751 deletions.
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 updating the bundled files inside the dist folder.

```bash
npm run build:watch # or 'npm run build' if there is no need to watch for changes
nx build halstack-react-hal #`npx nx build halstack-react-hal` if nx is not recognized as a command.
```

### 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 #`npx nx serve app` if nx is not recognized as a command.
```

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

0 comments on commit 1f7ded7

Please sign in to comment.