From a5fe299112f5549635dea01ad3bdb6bd37e30f2d Mon Sep 17 00:00:00 2001 From: fabriziofff Date: Mon, 30 Aug 2021 15:13:34 +0200 Subject: [PATCH] chore: [IA-209] Update publiccode.yml when a new version of the app is released (#3335) * test * fix * update date * update publiccode.yml * fix * update comments * remove unused import * remove variable --- .versionrc.json | 4 +++ publiccode.yml | 10 +++--- scripts/changelog/publiccode_updater.js | 43 +++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 scripts/changelog/publiccode_updater.js diff --git a/.versionrc.json b/.versionrc.json index 9d1990c09db..679504ff771 100644 --- a/.versionrc.json +++ b/.versionrc.json @@ -28,6 +28,10 @@ { "filename": "android/app/build.gradle", "updater": "scripts/changelog/gradle_updater.js" + }, + { + "filename": "publiccode.yml", + "updater": "scripts/changelog/publiccode_updater.js" } ] diff --git a/publiccode.yml b/publiccode.yml index 0911494482c..d0745ae178b 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -4,11 +4,11 @@ publiccodeYmlVersion: '0.2' name: IO -releaseDate: '2019-05-02' +releaseDate: '2021-08-27' url: 'https://github.com/pagopa/io-app' applicationSuite: IO landingURL: 'https://io.italia.it/' -softwareVersion: 0.1.0 +softwareVersion: 1.33.0-rc.9 developmentStatus: beta softwareType: standalone/mobile roadmap: 'https://io.italia.it/' @@ -20,11 +20,11 @@ categories: maintenance: type: internal contacts: - - name: Federico Feroldi - email: federico.feroldi@pagopa.it + - name: Matteo Boschi + email: matteo.boschi@pagopa.it legal: license: EUPL-1.2 - mainCopyrightOwner: pagoPA SpA + mainCopyrightOwner: PagoPA S.p.A. repoOwner: https://www.pagopa.it/ authorsFile: AUTHORS.md intendedAudience: diff --git a/scripts/changelog/publiccode_updater.js b/scripts/changelog/publiccode_updater.js new file mode 100644 index 00000000000..e7fd207d213 --- /dev/null +++ b/scripts/changelog/publiccode_updater.js @@ -0,0 +1,43 @@ +/** + * This is an updater for the utility "standard-version" that increase the versionName value + * for publiccode.yml file. + * Replace the line: + * softwareVersion: $VERSION + * with the new generated version. + * + * and the line: + * releaseDate: '$DATE' + * with the today date. + * + */ + +const softwareVersionRegex = /(softwareVersion: )(.+)/gm; +const releaseDateRegex = /(releaseDate: ')(.+)(')/gm; + +module.exports.readVersion = function (contents) { + // return the 2nd group of the regex (the version) + return softwareVersionRegex.exec(contents)[2]; +}; + +function replaceReleaseDate(_, version, p1, p2, p3) { + return [p1, version, p3].join(""); +} + +function replaceVersionName(_, version, p1) { + return [p1, version].join(""); +} + +module.exports.writeVersion = function (contents, version) { + // Update version + contents = contents.replace(softwareVersionRegex, (substr, ...args) => + replaceVersionName(substr, version, ...args) + ); + const today = new Date().toISOString().split("T")[0]; + + // update date + contents = contents.replace(releaseDateRegex, (substr, ...args) => + replaceReleaseDate(substr, today, ...args) + ); + + return contents; +};