Skip to content

Commit 572d7bb

Browse files
Chau TranChau Tran
Chau Tran
authored and
Chau Tran
committed
feat(postprocessing): migrate plugin
1 parent a87b9a8 commit 572d7bb

File tree

15 files changed

+231
-1
lines changed

15 files changed

+231
-1
lines changed

.release-it.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"releaseName": "Release ${version}"
4141
},
4242
"hooks": {
43-
"before:bump": "pnpm exec nx run-many --target=package --projects=angular-three,soba",
43+
"before:bump": "pnpm exec nx run-many --target=package --projects=angular-three,soba,postprocessing",
4444
"after:bump": ["git checkout -- package.json"]
4545
}
4646
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["./package.json", "./generators.json", "./executors.json"],
19+
"parser": "jsonc-eslint-parser",
20+
"rules": {
21+
"@nx/nx-plugin-checks": "error"
22+
}
23+
}
24+
]
25+
}

libs/postprocessing-plugin/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# plugin
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Building
6+
7+
Run `nx build plugin` to build the library.
8+
9+
## Running unit tests
10+
11+
Run `nx test plugin` to execute the unit tests via [Jest](https://jestjs.io).
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"name": "angular-three-postprocessing-plugin",
4+
"version": "0.0.1",
5+
"generators": {
6+
"init": {
7+
"factory": "./src/generators/init/init",
8+
"schema": "./src/generators/init/schema.json",
9+
"description": "Init Angular Three Postprocessing"
10+
}
11+
},
12+
"schematics": {
13+
"ng-add": {
14+
"factory": "./src/generators/init/compat",
15+
"schema": "./src/generators/init/schema.json",
16+
"description": "Add Angular Three Postprocessing"
17+
}
18+
}
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'plugin',
4+
preset: '../../jest.preset.js',
5+
globals: {},
6+
transform: {
7+
'^.+\\.[tj]s$': [
8+
'ts-jest',
9+
{
10+
tsconfig: '<rootDir>/tsconfig.spec.json',
11+
},
12+
],
13+
},
14+
moduleFileExtensions: ['ts', 'js', 'html'],
15+
coverageDirectory: '../../coverage/libs/plugin',
16+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "angular-three-postprocessing-plugin",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/postprocessing-plugin/src",
5+
"projectType": "library",
6+
"targets": {
7+
"build": {
8+
"executor": "@nx/js:tsc",
9+
"outputs": ["{options.outputPath}"],
10+
"options": {
11+
"outputPath": "dist/libs/postprocessing/plugin",
12+
"main": "libs/postprocessing-plugin/src/index.ts",
13+
"tsConfig": "libs/postprocessing-plugin/tsconfig.lib.json",
14+
"assets": [
15+
"libs/postprocessing-plugin/*.md",
16+
{
17+
"input": "./libs/postprocessing-plugin/src",
18+
"glob": "**/!(*.ts)",
19+
"output": "./src"
20+
},
21+
{
22+
"input": "./libs/postprocessing-plugin/src",
23+
"glob": "**/*.d.ts",
24+
"output": "./src"
25+
},
26+
{
27+
"input": "./libs/postprocessing-plugin",
28+
"glob": "generators.json",
29+
"output": "."
30+
}
31+
]
32+
}
33+
},
34+
"lint": {
35+
"executor": "@nx/linter:eslint",
36+
"outputs": ["{options.outputFile}"],
37+
"options": {
38+
"lintFilePatterns": [
39+
"libs/postprocessing-plugin/**/*.ts",
40+
"libs/postprocessing-plugin/generators.json",
41+
"libs/postprocessing-plugin/executors.json",
42+
"libs/postprocessing-plugin/package.json"
43+
]
44+
}
45+
},
46+
"test": {
47+
"executor": "@nx/jest:jest",
48+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
49+
"options": {
50+
"jestConfig": "libs/postprocessing-plugin/jest.config.ts",
51+
"passWithNoTests": true
52+
},
53+
"configurations": {
54+
"ci": {
55+
"ci": true,
56+
"codeCoverage": true
57+
}
58+
}
59+
}
60+
},
61+
"tags": []
62+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { convertNxGenerator } from '@nx/devkit';
2+
import init from './init';
3+
4+
export default convertNxGenerator(init);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { readJson, Tree } from '@nx/devkit';
2+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3+
import init, { ANGULAR_THREE_POSTPROCESSING_VERSION, POSTPROCESSING_VERSION } from './init';
4+
5+
describe('init generator', () => {
6+
let appTree: Tree;
7+
8+
beforeEach(() => {
9+
appTree = createTreeWithEmptyWorkspace();
10+
});
11+
12+
it('should add three dependencies', async () => {
13+
await init(appTree);
14+
15+
const packageJson = readJson(appTree, 'package.json');
16+
17+
expect(packageJson.dependencies['angular-three-postprocessing']).toEqual(ANGULAR_THREE_POSTPROCESSING_VERSION);
18+
expect(packageJson.dependencies['postprocessing']).toEqual(POSTPROCESSING_VERSION);
19+
});
20+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { addDependenciesToPackageJson, installPackagesTask, logger, readJson, Tree } from '@nx/devkit';
2+
3+
export const ANGULAR_THREE_POSTPROCESSING_VERSION = '^2.0.0';
4+
export const POSTPROCESSING_VERSION = '^6.0.0';
5+
6+
export default async function (tree: Tree) {
7+
logger.log('Initializing Angular Three Cannon...');
8+
9+
const packageJson = readJson(tree, 'package.json');
10+
11+
const version =
12+
packageJson['dependencies']?.['angular-three-postprocessing'] ||
13+
packageJson['devDependencies']?.['angular-three-postprocessing'] ||
14+
ANGULAR_THREE_POSTPROCESSING_VERSION;
15+
16+
addDependenciesToPackageJson(
17+
tree,
18+
{
19+
'angular-three-postprocessing': version,
20+
postprocessing: POSTPROCESSING_VERSION,
21+
},
22+
{}
23+
);
24+
25+
return () => {
26+
installPackagesTask(tree);
27+
};
28+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"cli": "nx",
4+
"$id": "Init",
5+
"title": "Init Angular Three Postprocessing"
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as initGenerator } from './generators/init/init';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs"
5+
},
6+
"files": [],
7+
"include": [],
8+
"references": [
9+
{
10+
"path": "./tsconfig.lib.json"
11+
},
12+
{
13+
"path": "./tsconfig.spec.json"
14+
}
15+
]
16+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"declaration": true,
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"],
9+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["jest", "node"]
7+
},
8+
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
9+
}

0 commit comments

Comments
 (0)