-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdeploy.ts
More file actions
44 lines (37 loc) · 1.58 KB
/
deploy.ts
File metadata and controls
44 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import {Args} from '@oclif/core';
import {uploadCartridges} from '@salesforce/b2c-tooling';
import {InstanceCommand} from '@salesforce/b2c-tooling/cli';
import {t} from '../../i18n/index.js';
export default class Deploy extends InstanceCommand<typeof Deploy> {
static args = {
cartridgePath: Args.string({
description: 'Path to cartridges directory',
default: './cartridges',
}),
};
static description = t('commands.code.deploy.description', 'Deploy cartridges to a B2C Commerce instance');
static examples = [
'<%= config.bin %> <%= command.id %>',
'<%= config.bin %> <%= command.id %> ./my-cartridges',
'<%= config.bin %> <%= command.id %> --server my-sandbox.demandware.net --code-version v1',
];
async run(): Promise<void> {
this.requireCodeVersion();
this.requireWebDavCredentials();
const path = this.args.cartridgePath;
const hostname = this.resolvedConfig.hostname!;
const version = this.resolvedConfig.codeVersion!;
this.log(t('commands.code.deploy.deploying', 'Deploying cartridges from {{path}}...', {path}));
this.log(t('commands.code.deploy.target', 'Target: {{hostname}}', {hostname}));
this.log(t('commands.code.deploy.codeVersion', 'Code Version: {{version}}', {version}));
try {
await uploadCartridges(this.instance, path);
this.log(t('commands.code.deploy.complete', 'Deployment complete'));
} catch (error) {
if (error instanceof Error) {
this.error(t('commands.code.deploy.failed', 'Deployment failed: {{message}}', {message: error.message}));
}
throw error;
}
}
}