Skip to content

Commit 58508e3

Browse files
feat: add ng add support for standalone config to NgRx packages (#3881)
1 parent 8cb5795 commit 58508e3

File tree

46 files changed

+775
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+775
-28
lines changed

build/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ export const packages: PackageDescription[] = fs
2020
return false;
2121
}
2222

23-
const hasBuild = fs.existsSync(`${modulesDir}${path}/BUILD`);
23+
if (path.includes('eslint-plugin')) {
24+
return false;
25+
}
26+
27+
const hasBuild = fs.existsSync(`${modulesDir}${path}/tsconfig.build.json`);
2428

2529
return hasBuild;
2630
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'Schematics Core',
4+
preset: '../../jest.preset.js',
5+
coverageDirectory: '../../coverage/modules/schematics-core',
6+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
],
22+
};

modules/component-store/schematics-core/tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"types": ["jest", "node"]
77
},
88
"files": ["test-setup.ts"],
9-
"include": ["**/*.spec.ts", "**/*.d.ts"]
9+
"include": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
1010
}

modules/component-store/schematics-core/utility/project.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import { TargetDefinition } from '@angular-devkit/core/src/workspace';
12
import { getWorkspace } from './config';
2-
import { Tree } from '@angular-devkit/schematics';
3+
import { SchematicsException, Tree } from '@angular-devkit/schematics';
34

45
export interface WorkspaceProject {
56
root: string;
67
projectType: string;
8+
architect: {
9+
[key: string]: TargetDefinition;
10+
};
711
}
812

913
export function getProject(
@@ -52,3 +56,20 @@ export function isLib(
5256

5357
return project.projectType === 'library';
5458
}
59+
60+
export function getProjectMainFile(
61+
host: Tree,
62+
options: { project?: string | undefined; path?: string | undefined }
63+
) {
64+
if (isLib(host, options)) {
65+
throw new SchematicsException(`Invalid project type`);
66+
}
67+
const project = getProject(host, options);
68+
const projectOptions = project.architect['build'].options;
69+
70+
if (!projectOptions?.main) {
71+
throw new SchematicsException(`Could not find the main file`);
72+
}
73+
74+
return projectOptions.main as string;
75+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'Schematics Core',
4+
preset: '../../jest.preset.js',
5+
coverageDirectory: '../../coverage/modules/schematics-core',
6+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
],
22+
};

modules/component/schematics-core/tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"types": ["jest", "node"]
77
},
88
"files": ["test-setup.ts"],
9-
"include": ["**/*.spec.ts", "**/*.d.ts"]
9+
"include": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
1010
}

modules/component/schematics-core/utility/project.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import { TargetDefinition } from '@angular-devkit/core/src/workspace';
12
import { getWorkspace } from './config';
2-
import { Tree } from '@angular-devkit/schematics';
3+
import { SchematicsException, Tree } from '@angular-devkit/schematics';
34

45
export interface WorkspaceProject {
56
root: string;
67
projectType: string;
8+
architect: {
9+
[key: string]: TargetDefinition;
10+
};
711
}
812

913
export function getProject(
@@ -52,3 +56,20 @@ export function isLib(
5256

5357
return project.projectType === 'library';
5458
}
59+
60+
export function getProjectMainFile(
61+
host: Tree,
62+
options: { project?: string | undefined; path?: string | undefined }
63+
) {
64+
if (isLib(host, options)) {
65+
throw new SchematicsException(`Invalid project type`);
66+
}
67+
const project = getProject(host, options);
68+
const projectOptions = project.architect['build'].options;
69+
70+
if (!projectOptions?.main) {
71+
throw new SchematicsException(`Could not find the main file`);
72+
}
73+
74+
return projectOptions.main as string;
75+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'Schematics Core',
4+
preset: '../../jest.preset.js',
5+
coverageDirectory: '../../coverage/modules/schematics-core',
6+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
],
22+
};

modules/data/schematics-core/tsconfig.spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"types": ["jest", "node"]
77
},
88
"files": ["test-setup.ts"],
9-
"include": ["**/*.spec.ts", "**/*.d.ts"]
9+
"include": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
1010
}

modules/data/schematics-core/utility/project.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import { TargetDefinition } from '@angular-devkit/core/src/workspace';
12
import { getWorkspace } from './config';
2-
import { Tree } from '@angular-devkit/schematics';
3+
import { SchematicsException, Tree } from '@angular-devkit/schematics';
34

45
export interface WorkspaceProject {
56
root: string;
67
projectType: string;
8+
architect: {
9+
[key: string]: TargetDefinition;
10+
};
711
}
812

913
export function getProject(
@@ -52,3 +56,20 @@ export function isLib(
5256

5357
return project.projectType === 'library';
5458
}
59+
60+
export function getProjectMainFile(
61+
host: Tree,
62+
options: { project?: string | undefined; path?: string | undefined }
63+
) {
64+
if (isLib(host, options)) {
65+
throw new SchematicsException(`Invalid project type`);
66+
}
67+
const project = getProject(host, options);
68+
const projectOptions = project.architect['build'].options;
69+
70+
if (!projectOptions?.main) {
71+
throw new SchematicsException(`Could not find the main file`);
72+
}
73+
74+
return projectOptions.main as string;
75+
}

0 commit comments

Comments
 (0)