From 33703cf92906fe9586a850c2ea73858b8ed43cf1 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Mon, 15 May 2023 15:41:03 +0000 Subject: [PATCH 01/11] Add Data Maintenances CLI recommendation to maint commands --- packages/pg-v5/commands/maintenance/index.js | 4 ++++ packages/pg-v5/commands/maintenance/run.js | 4 ++++ packages/pg-v5/commands/maintenance/window.js | 3 +++ packages/pg-v5/test/commands/maintenance/run.js | 10 +++++++++- packages/pg-v5/test/commands/maintenance/window.js | 10 +++++++++- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/pg-v5/commands/maintenance/index.js b/packages/pg-v5/commands/maintenance/index.js index c0dd543ad0..81a53585eb 100644 --- a/packages/pg-v5/commands/maintenance/index.js +++ b/packages/pg-v5/commands/maintenance/index.js @@ -10,6 +10,10 @@ async function run(context, heroku) { const db = await fetcher.addon(app, args.database) if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') + + cli.warn(`The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the ${cli.color.cmd('pg:maintenance')} functionality.`) + cli.warn(`Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation to install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance events for your add-ons.`) + let info = await heroku.get(`/client/v11/databases/${db.id}/maintenance`, { host: host(db) }) cli.log(info.message) } diff --git a/packages/pg-v5/commands/maintenance/run.js b/packages/pg-v5/commands/maintenance/run.js index 46d5026d92..f2a869d536 100644 --- a/packages/pg-v5/commands/maintenance/run.js +++ b/packages/pg-v5/commands/maintenance/run.js @@ -10,6 +10,10 @@ async function run(context, heroku) { const db = await fetcher.addon(app, args.database) if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') + + cli.warn(`The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the ${cli.color.cmd('pg:maintenance')} functionality.`) + cli.warn(`Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation to install the plugin and run ${cli.color.cmd('data:maintenances:run')} to start a maintenance.`) + await cli.action(`Starting maintenance for ${cli.color.addon(db.name)}`, async function () { if (!flags.force) { let appInfo = await heroku.get(`/apps/${app}`) diff --git a/packages/pg-v5/commands/maintenance/window.js b/packages/pg-v5/commands/maintenance/window.js index 6641446347..c07b0707b0 100644 --- a/packages/pg-v5/commands/maintenance/window.js +++ b/packages/pg-v5/commands/maintenance/window.js @@ -13,6 +13,9 @@ async function run(context, heroku) { if (!args.window.match(/^[A-Za-z]{2,10} \d\d?:[03]0$/)) throw new Error('Window must be "Day HH:MM" where MM is 00 or 30') + cli.warn(`The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the ${cli.color.cmd('pg:maintenance')} functionality.`) + cli.warn(`Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation to install the plugin and run ${cli.color.cmd('data:maintenances:window:update')} to change the database maintenance window.`) + await cli.action(`Setting maintenance window for ${cli.color.addon(db.name)} to ${cli.color.cyan(args.window)}`, async function () { let response = await heroku.put(`/client/v11/databases/${db.id}/maintenance_window`, { body: { description: args.window }, diff --git a/packages/pg-v5/test/commands/maintenance/run.js b/packages/pg-v5/test/commands/maintenance/run.js index 37118f7935..d0dd4361ac 100644 --- a/packages/pg-v5/test/commands/maintenance/run.js +++ b/packages/pg-v5/test/commands/maintenance/run.js @@ -24,6 +24,14 @@ const cmd = proxyquire('../../../commands/maintenance/run', { describe('pg:maintenance', () => { let api, pg + let displayed = ` ▸ The new Data Maintenance CLI plugin improves and extends the + ▸ pg:maintenance functionality. + ▸ Follow + ▸ https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation + ▸ to install the plugin and run data:maintenances:run to start a + ▸ maintenance. +` + beforeEach(() => { api = nock('https://api.heroku.com') pg = nock('https://postgres-api.heroku.com') @@ -40,7 +48,7 @@ describe('pg:maintenance', () => { api.get('/apps/myapp').reply(200, { maintenance: true }) pg.post('/client/v11/databases/1/maintenance').reply(200, { message: 'foo' }) return cmd.run({ app: 'myapp', args: {}, flags: {} }) - .then(() => expect(cli.stderr).to.equal('Starting maintenance for postgres-1... foo\n')) + .then(() => expect(cli.stderr).to.equal(displayed + 'Starting maintenance for postgres-1... foo\n')) .then(() => expect(cli.stdout).to.equal('')) }) }) diff --git a/packages/pg-v5/test/commands/maintenance/window.js b/packages/pg-v5/test/commands/maintenance/window.js index 090aec8d2f..b2e31b6096 100644 --- a/packages/pg-v5/test/commands/maintenance/window.js +++ b/packages/pg-v5/test/commands/maintenance/window.js @@ -24,6 +24,14 @@ const cmd = proxyquire('../../../commands/maintenance/window', { describe('pg:maintenance', () => { let api, pg + let displayed = ` ▸ The new Data Maintenance CLI plugin improves and extends the + ▸ pg:maintenance functionality. + ▸ Follow + ▸ https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation + ▸ to install the plugin and run data:maintenances:window:update to change + ▸ the database maintenance window. +` + beforeEach(() => { api = nock('https://api.heroku.com') pg = nock('https://postgres-api.heroku.com') @@ -40,6 +48,6 @@ describe('pg:maintenance', () => { pg.put('/client/v11/databases/1/maintenance_window', { description: 'Sunday 06:30' }).reply(200) return cmd.run({ app: 'myapp', args: { window: 'Sunday 06:30' } }) .then(() => expect(cli.stdout).to.equal('')) - .then(() => expect(cli.stderr).to.equal('Setting maintenance window for postgres-1 to Sunday 06:30... done\n')) + .then(() => expect(cli.stderr).to.equal(displayed + 'Setting maintenance window for postgres-1 to Sunday 06:30... done\n')) }) }) From 80c8def66aabda7f70391e64c5af2639a27e3912 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Mon, 15 May 2023 17:13:17 +0000 Subject: [PATCH 02/11] New plugin messaging for Redis commands --- packages/pg-v5/commands/maintenance/index.js | 9 ++++++-- packages/pg-v5/commands/maintenance/run.js | 9 ++++++-- packages/pg-v5/commands/maintenance/window.js | 9 ++++++-- .../pg-v5/test/commands/maintenance/run.js | 8 +++---- .../pg-v5/test/commands/maintenance/window.js | 8 +++---- packages/redis-v5/commands/maintenance.js | 12 ++++++++-- .../redis-v5/test/commands/maintenance.js | 23 ++++++++++++------- 7 files changed, 54 insertions(+), 24 deletions(-) diff --git a/packages/pg-v5/commands/maintenance/index.js b/packages/pg-v5/commands/maintenance/index.js index 81a53585eb..c0a00358ff 100644 --- a/packages/pg-v5/commands/maintenance/index.js +++ b/packages/pg-v5/commands/maintenance/index.js @@ -11,8 +11,13 @@ async function run(context, heroku) { if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') - cli.warn(`The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the ${cli.color.cmd('pg:maintenance')} functionality.`) - cli.warn(`Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation to install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance events for your add-ons.`) + let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the` + newPluginMessage += `\n${cli.color.cmd('pg:maintenance')} functionality.` + newPluginMessage += `\n\n1Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance` + newPluginMessage += `\nevents for your add-ons.` + + cli.warn(newPluginMessage) let info = await heroku.get(`/client/v11/databases/${db.id}/maintenance`, { host: host(db) }) cli.log(info.message) diff --git a/packages/pg-v5/commands/maintenance/run.js b/packages/pg-v5/commands/maintenance/run.js index f2a869d536..7375050e57 100644 --- a/packages/pg-v5/commands/maintenance/run.js +++ b/packages/pg-v5/commands/maintenance/run.js @@ -11,8 +11,13 @@ async function run(context, heroku) { if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') - cli.warn(`The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the ${cli.color.cmd('pg:maintenance')} functionality.`) - cli.warn(`Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation to install the plugin and run ${cli.color.cmd('data:maintenances:run')} to start a maintenance.`) + let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the` + newPluginMessage += `\n${cli.color.cmd('pg:maintenance')} functionality.` + newPluginMessage += `\n\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances:run')}` + newPluginMessage += `\nto start a maintenance.` + + cli.warn(newPluginMessage) await cli.action(`Starting maintenance for ${cli.color.addon(db.name)}`, async function () { if (!flags.force) { diff --git a/packages/pg-v5/commands/maintenance/window.js b/packages/pg-v5/commands/maintenance/window.js index c07b0707b0..f29f113787 100644 --- a/packages/pg-v5/commands/maintenance/window.js +++ b/packages/pg-v5/commands/maintenance/window.js @@ -13,8 +13,13 @@ async function run(context, heroku) { if (!args.window.match(/^[A-Za-z]{2,10} \d\d?:[03]0$/)) throw new Error('Window must be "Day HH:MM" where MM is 00 or 30') - cli.warn(`The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the ${cli.color.cmd('pg:maintenance')} functionality.`) - cli.warn(`Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation to install the plugin and run ${cli.color.cmd('data:maintenances:window:update')} to change the database maintenance window.`) + let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the` + newPluginMessage += `\n${cli.color.cmd('pg:maintenance')} functionality.` + newPluginMessage += `\n\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances:window:update')}` + newPluginMessage += `\nto change the database maintenance window.` + + cli.warn(newPluginMessage) await cli.action(`Setting maintenance window for ${cli.color.addon(db.name)} to ${cli.color.cyan(args.window)}`, async function () { let response = await heroku.put(`/client/v11/databases/${db.id}/maintenance_window`, { diff --git a/packages/pg-v5/test/commands/maintenance/run.js b/packages/pg-v5/test/commands/maintenance/run.js index d0dd4361ac..7864ff3f81 100644 --- a/packages/pg-v5/test/commands/maintenance/run.js +++ b/packages/pg-v5/test/commands/maintenance/run.js @@ -26,10 +26,10 @@ describe('pg:maintenance', () => { let displayed = ` ▸ The new Data Maintenance CLI plugin improves and extends the ▸ pg:maintenance functionality. - ▸ Follow - ▸ https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation - ▸ to install the plugin and run data:maintenances:run to start a - ▸ maintenance. + ▸ + ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands + ▸ to install the plugin and run data:maintenances:run + ▸ to start a maintenance. ` beforeEach(() => { diff --git a/packages/pg-v5/test/commands/maintenance/window.js b/packages/pg-v5/test/commands/maintenance/window.js index b2e31b6096..8de7ba75c0 100644 --- a/packages/pg-v5/test/commands/maintenance/window.js +++ b/packages/pg-v5/test/commands/maintenance/window.js @@ -26,10 +26,10 @@ describe('pg:maintenance', () => { let displayed = ` ▸ The new Data Maintenance CLI plugin improves and extends the ▸ pg:maintenance functionality. - ▸ Follow - ▸ https://devcenter.heroku.com/articles/data-maintenance-cli-commands#installation - ▸ to install the plugin and run data:maintenances:window:update to change - ▸ the database maintenance window. + ▸ + ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands + ▸ to install the plugin and run data:maintenances:window:update + ▸ to change the database maintenance window. ` beforeEach(() => { diff --git a/packages/redis-v5/commands/maintenance.js b/packages/redis-v5/commands/maintenance.js index f07d9a8eda..cc1e0d3da8 100644 --- a/packages/redis-v5/commands/maintenance.js +++ b/packages/redis-v5/commands/maintenance.js @@ -19,8 +19,16 @@ module.exports = { const api = require('../lib/shared')(context, heroku) let addon = await api.getRedisAddon() - if (addon.plan.name.match(/hobby/) != null) { - cli.exit(1, 'redis:maintenance is not available for hobby-dev instances') + let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends` + newPluginMessage += `\nthe ${cli.color.cmd('redis:maintenance')} functionality.` + newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance` + newPluginMessage += `\nevents for your add-ons.` + + cli.warn(newPluginMessage) + + if (addon.plan.name.match(/mini/) != null) { + cli.exit(1, 'redis:maintenance is not available for Mini plans') } if (context.flags.window) { diff --git a/packages/redis-v5/test/commands/maintenance.js b/packages/redis-v5/test/commands/maintenance.js index b830c141fa..4ef0c8424b 100644 --- a/packages/redis-v5/test/commands/maintenance.js +++ b/packages/redis-v5/test/commands/maintenance.js @@ -13,6 +13,13 @@ describe('heroku redis:maintenance', function () { }) describe('heroku redis:maintenance', function () { + + let newPluginMessage = ` ▸ The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends` + newPluginMessage += `\n ▸ the ${cli.color.cmd('redis:maintenance')} functionality.` + newPluginMessage += `\n ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\n ▸ to install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance` + newPluginMessage += `\n ▸ events for your add-ons.\n` + beforeEach(function () { cli.mockConsole() nock.cleanAll() @@ -32,7 +39,7 @@ describe('heroku redis:maintenance', function () { .then(() => app.done()) .then(() => redis.done()) .then(() => expect(cli.stdout).to.equal('Message\n')) - .then(() => expect(cli.stderr).to.equal('')) + .then(() => expect(cli.stderr).to.equal(newPluginMessage)) }) it('# sets the maintenance window', function () { @@ -50,7 +57,7 @@ describe('heroku redis:maintenance', function () { .then(() => app.done()) .then(() => redis.done) .then(() => expect(cli.stdout).to.equal('Maintenance window for redis-haiku (REDIS_FOO, REDIS_BAR) set to Mon 10:00.\n')) - .then(() => expect(cli.stderr).to.equal('')) + .then(() => expect(cli.stderr).to.equal(newPluginMessage)) }) it('# runs the maintenance', function () { @@ -70,7 +77,7 @@ describe('heroku redis:maintenance', function () { .then(() => appInfo.done()) .then(() => redis.done()) .then(() => expect(cli.stdout).to.equal('Message\n')) - .then(() => expect(cli.stderr).to.equal('')) + .then(() => expect(cli.stderr).to.equal(newPluginMessage)) }) it('# run errors out when not in maintenance', function () { @@ -86,17 +93,17 @@ describe('heroku redis:maintenance', function () { .then(() => app.done()) .then(() => appInfo.done()) .then(() => expect(cli.stdout).to.equal('')) - .then(() => expect(unwrap(cli.stderr)).to.equal('Application must be in maintenance mode or --force flag must be used\n')) + .then(() => expect(unwrap(cli.stderr)).to.include('Application must be in maintenance mode or --force flag must be used\n')) }) - it('# errors out on hobby dynos', function () { + it('# errors out on mini instances', function () { let app = nock('https://api.heroku.com:443') .get('/apps/example/addons').reply(200, [ - { name: 'redis-haiku', addon_service: { name: 'heroku-redis' }, plan: { name: 'hobby' }, config_vars: ['REDIS_FOO', 'REDIS_BAR'] } + { name: 'redis-haiku', addon_service: { name: 'heroku-redis' }, plan: { name: 'mini' }, config_vars: ['REDIS_FOO', 'REDIS_BAR'] } ]) return expect(command.run({ app: 'example', args: {}, auth: { username: 'foobar', password: 'password' } })).to.be.rejected - .then(() => expect(unwrap(cli.stderr)).to.equal('redis:maintenance is not available for hobby-dev instances\n')) + .then(() => expect(unwrap(cli.stderr)).to.include('redis:maintenance is not available for Mini plans\n')) .then(() => app.done()) }) @@ -109,6 +116,6 @@ describe('heroku redis:maintenance', function () { return expect(command.run({ app: 'example', args: {}, flags: { window: 'Mon 10:45' }, auth: { username: 'foobar', password: 'password' } })).to.be.rejected .then(() => app.done()) .then(() => expect(cli.stdout).to.equal('')) - .then(() => expect(unwrap(cli.stderr)).to.equal('Maintenance windows must be "Day HH:MM", where MM is 00 or 30.\n')) + .then(() => expect(unwrap(cli.stderr)).to.include('Maintenance windows must be "Day HH:MM", where MM is 00 or 30.\n')) }) }) From d4faca05f8f0e9d9512dae7f38567c0c95964923 Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Mon, 15 May 2023 17:15:53 +0000 Subject: [PATCH 03/11] Fix typo --- packages/pg-v5/commands/maintenance/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pg-v5/commands/maintenance/index.js b/packages/pg-v5/commands/maintenance/index.js index c0a00358ff..7655d1b089 100644 --- a/packages/pg-v5/commands/maintenance/index.js +++ b/packages/pg-v5/commands/maintenance/index.js @@ -13,7 +13,7 @@ async function run(context, heroku) { let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the` newPluginMessage += `\n${cli.color.cmd('pg:maintenance')} functionality.` - newPluginMessage += `\n\n1Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\n\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance` newPluginMessage += `\nevents for your add-ons.` From 17f59874814c5d87e980eb8ec5d7a0eaf002d30e Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 22 May 2023 11:28:29 +0000 Subject: [PATCH 04/11] Update Redis maintenance commands with CX review --- packages/redis-v5/commands/maintenance.js | 10 ++++------ packages/redis-v5/test/commands/maintenance.js | 14 +++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/redis-v5/commands/maintenance.js b/packages/redis-v5/commands/maintenance.js index cc1e0d3da8..cd82ba1be6 100644 --- a/packages/redis-v5/commands/maintenance.js +++ b/packages/redis-v5/commands/maintenance.js @@ -19,16 +19,14 @@ module.exports = { const api = require('../lib/shared')(context, heroku) let addon = await api.getRedisAddon() - let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends` - newPluginMessage += `\nthe ${cli.color.cmd('redis:maintenance')} functionality.` + let newPluginMessage = `You can also manage maintenances on your Redis instance with ${cli.color.cmd('data:maintenances')}.` newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` - newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance` - newPluginMessage += `\nevents for your add-ons.` + newPluginMessage += `\nto install the ${cli.color.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) if (addon.plan.name.match(/mini/) != null) { - cli.exit(1, 'redis:maintenance is not available for Mini plans') + cli.exit(1, 'The redis:maintenance command is not available for Mini plans') } if (context.flags.window) { @@ -44,7 +42,7 @@ module.exports = { if (context.flags.run) { let app = await heroku.get(`/apps/${context.app}`) if (!app.maintenance && !context.flags.force) { - cli.exit(1, 'Application must be in maintenance mode or --force flag must be used') + cli.exit(1, 'You must put your application in maintenance mode, or use the redis:maintenance --run --force command.') } let maintenance = await api.request(`/redis/v0/databases/${addon.name}/maintenance`, 'POST') diff --git a/packages/redis-v5/test/commands/maintenance.js b/packages/redis-v5/test/commands/maintenance.js index 4ef0c8424b..df0f30e939 100644 --- a/packages/redis-v5/test/commands/maintenance.js +++ b/packages/redis-v5/test/commands/maintenance.js @@ -13,12 +13,12 @@ describe('heroku redis:maintenance', function () { }) describe('heroku redis:maintenance', function () { - - let newPluginMessage = ` ▸ The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends` - newPluginMessage += `\n ▸ the ${cli.color.cmd('redis:maintenance')} functionality.` + + let newPluginMessage = ` ▸ You can also manage maintenances on your Redis instance with` + newPluginMessage += `\n ▸ ${cli.color.cmd('data:maintenances')}.` newPluginMessage += `\n ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` - newPluginMessage += `\n ▸ to install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance` - newPluginMessage += `\n ▸ events for your add-ons.\n` + newPluginMessage += `\n ▸ to install the ${cli.color.cyan('Data Maintenance CLI plugin')}.\n` + beforeEach(function () { cli.mockConsole() @@ -93,7 +93,7 @@ describe('heroku redis:maintenance', function () { .then(() => app.done()) .then(() => appInfo.done()) .then(() => expect(cli.stdout).to.equal('')) - .then(() => expect(unwrap(cli.stderr)).to.include('Application must be in maintenance mode or --force flag must be used\n')) + .then(() => expect(unwrap(cli.stderr)).to.include('You must put your application in maintenance mode, or use the redis:maintenance --run --force command.\n')) }) it('# errors out on mini instances', function () { @@ -103,7 +103,7 @@ describe('heroku redis:maintenance', function () { ]) return expect(command.run({ app: 'example', args: {}, auth: { username: 'foobar', password: 'password' } })).to.be.rejected - .then(() => expect(unwrap(cli.stderr)).to.include('redis:maintenance is not available for Mini plans\n')) + .then(() => expect(unwrap(cli.stderr)).to.include('The redis:maintenance command is not available for Mini plans\n')) .then(() => app.done()) }) From 6292068283f5c9f6c2163cdea46ea621c82c225c Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 22 May 2023 11:42:50 +0000 Subject: [PATCH 05/11] Update PG maintenance commands with CX review --- packages/pg-v5/commands/maintenance/index.js | 8 +++----- packages/pg-v5/commands/maintenance/run.js | 8 +++----- packages/pg-v5/commands/maintenance/window.js | 8 +++----- packages/pg-v5/test/commands/maintenance/run.js | 7 ++----- packages/pg-v5/test/commands/maintenance/window.js | 8 +++----- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/pg-v5/commands/maintenance/index.js b/packages/pg-v5/commands/maintenance/index.js index 7655d1b089..aafdb1120f 100644 --- a/packages/pg-v5/commands/maintenance/index.js +++ b/packages/pg-v5/commands/maintenance/index.js @@ -11,11 +11,9 @@ async function run(context, heroku) { if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') - let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the` - newPluginMessage += `\n${cli.color.cmd('pg:maintenance')} functionality.` - newPluginMessage += `\n\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` - newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances')} to list the maintenance` - newPluginMessage += `\nevents for your add-ons.` + let newPluginMessage = `You can also list the maintenance events for your Postgres database with ${cli.color.cmd('data:maintenances')}.` + newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\nto install the ${cli.color.bold.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) diff --git a/packages/pg-v5/commands/maintenance/run.js b/packages/pg-v5/commands/maintenance/run.js index 7375050e57..3ba4de2934 100644 --- a/packages/pg-v5/commands/maintenance/run.js +++ b/packages/pg-v5/commands/maintenance/run.js @@ -11,11 +11,9 @@ async function run(context, heroku) { if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') - let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the` - newPluginMessage += `\n${cli.color.cmd('pg:maintenance')} functionality.` - newPluginMessage += `\n\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` - newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances:run')}` - newPluginMessage += `\nto start a maintenance.` + let newPluginMessage = `You can also start a maintenance with ${cli.color.cmd('data:maintenances:run')}.` + newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\nto install the ${cli.color.bold.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) diff --git a/packages/pg-v5/commands/maintenance/window.js b/packages/pg-v5/commands/maintenance/window.js index f29f113787..97b5fe119e 100644 --- a/packages/pg-v5/commands/maintenance/window.js +++ b/packages/pg-v5/commands/maintenance/window.js @@ -13,11 +13,9 @@ async function run(context, heroku) { if (!args.window.match(/^[A-Za-z]{2,10} \d\d?:[03]0$/)) throw new Error('Window must be "Day HH:MM" where MM is 00 or 30') - let newPluginMessage = `The new ${cli.color.bold.cyan('Data Maintenance CLI plugin')} improves and extends the` - newPluginMessage += `\n${cli.color.cmd('pg:maintenance')} functionality.` - newPluginMessage += `\n\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` - newPluginMessage += `\nto install the plugin and run ${cli.color.cmd('data:maintenances:window:update')}` - newPluginMessage += `\nto change the database maintenance window.` + let newPluginMessage = `You can also change the maintenance window with ${cli.color.cmd('data:maintenances:window:update')}.` + newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += `\nto install the ${cli.color.bold.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) diff --git a/packages/pg-v5/test/commands/maintenance/run.js b/packages/pg-v5/test/commands/maintenance/run.js index 7864ff3f81..1589626d57 100644 --- a/packages/pg-v5/test/commands/maintenance/run.js +++ b/packages/pg-v5/test/commands/maintenance/run.js @@ -24,12 +24,9 @@ const cmd = proxyquire('../../../commands/maintenance/run', { describe('pg:maintenance', () => { let api, pg - let displayed = ` ▸ The new Data Maintenance CLI plugin improves and extends the - ▸ pg:maintenance functionality. - ▸ + let displayed = ` ▸ You can also start a maintenance with data:maintenances:run. ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands - ▸ to install the plugin and run data:maintenances:run - ▸ to start a maintenance. + ▸ to install the Data Maintenance CLI plugin. ` beforeEach(() => { diff --git a/packages/pg-v5/test/commands/maintenance/window.js b/packages/pg-v5/test/commands/maintenance/window.js index 8de7ba75c0..7b9b593072 100644 --- a/packages/pg-v5/test/commands/maintenance/window.js +++ b/packages/pg-v5/test/commands/maintenance/window.js @@ -24,12 +24,10 @@ const cmd = proxyquire('../../../commands/maintenance/window', { describe('pg:maintenance', () => { let api, pg - let displayed = ` ▸ The new Data Maintenance CLI plugin improves and extends the - ▸ pg:maintenance functionality. - ▸ + let displayed = ` ▸ You can also change the maintenance window with + ▸ data:maintenances:window:update. ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands - ▸ to install the plugin and run data:maintenances:window:update - ▸ to change the database maintenance window. + ▸ to install the Data Maintenance CLI plugin. ` beforeEach(() => { From a2e3c9317829f670314192ac6c72d57018ad8df2 Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 22 May 2023 12:40:09 +0000 Subject: [PATCH 06/11] Fix bad merge --- packages/pg-v5/commands/maintenance/run.js | 7 +++---- packages/pg-v5/commands/maintenance/window.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/pg-v5/commands/maintenance/run.js b/packages/pg-v5/commands/maintenance/run.js index 16a250a5bd..50616a2063 100644 --- a/packages/pg-v5/commands/maintenance/run.js +++ b/packages/pg-v5/commands/maintenance/run.js @@ -9,7 +9,7 @@ async function run(context, heroku) { const {app, args, flags} = context const db = await fetcher.addon(app, args.database) - if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') + if (util.starterPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.') let newPluginMessage = `You can also start a maintenance with ${cli.color.cmd('data:maintenances:run')}.` newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` @@ -17,11 +17,10 @@ async function run(context, heroku) { cli.warn(newPluginMessage) - await cli.action(`Starting maintenance for ${cli.color.addon(db.name)}`, async function () { - + await cli.action(`Starting maintenance for ${cli.color.addon(db.name)}`, (async function () { if (!flags.force) { let appInfo = await heroku.get(`/apps/${app}`) - if (!appInfo.maintenance) throw new Error('Application must be in maintenance mode or run with --force') + if (!appInfo.maintenance) throw new Error('You must put your app in maintenance mode with maintenance:on, or use pg:maintenance:run --force to manually initiate maintenance.') } let response = await heroku.post(`/client/v11/databases/${db.id}/maintenance`, {host: host(db)}) diff --git a/packages/pg-v5/commands/maintenance/window.js b/packages/pg-v5/commands/maintenance/window.js index 8e3adb35b7..cbb271b166 100644 --- a/packages/pg-v5/commands/maintenance/window.js +++ b/packages/pg-v5/commands/maintenance/window.js @@ -19,7 +19,7 @@ async function run(context, heroku) { cli.warn(newPluginMessage) - await cli.action(`Setting maintenance window for ${cli.color.addon(db.name)} to ${cli.color.cyan(args.window)}`, async function () { + await cli.action(`Setting maintenance window for ${cli.color.addon(db.name)} to ${cli.color.cyan(args.window)}`, (async function () { let response = await heroku.put(`/client/v11/databases/${db.id}/maintenance_window`, { body: {description: args.window}, From d971612a679e4bc0a06d7032784a659e8ffdb5ce Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 22 May 2023 12:45:11 +0000 Subject: [PATCH 07/11] Correct plan references to use Essential --- packages/pg-v5/commands/maintenance/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pg-v5/commands/maintenance/index.js b/packages/pg-v5/commands/maintenance/index.js index 24672dbeb8..d2e88e599f 100644 --- a/packages/pg-v5/commands/maintenance/index.js +++ b/packages/pg-v5/commands/maintenance/index.js @@ -9,7 +9,7 @@ async function run(context, heroku) { const {app, args} = context const db = await fetcher.addon(app, args.database) - if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') + if (util.starterPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.') let newPluginMessage = `You can also list the maintenance events for your Postgres database with ${cli.color.cmd('data:maintenances')}.` newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` From d3a4b5ee16e785fd7d07c4313fef4eb7699c13a3 Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 22 May 2023 12:45:11 +0000 Subject: [PATCH 08/11] Correct plan references to use Essential --- packages/pg-v5/commands/maintenance/index.js | 2 +- packages/pg-v5/commands/maintenance/run.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pg-v5/commands/maintenance/index.js b/packages/pg-v5/commands/maintenance/index.js index 24672dbeb8..8c10e9ccfb 100644 --- a/packages/pg-v5/commands/maintenance/index.js +++ b/packages/pg-v5/commands/maintenance/index.js @@ -9,7 +9,7 @@ async function run(context, heroku) { const {app, args} = context const db = await fetcher.addon(app, args.database) - if (util.starterPlan(db)) throw new Error('pg:maintenance is only available for production databases') + if (util.essentialPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.') let newPluginMessage = `You can also list the maintenance events for your Postgres database with ${cli.color.cmd('data:maintenances')}.` newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` diff --git a/packages/pg-v5/commands/maintenance/run.js b/packages/pg-v5/commands/maintenance/run.js index 50616a2063..6559e21c33 100644 --- a/packages/pg-v5/commands/maintenance/run.js +++ b/packages/pg-v5/commands/maintenance/run.js @@ -9,7 +9,7 @@ async function run(context, heroku) { const {app, args, flags} = context const db = await fetcher.addon(app, args.database) - if (util.starterPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.') + if (util.essentialPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.') let newPluginMessage = `You can also start a maintenance with ${cli.color.cmd('data:maintenances:run')}.` newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` From 0f389a3d3b34281626fd6da417e56b2a2f3919c4 Mon Sep 17 00:00:00 2001 From: Carla Date: Mon, 22 May 2023 13:54:56 +0000 Subject: [PATCH 09/11] Use plain text in test comparisons --- packages/redis-v5/test/commands/maintenance.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/redis-v5/test/commands/maintenance.js b/packages/redis-v5/test/commands/maintenance.js index c485baafcb..86eff92d56 100644 --- a/packages/redis-v5/test/commands/maintenance.js +++ b/packages/redis-v5/test/commands/maintenance.js @@ -15,9 +15,9 @@ describe('heroku redis:maintenance', function () { describe('heroku redis:maintenance', function () { let newPluginMessage = ` ▸ You can also manage maintenances on your Redis instance with` - newPluginMessage += `\n ▸ ${cli.color.cmd('data:maintenances')}.` + newPluginMessage += `\n ▸ data:maintenances.` newPluginMessage += `\n ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` - newPluginMessage += `\n ▸ to install the ${cli.color.cyan('Data Maintenance CLI plugin')}.\n` + newPluginMessage += `\n ▸ to install the Data Maintenance CLI plugin.\n` beforeEach(function () { From 02f0db5471c4d65b6b547e0485f7249f2d31d4ca Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 23 May 2023 14:39:38 +0000 Subject: [PATCH 10/11] Fix linter errors --- packages/pg-v5/commands/maintenance/index.js | 5 ++--- packages/pg-v5/commands/maintenance/run.js | 2 +- packages/pg-v5/commands/maintenance/window.js | 3 +-- packages/pg-v5/test/commands/maintenance/run.js | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/pg-v5/commands/maintenance/index.js b/packages/pg-v5/commands/maintenance/index.js index 8c10e9ccfb..7b26d2f668 100644 --- a/packages/pg-v5/commands/maintenance/index.js +++ b/packages/pg-v5/commands/maintenance/index.js @@ -12,13 +12,12 @@ async function run(context, heroku) { if (util.essentialPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.') let newPluginMessage = `You can also list the maintenance events for your Postgres database with ${cli.color.cmd('data:maintenances')}.` - newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += '\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands' newPluginMessage += `\nto install the ${cli.color.bold.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) - let info = await heroku.get(`/client/v11/databases/${db.id}/maintenance`, { host: host(db) }) - + let info = await heroku.get(`/client/v11/databases/${db.id}/maintenance`, {host: host(db)}) cli.log(info.message) } diff --git a/packages/pg-v5/commands/maintenance/run.js b/packages/pg-v5/commands/maintenance/run.js index 6559e21c33..0937874c02 100644 --- a/packages/pg-v5/commands/maintenance/run.js +++ b/packages/pg-v5/commands/maintenance/run.js @@ -12,7 +12,7 @@ async function run(context, heroku) { if (util.essentialPlan(db)) throw new Error('pg:maintenance isn’t available for Essential-tier databases.') let newPluginMessage = `You can also start a maintenance with ${cli.color.cmd('data:maintenances:run')}.` - newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += '\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands' newPluginMessage += `\nto install the ${cli.color.bold.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) diff --git a/packages/pg-v5/commands/maintenance/window.js b/packages/pg-v5/commands/maintenance/window.js index cbb271b166..ba030f5835 100644 --- a/packages/pg-v5/commands/maintenance/window.js +++ b/packages/pg-v5/commands/maintenance/window.js @@ -14,13 +14,12 @@ async function run(context, heroku) { if (!args.window.match(/^[A-Za-z]{2,10} \d\d?:[03]0$/)) throw new Error('Window must be "Day HH:MM" where MM is 00 or 30') let newPluginMessage = `You can also change the maintenance window with ${cli.color.cmd('data:maintenances:window:update')}.` - newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += '\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands' newPluginMessage += `\nto install the ${cli.color.bold.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) await cli.action(`Setting maintenance window for ${cli.color.addon(db.name)} to ${cli.color.cyan(args.window)}`, (async function () { - let response = await heroku.put(`/client/v11/databases/${db.id}/maintenance_window`, { body: {description: args.window}, host: host(db), diff --git a/packages/pg-v5/test/commands/maintenance/run.js b/packages/pg-v5/test/commands/maintenance/run.js index 933c17dbf9..c4183f9a68 100644 --- a/packages/pg-v5/test/commands/maintenance/run.js +++ b/packages/pg-v5/test/commands/maintenance/run.js @@ -43,9 +43,9 @@ describe('pg:maintenance', () => { }) it('runs maintenance', () => { - api.get('/apps/myapp').reply(200, { maintenance: true }) - pg.post('/client/v11/databases/1/maintenance').reply(200, { message: 'foo' }) - return cmd.run({ app: 'myapp', args: {}, flags: {} }) + api.get('/apps/myapp').reply(200, {maintenance: true}) + pg.post('/client/v11/databases/1/maintenance').reply(200, {message: 'foo'}) + return cmd.run({app: 'myapp', args: {}, flags: {}}) .then(() => expect(cli.stderr).to.equal(displayed + 'Starting maintenance for postgres-1... foo\n')) .then(() => expect(cli.stdout).to.equal('')) From 4fdbb011e1989076668b36b6b0f09de2e3ee1dc6 Mon Sep 17 00:00:00 2001 From: Carla Date: Tue, 23 May 2023 15:36:03 +0000 Subject: [PATCH 11/11] (redis-v5) Fix lint checks --- packages/redis-v5/commands/maintenance.js | 2 +- packages/redis-v5/test/commands/maintenance.js | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/redis-v5/commands/maintenance.js b/packages/redis-v5/commands/maintenance.js index f03b7828c0..65f12df603 100644 --- a/packages/redis-v5/commands/maintenance.js +++ b/packages/redis-v5/commands/maintenance.js @@ -20,7 +20,7 @@ module.exports = { let addon = await api.getRedisAddon() let newPluginMessage = `You can also manage maintenances on your Redis instance with ${cli.color.cmd('data:maintenances')}.` - newPluginMessage += `\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` + newPluginMessage += '\nFollow https://devcenter.heroku.com/articles/data-maintenance-cli-commands' newPluginMessage += `\nto install the ${cli.color.cyan('Data Maintenance CLI plugin')}.` cli.warn(newPluginMessage) diff --git a/packages/redis-v5/test/commands/maintenance.js b/packages/redis-v5/test/commands/maintenance.js index 86eff92d56..67ec5fcdbe 100644 --- a/packages/redis-v5/test/commands/maintenance.js +++ b/packages/redis-v5/test/commands/maintenance.js @@ -13,12 +13,10 @@ describe('heroku redis:maintenance', function () { }) describe('heroku redis:maintenance', function () { - - let newPluginMessage = ` ▸ You can also manage maintenances on your Redis instance with` - newPluginMessage += `\n ▸ data:maintenances.` - newPluginMessage += `\n ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands` - newPluginMessage += `\n ▸ to install the Data Maintenance CLI plugin.\n` - + let newPluginMessage = ' ▸ You can also manage maintenances on your Redis instance with' + newPluginMessage += '\n ▸ data:maintenances.' + newPluginMessage += '\n ▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands' + newPluginMessage += '\n ▸ to install the Data Maintenance CLI plugin.\n' beforeEach(function () { cli.mockConsole() @@ -99,10 +97,10 @@ describe('heroku redis:maintenance', function () { it('# errors out on mini instances', function () { let app = nock('https://api.heroku.com:443') .get('/apps/example/addons').reply(200, [ - { name: 'redis-haiku', addon_service: { name: 'heroku-redis' }, plan: { name: 'mini' }, config_vars: ['REDIS_FOO', 'REDIS_BAR'] } + {name: 'redis-haiku', addon_service: {name: 'heroku-redis'}, plan: {name: 'mini'}, config_vars: ['REDIS_FOO', 'REDIS_BAR']}, ]) - return expect(command.run({ app: 'example', args: {}, auth: { username: 'foobar', password: 'password' } })).to.be.rejected + return expect(command.run({app: 'example', args: {}, auth: {username: 'foobar', password: 'password'}})).to.be.rejected .then(() => expect(unwrap(cli.stderr)).to.include('The redis:maintenance command is not available for Mini plans\n')) .then(() => app.done()) })