Skip to content

Commit 0c11432

Browse files
Merge pull request #3 from red-gate/arrow-function
Only arrow function style
2 parents 40cc15b + e467dec commit 0c11432

File tree

6 files changed

+40
-34
lines changed

6 files changed

+40
-34
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default tseslint.config(
1515
],
1616
'@typescript-eslint/explicit-function-return-type': 'off',
1717
'@typescript-eslint/no-explicit-any': 'warn',
18+
'func-style': ['error', 'expression', { allowArrowFunctions: true }],
1819
},
1920
}
2021
);

flyway/migrate/dist/index.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

flyway/migrate/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default tseslint.config(
1515
],
1616
'@typescript-eslint/explicit-function-return-type': 'off',
1717
'@typescript-eslint/no-explicit-any': 'warn',
18+
'func-style': ['error', 'expression', { allowArrowFunctions: true }],
1819
},
1920
}
2021
);

flyway/migrate/src/flyway-runner.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { INPUT_DEFINITIONS } from './inputs.js';
66
/**
77
* Build the Flyway command arguments from inputs
88
*/
9-
export function buildFlywayArgs(inputs: FlywayMigrateInputs): string[] {
9+
export const buildFlywayArgs = (inputs: FlywayMigrateInputs): string[] => {
1010
const args: string[] = ['migrate'];
1111

1212
// Process all standard inputs
@@ -45,12 +45,12 @@ export function buildFlywayArgs(inputs: FlywayMigrateInputs): string[] {
4545
}
4646

4747
return args;
48-
}
48+
};
4949

5050
/**
5151
* Parse extra args string into array, handling quoted strings
5252
*/
53-
export function parseExtraArgs(extraArgs: string): string[] {
53+
export const parseExtraArgs = (extraArgs: string): string[] => {
5454
const args: string[] = [];
5555
let current = '';
5656
let inQuotes = false;
@@ -80,12 +80,12 @@ export function parseExtraArgs(extraArgs: string): string[] {
8080
}
8181

8282
return args;
83-
}
83+
};
8484

8585
/**
8686
* Check if Flyway is available in PATH
8787
*/
88-
export async function checkFlywayInstalled(): Promise<boolean> {
88+
export const checkFlywayInstalled = async (): Promise<boolean> => {
8989
try {
9090
await exec.exec('flyway', ['--version'], {
9191
silent: true,
@@ -95,12 +95,12 @@ export async function checkFlywayInstalled(): Promise<boolean> {
9595
} catch {
9696
return false;
9797
}
98-
}
98+
};
9999

100100
/**
101101
* Get Flyway version
102102
*/
103-
export async function getFlywayVersion(): Promise<string> {
103+
export const getFlywayVersion = async (): Promise<string> => {
104104
let stdout = '';
105105

106106
await exec.exec('flyway', ['--version'], {
@@ -115,12 +115,12 @@ export async function getFlywayVersion(): Promise<string> {
115115
// Parse version from output like "Flyway Community Edition 10.0.0"
116116
const match = stdout.match(/Flyway\s+(?:Community|Teams|Enterprise)\s+Edition\s+(\d+\.\d+\.\d+)/);
117117
return match ? match[1] : 'unknown';
118-
}
118+
};
119119

120120
/**
121121
* Run the Flyway migrate command
122122
*/
123-
export async function runFlyway(inputs: FlywayMigrateInputs): Promise<FlywayRunResult> {
123+
export const runFlyway = async (inputs: FlywayMigrateInputs): Promise<FlywayRunResult> => {
124124
const args = buildFlywayArgs(inputs);
125125

126126
let stdout = '';
@@ -148,12 +148,12 @@ export async function runFlyway(inputs: FlywayMigrateInputs): Promise<FlywayRunR
148148
const exitCode = await exec.exec('flyway', args, options);
149149

150150
return { exitCode, stdout, stderr };
151-
}
151+
};
152152

153153
/**
154154
* Mask sensitive values in args for logging
155155
*/
156-
export function maskArgsForLog(args: string[]): string[] {
156+
export const maskArgsForLog = (args: string[]): string[] => {
157157
const sensitivePatterns = [/^-password=/i, /^-user=/i, /^-vault\.token=/i, /^-url=.*password=/i];
158158

159159
return args.map((arg) => {
@@ -165,15 +165,17 @@ export function maskArgsForLog(args: string[]): string[] {
165165
}
166166
return arg;
167167
});
168-
}
168+
};
169169

170170
/**
171171
* Parse Flyway output to extract migration information
172172
*/
173-
export function parseFlywayOutput(stdout: string): {
173+
export const parseFlywayOutput = (
174+
stdout: string
175+
): {
174176
migrationsApplied: number;
175177
schemaVersion: string;
176-
} {
178+
} => {
177179
let migrationsApplied = 0;
178180
let schemaVersion = 'unknown';
179181

@@ -210,21 +212,21 @@ export function parseFlywayOutput(stdout: string): {
210212
}
211213

212214
return { migrationsApplied, schemaVersion };
213-
}
215+
};
214216

215217
/**
216218
* Set action outputs
217219
*/
218-
export function setOutputs(outputs: FlywayMigrateOutputs): void {
220+
export const setOutputs = (outputs: FlywayMigrateOutputs): void => {
219221
core.setOutput('exit-code', outputs.exitCode.toString());
220222
core.setOutput('flyway-version', outputs.flywayVersion);
221223
core.setOutput('migrations-applied', outputs.migrationsApplied.toString());
222224
core.setOutput('schema-version', outputs.schemaVersion);
223-
}
225+
};
224226

225227
/**
226228
* Convert kebab-case to camelCase
227229
*/
228-
function toCamelCase(str: string): string {
230+
const toCamelCase = (str: string): string => {
229231
return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
230-
}
232+
};

flyway/migrate/src/inputs.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const INPUT_DEFINITIONS: InputDefinition[] = [
129129
/**
130130
* Parse boolean input from string
131131
*/
132-
export function parseBoolean(value: string | undefined): boolean | undefined {
132+
export const parseBoolean = (value: string | undefined): boolean | undefined => {
133133
if (value === undefined || value === '') {
134134
return undefined;
135135
}
@@ -141,12 +141,12 @@ export function parseBoolean(value: string | undefined): boolean | undefined {
141141
return false;
142142
}
143143
throw new Error(`Invalid boolean value: ${value}`);
144-
}
144+
};
145145

146146
/**
147147
* Parse number input from string
148148
*/
149-
export function parseNumber(value: string | undefined): number | undefined {
149+
export const parseNumber = (value: string | undefined): number | undefined => {
150150
if (value === undefined || value === '') {
151151
return undefined;
152152
}
@@ -155,13 +155,15 @@ export function parseNumber(value: string | undefined): number | undefined {
155155
throw new Error(`Invalid number value: ${value}`);
156156
}
157157
return num;
158-
}
158+
};
159159

160160
/**
161161
* Parse placeholders from comma-separated key=value pairs
162162
* Format: "key1=value1,key2=value2"
163163
*/
164-
export function parsePlaceholders(value: string | undefined): Record<string, string> | undefined {
164+
export const parsePlaceholders = (
165+
value: string | undefined
166+
): Record<string, string> | undefined => {
165167
if (value === undefined || value === '') {
166168
return undefined;
167169
}
@@ -189,12 +191,12 @@ export function parsePlaceholders(value: string | undefined): Record<string, str
189191
}
190192

191193
return Object.keys(placeholders).length > 0 ? placeholders : undefined;
192-
}
194+
};
193195

194196
/**
195197
* Get all inputs from the GitHub Action context
196198
*/
197-
export function getInputs(): FlywayMigrateInputs {
199+
export const getInputs = (): FlywayMigrateInputs => {
198200
const url = core.getInput('url', { required: true });
199201

200202
const inputs: FlywayMigrateInputs = { url };
@@ -236,23 +238,23 @@ export function getInputs(): FlywayMigrateInputs {
236238
}
237239

238240
return inputs;
239-
}
241+
};
240242

241243
/**
242244
* Convert kebab-case to camelCase
243245
*/
244-
export function toCamelCase(str: string): string {
246+
export const toCamelCase = (str: string): string => {
245247
return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
246-
}
248+
};
247249

248250
/**
249251
* Mask secret inputs in the log
250252
*/
251-
export function maskSecrets(inputs: FlywayMigrateInputs): void {
253+
export const maskSecrets = (inputs: FlywayMigrateInputs): void => {
252254
if (inputs.password) {
253255
core.setSecret(inputs.password);
254256
}
255257
if (inputs.vaultToken) {
256258
core.setSecret(inputs.vaultToken);
257259
}
258-
}
260+
};

flyway/migrate/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
setOutputs,
99
} from './flyway-runner.js';
1010

11-
async function run(): Promise<void> {
11+
const run = async (): Promise<void> => {
1212
try {
1313
// Check if Flyway is installed
1414
const flywayInstalled = await checkFlywayInstalled();
@@ -66,6 +66,6 @@ async function run(): Promise<void> {
6666
core.setFailed('An unexpected error occurred');
6767
}
6868
}
69-
}
69+
};
7070

7171
run();

0 commit comments

Comments
 (0)