Skip to content

Commit

Permalink
chore: re-scaffold the project
Browse files Browse the repository at this point in the history
  • Loading branch information
bennymeg committed Nov 22, 2021
1 parent b1587cd commit 4489612
Show file tree
Hide file tree
Showing 99 changed files with 15,149 additions and 12,292 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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc

This file was deleted.

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": {}
}
]
}
43 changes: 41 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
node_modules
build
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/build
/dist
/tmp
/out-tsc

# dependencies
/node_modules
/packages/*/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

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

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
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",
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner"
]
}
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Electron builders and schematics for Nrwl Nx platform.

[![licence](https://img.shields.io/github/license/bennymeg/nx-electron.svg)](https://github.com/bennymeg/nx-electron/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/nx-electron.svg)](https://www.npmjs.com/package/nx-electron)
[![Dependencies status](https://david-dm.org/bennymeg/nx-electron/status.svg)](https://david-dm.org/bennymeg/nx-electron)
<!-- [![Dependencies status](https://david-dm.org/bennymeg/nx-electron/status.svg)](https://david-dm.org/bennymeg/nx-electron) -->
![Downloads](https://img.shields.io/npm/dt/nx-electron)
[![star this repo](https://img.shields.io/github/stars/bennymeg/nx-electron?style=social)](https://github.com/bennymeg/nx-electron)

Expand Down Expand Up @@ -60,20 +60,11 @@ nx g nx-electron:app <electron-app-name> --frontendProject=<frontend-app-name>

## Building Nx Electron Application

- Run `nx run-many --target=build --projects=<frontend-app-name>,<electron-app-name> --parallel` to build your application.

**NOTE:** To build your application in production mode use the `--prod` option.

**NOTE:** On some frameworks you might need to use the `--baseHref="./"` option to configure your application routing correctly. This might require you to build your frontend and backend applications separately.
- Run `nx build <electron-app-name>` to build your application.

## Serving Nx Electron Application

- Run `nx run-many --target=serve --projects=<frontend-app-name>,<electron-app-name> --parallel` to serve your application.

In case you see a blank application, that happens due to that the electron app was served before the frontend was served. In that case, there are couple of possible solutions:
1. Refresh you application when it has been served (i.e. with [electron-debug](https://github.com/sindresorhus/electron-debug)).
2. Manually serve the backend and frontend with to separate commands (e.g. serve the backend only after the frontend was served).
3. Automatically serve the backend after the frontend was served (i.e. this [script](https://github.com/bennymeg/nx-electron/issues/103)).
- Run `nx serve <electron-app-name>` to serve your application.

## Packaging Nx Electron Application

Expand All @@ -82,34 +73,29 @@ In case you see a blank application, that happens due to that the electron app w

The options that can be passed are described [here](https://github.com/bennymeg/nx-electron/blob/master/src/builders/package/schema.json).

**NOTE**: You have to build your application before invoking this command.

## Making Nx Electron Application

- Run `nx run <electron-app-name>:make [--options]` to make your application.

The options that can be passed are described [here](https://github.com/bennymeg/nx-electron/blob/master/src/builders/package/schema.json).

**NOTE**: You have to build your application before invoking this command.

## Configuring static packaging / making options

It is possible to configure all the packaging / making [options](https://www.electron.build/configuration/configuration) in _`.\apps\<electron-app-name>\src\app\options\maker.options.json`_. For more information [read this article](https://github.com/bennymeg/nx-electron/blob/master/docs/packaging.md).
**Notice:** the option you define at this file will override the options you pass manually via the command line or choose via the angular console.

## Migrating Nx Electron Application

To migrate automatically run `ng update nx-electron@<version>`.
To migrate automaticlly run `ng update nx-electron@<version>`.
You can find detailed information in the following articles:

- [v8.0.0](https://github.com/bennymeg/nx-electron/blob/master/docs/migration/migrating.v8.md)
- [v9.0.0](https://github.com/bennymeg/nx-electron/blob/master/docs/migration/migrating.v9.md)
- [v10.0.0](https://github.com/bennymeg/nx-electron/blob/master/docs/migration/migrating.v10.md)
- [v11.0.0](https://github.com/bennymeg/nx-electron/blob/master/docs/migration/migrating.v11.md)

## Testing Nx Electron Application

- Run `nx run-many --target=test --projects=<frontend-app-name>,<electron-app-name> --parallel` to test your application.
- Run `nx test <electron-app-name>` to test your application.

## Debugging Nx Electron Application

Expand Down
25 changes: 0 additions & 25 deletions builders.json

This file was deleted.

20 changes: 0 additions & 20 deletions collection.json

This file was deleted.

3 changes: 0 additions & 3 deletions docs/migration/migrating.v11.md

This file was deleted.

14 changes: 14 additions & 0 deletions e2e/nx-electron-e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
displayName: 'nx-electron-e2e',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/e2e\nx-electron-e2e',
};
16 changes: 16 additions & 0 deletions e2e/nx-electron-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"root": "e2e\\nx-electron-e2e",
"projectType": "application",
"sourceRoot": "e2e\\nx-electron-e2e/src",
"targets": {
"e2e": {
"executor": "@nrwl/nx-plugin:e2e",
"options": {
"target": "nx-electron:build",
"jestConfig": "e2e/nx-electron-e2e/jest.config.js"
}
}
},
"tags": [],
"implicitDependencies": ["nx-electron"]
}
44 changes: 44 additions & 0 deletions e2e/nx-electron-e2e/tests/nx-electron.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {
checkFilesExist,
ensureNxProject,
readJson,
runNxCommandAsync,
uniq,
} from '@nrwl/nx-plugin/testing';
describe('nx-electron e2e', () => {
it('should create nx-electron', async () => {
const plugin = uniq('nx-electron');
ensureNxProject('@nx-electron/nx-electron', 'dist/packages/nx-electron');
await runNxCommandAsync(
`generate @nx-electron/nx-electron:nx-electron ${plugin}`
);

const result = await runNxCommandAsync(`build ${plugin}`);
expect(result.stdout).toContain('Executor ran');
}, 120000);

describe('--directory', () => {
it('should create src in the specified directory', async () => {
const plugin = uniq('nx-electron');
ensureNxProject('@nx-electron/nx-electron', 'dist/packages/nx-electron');
await runNxCommandAsync(
`generate @nx-electron/nx-electron:nx-electron ${plugin} --directory subdir`
);
expect(() =>
checkFilesExist(`libs/subdir/${plugin}/src/index.ts`)
).not.toThrow();
}, 120000);
});

describe('--tags', () => {
it('should add tags to the project', async () => {
const plugin = uniq('nx-electron');
ensureNxProject('@nx-electron/nx-electron', 'dist/packages/nx-electron');
await runNxCommandAsync(
`generate @nx-electron/nx-electron:nx-electron ${plugin} --tags e2etag,e2ePackage`
);
const project = readJson(`libs/${plugin}/project.json`);
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);
}, 120000);
});
});
13 changes: 13 additions & 0 deletions e2e/nx-electron-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.e2e.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
9 changes: 9 additions & 0 deletions e2e/nx-electron-e2e/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
20 changes: 4 additions & 16 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
const { getJestProjects } = require('@nrwl/jest');

module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
modulePathIgnorePatterns: [
"tmp",
"<rootDir>/test",
"<rootDir>/src",
"collection/.*/files"
],
testPathIgnorePatterns: [
"node_modules"
],
coverageReporters: [
"html"
],
coverageDirectory: "coverage",
};
projects: getJestProjects(),
};
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('@nrwl/jest/preset');

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

0 comments on commit 4489612

Please sign in to comment.