Skip to content

Commit 6b77cd6

Browse files
committed
Refactor input data zipping
1 parent 0e581e0 commit 6b77cd6

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@
4747
* Add output of zones that share same timekeeping method since 1970
4848
* Add output of zones that share same timekeeping method since the current time
4949
* Add caching of various operations to reuse data from previous calculations
50-
* Add cached data to input data in release files
50+
* Refactor input data output
51+
* Move downloads to dedicated folder
52+
* Add cached data to dedicated folder
53+
* Include root-level files in root of zip file
5154
* Add ability to reuse downloaded OSM timezone comparison data by copying it to the working directory and reusing it on calculation retries
5255
* Refactor README noting new release types
5356
* Note Sponsorship Opportunity

index.js

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,55 @@ function analyzeChangesFromLastRelease (cb) {
15281528
})
15291529
}
15301530

1531+
function assembleAndZipInputData (callback) {
1532+
// since lots of files are at absolute paths, assemble a temporary folder with needed files
1533+
const tempInputFilesDir = path.join(workingDir, 'input-data')
1534+
asynclib.series(
1535+
[
1536+
// remove previous folder
1537+
cb => fs.rm(tempInputFilesDir, { recursive: true }, cb),
1538+
// create it again
1539+
cb => fs.mkdir(tempInputFilesDir, cb),
1540+
// copy necessary files
1541+
copyCb => {
1542+
asynclib.parallel(
1543+
[
1544+
// downloads
1545+
cb => fs.cp(
1546+
downloadsDir,
1547+
path.join(tempInputFilesDir, 'downloads'),
1548+
{ recursive: true },
1549+
cb
1550+
),
1551+
// cache
1552+
cb => fs.cp(
1553+
cacheDir,
1554+
path.join(tempInputFilesDir, 'cache'),
1555+
{ recursive: true },
1556+
cb
1557+
),
1558+
// etc single files (assumes cwd is repo root)
1559+
cb => fs.cp('timezones.json', path.join(tempInputFilesDir, 'timezones.json'), cb),
1560+
cb => fs.cp('osmBoundarySources.json', path.join(tempInputFilesDir, 'osmBoundarySources.json'), cb),
1561+
cb => fs.cp('expectedZoneOverlaps.json', path.join(tempInputFilesDir, 'expectedZoneOverlaps.json'), cb)
1562+
],
1563+
copyCb
1564+
)
1565+
},
1566+
// zip up
1567+
cb => {
1568+
const zipFilepath = path.join(distDir, 'input-data.zip')
1569+
exec(
1570+
`zip -r ${zipFilepath} input-data`,
1571+
{ cwd: workingDir },
1572+
cb
1573+
)
1574+
}
1575+
],
1576+
callback
1577+
)
1578+
}
1579+
15311580
const autoScript = {
15321581
makeCacheDirAndFns: function (cb) {
15331582
overallProgress.beginTask(`Creating downloads dir (${downloadsDir})`)
@@ -1698,11 +1747,7 @@ const autoScript = {
16981747
}],
16991748
zipInputData: ['cleanDownloadFolder', function (results, cb) {
17001749
overallProgress.beginTask('Zipping up input data')
1701-
const zipFilepath = path.join(distDir, 'input-data.zip')
1702-
exec(
1703-
`zip -j ${zipFilepath} ${downloadsDir}/* ${cacheDir}/* timezones.json osmBoundarySources.json expectedZoneOverlaps.json`,
1704-
cb
1705-
)
1750+
assembleAndZipInputData(cb)
17061751
}]
17071752
}
17081753

0 commit comments

Comments
 (0)