mirror of
https://github.com/reconurge/flowsint.git
synced 2026-03-08 23:04:17 -05:00
feat: new commit instructions
This commit is contained in:
20
scripts/pyproject-updater.js
Executable file
20
scripts/pyproject-updater.js
Executable file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Custom updater for pyproject.toml
|
||||
* Used by standard-version to bump version in pyproject.toml
|
||||
*/
|
||||
|
||||
const stringifyPackage = require('stringify-package');
|
||||
const detectIndent = require('detect-indent');
|
||||
const detectNewline = require('detect-newline');
|
||||
|
||||
module.exports.readVersion = function (contents) {
|
||||
const match = contents.match(/^version = "(.*)"$/m);
|
||||
return match ? match[1] : null;
|
||||
};
|
||||
|
||||
module.exports.writeVersion = function (contents, version) {
|
||||
return contents.replace(
|
||||
/^version = ".*"$/m,
|
||||
`version = "${version}"`
|
||||
);
|
||||
};
|
||||
74
scripts/sync-versions.js
Executable file
74
scripts/sync-versions.js
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Version Synchronization Script
|
||||
*
|
||||
* Keeps versions synchronized across:
|
||||
* - pyproject.toml (root)
|
||||
* - flowsint-app/package.json
|
||||
*
|
||||
* Usage: node scripts/sync-versions.js <new-version>
|
||||
*/
|
||||
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { join, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const ROOT_DIR = join(__dirname, '..');
|
||||
|
||||
function updatePyprojectVersion(version) {
|
||||
const pyprojectPath = join(ROOT_DIR, 'pyproject.toml');
|
||||
let content = readFileSync(pyprojectPath, 'utf8');
|
||||
|
||||
// Update version in [tool.poetry] section
|
||||
content = content.replace(
|
||||
/^version = ".*"$/m,
|
||||
`version = "${version}"`
|
||||
);
|
||||
|
||||
writeFileSync(pyprojectPath, content, 'utf8');
|
||||
console.log(`✓ Updated pyproject.toml to ${version}`);
|
||||
}
|
||||
|
||||
function updatePackageJsonVersion(version) {
|
||||
const packagePath = join(ROOT_DIR, 'flowsint-app', 'package.json');
|
||||
const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
|
||||
|
||||
pkg.version = version;
|
||||
|
||||
writeFileSync(packagePath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
||||
console.log(`✓ Updated flowsint-app/package.json to ${version}`);
|
||||
}
|
||||
|
||||
function getCurrentVersion() {
|
||||
const packagePath = join(ROOT_DIR, 'flowsint-app', 'package.json');
|
||||
const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
// Main execution
|
||||
const newVersion = process.argv[2];
|
||||
|
||||
if (!newVersion) {
|
||||
console.log(`Current version: ${getCurrentVersion()}`);
|
||||
console.log('\nUsage: node scripts/sync-versions.js <version>');
|
||||
console.log('Example: node scripts/sync-versions.js 1.2.3');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Validate semantic version format
|
||||
if (!/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(newVersion)) {
|
||||
console.error('Error: Invalid version format. Expected: X.Y.Z or X.Y.Z-suffix');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
updatePyprojectVersion(newVersion);
|
||||
updatePackageJsonVersion(newVersion);
|
||||
console.log(`\n✓ All versions synchronized to ${newVersion}`);
|
||||
} catch (error) {
|
||||
console.error('Error syncing versions:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user