Skip to content

Commit

Permalink
chore: upgrade dev dependencies (NG-ZORRO#8986)
Browse files Browse the repository at this point in the history
* build: bump detect-port to 2.1.0

* build: remove lodash.debounce

* build: bump jasmine to 5.5.0

* build: bump puppeteer to 24.1.0

* build: bump stylelint to 16.13.0

* build: bump sitemap to 8.0.0

* build: bump parse5 to 7.2.1

* build: bump fs-extra to 11.3.0

* build: bump conventional-changelog to 5.0.0
  • Loading branch information
Laffery authored Jan 21, 2025
1 parent 17d5ca1 commit 6ef72c8
Show file tree
Hide file tree
Showing 9 changed files with 1,616 additions and 1,686 deletions.
2 changes: 1 addition & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["stylelint-config-standard", "stylelint-config-rational-order", "stylelint-config-prettier"],
"extends": ["stylelint-config-standard", "stylelint-config-rational-order"],
"customSyntax": "postcss-less",
"plugins": ["stylelint-declaration-block-no-ignored-properties"],
"rules": {
Expand Down
3,116 changes: 1,521 additions & 1,595 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 16 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "gulp build:release",
"build:lib": "gulp build:library",
"doc": "gulp build:preview",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --pkg components/package.json && node ./scripts/site/replace-scope-prefix.js",
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s --pkg components/package.json && node ./scripts/site/replace-scope-prefix.js",
"format": "prettier --config .prettierrc.js --list-different \\\"component/**/*{.ts}\\\"",
"stage-release": "ts-node --project scripts/release/tsconfig.json scripts/release/release.ts",
"gulp": "gulp",
Expand Down Expand Up @@ -55,45 +55,44 @@
"@angular/router": "^19.1.0",
"@angular/service-worker": "^19.1.0",
"@angular/ssr": "^19.1.0",
"@commitlint/cli": "^13.0.0",
"@commitlint/config-angular": "^13.0.0",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-angular": "^19.0.0",
"@ctrl/tinycolor": "^3.6.0",
"@schematics/angular": "^19.0.2",
"@stackblitz/sdk": "^1.11.0",
"@types/d3": "^6.2.0",
"@types/fs-extra": "^9.0.5",
"@types/fs-extra": "^11.0.4",
"@types/gulp": "^4.0.7",
"@types/jasmine": "^5.0.0",
"@types/less": "^3.0.7",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash": "^4.17.14",
"@types/node": "^20.11.1",
"@types/parse5": "^5.0.3",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"@typescript-eslint/utils": "^8.16.0",
"chalk": "^4.1.0",
"codecov": "^3.8.1",
"conventional-changelog-cli": "^2.1.1",
"conventional-changelog-cli": "^5.0.0",
"cron-parser": "^4.6.0",
"cross-env": "^7.0.3",
"d3": "^6.3.1",
"dagre": "^0.8.5",
"dagre-compound": "^0.0.8",
"detect-port": "^1.3.0",
"detect-port": "^2.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "~9.1.0",
"eslint-plugin-header": "~3.1.1",
"eslint-plugin-import": "~2.25.3",
"eslint-plugin-jsdoc": "~46.8.2",
"eslint-plugin-prefer-arrow": "~1.2.2",
"eslint-plugin-prettier": "~5.0.0",
"fs-extra": "^9.0.1",
"fs-extra": "^11.3.0",
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"html-minifier-terser": "^5.1.1",
"husky": "^9.0.0",
"jasmine": "^5.4.0",
"jasmine-core": "^5.4.0",
"jasmine": "^5.5.0",
"jasmine-core": "^5.5.0",
"jasmine-spec-reporter": "^7.0.0",
"karma": "^6.4.4",
"karma-chrome-launcher": "^3.1.0",
Expand All @@ -108,29 +107,27 @@
"less-plugin-npm-import": "^2.1.0",
"less-vars-to-js": "^1.3.0",
"lint-staged": "^15.0.0",
"lodash.debounce": "^4.0.8",
"marked": "^4.0.10",
"minimist": "^1.2.5",
"monaco-editor": "^0.33.0",
"ng-packagr": "^19.1.0",
"node-prismjs": "^0.1.2",
"parse5": "^6.0.1",
"parse5": "^7.2.1",
"postcss": "^8.2.4",
"prettier": "~3.1.0",
"prismjs": "^1.22.0",
"process": "^0.11.10",
"puppeteer": "^23.9.0",
"puppeteer": "^24.1.0",
"readline-sync": "^1.4.10",
"remark": "^13.0.0",
"resolve-bin": "^0.4.0",
"rxjs": "~7.8.1",
"sitemap": "^4.1.1",
"stylelint": "^14.9.0",
"stylelint-config-prettier": "^9.0.2",
"sitemap": "^8.0.0",
"stylelint": "^16.13.0",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-standard": "^29.0.0",
"stylelint-config-standard": "^37.0.0",
"stylelint-declaration-block-no-ignored-properties": "^2.1.0",
"stylelint-order": "^5.0.0",
"stylelint-order": "^6.0.0",
"terser": "^5.5.1",
"ts-node": "^10.9.1",
"tslib": "^2.0.3",
Expand Down
71 changes: 44 additions & 27 deletions schematics/utils/ng-update/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,41 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { Attribute, DefaultTreeDocument, DefaultTreeElement, parseFragment } from "parse5";
import { DefaultTreeAdapterMap, parseFragment } from 'parse5';

const hasClassName = (node: DefaultTreeElement, className: string): Attribute | undefined => {
return node.attrs?.find?.(attr => attr.name === 'class' && attr.value.indexOf(className) !== -1)
/**
* Get the type of the item in an array.
*/
export type ArrayItem<T> = T extends Array<infer U> ? U : never;

// At the time of writing `parse5` doesn't expose the node interfaces directly, even though
// they're used as return types, but We can still access them through `DefaultTreeAdapterMap`.
export type Element = DefaultTreeAdapterMap['element'];
export type ChildNode = DefaultTreeAdapterMap['childNode'];
export type Attribute = ArrayItem<Element['attrs']>;

const hasClassName = (node: Element, className: string): Attribute | undefined => {
return node.attrs?.find?.(attr => attr.name === 'class' && attr.value.indexOf(className) !== -1);
};

const compareCaseInsensitive = (a: string, b: string): boolean => a?.toLowerCase() === b?.toLowerCase();

export function findElementWithoutStructuralDirective(html: string, tagName: string, directiveName: string, attr: string): number[] {
const document = parseFragment(html, {sourceCodeLocationInfo: true}) as DefaultTreeDocument;
const elements: DefaultTreeElement[] = [];
const document = parseFragment(html, { sourceCodeLocationInfo: true });
const elements: Element[] = [];

const visitNodes = (nodes): void => {
const visitNodes = (nodes: ChildNode[]): void => {
nodes.forEach(node => {
if (node.childNodes && !(node.tagName === 'ng-template' && !!node.attrs.find(a => a.name!.toLowerCase() === directiveName.toLowerCase()))) {
visitNodes(node.childNodes);
if (node['childNodes'] && !(node['tagName'] === 'ng-template' && !!(node as Element).attrs.find(a => compareCaseInsensitive(a.name!, directiveName)))) {
visitNodes(node['childNodes']);
}

if (node.tagName?.toLowerCase() === tagName.toLowerCase() && !!node.attrs.find(a => a.name!.toLowerCase() === attr.toLowerCase()) && !node.attrs.find(a => a.name!.toLowerCase() === `*${directiveName}`.toLowerCase())) {
elements.push(node);
if (compareCaseInsensitive(node['tagName'], tagName)) {
const element = node as Element;
const directive = `*${directiveName}`;
if (!!element.attrs.find(a => compareCaseInsensitive(a.name!, attr)) && !element.attrs.find(a => compareCaseInsensitive(a.name!, directive))) {
elements.push(element);
}
}
});
};
Expand All @@ -29,21 +46,21 @@ export function findElementWithoutStructuralDirective(html: string, tagName: str

return elements
.filter(e => e?.sourceCodeLocation?.startTag)
.map(element => element.sourceCodeLocation.startTag.startOffset)
.map(element => element.sourceCodeLocation.startTag.startOffset);
}

export function findElementWithTag(html: string, tagName: string): number[] {
const document = parseFragment(html, {sourceCodeLocationInfo: true}) as DefaultTreeDocument;
const elements: DefaultTreeElement[] = [];
const document = parseFragment(html, { sourceCodeLocationInfo: true });
const elements: Element[] = [];

const visitNodes = (nodes): void => {
const visitNodes = (nodes: ChildNode[]): void => {
nodes.forEach(node => {
if (node.childNodes) {
visitNodes(node.childNodes);
if (node['childNodes']) {
visitNodes(node['childNodes']);
}

if (node.tagName?.toLowerCase() === tagName.toLowerCase()) {
elements.push(node);
if (compareCaseInsensitive(node['tagName'], tagName)) {
elements.push(node as Element);
}
});
};
Expand All @@ -52,21 +69,21 @@ export function findElementWithTag(html: string, tagName: string): number[] {

return elements
.filter(e => e?.sourceCodeLocation?.startTag)
.map(element => element.sourceCodeLocation.startTag.startOffset)
.map(element => element.sourceCodeLocation.startTag.startOffset);
}

export function findElementWithClassName(html: string, className: string, tagName: string): number[] {
const document = parseFragment(html, {sourceCodeLocationInfo: true}) as DefaultTreeDocument;
const elements: DefaultTreeElement[] = [];
const document = parseFragment(html, { sourceCodeLocationInfo: true });
const elements: Element[] = [];

const visitNodes = (nodes): void => {
const visitNodes = (nodes: ChildNode[]): void => {
nodes.forEach(node => {
if (node.childNodes) {
visitNodes(node.childNodes);
if (node['childNodes']) {
visitNodes(node['childNodes']);
}

if (hasClassName(node, className) && node.tagName?.toLowerCase() === tagName.toLowerCase()) {
elements.push(node);
if (compareCaseInsensitive(node['tagName'], tagName) && hasClassName(node as Element, className)) {
elements.push(node as Element);
}
});
};
Expand All @@ -75,5 +92,5 @@ export function findElementWithClassName(html: string, className: string, tagNam

return elements
.filter(e => e?.sourceCodeLocation?.startTag)
.map(element => element.sourceCodeLocation.attrs.class.startOffset)
.map(element => element.sourceCodeLocation.attrs.class.startOffset);
}
15 changes: 4 additions & 11 deletions scripts/gulp/tasks/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { detect } from 'detect-port';
import * as fs from 'fs-extra';
import { parallel, series, task, watch } from 'gulp';
import { debounce } from 'lodash';
Expand All @@ -14,8 +15,6 @@ import { generate } from '../../prerender/ngsw-config';
import { generateSitemap } from '../../prerender/sitemap';
import { execNodeTask, execTask } from '../util/task-helpers';

const detectPort = require('detect-port');

const siteGenerate = require('../../site/generate-site');
const themeGenerate = require('../../site/generate-theme');

Expand Down Expand Up @@ -55,15 +54,9 @@ task('init:site', async done => {
});

/** Run `ng serve` */
task('serve:site', done => {
detectPort(4200).then((port: number) => {
execNodeTask('@angular/cli', 'ng', [
'serve',
'--port',
port === 4200 ? '4200' : '0',
'--project=ng-zorro-antd-doc'
])(done);
});
task('serve:site', async done => {
const port = await detect(4200);
execNodeTask('@angular/cli', 'ng', ['serve', 'ng-zorro-antd-doc', '--port', port === 4200 ? '4200' : '0'])(done);
});

/** Run `ng build ng-zorro-antd-doc --configuration=production` */
Expand Down
45 changes: 22 additions & 23 deletions scripts/prerender/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { readFileSync, writeFileSync } from 'fs-extra';
import * as sitemap from 'sitemap';
import { readFileSync, createWriteStream } from 'fs-extra';
import { EnumChangefreq, SitemapStream, SitemapItemLoose } from 'sitemap';

import * as os from 'os';
import { resolve } from 'path';

import { buildConfig } from '../build-config';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const priorityMap: any = {
const priorityMap: Record<string, number> = {
'/docs/introduce/en': 1,
'/docs/getting-started/en': 0.8,
'/docs/schematics/en': 0.8,
Expand All @@ -22,13 +21,13 @@ const priorityMap: any = {

const ROUTES = readFileSync(resolve(__dirname, 'route-paths.txt')).toString().split(os.EOL) as string[];

function generateUrls(lang: 'zh' | 'en'): sitemap.ISitemapItemOptionsLoose[] {
function generateUrls(lang: 'zh' | 'en'): SitemapItemLoose[] {
const urls = Array.from(new Set(ROUTES.filter(r => r !== '/').map(r => r.replace(/\/(zh|en)$/, ''))));
return urls.map((r: string) => {
const url = `${r}/${lang}`;
return {
url,
changefreq: sitemap.EnumChangefreq.HOURLY,
changefreq: EnumChangefreq.HOURLY,
priority: priorityMap[url] || 0.6,
lastmodrealtime: true,
lastmodISO: new Date().toISOString(),
Expand All @@ -41,21 +40,21 @@ function generateUrls(lang: 'zh' | 'en'): sitemap.ISitemapItemOptionsLoose[] {
});
}

export function generateSitemap(): void {
const sitemapInstance = sitemap.createSitemap({
hostname: 'https://ng.ant.design',
cacheTime: 600000,
urls: [
{
url: '/',
changefreq: sitemap.EnumChangefreq.HOURLY,
priority: 1,
lastmodrealtime: true,
lastmodISO: new Date().toISOString()
},
...generateUrls('en'),
...generateUrls('zh')
]
});
writeFileSync(resolve(`${buildConfig.outputDir}/browser`, 'sitemap.xml'), sitemapInstance.toString(true));
export function generateSitemap(hostname = 'https://ng.ant.design'): void {
const sms = new SitemapStream({ hostname });
sms.pipe(createWriteStream(resolve(`${buildConfig.outputDir}/browser`, 'sitemap.xml')));

const urls: SitemapItemLoose[] = [
{
url: '/',
changefreq: EnumChangefreq.HOURLY,
priority: 1,
lastmodrealtime: true,
lastmodISO: new Date().toISOString()
},
...generateUrls('en'),
...generateUrls('zh')
];
urls.forEach(url => sms.write(url));
sms.end();
}
6 changes: 2 additions & 4 deletions scripts/release/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ function getUpstreamRemoteName(): string | null {
const output = spawnSync('git', ['remote', 'show'], {
encoding: 'utf-8'
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const names: string[] = (output.stdout as any).split('\n').map((e: string) => e.trim());
// eslint-disable-next-line @typescript-eslint/prefer-for-of
const names: string[] = (output.stdout as string).split('\n').map((e: string) => e.trim());
for (let i = 0; i < names.length; i++) {
const url = getRemoteUrl(names[i]);
if (url.search(/github\.com(\/|:)NG-ZORRO\/ng-zorro-antd/) !== -1) {
Expand Down Expand Up @@ -115,7 +113,7 @@ function bumpVersion(): void {
const zorroVersionPath = path.join(buildConfig.componentsDir, 'version', 'version.ts');
const currentVersion = packageJson.version;
let versionNumberValid = false;
let version;
let version: string;

while (!versionNumberValid) {
version = read.question(`${bgYellow.black('Please input the new version:')} `);
Expand Down
6 changes: 3 additions & 3 deletions scripts/site/replace-scope-prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const path = require('path');

const changelogPath = path.resolve(__dirname, `../../CHANGELOG.md`);

async function replace(path) {
const content = await fs.readFile(path, 'utf8');
function replace(path) {
const content = fs.readFileSync(path, 'utf8');
const replaced = content
.replace(/\*\*\w+:(?!\*\*)/g, '**')
.replace(/\*\s\*\*\s/g, '* **');
await fs.outputFile(path, replaced);
fs.writeFileSync(path, replaced);
}

replace(changelogPath);
6 changes: 3 additions & 3 deletions scripts/site/utils/get-meta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const YFM = require('yaml-front-matter');
const {parse} = require('marked');
const parse5 = require('parse5');
const { parse } = require('marked');
const { parseFragment } = require('parse5');

/**
*
Expand Down Expand Up @@ -44,7 +44,7 @@ module.exports = function getMeta(file) {
/** @type ComponentIndexDocMeta */
const meta = YFM.loadFront(file);
const content = parse(meta.__content);
const fragment = parse5.parseFragment(content);
const fragment = parseFragment(content);
/** @type DocumentFragment[] */
const paragraphs = [];
findNodeByName(fragment, ['p', 'li'], paragraphs);
Expand Down

0 comments on commit 6ef72c8

Please sign in to comment.