Skip to content

Commit

Permalink
add --optional arg to gro publish and use it from gro release
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Jun 16, 2024
1 parent 5c36e89 commit dd02f27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-rocks-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ryanatkn/gro': patch
---

add `--optional` arg to `gro publish` and use it from `gro release`
11 changes: 9 additions & 2 deletions src/lib/publish.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const Args = z
'opt out of linkifying and formatting the changelog from @changesets/changelog-git',
})
.default(false),
optional: z.boolean({description: 'exit gracefully if there are no changesets'}).default(false),
dry: z
.boolean({description: 'build and prepare to publish without actually publishing'})
.default(false),
Expand All @@ -58,7 +59,7 @@ export const task: Task<Args> = {
summary: 'bump version, publish to npm, and git push',
Args,
run: async ({args, log, invoke_task}): Promise<void> => {
const {branch, origin, changelog, preserve_changelog, dry, check, build, pull} = args;
const {branch, origin, changelog, preserve_changelog, dry, check, build, pull, optional} = args;
if (dry) {
log.info(green('dry run!'));
}
Expand Down Expand Up @@ -141,7 +142,13 @@ export const task: Task<Args> = {
const package_json_after = await load_package_json();
version = package_json_after.version!;
if (package_json_before.version === version) {
throw new Task_Error('changeset version failed: are there any changes?');
// The version didn't change.
// For now this is the best detection we have for a no-op `changeset version`.
if (optional) {
return; // exit gracefully
} else {
throw new Task_Error('changeset version failed: are there any changes?');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/release.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const task: Task<Args> = {
run: async ({invoke_task}) => {
const publish = (await has_sveltekit_library()).ok;
if (publish) {
await invoke_task('publish');
await invoke_task('publish', {optional: true});
}
if ((await has_sveltekit_app()).ok) {
await invoke_task('deploy', {build: !publish});
Expand Down

0 comments on commit dd02f27

Please sign in to comment.