This is an automated email from the ASF dual-hosted git repository. shuai pushed a commit to branch fix-text in repository https://gitbox.apache.org/repos/asf/answer-website.git
commit 0e24ddf67d2a91a3e82965284c6ea163e01920e7 Author: shuai <[email protected]> AuthorDate: Mon Feb 17 12:15:53 2025 +0800 fix: add scripts to get plugin data --- scripts/fetchPlugins.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/fetchPlugins.js b/scripts/fetchPlugins.js new file mode 100644 index 000000000..02aab12a5 --- /dev/null +++ b/scripts/fetchPlugins.js @@ -0,0 +1,26 @@ +var fs = require('fs'); +var path = require('path'); + + +var url = 'https://raw.githubusercontent.com/apache/answer-plugins/main/plugins_desc.json'; +var outputPath = path.join(__dirname, '../static/data/plugin.json'); + +function fetchPlugins() { + fetch(url) + .then(function(response) { + if (!response.ok) { + throw new Error('HTTP error! status:', response.status); + } + return response.text(); + }) + .then(function(data) { + fs.mkdirSync(path.dirname(outputPath), { recursive: true }); + fs.writeFileSync(outputPath, data, 'utf8'); + console.log('Data fetched and saved to', outputPath); + }) + .catch(function (error) { + console.error('Error fetching data:', error.message); + }); +} + +fetchPlugins();
