@rxap/plugin-angular 20.0.1-dev.11 → 20.0.1-dev.13
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/CHANGELOG.md +8 -0
- package/package.json +16 -3
- package/.eslintignore +0 -6
- package/.eslintrc.json +0 -44
- package/LICENSE +0 -621
- package/README.md.handlebars +0 -115
- package/jest.config.ts +0 -11
- package/project.json +0 -68
- package/schematics.yaml +0 -6
- package/src/application.ts +0 -124
- package/src/executors/check-ng-package/executor.ts +0 -33
- package/src/executors/config/executor.ts +0 -74
- package/src/executors/i18n/executor.ts +0 -198
- package/src/executors/tailwind/executor.ts +0 -34
- package/src/generators/convert-to-buildable-library/generator.ts +0 -110
- package/src/generators/fix-schematic/generator.ts +0 -103
- package/src/generators/fix-schematic/index.ts +0 -5
- package/src/generators/init/coerce-nx-json.ts +0 -72
- package/src/generators/init/generator.ts +0 -28
- package/src/generators/init/index.ts +0 -5
- package/src/generators/init/init-workspace.ts +0 -84
- package/src/generators/init-application/assert-main-statements.ts +0 -74
- package/src/generators/init-application/cleanup.ts +0 -127
- package/src/generators/init-application/coerce-app-config.ts +0 -147
- package/src/generators/init-application/coerce-environment-files.ts +0 -105
- package/src/generators/init-application/coerce-localazy-config-file.ts +0 -26
- package/src/generators/init-application/coerce-project.ts +0 -128
- package/src/generators/init-application/generate-authentication.ts +0 -122
- package/src/generators/init-application/generate-monolithic.spec.ts +0 -45
- package/src/generators/init-application/generate-monolithic.ts +0 -57
- package/src/generators/init-application/generator.ts +0 -356
- package/src/generators/init-application/index.ts +0 -5
- package/src/generators/init-application/link-mfe-remote-with-host.ts +0 -60
- package/src/generators/init-application/project-i18n-configuration.ts +0 -4
- package/src/generators/init-application/update-git-ignore.ts +0 -22
- package/src/generators/init-application/update-main-file.ts +0 -118
- package/src/generators/init-application/update-project-targets.ts +0 -229
- package/src/generators/init-application/update-tags.ts +0 -30
- package/src/generators/init-application/update-target-defaults.ts +0 -43
- package/src/generators/init-application/update-ts-config.ts +0 -31
- package/src/generators/init-component/generator.ts +0 -147
- package/src/generators/init-component/index.ts +0 -5
- package/src/generators/init-feature/generator.ts +0 -77
- package/src/generators/init-feature/index.ts +0 -5
- package/src/generators/init-feature-library/generator.ts +0 -82
- package/src/generators/init-feature-library/index.ts +0 -5
- package/src/generators/init-feature-library/init-project.ts +0 -53
- package/src/generators/init-feature-library/init-workspace.ts +0 -10
- package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.ts +0 -46
- package/src/generators/init-library/cleanup.ts +0 -22
- package/src/generators/init-library/coerce-projects.ts +0 -118
- package/src/generators/init-library/coerce-tailwind-theme-scss.ts +0 -27
- package/src/generators/init-library/extend-angular-specific-eslint.ts +0 -37
- package/src/generators/init-library/generator.ts +0 -87
- package/src/generators/init-library/has-index-scss.ts +0 -14
- package/src/generators/init-library/has-tailwind-config.ts +0 -9
- package/src/generators/init-library/index.ts +0 -5
- package/src/generators/init-library/init-project.ts +0 -46
- package/src/generators/init-library/init-workspace.ts +0 -26
- package/src/generators/init-library/is-ng-packagr-project.ts +0 -9
- package/src/generators/init-library/ng-package-json.ts +0 -23
- package/src/generators/init-library/set-general-target-defaults.ts +0 -36
- package/src/generators/init-library/update-package-json.ts +0 -26
- package/src/generators/init-library/update-project-ng-package-configuration.ts +0 -51
- package/src/generators/init-library/update-ts-config.ts +0 -24
- package/src/generators/schematic/generator.ts +0 -179
- package/src/generators/schematic/index.ts +0 -5
- package/src/i18n.ts +0 -130
- package/src/index.ts +0 -3
- package/src/lib/angular-version.ts +0 -1
- package/src/lib/coerce-cypress-component-testing.ts +0 -113
- package/src/lib/coerce-test-setup.ts +0 -60
- package/src/library.ts +0 -153
- package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.ts +0 -32
- package/src/migrations/update-19-0-0/migration.ts +0 -283
- package/src/test-setup.ts +0 -24
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -15
- package/tsconfig.typedoc.json +0 -5
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
}
|