From 05b09772411189263ab4ba7fce32d68c234e9566 Mon Sep 17 00:00:00 2001 From: Rajat Jaiswal <76243388+anartify@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:08:24 +0530 Subject: [PATCH] NPM automation (#36) Initial support for NPM Automation. This isn't widely used, since most NPM projects will use git tags as well, but helpful for a few projects. Co-authored-by: Hugo van Kemenade * Fix fstrings and remove unused imports * Fix the merge of product config with default config in npm.py and pypi.py If product config is first, default config overrides product config. * Simplify npm.py Co-authored-by: Nemo Co-authored-by: Hugo van Kemenade Co-authored-by: Marc Wrobel --- releases/jhipster.json | 262 +++++++++++++++++++++++++++++++++++++++++ releases/vue.json | 256 ++++++++++++++++++++++++---------------- src/npm.py | 68 +++++++++++ src/pypi.py | 2 +- 4 files changed, 487 insertions(+), 101 deletions(-) create mode 100644 releases/jhipster.json create mode 100644 src/npm.py diff --git a/releases/jhipster.json b/releases/jhipster.json new file mode 100644 index 00000000..8e1de110 --- /dev/null +++ b/releases/jhipster.json @@ -0,0 +1,262 @@ +{ + "0.0.1": "2013-10-21", + "0.0.2": "2013-10-22", + "0.0.3": "2013-10-24", + "0.0.4": "2013-10-25", + "0.0.5": "2013-10-25", + "0.0.6": "2013-10-26", + "0.0.7": "2013-10-27", + "0.0.8": "2013-10-28", + "0.0.9": "2013-10-31", + "0.0.10": "2013-11-01", + "0.0.11": "2013-11-01", + "0.0.12": "2013-11-02", + "0.0.13": "2013-11-03", + "0.0.14": "2013-11-04", + "0.0.15": "2013-11-05", + "0.0.16": "2013-11-06", + "0.0.17": "2013-11-07", + "0.0.18": "2013-11-08", + "0.0.19": "2013-11-08", + "0.0.20": "2013-11-09", + "0.0.21": "2013-11-12", + "0.0.22": "2013-11-14", + "0.0.23": "2013-11-15", + "0.0.26": "2013-11-26", + "0.0.27": "2013-11-26", + "0.0.28": "2013-11-29", + "0.0.29": "2013-11-30", + "0.1.0": "2013-11-30", + "0.2.0": "2013-12-03", + "0.2.1": "2013-12-05", + "0.3.0": "2013-12-07", + "0.3.1": "2013-12-07", + "0.4.0": "2013-12-15", + "0.5.0": "2013-12-17", + "0.5.1": "2013-12-21", + "0.5.2": "2013-12-21", + "0.6.0": "2013-12-23", + "0.6.1": "2013-12-27", + "0.6.2": "2014-01-08", + "0.7.0": "2014-01-13", + "0.7.1": "2014-01-14", + "0.8.0": "2014-01-23", + "0.8.1": "2014-01-24", + "0.8.2": "2014-01-24", + "0.8.3": "2014-01-29", + "0.8.4": "2014-01-30", + "0.9.0": "2014-02-07", + "0.9.1": "2014-02-13", + "0.9.2": "2014-02-13", + "0.9.3": "2014-02-16", + "0.10.0": "2014-02-17", + "0.10.1": "2014-02-18", + "0.11.0": "2014-03-13", + "0.12.0": "2014-03-28", + "0.13.0": "2014-04-10", + "0.14.0": "2014-05-18", + "0.15.0": "2014-05-26", + "0.16.0": "2014-06-02", + "0.17.0": "2014-06-23", + "0.17.1": "2014-06-30", + "0.17.2": "2014-07-01", + "0.18.0": "2014-07-23", + "0.18.1": "2014-07-24", + "1.0.0": "2014-09-01", + "1.1.0": "2014-09-08", + "1.1.1": "2014-09-10", + "1.2.0": "2014-09-21", + "1.2.1": "2014-09-29", + "1.2.2": "2014-10-02", + "1.3.0": "2014-10-07", + "1.4.0": "2014-10-13", + "1.5.0": "2014-10-29", + "1.6.0": "2014-10-31", + "1.7.0": "2014-11-05", + "1.7.1": "2014-11-06", + "1.8.0": "2014-11-09", + "1.8.1": "2014-11-10", + "1.9.0": "2014-11-14", + "1.10.0": "2014-11-26", + "1.10.1": "2014-12-04", + "1.10.2": "2014-12-11", + "2.0.0": "2015-01-12", + "2.1.0": "2015-01-29", + "2.1.1": "2015-01-31", + "2.2.0": "2015-02-12", + "2.3.0": "2015-02-18", + "2.4.0": "2015-02-24", + "2.5.0": "2015-03-01", + "2.5.1": "2015-03-03", + "2.5.2": "2015-03-06", + "2.6.0": "2015-03-10", + "2.7.0": "2015-04-03", + "2.8.0": "2015-04-20", + "2.9.0": "2015-04-24", + "2.9.1": "2015-04-29", + "2.9.2": "2015-04-29", + "2.10.0": "2015-05-07", + "2.10.1": "2015-05-07", + "2.11.0": "2015-05-15", + "2.11.1": "2015-05-19", + "2.12.0": "2015-05-22", + "2.13.0": "2015-05-28", + "2.13.1": "2015-05-29", + "2.14.0": "2015-05-29", + "2.14.1": "2015-05-29", + "2.14.2": "2015-05-31", + "2.15.0": "2015-06-05", + "2.15.1": "2015-06-06", + "2.15.2": "2015-06-07", + "2.16.0": "2015-06-09", + "2.16.1": "2015-06-17", + "2.17.0": "2015-06-30", + "2.18.0": "2015-07-07", + "2.19.0": "2015-07-31", + "2.20.0": "2015-08-25", + "2.21.0": "2015-09-16", + "2.21.1": "2015-09-23", + "2.22.0": "2015-10-06", + "2.23.0": "2015-10-23", + "2.23.1": "2015-11-10", + "2.24.0": "2015-11-20", + "2.25.0": "2015-12-04", + "2.26.0": "2015-12-16", + "2.26.1": "2015-12-17", + "2.26.2": "2015-12-30", + "2.27.0": "2016-01-19", + "2.27.1": "2016-02-23", + "2.27.2": "2016-03-07", + "3.0.0": "2016-03-23", + "3.1.0": "2016-04-20", + "3.2.0": "2016-05-06", + "3.2.1": "2016-05-08", + "3.3.0": "2016-05-13", + "3.4.0": "2016-05-27", + "3.4.1": "2016-06-13", + "3.4.2": "2016-06-19", + "3.5.0": "2016-07-20", + "3.5.1": "2016-07-22", + "3.6.0": "2016-08-17", + "3.6.1": "2016-08-18", + "3.7.0": "2016-09-12", + "3.7.1": "2016-09-16", + "3.8.0": "2016-09-22", + "3.9.0": "2016-10-07", + "3.9.1": "2016-10-10", + "3.10.0": "2016-10-28", + "3.11.0": "2016-11-14", + "3.12.0": "2016-11-30", + "3.12.1": "2016-12-08", + "3.12.2": "2016-12-19", + "4.0.0": "2017-02-02", + "4.0.1": "2017-02-04", + "4.0.2": "2017-02-06", + "4.0.3": "2017-02-13", + "4.0.4": "2017-02-17", + "4.0.5": "2017-02-17", + "4.0.6": "2017-02-21", + "4.0.7": "2017-03-01", + "4.0.8": "2017-03-09", + "4.1.0": "2017-03-20", + "4.1.1": "2017-03-23", + "4.2.0": "2017-04-05", + "4.3.0": "2017-04-13", + "4.4.0": "2017-05-08", + "4.4.1": "2017-05-08", + "4.5.0": "2017-05-20", + "4.5.1": "2017-05-20", + "4.5.2": "2017-05-29", + "4.5.3": "2017-06-09", + "4.5.4": "2017-06-16", + "4.5.5": "2017-06-19", + "4.5.6": "2017-06-23", + "4.6.0": "2017-07-06", + "4.6.1": "2017-07-10", + "4.6.2": "2017-07-19", + "4.7.0": "2017-08-23", + "4.8.0": "2017-09-12", + "4.8.1": "2017-09-13", + "4.8.2": "2017-09-15", + "4.9.0": "2017-09-28", + "4.10.0": "2017-10-17", + "4.10.1": "2017-10-25", + "4.10.2": "2017-10-27", + "4.11.0": "2017-11-24", + "4.11.1": "2017-11-26", + "4.12.0": "2017-12-08", + "4.13.0": "2017-12-14", + "4.13.1": "2017-12-27", + "4.13.2": "2018-01-04", + "4.13.3": "2018-01-09", + "4.14.0": "2018-01-30", + "4.14.1": "2018-02-27", + "4.14.2": "2018-04-06", + "4.14.3": "2018-04-10", + "4.14.4": "2018-05-11", + "4.14.5": "2018-06-19", + "5.0.0": "2018-06-20", + "5.0.1": "2018-06-23", + "5.0.2": "2018-07-05", + "5.1.0": "2018-07-12", + "5.2.0": "2018-08-13", + "5.2.1": "2018-08-16", + "5.3.0": "2018-09-03", + "5.3.1": "2018-09-05", + "5.3.2": "2018-09-17", + "5.3.3": "2018-09-17", + "5.3.4": "2018-09-17", + "5.4.0": "2018-10-03", + "5.4.1": "2018-10-04", + "5.4.2": "2018-10-07", + "5.5.0": "2018-10-16", + "5.6.0": "2018-11-02", + "5.6.1": "2018-11-05", + "5.7.0": "2018-11-13", + "5.7.1": "2018-12-14", + "5.7.2": "2018-12-21", + "5.8.0": "2019-01-25", + "5.8.1": "2019-01-29", + "5.8.2": "2019-02-28", + "6.0.0": "2019-05-02", + "6.0.1": "2019-05-10", + "6.1.0": "2019-06-11", + "6.1.1": "2019-06-21", + "6.1.2": "2019-06-23", + "6.2.0": "2019-08-01", + "6.3.0": "2019-09-13", + "6.3.1": "2019-09-20", + "6.4.0": "2019-10-10", + "6.4.1": "2019-10-11", + "6.5.0": "2019-11-10", + "6.5.1": "2019-11-19", + "6.6.0": "2019-12-22", + "6.7.0": "2020-02-06", + "6.7.1": "2020-02-12", + "6.8.0": "2020-03-08", + "6.9.0": "2020-05-17", + "6.9.1": "2020-06-01", + "6.10.0": "2020-06-28", + "6.10.1": "2020-07-04", + "6.10.2": "2020-09-20", + "6.10.3": "2020-09-20", + "6.10.4": "2020-10-18", + "6.10.5": "2020-11-07", + "7.0.0": "2021-03-21", + "7.0.1": "2021-04-02", + "7.1.0": "2021-06-18", + "7.2.0": "2021-09-14", + "7.3.0": "2021-10-08", + "7.3.1": "2021-10-19", + "7.4.0": "2021-11-19", + "7.4.1": "2021-12-03", + "7.5.0": "2022-01-02", + "7.6.0": "2022-01-23", + "7.7.0": "2022-02-27", + "7.8.0": "2022-04-01", + "7.8.1": "2022-04-07", + "7.9.0": "2022-07-31", + "7.9.1": "2022-08-03", + "7.9.2": "2022-08-03", + "7.9.3": "2022-09-02" +} \ No newline at end of file diff --git a/releases/vue.json b/releases/vue.json index 8209b6d9..97fa4070 100644 --- a/releases/vue.json +++ b/releases/vue.json @@ -1,77 +1,70 @@ { - "3.0.0": "2020-09-18", - "3.0.1": "2020-10-15", - "3.0.10": "2021-03-30", - "3.0.11": "2021-04-01", - "3.0.2": "2020-10-20", - "3.0.3": "2020-11-25", - "3.0.4": "2020-12-02", - "3.0.5": "2020-12-30", - "3.0.6": "2021-02-24", - "3.0.7": "2021-03-01", - "3.0.8": "2021-03-26", - "3.0.9": "2021-03-27", - "3.1.0": "2021-06-07", - "3.1.1": "2021-06-07", - "3.1.2": "2021-06-22", - "3.1.3": "2021-07-01", - "3.1.4": "2021-07-02", - "3.1.5": "2021-07-16", - "3.2.0": "2021-08-09", - "3.2.1": "2021-08-09", - "3.2.10": "2021-09-07", - "3.2.11": "2021-09-08", - "3.2.12": "2021-09-17", - "3.2.13": "2021-09-21", - "3.2.14": "2021-09-22", - "3.2.15": "2021-09-23", - "3.2.16": "2021-09-23", - "3.2.17": "2021-09-24", - "3.2.18": "2021-09-24", - "3.2.19": "2021-09-25", - "3.2.2": "2021-08-11", - "3.2.20": "2021-10-08", - "3.2.21": "2021-11-02", - "3.2.22": "2021-11-15", - "3.2.23": "2021-11-26", - "3.2.24": "2021-12-06", - "3.2.25": "2021-12-12", - "3.2.26": "2021-12-12", - "3.2.27": "2022-01-16", - "3.2.28": "2022-01-21", - "3.2.29": "2022-01-23", - "3.2.3": "2021-08-16", - "3.2.30": "2022-02-07", - "3.2.31": "2022-02-12", - "3.2.32": "2022-04-12", - "3.2.33": "2022-04-14", - "3.2.34": "2022-05-19", - "3.2.35": "2022-05-21", - "3.2.36": "2022-05-23", - "3.2.37": "2022-06-06", - "3.2.38": "2022-08-30", - "3.2.39": "2022-09-08", - "3.2.4": "2021-08-17", - "3.2.40": "2022-09-28", - "3.2.41": "2022-10-14", - "3.2.42": "2022-11-09", - "3.2.43": "2022-11-09", - "3.2.44": "2022-11-10", - "3.2.45": "2022-11-11", - "3.2.5": "2021-08-24", - "3.2.6": "2021-08-24", - "3.2.7": "2021-09-01", - "3.2.8": "2021-09-02", - "3.2.9": "2021-09-05", - "1.0.0": "2015-10-26", + "0.0.0": "2013-12-07", + "0.6.0": "2013-12-08", + "0.7.0": "2013-12-24", + "0.7.1": "2013-12-24", + "0.7.3": "2014-01-06", + "0.7.4": "2014-01-10", + "0.7.5": "2014-01-13", + "0.7.6": "2014-01-19", + "0.8.0": "2014-01-27", + "0.8.1": "2014-02-02", + "0.8.2": "2014-02-03", + "0.8.3": "2014-02-06", + "0.8.4": "2014-02-09", + "0.8.5": "2014-02-10", + "0.8.6": "2014-02-14", + "0.8.7": "2014-02-20", + "0.8.8": "2014-02-20", + "0.9.0": "2014-02-25", + "0.9.1": "2014-02-25", + "0.9.2": "2014-02-25", + "0.9.3": "2014-03-02", + "0.10.0": "2014-03-23", + "0.10.1": "2014-03-24", + "0.10.2": "2014-03-25", + "0.10.3": "2014-03-26", + "0.10.4": "2014-04-25", + "0.10.5": "2014-06-06", + "0.10.6": "2014-07-29", + "0.11.0": "2014-11-07", + "0.11.1": "2014-12-01", + "0.11.2": "2014-12-02", + "0.11.3": "2014-12-02", + "0.11.4": "2014-12-07", + "0.11.5": "2015-02-05", + "0.11.6": "2015-04-18", + "0.11.7": "2015-04-21", + "0.11.8": "2015-04-21", + "0.11.9": "2015-05-06", + "0.11.10": "2015-05-07", + "0.12.0": "2015-06-12", + "0.12.1": "2015-06-14", + "0.12.2": "2015-06-25", + "0.12.3": "2015-06-25", + "0.12.4": "2015-06-25", + "0.12.5": "2015-07-02", + "0.12.6": "2015-07-05", + "0.12.7": "2015-07-07", + "0.12.8": "2015-07-23", + "0.12.9": "2015-07-31", + "0.12.10": "2015-08-10", + "0.12.11": "2015-08-25", + "0.12.12": "2015-08-26", + "0.12.13": "2015-09-07", + "0.12.14": "2015-09-11", + "0.12.15": "2015-09-19", + "0.12.16": "2015-09-25", + "1.0.0": "2015-10-27", "1.0.1": "2015-10-27", - "1.0.2": "2015-10-28", - "1.0.3": "2015-10-28", + "1.0.2": "2015-10-29", + "1.0.3": "2015-10-29", "1.0.4": "2015-10-31", "1.0.5": "2015-11-05", "1.0.6": "2015-11-05", "1.0.7": "2015-11-06", "1.0.8": "2015-11-12", + "1.0.9": "2015-11-23", "1.0.10": "2015-11-23", "1.0.11": "2015-12-10", "1.0.12": "2015-12-17", @@ -79,8 +72,8 @@ "1.0.14": "2016-01-11", "1.0.15": "2016-01-18", "1.0.16": "2016-01-30", - "1.0.17": "2016-02-28", - "1.0.18": "2016-03-17", + "1.0.17": "2016-02-29", + "1.0.18": "2016-03-18", "1.0.19": "2016-03-25", "1.0.20": "2016-03-26", "1.0.21": "2016-04-07", @@ -91,28 +84,27 @@ "1.0.26": "2016-06-28", "1.0.27": "2016-09-23", "1.0.28": "2016-09-27", - "1.0.9": "2015-11-23", "2.0.0": "2016-09-30", "2.0.1": "2016-09-30", "2.0.2": "2016-10-12", "2.0.3": "2016-10-13", "2.0.4": "2016-11-04", - "2.0.5": "2016-11-04", + "2.0.5": "2016-11-05", "2.0.6": "2016-11-15", "2.0.7": "2016-11-16", - "2.0.8": "2016-11-19", + "2.0.8": "2016-11-20", "2.1.0": "2016-11-22", "2.1.1": "2016-11-23", - "2.1.10": "2017-01-17", "2.1.2": "2016-11-23", - "2.1.3": "2016-11-23", - "2.1.4": "2016-12-01", - "2.1.5": "2016-12-12", + "2.1.3": "2016-11-24", + "2.1.4": "2016-12-02", + "2.1.5": "2016-12-13", "2.1.6": "2016-12-13", "2.1.7": "2016-12-24", "2.1.8": "2016-12-28", "2.1.9": "2017-01-16", - "2.2.0": "2017-02-25", + "2.1.10": "2017-01-17", + "2.2.0": "2017-02-26", "2.2.1": "2017-02-26", "2.2.2": "2017-03-09", "2.2.3": "2017-03-13", @@ -122,15 +114,23 @@ "2.3.0": "2017-04-27", "2.3.1": "2017-05-02", "2.3.2": "2017-05-02", - "2.3.3": "2017-05-10", + "2.3.3": "2017-05-09", "2.3.4": "2017-06-08", "2.4.0": "2017-07-13", "2.4.1": "2017-07-13", "2.4.2": "2017-07-21", "2.4.3": "2017-09-13", "2.4.4": "2017-09-14", - "2.5.0": "2017-10-12", + "2.5.0": "2017-10-13", "2.5.1": "2017-10-13", + "2.5.2": "2017-10-13", + "2.5.3": "2017-11-03", + "2.5.4": "2017-11-16", + "2.5.5": "2017-11-17", + "2.5.6": "2017-11-18", + "2.5.7": "2017-11-20", + "2.5.8": "2017-11-21", + "2.5.9": "2017-11-27", "2.5.10": "2017-12-12", "2.5.11": "2017-12-14", "2.5.12": "2017-12-19", @@ -141,39 +141,82 @@ "2.5.17": "2018-08-01", "2.5.18": "2018-12-07", "2.5.19": "2018-12-09", - "2.5.2": "2017-10-13", "2.5.20": "2018-12-10", "2.5.21": "2018-12-11", "2.5.22": "2019-01-11", - "2.5.3": "2017-11-03", - "2.5.4": "2017-11-16", - "2.5.5": "2017-11-17", - "2.5.6": "2017-11-18", - "2.5.7": "2017-11-20", - "2.5.8": "2017-11-21", - "2.5.9": "2017-11-27", "2.6.0": "2019-02-04", "2.6.1": "2019-02-04", - "2.6.10": "2019-03-20", - "2.6.11": "2019-12-13", - "2.6.12": "2020-08-20", - "2.6.13": "2021-06-01", - "2.6.14": "2021-06-07", - "2.6.2": "2019-02-04", + "2.6.2": "2019-02-05", "2.6.3": "2019-02-06", "2.6.4": "2019-02-08", "2.6.5": "2019-02-11", - "2.6.6": "2019-02-11", + "2.6.6": "2019-02-12", "2.6.7": "2019-02-21", "2.6.8": "2019-03-01", "2.6.9": "2019-03-14", + "2.6.10": "2019-03-20", + "2.6.11": "2019-12-13", + "2.6.12": "2020-08-20", + "3.0.0": "2020-09-18", + "3.0.1": "2020-10-15", + "3.0.2": "2020-10-20", + "3.0.3": "2020-11-25", + "3.0.4": "2020-12-02", + "3.0.5": "2020-12-30", + "3.0.6": "2021-02-24", + "3.0.7": "2021-03-01", + "3.0.8": "2021-03-26", + "3.0.9": "2021-03-27", + "3.0.10": "2021-03-31", + "3.0.11": "2021-04-01", + "2.6.13": "2021-06-01", + "2.6.14": "2021-06-07", + "3.1.0": "2021-06-07", + "3.1.1": "2021-06-07", + "3.1.2": "2021-06-22", + "3.1.3": "2021-07-01", + "3.1.4": "2021-07-02", + "3.1.5": "2021-07-16", + "3.2.0": "2021-08-09", + "3.2.1": "2021-08-09", + "3.2.2": "2021-08-11", + "3.2.3": "2021-08-16", + "3.2.4": "2021-08-17", + "3.2.5": "2021-08-24", + "3.2.6": "2021-08-24", + "3.2.7": "2021-09-01", + "3.2.8": "2021-09-02", + "3.2.9": "2021-09-05", + "3.2.10": "2021-09-07", + "3.2.11": "2021-09-08", + "3.2.12": "2021-09-17", + "3.2.13": "2021-09-21", + "3.2.14": "2021-09-22", + "3.2.15": "2021-09-23", + "3.2.16": "2021-09-23", + "3.2.17": "2021-09-24", + "3.2.18": "2021-09-24", + "3.2.19": "2021-09-25", + "3.2.20": "2021-10-08", + "3.2.21": "2021-11-02", + "3.2.22": "2021-11-15", + "3.2.23": "2021-11-26", + "3.2.24": "2021-12-06", + "3.2.25": "2021-12-12", + "3.2.26": "2021-12-12", + "3.2.27": "2022-01-16", + "3.2.28": "2022-01-21", + "3.2.29": "2022-01-23", + "3.2.30": "2022-02-07", + "3.2.31": "2022-02-12", + "3.2.32": "2022-04-12", + "3.2.33": "2022-04-14", + "3.2.34": "2022-05-19", + "3.2.35": "2022-05-20", + "3.2.36": "2022-05-23", + "3.2.37": "2022-06-06", "2.7.0": "2022-07-01", "2.7.1": "2022-07-04", - "2.7.10": "2022-08-23", - "2.7.11": "2022-10-11", - "2.7.12": "2022-10-12", - "2.7.13": "2022-10-14", - "2.7.14": "2022-11-09", "2.7.2": "2022-07-05", "2.7.3": "2022-07-06", "2.7.4": "2022-07-08", @@ -181,5 +224,18 @@ "2.7.6": "2022-07-15", "2.7.7": "2022-07-16", "2.7.8": "2022-07-22", - "2.7.9": "2022-08-19" + "2.7.9": "2022-08-19", + "2.7.10": "2022-08-23", + "3.2.38": "2022-08-30", + "3.2.39": "2022-09-08", + "3.2.40": "2022-09-28", + "2.7.11": "2022-10-11", + "2.7.12": "2022-10-12", + "2.7.13": "2022-10-14", + "3.2.41": "2022-10-14", + "3.2.42": "2022-11-09", + "2.7.14": "2022-11-09", + "3.2.43": "2022-11-09", + "3.2.44": "2022-11-09", + "3.2.45": "2022-11-11" } \ No newline at end of file diff --git a/src/npm.py b/src/npm.py new file mode 100644 index 00000000..95413ea5 --- /dev/null +++ b/src/npm.py @@ -0,0 +1,68 @@ +from glob import glob +import os +import re +import sys +import json +import frontmatter +import urllib.request + +DEFAULT_TAG_TEMPLATE = ( + "{{major}}{% if minor %}.{{minor}}{% if patch %}.{{patch}}{%endif%}{%endif%}" +) +REGEX = r"^(?:(\d+\.(?:\d+\.)*\d+))$" + + +def fetch_releases(npm_id, regex): + releases = {} + + if not isinstance(regex, list): + regex = [regex] + + url = f"https://registry.npmjs.org/{npm_id}" + with urllib.request.urlopen(url, data=None, timeout=5) as response: + data = json.loads(response.read().decode("utf-8")) + for version in data["time"]: + matches = False + for r in regex: + if re.match(r, version): + matches = True + + release_datetime = data["time"][version] + if matches and release_datetime: + releases[version] = release_datetime.split("T")[0] + print(f"{version}: {releases[version]}") + + return releases + + +def update_releases(product_filter=None): + for product_file in glob("website/products/*.md"): + product_name = os.path.splitext(os.path.basename(product_file))[0] + if product_filter and product_name != product_filter: + continue + + with open(product_file, "r") as f: + data = frontmatter.load(f) + if "auto" in data: + for config in data["auto"]: + for key, d_id in config.items(): + if key == "npm": + update_product(product_name, config) + + +def update_product(product_name, config): + if "npm" in config: + print(f"::group::{product_name}") + config = {"regex": REGEX} | config + r = fetch_releases(config["npm"], config["regex"]) + print("::endgroup::") + + with open(f"releases/{product_name}.json", "w") as f: + f.write(json.dumps(r, indent=2)) + + +if __name__ == "__main__": + if len(sys.argv) > 1: + update_releases(sys.argv[1]) + else: + update_releases() diff --git a/src/pypi.py b/src/pypi.py index a6a7f624..4f94bced 100644 --- a/src/pypi.py +++ b/src/pypi.py @@ -54,7 +54,7 @@ def update_releases(product_filter=None): def update_product(product_name, config): if "pypi" in config: print("::group::%s" % product_name) - config = config | {"regex": REGEX} + config = {"regex": REGEX} | config r = fetch_releases(config["pypi"], config["regex"]) with open("releases/%s.json" % product_name, "w") as f: f.write(json.dumps(r, indent=2))