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
2066486e
Commit
2066486e
authored
Jun 26, 2025
by
Lin Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: judge whether has change
parent
d2d753dd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
7 deletions
+38
-7
diffWithDeepDiff.ts
src/detect_section_selector_masters/diffWithDeepDiff.ts
+5
-4
index.ts
src/detect_section_selector_masters/index.ts
+0
-1
sendDiffToGoogleSheets.ts
...detect_section_selector_masters/sendDiffToGoogleSheets.ts
+1
-1
sendDiffToSlack.ts
src/detect_section_selector_masters/sendDiffToSlack.ts
+2
-1
sendNotifySlack.ts
src/detect_section_selector_masters/sendNotifySlack.ts
+30
-0
No files found.
src/detect_section_selector_masters/diffWithDeepDiff.ts
View file @
2066486e
...
...
@@ -4,18 +4,19 @@ import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
import
{
join
}
from
'path'
;
import
{
section_selectors
,
sectionSelectorLanguages
,
ai_section_selectors
,
aiSectionSelectorsLanguages
,
diffBaselineId
}
from
'../constant/section_selectors'
;
const
useAiSelectors
=
process
.
env
.
USE_AI_SELECTORS
===
'true'
;
// Directory containing JSON outputs to compare
const
srcDir
=
'src/detect_section_selector_masters/extractOutput'
;
// Directory to write diff results
const
outDir
=
'src/detect_section_selector_masters/diffWithBaseline'
;
const
outDir
=
useAiSelectors
?
'src/detect_section_selector_masters/diffAIWithBaseline'
:
'src/detect_section_selector_masters/diffWithBaseline'
;
// Remove existing
diffWithBaseline
folder if it exists to start fresh
// Remove existing folder if it exists to start fresh
rmSync
(
outDir
,
{
recursive
:
true
,
force
:
true
});
// Ensure output directory exists
mkdirSync
(
outDir
,
{
recursive
:
true
});
const
useAiSelectors
=
process
.
env
.
USE_AI_SELECTORS
===
'true'
;
// 根据环境变量选择使用哪个 selector 数组
const
selectedSelectors
=
useAiSelectors
?
ai_section_selectors
:
section_selectors
;
const
selectedLanguages
=
useAiSelectors
?
aiSectionSelectorsLanguages
:
sectionSelectorLanguages
;
...
...
@@ -30,7 +31,7 @@ const baselineData = JSON.parse(readFileSync(baselinePath, 'utf-8'));
const
ignoreFields
=
[
'category'
,
'pageUid'
,
'pageTitle'
,
'id'
,
'path'
];
selectedSelectors
.
filter
(
id
=>
Number
(
id
)
!==
diffBaselineId
)
.
filter
(
id
=>
Number
(
id
)
!==
Number
(
diffBaselineId
))
// Exclude baseline ID
.
forEach
(
otherId
=>
{
const
otherFile
=
`
${
otherId
}
_extract.json`
;
const
otherPath
=
join
(
srcDir
,
otherFile
);
...
...
src/detect_section_selector_masters/index.ts
View file @
2066486e
...
...
@@ -35,7 +35,6 @@ if (commandMode === 'detect') {
outDir
=
'src/detect_section_selector_masters/extractNavOutput'
}
// Remove existing diffWithBaseline folder if it exists to start fresh
rmSync
(
outDir
,
{
recursive
:
true
,
force
:
true
})
// Ensure output directory exists
...
...
src/detect_section_selector_masters/sendDiffToGoogleSheets.ts
View file @
2066486e
...
...
@@ -15,7 +15,7 @@ async function uploadAllToSheets() {
});
const
sheets
=
google
.
sheets
({
version
:
'v4'
,
auth
});
const
dir
=
join
(
__dirname
,
'diffWithBaseline'
);
const
dir
=
join
(
__dirname
,
useAiSelectors
?
'diffAIWithBaseline'
:
'diffWithBaseline'
);
const
files
=
readdirSync
(
dir
).
filter
(
f
=>
f
.
endsWith
(
'.json'
));
// Fetch existing sheet names
...
...
src/detect_section_selector_masters/sendDiffToSlack.ts
View file @
2066486e
...
...
@@ -3,9 +3,10 @@ import { readdirSync } from 'fs';
import
{
join
}
from
'path'
;
async
function
uploadAll
()
{
const
useAiSelectors
=
process
.
env
.
USE_AI_SELECTORS
===
'true'
;
const
token
=
process
.
env
.
SLACK_BOT_USER_OAUTH_TOKEN
!
;
const
channel
=
process
.
env
.
DESIGN_TEAM_CHANNEL_ID
!
;
const
dir
=
join
(
__dirname
,
'diffWithBaseline'
);
const
dir
=
join
(
__dirname
,
useAiSelectors
?
'diffAIWithBaseline'
:
'diffWithBaseline'
);
const
files
=
readdirSync
(
dir
).
filter
(
f
=>
f
.
endsWith
(
'.json'
));
for
(
const
file
of
files
)
{
...
...
src/detect_section_selector_masters/sendNotifySlack.ts
View file @
2066486e
import
{
sendSlackMessage
}
from
'../clients/slack'
;
import
{
readdirSync
,
readFileSync
}
from
'fs'
;
import
{
join
}
from
'path'
;
async
function
main
()
{
// Scan both diff directories for JSON files, with error handling
const
dirs
=
[
join
(
__dirname
,
'diffWithBaseline'
),
join
(
__dirname
,
'diffAIWithBaseline'
)
];
let
filePaths
:
string
[]
=
[];
dirs
.
forEach
(
dir
=>
{
try
{
const
jsFiles
=
readdirSync
(
dir
).
filter
(
f
=>
f
.
endsWith
(
'.json'
));
jsFiles
.
forEach
(
f
=>
filePaths
.
push
(
join
(
dir
,
f
)));
}
catch
(
e
)
{
console
.
warn
(
`Directory
${
dir
}
not found, skipping.`
);
}
});
// Determine if any diff file contains non-empty array data
const
hasChanges
=
filePaths
.
some
(
fp
=>
{
try
{
const
data
=
JSON
.
parse
(
readFileSync
(
fp
,
'utf-8'
));
return
Array
.
isArray
(
data
)
&&
data
.
length
>
0
;
}
catch
{
return
false
;
}
});
if
(
!
hasChanges
)
{
console
.
log
(
'No changes detected in both diff directories, skipping Slack notification.'
);
process
.
exit
(
0
);
}
const
webhookUrl
=
process
.
env
.
SLACK_WEBHOOK
!
;
const
nonAiUrl
=
`https://docs.google.com/spreadsheets/d/
${
process
.
env
.
GOOGLE_SHEET_ID
}
/edit`
;
const
aiUrl
=
`https://docs.google.com/docs.google.com/spreadsheets/d/
${
process
.
env
.
GOOGLE_SHEET_AI_ID
}
/edit`
;
...
...
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