Skip to content

Commit 29f8ecd

Browse files
authored
Merge branch 'master' into state-support-hiergrid-master
2 parents 23785cb + fe3a767 commit 29f8ecd

15 files changed

+853
-472
lines changed

gulpfile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ module.exports.copySchematics = (cb) => {
135135
};
136136

137137
const typedocBuildTheme = (cb) => {
138-
spawnSync(`typedoc`, [TYPEDOC.PROJECT_PATH], { stdio: 'inherit', shell: true });
138+
spawnSync(`typedoc`, [TYPEDOC.PROJECT_PATH,
139+
"--tsconfig",
140+
"tsconfig.base.json"], { stdio: 'inherit', shell: true });
139141
cb();
140142
};
141143
typedocBuildTheme.displayName = 'typedoc-build:theme';
@@ -208,7 +210,9 @@ function typedocBuildDocsJA (cb) {
208210
TYPEDOC.TEMPLATE_STRINGS_PATH,
209211
'--warns',
210212
'--localize',
211-
'jp'], { stdio: 'inherit', shell: true });
213+
'jp',
214+
"--tsconfig",
215+
"tsconfig.base.json"], { stdio: 'inherit', shell: true });
212216

213217
cb();
214218
}
@@ -217,7 +221,9 @@ function typedocBuildDocsEN (cb) {
217221
spawnSync('typedoc', [
218222
TYPEDOC.PROJECT_PATH,
219223
'--localize',
220-
'en'], { stdio: 'inherit', shell: true});
224+
'en',
225+
"--tsconfig",
226+
"tsconfig.base.json"], { stdio: 'inherit', shell: true});
221227

222228
cb();
223229
}

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"build:style": "gulp buildStyle",
2626
"build:migration": "gulp copyMigrations && tsc --listEmittedFiles --project ./projects/igniteui-angular/migrations/tsconfig.json",
2727
"build:schematics": "gulp copySchematics && tsc --listEmittedFiles --project ./projects/igniteui-angular/schematics/tsconfig.json",
28-
"build:docs": "sassdoc projects/igniteui-angular/src/lib/core/styles && gulp typedocBuildTheme",
28+
"build:docs": "sassdoc projects/igniteui-angular/src/lib/core/styles && gulp typedoc-build:theme",
2929
"lint:lib": "ng lint && stylelint \"projects/igniteui-angular/src/lib/core/styles\"",
3030
"typedoc:dev": "gulp typedocServe",
3131
"typedoc-build:export": "gulp exportTypedocJson ",
@@ -93,7 +93,7 @@
9393
"gulp-util": "^3.0.8",
9494
"hammer-simulator": "0.0.1",
9595
"igniteui-sassdoc-theme": "^1.1.2",
96-
"igniteui-typedoc-theme": "^1.3.5",
96+
"igniteui-typedoc-theme": "^1.3.6",
9797
"jasmine": "~3.5.0",
9898
"jasmine-core": "~3.5.0",
9999
"jasmine-spec-reporter": "~5.0.2",
@@ -116,7 +116,7 @@
116116
"themeleon": "^3.0.2",
117117
"ts-node": "~7.0.1",
118118
"tslint": "~6.1.0",
119-
"typedoc": "^0.16.9",
119+
"typedoc": "^0.17.7",
120120
"typedoc-plugin-localization": "^2.2.1",
121121
"typescript": "~3.9.3",
122122
"webpack-sources": "1.3.0"

projects/igniteui-angular/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
7575
"igniteui-trial-watermark": "^1.0.3"
7676
},
7777
"peerDependencies": {
78-
"@angular/common": "^9.0.0",
79-
"@angular/core": "^9.0.0",
80-
"@angular/animations": "^9.0.0",
81-
"@angular/forms": "^9.0.0",
78+
"@angular/common": "^10.0.0",
79+
"@angular/core": "^10.0.0",
80+
"@angular/animations": "^10.0.0",
81+
"@angular/forms": "^10.0.0",
8282
"web-animations-js": "^2.3.2"
8383
},
8484
"igxDevDependencies": {
85-
"@igniteui/angular-schematics": "~9.1.510"
85+
"@igniteui/angular-schematics": "~10.0.600"
8686
},
8787
"ng-update": {
8888
"migrations": "./migrations/migration-collection.json"

projects/igniteui-angular/schematics/ng-add/index.spec.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ describe('ng-add schematics', () => {
2525
polyfills: `${sourceRoot}/polyfills.ts`,
2626
scripts: []
2727
}
28-
}
28+
},
29+
test: {
30+
options: {
31+
main: `${sourceRoot}/test.ts`,
32+
polyfills: `${sourceRoot}/polyfills.ts`,
33+
scripts: []
34+
}
35+
},
2936
}
3037
}
3138
}
@@ -46,6 +53,7 @@ describe('ng-add schematics', () => {
4653
tree.create('/angular.json', JSON.stringify(ngJsonConfig));
4754
tree.create('/package.json', JSON.stringify(pkgJsonConfig));
4855
tree.create(`${sourceRoot}/main.ts`, '// test comment');
56+
tree.create(`${sourceRoot}/test.ts`, '// test comment');
4957
});
5058

5159
it('should create the needed files correctly', () => {
@@ -101,7 +109,7 @@ describe('ng-add schematics', () => {
101109
expect(mainTs).toContain('import \'hammerjs\';');
102110
});
103111

104-
it('should not add hammer.js if it exists in angular.json', async () => {
112+
it('should not add hammer.js if it exists in angular.json build options', async () => {
105113
const workspace = getWorkspace(tree) as any;
106114
const currentProjectName = workspace.defaultProject;
107115
workspace.projects[currentProjectName].architect.build.options.scripts.push('./node_modules/hammerjs/hammer.min.js');
@@ -112,7 +120,25 @@ describe('ng-add schematics', () => {
112120
expect(newContent.split('import \'hammerjs\';\n// test comment').length).toEqual(1);
113121
});
114122

123+
it('should add hammer.js to the test.ts file', async () => {
124+
await runner.runSchematicAsync('ng-add', { normalizeCss: false }, tree).toPromise();
125+
const testTs = tree.read(`${sourceRoot}/test.ts`).toString();
126+
expect(testTs).toContain('import \'hammerjs\';');
127+
});
128+
129+
it('should not add hammer.js if it exists in angular.json test options', async () => {
130+
const workspace = getWorkspace(tree) as any;
131+
const currentProjectName = workspace.defaultProject;
132+
workspace.projects[currentProjectName].architect.test.options.scripts.push('./node_modules/hammerjs/hammer.min.js');
133+
tree.overwrite('angular.json', JSON.stringify(workspace));
134+
await runner.runSchematicAsync('ng-add', { normalizeCss: false }, tree).toPromise();
135+
136+
const testTs = tree.read(`${sourceRoot}/test.ts`).toString();
137+
expect(testTs).toMatch('// test comment');
138+
});
139+
115140
it('should not add hammer.js if it exists in main.ts', async () => {
141+
116142
const mainTsPath = `${sourceRoot}/main.ts`;
117143
const content = tree.read(mainTsPath).toString();
118144
tree.overwrite(mainTsPath, 'import \'hammerjs\';\n' + content);

projects/igniteui-angular/schematics/utils/dependency-handler.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,19 @@ function getTargetedProjectOptions(project: WorkspaceProject<ProjectType>, targe
6060
throw new SchematicsException(`Cannot determine the project's configuration for: ${target}`);
6161
}
6262

63-
export function getConfigFile(project: WorkspaceProject<ProjectType>, option: string): string {
64-
const buildOptions = getTargetedProjectOptions(project, 'build');
65-
if (!buildOptions[option]) {
63+
export function getConfigFile(project: WorkspaceProject<ProjectType>, option: string, configSection: string = 'build'): string {
64+
const options = getTargetedProjectOptions(project, configSection);
65+
if (!options) {
66+
throw new SchematicsException(`Could not find matching ${configSection} section` +
67+
`inside of the workspace config ${project.sourceRoot} `);
68+
}
69+
if (!options[option]) {
6670
throw new SchematicsException(`Could not find the project ${option} file inside of the ` +
67-
`workspace config (${project.sourceRoot})`);
71+
`workspace config ${project.sourceRoot}`);
6872
}
73+
return options[option];
6974

70-
return buildOptions[option];
7175
}
72-
7376
export function overwriteJsonFile(tree: Tree, targetFile: string, data: any) {
7477
tree.overwrite(targetFile, JSON.stringify(data, null, 2) + '\n');
7578
}
@@ -134,6 +137,20 @@ export function getPropertyFromWorkspace(targetProp: string, workspace: any, cur
134137
return null;
135138
}
136139

140+
function addHammerToConfig(project: WorkspaceProject<ProjectType>, tree: Tree, config: string) {
141+
const projectOptions = getTargetedProjectOptions(project, config);
142+
const tsPath = getConfigFile(project, 'main', config);
143+
const hammerImport = 'import \'hammerjs\';\n';
144+
const tsContent = tree.read(tsPath).toString();
145+
// if there are no elements in the architect[config]options.scripts array that contain hammerjs
146+
// and the "main" file does not contain an import with hammerjs
147+
if (!projectOptions.scripts.some(el => el.includes('hammerjs')) && !tsContent.includes(hammerImport)) {
148+
// import hammerjs in the specified by config main file
149+
const mainContents = hammerImport + tsContent;
150+
tree.overwrite(tsPath, mainContents);
151+
}
152+
}
153+
137154
function includeDependencies(pkgJson: any, context: SchematicContext, tree: Tree) {
138155
Object.keys(pkgJson.dependencies).forEach(pkg => {
139156
const version = pkgJson.dependencies[pkg];
@@ -145,20 +162,10 @@ function includeDependencies(pkgJson: any, context: SchematicContext, tree: Tree
145162
case 'hammerjs':
146163
logIncludingDependency(context, pkg, version);
147164
addPackageToPkgJson(tree, pkg, version, entry.target);
148-
149165
const workspace = getWorkspace(tree);
150166
const project = workspace.projects[workspace.defaultProject];
151-
const projectOptions = getTargetedProjectOptions(project, 'build');
152-
const mainTsPath = getConfigFile(project, 'main');
153-
const hammerImport = 'import \'hammerjs\';\n';
154-
const mainTsContent = tree.read(mainTsPath).toString();
155-
// if there are no elements in the architect.build.options.scripts array that contain hammerjs
156-
// and main.ts does not contain an import with hammerjs
157-
if (!projectOptions.scripts.some(el => el.includes('hammerjs')) && !mainTsContent.includes(hammerImport)) {
158-
// import hammerjs in the main.ts file
159-
const contents = hammerImport + mainTsContent;
160-
tree.overwrite(mainTsPath, contents);
161-
}
167+
addHammerToConfig(project, tree, 'build');
168+
addHammerToConfig(project, tree, 'test');
162169
break;
163170
default:
164171
logIncludingDependency(context, pkg, version);

0 commit comments

Comments
 (0)