@adobe/aio-cli-plugin-app 10.5.0 → 10.7.0

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.
package/README.md CHANGED
@@ -71,7 +71,7 @@ DESCRIPTION
71
71
  Create, run, test, and deploy Adobe I/O Apps
72
72
  ```
73
73
 
74
- _See code: [src/commands/app/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/index.ts)_
74
+ _See code: [src/commands/app/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/index.ts)_
75
75
 
76
76
  ## `aio app add`
77
77
 
@@ -89,7 +89,7 @@ DESCRIPTION
89
89
  Add a new component to an existing Adobe I/O App
90
90
  ```
91
91
 
92
- _See code: [src/commands/app/add/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/add/index.ts)_
92
+ _See code: [src/commands/app/add/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/add/index.ts)_
93
93
 
94
94
  ## `aio app add action`
95
95
 
@@ -114,7 +114,7 @@ ALIASES
114
114
  $ aio app add actions
115
115
  ```
116
116
 
117
- _See code: [src/commands/app/add/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/add/action.ts)_
117
+ _See code: [src/commands/app/add/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/add/action.ts)_
118
118
 
119
119
  ## `aio app add ci`
120
120
 
@@ -132,7 +132,7 @@ DESCRIPTION
132
132
  Add CI files
133
133
  ```
134
134
 
135
- _See code: [src/commands/app/add/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/add/ci.ts)_
135
+ _See code: [src/commands/app/add/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/add/ci.ts)_
136
136
 
137
137
  ## `aio app add event`
138
138
 
@@ -140,14 +140,16 @@ Add a new Adobe I/O Events action
140
140
 
141
141
  ```
142
142
  USAGE
143
- $ aio app add event [-v] [--version] [--install] [-y] [-e <value>]
143
+ $ aio app add event [-v] [--version] [--install] [-y] [-e <value>] [--experimental-allow-events-templates]
144
144
 
145
145
  FLAGS
146
- -e, --extension=<value> Add actions to a specific extension
147
- -v, --verbose Verbose output
148
- -y, --yes Skip questions, and use all default values
149
- --[no-]install [default: true] Run npm installation after files are created
150
- --version Show version
146
+ -e, --extension=<value> Add events to a specific extension
147
+ -v, --verbose Verbose output
148
+ -y, --yes Skip questions, and use all default values
149
+ --experimental-allow-events-templates Feature flag to enable events templates. NOTE: skip-prompt will have no effect
150
+ if this flag is enabled.
151
+ --[no-]install [default: true] Run npm installation after files are created
152
+ --version Show version
151
153
 
152
154
  DESCRIPTION
153
155
  Add a new Adobe I/O Events action
@@ -157,7 +159,7 @@ ALIASES
157
159
  $ aio app add events
158
160
  ```
159
161
 
160
- _See code: [src/commands/app/add/event.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/add/event.ts)_
162
+ _See code: [src/commands/app/add/event.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/add/event.ts)_
161
163
 
162
164
  ## `aio app add extension`
163
165
 
@@ -183,7 +185,7 @@ ALIASES
183
185
  $ aio app add extensions
184
186
  ```
185
187
 
186
- _See code: [src/commands/app/add/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/add/extension.ts)_
188
+ _See code: [src/commands/app/add/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/add/extension.ts)_
187
189
 
188
190
  ## `aio app add service`
189
191
 
@@ -207,7 +209,7 @@ ALIASES
207
209
  $ aio app add services
208
210
  ```
209
211
 
210
- _See code: [src/commands/app/add/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/add/service.ts)_
212
+ _See code: [src/commands/app/add/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/add/service.ts)_
211
213
 
212
214
  ## `aio app add web-assets`
213
215
 
@@ -228,7 +230,7 @@ DESCRIPTION
228
230
  Add web assets support
229
231
  ```
230
232
 
231
- _See code: [src/commands/app/add/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/add/web-assets.ts)_
233
+ _See code: [src/commands/app/add/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/add/web-assets.ts)_
232
234
 
233
235
  ## `aio app build`
234
236
 
@@ -257,7 +259,7 @@ DESCRIPTION
257
259
  This will always force a rebuild unless --no-force-build is set.
258
260
  ```
259
261
 
260
- _See code: [src/commands/app/build.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/build.ts)_
262
+ _See code: [src/commands/app/build.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/build.ts)_
261
263
 
262
264
  ## `aio app create [PATH]`
263
265
 
@@ -279,7 +281,7 @@ DESCRIPTION
279
281
  Create a new Adobe I/O App with default parameters
280
282
  ```
281
283
 
282
- _See code: [src/commands/app/create.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/create.ts)_
284
+ _See code: [src/commands/app/create.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/create.ts)_
283
285
 
284
286
  ## `aio app delete`
285
287
 
@@ -297,7 +299,7 @@ DESCRIPTION
297
299
  Delete a component from an existing Adobe I/O App
298
300
  ```
299
301
 
300
- _See code: [src/commands/app/delete/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/delete/index.ts)_
302
+ _See code: [src/commands/app/delete/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/delete/index.ts)_
301
303
 
302
304
  ## `aio app delete action [ACTION-NAME]`
303
305
 
@@ -323,7 +325,7 @@ ALIASES
323
325
  $ aio app delete actions
324
326
  ```
325
327
 
326
- _See code: [src/commands/app/delete/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/delete/action.ts)_
328
+ _See code: [src/commands/app/delete/action.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/delete/action.ts)_
327
329
 
328
330
  ## `aio app delete ci`
329
331
 
@@ -342,7 +344,7 @@ DESCRIPTION
342
344
  Delete existing CI files
343
345
  ```
344
346
 
345
- _See code: [src/commands/app/delete/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/delete/ci.ts)_
347
+ _See code: [src/commands/app/delete/ci.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/delete/ci.ts)_
346
348
 
347
349
  ## `aio app delete event [EVENT-ACTION-NAME]`
348
350
 
@@ -368,7 +370,7 @@ ALIASES
368
370
  $ aio app delete events
369
371
  ```
370
372
 
371
- _See code: [src/commands/app/delete/event.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/delete/event.ts)_
373
+ _See code: [src/commands/app/delete/event.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/delete/event.ts)_
372
374
 
373
375
  ## `aio app delete extension`
374
376
 
@@ -394,7 +396,7 @@ ALIASES
394
396
  $ aio app delete extensions
395
397
  ```
396
398
 
397
- _See code: [src/commands/app/delete/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/delete/extension.ts)_
399
+ _See code: [src/commands/app/delete/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/delete/extension.ts)_
398
400
 
399
401
  ## `aio app delete service`
400
402
 
@@ -418,7 +420,7 @@ ALIASES
418
420
  $ aio app delete services
419
421
  ```
420
422
 
421
- _See code: [src/commands/app/delete/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/delete/service.ts)_
423
+ _See code: [src/commands/app/delete/service.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/delete/service.ts)_
422
424
 
423
425
  ## `aio app delete web-assets`
424
426
 
@@ -437,7 +439,7 @@ DESCRIPTION
437
439
  Delete existing web assets
438
440
  ```
439
441
 
440
- _See code: [src/commands/app/delete/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/delete/web-assets.ts)_
442
+ _See code: [src/commands/app/delete/web-assets.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/delete/web-assets.ts)_
441
443
 
442
444
  ## `aio app deploy`
443
445
 
@@ -477,7 +479,7 @@ DESCRIPTION
477
479
  This will always force a rebuild unless --no-force-build is set.
478
480
  ```
479
481
 
480
- _See code: [src/commands/app/deploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/deploy.ts)_
482
+ _See code: [src/commands/app/deploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/deploy.ts)_
481
483
 
482
484
  ## `aio app get-url [ACTION]`
483
485
 
@@ -500,7 +502,7 @@ DESCRIPTION
500
502
  Get action URLs
501
503
  ```
502
504
 
503
- _See code: [src/commands/app/get-url.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/get-url.ts)_
505
+ _See code: [src/commands/app/get-url.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/get-url.ts)_
504
506
 
505
507
  ## `aio app info`
506
508
 
@@ -522,7 +524,7 @@ DESCRIPTION
522
524
  Display settings/configuration in use by an Adobe I/O App
523
525
  ```
524
526
 
525
- _See code: [src/commands/app/info.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/info.ts)_
527
+ _See code: [src/commands/app/info.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/info.ts)_
526
528
 
527
529
  ## `aio app init [PATH]`
528
530
 
@@ -556,7 +558,7 @@ DESCRIPTION
556
558
  Create a new Adobe I/O App
557
559
  ```
558
560
 
559
- _See code: [src/commands/app/init.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/init.ts)_
561
+ _See code: [src/commands/app/init.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/init.ts)_
560
562
 
561
563
  ## `aio app list`
562
564
 
@@ -574,7 +576,7 @@ DESCRIPTION
574
576
  List components for Adobe I/O App
575
577
  ```
576
578
 
577
- _See code: [src/commands/app/list/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/list/index.ts)_
579
+ _See code: [src/commands/app/list/index.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/list/index.ts)_
578
580
 
579
581
  ## `aio app list extension`
580
582
 
@@ -599,7 +601,7 @@ ALIASES
599
601
  $ aio app list extensions
600
602
  ```
601
603
 
602
- _See code: [src/commands/app/list/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/list/extension.ts)_
604
+ _See code: [src/commands/app/list/extension.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/list/extension.ts)_
603
605
 
604
606
  ## `aio app logs`
605
607
 
@@ -623,7 +625,7 @@ DESCRIPTION
623
625
  Fetch logs for an Adobe I/O App
624
626
  ```
625
627
 
626
- _See code: [src/commands/app/logs.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/logs.ts)_
628
+ _See code: [src/commands/app/logs.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/logs.ts)_
627
629
 
628
630
  ## `aio app run`
629
631
 
@@ -646,7 +648,7 @@ DESCRIPTION
646
648
  Run an Adobe I/O App
647
649
  ```
648
650
 
649
- _See code: [src/commands/app/run.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/run.ts)_
651
+ _See code: [src/commands/app/run.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/run.ts)_
650
652
 
651
653
  ## `aio app test`
652
654
 
@@ -674,7 +676,7 @@ DESCRIPTION
674
676
  If the extension has a hook called 'test' in its 'ext.config.yaml', the script specified will be run instead.
675
677
  ```
676
678
 
677
- _See code: [src/commands/app/test.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/test.ts)_
679
+ _See code: [src/commands/app/test.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/test.ts)_
678
680
 
679
681
  ## `aio app undeploy`
680
682
 
@@ -699,7 +701,7 @@ DESCRIPTION
699
701
  Undeploys an Adobe I/O App
700
702
  ```
701
703
 
702
- _See code: [src/commands/app/undeploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/undeploy.ts)_
704
+ _See code: [src/commands/app/undeploy.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/undeploy.ts)_
703
705
 
704
706
  ## `aio app use [CONFIG_FILE_PATH]`
705
707
 
@@ -747,5 +749,5 @@ DESCRIPTION
747
749
  page in https://developer.adobe.com/console/
748
750
  ```
749
751
 
750
- _See code: [src/commands/app/use.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.5.0/src/commands/app/use.ts)_
752
+ _See code: [src/commands/app/use.ts](https://github.com/adobe/aio-cli-plugin-app/blob/10.7.0/src/commands/app/use.ts)_
751
753
  <!-- commandsstop -->
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "10.5.0",
2
+ "version": "10.7.0",
3
3
  "commands": {
4
4
  "app:build": {
5
5
  "id": "app:build",
@@ -1104,8 +1104,14 @@
1104
1104
  "name": "extension",
1105
1105
  "type": "option",
1106
1106
  "char": "e",
1107
- "description": "Add actions to a specific extension",
1107
+ "description": "Add events to a specific extension",
1108
1108
  "multiple": false
1109
+ },
1110
+ "experimental-allow-events-templates": {
1111
+ "name": "experimental-allow-events-templates",
1112
+ "type": "boolean",
1113
+ "description": "Feature flag to enable events templates. NOTE: skip-prompt will have no effect if this flag is enabled.",
1114
+ "allowNo": false
1109
1115
  }
1110
1116
  },
1111
1117
  "args": {}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@adobe/aio-cli-plugin-app",
3
3
  "description": "Create, Build and Deploy Adobe I/O Applications",
4
- "version": "10.5.0",
4
+ "version": "10.7.0",
5
5
  "author": "Adobe Inc.",
6
6
  "bugs": "https://github.com/adobe/aio-cli-plugin-app/issues",
7
7
  "dependencies": {
8
- "@adobe/aio-cli-lib-app-config": "^1.0.1",
8
+ "@adobe/aio-cli-lib-app-config": "^1.1.0",
9
9
  "@adobe/aio-cli-lib-console": "^4.1.0",
10
10
  "@adobe/aio-lib-core-config": "^4.0.0",
11
11
  "@adobe/aio-lib-core-logging": "^2.0.0",
@@ -82,7 +82,7 @@
82
82
  "packages": {
83
83
  "type": "object",
84
84
  "patternProperties": {
85
- "^[A-Za-z0-9-_\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff]{1,20}$": {
85
+ "^([\\w]|[\\w][\\w@ .-]*[\\w@.-]+)$": {
86
86
  "$ref": "#/definitions/package"
87
87
  }
88
88
  },
@@ -98,7 +98,7 @@
98
98
  "actions": {
99
99
  "type": "object",
100
100
  "patternProperties": {
101
- "^[A-Za-z0-9-_\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff]{1,20}$": {
101
+ "^([\\w]|[\\w][\\w@ .-]*[\\w@.-]+)$": {
102
102
  "$ref": "#/definitions/action"
103
103
  }
104
104
  },
@@ -212,8 +212,7 @@
212
212
  "redirect_uri": {
213
213
  "type": "array",
214
214
  "items": {
215
- "type": "string",
216
- "format": "uri"
215
+ "type": "string"
217
216
  }
218
217
  }
219
218
  },
@@ -230,8 +229,7 @@
230
229
  "redirect_uri": {
231
230
  "type": "array",
232
231
  "items": {
233
- "type": "string",
234
- "format": "uri"
232
+ "type": "string"
235
233
  }
236
234
  }
237
235
  },
@@ -19,7 +19,7 @@
19
19
  "type": "object",
20
20
  "properties": {
21
21
  "id": { "type": "string" },
22
- "version": { "type": "string" }
22
+ "version": { "type": "string", "pattern": "^[0-9]+.[0-9]+.[0-9]+$" }
23
23
  },
24
24
  "required": ["id", "version"]
25
25
  },
@@ -29,22 +29,6 @@
29
29
  "default": []
30
30
  },
31
31
  "meshConfig": {
32
- "type": "object",
33
- "properties": {
34
- "meshConfig": { "$ref": "#/definitions/meshConfigNested" },
35
- "meshId": {
36
- "type": "string"
37
- },
38
- "lastUpdatedBy": { "type": "object" },
39
- "lastUpdated": {
40
- "type": "string",
41
- "pattern": "(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)((-(\\d{2}):(\\d{2})|Z)?)"
42
- },
43
- "meshStatus": { "type": "string" }
44
- },
45
- "required": ["meshConfig", "meshId"]
46
- },
47
- "meshConfigNested": {
48
32
  "type": "object",
49
33
  "properties": {
50
34
  "sources": {
@@ -118,6 +118,22 @@ class BaseCommand extends Command {
118
118
  return configData
119
119
  }
120
120
 
121
+ getEventsConfigFile (implName) {
122
+ let configKey
123
+ if (implName === APPLICATION_CONFIG_KEY) {
124
+ configKey = APPLICATION_CONFIG_KEY
125
+ } else {
126
+ configKey = `${EXTENSIONS_CONFIG_KEY}.${implName}`
127
+ }
128
+ let configData = this.getConfigFileForKey(`${configKey}.events`)
129
+ if (!configData.file) {
130
+ // first events manifest is not defined
131
+ configData = this.getConfigFileForKey(`${configKey}`)
132
+ configData.key = configData.key + '.events'
133
+ }
134
+ return configData
135
+ }
136
+
121
137
  getConfigFileForKey (fullKey) {
122
138
  // NOTE: the index returns undefined if the key is loaded from a legacy configuration file
123
139
  const fullConfig = this.getFullConfig()
@@ -10,14 +10,16 @@ governing permissions and limitations under the License.
10
10
  */
11
11
 
12
12
  const AddCommand = require('../../../AddCommand')
13
+ const TemplatesCommand = require('../../../TemplatesCommand')
13
14
  const yeoman = require('yeoman-environment')
14
15
  const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:add:event', { provider: 'debug' })
15
16
  const { Flags } = require('@oclif/core')
16
17
  const ora = require('ora')
17
18
  const path = require('path')
18
19
  const generators = require('@adobe/generator-aio-app')
20
+ const TemplateRegistryAPI = require('@adobe/aio-lib-templates')
19
21
 
20
- class AddEventCommand extends AddCommand {
22
+ class AddEventCommand extends TemplatesCommand {
21
23
  async run () {
22
24
  const { flags } = await this.parse(AddEventCommand)
23
25
 
@@ -29,27 +31,63 @@ class AddEventCommand extends AddCommand {
29
31
  if (entries.length > 1) {
30
32
  this.error('Please use the \'-e\' flag to specify to which implementation you want to add events to.')
31
33
  }
34
+
32
35
  const configName = entries[0][0]
33
36
  const config = entries[0][1]
34
37
  const actionFolder = path.relative(config.root, config.actions.src)
35
- const configData = this.getRuntimeManifestConfigFile(configName)
38
+ const runtimeManifestData = this.getRuntimeManifestConfigFile(configName)
39
+
40
+ const templateOptions = {
41
+ 'skip-prompt': false,
42
+ 'action-folder': actionFolder,
43
+ 'config-path': runtimeManifestData.file,
44
+ 'full-key-to-manifest': runtimeManifestData.key
45
+ }
36
46
 
37
- const env = yeoman.createEnv()
38
- // by default yeoman runs the install, we control installation from the app plugin
39
- env.options = { skipInstall: true }
40
- const eventsGen = env.instantiate(generators['add-events'], {
41
- options: {
42
- 'skip-prompt': flags.yes,
43
- 'action-folder': actionFolder,
44
- 'config-path': configData.file,
45
- 'full-key-to-manifest': configData.key,
46
- // force overwrites, no useless prompts, this is a feature exposed by yeoman itself
47
- force: true
47
+ if (flags['experimental-allow-events-templates']) {
48
+ const eventsData = this.getEventsConfigFile(configName)
49
+ templateOptions['full-key-to-events-manifest'] = eventsData.key
50
+ const [searchCriteria, orderByCriteria] = await this.getSearchCriteria()
51
+ const templates = await this.selectTemplates(searchCriteria, orderByCriteria)
52
+ if (templates.length === 0) {
53
+ this.error('No events templates were chosen to be installed.')
54
+ } else {
55
+ await this.installTemplates({
56
+ useDefaultValues: flags.yes,
57
+ installNpm: flags.install,
58
+ templateOptions,
59
+ templates
60
+ })
48
61
  }
49
- })
50
- await env.runGenerator(eventsGen)
62
+ // by default yeoman runs the install, we control installation from the app plugin
63
+ } else {
64
+ templateOptions['skip-prompt'] = flags.yes
65
+ templateOptions.force = true
66
+ const env = yeoman.createEnv()
67
+ env.options = { skipInstall: true }
68
+ const eventsGen = env.instantiate(generators['add-events'], {
69
+ options: templateOptions
70
+ })
71
+ await env.runGenerator(eventsGen)
51
72
 
52
- await this.runInstallPackages(flags, spinner)
73
+ await this.runInstallPackages(flags, spinner)
74
+ }
75
+ }
76
+
77
+ async getSearchCriteria () {
78
+ const TEMPLATE_CATEGORIES = ['events', 'helper-template']
79
+ const searchCriteria = {
80
+ [TemplateRegistryAPI.SEARCH_CRITERIA_STATUSES]: TemplateRegistryAPI.TEMPLATE_STATUS_APPROVED,
81
+ [TemplateRegistryAPI.SEARCH_CRITERIA_CATEGORIES]: TEMPLATE_CATEGORIES,
82
+ [TemplateRegistryAPI.SEARCH_CRITERIA_EXTENSIONS]: TemplateRegistryAPI.SEARCH_CRITERIA_FILTER_NONE
83
+ }
84
+
85
+ // an optional OrderBy Criteria object
86
+ const orderByCriteria = {
87
+ [TemplateRegistryAPI.ORDER_BY_CRITERIA_PUBLISH_DATE]: TemplateRegistryAPI.ORDER_BY_CRITERIA_SORT_DESC
88
+ }
89
+
90
+ return [searchCriteria, orderByCriteria]
53
91
  }
54
92
  }
55
93
 
@@ -63,11 +101,15 @@ AddEventCommand.flags = {
63
101
  char: 'y'
64
102
  }),
65
103
  extension: Flags.string({
66
- description: 'Add actions to a specific extension',
104
+ description: 'Add events to a specific extension',
67
105
  char: 'e',
68
106
  multiple: false,
69
107
  parse: str => [str]
70
108
  }),
109
+ 'experimental-allow-events-templates': Flags.boolean({
110
+ description: 'Feature flag to enable events templates. NOTE: skip-prompt will have no effect if this flag is enabled.',
111
+ default: false
112
+ }),
71
113
  ...AddCommand.flags
72
114
  }
73
115
 
@@ -18,8 +18,6 @@ const fs = require('fs-extra')
18
18
  const execa = require('execa')
19
19
  const unzipper = require('unzipper')
20
20
  const { validateJsonWithSchema } = require('../../lib/install-helper')
21
- const { loadConfigFile, writeFile } = require('../../lib/import-helper')
22
- const { getObjectValue } = require('../../lib/app-helper')
23
21
  const jsYaml = require('js-yaml')
24
22
  const { USER_CONFIG_FILE, DEPLOY_CONFIG_FILE } = require('../../lib/defaults')
25
23
  const ora = require('ora')
@@ -30,7 +28,6 @@ class InstallCommand extends BaseCommand {
30
28
  const { args, flags } = await this.parse(InstallCommand)
31
29
 
32
30
  this.preRelease()
33
- const appConfig = this.getFullConfig()
34
31
 
35
32
  aioLogger.debug(`flags: ${JSON.stringify(flags, null, 2)}`)
36
33
  aioLogger.debug(`args: ${JSON.stringify(args, null, 2)}`)
@@ -52,7 +49,6 @@ class InstallCommand extends BaseCommand {
52
49
  try {
53
50
  await this.validateZipDirectoryStructure(args.path)
54
51
  await this.unzipFile(args.path, outputPath)
55
- await this.addCodeDownloadAnnotation(outputPath, appConfig)
56
52
  await this.validateConfig(outputPath, USER_CONFIG_FILE)
57
53
  await this.validateConfig(outputPath, DEPLOY_CONFIG_FILE)
58
54
  await this.npmInstall(flags.verbose)
@@ -143,67 +139,6 @@ class InstallCommand extends BaseCommand {
143
139
  }
144
140
  })
145
141
  }
146
-
147
- /**
148
- * An annotation called disable-download will be added to all actions in app.config.yaml
149
- * (and linked yaml configs for example in extensions). This value will be set to true.
150
- * The annotation will by default be false if not set.
151
- *
152
- * @param {object} outputPath the path to the app package
153
- * @param {object} appConfig the app's configuration file
154
- */
155
- async addCodeDownloadAnnotation (outputPath, appConfig) {
156
- this.spinner.start('Adding disable-download annotations...')
157
- // get each annotation key relative to the file it is defined in
158
- /// iterate only over extensions that have actions defined
159
- const fileToAnnotationKey = {}
160
- Object.entries(appConfig.all)
161
- .filter(([_, extConf]) => extConf.manifest?.full?.packages)
162
- .forEach(([ext, extConf]) => {
163
- Object.entries(extConf.manifest.full.packages)
164
- .filter(([pkg, pkgConf]) => pkgConf.actions)
165
- .forEach(([pkg, pkgConf]) => {
166
- Object.entries(pkgConf.actions).forEach(([action, actionConf]) => {
167
- const baseFullKey = ext === 'application'
168
- ? `application.runtimeManifest.packages.${pkg}.actions.${action}`
169
- : `extensions.${ext}.runtimeManifest.packages.${pkg}.actions.${action}`
170
-
171
- let index
172
- if (actionConf.annotations) {
173
- index = appConfig.includeIndex[`${baseFullKey}.annotations`]
174
- } else {
175
- // the annotation object is not defined, take the parent key
176
- index = appConfig.includeIndex[baseFullKey]
177
- }
178
- if (!fileToAnnotationKey[index.file]) {
179
- fileToAnnotationKey[index.file] = []
180
- }
181
- fileToAnnotationKey[index.file].push(index.key) // index.key is relative to the file
182
- })
183
- })
184
- })
185
-
186
- // rewrite config files
187
- for (const [file, keys] of Object.entries(fileToAnnotationKey)) {
188
- const configFilePath = path.join(outputPath, file)
189
- const { values } = loadConfigFile(configFilePath)
190
-
191
- keys.forEach(key => {
192
- const object = getObjectValue(values, key)
193
- if (key.endsWith('.annotations') || key === 'annotations') {
194
- // object is the annotations object
195
- object['disable-download'] = true
196
- } else {
197
- // annotation object is not defined, the object is the action object
198
- object.annotations = { 'disable-download': true }
199
- }
200
- })
201
-
202
- // write back the modified manifest to disk
203
- await writeFile(configFilePath, jsYaml.dump(values), { overwrite: true })
204
- }
205
- this.spinner.succeed('Added disable-download annotations')
206
- }
207
142
  }
208
143
 
209
144
  InstallCommand.hidden = true // hide from help for pre-release
@@ -17,7 +17,8 @@ const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-
17
17
  const archiver = require('archiver')
18
18
  const yaml = require('js-yaml')
19
19
  const execa = require('execa')
20
- const { writeFile } = require('../../lib/import-helper')
20
+ const { loadConfigFile, writeFile } = require('../../lib/import-helper')
21
+ const { getObjectValue } = require('../../lib/app-helper')
21
22
  const ora = require('ora')
22
23
  const chalk = require('chalk')
23
24
 
@@ -69,6 +70,10 @@ class Pack extends BaseCommand {
69
70
  await this.createDeployYamlFile(appConfig)
70
71
  this.spinner.succeed('Created configuration files')
71
72
 
73
+ this.spinner.start('Adding code-download annotations...')
74
+ await this.addCodeDownloadAnnotation(appConfig)
75
+ this.spinner.succeed('Added code-download annotations')
76
+
72
77
  // doing this before zip so other things can be added to the zip
73
78
  await this.config.runHook('post-pack', { appConfig, artifactsFolder: DEFAULTS.ARTIFACTS_FOLDER })
74
79
 
@@ -123,6 +128,10 @@ class Pack extends BaseCommand {
123
128
  version: appConfig.packagejson.version
124
129
  }
125
130
 
131
+ if (!application.version.match(/^[0-9]+.[0-9]+.[0-9]+$/)) {
132
+ throw new Error('Application version format must be "X.Y.Z", where X, Y, and Z are non-negative integers.')
133
+ }
134
+
126
135
  let meshConfig
127
136
  // ACNA-2041
128
137
  // get the mesh config by running the `aio api-mesh:get` command (if available)
@@ -135,7 +144,7 @@ class Pack extends BaseCommand {
135
144
  const { stdout } = await execa('aio', ['api-mesh', 'get'], { cwd: process.cwd() })
136
145
  // until we get the --json flag, we parse the output
137
146
  const idx = stdout.indexOf('{')
138
- meshConfig = JSON.parse(stdout.substring(idx))
147
+ meshConfig = JSON.parse(stdout.substring(idx)).meshConfig
139
148
  aioLogger.debug(`api-mesh:get - ${JSON.stringify(meshConfig, null, 2)}`)
140
149
  this.spinner.succeed('Got api-mesh config')
141
150
  } catch (err) {
@@ -238,6 +247,64 @@ class Pack extends BaseCommand {
238
247
  .map(file => file.path)
239
248
  .filter(file => !filesToExclude.includes(file))
240
249
  }
250
+
251
+ /**
252
+ * An annotation called code-download will be added to all actions in app.config.yaml
253
+ * (and linked yaml configs for example in extensions). This value will be set to false.
254
+ * The annotation will by default be true if not set.
255
+ *
256
+ * @param {object} appConfig the app's configuration file
257
+ */
258
+ async addCodeDownloadAnnotation (appConfig) {
259
+ // get each annotation key relative to the file it is defined in
260
+ /// iterate only over extensions that have actions defined
261
+ const fileToAnnotationKey = {}
262
+ Object.entries(appConfig.all)
263
+ .filter(([_, extConf]) => extConf.manifest?.full?.packages)
264
+ .forEach(([ext, extConf]) => {
265
+ Object.entries(extConf.manifest.full.packages)
266
+ .filter(([pkg, pkgConf]) => pkgConf.actions)
267
+ .forEach(([pkg, pkgConf]) => {
268
+ Object.entries(pkgConf.actions).forEach(([action, actionConf]) => {
269
+ const baseFullKey = ext === 'application'
270
+ ? `application.runtimeManifest.packages.${pkg}.actions.${action}`
271
+ : `extensions.${ext}.runtimeManifest.packages.${pkg}.actions.${action}`
272
+
273
+ let index
274
+ if (actionConf.annotations) {
275
+ index = appConfig.includeIndex[`${baseFullKey}.annotations`]
276
+ } else {
277
+ // the annotation object is not defined, take the parent key
278
+ index = appConfig.includeIndex[baseFullKey]
279
+ }
280
+ if (!fileToAnnotationKey[index.file]) {
281
+ fileToAnnotationKey[index.file] = []
282
+ }
283
+ fileToAnnotationKey[index.file].push(index.key) // index.key is relative to the file
284
+ })
285
+ })
286
+ })
287
+
288
+ // rewrite config files
289
+ for (const [file, keys] of Object.entries(fileToAnnotationKey)) {
290
+ const configFilePath = path.join(DEFAULTS.ARTIFACTS_FOLDER, file)
291
+ const { values } = loadConfigFile(configFilePath)
292
+
293
+ keys.forEach(key => {
294
+ const object = getObjectValue(values, key)
295
+ if (key.endsWith('.annotations') || key === 'annotations') {
296
+ // object is the annotations object
297
+ object['code-download'] = false
298
+ } else {
299
+ // annotation object is not defined, the object is the action object
300
+ object.annotations = { 'code-download': false }
301
+ }
302
+ })
303
+
304
+ // write back the modified manifest to disk
305
+ await writeFile(configFilePath, yaml.dump(values), { overwrite: true })
306
+ }
307
+ }
241
308
  }
242
309
 
243
310
  Pack.hidden = true // hide from help for pre-release