Skip to content

Commit

Permalink
Merge pull request #1405 from aligent/chore/DO-1587-migrate-to-yarn
Browse files Browse the repository at this point in the history
Chore/do 1587 migrate to yarn
  • Loading branch information
TheOrangePuff authored Nov 29, 2024
2 parents 98bf732 + d435d0f commit 0e3437c
Show file tree
Hide file tree
Showing 100 changed files with 11,451 additions and 10,273 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

95 changes: 74 additions & 21 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,77 @@
{
"env": {
"node": true,
"commonjs": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": ["@typescript-eslint", "prettier"],
"rules": {
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"overrides": [
{
"files": "*.json",
"parser": "jsonc-eslint-parser",
"rules": {}
},
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"parserOptions": {
"project": ["./tsconfig.base.json"]
},
"extends": [
"plugin:@nx/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description"
}
],
"no-return-await": "off",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
"@nx/enforce-module-boundaries": [
"error",
{
"allow": ["@aligent/cdk-esbuild"]
}
]
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
35 changes: 24 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@ on: [pull_request]

jobs:
build:
name: 🏭 Build all packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }}
- name: Use Node.js 20
uses: actions/setup-node@v1
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run lint:check && npm run format:check
- run: npm run build
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch target
run: git fetch origin ${{ github.event.pull_request.base.ref }}

- name: Enable Corepack
run: corepack enable

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"

- name: Install
run: yarn install

- name: Build all packages
run: yarn nx run-many -t build

- run: yarn nx affected:lint --base=origin/${{ github.event.pull_request.base.ref }} --parallel --max-parallel=3
66 changes: 32 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,41 @@ name: Publish to NPM

on:
release:
tags:
- '**-[0-9]+.[0-9]+.[0-9]+'
- '**-[0-9]+.[0-9]+.[0-9]+-*'
tags:
- "**-[0-9]+.[0-9]+.[0-9]+"
- "**-[0-9]+.[0-9]+.[0-9]+-*"
types: [published]

jobs:
build-and-publish:
name: 🚀 Publish to NPM
runs-on: ubuntu-latest
steps:
# Source checkout
- uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }}
# Setting Node environment
- name: Setting up Node environment
uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/
# Environment configuration
- name: Preparing environment for release
run: |
VERSION=$(echo $GITHUB_REF_NAME | sed 's/^.*[A-Za-z]-//g')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PACKAGE=$(echo $GITHUB_REF_NAME | sed "s/-${VERSION}//g")" >> $GITHUB_ENV
# Release process
- name: Release
run: |
npm ci
git config --global user.name "Automated NPM Release"
git config --global user.email "[email protected]"
npm version $VERSION --allow-same-version --workspace "@aligent/cdk-${{env.PACKAGE}}"
npm run build --workspace "@aligent/cdk-${{env.PACKAGE}}"
npm test --workspace "@aligent/cdk-${{env.PACKAGE}}" --if-present
npm publish --access public --workspace "@aligent/cdk-${{env.PACKAGE}}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git push
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
registry-url: https://registry.npmjs.org/

- name: Install
run: yarn install

- name: Preparing environment for release
run: |
VERSION=$(echo $GITHUB_REF_NAME | sed 's/^.*[A-Za-z]-//g')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PACKAGE=$(echo $GITHUB_REF_NAME | sed "s/-${VERSION}//g")" >> $GITHUB_ENV
- name: Release
run: |
git config --global user.name "Automated NPM Release"
git config --global user.email "[email protected]"
echo "Publishing $PACKAGE @ $VERSION"
yarn config set registry https://registry.npmjs.org/
yarn nx publish $PACKAGE --ver=$VERSION --tag=latest --verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
node_modules/
dist/

# Yarn (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Compiled Java class files
*.class

Expand Down Expand Up @@ -60,3 +69,9 @@ cdk.out

*.d.ts
*.js



.nx/cache
.nx/workspace-data
!jest.preset.js
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ cdk.out
*.js

# Lock files
package-lock.json
package-lock.json

# Ignore nx files
.nx
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"semi": true,
"singleQuote": false,
"arrowParens": "avoid"
"arrowParens": "avoid",
"trailingComma": "es5"
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
14 changes: 14 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getJestProjects } from "@nx/jest";

export default {
projects: getJestProjects(),
modulePathIgnorePatterns: ["__data__"],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
};
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
26 changes: 26 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {
"build": {
"cache": true
},
"test": {
"cache": true
}
},
"defaultBase": "main",
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
{
"plugin": "@nx/jest/plugin",
"options": {
"targetName": "test"
}
}
]
}
Loading

0 comments on commit 0e3437c

Please sign in to comment.