Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies to Angular 10 #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0] - 2021-10-27

### Fixed

- Fix vulnerable dependency reported in [Issue #49](https://github.com/nitayneeman/schematics-utilities/issues/49)

### Changed

- Update dependencies to Angular 10

## [2.0.3] - 2021-04-25

### Fixed
Expand Down
1,015 changes: 635 additions & 380 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "schematics-utilities",
"version": "2.0.3",
"version": "3.0.0",
"author": "Nitay Neeman",
"description": "🛠️ Useful exported utilities for working with Schematics",
"homepage": "https://github.com/nitayneeman/schematics-utilities",
Expand Down Expand Up @@ -34,25 +34,28 @@
"publish:docs": "./scripts/publish-docs.sh",
"test:sanity": "./scripts/test-sanity.sh"
},
"engines": {
"node": ">=10.13"
},
"dependencies": {
"@angular-devkit/core": "^8.3.8",
"@angular-devkit/schematics": "^8.3.8",
"@schematics/angular": "^8.3.8",
"@schematics/update": "^0.803.8",
"rxjs": "^6.4.0",
"typescript": "^3.6.3"
"@angular-devkit/core": "^10.2.3",
"@angular-devkit/schematics": "^10.2.3",
"@schematics/angular": "^10.2.3",
"@schematics/update": "^0.1002.3",
"rxjs": "^6.6.7",
"typescript": "^3.9.10"
},
"optionalDependencies": {
"parse5": "^5.1.0"
"parse5": "^5.1.1"
},
"devDependencies": {
"@angular-devkit/schematics-cli": "^0.803.21",
"@types/jasmine": "^3.4.2",
"@types/node": "^8.0.31",
"husky": "^3.0.8",
"jasmine": "^3.5.0",
"prettier": "^1.18.2",
"@angular-devkit/schematics-cli": "^0.1002.3",
"@types/jasmine": "^3.10.1",
"@types/node": "^10.12.30",
"husky": "^3.1.0",
"jasmine": "^3.10.0",
"prettier": "^1.19.1",
"pretty-quick": "^1.11.1",
"typedoc": "^0.15.0"
"typedoc": "^0.15.8"
}
}
15 changes: 11 additions & 4 deletions src/@schematics/angular/utility/workspace-models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copied from https://github.com/angular/angular-cli/blob/9.1.x/packages/schematics/angular/utility/workspace-models.ts for Angular 10 compatibility.
// Copied from https://github.com/angular/angular-cli/blob/10.2.x/packages/schematics/angular/utility/workspace-models.ts for Angular 10 compatibility.

/**
* @license
Expand All @@ -21,7 +21,8 @@ export enum Builders {
Browser = '@angular-devkit/build-angular:browser',
Karma = '@angular-devkit/build-angular:karma',
TsLint = '@angular-devkit/build-angular:tslint',
NgPackagr = '@angular-devkit/build-ng-packagr:build',
DeprecatedNgPackagr = '@angular-devkit/build-ng-packagr:build',
NgPackagr = '@angular-devkit/build-angular:ng-packagr',
DevServer = '@angular-devkit/build-angular:dev-server',
ExtractI18n = '@angular-devkit/build-angular:extract-i18n',
Protractor = '@angular-devkit/build-angular:protractor'
Expand Down Expand Up @@ -64,7 +65,6 @@ export interface BrowserBuilderOptions extends BrowserBuilderBaseOptions {
maximumWarning?: string;
maximumError?: string;
}[];
es5BrowserSupport?: boolean;
webWorkerTsConfig?: string;
}

Expand All @@ -85,7 +85,14 @@ export interface ServerBuilderOptions {
scripts?: boolean;
styles?: boolean;
};
sourceMap?: boolean;
sourceMap?:
| boolean
| {
scripts?: boolean;
styles?: boolean;
hidden?: boolean;
vendor?: boolean;
};
}

export interface AppShellBuilderOptions {
Expand Down
34 changes: 24 additions & 10 deletions src/angular/project.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
// Copied from https://github.com/angular/angular-cli/blob/9.1.x/packages/schematics/angular/utility/project.ts for Angular 10 compatibility.

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Tree } from '@angular-devkit/schematics';
import {
buildDefaultPath as originalBuildDefaultPath,
getProject as originalGetProject,
isWorkspaceSchema as originalIsWorkspaceSchema,
isWorkspaceProject as originalIsWorkspaceProject
} from '@schematics/angular/utility/project';
import { getWorkspace } from '@schematics/angular/utility/config';
import { ProjectType, WorkspaceProject, WorkspaceSchema } from '@schematics/angular/utility/workspace-models';

/**
* Build a default project path for generating.
* @param project The project to build the path for.
*/
export function buildDefaultPath(project: WorkspaceProject): string {
return originalBuildDefaultPath(project);
const root = project.sourceRoot ? `/${project.sourceRoot}/` : `/${project.root}/src/`;

const projectDirName = project.projectType === ProjectType.Application ? 'app' : 'lib';

return `${root}${projectDirName}`;
}

export function getProject<TProjectType extends ProjectType = ProjectType.Application>(
workspaceOrHost: WorkspaceSchema | Tree,
projectName: string
): WorkspaceProject<TProjectType> {
return originalGetProject(workspaceOrHost, projectName);
const workspace = isWorkspaceSchema(workspaceOrHost) ? workspaceOrHost : getWorkspace(workspaceOrHost);

return workspace.projects[projectName] as WorkspaceProject<TProjectType>;
}

// TODO(hans): change this any to unknown when google3 supports TypeScript 3.0.
// tslint:disable-next-line:no-any
export function isWorkspaceSchema(workspace: any): workspace is WorkspaceSchema {
return originalIsWorkspaceSchema(workspace);
return !!(workspace && (workspace as WorkspaceSchema).projects);
}

// TODO(hans): change this any to unknown when google3 supports TypeScript 3.0.
// tslint:disable-next-line:no-any
export function isWorkspaceProject(project: any): project is WorkspaceProject {
return originalIsWorkspaceProject(project);
return !!(project && (project as WorkspaceProject).projectType);
}
29 changes: 24 additions & 5 deletions src/angular/workspace-models.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copied from https://github.com/angular/angular-cli/blob/10.2.x/packages/schematics/angular/utility/workspace-models.ts for Angular 10 compatibility.

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import { experimental } from '@angular-devkit/core';

export enum ProjectType {
Expand All @@ -11,7 +21,8 @@ export enum Builders {
Browser = '@angular-devkit/build-angular:browser',
Karma = '@angular-devkit/build-angular:karma',
TsLint = '@angular-devkit/build-angular:tslint',
NgPackagr = '@angular-devkit/build-ng-packagr:build',
DeprecatedNgPackagr = '@angular-devkit/build-ng-packagr:build',
NgPackagr = '@angular-devkit/build-angular:ng-packagr',
DevServer = '@angular-devkit/build-angular:dev-server',
ExtractI18n = '@angular-devkit/build-angular:extract-i18n',
Protractor = '@angular-devkit/build-angular:protractor'
Expand All @@ -35,10 +46,12 @@ export interface BrowserBuilderBaseOptions {
sourceMap?: boolean;
}

export type OutputHashing = 'all' | 'media' | 'none' | 'bundles';

export interface BrowserBuilderOptions extends BrowserBuilderBaseOptions {
serviceWorker?: boolean;
optimization?: boolean;
outputHashing?: 'all';
outputHashing?: OutputHashing;
resourcesOutputPath?: string;
extractCss?: boolean;
namedChunks?: boolean;
Expand All @@ -52,7 +65,6 @@ export interface BrowserBuilderOptions extends BrowserBuilderBaseOptions {
maximumWarning?: string;
maximumError?: string;
}[];
es5BrowserSupport?: boolean;
webWorkerTsConfig?: string;
}

Expand All @@ -73,7 +85,14 @@ export interface ServerBuilderOptions {
scripts?: boolean;
styles?: boolean;
};
sourceMap?: boolean;
sourceMap?:
| boolean
| {
scripts?: boolean;
styles?: boolean;
hidden?: boolean;
vendor?: boolean;
};
}

export interface AppShellBuilderOptions {
Expand Down Expand Up @@ -151,7 +170,7 @@ export interface WorkspaceTargets<TProjectType extends ProjectType = ProjectType
e2e?: E2EBuilderTarget;
'app-shell'?: AppShellBuilderTarget;
'extract-i18n'?: ExtractI18nBuilderTarget;
// TODO change this any to unknown when google3 supports TypeScript 3.0.
// TODO(hans): change this any to unknown when google3 supports TypeScript 3.0.
// tslint:disable-next-line:no-any
[key: string]: any;
}
2 changes: 1 addition & 1 deletion src/cdk/utils/ast/ng-module-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function hasNgModuleImport(tree: Tree, modulePath: string, className: str
* Resolves the last identifier that is part of the given expression. This helps resolving
* identifiers of nested property access expressions (e.g. myNamespace.core.NgModule).
*/
function resolveIdentifierOfExpression(expression: ts.Expression): ts.Identifier | null {
function resolveIdentifierOfExpression(expression: ts.Expression): ts.Identifier | ts.PrivateIdentifier | null {
if (ts.isIdentifier(expression)) {
return expression;
} else if (ts.isPropertyAccessExpression(expression)) {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/utils/build-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { InsertChange } from '@schematics/angular/utility/change';
import { getWorkspace } from '@schematics/angular/utility/config';
import { buildRelativePath, findModuleFromOptions } from '@schematics/angular/utility/find-module';
import { parseName } from '@schematics/angular/utility/parse-name';
import { buildDefaultPath } from '@schematics/angular/utility/project';
import { buildDefaultPath } from '@schematics/angular/utility/workspace';
import { validateHtmlSelector, validateName } from '@schematics/angular/utility/validation';
import { readFileSync, statSync } from 'fs';
import { dirname, join, resolve } from 'path';
Expand Down
3 changes: 1 addition & 2 deletions src/package_update/npm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { logging } from '@angular-devkit/core';
import { Observable } from 'rxjs';
import { getNpmPackageJson as originalGetNpmPackageJson } from '@schematics/update/update/npm';

import { NpmRepositoryPackageJson } from './npm-package-json';
Expand All @@ -19,6 +18,6 @@ export function getNpmPackageJson(
usingYarn?: boolean;
verbose?: boolean;
}
): Observable<Partial<NpmRepositoryPackageJson>> {
): Promise<Partial<NpmRepositoryPackageJson>> {
return originalGetNpmPackageJson(packageName, logger, options);
}