@rxap/plugin-angular 20.0.1-dev.1 → 20.0.1-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +6 -0
- package/.eslintrc.json +44 -0
- package/CHANGELOG.md +43 -0
- package/LICENSE +621 -0
- package/README.md.handlebars +115 -0
- package/jest.config.ts +11 -0
- package/package.json +11 -24
- package/project.json +68 -0
- package/schematics.yaml +6 -0
- package/src/application.ts +124 -0
- package/src/executors/check-ng-package/executor.ts +33 -0
- package/src/executors/config/executor.ts +74 -0
- package/src/executors/i18n/executor.ts +198 -0
- package/src/executors/tailwind/executor.ts +34 -0
- package/src/generators/convert-to-buildable-library/generator.ts +110 -0
- package/src/generators/fix-schematic/generator.ts +103 -0
- package/src/generators/fix-schematic/index.ts +5 -0
- package/src/generators/init/coerce-nx-json.ts +72 -0
- package/src/generators/init/generator.ts +28 -0
- package/src/generators/init/index.ts +5 -0
- package/src/generators/init/init-workspace.ts +84 -0
- package/src/generators/init-application/assert-main-statements.ts +74 -0
- package/src/generators/init-application/cleanup.ts +127 -0
- package/src/generators/init-application/coerce-app-config.ts +147 -0
- package/src/generators/init-application/coerce-environment-files.ts +105 -0
- package/src/generators/init-application/coerce-localazy-config-file.ts +26 -0
- package/src/generators/init-application/coerce-project.ts +128 -0
- package/src/generators/init-application/generate-authentication.ts +122 -0
- package/src/generators/init-application/generate-monolithic.spec.ts +45 -0
- package/src/generators/init-application/generate-monolithic.ts +57 -0
- package/src/generators/init-application/generator.ts +356 -0
- package/src/generators/init-application/index.ts +5 -0
- package/src/generators/init-application/link-mfe-remote-with-host.ts +60 -0
- package/src/generators/init-application/project-i18n-configuration.ts +4 -0
- package/src/generators/init-application/update-git-ignore.ts +22 -0
- package/src/generators/init-application/update-main-file.ts +118 -0
- package/src/generators/init-application/update-project-targets.ts +229 -0
- package/src/generators/init-application/update-tags.ts +30 -0
- package/src/generators/init-application/update-target-defaults.ts +43 -0
- package/src/generators/init-application/update-ts-config.ts +31 -0
- package/src/generators/init-component/generator.ts +147 -0
- package/src/generators/init-component/index.ts +5 -0
- package/src/generators/init-feature/generator.ts +77 -0
- package/src/generators/init-feature/index.ts +5 -0
- package/src/generators/init-feature-library/generator.ts +82 -0
- package/src/generators/init-feature-library/index.ts +5 -0
- package/src/generators/init-feature-library/init-project.ts +53 -0
- package/src/generators/init-feature-library/init-workspace.ts +10 -0
- package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.ts +46 -0
- package/src/generators/init-library/cleanup.ts +22 -0
- package/src/generators/init-library/coerce-projects.ts +118 -0
- package/src/generators/init-library/coerce-tailwind-theme-scss.ts +27 -0
- package/src/generators/init-library/extend-angular-specific-eslint.ts +37 -0
- package/src/generators/init-library/generator.ts +87 -0
- package/src/generators/init-library/has-index-scss.ts +14 -0
- package/src/generators/init-library/has-tailwind-config.ts +9 -0
- package/src/generators/init-library/index.ts +5 -0
- package/src/generators/init-library/init-project.ts +46 -0
- package/src/generators/init-library/init-workspace.ts +26 -0
- package/src/generators/init-library/is-ng-packagr-project.ts +9 -0
- package/src/generators/init-library/ng-package-json.ts +23 -0
- package/src/generators/init-library/set-general-target-defaults.ts +36 -0
- package/src/generators/init-library/update-package-json.ts +26 -0
- package/src/generators/init-library/update-project-ng-package-configuration.ts +51 -0
- package/src/generators/init-library/update-ts-config.ts +24 -0
- package/src/generators/schematic/generator.ts +179 -0
- package/src/generators/schematic/index.ts +5 -0
- package/src/i18n.ts +130 -0
- package/src/lib/angular-version.ts +1 -0
- package/src/lib/coerce-cypress-component-testing.ts +113 -0
- package/src/lib/coerce-test-setup.ts +60 -0
- package/src/library.ts +153 -0
- package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.ts +32 -0
- package/src/migrations/update-19-0-0/migration.ts +283 -0
- package/src/test-setup.ts +24 -0
- package/tsconfig.json +20 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +15 -0
- package/tsconfig.typedoc.json +5 -0
- package/src/application.d.ts +0 -6
- package/src/application.js +0 -77
- package/src/application.js.map +0 -1
- package/src/executors/check-ng-package/executor.d.ts +0 -5
- package/src/executors/check-ng-package/executor.js +0 -30
- package/src/executors/check-ng-package/executor.js.map +0 -1
- package/src/executors/config/executor.d.ts +0 -10
- package/src/executors/config/executor.js +0 -65
- package/src/executors/config/executor.js.map +0 -1
- package/src/executors/i18n/executor.d.ts +0 -9
- package/src/executors/i18n/executor.js +0 -158
- package/src/executors/i18n/executor.js.map +0 -1
- package/src/executors/tailwind/executor.d.ts +0 -5
- package/src/executors/tailwind/executor.js +0 -31
- package/src/executors/tailwind/executor.js.map +0 -1
- package/src/generators/convert-to-buildable-library/generator.d.ts +0 -4
- package/src/generators/convert-to-buildable-library/generator.js +0 -88
- package/src/generators/convert-to-buildable-library/generator.js.map +0 -1
- package/src/generators/fix-schematic/generator.d.ts +0 -4
- package/src/generators/fix-schematic/generator.js +0 -72
- package/src/generators/fix-schematic/generator.js.map +0 -1
- package/src/generators/fix-schematic/index.d.ts +0 -2
- package/src/generators/fix-schematic/index.js +0 -7
- package/src/generators/fix-schematic/index.js.map +0 -1
- package/src/generators/init/coerce-nx-json.d.ts +0 -3
- package/src/generators/init/coerce-nx-json.js +0 -74
- package/src/generators/init/coerce-nx-json.js.map +0 -1
- package/src/generators/init/generator.d.ts +0 -4
- package/src/generators/init/generator.js +0 -19
- package/src/generators/init/generator.js.map +0 -1
- package/src/generators/init/index.d.ts +0 -2
- package/src/generators/init/index.js +0 -7
- package/src/generators/init/index.js.map +0 -1
- package/src/generators/init/init-workspace.d.ts +0 -3
- package/src/generators/init/init-workspace.js +0 -73
- package/src/generators/init/init-workspace.js.map +0 -1
- package/src/generators/init-application/assert-main-statements.d.ts +0 -4
- package/src/generators/init-application/assert-main-statements.js +0 -76
- package/src/generators/init-application/assert-main-statements.js.map +0 -1
- package/src/generators/init-application/cleanup.d.ts +0 -3
- package/src/generators/init-application/cleanup.js +0 -108
- package/src/generators/init-application/cleanup.js.map +0 -1
- package/src/generators/init-application/coerce-app-config.d.ts +0 -3
- package/src/generators/init-application/coerce-app-config.js +0 -143
- package/src/generators/init-application/coerce-app-config.js.map +0 -1
- package/src/generators/init-application/coerce-environment-files.d.ts +0 -5
- package/src/generators/init-application/coerce-environment-files.js +0 -75
- package/src/generators/init-application/coerce-environment-files.js.map +0 -1
- package/src/generators/init-application/coerce-localazy-config-file.d.ts +0 -2
- package/src/generators/init-application/coerce-localazy-config-file.js +0 -25
- package/src/generators/init-application/coerce-localazy-config-file.js.map +0 -1
- package/src/generators/init-application/coerce-project.d.ts +0 -4
- package/src/generators/init-application/coerce-project.js +0 -56
- package/src/generators/init-application/coerce-project.js.map +0 -1
- package/src/generators/init-application/generate-authentication.d.ts +0 -3
- package/src/generators/init-application/generate-authentication.js +0 -97
- package/src/generators/init-application/generate-authentication.js.map +0 -1
- package/src/generators/init-application/generate-monolithic.d.ts +0 -3
- package/src/generators/init-application/generate-monolithic.js +0 -45
- package/src/generators/init-application/generate-monolithic.js.map +0 -1
- package/src/generators/init-application/generator.d.ts +0 -4
- package/src/generators/init-application/generator.js +0 -257
- package/src/generators/init-application/generator.js.map +0 -1
- package/src/generators/init-application/index.d.ts +0 -2
- package/src/generators/init-application/index.js +0 -7
- package/src/generators/init-application/index.js.map +0 -1
- package/src/generators/init-application/link-mfe-remote-with-host.d.ts +0 -3
- package/src/generators/init-application/link-mfe-remote-with-host.js +0 -54
- package/src/generators/init-application/link-mfe-remote-with-host.js.map +0 -1
- package/src/generators/init-application/project-i18n-configuration.d.ts +0 -7
- package/src/generators/init-application/project-i18n-configuration.js +0 -3
- package/src/generators/init-application/project-i18n-configuration.js.map +0 -1
- package/src/generators/init-application/update-git-ignore.d.ts +0 -3
- package/src/generators/init-application/update-git-ignore.js +0 -17
- package/src/generators/init-application/update-git-ignore.js.map +0 -1
- package/src/generators/init-application/update-main-file.d.ts +0 -3
- package/src/generators/init-application/update-main-file.js +0 -106
- package/src/generators/init-application/update-main-file.js.map +0 -1
- package/src/generators/init-application/update-project-targets.d.ts +0 -6
- package/src/generators/init-application/update-project-targets.js +0 -210
- package/src/generators/init-application/update-project-targets.js.map +0 -1
- package/src/generators/init-application/update-tags.d.ts +0 -3
- package/src/generators/init-application/update-tags.js +0 -25
- package/src/generators/init-application/update-tags.js.map +0 -1
- package/src/generators/init-application/update-target-defaults.d.ts +0 -3
- package/src/generators/init-application/update-target-defaults.js +0 -30
- package/src/generators/init-application/update-target-defaults.js.map +0 -1
- package/src/generators/init-application/update-ts-config.d.ts +0 -2
- package/src/generators/init-application/update-ts-config.js +0 -30
- package/src/generators/init-application/update-ts-config.js.map +0 -1
- package/src/generators/init-component/generator.d.ts +0 -5
- package/src/generators/init-component/generator.js +0 -106
- package/src/generators/init-component/generator.js.map +0 -1
- package/src/generators/init-component/index.d.ts +0 -2
- package/src/generators/init-component/index.js +0 -7
- package/src/generators/init-component/index.js.map +0 -1
- package/src/generators/init-feature/generator.d.ts +0 -4
- package/src/generators/init-feature/generator.js +0 -53
- package/src/generators/init-feature/generator.js.map +0 -1
- package/src/generators/init-feature/index.d.ts +0 -2
- package/src/generators/init-feature/index.js +0 -7
- package/src/generators/init-feature/index.js.map +0 -1
- package/src/generators/init-feature-library/generator.d.ts +0 -4
- package/src/generators/init-feature-library/generator.js +0 -51
- package/src/generators/init-feature-library/generator.js.map +0 -1
- package/src/generators/init-feature-library/index.d.ts +0 -2
- package/src/generators/init-feature-library/index.js +0 -7
- package/src/generators/init-feature-library/index.js.map +0 -1
- package/src/generators/init-feature-library/init-project.d.ts +0 -3
- package/src/generators/init-feature-library/init-project.js +0 -41
- package/src/generators/init-feature-library/init-project.js.map +0 -1
- package/src/generators/init-feature-library/init-workspace.d.ts +0 -3
- package/src/generators/init-feature-library/init-workspace.js +0 -12
- package/src/generators/init-feature-library/init-workspace.js.map +0 -1
- package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.d.ts +0 -2
- package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.js +0 -39
- package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.js.map +0 -1
- package/src/generators/init-library/cleanup.d.ts +0 -2
- package/src/generators/init-library/cleanup.js +0 -16
- package/src/generators/init-library/cleanup.js.map +0 -1
- package/src/generators/init-library/coerce-projects.d.ts +0 -3
- package/src/generators/init-library/coerce-projects.js +0 -92
- package/src/generators/init-library/coerce-projects.js.map +0 -1
- package/src/generators/init-library/coerce-tailwind-theme-scss.d.ts +0 -2
- package/src/generators/init-library/coerce-tailwind-theme-scss.js +0 -22
- package/src/generators/init-library/coerce-tailwind-theme-scss.js.map +0 -1
- package/src/generators/init-library/extend-angular-specific-eslint.d.ts +0 -2
- package/src/generators/init-library/extend-angular-specific-eslint.js +0 -25
- package/src/generators/init-library/extend-angular-specific-eslint.js.map +0 -1
- package/src/generators/init-library/generator.d.ts +0 -4
- package/src/generators/init-library/generator.js +0 -56
- package/src/generators/init-library/generator.js.map +0 -1
- package/src/generators/init-library/has-index-scss.d.ts +0 -2
- package/src/generators/init-library/has-index-scss.js +0 -11
- package/src/generators/init-library/has-index-scss.js.map +0 -1
- package/src/generators/init-library/has-tailwind-config.d.ts +0 -2
- package/src/generators/init-library/has-tailwind-config.js +0 -8
- package/src/generators/init-library/has-tailwind-config.js.map +0 -1
- package/src/generators/init-library/index.d.ts +0 -2
- package/src/generators/init-library/index.js +0 -7
- package/src/generators/init-library/index.js.map +0 -1
- package/src/generators/init-library/init-project.d.ts +0 -3
- package/src/generators/init-library/init-project.js +0 -37
- package/src/generators/init-library/init-project.js.map +0 -1
- package/src/generators/init-library/init-workspace.d.ts +0 -3
- package/src/generators/init-library/init-workspace.js +0 -21
- package/src/generators/init-library/init-workspace.js.map +0 -1
- package/src/generators/init-library/is-ng-packagr-project.d.ts +0 -2
- package/src/generators/init-library/is-ng-packagr-project.js +0 -8
- package/src/generators/init-library/is-ng-packagr-project.js.map +0 -1
- package/src/generators/init-library/ng-package-json.d.ts +0 -8
- package/src/generators/init-library/ng-package-json.js +0 -16
- package/src/generators/init-library/ng-package-json.js.map +0 -1
- package/src/generators/init-library/set-general-target-defaults.d.ts +0 -2
- package/src/generators/init-library/set-general-target-defaults.js +0 -27
- package/src/generators/init-library/set-general-target-defaults.js.map +0 -1
- package/src/generators/init-library/update-package-json.d.ts +0 -2
- package/src/generators/init-library/update-package-json.js +0 -17
- package/src/generators/init-library/update-package-json.js.map +0 -1
- package/src/generators/init-library/update-project-ng-package-configuration.d.ts +0 -2
- package/src/generators/init-library/update-project-ng-package-configuration.js +0 -37
- package/src/generators/init-library/update-project-ng-package-configuration.js.map +0 -1
- package/src/generators/init-library/update-ts-config.d.ts +0 -2
- package/src/generators/init-library/update-ts-config.js +0 -22
- package/src/generators/init-library/update-ts-config.js.map +0 -1
- package/src/generators/schematic/generator.d.ts +0 -6
- package/src/generators/schematic/generator.js +0 -127
- package/src/generators/schematic/generator.js.map +0 -1
- package/src/generators/schematic/index.d.ts +0 -2
- package/src/generators/schematic/index.js +0 -7
- package/src/generators/schematic/index.js.map +0 -1
- package/src/i18n.d.ts +0 -6
- package/src/i18n.js +0 -83
- package/src/i18n.js.map +0 -1
- package/src/index.js +0 -10
- package/src/index.js.map +0 -1
- package/src/lib/angular-version.d.ts +0 -1
- package/src/lib/angular-version.js +0 -5
- package/src/lib/angular-version.js.map +0 -1
- package/src/lib/coerce-cypress-component-testing.d.ts +0 -2
- package/src/lib/coerce-cypress-component-testing.js +0 -78
- package/src/lib/coerce-cypress-component-testing.js.map +0 -1
- package/src/lib/coerce-test-setup.d.ts +0 -2
- package/src/lib/coerce-test-setup.js +0 -47
- package/src/lib/coerce-test-setup.js.map +0 -1
- package/src/library.d.ts +0 -6
- package/src/library.js +0 -100
- package/src/library.js.map +0 -1
- package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.d.ts +0 -2
- package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.js +0 -29
- package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.js.map +0 -1
- package/src/migrations/update-19-0-0/migration.d.ts +0 -9
- package/src/migrations/update-19-0-0/migration.js +0 -220
- package/src/migrations/update-19-0-0/migration.js.map +0 -1
- /package/src/{index.d.ts → index.ts} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import { CoerceRoutes } from '@rxap/ts-morph';
|
|
6
|
+
import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
|
|
7
|
+
import {
|
|
8
|
+
CoerceProjectTags,
|
|
9
|
+
GetLibraryPathAliasName,
|
|
10
|
+
GetProjectSourceRoot,
|
|
11
|
+
UpdateProjectPackageJson,
|
|
12
|
+
UpdateTsConfigPaths,
|
|
13
|
+
} from '@rxap/workspace-utilities';
|
|
14
|
+
import { initProject as InitLibraryProject } from '../init-library/init-project';
|
|
15
|
+
import { InitFeatureLibraryGeneratorSchema } from './schema';
|
|
16
|
+
|
|
17
|
+
function coerceRoutesEntryPoint(tree: Tree, projectName: string) {
|
|
18
|
+
TsMorphAngularProjectTransform(tree, {
|
|
19
|
+
project: projectName,
|
|
20
|
+
}, (_, [sourceFile]) => {
|
|
21
|
+
CoerceRoutes(sourceFile, {});
|
|
22
|
+
}, ['routes.ts?']);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function addRoutesImportPathToBaseTsConfig(tree: Tree, projectName: string) {
|
|
26
|
+
|
|
27
|
+
UpdateTsConfigPaths(tree, paths => {
|
|
28
|
+
paths[`${GetLibraryPathAliasName(tree, projectName)}/routes`] = [
|
|
29
|
+
`${GetProjectSourceRoot(tree, projectName)}/lib/routes.ts`,
|
|
30
|
+
];
|
|
31
|
+
}, { infix: 'base' });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function initProject(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitFeatureLibraryGeneratorSchema) {
|
|
35
|
+
console.log(`init angular library project: ${ projectName }`);
|
|
36
|
+
|
|
37
|
+
CoerceProjectTags(project, ['feature', 'angular', 'ngx']);
|
|
38
|
+
|
|
39
|
+
// It is required to ensure that private is set to true before calling the InitLibraryProject function
|
|
40
|
+
// Is function this value will be used to determine if the library is publishable or not. And on default, a
|
|
41
|
+
// feature library is only buildable and NOT publishable
|
|
42
|
+
UpdateProjectPackageJson(tree, json => {
|
|
43
|
+
json.private ??= true;
|
|
44
|
+
}, { projectName });
|
|
45
|
+
|
|
46
|
+
await InitLibraryProject(tree, projectName, project, options);
|
|
47
|
+
|
|
48
|
+
if (options.routes) {
|
|
49
|
+
coerceRoutesEntryPoint(tree, projectName);
|
|
50
|
+
addRoutesImportPathToBaseTsConfig(tree, projectName);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { initWorkspace as InitLibraryWorkspace } from '../init-library/init-workspace';
|
|
3
|
+
import { InitFeatureLibraryGeneratorSchema } from './schema';
|
|
4
|
+
|
|
5
|
+
export async function initWorkspace(tree: Tree, options: InitFeatureLibraryGeneratorSchema) {
|
|
6
|
+
console.log('init angular library workspace');
|
|
7
|
+
|
|
8
|
+
await InitLibraryWorkspace(tree, options);
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import {
|
|
6
|
+
CoerceFile,
|
|
7
|
+
ForEachSecondaryEntryPoint,
|
|
8
|
+
} from '@rxap/workspace-utilities';
|
|
9
|
+
import {
|
|
10
|
+
dirname,
|
|
11
|
+
join,
|
|
12
|
+
relative,
|
|
13
|
+
} from 'path';
|
|
14
|
+
|
|
15
|
+
export function checkIfSecondaryEntrypointIncludeInTheTsConfig(tree: Tree, project: ProjectConfiguration) {
|
|
16
|
+
const projectRoot = project.root;
|
|
17
|
+
const libTsConfigPath = join(projectRoot, 'tsconfig.lib.json');
|
|
18
|
+
const specTsConfigPath = join(projectRoot, 'tsconfig.spec.json');
|
|
19
|
+
const libTsConfig = tree.exists(libTsConfigPath) ? JSON.parse(tree.read(libTsConfigPath)!.toString('utf-8')) : null;
|
|
20
|
+
const specTsConfig = tree.exists(specTsConfigPath) ? JSON.parse(tree.read(specTsConfigPath)!.toString('utf-8')) :
|
|
21
|
+
null;
|
|
22
|
+
for (const path of ForEachSecondaryEntryPoint(tree, projectRoot)) {
|
|
23
|
+
const folder = dirname(path);
|
|
24
|
+
const entryPoint = relative(projectRoot, folder);
|
|
25
|
+
if (entryPoint) {
|
|
26
|
+
if (libTsConfig) {
|
|
27
|
+
libTsConfig.include ??= [];
|
|
28
|
+
if (!libTsConfig.include.includes(`${ entryPoint }/**/*.ts`)) {
|
|
29
|
+
libTsConfig.include.push(`${ entryPoint }/**/*.ts`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (specTsConfig) {
|
|
33
|
+
specTsConfig.include ??= [];
|
|
34
|
+
if (!specTsConfig.include.includes(`${ entryPoint }/**/*.spec.ts`)) {
|
|
35
|
+
specTsConfig.include.push(`${ entryPoint }/**/*.spec.ts`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (libTsConfig) {
|
|
41
|
+
CoerceFile(tree, libTsConfigPath, JSON.stringify(libTsConfig, null, 2), true);
|
|
42
|
+
}
|
|
43
|
+
if (specTsConfig) {
|
|
44
|
+
CoerceFile(tree, specTsConfigPath, JSON.stringify(specTsConfig, null, 2), true);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import {
|
|
6
|
+
CoerceFile,
|
|
7
|
+
DeleteRecursive,
|
|
8
|
+
} from '@rxap/workspace-utilities';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
|
|
11
|
+
export function cleanup(tree: Tree, project: ProjectConfiguration, projectName: string) {
|
|
12
|
+
const projectSourceRoot = project.sourceRoot;
|
|
13
|
+
|
|
14
|
+
if (!projectSourceRoot) {
|
|
15
|
+
throw new Error(`The project ${ projectName } has no sourceRoot`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (tree.exists(join(projectSourceRoot, 'lib', projectName))) {
|
|
19
|
+
DeleteRecursive(tree, join(projectSourceRoot, 'lib', projectName));
|
|
20
|
+
CoerceFile(tree, join(projectSourceRoot, 'index.ts'), 'export {};', true);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { libraryGenerator as angularLibraryGenerator } from '@nx/angular/generators';
|
|
2
|
+
import { Schema as AngularLibraryGeneratorSchema } from '@nx/angular/src/generators/library/schema';
|
|
3
|
+
import { Tree } from '@nx/devkit';
|
|
4
|
+
import { FixDependencies } from '@rxap/plugin-library';
|
|
5
|
+
import {
|
|
6
|
+
GetDefaultGeneratorOptions,
|
|
7
|
+
GetProject,
|
|
8
|
+
GetProjectSourceRoot,
|
|
9
|
+
GetWorkspaceScope,
|
|
10
|
+
HasProject,
|
|
11
|
+
UpdateProjectPackageJson,
|
|
12
|
+
UpdateTsConfigJson,
|
|
13
|
+
} from '@rxap/workspace-utilities';
|
|
14
|
+
import { join } from 'path';
|
|
15
|
+
import { cleanup } from './cleanup';
|
|
16
|
+
import { InitLibraryGeneratorSchema } from './schema';
|
|
17
|
+
|
|
18
|
+
export async function coerceProjects(tree: Tree, options: InitLibraryGeneratorSchema) {
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const defaultOptions = GetDefaultGeneratorOptions<Partial<AngularLibraryGeneratorSchema>>(
|
|
22
|
+
tree, '@nx/angular:library');
|
|
23
|
+
const tags = (
|
|
24
|
+
defaultOptions.tags ?? ''
|
|
25
|
+
).split(',').map(tag => tag.trim());
|
|
26
|
+
tags.push('angular');
|
|
27
|
+
tags.push('ngx');
|
|
28
|
+
defaultOptions.publishable ??= false;
|
|
29
|
+
defaultOptions.buildable ??= false;
|
|
30
|
+
defaultOptions.skipFormat ??= false;
|
|
31
|
+
defaultOptions.simpleName ??= false;
|
|
32
|
+
defaultOptions.addModuleSpec ??= false;
|
|
33
|
+
defaultOptions.skipPackageJson ??= false;
|
|
34
|
+
defaultOptions.skipPackageJson ??= false;
|
|
35
|
+
defaultOptions.routing ??= false;
|
|
36
|
+
defaultOptions.lazy ??= false;
|
|
37
|
+
defaultOptions.unitTestRunner ??= 'jest' as any;
|
|
38
|
+
defaultOptions.strict ??= true;
|
|
39
|
+
defaultOptions.linter ??= 'eslint' as any;
|
|
40
|
+
defaultOptions.standaloneConfig ??= true;
|
|
41
|
+
defaultOptions.setParserOptionsProject ??= false;
|
|
42
|
+
defaultOptions.addTailwind ??= false;
|
|
43
|
+
defaultOptions.skipModule ??= false;
|
|
44
|
+
defaultOptions.standalone ??= true;
|
|
45
|
+
defaultOptions.displayBlock ??= false;
|
|
46
|
+
defaultOptions.inlineStyle ??= false;
|
|
47
|
+
defaultOptions.inlineTemplate ??= false;
|
|
48
|
+
defaultOptions.changeDetection ??= 'OnPush';
|
|
49
|
+
defaultOptions.style ??= 'scss';
|
|
50
|
+
defaultOptions.skipTests ??= false;
|
|
51
|
+
defaultOptions.skipSelector ??= false;
|
|
52
|
+
defaultOptions.flat ??= false;
|
|
53
|
+
|
|
54
|
+
const scope = GetWorkspaceScope(tree);
|
|
55
|
+
|
|
56
|
+
for (const projectName of options.projects ?? []) {
|
|
57
|
+
|
|
58
|
+
if (!HasProject(tree, projectName)) {
|
|
59
|
+
|
|
60
|
+
let directory = projectName;
|
|
61
|
+
let customOptions: Partial<AngularLibraryGeneratorSchema> = {};
|
|
62
|
+
if (typeof options.coerce === 'object') {
|
|
63
|
+
customOptions = options.coerce;
|
|
64
|
+
if (options.coerce.directory) {
|
|
65
|
+
if (options.projects?.length === 1) {
|
|
66
|
+
directory = options.coerce.directory;
|
|
67
|
+
} else {
|
|
68
|
+
directory = join(options.coerce.directory, projectName);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const importPath = `${ scope }/${ projectName }`;
|
|
74
|
+
|
|
75
|
+
const schema: AngularLibraryGeneratorSchema = {
|
|
76
|
+
...defaultOptions,
|
|
77
|
+
...customOptions,
|
|
78
|
+
directory,
|
|
79
|
+
importPath,
|
|
80
|
+
name: projectName,
|
|
81
|
+
tags: tags.join(','),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
await angularLibraryGenerator(tree, schema);
|
|
85
|
+
|
|
86
|
+
if (options.targets?.indexExport === false) {
|
|
87
|
+
UpdateTsConfigJson(tree, tsConfig => {
|
|
88
|
+
tsConfig.compilerOptions ??= {};
|
|
89
|
+
tsConfig.compilerOptions.paths ??= {};
|
|
90
|
+
if (tsConfig.compilerOptions.paths[importPath]) {
|
|
91
|
+
delete tsConfig.compilerOptions.paths[importPath];
|
|
92
|
+
}
|
|
93
|
+
tsConfig.compilerOptions.paths[`${ importPath }/*`] = [
|
|
94
|
+
`${ GetProjectSourceRoot(
|
|
95
|
+
tree, projectName) }/lib/*`,
|
|
96
|
+
];
|
|
97
|
+
}, { infix: 'base' });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (schema.buildable && !schema.publishable) {
|
|
101
|
+
UpdateProjectPackageJson(tree, packageJson => {
|
|
102
|
+
packageJson.private = true;
|
|
103
|
+
}, { projectName });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
cleanup(tree, GetProject(tree, projectName), projectName);
|
|
107
|
+
|
|
108
|
+
if (schema.buildable || schema.publishable) {
|
|
109
|
+
await FixDependencies(tree, { projects: [ projectName ] });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
} else {
|
|
113
|
+
console.log(`project ${ projectName } already exists`.grey);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import {
|
|
6
|
+
CoerceFile,
|
|
7
|
+
CoerceIgnorePattern,
|
|
8
|
+
} from '@rxap/workspace-utilities';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
import { hasTailwindConfig } from './has-tailwind-config';
|
|
11
|
+
|
|
12
|
+
export function coerceTailwindThemeScss(tree: Tree, project: ProjectConfiguration) {
|
|
13
|
+
|
|
14
|
+
if (!project.sourceRoot) {
|
|
15
|
+
throw new Error(`The project ${ project.name } has no sourceRoot`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const themeScssPath = join(project.sourceRoot, 'styles/theme.scss');
|
|
19
|
+
if (hasTailwindConfig(tree, project)) {
|
|
20
|
+
CoerceFile(tree, themeScssPath, '@tailwind components;\n@tailwind utilities;');
|
|
21
|
+
CoerceIgnorePattern(tree, join(project.root, '.gitignore'), [ 'theme.css' ]);
|
|
22
|
+
} else {
|
|
23
|
+
if (tree.exists(themeScssPath)) {
|
|
24
|
+
tree.delete(themeScssPath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import {
|
|
6
|
+
CoerceFile,
|
|
7
|
+
IsRxapRepository,
|
|
8
|
+
} from '@rxap/workspace-utilities';
|
|
9
|
+
import { relative } from 'path';
|
|
10
|
+
|
|
11
|
+
export function extendAngularSpecificEslint(tree: Tree, project: ProjectConfiguration) {
|
|
12
|
+
|
|
13
|
+
if (!IsRxapRepository(tree)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const projectRoot = project.root;
|
|
18
|
+
|
|
19
|
+
const relativeToAngularRoot = relative(projectRoot, 'packages/angular');
|
|
20
|
+
|
|
21
|
+
const extendsPath = relativeToAngularRoot + '/.eslintrc.json';
|
|
22
|
+
|
|
23
|
+
const eslintConfigFilaPath = `${ projectRoot }/.eslintrc.json`;
|
|
24
|
+
const defaultEslintConfig = {
|
|
25
|
+
extends: [ extendsPath ],
|
|
26
|
+
ignorePatterns: [ '!**/*' ],
|
|
27
|
+
overrides: [],
|
|
28
|
+
};
|
|
29
|
+
CoerceFile(tree, eslintConfigFilaPath, JSON.stringify(defaultEslintConfig, null, 2));
|
|
30
|
+
|
|
31
|
+
const eslintConfig = JSON.parse(tree.read(eslintConfigFilaPath)!.toString('utf-8'));
|
|
32
|
+
|
|
33
|
+
if (eslintConfig.extends[0] !== extendsPath) {
|
|
34
|
+
CoerceFile(tree, eslintConfigFilaPath, JSON.stringify(defaultEslintConfig, null, 2), true);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatFiles,
|
|
3
|
+
getProjects,
|
|
4
|
+
ProjectConfiguration,
|
|
5
|
+
Tree,
|
|
6
|
+
} from '@nx/devkit';
|
|
7
|
+
import { CoerceArrayItems } from '@rxap/utilities';
|
|
8
|
+
import {
|
|
9
|
+
GenerateSerializedSchematicFile,
|
|
10
|
+
GetProjectRoot,
|
|
11
|
+
SkipNonAngularProject,
|
|
12
|
+
SkipNonLibraryProject,
|
|
13
|
+
} from '@rxap/workspace-utilities';
|
|
14
|
+
import { coerceProjects } from './coerce-projects';
|
|
15
|
+
import { initProject } from './init-project';
|
|
16
|
+
import { initWorkspace } from './init-workspace';
|
|
17
|
+
import { InitLibraryGeneratorSchema } from './schema';
|
|
18
|
+
|
|
19
|
+
function skipProject(tree: Tree, options: InitLibraryGeneratorSchema, project: ProjectConfiguration, projectName: string) {
|
|
20
|
+
|
|
21
|
+
if (options.project === projectName) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (SkipNonAngularProject(tree, options, project, projectName)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (SkipNonLibraryProject(tree, options, project, projectName)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return false;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function initLibraryGenerator(
|
|
38
|
+
tree: Tree,
|
|
39
|
+
options: InitLibraryGeneratorSchema,
|
|
40
|
+
) {
|
|
41
|
+
options.project ??= undefined;
|
|
42
|
+
options.projects ??= [];
|
|
43
|
+
if (options.project) {
|
|
44
|
+
CoerceArrayItems(options.projects, [options.project]);
|
|
45
|
+
}
|
|
46
|
+
if (options.indexExport !== undefined) {
|
|
47
|
+
options.targets ??= {};
|
|
48
|
+
options.targets.indexExport = options.indexExport;
|
|
49
|
+
delete options.indexExport;
|
|
50
|
+
}
|
|
51
|
+
console.log('angular library init generator:', options);
|
|
52
|
+
|
|
53
|
+
await initWorkspace(tree, options);
|
|
54
|
+
|
|
55
|
+
if (options.coerce) {
|
|
56
|
+
await coerceProjects(tree, options);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!options.skipProjects) {
|
|
60
|
+
|
|
61
|
+
for (const [ projectName, project ] of getProjects(tree).entries()) {
|
|
62
|
+
|
|
63
|
+
if (skipProject(tree, options, project, projectName)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
GenerateSerializedSchematicFile(
|
|
68
|
+
tree,
|
|
69
|
+
GetProjectRoot(tree, projectName),
|
|
70
|
+
'@rxap/plugin-angular',
|
|
71
|
+
'init-library',
|
|
72
|
+
options,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
await initProject(tree, projectName, project, options);
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!options.skipFormat) {
|
|
82
|
+
await formatFiles(tree);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default initLibraryGenerator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
export function hasIndexScss(tree: Tree, project: ProjectConfiguration) {
|
|
8
|
+
|
|
9
|
+
if (!project.sourceRoot) {
|
|
10
|
+
throw new Error(`The project ${ project.name } has no sourceRoot`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return tree.exists(join(project.sourceRoot, '_index.scss'));
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
updateProjectConfiguration,
|
|
5
|
+
} from '@nx/devkit';
|
|
6
|
+
import { LibraryInitProject } from '@rxap/plugin-library';
|
|
7
|
+
import {
|
|
8
|
+
CoerceIgnorePattern,
|
|
9
|
+
IsBuildable,
|
|
10
|
+
} from '@rxap/workspace-utilities';
|
|
11
|
+
import { join } from 'path';
|
|
12
|
+
import { coerceTestSetup } from '../../lib/coerce-test-setup';
|
|
13
|
+
import { checkIfSecondaryEntrypointIncludeInTheTsConfig } from './check-if-secondary-entrypoint-include-in-the-ts-config';
|
|
14
|
+
import { cleanup } from './cleanup';
|
|
15
|
+
import { coerceTailwindThemeScss } from './coerce-tailwind-theme-scss';
|
|
16
|
+
import { extendAngularSpecificEslint } from './extend-angular-specific-eslint';
|
|
17
|
+
import { InitLibraryGeneratorSchema } from './schema';
|
|
18
|
+
import { updatePackageJson } from './update-package-json';
|
|
19
|
+
import { updateProjectNgPackageConfiguration } from './update-project-ng-package-configuration';
|
|
20
|
+
import { updateTsConfig } from './update-ts-config';
|
|
21
|
+
|
|
22
|
+
export async function initProject(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitLibraryGeneratorSchema) {
|
|
23
|
+
console.log(`init angular library project: ${ projectName }`);
|
|
24
|
+
|
|
25
|
+
await LibraryInitProject(tree, projectName, project, options);
|
|
26
|
+
|
|
27
|
+
cleanup(tree, project, projectName);
|
|
28
|
+
updatePackageJson(tree, projectName, project);
|
|
29
|
+
|
|
30
|
+
checkIfSecondaryEntrypointIncludeInTheTsConfig(tree, project);
|
|
31
|
+
|
|
32
|
+
if (IsBuildable(project)) {
|
|
33
|
+
updateProjectNgPackageConfiguration(tree, project);
|
|
34
|
+
coerceTailwindThemeScss(tree, project);
|
|
35
|
+
}
|
|
36
|
+
extendAngularSpecificEslint(tree, project);
|
|
37
|
+
updateTsConfig(tree, projectName);
|
|
38
|
+
coerceTestSetup(tree, projectName);
|
|
39
|
+
|
|
40
|
+
updateProjectConfiguration(tree, projectName, project);
|
|
41
|
+
|
|
42
|
+
CoerceIgnorePattern(tree, join(project.root, '.eslintignore'), [
|
|
43
|
+
'.angular',
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { LibraryInitWorkspace } from '@rxap/plugin-library';
|
|
3
|
+
import {
|
|
4
|
+
AddPackageJsonDependency,
|
|
5
|
+
IsAlreadyExecuted,
|
|
6
|
+
} from '@rxap/workspace-utilities';
|
|
7
|
+
import { ANGULAR_VERSION } from '../../lib/angular-version';
|
|
8
|
+
import { InitLibraryGeneratorSchema } from './schema';
|
|
9
|
+
import { setGeneralTargetDefaults } from './set-general-target-defaults';
|
|
10
|
+
|
|
11
|
+
export async function initWorkspace(tree: Tree, options: InitLibraryGeneratorSchema) {
|
|
12
|
+
|
|
13
|
+
if (IsAlreadyExecuted([__dirname, __filename, 'initWorkspace'].join('_'))) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
console.log('init angular library workspace');
|
|
18
|
+
|
|
19
|
+
// must always be added as some rxap components use the i18n tag
|
|
20
|
+
await AddPackageJsonDependency(tree, '@angular/localize', ANGULAR_VERSION, { soft: true });
|
|
21
|
+
|
|
22
|
+
LibraryInitWorkspace(tree, options);
|
|
23
|
+
|
|
24
|
+
setGeneralTargetDefaults(tree);
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
readJson,
|
|
4
|
+
Tree,
|
|
5
|
+
writeJson,
|
|
6
|
+
} from '@nx/devkit';
|
|
7
|
+
import { Assets } from '@rxap/workspace-utilities';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
|
|
10
|
+
interface NgPackageJson {
|
|
11
|
+
assets: Assets;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function readNgPackageJson(tree: Tree, project: ProjectConfiguration): NgPackageJson {
|
|
15
|
+
if (!tree.exists(join(project.root, 'ng-package.json'))) {
|
|
16
|
+
throw new Error(`The project ${ project.name } has no ng-package.json file.`);
|
|
17
|
+
}
|
|
18
|
+
return readJson(tree, join(project.root, 'ng-package.json'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function writeNgPackageJson(tree: Tree, project: ProjectConfiguration, ngPackageJson: NgPackageJson) {
|
|
22
|
+
writeJson(tree, join(project.root, 'ng-package.json'), ngPackageJson);
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readNxJson,
|
|
3
|
+
Tree,
|
|
4
|
+
updateNxJson,
|
|
5
|
+
} from '@nx/devkit';
|
|
6
|
+
import {
|
|
7
|
+
CoerceTarget,
|
|
8
|
+
CoerceTargetDefaultsDependency,
|
|
9
|
+
IsRxapRepository,
|
|
10
|
+
Strategy,
|
|
11
|
+
} from '@rxap/workspace-utilities';
|
|
12
|
+
|
|
13
|
+
export function setGeneralTargetDefaults(tree: Tree) {
|
|
14
|
+
const nxJson = readNxJson(tree);
|
|
15
|
+
|
|
16
|
+
if (!nxJson) {
|
|
17
|
+
throw new Error('No nx.json found');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
CoerceTarget(nxJson, '@nx/angular:ng-packagr-lite', {
|
|
21
|
+
dependsOn: [
|
|
22
|
+
'index-export', '^index-export', '^build', 'check-version', 'build-tailwind', 'check-ng-package'
|
|
23
|
+
],
|
|
24
|
+
inputs: [ "production", "^production" ]
|
|
25
|
+
}, Strategy.OVERWRITE);
|
|
26
|
+
if (IsRxapRepository(tree)) {
|
|
27
|
+
CoerceTargetDefaultsDependency(nxJson, 'build-tailwind', {
|
|
28
|
+
target: 'build',
|
|
29
|
+
projects: [
|
|
30
|
+
'browser-tailwind',
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
updateNxJson(tree, nxJson);
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import {
|
|
6
|
+
GetMajorAngularVersion,
|
|
7
|
+
IsPublishable,
|
|
8
|
+
UpdateProjectPackageJson,
|
|
9
|
+
} from '@rxap/workspace-utilities';
|
|
10
|
+
import { gte } from 'semver';
|
|
11
|
+
|
|
12
|
+
export function updatePackageJson(
|
|
13
|
+
tree: Tree,
|
|
14
|
+
projectName: string,
|
|
15
|
+
project: ProjectConfiguration,
|
|
16
|
+
) {
|
|
17
|
+
if (IsPublishable(tree, project)) {
|
|
18
|
+
UpdateProjectPackageJson(tree, packageJson => {
|
|
19
|
+
const majorAngularVersion = GetMajorAngularVersion(tree);
|
|
20
|
+
const version = `${ majorAngularVersion }.0.0-dev.0`;
|
|
21
|
+
if (!packageJson.version || gte(version, packageJson.version)) {
|
|
22
|
+
packageJson.version = version;
|
|
23
|
+
}
|
|
24
|
+
}, { projectName });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProjectConfiguration,
|
|
3
|
+
Tree,
|
|
4
|
+
} from '@nx/devkit';
|
|
5
|
+
import {
|
|
6
|
+
CoerceAssets,
|
|
7
|
+
RemoveAssets,
|
|
8
|
+
ReadNgPackageJson,
|
|
9
|
+
WriteNgPackageJson,
|
|
10
|
+
} from '@rxap/workspace-utilities';
|
|
11
|
+
import { hasIndexScss } from './has-index-scss';
|
|
12
|
+
import { hasTailwindConfig } from './has-tailwind-config';
|
|
13
|
+
import {
|
|
14
|
+
readNgPackageJson,
|
|
15
|
+
writeNgPackageJson,
|
|
16
|
+
} from './ng-package-json';
|
|
17
|
+
|
|
18
|
+
export function updateProjectNgPackageConfiguration(tree: Tree, project: ProjectConfiguration) {
|
|
19
|
+
const ngPackageJson = ReadNgPackageJson(tree, project);
|
|
20
|
+
|
|
21
|
+
ngPackageJson.assets ??= [];
|
|
22
|
+
|
|
23
|
+
CoerceAssets(ngPackageJson.assets, [ 'README.md', 'CHANGELOG.md', 'LICENSE', 'LICENSE.md' ]);
|
|
24
|
+
|
|
25
|
+
const assetThemes = {
|
|
26
|
+
input: '.',
|
|
27
|
+
glob: '**/*.theme.scss',
|
|
28
|
+
output: '.',
|
|
29
|
+
};
|
|
30
|
+
const assetIndex = {
|
|
31
|
+
input: '.',
|
|
32
|
+
glob: '_index.scss',
|
|
33
|
+
output: '.',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const assetStyles = 'theme.css';
|
|
37
|
+
|
|
38
|
+
if (hasIndexScss(tree, project)) {
|
|
39
|
+
CoerceAssets(ngPackageJson.assets, [ assetThemes, assetIndex ]);
|
|
40
|
+
} else {
|
|
41
|
+
RemoveAssets(ngPackageJson.assets, [ assetThemes, assetIndex ]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (hasTailwindConfig(tree, project)) {
|
|
45
|
+
CoerceAssets(ngPackageJson.assets, [ assetStyles ]);
|
|
46
|
+
} else {
|
|
47
|
+
RemoveAssets(ngPackageJson.assets, [ assetStyles ]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
WriteNgPackageJson(tree, project, ngPackageJson);
|
|
51
|
+
}
|