Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 11016d8

Browse files
[HOUSEKEEPING] resolve no-use-before-define page wide eslint disablement (#467)
Co-authored-by: Samiya Akhtar <[email protected]>
1 parent b7d5cd0 commit 11016d8

File tree

1 file changed

+74
-75
lines changed

1 file changed

+74
-75
lines changed

src/commands/deployment/validate.ts

+74-75
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-use-before-define */
21
import commander from "commander";
32
import { Config } from "../../config";
43
import {
@@ -27,42 +26,6 @@ export interface ValidateConfig {
2726
key: string;
2827
}
2928

30-
/**
31-
* Executes the command, can all exit function with 0 or 1
32-
* when command completed successfully or failed respectively.
33-
*
34-
* @param opts validated option values
35-
* @param exitFn exit function
36-
*/
37-
export const execute = async (
38-
opts: CommandOptions,
39-
exitFn: (status: number) => Promise<void>
40-
): Promise<void> => {
41-
try {
42-
const config = isValidConfig(Config());
43-
44-
if (opts.selfTest) {
45-
await runSelfTest(config);
46-
}
47-
await exitFn(0);
48-
} catch (err) {
49-
logger.error(err);
50-
await exitFn(1);
51-
}
52-
};
53-
54-
/**
55-
* Adds the validate command to the commander command object
56-
* @param command Commander command object to decorate
57-
*/
58-
export const commandDecorator = (command: commander.Command): void => {
59-
buildCmd(command, decorator).action(async (opts: CommandOptions) => {
60-
await execute(opts, async (status: number) => {
61-
await exitCmd(logger, process.exit, status);
62-
});
63-
});
64-
};
65-
6629
/**
6730
* Validates that the deployment configuration is specified.
6831
*/
@@ -132,44 +95,6 @@ export const isValidConfig = (config: ConfigYaml): ValidateConfig => {
13295
);
13396
};
13497

135-
/**
136-
* Run the self-test for introspection
137-
*
138-
* @param config spk configuration values
139-
*/
140-
export const runSelfTest = async (config: ValidateConfig): Promise<void> => {
141-
try {
142-
logger.info("Writing self-test data for introspection...");
143-
const buildId = await writeSelfTestData(
144-
config.key,
145-
config.accountName,
146-
config.partitionKey,
147-
config.tableName
148-
);
149-
150-
logger.info("Deleting self-test data...");
151-
const isVerified = await deleteSelfTestData(
152-
config.key,
153-
config.accountName,
154-
config.partitionKey,
155-
config.tableName,
156-
buildId
157-
);
158-
159-
const statusMessage =
160-
"Finished running self-test. Service introspection self-test status: ";
161-
162-
if (!isVerified) {
163-
logger.error(statusMessage + "FAILED. Please try again.");
164-
} else {
165-
logger.info(statusMessage + "SUCCEEDED.");
166-
}
167-
} catch (err) {
168-
logger.error("Error running self-test.");
169-
throw err;
170-
}
171-
};
172-
17398
/**
17499
* Writes self-test pipeline data to the storage account table.
175100
* @param accountKey storage account key
@@ -261,3 +186,77 @@ export const deleteSelfTestData = async (
261186
});
262187
return isDeleted;
263188
};
189+
190+
/**
191+
* Run the self-test for introspection
192+
*
193+
* @param config spk configuration values
194+
*/
195+
export const runSelfTest = async (config: ValidateConfig): Promise<void> => {
196+
try {
197+
logger.info("Writing self-test data for introspection...");
198+
const buildId = await writeSelfTestData(
199+
config.key,
200+
config.accountName,
201+
config.partitionKey,
202+
config.tableName
203+
);
204+
205+
logger.info("Deleting self-test data...");
206+
const isVerified = await deleteSelfTestData(
207+
config.key,
208+
config.accountName,
209+
config.partitionKey,
210+
config.tableName,
211+
buildId
212+
);
213+
214+
const statusMessage =
215+
"Finished running self-test. Service introspection self-test status: ";
216+
217+
if (!isVerified) {
218+
logger.error(statusMessage + "FAILED. Please try again.");
219+
} else {
220+
logger.info(statusMessage + "SUCCEEDED.");
221+
}
222+
} catch (err) {
223+
logger.error("Error running self-test.");
224+
throw err;
225+
}
226+
};
227+
228+
/**
229+
* Executes the command, can all exit function with 0 or 1
230+
* when command completed successfully or failed respectively.
231+
*
232+
* @param opts validated option values
233+
* @param exitFn exit function
234+
*/
235+
export const execute = async (
236+
opts: CommandOptions,
237+
exitFn: (status: number) => Promise<void>
238+
): Promise<void> => {
239+
try {
240+
const config = isValidConfig(Config());
241+
242+
if (opts.selfTest) {
243+
await runSelfTest(config);
244+
}
245+
await exitFn(0);
246+
} catch (err) {
247+
logger.error(err);
248+
await exitFn(1);
249+
}
250+
};
251+
252+
/**
253+
* Adds the validate command to the commander command object
254+
* @param command Commander command object to decorate
255+
*/
256+
export const commandDecorator = (command: commander.Command): void => {
257+
buildCmd(command, decorator).action(async (opts: CommandOptions) => {
258+
await execute(opts, async (status: number) => {
259+
await exitCmd(logger, process.exit, status);
260+
});
261+
});
262+
};

0 commit comments

Comments
 (0)