Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit cbd9b67

Browse files
committed
feat: Schematic for extracting libraries from projects
JIRA-Ticket: AV-27910
1 parent 528c54d commit cbd9b67

13 files changed

+480
-4
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77

88
## Generation schematics
99
Generation schematics are instructions for the ``ng generate`` command. Avrios' Schematics [support custom API Services, components, modals, page components, ngrx store and library generation](https://github.com/avrios/angular-schematics/blob/master/src/collection.json).
10-
10+
1111
Usage example:
1212
``ng generate avrios-schematics:component <component-name>``
13+
14+
## Schematic: library (deprecated)
15+
16+
## Schematic: extract-app-libs
17+
Generates libraries for a specific Avrio's app scope.
18+
19+
### inputs:
20+
- `**name:**` The name of the project this libraries belong to. If none given then the libraries are added to the the shared scope.
21+
- `**namespace:**` The namespace of the Library. Normally matches the project name. Ex: `@secure, @shared``.
22+
- `**tags:**` The list of tags the libraries are allowed to use.
23+
- `**prefix:**` The prefix to apply to the generated libraries.
24+
25+
For this schematic to work you have to:
26+
- extract the apps folders that you want to convert to libraries to the path libs/<app-name>/src/lib
27+
- run `npm run ng generate avrios-schematics:extract-app-libs <app-name>`

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "avrios-schematics",
3-
"version": "2.5.0",
3+
"version": "2.6.0",
44
"description": "A blank schematics",
55
"scripts": {
66
"build": "tsc -p tsconfig.json"

src/collection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"description": "Create an Avrios library",
3131
"factory": "./library",
3232
"schema": "./library/schema.json"
33+
},
34+
"extract-app-libs": {
35+
"description": "Extract app libs from an Avrios project",
36+
"factory": "./extract-app-libs",
37+
"schema": "./extract-app-libs/schema.json"
3338
}
3439
}
3540
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*", "**/*.stories.ts"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"extends": ["plugin:@nrwl/nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
8+
"rules": {
9+
"@angular-eslint/directive-selector": [
10+
"error",
11+
{
12+
"type": "attribute",
13+
"prefix": "avr",
14+
"style": "camelCase"
15+
}
16+
],
17+
"@angular-eslint/component-selector": [
18+
"error",
19+
{
20+
"type": "element",
21+
"prefix": "avr",
22+
"style": "kebab-case"
23+
}
24+
],
25+
"@angular-eslint/no-output-on-prefix": "off",
26+
"@typescript-eslint/no-namespace": "off"
27+
},
28+
"plugins": ["@typescript-eslint"],
29+
"parserOptions": {
30+
"project": "libs/<%= dasherize(name) %>/tsconfig-linter.json"
31+
}
32+
}, {
33+
"files": ["*.html"],
34+
"extends": ["plugin:@nrwl/nx/angular-template"],
35+
"rules": {
36+
"@angular-eslint/template/no-negated-async": "off",
37+
"@angular-eslint/template/eqeqeq": "warn"
38+
}
39+
}
40+
]
41+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const esModules = ['design-system-toolkit', '.*\\.mjs$'].join('|');
2+
3+
module.exports = {
4+
displayName: '<%= dasherize(name) %>',
5+
preset: '../../jest.config.ts',
6+
coverageDirectory: '../../coverage/libs/<%= dasherize(name) %>',
7+
setupFilesAfterEnv: ['<rootDir>../../setupJest.ts'],
8+
globals: {
9+
'ts-jest': {
10+
tsconfig: '<rootDir>/tsconfig.spec.json',
11+
stringifyContentPathRegex: '\\.(html|svg)$',
12+
},
13+
},
14+
transform: {
15+
'^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
16+
[`(${esModules}).+\\.js$`]: 'babel-jest',
17+
},
18+
transformIgnorePatterns: [`node_modules/(?!${esModules})`],
19+
20+
21+
moduleNameMapper: {
22+
'^@shared(.*)$': '<rootDir>../shared/src/lib$1',
23+
'^@<%= dasherize(name) %>(.*)$': '<rootDir>/src/lib$1'
24+
},
25+
snapshotSerializers: [
26+
'jest-preset-angular/build/serializers/no-ng-attributes',
27+
'jest-preset-angular/build/serializers/ng-snapshot',
28+
'jest-preset-angular/build/serializers/html-comment',
29+
],
30+
testRunner: 'jest-jasmine2'
31+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": [
4+
"./**/*.ts",
5+
"src/**/*.ts"
6+
],
7+
"exclude": [
8+
"../../dist/**/*",
9+
"../../release/**/*",
10+
"../../node_modules/**/*",
11+
"../../tmp/**/*",
12+
"**/*.stories.ts",
13+
"**/*.stories.js"
14+
]
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"files": [],
4+
"references": [
5+
{
6+
"path": "./tsconfig.lib.json"
7+
},
8+
{
9+
"path": "./tsconfig.spec.json"
10+
}
11+
],
12+
"compilerOptions": {
13+
"paths": {
14+
"@shared/*": ["libs/shared/src/lib/*"],
15+
"@<%= dasherize(namespace) %>/*": ["libs/<%= dasherize(name) %>/src/lib/*"]
16+
},
17+
"target": "es2020"
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"types": [
6+
"angular-loading-bar",
7+
"angular-promise-tracker",
8+
"angular-translate",
9+
"ng-file-upload",
10+
"node"
11+
]
12+
},
13+
"exclude": [
14+
"**/*.spec.ts"
15+
],
16+
"include": [
17+
"**/*.ts"
18+
]
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": [
7+
"angular-ui-bootstrap",
8+
"jest",
9+
"node"
10+
]
11+
},
12+
"include": [
13+
"../../libs/**/*.d.ts",
14+
"**/*.spec.ts",
15+
"**/*.test.ts"
16+
]
17+
}

0 commit comments

Comments
 (0)