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

Commit

Permalink
feat: Schematic for extracting libraries from projects
Browse files Browse the repository at this point in the history
JIRA-Ticket: AV-27910
  • Loading branch information
jeka-gom committed Jan 3, 2024
1 parent 528c54d commit cbd9b67
Show file tree
Hide file tree
Showing 13 changed files with 480 additions and 4 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@

## Generation schematics
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).

Usage example:
``ng generate avrios-schematics:component <component-name>``

## Schematic: library (deprecated)

## Schematic: extract-app-libs
Generates libraries for a specific Avrio's app scope.

### inputs:
- `**name:**` The name of the project this libraries belong to. If none given then the libraries are added to the the shared scope.
- `**namespace:**` The namespace of the Library. Normally matches the project name. Ex: `@secure, @shared``.
- `**tags:**` The list of tags the libraries are allowed to use.
- `**prefix:**` The prefix to apply to the generated libraries.

For this schematic to work you have to:
- extract the apps folders that you want to convert to libraries to the path libs/<app-name>/src/lib
- run `npm run ng generate avrios-schematics:extract-app-libs <app-name>`
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "avrios-schematics",
"version": "2.5.0",
"version": "2.6.0",
"description": "A blank schematics",
"scripts": {
"build": "tsc -p tsconfig.json"
Expand Down
5 changes: 5 additions & 0 deletions src/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"description": "Create an Avrios library",
"factory": "./library",
"schema": "./library/schema.json"
},
"extract-app-libs": {
"description": "Extract app libs from an Avrios project",
"factory": "./extract-app-libs",
"schema": "./extract-app-libs/schema.json"
}
}
}
41 changes: 41 additions & 0 deletions src/extract-app-libs/files/.eslintrc.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "**/*.stories.ts"],
"overrides": [
{
"files": ["*.ts"],
"extends": ["plugin:@nrwl/nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "avr",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "avr",
"style": "kebab-case"
}
],
"@angular-eslint/no-output-on-prefix": "off",
"@typescript-eslint/no-namespace": "off"
},
"plugins": ["@typescript-eslint"],
"parserOptions": {
"project": "libs/<%= dasherize(name) %>/tsconfig-linter.json"
}
}, {
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {
"@angular-eslint/template/no-negated-async": "off",
"@angular-eslint/template/eqeqeq": "warn"
}
}
]
}
31 changes: 31 additions & 0 deletions src/extract-app-libs/files/jest.config.ts.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const esModules = ['design-system-toolkit', '.*\\.mjs$'].join('|');

module.exports = {
displayName: '<%= dasherize(name) %>',
preset: '../../jest.config.ts',
coverageDirectory: '../../coverage/libs/<%= dasherize(name) %>',
setupFilesAfterEnv: ['<rootDir>../../setupJest.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
},
transform: {
'^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
[`(${esModules}).+\\.js$`]: 'babel-jest',
},
transformIgnorePatterns: [`node_modules/(?!${esModules})`],


moduleNameMapper: {
'^@shared(.*)$': '<rootDir>../shared/src/lib$1',
'^@<%= dasherize(name) %>(.*)$': '<rootDir>/src/lib$1'
},
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
testRunner: 'jest-jasmine2'
};
15 changes: 15 additions & 0 deletions src/extract-app-libs/files/tsconfig-linter.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"include": [
"./**/*.ts",
"src/**/*.ts"
],
"exclude": [
"../../dist/**/*",
"../../release/**/*",
"../../node_modules/**/*",
"../../tmp/**/*",
"**/*.stories.ts",
"**/*.stories.js"
]
}
19 changes: 19 additions & 0 deletions src/extract-app-libs/files/tsconfig.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.json",
"files": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"paths": {
"@shared/*": ["libs/shared/src/lib/*"],
"@<%= dasherize(namespace) %>/*": ["libs/<%= dasherize(name) %>/src/lib/*"]
},
"target": "es2020"
}
}
19 changes: 19 additions & 0 deletions src/extract-app-libs/files/tsconfig.lib.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"angular-loading-bar",
"angular-promise-tracker",
"angular-translate",
"ng-file-upload",
"node"
]
},
"exclude": [
"**/*.spec.ts"
],
"include": [
"**/*.ts"
]
}
17 changes: 17 additions & 0 deletions src/extract-app-libs/files/tsconfig.spec.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": [
"angular-ui-bootstrap",
"jest",
"node"
]
},
"include": [
"../../libs/**/*.d.ts",
"**/*.spec.ts",
"**/*.test.ts"
]
}
108 changes: 108 additions & 0 deletions src/extract-app-libs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cbd9b67

Please sign in to comment.