Skip to content

Commit

Permalink
fix: throw error if no app exists
Browse files Browse the repository at this point in the history
  • Loading branch information
robingenz committed Jun 10, 2024
1 parent e67e94b commit 930857c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/commands/apps/bundles/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export default defineCommand({
}
if (!appId) {
const apps = await appsService.findAll();
if (!apps.length) {
consola.error('You must create an app before creating a bundle.');
return;
}
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
appId = await prompt('Which app do you want to deploy to:', {
type: 'select',
Expand Down
4 changes: 4 additions & 0 deletions src/commands/apps/bundles/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export default defineCommand({
let bundleId = ctx.args.bundleId;
if (!appId) {
const apps = await appsService.findAll();
if (!apps.length) {
consola.error('You must create an app before deleting a bundle.');
return;
}
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
appId = await prompt('Which app do you want to delete the bundle from?', {
type: 'select',
Expand Down
4 changes: 4 additions & 0 deletions src/commands/apps/bundles/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export default defineCommand({
let bundleId = ctx.args.bundleId;
if (!appId) {
const apps = await appsService.findAll();
if (!apps.length) {
consola.error('You must create an app before updating a bundle.');
return;
}
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
appId = await prompt('Which app do you want to update the bundle for?', {
type: 'select',
Expand Down
4 changes: 4 additions & 0 deletions src/commands/apps/channels/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default defineCommand({
let appId = ctx.args.appId;
if (!appId) {
const apps = await appsService.findAll();
if (!apps.length) {
consola.error('You must create an app before creating a channel.');
return;
}
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
appId = await prompt('Which app do you want to delete the channel from?', {
type: 'select',
Expand Down
4 changes: 4 additions & 0 deletions src/commands/apps/channels/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default defineCommand({
let appId = ctx.args.appId;
if (!appId) {
const apps = await appsService.findAll();
if (!apps.length) {
consola.error('You must create an app before deleting a bundle.');
return;
}
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
appId = await prompt('Which app do you want to delete the channel from?', {
type: 'select',
Expand Down
4 changes: 4 additions & 0 deletions src/commands/apps/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default defineCommand({
let appId = ctx.args.appId;
if (!appId) {
const apps = await appsService.findAll();
if (!apps.length) {
consola.error('You must create an app before deleting it.');
return;
}
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
appId = await prompt('Which app do you want to delete?', {
type: 'select',
Expand Down
4 changes: 4 additions & 0 deletions src/commands/apps/devices/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default defineCommand({
let appId = ctx.args.appId;
if (!appId) {
const apps = await appsService.findAll();
if (!apps.length) {
consola.error('You must create an app before deleting a device.');
return;
}
// @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
appId = await prompt('Which app do you want to delete the device from?', {
type: 'select',
Expand Down

0 comments on commit 930857c

Please sign in to comment.