Skip to content

Commit 06fa3ce

Browse files
Chau TranChau Tran
Chau Tran
authored and
Chau Tran
committed
feat(soba): setup soba plugin
1 parent 0ee2984 commit 06fa3ce

File tree

15 files changed

+237
-0
lines changed

15 files changed

+237
-0
lines changed

libs/soba-plugin/.eslintrc.json

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/soba-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).

libs/soba-plugin/generators.json

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": "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 Soba"
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 Soba"
17+
}
18+
}
19+
}

libs/soba-plugin/jest.config.ts

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+
};

libs/soba-plugin/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

libs/soba-plugin/project.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "angular-three-soba-plugin",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/soba-plugin/src",
5+
"projectType": "library",
6+
"targets": {
7+
"build": {
8+
"executor": "@nx/js:tsc",
9+
"outputs": ["{options.outputPath}"],
10+
"options": {
11+
"outputPath": "dist/libs/soba/plugin",
12+
"main": "libs/soba-plugin/src/index.ts",
13+
"tsConfig": "libs/soba-plugin/tsconfig.lib.json",
14+
"assets": [
15+
"libs/plugin/*.md",
16+
{
17+
"input": "./libs/soba-plugin/src",
18+
"glob": "**/!(*.ts)",
19+
"output": "./src"
20+
},
21+
{
22+
"input": "./libs/soba-plugin/src",
23+
"glob": "**/*.d.ts",
24+
"output": "./src"
25+
},
26+
{
27+
"input": "./libs/soba-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/soba-plugin/**/*.ts",
40+
"libs/soba-plugin/generators.json",
41+
"libs/soba-plugin/executors.json",
42+
"libs/soba-plugin/package.json"
43+
]
44+
}
45+
},
46+
"test": {
47+
"executor": "@nx/jest:jest",
48+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
49+
"options": {
50+
"jestConfig": "libs/soba-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_SOBA_VERSION, THREE_STDLIB_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-soba']).toEqual(ANGULAR_THREE_SOBA_VERSION);
18+
expect(packageJson.dependencies['three-stdlib']).toEqual(THREE_STDLIB_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_SOBA_VERSION = '^2.0.0';
4+
export const THREE_STDLIB_VERSION = '^2.0.0';
5+
6+
export default async function (tree: Tree) {
7+
logger.log('Initializing Angular Three...');
8+
9+
const packageJson = readJson(tree, 'package.json');
10+
11+
const version =
12+
packageJson['dependencies']?.['angular-three-soba'] ||
13+
packageJson['devDependencies']?.['angular-three-soba'] ||
14+
ANGULAR_THREE_SOBA_VERSION;
15+
16+
addDependenciesToPackageJson(
17+
tree,
18+
{
19+
'angular-three-soba': version,
20+
'three-stdlib': THREE_STDLIB_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 Soba"
6+
}

libs/soba-plugin/src/index.ts

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';

libs/soba-plugin/tsconfig.json

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+
}

libs/soba-plugin/tsconfig.lib.json

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+
}

libs/soba-plugin/tsconfig.spec.json

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+
}

libs/soba/project.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
},
2323
"defaultConfiguration": "production"
2424
},
25+
"package": {
26+
"executor": "nx:run-commands",
27+
"options": {
28+
"commands": ["npx nx build soba", "npx nx build angular-three-soba-plugin"],
29+
"parallel": false
30+
}
31+
},
2532
"test": {
2633
"executor": "@nx/jest:jest",
2734
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],

0 commit comments

Comments
 (0)