diff --git a/package.json b/package.json index 9b9b14a3a..333398c68 100644 --- a/package.json +++ b/package.json @@ -57,31 +57,31 @@ "ssr:prerender": "ng run site:prerender" }, "dependencies": { - "@angular/animations": "^15.0.0", - "@angular/common": "^15.0.0", - "@angular/compiler": "^15.0.0", - "@angular/core": "^15.0.0", - "@angular/forms": "^15.0.0", - "@angular/platform-browser": "^15.0.0", - "@angular/platform-browser-dynamic": "^15.0.0", - "@angular/router": "^15.0.0", - "rxjs": "~7.5.0", + "@angular/animations": "^15.1.0", + "@angular/common": "^15.1.0", + "@angular/compiler": "^15.1.0", + "@angular/core": "^15.1.0", + "@angular/forms": "^15.1.0", + "@angular/platform-browser": "^15.1.0", + "@angular/platform-browser-dynamic": "^15.1.0", + "@angular/router": "^15.1.0", + "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.12.0", - "@angular/service-worker": "^15.0.4", - "@angular/platform-server": "^15.0.4", - "@angular/elements": "^15.0.4", + "@angular/service-worker": "^15.1.0", + "@angular/platform-server": "^15.1.0", + "@angular/elements": "^15.1.0", "@antv/data-set": "^0.11.8", "@antv/g2": "^4.2.8", "echarts": "^5.4.1", - "@stackblitz/sdk": "^1.8.1", + "@stackblitz/sdk": "^1.8.2", "codesandbox": "^2.2.3", - "ajv": "^8.11.2", + "ajv": "^8.12.0", "ajv-formats": "^2.1.1", "extend": "^3.0.2", "file-saver": "^2.0.5", "ng-github-button": "^15.0.0", - "ng-zorro-antd": "^15.0.1", + "ng-zorro-antd": "^15.0.3", "ngx-color": "~8.0.3", "ngx-countdown": "^15.0.0", "ngx-highlight-js": "^15.0.0", @@ -90,15 +90,15 @@ "@webcomponents/custom-elements": "^1.5.1", "aos": "^3.0.0-beta.6", "@ng-util/monaco-editor": "^15.0.0", - "@nguniversal/express-engine": "~15.0.0", + "@nguniversal/express-engine": "~15.1.0", "express": "^4.18.2", "isutf8": "^4.0.0", "@github/hotkey": "^2.0.1" }, "devDependencies": { - "@angular-devkit/build-angular": "^15.0.4", - "@angular/cli": "~15.0.4", - "@angular/compiler-cli": "^15.0.0", + "@angular-devkit/build-angular": "^15.1.3", + "@angular/cli": "~15.1.3", + "@angular/compiler-cli": "^15.1.0", "@types/jasmine": "~4.3.0", "jasmine-core": "~4.5.0", "karma": "~6.4.0", @@ -106,12 +106,12 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.0.0", - "typescript": "~4.8.2", + "typescript": "~4.9.4", "codelyzer": "^6.0.2", "jasmine-spec-reporter": "^7.0.0", "protractor": "~7.0.0", "ts-node": "~10.9.1", - "@angular/language-service": "^15.0.4", + "@angular/language-service": "^15.1.0", "@types/jasminewd2": "~2.0.10", "karma-junit-reporter": "^2.0.1", "karma-spec-reporter": "0.0.36", @@ -138,9 +138,9 @@ "mark-twain": "^2.0.3", "mockjs": "^1.1.0", "mustache": "^4.2.0", - "ng-packagr": "^15.0.3", + "ng-packagr": "^15.1.0", "parse5": "^7.1.2", - "prettier": "^2.8.1", + "prettier": "^2.8.3", "readline-sync": "^1.4.10", "stream": "0.0.2", "stylelint": "^14.16.1", @@ -148,7 +148,7 @@ "stylelint-config-rational-order": "^0.1.2", "stylelint-config-standard": "^29.0.0", "stylelint-declaration-block-no-ignored-properties": "^2.6.0", - "stylelint-order": "^5.0.0", + "stylelint-order": "^6.0.1", "source-map-explorer": "^2.5.3", "xlsx": "^0.18.5", "jszip": "^3.10.1", @@ -160,23 +160,23 @@ "ng-alain-sts": "^0.0.2", "ng-alain-plugin-theme": "^15.0.1", "tsconfig-paths": "^4.1.2", - "@nguniversal/builders": "^15.0.0", - "@types/express": "^4.17.15", + "@nguniversal/builders": "^15.1.0", + "@types/express": "^4.17.16", "html-minifier-terser": "^7.1.0", "terser": "^5.16.1", - "@commitlint/cli": "^17.3.0", - "@commitlint/config-angular": "^17.3.0", - "@angular-eslint/builder": "~15.1.0", - "@angular-eslint/eslint-plugin": "~15.1.0", - "@angular-eslint/eslint-plugin-template": "~15.1.0", - "@angular-eslint/schematics": "~15.1.0", - "@angular-eslint/template-parser": "~15.1.0", - "@typescript-eslint/eslint-plugin": "~5.47.1", - "@typescript-eslint/parser": "~5.47.1", - "eslint": "^8.31.0", - "eslint-config-prettier": "~8.5.0", + "@commitlint/cli": "^17.4.2", + "@commitlint/config-angular": "^17.4.2", + "@angular-eslint/builder": "~15.2.0", + "@angular-eslint/eslint-plugin": "~15.2.0", + "@angular-eslint/eslint-plugin-template": "~15.2.0", + "@angular-eslint/schematics": "~15.2.0", + "@angular-eslint/template-parser": "~15.2.0", + "@typescript-eslint/eslint-plugin": "~5.49.0", + "@typescript-eslint/parser": "~5.49.0", + "eslint": "^8.33.0", + "eslint-config-prettier": "~8.6.0", "eslint-plugin-import": "~2.26.0", - "eslint-plugin-jsdoc": "~39.6.4", + "eslint-plugin-jsdoc": "~39.7.4", "eslint-plugin-prefer-arrow": "~1.2.3", "eslint-plugin-prettier": "~4.2.1", "eslint-plugin-deprecation": "~1.3.3", diff --git a/schematics/application/index.ts b/schematics/application/index.ts index b08e33d10..6476145a5 100644 --- a/schematics/application/index.ts +++ b/schematics/application/index.ts @@ -1,4 +1,4 @@ -import { JsonObject, strings } from '@angular-devkit/core'; +import { strings } from '@angular-devkit/core'; import { ProjectDefinition } from '@angular-devkit/core/src/workspace'; import { apply, @@ -14,7 +14,7 @@ import { Tree, url } from '@angular-devkit/schematics'; -import { updateWorkspace } from '@schematics/angular/utility/workspace'; +import { getWorkspace, updateWorkspace } from '@schematics/angular/utility/workspace'; import { getLangData } from '../core/lang.config'; import { @@ -28,9 +28,10 @@ import { addStylePreprocessorOptionsToAllProject, BUILD_TARGET_BUILD, BUILD_TARGET_SERVE, + DEFAULT_WORKSPACE_PATH, getProject, getProjectFromWorkspace, - getProjectTarget, + getProjectName, readContent, readJSON, readPackage, @@ -75,9 +76,35 @@ function fixAngularJson(options: ApplicationOptions): Rule { const serveTarget = p.targets?.get(BUILD_TARGET_SERVE); if (serveTarget.options == null) serveTarget.options = {}; serveTarget.options.proxyConfig = 'proxy.conf.js'; - // 调整budgets - const budgets = (getProjectTarget(p, BUILD_TARGET_BUILD, 'configurations').production as JsonObject) - .budgets as Array<{ + + // // 调整budgets, error in angular 15.1 + // const budgets = (getProjectTarget(p, BUILD_TARGET_BUILD, 'configurations').production as JsonObject) + // .budgets as Array<{ + // type: string; + // maximumWarning: string; + // maximumError: string; + // }>; + // if (budgets && budgets.length > 0) { + // const initial = budgets.find(w => w.type === 'initial'); + // if (initial) { + // initial.maximumWarning = '2mb'; + // initial.maximumError = '3mb'; + // } + // } + + addStylePreprocessorOptionsToAllProject(workspace); + addSchematicCollections(workspace); + }); +} + +/** + * Fix https://github.com/ng-alain/ng-alain/issues/2359 + */ +function fixBrowserBuilderBudgets(options: ApplicationOptions): Rule { + return async (tree: Tree) => { + const projectName = getProjectName(await getWorkspace(tree), options.project); + const json = readJSON(tree, DEFAULT_WORKSPACE_PATH); + const budgets = json.projects[projectName].architect.build.configurations.production.budgets as Array<{ type: string; maximumWarning: string; maximumError: string; @@ -87,12 +114,10 @@ function fixAngularJson(options: ApplicationOptions): Rule { if (initial) { initial.maximumWarning = '2mb'; initial.maximumError = '3mb'; + writeJSON(tree, DEFAULT_WORKSPACE_PATH, json); } } - - addStylePreprocessorOptionsToAllProject(workspace); - addSchematicCollections(workspace); - }); + }; } function addDependenciesToPackageJson(options: ApplicationOptions): Rule { @@ -372,7 +397,8 @@ export default function (options: ApplicationOptions): Rule { addStyle(), fixLang(options), fixVsCode(), - fixAngularJson(options) + fixAngularJson(options), + fixBrowserBuilderBudgets(options) ]); }; } diff --git a/schematics/ng-add/index.spec.ts b/schematics/ng-add/index.spec.ts index 13ab10193..3de67a95a 100644 --- a/schematics/ng-add/index.spec.ts +++ b/schematics/ng-add/index.spec.ts @@ -2,6 +2,7 @@ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/te import * as nodeUtils from '../utils/node'; import { createAlainApp } from '../utils/testing'; +import { DEFAULT_WORKSPACE_PATH } from '../utils/workspace'; describe('Schematic: ng-add', () => { let runner: SchematicTestRunner; @@ -13,6 +14,14 @@ describe('Schematic: ng-add', () => { expect(packageJson.dependencies['@delon/theme']).toBeDefined(); }); + it('#issues-https://github.com/ng-alain/ng-alain/issues/2359', async () => { + ({ runner, tree } = await createAlainApp()); + const json = JSON.parse(tree.readContent(DEFAULT_WORKSPACE_PATH)); + const budgets = json.projects['foo'].architect.build.configurations.production.budgets; + expect(budgets[0].maximumWarning).toBe('2mb'); + expect(budgets[0].maximumError).toBe('3mb'); + }); + it('should throw errr when node version is not valid range', async () => { spyOn(nodeUtils, 'getNodeMajorVersion').and.returnValue(10); try { diff --git a/schematics/ng-add/index.ts b/schematics/ng-add/index.ts index cc9df3d7b..a07ccbf1b 100644 --- a/schematics/ng-add/index.ts +++ b/schematics/ng-add/index.ts @@ -3,7 +3,7 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; import * as colors from 'ansi-colors'; import { Schema as ApplicationOptions } from '../application/schema'; -import { readJSON, readPackage } from '../utils'; +import { DEFAULT_WORKSPACE_PATH, readJSON, readPackage } from '../utils'; import { getNodeMajorVersion } from '../utils/node'; import { Schema as NgAddOptions } from './schema'; @@ -55,7 +55,7 @@ function genRules(options: NgAddOptions): Rule { } function isYarn(tree: Tree): boolean { - return readJSON(tree, '/angular.json')?.cli?.packageManager === 'yarn'; + return readJSON(tree, DEFAULT_WORKSPACE_PATH)?.cli?.packageManager === 'yarn'; } function finished(): Rule { diff --git a/schematics/test.ts b/schematics/test.ts index 51eec886a..e0e06cfca 100644 --- a/schematics/test.ts +++ b/schematics/test.ts @@ -13,7 +13,7 @@ const Jasmine = require('jasmine'); const runner = new Jasmine({ projectBaseDir }); // const files = `schematics/**/*.spec.ts`; -const files = `schematics/sta/index.spec.ts`; +const files = `schematics/ng-add/index.spec.ts`; const tests = glob.sync(files).map(p => relative(projectBaseDir, p)); diff --git a/schematics/utils/workspace.ts b/schematics/utils/workspace.ts index 8c1f12dd2..9619ef451 100644 --- a/schematics/utils/workspace.ts +++ b/schematics/utils/workspace.ts @@ -10,6 +10,7 @@ export const BUILD_TARGET_TEST = 'test'; export const BUILD_TARGET_SERVE = 'serve'; export const BUILD_TARGET_LINT = 'lint'; export const NG_ALAIN_JSON = `ng-alain.json`; +export const DEFAULT_WORKSPACE_PATH = `/angular.json`; export interface NgAlainDefinition { projects?: { [key: string]: NgAlainProjectDefinition }; @@ -19,7 +20,7 @@ export interface NgAlainProjectDefinition { routesRoot?: string; } -function getProjectName(workspace: WorkspaceDefinition, name?: string): string | null { +export function getProjectName(workspace: WorkspaceDefinition, name?: string): string | null { if (name && workspace.projects.has(name)) { return name; }