1
1
/*
2
- Copyright 2020 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
you may not use this file except in compliance with the License. You may obtain a copy
5
5
of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -10,60 +10,52 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
governing permissions and limitations under the License.
11
11
*/
12
12
13
- const { runInProcess, createWebExportFilter } = require ( './app-helper' )
13
+ const { runInProcess } = require ( './app-helper' )
14
14
const { deployActions } = require ( '@adobe/aio-lib-runtime' )
15
+ const logActions = require ( './log-actions' )
15
16
16
17
/**
17
18
* Deploys actions.
18
19
*
19
- * @param {object } config see src/lib/config-loader.js
20
- * @param {boolean } isLocalDev default false, set to true if it's a local deploy
21
- * @param {Function } [log] a log function
22
- * @param {boolean } filter true if a filter by built actions is desired.
20
+ * @private
21
+ * @param {object } options
22
+ * @param {object } options.config see src/lib/config-loader.js
23
+ * @param {object } [options.deployConfig] see https://github.com/adobe/aio-lib-runtime/blob/master/README.md#typedefs
24
+ * @param {Function } [options.log] a log function
25
+ * @param {Function } [options.inprocHook] a hook function
23
26
*/
24
- /** @private */
25
- module . exports = async ( config , isLocalDev = false , log = ( ) => { } , filter = false , inprocHook ) => {
27
+ module . exports = async ( {
28
+ config,
29
+ deployConfig = { } ,
30
+ log = ( ) => { } ,
31
+ inprocHook
32
+ } ) => {
26
33
await runInProcess ( config . hooks [ 'pre-app-deploy' ] , config )
27
- const script = await runInProcess ( config . hooks [ 'deploy-actions' ] , { config, options : { isLocalDev, filter } } )
34
+
35
+ const hookFilterEntities = Array . isArray ( deployConfig . filterEntities ?. actions ) ? deployConfig . filterEntities . actions : [ ]
36
+ const hookData = {
37
+ appConfig : config ,
38
+ filterEntities : hookFilterEntities ,
39
+ isLocalDev : deployConfig . isLocalDev
40
+ }
41
+
42
+ let entities
43
+ const script = await runInProcess ( config . hooks [ 'deploy-actions' ] , hookData )
28
44
if ( ! script ) {
29
- const deployConfig = {
30
- isLocalDev,
31
- filterEntities : {
32
- byBuiltActions : filter
33
- }
34
- }
35
45
if ( inprocHook ) {
36
- const hookFilterEntities = Array . isArray ( filter ) ? filter : [ ]
37
- const hookResults = await inprocHook ( 'deploy-actions' , {
38
- appConfig : config ,
39
- filterEntities : hookFilterEntities ,
40
- isLocalDev
41
- } )
46
+ const hookResults = await inprocHook ( 'deploy-actions' , hookData )
42
47
if ( hookResults ?. failures ?. length > 0 ) {
43
48
// output should be "Error : <plugin-name> : <error-message>\n" for each failure
44
49
log ( 'Error: ' + hookResults . failures . map ( f => `${ f . plugin . name } : ${ f . error . message } ` ) . join ( '\nError: ' ) )
45
50
throw new Error ( `Hook 'deploy-actions' failed with ${ hookResults . failures [ 0 ] . error } ` )
46
51
}
47
52
}
48
- const entities = await deployActions ( config , deployConfig , log )
49
- if ( entities . actions ) {
50
- const web = entities . actions . filter ( createWebExportFilter ( true ) )
51
- const nonWeb = entities . actions . filter ( createWebExportFilter ( false ) )
52
53
53
- if ( web . length > 0 ) {
54
- log ( 'web actions:' )
55
- web . forEach ( a => {
56
- log ( ` -> ${ a . url || a . name } ` )
57
- } )
58
- }
59
-
60
- if ( nonWeb . length > 0 ) {
61
- log ( 'non-web actions:' )
62
- nonWeb . forEach ( a => {
63
- log ( ` -> ${ a . url || a . name } ` )
64
- } )
65
- }
66
- }
54
+ entities = await deployActions ( config , deployConfig , log )
55
+ await logActions ( { entities, log } )
67
56
}
57
+
68
58
await runInProcess ( config . hooks [ 'post-app-deploy' ] , config )
59
+
60
+ return { script, entities }
69
61
}
0 commit comments