Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
Falcon
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Walter Huang
Falcon
Commits
15e8ac01
Commit
15e8ac01
authored
Jun 27, 2025
by
Lin Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: diff the nav info
parent
0f005353
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
3 deletions
+47
-3
diffNavWithDeepDiff.ts
src/detect_section_selector_masters/diffNavWithDeepDiff.ts
+44
-2
helper.ts
src/detect_section_selector_masters/helper.ts
+3
-1
No files found.
src/detect_section_selector_masters/diffNavWithDeepDiff.ts
View file @
15e8ac01
...
@@ -23,6 +23,9 @@ const baselineFile = `${diffBaselineId}_extractNav.json`;
...
@@ -23,6 +23,9 @@ const baselineFile = `${diffBaselineId}_extractNav.json`;
const
baselinePath
=
join
(
srcDir
,
baselineFile
);
const
baselinePath
=
join
(
srcDir
,
baselineFile
);
const
baselineData
=
JSON
.
parse
(
readFileSync
(
baselinePath
,
'utf-8'
));
const
baselineData
=
JSON
.
parse
(
readFileSync
(
baselinePath
,
'utf-8'
));
// Fields to ignore during diff
const
ignoreFields
=
[
'category'
];
// Get all nav files excluding baseline
// Get all nav files excluding baseline
const
allFiles
=
readdirSync
(
srcDir
).
filter
(
f
=>
f
.
endsWith
(
'_extractNav.json'
)
&&
f
!==
baselineFile
);
const
allFiles
=
readdirSync
(
srcDir
).
filter
(
f
=>
f
.
endsWith
(
'_extractNav.json'
)
&&
f
!==
baselineFile
);
...
@@ -32,11 +35,50 @@ allFiles.forEach(file => {
...
@@ -32,11 +35,50 @@ allFiles.forEach(file => {
const
otherData
=
JSON
.
parse
(
readFileSync
(
otherPath
,
'utf-8'
));
const
otherData
=
JSON
.
parse
(
readFileSync
(
otherPath
,
'utf-8'
));
// Compute differences
// Compute differences
const
changes
=
diff
(
baselineData
,
otherData
)
||
[];
const
changes
=
diff
(
baselineData
,
otherData
,
(
path
,
key
)
=>
ignoreFields
.
includes
(
key
))
||
[];
// Convert to semantic format
const
semantic
=
changes
.
map
(
change
=>
{
const
map
:
Record
<
string
,
string
>
=
{
E
:
'修改'
,
N
:
'新增'
,
D
:
'删除'
,
A
:
'数组类型的变更'
};
const
type
=
map
[
change
.
kind
]
||
change
.
kind
;
const
pathStr
=
(
change
.
path
||
[]).
filter
(
seg
=>
typeof
seg
!==
'number'
).
join
(
'.'
);
let
oldV
:
any
,
newV
:
any
;
if
(
change
.
kind
===
'E'
)
{
oldV
=
(
change
as
any
).
lhs
;
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'N'
)
{
oldV
=
(
change
as
any
).
lhs
;
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'D'
)
{
oldV
=
(
change
as
any
).
lhs
;
newV
=
(
change
as
any
).
rhs
;
}
else
if
(
change
.
kind
===
'A'
)
{
oldV
=
(
change
as
any
).
item
.
lhs
;
newV
=
(
change
as
any
).
item
.
rhs
;
}
// Include category context for troubleshooting
let
categoryA
:
any
=
'Not Applicable'
;
let
categoryB
:
any
=
'Not Applicable'
;
if
(
change
.
path
&&
change
.
path
[
0
]
!==
undefined
&&
typeof
change
.
path
[
0
]
===
'number'
)
{
const
idx
=
change
.
path
[
0
]
as
number
;
const
entryA
=
baselineData
[
idx
]
||
{};
const
entryB
=
otherData
[
idx
]
||
{};
categoryA
=
entryA
.
category
||
'Not Applicable'
;
categoryB
=
entryB
.
category
||
'Not Applicable'
;
}
return
{
[
`更改类型:
${
selectedLanguages
[
diffBaselineId
]}
vs
${
selectedLanguages
[
otherId
]}
`
]:
type
,
"字段类型"
:
pathStr
,
[
`模版值:
${
selectedLanguages
[
diffBaselineId
]}
`
]:
oldV
||
'Not Applicable'
,
[
`模版值:
${
selectedLanguages
[
otherId
]}
`
]:
newV
||
'Not Applicable'
,
[
`category:
${
selectedLanguages
[
diffBaselineId
]}
`
]:
categoryA
,
[
`category:
${
selectedLanguages
[
otherId
]}
`
]:
categoryB
};
});
// Write diff output
// Write diff output
const
outFile
=
`
${
selectedLanguages
[
diffBaselineId
]}
_vs_
${
selectedLanguages
[
otherId
]}
_nav_diff.json`
;
const
outFile
=
`
${
selectedLanguages
[
diffBaselineId
]}
_vs_
${
selectedLanguages
[
otherId
]}
_nav_diff.json`
;
const
outPath
=
join
(
outDir
,
outFile
);
const
outPath
=
join
(
outDir
,
outFile
);
writeFileSync
(
outPath
,
JSON
.
stringify
(
changes
,
null
,
2
),
'utf-8'
);
writeFileSync
(
outPath
,
JSON
.
stringify
(
semantic
,
null
,
2
),
'utf-8'
);
console
.
log
(
`✅ Nav diff between
${
diffBaselineId
}
and
${
otherId
}
written to
${
outPath
}
`
);
console
.
log
(
`✅ Nav diff between
${
diffBaselineId
}
and
${
otherId
}
written to
${
outPath
}
`
);
});
});
src/detect_section_selector_masters/helper.ts
View file @
15e8ac01
...
@@ -8,12 +8,14 @@ export const getNavigationInfo = (items, pathArr: string[] = []) => {
...
@@ -8,12 +8,14 @@ export const getNavigationInfo = (items, pathArr: string[] = []) => {
// 构建对象路径
// 构建对象路径
const
currentPathArr
=
[...
pathArr
,
`items[
${
idx
}
]`
];
const
currentPathArr
=
[...
pathArr
,
`items[
${
idx
}
]`
];
const
type
=
item
.
type
;
const
type
=
item
.
type
;
const
category
=
item
.
title
||
'No Applicable'
const
itemsCount
=
item
.
items
?
item
.
items
.
length
:
0
;
const
itemsCount
=
item
.
items
?
item
.
items
.
length
:
0
;
navigationResult
.
push
({
navigationResult
.
push
({
patch
:
currentPathArr
.
join
(
"."
),
patch
:
currentPathArr
.
join
(
"."
),
type
:
type
,
type
:
type
,
itemsCount
:
itemsCount
,
category
,
dropdown_count
:
itemsCount
,
});
});
// 递归处理 dropdown
// 递归处理 dropdown
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment