Discover a step-by-step guide to integrating Bolt.new AI with Mercurial for seamless automation and improved code management in your development workflow.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
package.json
file to include the Mercurial dependency.In your project’s root, open (or create) the package.json
file and add the following lines inside the "dependencies" section to install the node-hg
package. (This package allows your TypeScript code to run Mercurial commands.)
{
"name": "bolt-ai-project",
"version": "1.0.0",
"dependencies": {
"node-hg": "latest"
}
}
mercurialIntegration.ts
. This file will contain functions that wrap common Mercurial commands.mercurialIntegration.ts
:
import { exec } from 'child_process';
export function hgStatus(repoPath: string): Promise<string> {
return new Promise((resolve, reject) => {
exec('hg status', { cwd: repoPath }, (error, stdout, stderr) => {
if (error) {
reject(Error fetching status: ${stderr});
} else {
resolve(stdout);
}
});
});
}
export function hgCommit(repoPath: string, message: string): Promise<string> {
return new Promise((resolve, reject) => {
exec(hg commit -m "${message}", { cwd: repoPath }, (error, stdout, stderr) => {
if (error) {
reject(Error committing changes: ${stderr});
} else {
resolve(stdout);
}
});
});
}
export function hgPush(repoPath: string): Promise<string> {
return new Promise((resolve, reject) => {
exec('hg push', { cwd: repoPath }, (error, stdout, stderr) => {
if (error) {
reject(Error pushing changes: ${stderr});
} else {
resolve(stdout);
}
});
});
}
child_process
to execute Mercurial commands on your repository located at the specified path.
index.ts
or app.ts
).mercurialIntegration.ts
to perform Mercurial operations. Insert the following code where you need version control actions:
import { hgStatus, hgCommit, hgPush } from './mercurialIntegration';
// Replace with the absolute or relative path to your repository folder
const repoPath = '/path/to/your/mercurial/repository';
async function performMercurialOperations() {
try {
const status = await hgStatus(repoPath);
console.log('Mercurial Status:', status);
// Commit changes with a custom message
const commitResult = await hgCommit(repoPath, 'Automated commit from Bolt.new AI');
console.log('Commit Result:', commitResult);
// Push the committed changes to the remote repository
const pushResult = await hgPush(repoPath);
console.log('Push Result:', pushResult);
} catch (error) {
console.error('An error occurred:', error);
}
}
// Call this function at the appropriate time in your application workflow
performMercurialOperations();
repoPath
to point to your Mercurial repository location.
mercurialIntegration.ts
file.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.