Skip to content

Commit 6c167f3

Browse files
Tiffany Le-Nguyenkodiakhq[bot]
Tiffany Le-Nguyen
andauthored
chore: add nx demo (#854)
* chore: add nx * chore: cleanup * chore: prettier ignore demo thanks * chore: config netlify toml * chore: fix path to lib * chore: fix package.json preinstall path * chore: fix test * chore: fix test * chore: ignore all dists * chore: ignore all dists again Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent f3340b8 commit 6c167f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+35289
-6
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.next
22
node_modules
33
test
4-
lib
4+
lib
5+
demos

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bower_components
4040
build/Release
4141

4242
# Dependency directories
43-
node_modules/
43+
**/node_modules/
4444
jspm_packages/
4545

4646
# TypeScript v1 declaration files
@@ -84,7 +84,8 @@ typings/
8484

8585
# Nuxt.js build / generate output
8686
.nuxt
87-
dist
87+
**/dist
88+
**/.dist
8889

8990
# Gatsby files
9091
.cache/

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ node_modules
1717

1818
# Test
1919
lib
20-
tsconfig.json
20+
tsconfig.json
21+
demos

cypress/config/ci.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"baseUrl": "http://localhost:3000",
3-
"integrationFolder": "../../cypress/integration",
3+
"integrationFolder": "../../cypress/integration/default",
44
"pluginsFile": "../../cypress/plugins",
55
"screenshotsFolder": "../../cypress/screenshots",
66
"supportFile": "../../cypress/support/index.js",

cypress/config/nx-demo.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"baseUrl": "http://localhost:4200",
3+
"integrationFolder": "../../cypress/integration/nx",
4+
"pluginsFile": "../../cypress/plugins",
5+
"screenshotsFolder": "../../cypress/screenshots",
6+
"supportFile": "../../cypress/support/index.js",
7+
"videoFolder": "../../cypress/videos"
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
describe('Default site', () => {
2+
beforeEach(() => {
3+
cy.visit('/')
4+
})
5+
6+
it('loads home page', () => {
7+
cy.findByRole('heading', { name: 'Welcome to nx-nextjs-monorepo!' })
8+
9+
cy.visit('//')
10+
cy.url().should('eq', `${Cypress.config().baseUrl}/`)
11+
})
12+
})

demos/default/local-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"preinstall": "cd ../.. && npm i"
7+
"preinstall": "cd ../../.. && npm i"
88
},
99
"author": "",
1010
"license": "ISC"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nrwl/nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nrwl/nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nrwl/nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nrwl/nx/javascript"],
32+
"rules": {}
33+
}
34+
]
35+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add files here to ignore them from prettier formatting
2+
3+
/dist
4+
/coverage
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

demos/nx-next-monorepo-demo/README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# NxNextjsMonorepo
2+
3+
This project was generated using [Nx](https://nx.dev). It is a demo site to test that Nx monorepos work properly with the Netlify Essential NextJS plugin.
4+
5+
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p>
6+
7+
🔎 **Smart, Extensible Build Framework**
8+
9+
## Adding capabilities to your workspace
10+
11+
Nx supports many plugins which add capabilities for developing different types of applications and different tools.
12+
13+
These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects
14+
as well.
15+
16+
Below are our core plugins:
17+
18+
- [React](https://reactjs.org)
19+
- `npm install --save-dev @nrwl/react`
20+
- Web (no framework frontends)
21+
- `npm install --save-dev @nrwl/web`
22+
- [Angular](https://angular.io)
23+
- `npm install --save-dev @nrwl/angular`
24+
- [Nest](https://nestjs.com)
25+
- `npm install --save-dev @nrwl/nest`
26+
- [Express](https://expressjs.com)
27+
- `npm install --save-dev @nrwl/express`
28+
- [Node](https://nodejs.org)
29+
- `npm install --save-dev @nrwl/node`
30+
31+
There are also many [community plugins](https://nx.dev/community) you could add.
32+
33+
## Generate an application
34+
35+
Run `nx g @nrwl/react:app my-app` to generate an application.
36+
37+
> You can use any of the plugins above to generate applications as well.
38+
39+
When using Nx, you can create multiple applications and libraries in the same workspace.
40+
41+
## Generate a library
42+
43+
Run `nx g @nrwl/react:lib my-lib` to generate a library.
44+
45+
> You can also use any of the plugins above to generate libraries as well.
46+
47+
Libraries are shareable across libraries and applications. They can be imported from `@nx-nextjs-monorepo/mylib`.
48+
49+
## Development server
50+
51+
Run `nx serve my-app` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you
52+
change any of the source files.
53+
54+
## Code scaffolding
55+
56+
Run `nx g @nrwl/react:component my-component --project=my-app` to generate a new component.
57+
58+
## Build
59+
60+
Run `nx build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the
61+
`--prod` flag for a production build.
62+
63+
## Running unit tests
64+
65+
Run `nx test my-app` to execute the unit tests via [Jest](https://jestjs.io).
66+
67+
Run `nx affected:test` to execute the unit tests affected by a change.
68+
69+
## Running end-to-end tests
70+
71+
Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).
72+
73+
Run `nx affected:e2e` to execute the end-to-end tests affected by a change.
74+
75+
## Understand your workspace
76+
77+
Run `nx dep-graph` to see a diagram of the dependencies of your projects.
78+
79+
## Further help
80+
81+
Visit the [Nx Documentation](https://nx.dev) to learn more.
82+
83+
## ☁ Nx Cloud
84+
85+
### Distributed Computation Caching & Distributed Task Execution
86+
87+
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-cloud-card.png"></p>
88+
89+
Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that
90+
are new to Nx can connect to Nx Cloud and start saving time instantly.
91+
92+
Teams using Nx gain the advantage of building full-stack applications with their preferred framework alongside Nx’s
93+
advanced code generation and project dependency graph, plus a unified experience for both frontend and backend
94+
developers.
95+
96+
Visit [Nx Cloud](https://nx.app/) to learn more.

demos/nx-next-monorepo-demo/apps/.gitkeep

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
}
9+
]
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"fileServerFolder": ".",
3+
"fixturesFolder": "./src/fixtures",
4+
"integrationFolder": "./src/integration",
5+
"modifyObstructiveCode": false,
6+
"supportFile": "./src/support/index.ts",
7+
"pluginsFile": false,
8+
"video": true,
9+
"videosFolder": "../../dist/cypress/apps/demo-monorepo-e2e/videos",
10+
"screenshotsFolder": "../../dist/cypress/apps/demo-monorepo-e2e/screenshots",
11+
"chromeWebSecurity": false
12+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"root": "apps/demo-monorepo-e2e",
3+
"sourceRoot": "apps/demo-monorepo-e2e/src",
4+
"projectType": "application",
5+
"targets": {
6+
"e2e": {
7+
"executor": "@nrwl/cypress:cypress",
8+
"options": {
9+
"cypressConfig": "apps/demo-monorepo-e2e/cypress.json",
10+
"devServerTarget": "demo-monorepo:serve"
11+
},
12+
"configurations": {
13+
"production": {
14+
"devServerTarget": "demo-monorepo:serve:production"
15+
}
16+
}
17+
},
18+
"lint": {
19+
"executor": "@nrwl/linter:eslint",
20+
"outputs": ["{options.outputFile}"],
21+
"options": {
22+
"lintFilePatterns": ["apps/demo-monorepo-e2e/**/*.{js,ts}"]
23+
}
24+
}
25+
},
26+
"tags": [],
27+
"implicitDependencies": ["demo-monorepo"]
28+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io"
4+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { getGreeting } from '../support/app.po';
2+
3+
describe('demo-monorepo', () => {
4+
beforeEach(() => cy.visit('/'));
5+
6+
it('should display welcome message', () => {
7+
// Custom command example, see `../support/commands.ts` file
8+
cy.login('my-email@something.com', 'myPassword');
9+
10+
// Function helper example, see `../support/app.po.ts` file
11+
getGreeting().contains('Welcome to demo-monorepo!');
12+
});
13+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const getGreeting = () => cy.get('h1');
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
11+
// eslint-disable-next-line @typescript-eslint/no-namespace
12+
declare namespace Cypress {
13+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
14+
interface Chainable<Subject> {
15+
login(email: string, password: string): void;
16+
}
17+
}
18+
//
19+
// -- This is a parent command --
20+
Cypress.Commands.add('login', (email, password) => {
21+
console.log('Custom command example: Login', email, password);
22+
});
23+
//
24+
// -- This is a child command --
25+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
26+
//
27+
//
28+
// -- This is a dual command --
29+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
30+
//
31+
//
32+
// -- This will overwrite an existing command --
33+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"sourceMap": false,
5+
"outDir": "../../dist/out-tsc",
6+
"allowJs": true,
7+
"types": ["cypress", "node"]
8+
},
9+
"include": ["src/**/*.ts", "src/**/*.js"]
10+
}

0 commit comments

Comments
 (0)