From 09b56a01a7cb92861b10e937030de913cc3bfe32 Mon Sep 17 00:00:00 2001 From: cipchk Date: Fri, 7 Jul 2023 19:51:50 +0800 Subject: [PATCH 1/2] fix(cli): remove `stylelint-config-prettier` - see: https://github.com/prettier/stylelint-config-prettier#stylelint-config-prettier --- .stylelintrc | 3 +- package.json | 1 - schematics/application/index.ts | 1 - .../ng-update/upgrade-rules/v16/index.spec.ts | 12 ++++++++ .../ng-update/upgrade-rules/v16/index.ts | 30 +++++++++++++++++-- schematics/test.ts | 2 +- scripts/ci/utils.sh | 1 - 7 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.stylelintrc b/.stylelintrc index ff59152b4..f28f86dff 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -1,8 +1,7 @@ { "extends": [ "stylelint-config-standard", - "stylelint-config-rational-order", - "stylelint-config-prettier" + "stylelint-config-rational-order" ], "customSyntax": "postcss-less", "plugins": [ diff --git a/package.json b/package.json index 0e357108d..411d42e9b 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,6 @@ "readline-sync": "^1.4.10", "stream": "0.0.2", "stylelint": "^15.6.2", - "stylelint-config-prettier": "^9.0.5", "stylelint-config-rational-order": "^0.1.2", "stylelint-config-standard": "^33.0.0", "stylelint-declaration-block-no-ignored-properties": "^2.7.0", diff --git a/schematics/application/index.ts b/schematics/application/index.ts index 6476145a5..0354684c2 100644 --- a/schematics/application/index.ts +++ b/schematics/application/index.ts @@ -187,7 +187,6 @@ function addCodeStylesToPackageJson(): Rule { `lint-staged@DEP-0.0.0-PLACEHOLDER`, `prettier@DEP-0.0.0-PLACEHOLDER`, `stylelint@DEP-0.0.0-PLACEHOLDER`, - `stylelint-config-prettier@DEP-0.0.0-PLACEHOLDER`, `stylelint-config-rational-order@DEP-0.0.0-PLACEHOLDER`, `stylelint-config-standard@DEP-0.0.0-PLACEHOLDER`, `stylelint-declaration-block-no-ignored-properties@DEP-0.0.0-PLACEHOLDER`, diff --git a/schematics/ng-update/upgrade-rules/v16/index.spec.ts b/schematics/ng-update/upgrade-rules/v16/index.spec.ts index 8b356c77a..20ad1a413 100644 --- a/schematics/ng-update/upgrade-rules/v16/index.spec.ts +++ b/schematics/ng-update/upgrade-rules/v16/index.spec.ts @@ -1,3 +1,4 @@ +import { JsonObject } from '@angular-devkit/core'; import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; import { createAlainApp, migrationCollection } from '../../../utils/testing'; @@ -17,4 +18,15 @@ describe('Schematic: ng-update: v16Rule', () => { runner.logger.subscribe(e => logs.push(e.message)); await runner.runSchematic('migration-v16', {}, tree); } + + it('should be remote stylelint-config-prettier', async () => { + const filePath = 'package.json'; + let json = tree.readJson(filePath) as JsonObject; + const key = 'stylelint-config-prettier'; + json['devDependencies']!![key] = '*'; + tree.overwrite(filePath, JSON.stringify(json)); + await runMigration(); + const migrationPackageJson = tree.readJson(filePath) as JsonObject; + expect(migrationPackageJson['devDependencies']!![key]).not.toBeDefined(); + }); }); diff --git a/schematics/ng-update/upgrade-rules/v16/index.ts b/schematics/ng-update/upgrade-rules/v16/index.ts index 9f7e63a8b..f7c97cbdc 100644 --- a/schematics/ng-update/upgrade-rules/v16/index.ts +++ b/schematics/ng-update/upgrade-rules/v16/index.ts @@ -2,9 +2,35 @@ import { chain, Rule, SchematicContext, Tree } from '@angular-devkit/schematics' import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; import * as colors from 'ansi-colors'; -import { logStart } from '../../../utils'; +import { logStart, readJSON, readPackage, writeJSON, writePackage } from '../../../utils'; import { UpgradeMainVersions } from '../../../utils/versions'; +function removeStylelintConfigPrettier(): Rule { + return (tree: Tree, context: SchematicContext) => { + const key = `stylelint-config-prettier`; + context.logger.info(colors.yellow(` ${key} have been deprecated`)); + // remove package.json + const packageJson = readPackage(tree); + if (packageJson != null) { + delete packageJson.devDependencies[key]; + writePackage(tree, packageJson); + } + + // remote .stylelintrc + const stylelintrcFilePath = '.stylelintrc'; + const stylelintrcjson = readJSON(tree, stylelintrcFilePath); + if (stylelintrcjson != null) { + if (!Array.isArray(stylelintrcjson.extends)) stylelintrcjson.extends = []; + const arr: string[] = stylelintrcjson.extends; + const idx = arr.indexOf(key); + if (idx !== -1) { + arr.splice(idx, 1); + writeJSON(tree, stylelintrcFilePath, stylelintrcjson); + } + } + }; +} + function finished(): Rule { return (_tree: Tree, context: SchematicContext) => { context.addTask(new NodePackageInstallTask()); @@ -21,6 +47,6 @@ export function v16Rule(): Rule { return async (tree: Tree, context: SchematicContext) => { logStart(context, `Upgrade @delon/* version number`); UpgradeMainVersions(tree); - return chain([finished()]); + return chain([removeStylelintConfigPrettier(), finished()]); }; } diff --git a/schematics/test.ts b/schematics/test.ts index e0e06cfca..a7ec22ddf 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/ng-add/index.spec.ts`; +const files = `schematics/ng-update/upgrade-rules/v16/index.spec.ts`; const tests = glob.sync(files).map(p => relative(projectBaseDir, p)); diff --git a/scripts/ci/utils.sh b/scripts/ci/utils.sh index 544b9465e..e837a12a4 100644 --- a/scripts/ci/utils.sh +++ b/scripts/ci/utils.sh @@ -18,7 +18,6 @@ DEPENDENCIES=$(node -p " 'ajv', 'ajv-formats', 'screenfull', - 'stylelint-config-prettier', 'stylelint-config-rational-order', 'stylelint-config-standard', 'stylelint-declaration-block-no-ignored-properties', From 5a0e1165790afef9c50e31821f27cf0687c4323e Mon Sep 17 00:00:00 2001 From: cipchk Date: Fri, 7 Jul 2023 19:56:58 +0800 Subject: [PATCH 2/2] chore: fix styles --- .stylelintrc | 1 - packages/abc/page-header/style/index.less | 5 +++++ packages/abc/page-header/style/rtl.less | 2 ++ packages/form/src/style/index.less | 3 +++ packages/theme/default.less | 1 - packages/theme/layout-blank/style/index.less | 1 - packages/theme/layout-default/style/_aside.less | 1 + packages/theme/layout-default/style/_layout.less | 1 + packages/theme/layout-default/style/fix/_sidebar-nav.less | 1 + packages/theme/layout-default/style/index.less | 6 +++--- packages/theme/layout-default/style/widgets/_user.less | 1 + packages/theme/system/antd/_drawer.less | 8 ++++++++ packages/theme/system/antd/index.less | 1 - 13 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.stylelintrc b/.stylelintrc index f28f86dff..6df3c741f 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -52,7 +52,6 @@ } ], "no-invalid-double-slash-comments": null, - "indentation": [ 2 ], "import-notation": "string", "media-feature-range-notation": "prefix" } diff --git a/packages/abc/page-header/style/index.less b/packages/abc/page-header/style/index.less index e22643303..2dde785df 100644 --- a/packages/abc/page-header/style/index.less +++ b/packages/abc/page-header/style/index.less @@ -97,16 +97,19 @@ min-width: 242px; margin-left: 88px; } + @media screen and (max-width: @screen-xl) { &__extra { margin-left: 44px; } } + @media screen and (max-width: @screen-lg) { &__extra { margin-left: 20px; } } + @media screen and (max-width: @screen-md) { &__row { display: block; @@ -118,11 +121,13 @@ margin-left: 0; } } + @media screen and (max-width: @screen-sm) { &__detail { display: block; } } + @media screen and (max-width: @screen-xs) { &__action { .@{ant-prefix}-btn-group, diff --git a/packages/abc/page-header/style/rtl.less b/packages/abc/page-header/style/rtl.less index bd3765d35..3ca79e5b8 100644 --- a/packages/abc/page-header/style/rtl.less +++ b/packages/abc/page-header/style/rtl.less @@ -22,12 +22,14 @@ margin-right: 88px; margin-left: 0; } + @media screen and (max-width: @screen-xl) { &__extra { margin-right: 44px; margin-left: 0; } } + @media screen and (max-width: @screen-lg) { &__extra { margin-right: 20px; diff --git a/packages/form/src/style/index.less b/packages/form/src/style/index.less index fc3d294da..ec9caaa96 100644 --- a/packages/form/src/style/index.less +++ b/packages/form/src/style/index.less @@ -86,6 +86,7 @@ } } } + @media (max-width: @mobile-max) { > .@{ant-prefix}-form-item { > .@{ant-prefix}-form-item-label, @@ -180,6 +181,7 @@ margin-right: 0; } } + @media (max-width: @mobile-max) { @{sf-prefix}__item { display: block; @@ -207,6 +209,7 @@ overflow: hidden; text-overflow: ellipsis; } + @media (max-width: @mobile-max) { .@{ant-prefix}-form-item-label > label { justify-content: flex-start; diff --git a/packages/theme/default.less b/packages/theme/default.less index 0d4363ce0..8a24180e5 100644 --- a/packages/theme/default.less +++ b/packages/theme/default.less @@ -1,5 +1,4 @@ @import './theme-default.less'; - @import './system/index.less'; @import './layout-default/style/index.less'; @import './layout-blank/style/index.less'; diff --git a/packages/theme/layout-blank/style/index.less b/packages/theme/layout-blank/style/index.less index 89e8e7bcf..04b2e2408 100644 --- a/packages/theme/layout-blank/style/index.less +++ b/packages/theme/layout-blank/style/index.less @@ -1,4 +1,3 @@ @import './theme-default.less'; - @import './_layout.less'; @import './fix/index.less'; diff --git a/packages/theme/layout-default/style/_aside.less b/packages/theme/layout-default/style/_aside.less index 3e330c1cb..b80c4e1a3 100644 --- a/packages/theme/layout-default/style/_aside.less +++ b/packages/theme/layout-default/style/_aside.less @@ -98,6 +98,7 @@ left: 0; } } + @media (max-width: @mobile-max) { @{alain-default-prefix}__content { transform: translate3d(-@alain-default-aside-wd, 0, 0); diff --git a/packages/theme/layout-default/style/_layout.less b/packages/theme/layout-default/style/_layout.less index d8df11f2a..f3e7de691 100644 --- a/packages/theme/layout-default/style/_layout.less +++ b/packages/theme/layout-default/style/_layout.less @@ -27,6 +27,7 @@ body { &__unwrap { margin-right: -@alain-default-content-padding; margin-left: -@alain-default-content-padding; + @media (max-width: @mobile-max) { margin-right: 0; margin-left: 0; diff --git a/packages/theme/layout-default/style/fix/_sidebar-nav.less b/packages/theme/layout-default/style/fix/_sidebar-nav.less index 7bf882536..ced9a6cc0 100644 --- a/packages/theme/layout-default/style/fix/_sidebar-nav.less +++ b/packages/theme/layout-default/style/fix/_sidebar-nav.less @@ -285,6 +285,7 @@ left: @layout-gutter * 2; } } + @media (min-width: @mobile-min) { @{alain-default-prefix}__collapsed { @{sidebar-nav-prefix}:not(@{sidebar-nav-prefix}__sub) { diff --git a/packages/theme/layout-default/style/index.less b/packages/theme/layout-default/style/index.less index 3da34c5d4..bb6d629a9 100644 --- a/packages/theme/layout-default/style/index.less +++ b/packages/theme/layout-default/style/index.less @@ -1,11 +1,11 @@ @import './theme-default.less'; - +// Layout @import './_layout.less'; @import './_header.less'; @import './_aside.less'; - +// Widgets @import './_progress-bar.less'; @import './fix/index.less'; @import './widgets/index.less'; - +// Fix @import './_fixed.less'; diff --git a/packages/theme/layout-default/style/widgets/_user.less b/packages/theme/layout-default/style/widgets/_user.less index 454243b4f..f11f8117c 100644 --- a/packages/theme/layout-default/style/widgets/_user.less +++ b/packages/theme/layout-default/style/widgets/_user.less @@ -51,6 +51,7 @@ margin-left: @layout-gutter; } } + @media (min-width: @mobile-min) { @{alain-default-prefix}__collapsed { @{alain-default-prefix}__aside-user { diff --git a/packages/theme/system/antd/_drawer.less b/packages/theme/system/antd/_drawer.less index f34480ba2..1045871c1 100644 --- a/packages/theme/system/antd/_drawer.less +++ b/packages/theme/system/antd/_drawer.less @@ -7,6 +7,7 @@ max-width: @drawer-sm; } } + @media (max-width: (@drawer-sm - 1)) { .drawer-sm { width: 100% !important; @@ -19,6 +20,7 @@ max-width: @drawer-md; } } + @media (max-width: (@drawer-md - 1)) { .drawer-md { width: 100% !important; @@ -31,6 +33,7 @@ max-width: @drawer-lg; } } + @media (max-width: (@drawer-lg - 1)) { .drawer-lg { width: 100% !important; @@ -43,6 +46,7 @@ max-width: @drawer-xl; } } + @media (max-width: (@drawer-xl - 1)) { .drawer-xl { width: 100% !important; @@ -58,6 +62,7 @@ max-height: @drawer-sm-height; } } + @media (max-height: (@drawer-sm-height - 1)) { .drawer-sm { height: 100% !important; @@ -70,6 +75,7 @@ max-height: @drawer-md-height; } } + @media (max-height: (@drawer-md-height - 1)) { .drawer-md { height: 100% !important; @@ -82,6 +88,7 @@ max-height: @drawer-lg-height; } } + @media (max-height: (@drawer-lg-height - 1)) { .drawer-lg { height: 100% !important; @@ -94,6 +101,7 @@ max-height: @drawer-xl-height; } } + @media (max-height: (@drawer-xl-height - 1)) { .drawer-xl { height: 100% !important; diff --git a/packages/theme/system/antd/index.less b/packages/theme/system/antd/index.less index 2d554d702..61745644d 100644 --- a/packages/theme/system/antd/index.less +++ b/packages/theme/system/antd/index.less @@ -1,5 +1,4 @@ @import './_link.less'; - @import './_input-number.less'; @import './_card.less'; @import './_drawer.less';