Skip to content

Commit

Permalink
Nx and webcomponents experiment.
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre committed Nov 23, 2021
1 parent 83a0cdc commit 01d3b09
Show file tree
Hide file tree
Showing 128 changed files with 59,599 additions and 72,501 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
35 changes: 35 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
}
]
}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
webcomponents/**/dist
/tmp
/out-tsc

Expand All @@ -16,15 +16,13 @@ webcomponents/**/dist
*.launch
.settings/
*.sublime-workspace
*.iml

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting

/dist
/coverage
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
}
80 changes: 38 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,64 @@
# DataHub
# Catalogue

Is built on top of:
This project was generated using [Nx](https://nx.dev).

- https://docs.appbase.io/docs/reactivesearch/v3/overview/components/
- https://react.semantic-ui.com/
## Adding capabilities to your workspace

```
npx create-react-app datahub --template typescript --use-npm
npm start
npm run build
npm install @appbaseio/reactivesearch
npm install semantic-ui-react semantic-ui-css
npx prettier --write .
```
Nx supports many plugins which add capabilities for developing different types of applications and different tools.

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Generate an application

## Available Scripts
Run `nx g @nrwl/react:app webcomponents` to generate an application.

In the project directory, you can run:
## Generate a library

### `npm start`
Run `nx g @nrwl/react:lib ui/search` to generate a library.

Runs the app in the development mode (the GeoNetwork API is used to communicate with ElasticSearch.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
> You can also use any of the plugins above to generate libraries as well.
The page will reload if you make edits.\
You will also see any lint errors in the console.
Libraries are shareable across libraries and applications. They can be imported from `@catalogue/mylib`.

### `npm run start-es`
## Development server

Runs the app in the development mode with direct connection to Elasticsearch.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
Run `nx serve catalogue` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

The page will reload if you make edits.\
You will also see any lint errors in the console.
## Code scaffolding

### `npm test`
Run `nx g @nrwl/react:component my-component --project=my-app` to generate a new component.

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
## Build

### `npm run build`
Run `nx build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
## Running unit tests

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
Run `nx test my-app` to execute the unit tests via [Jest](https://jestjs.io).

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
Run `nx affected:test` to execute the unit tests affected by a change.

### `npm run eject`
## Running end-to-end tests

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Run `nx affected:e2e` to execute the end-to-end tests affected by a change.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
## Understand your workspace

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
Run `nx dep-graph` to see a diagram of the dependencies of your projects.

## Learn More
## Further help

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
Visit the [Nx Documentation](https://nx.dev) to learn more.

To learn React, check out the [React documentation](https://reactjs.org/).
## ☁ Nx Cloud

### Distributed Computation Caching & Distributed Task Execution

<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-cloud-card.png"></p>

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 are new to Nx can connect to Nx Cloud and start saving time instantly.

Teams using Nx gain the advantage of building full-stack applications with their preferred framework alongside Nx’s advanced code generation and project dependency graph, plus a unified experience for both frontend and backend developers.

Visit [Nx Cloud](https://nx.app/) to learn more.
Empty file added apps/.gitkeep
Empty file.
17 changes: 17 additions & 0 deletions apps/catalogue-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["src/plugins/index.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off"
}
}
]
}
12 changes: 12 additions & 0 deletions apps/catalogue-e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"supportFile": "./src/support/index.ts",
"pluginsFile": false,
"video": true,
"videosFolder": "../../dist/cypress/apps/catalogue-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/catalogue-e2e/screenshots",
"chromeWebSecurity": false
}
28 changes: 28 additions & 0 deletions apps/catalogue-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"root": "apps/catalogue-e2e",
"sourceRoot": "apps/catalogue-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/catalogue-e2e/cypress.json",
"devServerTarget": "catalogue:serve"
},
"configurations": {
"production": {
"devServerTarget": "catalogue:serve:production"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/catalogue-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["catalogue"]
}
4 changes: 4 additions & 0 deletions apps/catalogue-e2e/src/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]"
}
13 changes: 13 additions & 0 deletions apps/catalogue-e2e/src/integration/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getGreeting } from '../support/app.po';

describe('catalogue', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('[email protected]', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome to catalogue!');
});
});
1 change: 1 addition & 0 deletions apps/catalogue-e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get('h1');
33 changes: 33 additions & 0 deletions apps/catalogue-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
17 changes: 17 additions & 0 deletions apps/catalogue-e2e/src/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';
10 changes: 10 additions & 0 deletions apps/catalogue-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js"]
}
11 changes: 11 additions & 0 deletions apps/catalogue/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
16 changes: 16 additions & 0 deletions apps/catalogue/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is used by:
# 1. autoprefixer to adjust CSS to support the below specified browsers
# 2. babel preset-env to adjust included polyfills
#
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# If you need to support different browsers in production, you may tweak the list below.

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 iOS major versions
Firefox ESR
not IE 9-11 # For IE 9-11 support, remove 'not'.
18 changes: 18 additions & 0 deletions apps/catalogue/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
Loading

0 comments on commit 01d3b09

Please sign in to comment.