diff --git a/package.json b/package.json index be6e6b75f0..3090576ce4 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "scripts": { "dev": "export NODE_OPTIONS=--openssl-legacy-provider && node --max_old_space_size=4096 ./node_modules/vuepress/cli.js dev docs", "build": "export NODE_OPTIONS=--openssl-legacy-provider && node --max_old_space_size=4096 ./node_modules/vuepress/cli.js build docs", + "predev": "vdoing", + "prebuild": "vdoing", "deploy": "bash deploy.sh", "editFm": "node utils/editFrontmatter.js", "baiduPush": "node utils/baiduPush.js https://xugaoyi.com && bash baiduPush.sh", @@ -25,7 +27,7 @@ "vuepress-plugin-sitemap": "^2.3.1", "vuepress-plugin-thirdparty-search": "^1.0.2", "vuepress-plugin-zooming": "^1.1.7", - "vuepress-theme-vdoing": "^1.12.8", + "vuepress-theme-vdoing": "^1.12.9", "yamljs": "^0.3.0" } } diff --git a/vdoing/bin/checkVersion.js b/vdoing/bin/checkVersion.js new file mode 100644 index 0000000000..9fb98f373b --- /dev/null +++ b/vdoing/bin/checkVersion.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +const semver = require('semver'); +const chalk = require('chalk'); +const requiredVersion = require('../package.json').engines.node; + +// check version +if (!semver.satisfies(process.version, requiredVersion)) { + console.log(chalk.red( + `\n[vdoing] minimum Node version not met:` + + `\nYou are using Node ${process.version}, but vdoing ` + + `requires Node ${requiredVersion}.\nPlease upgrade your Node version.\n` + + `请升级你的 Node 版本到 ${requiredVersion}.\n` + )) + process.exit(1) +} diff --git a/vdoing/package.json b/vdoing/package.json index ff17100f36..71652f9699 100644 --- a/vdoing/package.json +++ b/vdoing/package.json @@ -1,6 +1,6 @@ { "name": "vuepress-theme-vdoing", - "version": "1.12.8", + "version": "1.12.9", "description": "Vdoing theme for VuePress. 一个基于VuePress的知识管理兼博客主题。", "author": { "name": "gaoyi(Evan) Xu" @@ -50,6 +50,9 @@ "@vuepress/types": "^1.9.5" }, "engines": { - "node": ">=14.17.0" + "node": ">=18.0.0" + }, + "bin": { + "vdoing": "./bin/checkVersion.js" } }