Skip to content

Commit

Permalink
feat: update to nx 16.8 and use the new next build format (#20)
Browse files Browse the repository at this point in the history
* chore: update to the latest nx

* chore: move to flat eslint

* fix: version of eslint js

* fix: eslint issues

* feat: modify the next builder to match the new strutucture at nx

* fix(linter): missing dependency

* fix: e2e test to adjust to the new as-provided workspace layout

* chore: configure workspace layout to the legacy derived
  • Loading branch information
nacho-vazquez authored Sep 10, 2023
1 parent 632c308 commit 207215a
Show file tree
Hide file tree
Showing 15 changed files with 551 additions and 453 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

49 changes: 0 additions & 49 deletions .eslintrc.json

This file was deleted.

34 changes: 0 additions & 34 deletions e2e/examples/cloudflare-next-app/.eslintrc.json

This file was deleted.

46 changes: 46 additions & 0 deletions e2e/examples/cloudflare-next-app/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { FlatCompat } = require('@eslint/eslintrc');
const baseConfig = require('../../../eslint.config.js');
const globals = require('globals');
const js = require('@eslint/js');
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});
module.exports = [
...baseConfig,
...compat.extends(
'plugin:@nx/react-typescript',
'next',
'next/core-web-vitals'
),
{ languageOptions: { globals: { ...globals.jest } } },
{
files: [
'e2e/examples/cloudflare-next-app/**/*.ts',
'e2e/examples/cloudflare-next-app/**/*.tsx',
'e2e/examples/cloudflare-next-app/**/*.js',
'e2e/examples/cloudflare-next-app/**/*.jsx',
],
rules: { '@next/next/no-html-link-for-pages': 'off' },
},
{
files: [
'e2e/examples/cloudflare-next-app/**/*.ts',
'e2e/examples/cloudflare-next-app/**/*.tsx',
],
rules: {},
},
{
files: [
'e2e/examples/cloudflare-next-app/**/*.js',
'e2e/examples/cloudflare-next-app/**/*.jsx',
],
rules: {},
},
{
ignores: [
'e2e/examples/cloudflare-next-app/.next/**/*',
'e2e/examples/cloudflare-next-app/.vercel/**/*',
],
},
];
18 changes: 0 additions & 18 deletions e2e/plugins-nx-cloudflare-e2e/.eslintrc.json

This file was deleted.

27 changes: 27 additions & 0 deletions e2e/plugins-nx-cloudflare-e2e/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const baseConfig = require('../../eslint.config.js');
module.exports = [
...baseConfig,
{
files: [
'e2e/plugins-nx-cloudflare-e2e/**/*.ts',
'e2e/plugins-nx-cloudflare-e2e/**/*.tsx',
'e2e/plugins-nx-cloudflare-e2e/**/*.js',
'e2e/plugins-nx-cloudflare-e2e/**/*.jsx',
],
rules: {},
},
{
files: [
'e2e/plugins-nx-cloudflare-e2e/**/*.ts',
'e2e/plugins-nx-cloudflare-e2e/**/*.tsx',
],
rules: {},
},
{
files: [
'e2e/plugins-nx-cloudflare-e2e/**/*.js',
'e2e/plugins-nx-cloudflare-e2e/**/*.jsx',
],
rules: {},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Cloudflare Worker Applications', () => {
const workerapp = uniq('workerapp');

runNxCommand(
`generate @naxodev/nx-cloudflare:app ${workerapp} --template="none"`
`generate @naxodev/nx-cloudflare:app ${workerapp} --directory="apps" --template="none"`
);

expect(
Expand All @@ -39,7 +39,7 @@ describe('Cloudflare Worker Applications', () => {
const port = 8787;

runNxCommand(
`generate @naxodev/nx-cloudflare:app ${workerapp} --template="fetch-handler"`
`generate @naxodev/nx-cloudflare:app ${workerapp} --directory="apps" --template="fetch-handler"`
);

const lintResults = runNxCommand(`lint ${workerapp}`);
Expand All @@ -66,7 +66,7 @@ describe('Cloudflare Worker Applications', () => {
const port = 8787;

runNxCommand(
`generate @naxodev/nx-cloudflare:app ${workerapp} --template="scheduled-handler"`
`generate @naxodev/nx-cloudflare:app ${workerapp} --directory="apps" --template="scheduled-handler"`
);

const lintResults = runNxCommand(`lint ${workerapp}`);
Expand All @@ -93,7 +93,7 @@ describe('Cloudflare Worker Applications', () => {
const port = 8787;

runNxCommand(
`generate @naxodev/nx-cloudflare:app ${workerapp} --template="hono"`
`generate @naxodev/nx-cloudflare:app ${workerapp} --directory="apps" --template="hono"`
);

const lintResults = runNxCommand(`lint ${workerapp}`);
Expand Down
50 changes: 50 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { FlatCompat } = require('@eslint/eslintrc');
const nxEslintPlugin = require('@nx/eslint-plugin');
const js = require('@eslint/js');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});
module.exports = [
{ plugins: { '@nx': nxEslintPlugin } },
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: [],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
},
},
...compat.config({ extends: ['plugin:@nx/typescript'] }).map((config) => ({
...config,
files: ['**/*.ts', '**/*.tsx'],
rules: {},
})),
...compat.config({ extends: ['plugin:@nx/javascript'] }).map((config) => ({
...config,
files: ['**/*.js', '**/*.jsx'],
rules: {},
})),
...compat.config({ env: { jest: true } }).map((config) => ({
...config,
files: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.spec.js', '**/*.spec.jsx'],
rules: {},
})),
...compat.config({ parser: 'jsonc-eslint-parser' }).map((config) => ({
...config,
files: ['**/*.json'],
rules: { '@nx/dependency-checks': 'error' },
})),
{ ignores: ['.next', '.vercel'] },
];
7 changes: 5 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore"
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/eslint.config.js"
]
},
"test": {
Expand All @@ -33,11 +34,13 @@
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s"
"!{projectRoot}/src/test-setup.[jt]s",
"!{projectRoot}/eslint.config.js"
],
"sharedGlobals": []
},
"workspaceLayout": {
"projectNameAndRootFormat": "derived",
"appsDir": "e2e",
"libsDir": "packages"
},
Expand Down
31 changes: 17 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
"@cloudflare/next-on-pages": "^1.6.0",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@eslint/eslintrc": "^2.1.2",
"@eslint/js": "^8.48.0",
"@jscutlery/semver": "^3.1.0",
"@nx/angular": "16.7.4",
"@nx/devkit": "16.7.4",
"@nx/eslint-plugin": "16.7.4",
"@nx/jest": "16.7.4",
"@nx/js": "16.7.4",
"@nx/linter": "16.7.4",
"@nx/next": "16.7.4",
"@nx/node": "16.7.4",
"@nx/plugin": "16.7.4",
"@nx/react": "16.7.4",
"@nx/vite": "16.7.4",
"@nx/web": "16.7.4",
"@nx/workspace": "16.7.4",
"@nx/angular": "16.8.0",
"@nx/devkit": "16.8.0",
"@nx/eslint-plugin": "16.8.0",
"@nx/jest": "16.8.0",
"@nx/js": "16.8.0",
"@nx/linter": "16.8.0",
"@nx/next": "16.8.0",
"@nx/node": "16.8.0",
"@nx/plugin": "16.8.0",
"@nx/react": "16.8.0",
"@nx/vite": "16.8.0",
"@nx/web": "16.8.0",
"@nx/workspace": "16.8.0",
"@svgr/webpack": "^8.1.0",
"@swc-node/register": "~1.4.2",
"@swc/cli": "~0.1.62",
Expand Down Expand Up @@ -51,13 +53,14 @@
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"fs-extra": "^11.1.1",
"globals": "^13.21.0",
"husky": "^8.0.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"kill-port": "^2.0.1",
"next": "^13.4.19",
"ngx-deploy-npm": "^6.0.0",
"nx": "16.7.4",
"nx": "16.8.0",
"nx-cloud": "16.3.0",
"prettier": "^2.6.2",
"sass": "1.62.1",
Expand Down
25 changes: 0 additions & 25 deletions packages/plugins/nx-cloudflare/.eslintrc.json

This file was deleted.

Loading

0 comments on commit 207215a

Please sign in to comment.