Skip to content

Commit 5cd770b

Browse files
authored
feat: nx-plugin structure + Nx 12.5.x + webpack5 (#4)
1 parent 36f07bd commit 5cd770b

File tree

112 files changed

+9282
-1833
lines changed

Some content is hidden

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

112 files changed

+9282
-1833
lines changed

.editorconfig

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

.eslintrc.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}
36+

.gitignore

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,40 @@
1-
node_modules
2-
.idea
3-
/.vscode
4-
dist
5-
/build
6-
/coverage
7-
test
8-
.DS_Store
9-
tmp
10-
*.log
11-
.ng_pkg_build
12-
jest.debug.config.js
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
137

8+
# dependencies
9+
/node_modules
1410
package-lock.json
11+
12+
# IDEs and editors
13+
/.idea
14+
.project
15+
.classpath
16+
.c9/
17+
*.launch
18+
.settings/
19+
*.sublime-workspace
20+
21+
# IDE - VSCode
22+
.vscode/*
23+
!.vscode/settings.json
24+
!.vscode/tasks.json
25+
!.vscode/launch.json
26+
!.vscode/extensions.json
27+
28+
# misc
29+
/.sass-cache
30+
/connect.lock
31+
/coverage
32+
/libpeerconnection.log
33+
npm-debug.log
34+
yarn-error.log
35+
testem.log
36+
/typings
37+
38+
# System Files
39+
.DS_Store
40+
Thumbs.db

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged --allow-empty

.prettierignore

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
tmp
2-
/test
3-
/build
4-
node_modules
5-
/package.json
6-
packages/plugin-tools/src/schematics/**/files/**/*.json
7-
/.vscode
8-
/.idea
9-
/.github
10-
/coverage
1+
# Add files here to ignore them from prettier formatting
2+
3+
/dist
4+
/coverage

.prettierrc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2-
"singleQuote": true,
3-
"endOfLine": "lf"
4-
}
2+
"useTabs": false,
3+
"printWidth": 600,
4+
"tabWidth": 2,
5+
"singleQuote": true
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
displayName: 'plugin-tools-e2e',
3+
preset: '../../jest.preset.js',
4+
globals: {
5+
'ts-jest': {
6+
tsconfig: '<rootDir>/tsconfig.spec.json',
7+
},
8+
},
9+
transform: {
10+
'^.+\\.[tj]s$': 'ts-jest',
11+
},
12+
moduleFileExtensions: ['ts', 'js', 'html'],
13+
coverageDirectory: '../../coverage/e2e/plugin-tools-e2e',
14+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import {
2+
checkFilesExist,
3+
ensureNxProject,
4+
readJson,
5+
runNxCommandAsync,
6+
uniq,
7+
} from '@nrwl/nx-plugin/testing';
8+
describe('plugin-tools e2e', () => {
9+
it('should create plugin-tools', async () => {
10+
const plugin = uniq('plugin-tools');
11+
ensureNxProject('@nativescript/plugin-tools', 'dist/packages/plugin-tools');
12+
await runNxCommandAsync(
13+
`generate @nativescript/plugin-tools:plugin-tools ${plugin}`
14+
);
15+
16+
const result = await runNxCommandAsync(`build ${plugin}`);
17+
expect(result.stdout).toContain('Executor ran');
18+
}, 120000);
19+
20+
describe('--directory', () => {
21+
it('should create src in the specified directory', async () => {
22+
const plugin = uniq('plugin-tools');
23+
ensureNxProject(
24+
'@nativescript/plugin-tools',
25+
'dist/packages/plugin-tools'
26+
);
27+
await runNxCommandAsync(
28+
`generate @nativescript/plugin-tools:plugin-tools ${plugin} --directory subdir`
29+
);
30+
expect(() =>
31+
checkFilesExist(`libs/subdir/${plugin}/src/index.ts`)
32+
).not.toThrow();
33+
}, 120000);
34+
});
35+
36+
describe('--tags', () => {
37+
it('should add tags to nx.json', async () => {
38+
const plugin = uniq('plugin-tools');
39+
ensureNxProject(
40+
'@nativescript/plugin-tools',
41+
'dist/packages/plugin-tools'
42+
);
43+
await runNxCommandAsync(
44+
`generate @nativescript/plugin-tools:plugin-tools ${plugin} --tags e2etag,e2ePackage`
45+
);
46+
const nxJson = readJson('nx.json');
47+
expect(nxJson.projects[plugin].tags).toEqual(['e2etag', 'e2ePackage']);
48+
}, 120000);
49+
});
50+
});

e2e/plugin-tools-e2e/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.e2e.json"
8+
},
9+
{
10+
"path": "./tsconfig.spec.json"
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)