Skip to content

Commit

Permalink
Merge pull request #14 from getlarge/chore-update-nx
Browse files Browse the repository at this point in the history
chore: update nx
  • Loading branch information
getlarge authored Mar 12, 2024
2 parents 3fc5c89 + 01e2fe3 commit 17b42a4
Show file tree
Hide file tree
Showing 49 changed files with 7,690 additions and 14,510 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nx 18 enables using plugins to infer targets by default
# This is disabled for existing workspaces to maintain compatibility
# For more info, see: https://nx.dev/concepts/inferred-tasks
NX_ADD_PLUGINS=false
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
Expand All @@ -23,7 +23,7 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nx/typescript"],
"plugins": ["unused-imports", "import", "simple-import-sort"],
"rules": {
"eqeqeq": ["error", "always", { "null": "never" }],
Expand Down Expand Up @@ -63,7 +63,7 @@
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ runs:
using: composite
steps:
- name: Checkout all commits
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ inputs.github-token || github.token }}
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: https://registry.npmjs.org
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
node-version: [16, 18]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0

- name: Derive appropriate SHAs for base and head for `nx affected` commands
id: set-shas
uses: nrwl/nx-set-shas@v3
uses: nrwl/nx-set-shas@v4
with:
last-successful-event: release

Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
needs: [test]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ jobs:

strategy:
matrix:
node-version: [16, 18]
node-version: [18, 20]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0

- name: Derive appropriate SHAs for base and head for `nx affected` commands
id: set-shas
uses: nrwl/nx-set-shas@v3
uses: nrwl/nx-set-shas@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -61,7 +61,7 @@ jobs:

- name: Check tests coverage reports existence
id: has-coverage
uses: andstor/file-existence-action@v2
uses: andstor/file-existence-action@v3
with:
files: coverage

Expand All @@ -72,10 +72,10 @@ jobs:
# should be uploaded only once theoretically...
- name: Upload merged coverage reports
if: steps.has-coverage.outputs.files_exists == 'true'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage
name: coverage-${{ matrix.node-version }}
retention-days: 5

outputs:
Expand All @@ -88,7 +88,7 @@ jobs:

# TODO: move in separate workflow
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Shallow clones should be disabled for a better relevancy of Sonar analysis
fetch-depth: 0
Expand All @@ -102,9 +102,9 @@ jobs:

- name: Download merged coverage reports
if: needs.test.outputs.has-coverage == 'true'
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage
name: coverage-20
path: coverage

- name: SonarCloud Scan
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ testem.log
# System Files
.DS_Store
Thumbs.db

.nx/cache
.env
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

/dist
/coverage

/.nx/cache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ The `heroku-postbuild` script is used to build the application, it is executed a
`tools/heroku/postbuild.js`

```js
const { createPackageJson, createLockFile } = require('@nrwl/devkit');
const { createPackageJson, createLockFile } = require('@nx/devkit');
const { execSync } = require('child_process');
const { writeFileSync } = require('fs');

Expand Down
13 changes: 7 additions & 6 deletions e2e/nx-heroku-e2e/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
export default {
displayName: 'nx-heroku-e2e',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
globals: {},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
collectCoverageFrom: ['./src/**/*.(t|j)s'],
Expand Down
13 changes: 7 additions & 6 deletions e2e/nx-heroku-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
"sourceRoot": "e2e/nx-heroku-e2e/src",
"targets": {
"e2e": {
"executor": "@nrwl/nx-plugin:e2e",
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"target": "nx-heroku:build",
"jestConfig": "e2e/nx-heroku-e2e/jest.config.ts",
"coverageDirectory": "coverage/e2e/nx-heroku-e2e"
"coverageDirectory": "coverage/e2e/nx-heroku-e2e",
"runInBand": true,
"passWithNoTests": false
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
"runInBand": true
}
}
},
"dependsOn": ["nx-heroku:build"]
}
},
"tags": [],
Expand Down
2 changes: 1 addition & 1 deletion e2e/nx-heroku-e2e/tests/nx-heroku.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runNxCommandAsync } from '@nrwl/nx-plugin/testing';
import { runNxCommandAsync } from '@nx/plugin/testing';
import {
createProject,
prepareProjectForDeployment,
Expand Down
7 changes: 4 additions & 3 deletions e2e/nx-heroku-e2e/tests/postbuild.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { execSync } = require('child_process');
const projectName = process.argv[2] || process.env.PROJECT_NAME;
const projectEnv = 'production';
console.log(`Heroku custom postbuild hook, skip build goes faster`);
execSync(`npx nx build ${projectName} --c ${projectEnv}`, { stdio: 'inherit' });
console.log(
`Heroku custom postbuild hook for ${projectName}:${projectEnv} skip build goes faster`
);
// execSync(`npx nx build ${projectName} --c ${projectEnv}`, { stdio: 'inherit' });
18 changes: 14 additions & 4 deletions e2e/nx-heroku-e2e/tests/tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ProjectConfiguration, serializeJson } from '@nrwl/devkit';
import {
NxJsonConfiguration,
ProjectConfiguration,
serializeJson,
} from '@nx/devkit';
import {
cleanup,
ensureNxProject,
Expand All @@ -8,7 +12,7 @@ import {
tmpProjPath,
uniq,
updateFile,
} from '@nrwl/nx-plugin/testing';
} from '@nx/plugin/testing';
import { execSync as oGExecSync } from 'node:child_process';
import { copyFileSync } from 'node:fs';
import { join } from 'node:path';
Expand Down Expand Up @@ -61,6 +65,10 @@ export function commitTmpProjectFiles() {
// are not dependant on one another.
export function setup() {
ensureNxProject(PLUGIN_NAME, PLUGIN_PATH);
const nxJsonPath = 'nx.json';
const nxJson: NxJsonConfiguration = readJson(nxJsonPath);
nxJson.workspaceLayout = { appsDir: 'apps', libsDir: 'libs' };
updateFile(nxJsonPath, serializeJson(nxJson));
copyScript('postbuild');
initGit();
commitTmpProjectFiles();
Expand Down Expand Up @@ -112,8 +120,10 @@ export async function createProject(prefix: string = 'nx-heroku'): Promise<{
updateProjectConfig: (config: ProjectConfiguration) => void;
}> {
const projectName = uniq(prefix);
await runNxCommandAsync(`generate @nrwl/node:app ${projectName}`);
const projectConfigPath = `apps/${projectName}/project.json`;
await runNxCommandAsync(
`generate @nx/node:app ${projectName} --directory=apps`
);
const projectConfigPath = join('apps', projectName, 'project.json');
return {
projectName,
getProjectConfig: () => readJson(projectConfigPath),
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getJestProjects } from '@nrwl/jest';
import { getJestProjects } from '@nx/jest';

export default {
projects: getJestProjects(),
Expand Down
6 changes: 4 additions & 2 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const nxPreset = require('@nrwl/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
module.exports = {
...nxPreset,
};
Loading

0 comments on commit 17b42a4

Please sign in to comment.