Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: versioning script now updates package.json #551

Merged
merged 8 commits into from Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 8 additions & 13 deletions bin/version.ts
Expand Up @@ -34,8 +34,11 @@ const newVersion = (() => {
patch = Number(patch) + 1;
} else if (argv._.includes('minor')) {
minor = Number(minor) + 1;
patch = 0;
} else if (argv._.includes('major')) {
major = Number(major) + 1;
minor = 0;
patch = 0;
} else {
// else use the first argument
return argv._[0].toString();
Expand All @@ -53,8 +56,12 @@ const packages = workspaces
.filter(workspace => workspace.includes('packages'))
.map(packagePath => packagePath.replace('packages', '@dfinity'));

// Update version in root package.json
workspaces.push('.');

workspaces.forEach(async workspace => {
const packagePath = path.resolve(__dirname, '..', workspace, 'package.json');
console.log(packagePath);
const json = JSON.parse(fs.readFileSync(packagePath).toString());

// Set version for package
Expand All @@ -74,6 +81,7 @@ workspaces.forEach(async workspace => {
// Write file
fs.writeFileSync(packagePath, JSON.stringify(json));
});

function updateDeps(dependencies: Record<string, string>) {
for (const dep in dependencies) {
if (Object.prototype.hasOwnProperty.call(dependencies, dep)) {
Expand All @@ -84,16 +92,3 @@ function updateDeps(dependencies: Record<string, string>) {
}
return dependencies;
}
// Update version in root package.json
fs.writeFileSync(path.resolve(__dirname, '..', 'package.json'), JSON.stringify(rootPackage));

// Prettier format the modified package.json files
exec(`npm run prettier:format`, error => {
if (error) {
throw new Error(JSON.stringify(error));
}

// wrap up
console.log('success!');
console.timeEnd('script duration');
});
4 changes: 4 additions & 0 deletions docs/generated/changelog.html
Expand Up @@ -23,6 +23,10 @@ <h2>Version 0.10.5</h2>
Readme for more details
</li>
<li>Reduces the maxTimeToLive default setting from 24 hours to 8</li>
<li>
Versioning tool now sets patch version to 0 for minor version updates, or patch and minor
versions to 0 for major version updates
</li>
</ul>
<h2>Version 0.10.3</h2>
<ul>
Expand Down