Skip to content

Commit c62684d

Browse files
committed
fix: refactor away to a shared types
1 parent 2f7e339 commit c62684d

5 files changed

Lines changed: 24 additions & 62 deletions

File tree

src/base/deployBase.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
22
import { Messages, Org } from '@salesforce/core';
33
import { DatacodeBinaryChecker, type DatacodeDeployExecutionResult } from '../utils/datacodeBinaryChecker.js';
44
import { checkEnvironment } from '../utils/environmentChecker.js';
5+
import { type SharedResultProps } from './types.js';
56

67
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
78
const messages = Messages.loadMessages('data-code-extension', 'deploy');
@@ -16,27 +17,11 @@ export type BaseDeployFlags = {
1617
network?: string;
1718
};
1819

19-
export type DeployResult = {
20-
success: boolean;
21-
pythonVersion: {
22-
version: string;
23-
command: string;
24-
};
25-
packageInfo?: {
26-
name: string;
27-
version: string;
28-
};
29-
binaryInfo?: {
30-
command: string;
31-
version: string;
32-
};
33-
codeType: 'script' | 'function';
34-
packageDir: string;
20+
export type DeployResult = SharedResultProps & {
3521
targetOrg: string;
3622
deploymentId?: string;
3723
endpointUrl?: string;
3824
status?: string;
39-
message: string;
4025
executionResult?: DatacodeDeployExecutionResult;
4126
};
4227

src/base/initBase.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
22
import { Messages } from '@salesforce/core';
3-
import { type PythonVersionInfo } from '../utils/pythonChecker.js';
4-
import { type PipPackageInfo } from '../utils/pipChecker.js';
5-
import {
6-
DatacodeBinaryChecker,
7-
type DatacodeBinaryInfo,
8-
type DatacodeInitExecutionResult,
9-
} from '../utils/datacodeBinaryChecker.js';
3+
import { DatacodeBinaryChecker, type DatacodeInitExecutionResult } from '../utils/datacodeBinaryChecker.js';
104
import { checkEnvironment } from '../utils/environmentChecker.js';
5+
import { type SharedResultProps } from './types.js';
116

127
export type BaseInitFlags = {
138
'package-dir': string;
149
};
1510

16-
export type InitResult = {
17-
success: boolean;
18-
pythonVersion: PythonVersionInfo;
19-
packageInfo?: PipPackageInfo;
20-
binaryInfo?: DatacodeBinaryInfo;
21-
codeType: 'script' | 'function';
22-
packageDir: string;
23-
message: string;
11+
export type InitResult = SharedResultProps & {
2412
executionResult?: DatacodeInitExecutionResult;
2513
};
2614

src/base/runBase.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
22
import { Messages, Org } from '@salesforce/core';
3-
import { type PythonVersionInfo } from '../utils/pythonChecker.js';
4-
import { type PipPackageInfo } from '../utils/pipChecker.js';
5-
import {
6-
DatacodeBinaryChecker,
7-
type DatacodeBinaryInfo,
8-
type DatacodeRunExecutionResult,
9-
} from '../utils/datacodeBinaryChecker.js';
3+
import { DatacodeBinaryChecker, type DatacodeRunExecutionResult } from '../utils/datacodeBinaryChecker.js';
104
import { checkEnvironment } from '../utils/environmentChecker.js';
5+
import { type SharedResultProps } from './types.js';
116

127
export type BaseRunFlags = {
138
entrypoint: string;
@@ -16,17 +11,10 @@ export type BaseRunFlags = {
1611
dependencies?: string;
1712
};
1813

19-
export type RunResult = {
20-
success: boolean;
21-
pythonVersion: PythonVersionInfo;
22-
packageInfo?: PipPackageInfo;
23-
binaryInfo?: DatacodeBinaryInfo;
24-
codeType: 'script' | 'function';
25-
packageDir: string;
14+
export type RunResult = SharedResultProps & {
2615
targetOrg: string;
2716
status?: string;
2817
output?: string;
29-
message: string;
3018
executionResult?: DatacodeRunExecutionResult;
3119
};
3220

src/base/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { type PythonVersionInfo } from '../utils/pythonChecker.js';
2+
import { type PipPackageInfo } from '../utils/pipChecker.js';
3+
import { type DatacodeBinaryInfo } from '../utils/datacodeBinaryChecker.js';
4+
5+
export type SharedResultProps = {
6+
success: boolean;
7+
pythonVersion: PythonVersionInfo;
8+
packageInfo?: PipPackageInfo;
9+
binaryInfo?: DatacodeBinaryInfo;
10+
codeType: 'script' | 'function';
11+
packageDir: string;
12+
message: string;
13+
};

src/base/zipBase.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
import { existsSync } from 'node:fs';
22
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
33
import { Messages, SfError } from '@salesforce/core';
4-
import { type PythonVersionInfo } from '../utils/pythonChecker.js';
5-
import { type PipPackageInfo } from '../utils/pipChecker.js';
6-
import {
7-
DatacodeBinaryChecker,
8-
type DatacodeBinaryInfo,
9-
type DatacodeZipExecutionResult,
10-
} from '../utils/datacodeBinaryChecker.js';
4+
import { DatacodeBinaryChecker, type DatacodeZipExecutionResult } from '../utils/datacodeBinaryChecker.js';
115
import { checkEnvironment } from '../utils/environmentChecker.js';
6+
import { type SharedResultProps } from './types.js';
127

138
export type BaseZipFlags = {
149
'package-dir': string;
1510
network?: string;
1611
};
1712

18-
export type ZipResult = {
19-
success: boolean;
20-
pythonVersion: PythonVersionInfo;
21-
packageInfo?: PipPackageInfo;
22-
binaryInfo?: DatacodeBinaryInfo;
23-
codeType: 'script' | 'function';
24-
packageDir: string;
13+
export type ZipResult = SharedResultProps & {
2514
archivePath?: string;
26-
message: string;
2715
executionResult?: DatacodeZipExecutionResult;
2816
};
2917

0 commit comments

Comments
 (0)