Skip to content

Commit

Permalink
Merge pull request #43 from SuperViz/fix/semmantic-release-packages
Browse files Browse the repository at this point in the history
fix: async handle into version file
  • Loading branch information
carlossantos74 authored Oct 3, 2024
2 parents e821a36 + c53c96b commit 1ce6cd9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
35 changes: 24 additions & 11 deletions packages/semantic-release-version-file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,44 @@ const fs = require('fs');
const { exec } = require('child_process');

const createFile = (version) => {
const filename = '.version.js';
const content = `export const version = '${version}'`;
fs.writeFileSync(filename, content);
return new Promise((resolve, reject) => {
const filename = '.version.js';
const content = `export const version = '${version}'`;

fs.writeFile(filename, content, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}

const build = () => {
exec('pnpm turbo run build', (err, stdout, stderr) => {
if (err) {
return new Promise((resolve, reject) => {
exec('pnpm turbo run build && ls -la ./dist', (err, stdout, stderr) => {
if (err) {
console.error('build package error: ', err);
reject(err);
return;
}
}

console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
resolve();
});
});
}

const handle = async (context) => {
const version = context?.nextRelease?.version;
if (!version) {
throw new Error('Could not determine the version from semantic release.')
throw new Error('Could not determine the version from semantic release.')
}

createFile(version);
build()
await createFile(version);
await build();
};

async function prepare(pluginConfig, context) {
Expand Down
14 changes: 3 additions & 11 deletions packages/yjs/.releaserc
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
{
"branches": [
"main",
{
"name": "beta",
"channel": "beta",
"prerelease": true
},
{
"name": "lab",
"channel": "lab",
"prerelease": true
}
"main",
{ "name": "beta", "channel": "beta", "prerelease": true },
{ "name": "lab", "channel": "lab", "prerelease": true }
],
"tagFormat": "@superviz/yjs/${version}",
"plugins": [
Expand Down

0 comments on commit 1ce6cd9

Please sign in to comment.