Skip to content

开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.

chore: improve publish script

pubuzhixing8f98557a0b0b5
diff --git a/scripts/publish.js b/scripts/publish.js
index 1bb1afe..6c9cf83 100644
--- a/scripts/publish.js
+++ b/scripts/publish.js
@@ -8,9 +8,29 @@ libraries.forEach(lib => {
const libPath = path.resolve(__dirname, '../dist', lib);
if (fs.existsSync(libPath)) {
- console.log(`Publishing ${lib}...`);
+ const pkgPath = path.join(libPath, 'package.json');
+ let publishCmd = 'npm publish --access public';
+ let versionInfo = '';
+
+ if (fs.existsSync(pkgPath)) {
+ try {
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
+ const version = pkg.version || '';
+ versionInfo = version ? ` (version ${version})` : '';
+ // 识别带有预发布标识的版本(包含 '-'),使用 next 标签
+ if (typeof version === 'string' && version.includes('-')) {
+ publishCmd += ' --tag next';
+ }
+ } catch (e) {
+ console.warn(`Unable to read version for ${lib}:`, e.message);
+ }
+ } else {
+ console.warn(`package.json not found in ${libPath}`);
+ }
+
+ console.log(`Publishing ${lib}${versionInfo} with: ${publishCmd}`);
try {
- execSync('npm publish --access public', {
+ execSync(publishCmd, {
cwd: libPath,
stdio: 'inherit'
});