@adobe/aio-cli-plugin-app 9.2.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,6 @@ const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-
14
14
  const { Flags } = require('@oclif/core')
15
15
 
16
16
  const { atLeastOne, deleteUserConfig } = require('../../../lib/app-helper')
17
- const { implPromptChoices } = require('../../../lib/defaults')
18
17
  const chalk = require('chalk')
19
18
  const fs = require('fs-extra')
20
19
  const { EOL } = require('os')
@@ -59,16 +58,15 @@ class DeleteExtensionCommand extends BaseCommand {
59
58
  throw new Error('There are no implementations left in the project')
60
59
  }
61
60
  if (!flags.extension) {
62
- const alreadyImplementedChoices = implPromptChoices.filter(i => alreadyImplemented.includes(i.value.name))
63
61
  // prompt
64
62
  const answers = await this.prompt([{
65
63
  type: 'checkbox',
66
64
  name: 'res',
67
- message: 'Which new implementation(s) do you wish to add to the project ?',
68
- choices: alreadyImplementedChoices,
65
+ message: 'Which implementation(s) do you wish to delete from the project?',
66
+ choices: alreadyImplemented,
69
67
  validate: atLeastOne
70
68
  }])
71
- flags.extension = answers.res.map(v => v.name)
69
+ flags.extension = answers.res
72
70
  }
73
71
  return this.getAppExtConfigs(flags)
74
72
  }
@@ -110,9 +108,10 @@ DeleteExtensionCommand.flags = {
110
108
  default: false,
111
109
  char: 'y'
112
110
  }),
113
- 'skip-install': Flags.boolean({
114
- description: 'Skip npm installation after files are created',
115
- default: false
111
+ install: Flags.boolean({
112
+ description: '[default: true] Run npm installation after files are created',
113
+ default: true,
114
+ allowNo: true
116
115
  }),
117
116
  extension: Flags.string({
118
117
  description: 'Specify extensions to delete, skips selection prompt',
@@ -34,7 +34,7 @@ class AddServiceCommand extends BaseCommand {
34
34
  // load console configuration from .aio and .env files
35
35
  const projectConfig = config.get('project')
36
36
  if (!projectConfig) {
37
- this.error('Incomplete .aio configuration, please import a valid Adobe Developer Console configuration via `aio app use` first.')
37
+ this.error(`Incomplete .aio configuration, please import a valid Adobe Developer Console configuration via \`${this.config.bin} app use\` first.`)
38
38
  }
39
39
  const orgId = projectConfig.org.id
40
40
  const project = { name: projectConfig.name, id: projectConfig.id }
@@ -27,17 +27,16 @@ class Deploy extends BuildCommand {
27
27
  const { flags } = await this.parse(Deploy)
28
28
 
29
29
  // flags
30
- flags['web-assets'] = flags['web-assets'] && !flags['skip-web-assets'] && !flags['skip-static'] && !flags.action
31
- flags.actions = flags.actions && !flags['skip-actions']
30
+ flags['web-assets'] = flags['web-assets'] && !flags.action
32
31
  flags.publish = flags.publish && !flags.action
33
- flags.build = flags.build && !flags['skip-build']
34
32
 
35
33
  const deployConfigs = this.getAppExtConfigs(flags)
36
34
  const keys = Object.keys(deployConfigs)
37
35
  const values = Object.values(deployConfigs)
36
+ const isStandaloneApp = (keys.length === 1 && keys[0] === 'application')
38
37
 
39
38
  // if there are no extensions, then set publish to false
40
- flags.publish = flags.publish && !(keys.length === 1 && keys[0] === 'application')
39
+ flags.publish = flags.publish && !isStandaloneApp
41
40
  let libConsoleCLI
42
41
  if (flags.publish) {
43
42
  // force login at beginning (if required)
@@ -45,9 +44,7 @@ class Deploy extends BuildCommand {
45
44
  }
46
45
 
47
46
  if (
48
- (!flags.publish && !flags['web-assets'] && !flags.actions) ||
49
- // NOTE skip deploy is deprecated
50
- (!flags.publish && !flags.build && flags['skip-deploy'])
47
+ (!flags.publish && !flags['web-assets'] && !flags.actions)
51
48
  ) {
52
49
  this.error('Nothing to be done 🚫')
53
50
  }
@@ -86,7 +83,7 @@ class Deploy extends BuildCommand {
86
83
  }
87
84
 
88
85
  // 2. Bail if workspace is production and application status is PUBLISHED, honor force-deploy
89
- if (aioConfig.project.workspace.name === 'Production' && !flags['force-deploy']) {
86
+ if (!isStandaloneApp && aioConfig?.project?.workspace?.name === 'Production' && !flags['force-deploy']) {
90
87
  const extension = await this.getApplicationExtension(libConsoleCLI, aioConfig)
91
88
  spinner.info(chalk.dim(JSON.stringify(extension)))
92
89
  if (extension && extension.status === 'PUBLISHED') {
@@ -144,103 +141,101 @@ class Deploy extends BuildCommand {
144
141
 
145
142
  const filterActions = flags.action
146
143
 
147
- if (!flags['skip-deploy']) {
148
- try {
149
- await runScript(config.hooks['pre-app-deploy'])
150
- } catch (err) {
151
- this.log(err)
152
- }
144
+ try {
145
+ await runScript(config.hooks['pre-app-deploy'])
146
+ } catch (err) {
147
+ this.log(err)
148
+ }
153
149
 
154
- if (flags.actions) {
155
- if (config.app.hasBackend) {
156
- let filterEntities
157
- if (filterActions) {
158
- filterEntities = { actions: filterActions }
150
+ if (flags.actions) {
151
+ if (config.app.hasBackend) {
152
+ let filterEntities
153
+ if (filterActions) {
154
+ filterEntities = { actions: filterActions }
155
+ }
156
+ const message = `Deploying actions for '${name}'`
157
+ spinner.start(message)
158
+ try {
159
+ const script = await runScript(config.hooks['deploy-actions'])
160
+ if (!script) {
161
+ deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities }, onProgress)
159
162
  }
160
- const message = `Deploying actions for '${name}'`
161
- spinner.start(message)
162
- try {
163
- const script = await runScript(config.hooks['deploy-actions'])
164
- if (!script) {
165
- deployedRuntimeEntities = await rtLib.deployActions(config, { filterEntities }, onProgress)
166
- }
167
163
 
168
- if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
169
- spinner.succeed(chalk.green(`Deployed ${deployedRuntimeEntities.actions.length} action(s) for '${name}'`))
164
+ if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
165
+ spinner.succeed(chalk.green(`Deployed ${deployedRuntimeEntities.actions.length} action(s) for '${name}'`))
166
+ } else {
167
+ if (script) {
168
+ spinner.fail(chalk.green(`deploy-actions skipped by hook '${name}'`))
170
169
  } else {
171
- if (script) {
172
- spinner.fail(chalk.green(`deploy-actions skipped by hook '${name}'`))
173
- } else {
174
- spinner.fail(chalk.green(`No actions deployed for '${name}'`))
175
- }
170
+ spinner.fail(chalk.green(`No actions deployed for '${name}'`))
176
171
  }
177
- } catch (err) {
178
- spinner.fail(chalk.green(message))
179
- throw err
180
172
  }
181
- } else {
182
- this.log(`no backend, skipping action deploy '${name}'`)
173
+ } catch (err) {
174
+ spinner.fail(chalk.green(message))
175
+ throw err
183
176
  }
177
+ } else {
178
+ this.log(`no backend, skipping action deploy '${name}'`)
184
179
  }
180
+ }
185
181
 
186
- if (flags['web-assets']) {
187
- if (config.app.hasFrontend) {
188
- const message = `Deploying web assets for '${name}'`
189
- spinner.start(message)
190
- try {
191
- const script = await runScript(config.hooks['deploy-static'])
192
- if (script) {
193
- spinner.fail(chalk.green(`deploy-static skipped by hook '${name}'`))
194
- } else {
195
- deployedFrontendUrl = await webLib.deployWeb(config, onProgress)
196
- spinner.succeed(chalk.green(message))
197
- }
198
- } catch (err) {
199
- spinner.fail(chalk.green(message))
200
- throw err
182
+ if (flags['web-assets']) {
183
+ if (config.app.hasFrontend) {
184
+ const message = `Deploying web assets for '${name}'`
185
+ spinner.start(message)
186
+ try {
187
+ const script = await runScript(config.hooks['deploy-static'])
188
+ if (script) {
189
+ spinner.fail(chalk.green(`deploy-static skipped by hook '${name}'`))
190
+ } else {
191
+ deployedFrontendUrl = await webLib.deployWeb(config, onProgress)
192
+ spinner.succeed(chalk.green(message))
201
193
  }
202
- } else {
203
- this.log(`no frontend, skipping frontend deploy '${name}'`)
194
+ } catch (err) {
195
+ spinner.fail(chalk.green(message))
196
+ throw err
204
197
  }
198
+ } else {
199
+ this.log(`no frontend, skipping frontend deploy '${name}'`)
205
200
  }
201
+ }
206
202
 
207
- // log deployed resources
208
- if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
209
- this.log(chalk.blue(chalk.bold('Your deployed actions:')))
210
- const web = deployedRuntimeEntities.actions.filter(createWebExportFilter(true))
211
- const nonWeb = deployedRuntimeEntities.actions.filter(createWebExportFilter(false))
212
-
213
- if (web.length > 0) {
214
- this.log('web actions:')
215
- web.forEach(a => {
216
- this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
217
- })
218
- }
203
+ // log deployed resources
204
+ if (deployedRuntimeEntities.actions && deployedRuntimeEntities.actions.length > 0) {
205
+ this.log(chalk.blue(chalk.bold('Your deployed actions:')))
206
+ const web = deployedRuntimeEntities.actions.filter(createWebExportFilter(true))
207
+ const nonWeb = deployedRuntimeEntities.actions.filter(createWebExportFilter(false))
208
+
209
+ if (web.length > 0) {
210
+ this.log('web actions:')
211
+ web.forEach(a => {
212
+ this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
213
+ })
214
+ }
219
215
 
220
- if (nonWeb.length > 0) {
221
- this.log('non-web actions:')
222
- nonWeb.forEach(a => {
223
- this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
224
- })
225
- }
216
+ if (nonWeb.length > 0) {
217
+ this.log('non-web actions:')
218
+ nonWeb.forEach(a => {
219
+ this.log(chalk.blue(chalk.bold(` -> ${a.url || a.name} `)))
220
+ })
226
221
  }
227
- // TODO urls should depend on extension point, exc shell only for exc shell extension point - use a post-app-deploy hook ?
228
- if (deployedFrontendUrl) {
229
- this.log(chalk.blue(chalk.bold(`To view your deployed application:\n -> ${deployedFrontendUrl}`)))
230
- const launchUrl = this.getLaunchUrlPrefix() + deployedFrontendUrl
231
- if (flags.open) {
232
- this.log(chalk.blue(chalk.bold(`Opening your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
233
- cli.open(launchUrl)
234
- } else {
235
- this.log(chalk.blue(chalk.bold(`To view your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
236
- }
222
+ }
223
+ // TODO urls should depend on extension point, exc shell only for exc shell extension point - use a post-app-deploy hook ?
224
+ if (deployedFrontendUrl) {
225
+ this.log(chalk.blue(chalk.bold(`To view your deployed application:\n -> ${deployedFrontendUrl}`)))
226
+ const launchUrl = this.getLaunchUrlPrefix() + deployedFrontendUrl
227
+ if (flags.open) {
228
+ this.log(chalk.blue(chalk.bold(`Opening your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
229
+ cli.open(launchUrl)
230
+ } else {
231
+ this.log(chalk.blue(chalk.bold(`To view your deployed application in the Experience Cloud shell:\n -> ${launchUrl}`)))
237
232
  }
233
+ }
238
234
 
239
- try {
240
- await runScript(config.hooks['post-app-deploy'])
241
- } catch (err) {
242
- this.log(err)
243
- }
235
+ try {
236
+ await runScript(config.hooks['post-app-deploy'])
237
+ } catch (err) {
238
+ this.log(err)
244
239
  }
245
240
  }
246
241
 
@@ -276,21 +271,6 @@ This will always force a rebuild unless --no-force-build is set.
276
271
 
277
272
  Deploy.flags = {
278
273
  ...BaseCommand.flags,
279
- 'skip-build': Flags.boolean({
280
- description: '[deprecated] Please use --no-build'
281
- }),
282
- 'skip-deploy': Flags.boolean({
283
- description: '[deprecated] Please use \'aio app build\''
284
- }),
285
- 'skip-static': Flags.boolean({
286
- description: '[deprecated] Please use --no-web-assets'
287
- }),
288
- 'skip-web-assets': Flags.boolean({
289
- description: '[deprecated] Please use --no-web-assets'
290
- }),
291
- 'skip-actions': Flags.boolean({
292
- description: '[deprecated] Please use --no-actions'
293
- }),
294
274
  actions: Flags.boolean({
295
275
  description: '[default: true] Deploy actions if any',
296
276
  default: true,