|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const program = require('commander'); |
| 4 | +const cmd = require('../../lib/sse/cmd'); |
| 5 | + |
| 6 | +// List server-side extension custom apps on CX Commerce server |
| 7 | +// $ occ list-apps --url <host> --appKey <appKey> |
| 8 | +// $ occ ls -u <host> -k <appKey> |
| 9 | +program |
| 10 | + .command('list-apps') // sub-command name |
| 11 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 12 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 13 | + .description('List server-side extension custom apps on CX Commerce server') // command description |
| 14 | + // function to execute when command invoked |
| 15 | + .action(async (options) => { |
| 16 | + const response = await cmd.listApps(options); |
| 17 | + console.log(JSON.stringify(response)); |
| 18 | + }); |
| 19 | + |
| 20 | +// Create server-side extension archive |
| 21 | +// $ occ package-app <appName> |
| 22 | +program |
| 23 | + .command('package-app <appName>') // sub-command name |
| 24 | + .description('Create server-side extension archive') // command description |
| 25 | + // function to execute when command invoked |
| 26 | + .action(async (appName) => { |
| 27 | + const response = await cmd.packageApp(appName); |
| 28 | + console.log(JSON.stringify(response)); |
| 29 | + }); |
| 30 | + |
| 31 | +// Upload server-side extension custom app to CX Commerce server |
| 32 | +// $ occ upload-app <appName> --url <host> --appKey <appKey> |
| 33 | +// $ occ ls -u <host> -k <appKey> --a <appName> |
| 34 | +program |
| 35 | + .command('upload-app <appName>') // sub-command name |
| 36 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 37 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 38 | + .option( |
| 39 | + '-x, --exclude <items>', |
| 40 | + 'List of directories excluded from zip package', |
| 41 | + (value) => value.split(','), |
| 42 | + [] |
| 43 | + ) |
| 44 | + .description('Upload server-side extension custom app to CX Commerce server') // command description |
| 45 | + // function to execute when command invoked |
| 46 | + .action(async (appName, options) => { |
| 47 | + const response = await cmd.uploadApp(appName, options); |
| 48 | + console.log(response); |
| 49 | + }); |
| 50 | + |
| 51 | +// Get server-side extension log |
| 52 | +// $ occ server-log --url <host> --appKey <appKey> |
| 53 | +// $ occ server-log -u <host> -k <appKey> |
| 54 | +program |
| 55 | + .command('server-log') // sub-command name |
| 56 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 57 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 58 | + .option( |
| 59 | + '-d, --date [date]', |
| 60 | + 'The date of the log file to return. Will default to the current day if not supplied.' |
| 61 | + ) |
| 62 | + .option( |
| 63 | + '-l, --loggingLevel [loggingLevel]', |
| 64 | + 'The level of the log file to return. must be one of the following; debug, info, warning, error.', |
| 65 | + 'debug' |
| 66 | + ) |
| 67 | + .description('Get server-side extension logs') // command description |
| 68 | + // function to execute when command invoked |
| 69 | + .action(async (options) => { |
| 70 | + const response = await cmd.getServerLogs(options); |
| 71 | + console.log(response); |
| 72 | + }); |
| 73 | + |
| 74 | +// Returns the tail logs from the extension server for the given logging level and date. |
| 75 | +// $ occ tail-log --url <host> --appKey <appKey> |
| 76 | +// $ occ tail-log -u <host> -k <appKey> |
| 77 | +program |
| 78 | + .command('tail-log') // sub-command name |
| 79 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 80 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 81 | + .option( |
| 82 | + '-d, --date [date]', |
| 83 | + 'The date of the log file to return. Will default to the current day if not supplied.' |
| 84 | + ) |
| 85 | + .option( |
| 86 | + '-l, --loggingLevel [loggingLevel]', |
| 87 | + 'The level of the log file to return. must be one of the following; debug, info, warning, error.', |
| 88 | + 'debug' |
| 89 | + ) |
| 90 | + .description('Tail server-side extension logs') // command description |
| 91 | + // function to execute when command invoked |
| 92 | + .action(async (options) => { |
| 93 | + const response = await cmd.getServerLogTail(options); |
| 94 | + console.log(response); |
| 95 | + }); |
| 96 | + |
| 97 | +// Download server-side extension custom app files |
| 98 | +// $ occ download-app <appName> --url <host> --appKey <appKey> |
| 99 | +// $ occ download-app <appName> -u <host> -k <appKey> |
| 100 | +program |
| 101 | + .command('download-app <appName>') // sub-command name |
| 102 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 103 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 104 | + .description('Download server-side custom app files') // command description |
| 105 | + // function to execute when command invoked |
| 106 | + .action(async (appName, options) => { |
| 107 | + const response = await cmd.downloadApp(appName, options); |
| 108 | + console.log(response); |
| 109 | + }); |
| 110 | + |
| 111 | +// List custom app routes |
| 112 | +// $ occ list-routes [appName] --url <host> --appKey <appKey> |
| 113 | +program |
| 114 | + .command('list-routes [appName]') // sub-command name |
| 115 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 116 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 117 | + .description('List custom app routes') // command description |
| 118 | + // function to execute when command invoked |
| 119 | + .action(async (appName, options) => { |
| 120 | + const response = await cmd.listRoutes(appName, options); |
| 121 | + console.log(response); |
| 122 | + }); |
| 123 | + |
| 124 | +// List environment variables |
| 125 | +// $ occ config:list --url <host> --appKey <appKey> |
| 126 | +program |
| 127 | + .command('config:list') // sub-command name |
| 128 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 129 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 130 | + .description('List environment variables') // command description |
| 131 | + // function to execute when command invoked |
| 132 | + .action(async (options) => { |
| 133 | + const response = await cmd.getEnvironmentVariables(options); |
| 134 | + console.log(JSON.stringify(response)); |
| 135 | + }); |
| 136 | + |
| 137 | +// Set environment variables |
| 138 | +// $ occ config:set --url <host> --appKey <appKey> <var> [otherVars] |
| 139 | +program |
| 140 | + .command('config:set <envVar> [otherEnvVars...]') // sub-command name |
| 141 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 142 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 143 | + .description('Set environment variables') // command description |
| 144 | + // function to execute when command invoked |
| 145 | + .action(async (envVar, otherEnvVars, options) => { |
| 146 | + const response = await cmd.setEnvironmentVariables(envVar, otherEnvVars, options); |
| 147 | + console.log(JSON.stringify(response)); |
| 148 | + }); |
| 149 | + |
| 150 | +// Unset environment variables |
| 151 | +// $ occ config:unset --url <host> --appKey <appKey> <var> [otherVars] |
| 152 | +program |
| 153 | + .command('config:unset <envVar> [otherEnvVars...]') // sub-command name |
| 154 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 155 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 156 | + .description('Set environment variables') // command description |
| 157 | + // function to execute when command invoked |
| 158 | + .action(async (envVar, otherEnvVars, options) => { |
| 159 | + const response = await cmd.deleteEnvironmentVariables(envVar, otherEnvVars, options); |
| 160 | + console.log(JSON.stringify(response)); |
| 161 | + }); |
| 162 | + |
| 163 | +// Run tests |
| 164 | +// $ occ run-tests <appName> --url <host> --appKey <appKey> |
| 165 | +program |
| 166 | + .command('run-tests <appName>') // sub-command name |
| 167 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 168 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 169 | + .option('-i, --interval [interval]', 'Interval to wait between polling for results.', 10) |
| 170 | + .option('-t, --maxAttempts [maxAttempts]', 'Total number of attempts.', 5) |
| 171 | + .description('Run tests') // command description |
| 172 | + // function to execute when command invoked |
| 173 | + .action(async (appName, options) => { |
| 174 | + const response = await cmd.runTests(appName, options); |
| 175 | + console.log(JSON.stringify(response)); |
| 176 | + }); |
| 177 | + |
| 178 | +// Upload Apple Pay domain association file |
| 179 | +// $ occ upload-apple-domain-association <file> |
| 180 | +program |
| 181 | + .command('upload-apple-domain-association <filePath>') |
| 182 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 183 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 184 | + .description('Upload Apple Pay domain association file') |
| 185 | + .action(async (filePath, options) => { |
| 186 | + const response = await cmd.uploadAppleDomainAssociation(filePath, options); |
| 187 | + console.log(JSON.stringify(response)); |
| 188 | + }); |
| 189 | + |
| 190 | +// Get Custom Site Settings Config Data |
| 191 | +// $ occ settings:list <gatewayId> |
| 192 | +program |
| 193 | + .command('settings:list <gatewayId>') |
| 194 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 195 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 196 | + .description('Get Custom Site Settings. Get site settings by ID.') |
| 197 | + .action(async (gatewayId, options) => { |
| 198 | + const response = await cmd.getSiteSettings(gatewayId, options); |
| 199 | + console.log(JSON.stringify(response)); |
| 200 | + }); |
| 201 | + |
| 202 | +// Set Site Setting Config Data |
| 203 | +// $ occ settings:set <gatewayId> |
| 204 | +program |
| 205 | + .command('settings:set <gatewayId> <payload>') |
| 206 | + .requiredOption('-u, --url <url>', 'The url to your CX Commerce host.') |
| 207 | + .requiredOption('-k, --appKey <appKey>', 'The application key.') |
| 208 | + .description('Update a Site Settings based on ID and request parameters.') |
| 209 | + .action(async (gatewayId, payload, options) => { |
| 210 | + const response = await cmd.setSiteSettings(gatewayId, payload, options); |
| 211 | + console.log(JSON.stringify(response)); |
| 212 | + }); |
0 commit comments