Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
LuckySwap
interface
Commits
d28a4b34
Unverified
Commit
d28a4b34
authored
May 22, 2023
by
Zach Pomerantz
Committed by
GitHub
May 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: do not attempt to cache i18n:extract (#6616)
parent
f3a80c62
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
59 deletions
+0
-59
action.yml
.github/actions/setup/action.yml
+0
-10
lingui.config.ts
lingui.config.ts
+0
-49
No files found.
.github/actions/setup/action.yml
View file @
d28a4b34
...
...
@@ -53,16 +53,6 @@ runs:
shell
:
bash
# Messages are extracted from source.
# A record of source file content hashes is maintained in node_modules/.cache/lingui by a custom extractor.
# Messages are always extracted, but extraction may rely on the custom extractor's loaded cache.
-
uses
:
actions/cache@v3
id
:
i18n-extract-cache
with
:
path
:
|
src/locales/en-US.po
node_modules/.cache
key
:
${{ runner.os }}-i18n-extract-${{ github.run_id }}
restore-keys
:
${{ runner.os }}-i18n-extract-
-
run
:
yarn i18n:extract
shell
:
bash
...
...
lingui.config.ts
View file @
d28a4b34
import
{
default
as
babelExtractor
}
from
'
@lingui/cli/api/extractors/babel
'
import
{
createHash
}
from
'
crypto
'
import
{
mkdirSync
,
readFileSync
,
writeFileSync
}
from
'
fs
'
import
*
as
path
from
'
path
'
import
*
as
pkgUp
from
'
pkg-up
'
// pkg-up is used by lingui, and is used here to match lingui's own extractors
/**
* A custom caching extractor for CI.
* Falls back to the babelExtractor in a non-CI (ie local) environment.
* Caches a file's latest extracted content's hash, and skips re-extracting if it is already present in the cache.
* In CI, re-extracting files takes over one minute, so this is a significant savings.
*/
const
cachingExtractor
:
typeof
babelExtractor
=
{
match
(
filename
:
string
)
{
return
babelExtractor
.
match
(
filename
)
},
extract
(
filename
:
string
,
code
:
string
,
...
options
:
unknown
[])
{
if
(
!
process
.
env
.
CI
)
return
babelExtractor
.
extract
(
filename
,
code
,
...
options
)
// This runs from node_modules/@lingui/conf, so we need to back out to the root.
const
pkg
=
pkgUp
.
sync
()
if
(
!
pkg
)
throw
new
Error
(
'
No root found
'
)
const
root
=
path
.
dirname
(
pkg
)
const
filePath
=
path
.
join
(
root
,
filename
)
const
file
=
readFileSync
(
filePath
)
const
hash
=
createHash
(
'
sha256
'
).
update
(
file
).
digest
(
'
hex
'
)
const
cacheRoot
=
path
.
join
(
root
,
'
node_modules/.cache/lingui
'
)
mkdirSync
(
cacheRoot
,
{
recursive
:
true
})
const
cachePath
=
path
.
join
(
cacheRoot
,
filename
.
replace
(
/
\/
/g
,
'
-
'
))
// Only read from the cache if we're not performing a "clean" run, as a clean run must re-extract from all
// files to ensure that obsolete messages are removed.
if
(
!
process
.
argv
.
includes
(
'
--clean
'
))
{
try
{
const
cache
=
readFileSync
(
cachePath
,
'
utf8
'
)
if
(
cache
===
hash
)
return
}
catch
(
e
)
{
// It should not be considered an error if there is no cache file.
}
}
writeFileSync
(
cachePath
,
hash
)
return
babelExtractor
.
extract
(
filename
,
code
,
...
options
)
},
}
const
linguiConfig
=
{
catalogs
:
[
{
...
...
@@ -108,7 +60,6 @@ const linguiConfig = {
runtimeConfigModule
:
[
'
@lingui/core
'
,
'
i18n
'
],
sourceLocale
:
'
en-US
'
,
pseudoLocale
:
'
pseudo
'
,
extractors
:
[
cachingExtractor
],
}
export
default
linguiConfig
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