Skip to content

Commit

Permalink
Update icons and use mtime for versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirik Backer authored and Eirik Backer committed Sep 10, 2018
1 parent 3428c9f commit 61f9f72
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/core-icons.rss
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<generator>Sketch</generator>
<item>
<title>Core Icons</title>
<pubDate>Thu, 06 Sep 2018 06:50:00 GMT</pubDate>
<enclosure url="https://static.nrk.no/core-icons/latest/core-icons.sketch" type="application/octet-stream" sparkle:version="4000000"/>
<pubDate>Mon, 10 Sep 2018 14:38:17 GMT</pubDate>
<enclosure url="https://static.nrk.no/core-icons/latest/core-icons.sketch" type="application/octet-stream" sparkle:version="1536590297714"/>
</item>
</channel>
</rss>
Binary file modified lib/core-icons.sketch
Binary file not shown.
6 changes: 2 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,15 @@ function intro () {
return `'${file.slice(0, -4)}':['${body}',${size[2]},${size[3]}]` // Generate JS instead of JSON to save bytes
})

const coeff = 1000 * 60 * 5 // Round to nearest 5 minutes so RSS date does not change too often
const date = new Date(Math.round(Date.now() / coeff) * coeff)
const semverint = Number(pkg.version.split('.').map((v) => v.padStart(3, '0')).join(''))
const sketch = String(fs.readFileSync('./lib/core-icons.rss'))
const date = new Date(fs.statSync('./lib/core-icons.rss').mtime)
const docs = String(fs.readFileSync('./lib/docs.md'))

fs.writeFileSync('./lib/core-icons.json', JSON.stringify(files))
fs.writeFileSync('./lib/docs.md', docs.replace(/\/major\/\d+/, `/major/${pkg.version.match(/\d+/)}`))
fs.writeFileSync('./lib/core-icons.rss', sketch
.replace(/(<pubDate>)[^<]+/, `$1${date.toUTCString()}`) // Add publish date to sketch
.replace(/(sparkle:version=")[^"]+/, `$1${semverint}`)) // Convert semver to int version number
.replace(/(sparkle:version=")[^"]+/, `$1${date.getTime()}`)) // Use mtime as version

return `var ICONS = {${icons.join(',')}}`
}

0 comments on commit 61f9f72

Please sign in to comment.