Skip to content

Commit

Permalink
feat(publish): add vue package
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenJPx2 committed Dec 26, 2024
1 parent 3de07b4 commit 4e6b5ee
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions publish.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { readdirSync } from 'fs';
import { spawn } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';

// This publish process automatically replaces workspace:* with the actual version number of other packages currently in the repo

// The packages to publish – this will run in order and await each package before moving on
const packages = ['shaders', 'shaders-react'];
const packages = ['shaders', 'shaders-react', 'shaders-vue'];

const isDryRun = process.argv.includes('--dry-run');
// Extract the tag value from the command line arguments
Expand All @@ -22,9 +21,7 @@ if (tag) {
const packageVersionMap = {};
// Loop through all the packages and get the current version of each
for (const pkg of packages) {
const packageJson = JSON.parse(
readFileSync(`packages/${pkg}/package.json`, 'utf8')
);
const packageJson = JSON.parse(readFileSync(`packages/${pkg}/package.json`, 'utf8'));
// Get the name of the package
const name = packageJson.name;
const currentVersion = packageJson.version;
Expand All @@ -36,10 +33,7 @@ async function publish(pkg) {
console.log(`Publishing ${pkg}...`);

// ----- Update any workspace dependencies with the current version ----- //
const originalPackageJson = readFileSync(
`${packagePath}/package.json`,
'utf8'
);
const originalPackageJson = readFileSync(`${packagePath}/package.json`, 'utf8');
const packageJson = JSON.parse(originalPackageJson);
// Search the package.json for any packages in our packageVersionMap and replace the version with the current version
for (const [key, value] of Object.entries(packageJson.dependencies)) {
Expand All @@ -48,10 +42,7 @@ async function publish(pkg) {
}
}
// Write the updated package.json
writeFileSync(
`${packagePath}/package.json`,
JSON.stringify(packageJson, null, 2)
);
writeFileSync(`${packagePath}/package.json`, JSON.stringify(packageJson, null, 2));

// ----- Publish the package ----- //
const args = ['publish', '--access', 'public'];
Expand All @@ -70,9 +61,7 @@ async function publish(pkg) {

child.on('close', (code) => {
if (code !== 0) {
console.log(
`Skipping ${pkg}: Publication failed or package is already up to date`
);
console.log(`Skipping ${pkg}: Publication failed or package is already up to date`);
} else {
console.log(`Published ${pkg}`);
}
Expand Down

0 comments on commit 4e6b5ee

Please sign in to comment.