Skip to content

Commit

Permalink
fix: ACNA-1807 - remove deprecated flags in the commands (#586)
Browse files Browse the repository at this point in the history
Co-authored-by: Jesse MacFadyen <purplecabbage@gmail.com>
  • Loading branch information
shazron and purplecabbage authored Sep 30, 2022
1 parent 488b207 commit 1828633
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 305 deletions.
12 changes: 1 addition & 11 deletions src/commands/app/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class Build extends BaseCommand {
// cli input
const { flags } = await this.parse(Build)
// flags
flags['web-assets'] = flags['web-assets'] && !flags['skip-static'] && !flags['skip-web-assets'] && !flags.action
flags.actions = flags.actions && !flags['skip-actions']
flags['web-assets'] = flags['web-assets'] && !flags.action

const buildConfigs = this.getAppExtConfigs(flags)

Expand Down Expand Up @@ -144,15 +143,6 @@ This will always force a rebuild unless --no-force-build is set.

Build.flags = {
...BaseCommand.flags,
'skip-static': Flags.boolean({
description: '[deprecated] Please use --no-web-assets'
}),
'skip-web-assets': Flags.boolean({
description: '[deprecated] Please use --no-web-assets'
}),
'skip-actions': Flags.boolean({
description: '[deprecated] Please use --no-actions'
}),
actions: Flags.boolean({
description: '[default: true] Build actions if any',
default: true,
Expand Down
181 changes: 80 additions & 101 deletions src/commands/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ class Deploy extends BuildCommand {
const { flags } = await this.parse(Deploy)

// flags
flags['web-assets'] = flags['web-assets'] && !flags['skip-web-assets'] && !flags['skip-static'] && !flags.action
flags.actions = flags.actions && !flags['skip-actions']
flags['web-assets'] = flags['web-assets'] && !flags.action
flags.publish = flags.publish && !flags.action
flags.build = flags.build && !flags['skip-build']

const deployConfigs = this.getAppExtConfigs(flags)
const keys = Object.keys(deployConfigs)
Expand All @@ -45,9 +43,7 @@ class Deploy extends BuildCommand {
}

if (
(!flags.publish && !flags['web-assets'] && !flags.actions) ||
// NOTE skip deploy is deprecated
(!flags.publish && !flags.build && flags['skip-deploy'])
(!flags.publish && !flags['web-assets'] && !flags.actions)
) {
this.error('Nothing to be done 🚫')
}
Expand Down Expand Up @@ -144,103 +140,101 @@ class Deploy extends BuildCommand {

const filterActions = flags.action

if (!flags['skip-deploy']) {
try {
await runScript(config.hooks['pre-app-deploy'])
} catch (err) {
this.log(err)
}
try {
await runScript(config.hooks['pre-app-deploy'])
} catch (err) {
this.log(err)
}

if (flags.actions) {
if (config.app.hasBackend) {
let filterEntities
if (filterActions) {
filterEntities = { actions: filterActions }
if (flags.actions) {
if (config.app.hasBackend) {
let filterEntities
if (filterActions) {
filterEntities = { actions: filterActions }
}
const message = `Deploying actions for '${name}'`
spinner.start(message)
try {
const script = await runScript(config.hooks['deploy-actions'])
if (!script) {
deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities }, onProgress)
}
const message = `Deploying actions for '${name}'`
spinner.start(message)
try {
const script = await runScript(config.hooks['deploy-actions'])
if (!script) {
deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities }, onProgress)
}

if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
spinner.succeed(chalk.green(`Deployed ${deployedRuntimeEntities.actions.length} action(s) for '${name}'`))
if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
spinner.succeed(chalk.green(`Deployed ${deployedRuntimeEntities.actions.length} action(s) for '${name}'`))
} else {
if (script) {
spinner.fail(chalk.green(`deploy-actions skipped by hook '${name}'`))
} else {
if (script) {
spinner.fail(chalk.green(`deploy-actions skipped by hook '${name}'`))
} else {
spinner.fail(chalk.green(`No actions deployed for '${name}'`))
}
spinner.fail(chalk.green(`No actions deployed for '${name}'`))
}
} catch (err) {
spinner.fail(chalk.green(message))
throw err
}
} else {
this.log(`no backend, skipping action deploy '${name}'`)
} catch (err) {
spinner.fail(chalk.green(message))
throw err
}
} else {
this.log(`no backend, skipping action deploy '${name}'`)
}
}

if (flags['web-assets']) {
if (config.app.hasFrontend) {
const message = `Deploying web assets for '${name}'`
spinner.start(message)
try {
const script = await runScript(config.hooks['deploy-static'])
if (script) {
spinner.fail(chalk.green(`deploy-static skipped by hook '${name}'`))
} else {
deployedFrontendUrl = await webLib.deployWeb(config, onProgress)
spinner.succeed(chalk.green(message))
}
} catch (err) {
spinner.fail(chalk.green(message))
throw err
if (flags['web-assets']) {
if (config.app.hasFrontend) {
const message = `Deploying web assets for '${name}'`
spinner.start(message)
try {
const script = await runScript(config.hooks['deploy-static'])
if (script) {
spinner.fail(chalk.green(`deploy-static skipped by hook '${name}'`))
} else {
deployedFrontendUrl = await webLib.deployWeb(config, onProgress)
spinner.succeed(chalk.green(message))
}
} else {
this.log(`no frontend, skipping frontend deploy '${name}'`)
} catch (err) {
spinner.fail(chalk.green(message))
throw err
}
} else {
this.log(`no frontend, skipping frontend deploy '${name}'`)
}
}

// log deployed resources
if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
this.log(chalk.blue(chalk.bold('Your deployed actions:')))
const web = deployedRuntimeEntities.actions.filter(createWebExportFilter(true))
const nonWeb = deployedRuntimeEntities.actions.filter(createWebExportFilter(false))

if (web.length > 0) {
this.log('web actions:')
web.forEach(a => {
this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
})
}
// log deployed resources
if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
this.log(chalk.blue(chalk.bold('Your deployed actions:')))
const web = deployedRuntimeEntities.actions.filter(createWebExportFilter(true))
const nonWeb = deployedRuntimeEntities.actions.filter(createWebExportFilter(false))

if (web.length > 0) {
this.log('web actions:')
web.forEach(a => {
this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
})
}

if (nonWeb.length > 0) {
this.log('non-web actions:')
nonWeb.forEach(a => {
this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
})
}
if (nonWeb.length > 0) {
this.log('non-web actions:')
nonWeb.forEach(a => {
this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
})
}
// TODO urls should depend on extension point, exc shell only for exc shell extension point - use a post-app-deploy hook ?
if (deployedFrontendUrl) {
this.log(chalk.blue(chalk.bold(`To view your deployed application:\n -> ${deployedFrontendUrl}`)))
const launchUrl = this.getLaunchUrlPrefix() + deployedFrontendUrl
if (flags.open) {
this.log(chalk.blue(chalk.bold(`Opening your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
cli.open(launchUrl)
} else {
this.log(chalk.blue(chalk.bold(`To view your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
}
}
// TODO urls should depend on extension point, exc shell only for exc shell extension point - use a post-app-deploy hook ?
if (deployedFrontendUrl) {
this.log(chalk.blue(chalk.bold(`To view your deployed application:\n -> ${deployedFrontendUrl}`)))
const launchUrl = this.getLaunchUrlPrefix() + deployedFrontendUrl
if (flags.open) {
this.log(chalk.blue(chalk.bold(`Opening your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
cli.open(launchUrl)
} else {
this.log(chalk.blue(chalk.bold(`To view your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
}
}

try {
await runScript(config.hooks['post-app-deploy'])
} catch (err) {
this.log(err)
}
try {
await runScript(config.hooks['post-app-deploy'])
} catch (err) {
this.log(err)
}
}

Expand Down Expand Up @@ -276,21 +270,6 @@ This will always force a rebuild unless --no-force-build is set.

Deploy.flags = {
...BaseCommand.flags,
'skip-build': Flags.boolean({
description: '[deprecated] Please use --no-build'
}),
'skip-deploy': Flags.boolean({
description: '[deprecated] Please use \'aio app build\''
}),
'skip-static': Flags.boolean({
description: '[deprecated] Please use --no-web-assets'
}),
'skip-web-assets': Flags.boolean({
description: '[deprecated] Please use --no-web-assets'
}),
'skip-actions': Flags.boolean({
description: '[deprecated] Please use --no-actions'
}),
actions: Flags.boolean({
description: '[default: true] Deploy actions if any',
default: true,
Expand Down
16 changes: 4 additions & 12 deletions src/commands/app/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class Run extends BaseCommand {
async run () {
// cli input
const { flags } = await this.parse(Run)
// aliases
flags.actions = flags.actions && !flags['skip-actions']

const spinner = ora()

Expand Down Expand Up @@ -64,8 +62,8 @@ class Run extends BaseCommand {
if (!hasBackend && !hasFrontend) {
this.error(new Error('nothing to run.. there is no frontend and no manifest.yml, are you in a valid app?'))
}
if (flags['skip-actions'] && !hasFrontend) {
this.error(new Error('nothing to run.. there is no frontend and --skip-actions is set'))
if (!flags.actions && !hasFrontend) {
this.error(new Error('nothing to run.. there is no frontend and --no-actions is set'))
}

const runOptions = {
Expand Down Expand Up @@ -203,22 +201,16 @@ Run.description = 'Run an Adobe I/O App'
Run.flags = {
...BaseCommand.flags,
local: Flags.boolean({
description: 'Run/debug actions locally ( requires Docker running )',
exclusive: ['skip-actions']
description: 'Run/debug actions locally (requires Docker running)',
exclusive: ['no-actions']
}),
serve: Flags.boolean({
description: '[default: true] Start frontend server (experimental)',
default: true,
allowNo: true
}),
'skip-actions': Flags.boolean({
description: '[deprecated] Please use --no-actions',
exclusive: ['local'],
default: false
}),
actions: Flags.boolean({
description: '[default: true] Run actions, defaults to true, to skip actions use --no-actions',
exclusive: ['local'], // no-actions and local don't work together
default: true,
allowNo: true
}),
Expand Down
13 changes: 0 additions & 13 deletions src/commands/app/undeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class Undeploy extends BaseCommand {
// cli input
const { flags } = await this.parse(Undeploy)

// flags
flags['web-assets'] = flags['web-assets'] && !flags['skip-static'] && !flags['skip-web-assets'] && !flags.action
flags.actions = flags.actions && !flags['skip-actions']

const undeployConfigs = this.getAppExtConfigs(flags)
let libConsoleCLI
if (flags.unpublish) {
Expand Down Expand Up @@ -146,15 +142,6 @@ Undeploy.description = `Undeploys an Adobe I/O App

Undeploy.flags = {
...BaseCommand.flags,
'skip-static': Flags.boolean({
description: '[deprecated] Please use --no-web-assets'
}),
'skip-web-assets': Flags.boolean({
description: '[deprecated] Please use --no-web-assets'
}),
'skip-actions': Flags.boolean({
description: '[deprecated] Please use --no-actions'
}),
actions: Flags.boolean({
description: '[default: true] Undeploy actions if any',
default: true,
Expand Down
Loading

0 comments on commit 1828633

Please sign in to comment.