Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
testcenter-frontend
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IQB
discontinued
testcenter-frontend
Commits
38ea71c7
Commit
38ea71c7
authored
4 years ago
by
mechtelm
Browse files
Options
Downloads
Patches
Plain Diff
script added to list used custom text keys
parent
fd7c78cf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scripts/findCustomTexts.js
+53
-0
53 additions, 0 deletions
src/scripts/findCustomTexts.js
with
53 additions
and
0 deletions
src/scripts/findCustomTexts.js
0 → 100644
+
53
−
0
View file @
38ea71c7
// analysis of source code (html, ts):
// listing of all used keys for customText
const
fs
=
require
(
"
fs
"
);
let
foundKeys
=
{};
let
foundSourceFiles
=
[];
function
analyse
(
fileName
,
isHtml
)
{
const
fileContent
=
fs
.
readFileSync
(
fileName
,
'
utf8
'
).
toString
();
const
searchPattern
=
isHtml
?
/
\|\s
*customtext:
\s
*'
\w
+'/g
:
/
\.
getCustomText
\s
*
\(\s
*'
\w
+'
\s
*
\)
/g
;
const
matches
=
fileContent
.
match
(
searchPattern
);
if
(
matches
)
{
foundSourceFiles
.
push
(
fileName
);
for
(
let
i
=
0
;
i
<
matches
.
length
;
i
++
)
{
const
posStart
=
matches
[
i
].
indexOf
(
"
'
"
);
const
posEnd
=
matches
[
i
].
lastIndexOf
(
"
'
"
);
const
foundKey
=
matches
[
i
].
substr
(
posStart
+
1
,
posEnd
-
posStart
-
1
);
if
(
foundKeys
[
foundKey
])
{
foundKeys
[
foundKey
]
+=
1
;
}
else
{
foundKeys
[
foundKey
]
=
1
;
}
}
}
}
function
takeFolder
(
sourceFolder
)
{
const
dirEntries
=
fs
.
readdirSync
(
sourceFolder
);
for
(
let
i
=
0
;
i
<
dirEntries
.
length
;
i
++
)
{
const
fullObjectName
=
sourceFolder
+
'
/
'
+
dirEntries
[
i
];
const
stats
=
fs
.
statSync
(
fullObjectName
);
if
(
stats
.
isDirectory
())
{
takeFolder
(
fullObjectName
);
}
else
if
(
stats
.
isFile
())
{
const
dotPos
=
fullObjectName
.
lastIndexOf
(
'
.
'
);
if
(
dotPos
>
0
)
{
const
fileExtension
=
fullObjectName
.
substr
(
dotPos
+
1
);
if
(
fileExtension
.
toUpperCase
()
===
'
TS
'
)
{
analyse
(
fullObjectName
,
false
);
}
else
if
(
fileExtension
.
toUpperCase
()
===
'
HTML
'
)
{
analyse
(
fullObjectName
,
true
);
}
}
}
}
}
takeFolder
(
'
../app
'
);
console
.
log
(
foundKeys
);
console
.
log
(
foundSourceFiles
);
console
.
log
(
'
done.
'
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment