Skip to content

Commit 4d1b0a1

Browse files
committed
Reformat with prettier
1 parent 4cc2c01 commit 4d1b0a1

File tree

5 files changed

+171
-171
lines changed

5 files changed

+171
-171
lines changed

ReplaceVersion.js

+53-45
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,85 @@
11
module.exports = {
2-
replace: function replaceVersion (body, dependency) {
3-
const oldVersion = dependency.oldVersion
4-
const newVersion = dependency.version
2+
replace: function replaceVersion(body, dependency) {
3+
const oldVersion = dependency.oldVersion;
4+
const newVersion = dependency.version;
55

6-
const replaceActions = []
6+
const replaceActions = [];
77

8-
const regexVersionVariable = new RegExp(dependency.group + ":" + dependency.name + ":\\${?(\\w+)}?", "ig")
8+
const regexVersionVariable = new RegExp(dependency.group + ":" + dependency.name + ":\\${?(\\w+)}?", "ig");
99

1010
// 'de.kevcodez:pubg-api-wrapper:$myVar'
1111
// 'de.kevcodez:pubg-api-wrapper:${myVar}'
12-
const versionWithVariableMatches = regexVersionVariable.exec(body)
12+
const versionWithVariableMatches = regexVersionVariable.exec(body);
1313
if (versionWithVariableMatches && versionWithVariableMatches.length === 2) {
14-
const variableName = versionWithVariableMatches[1]
14+
const variableName = versionWithVariableMatches[1];
1515

16-
const regexVariableDefinition = new RegExp(`(${variableName}(\\s+)?=(\\s+)?('|")${oldVersion}('|"))`, "ig")
17-
const regexVariableDefinitionMatches = regexVariableDefinition.exec(body)
16+
const regexVariableDefinition = new RegExp(`(${variableName}(\\s+)?=(\\s+)?('|")${oldVersion}('|"))`, "ig");
17+
const regexVariableDefinitionMatches = regexVariableDefinition.exec(body);
1818

1919
if (regexVariableDefinitionMatches && regexVariableDefinitionMatches.length) {
20-
regexVariableDefinitionMatches.filter(it => it.includes(dependency.oldVersion)).forEach(match => {
21-
replaceActions.push({
22-
searchValue: match,
23-
replaceValue: match.replace(dependency.oldVersion, dependency.version)
24-
})
25-
})
20+
regexVariableDefinitionMatches
21+
.filter((it) => it.includes(dependency.oldVersion))
22+
.forEach((match) => {
23+
replaceActions.push({
24+
searchValue: match,
25+
replaceValue: match.replace(dependency.oldVersion, dependency.version),
26+
});
27+
});
2628
}
2729

2830
// val PUBG_API_WRAPPER by extra("0.8.1")
29-
const regexKotlinValExtra = new RegExp(`${variableName}.+\(("|')${oldVersion}("|')\)`)
30-
const regexKotlinValMatches = regexKotlinValExtra.exec(body)
31+
const regexKotlinValExtra = new RegExp(`${variableName}.+\(("|')${oldVersion}("|')\)`);
32+
const regexKotlinValMatches = regexKotlinValExtra.exec(body);
3133
if (regexKotlinValMatches && regexKotlinValMatches.length) {
32-
regexKotlinValMatches.filter(it => it.includes(dependency.oldVersion)).forEach(match => {
33-
replaceActions.push({
34-
searchValue: match,
35-
replaceValue: match.replace(dependency.oldVersion, dependency.version)
36-
})
37-
})
34+
regexKotlinValMatches
35+
.filter((it) => it.includes(dependency.oldVersion))
36+
.forEach((match) => {
37+
replaceActions.push({
38+
searchValue: match,
39+
replaceValue: match.replace(dependency.oldVersion, dependency.version),
40+
});
41+
});
3842
}
3943
}
4044

4145
// compile 'de.kevcodez:pubg-api-wrapper:1.0.0'
42-
const regexVersionInline = new RegExp(`${dependency.group}:${dependency.name}:${dependency.oldVersion}`, "g")
46+
const regexVersionInline = new RegExp(`${dependency.group}:${dependency.name}:${dependency.oldVersion}`, "g");
4347
if (regexVersionInline.exec(body)) {
4448
replaceActions.push({
4549
searchValue: regexVersionInline,
46-
replaceValue: `${dependency.group}:${dependency.name}:${dependency.version}`
47-
})
50+
replaceValue: `${dependency.group}:${dependency.name}:${dependency.version}`,
51+
});
4852
}
4953

5054
// id 'com.github.ben-manes.versions' version "0.21.0"
5155
// id("com.github.ben-manes.versions") version "0.22.0"
52-
const regexPluginVersionWithPrefix = new RegExp(`${dependency.group}("|')\\)?(\\s+)?version(\\s+)?("|')${oldVersion}("|')`)
53-
const regexVersionWithPrefixMatches = regexPluginVersionWithPrefix.exec(body)
56+
const regexPluginVersionWithPrefix = new RegExp(`${dependency.group}("|')\\)?(\\s+)?version(\\s+)?("|')${oldVersion}("|')`);
57+
const regexVersionWithPrefixMatches = regexPluginVersionWithPrefix.exec(body);
5458
if (regexVersionWithPrefixMatches && regexVersionWithPrefixMatches.length) {
55-
regexVersionWithPrefixMatches.filter(it => it.includes(oldVersion)).forEach(match => {
56-
replaceActions.push({
57-
searchValue: match,
58-
replaceValue: match.replace(oldVersion, newVersion)
59-
})
60-
})
59+
regexVersionWithPrefixMatches
60+
.filter((it) => it.includes(oldVersion))
61+
.forEach((match) => {
62+
replaceActions.push({
63+
searchValue: match,
64+
replaceValue: match.replace(oldVersion, newVersion),
65+
});
66+
});
6167
}
6268

6369
// compile group: 'de.kevcodez.pubg', name: 'pubg-api-wrapper', version: '0.8.1'
64-
const regexDependencyWithVersionPrefix = new RegExp(`${dependency.name}('|"),(\\s+)?version:(\\s+)('|")${dependency.oldVersion}('|")`)
65-
const regexDependencyWithVersionPrefixMatches = regexDependencyWithVersionPrefix.exec(body)
70+
const regexDependencyWithVersionPrefix = new RegExp(`${dependency.name}('|"),(\\s+)?version:(\\s+)('|")${dependency.oldVersion}('|")`);
71+
const regexDependencyWithVersionPrefixMatches = regexDependencyWithVersionPrefix.exec(body);
6672
if (regexDependencyWithVersionPrefixMatches && regexDependencyWithVersionPrefixMatches.length) {
67-
regexDependencyWithVersionPrefixMatches.filter(it => it.includes(oldVersion)).forEach(match => {
68-
replaceActions.push({
69-
searchValue: match,
70-
replaceValue: match.replace(oldVersion, newVersion)
71-
})
72-
})
73+
regexDependencyWithVersionPrefixMatches
74+
.filter((it) => it.includes(oldVersion))
75+
.forEach((match) => {
76+
replaceActions.push({
77+
searchValue: match,
78+
replaceValue: match.replace(oldVersion, newVersion),
79+
});
80+
});
7381
}
7482

75-
return replaceActions
76-
}
77-
}
83+
return replaceActions;
84+
},
85+
};

args.js

+39-37
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
1-
const argv = require('yargs')
2-
.option('resolution', {
3-
alias: 'r',
4-
describe: 'Controls the dependency resolution strategy.\nSupported options:\n* release: selects the latest release\n* milestone: select the latest version being either a milestone or a release (default)\n* integration: selects the latest revision of the dependency module (such as SNAPSHOT)',
5-
type: 'string',
6-
nargs: 1,
7-
demand: false
8-
})
9-
.option('semver', {
10-
alias: 's',
11-
describe: 'Which semantic version diffs to include (https://semver.org). Flag can be used multiple times.\nSupported options:\n* major: Include upgrades with a major version change\n* minor: Include upgrades with a minor version change\n* patch: Include upgrades with a patch version change',
12-
type: 'string',
13-
array: true,
14-
nargs: 1,
15-
demand: false
16-
})
17-
.option('external-file', {
18-
alias: 'e',
19-
describe: 'Points to a file where dependencies have been declared, e.g. gradle/dependencies.gradle. Option can be used multiple times.',
20-
type: 'array',
21-
nargs: 1,
22-
demand: false
23-
})
24-
.option('debug', {
25-
alias: 'd',
26-
describe: 'Prints debugging information, such as commands executed and current status.',
27-
type: 'boolean',
28-
demand: false,
29-
default: false
30-
})
31-
.option('no-color', {
32-
describe: 'Disables color output',
33-
nargs: 1,
34-
demand: false
35-
}).argv
1+
const argv = require("yargs")
2+
.option("resolution", {
3+
alias: "r",
4+
describe:
5+
"Controls the dependency resolution strategy.\nSupported options:\n* release: selects the latest release\n* milestone: select the latest version being either a milestone or a release (default)\n* integration: selects the latest revision of the dependency module (such as SNAPSHOT)",
6+
type: "string",
7+
nargs: 1,
8+
demand: false,
9+
})
10+
.option("semver", {
11+
alias: "s",
12+
describe:
13+
"Which semantic version diffs to include (https://semver.org). Flag can be used multiple times.\nSupported options:\n* major: Include upgrades with a major version change\n* minor: Include upgrades with a minor version change\n* patch: Include upgrades with a patch version change",
14+
type: "string",
15+
array: true,
16+
nargs: 1,
17+
demand: false,
18+
})
19+
.option("external-file", {
20+
alias: "e",
21+
describe: "Points to a file where dependencies have been declared, e.g. gradle/dependencies.gradle. Option can be used multiple times.",
22+
type: "array",
23+
nargs: 1,
24+
demand: false,
25+
})
26+
.option("debug", {
27+
alias: "d",
28+
describe: "Prints debugging information, such as commands executed and current status.",
29+
type: "boolean",
30+
demand: false,
31+
default: false,
32+
})
33+
.option("no-color", {
34+
describe: "Disables color output",
35+
nargs: 1,
36+
demand: false,
37+
}).argv;
3638

3739
module.exports = {
38-
argv
39-
}
40+
argv,
41+
};

buildFiles.js

+38-41
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,55 @@
1-
const {
2-
existsSync
3-
} = require('fs');
4-
const {
5-
resolve
6-
} = require('path')
7-
const fs = require('fs')
1+
const { existsSync } = require("fs");
2+
const { resolve } = require("path");
3+
const fs = require("fs");
84

95
function getBuildFiles(externalFiles, debugLog) {
10-
let buildFiles = [];
11-
exports.buildFiles = buildFiles;
12-
if (externalFiles && externalFiles.length) {
13-
externalFiles.forEach(externalFile => {
14-
if (!existsSync(externalFile)) {
15-
console.log(`Unable to find ${externalFile} file.`.bgRed);
16-
return;
17-
} else {
18-
buildFiles.push(externalFile);
19-
}
20-
});
21-
}
6+
let buildFiles = [];
7+
exports.buildFiles = buildFiles;
8+
if (externalFiles && externalFiles.length) {
9+
externalFiles.forEach((externalFile) => {
10+
if (!existsSync(externalFile)) {
11+
console.log(`Unable to find ${externalFile} file.`.bgRed);
12+
return;
13+
} else {
14+
buildFiles.push(externalFile);
15+
}
16+
});
17+
}
2218

23-
const directoryToSearchIn = process.cwd()
19+
const directoryToSearchIn = process.cwd();
2420

25-
debugLog(`Recursively looking for build files in directory ${directoryToSearchIn}`)
21+
debugLog(`Recursively looking for build files in directory ${directoryToSearchIn}`);
2622

27-
const allRecursiveFiles = getAllBuildFiles(directoryToSearchIn)
23+
const allRecursiveFiles = getAllBuildFiles(directoryToSearchIn);
2824

29-
const recursiveBuildFiles = allRecursiveFiles.filter(it => it.endsWith('build.gradle') || it.endsWith('build.gradle.kts'))
25+
const recursiveBuildFiles = allRecursiveFiles.filter((it) => it.endsWith("build.gradle") || it.endsWith("build.gradle.kts"));
3026

31-
buildFiles.push(...recursiveBuildFiles)
27+
buildFiles.push(...recursiveBuildFiles);
3228

33-
return buildFiles
29+
return buildFiles;
3430
}
3531

3632
const getAllBuildFiles = function (dirPath, arrayOfFiles) {
37-
const files = fs.readdirSync(dirPath, {
38-
withFileTypes: true
33+
const files = fs
34+
.readdirSync(dirPath, {
35+
withFileTypes: true,
3936
})
40-
.filter(it => !it.name.startsWith('.') && !it.name.startsWith('node_modules'))
37+
.filter((it) => !it.name.startsWith(".") && !it.name.startsWith("node_modules"));
4138

42-
arrayOfFiles = arrayOfFiles || []
39+
arrayOfFiles = arrayOfFiles || [];
4340

44-
files.forEach((dirent) => {
45-
const resolvedFile = resolve(dirPath, dirent.name);
46-
if (dirent.isDirectory()) {
47-
arrayOfFiles = getAllBuildFiles(resolvedFile, arrayOfFiles)
48-
} else {
49-
arrayOfFiles.push(resolvedFile)
50-
}
51-
})
41+
files.forEach((dirent) => {
42+
const resolvedFile = resolve(dirPath, dirent.name);
43+
if (dirent.isDirectory()) {
44+
arrayOfFiles = getAllBuildFiles(resolvedFile, arrayOfFiles);
45+
} else {
46+
arrayOfFiles.push(resolvedFile);
47+
}
48+
});
5249

53-
return arrayOfFiles
54-
}
50+
return arrayOfFiles;
51+
};
5552

5653
module.exports = {
57-
getBuildFiles
58-
}
54+
getBuildFiles,
55+
};

gradleCommand.js

+36-40
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
1-
const {
2-
spawnSync
3-
} = require('child_process');
4-
const {
5-
existsSync
6-
} = require('fs')
1+
const { spawnSync } = require("child_process");
2+
const { existsSync } = require("fs");
73

84
function determineGradleCommand(debugLog) {
9-
let gradleCommand = null
10-
let gradleWrapper = false
11-
12-
debugLog('Determining gradle command')
13-
14-
try {
15-
const isWindows = process.platform === 'win32'
16-
debugLog('isWindows: ' + isWindows)
17-
const gradleWrapperFile = isWindows ? 'gradlew.bat' : 'gradlew'
18-
19-
debugLog(`Checking if wrapper file ${gradleWrapperFile} exists`)
20-
if (existsSync(gradleWrapperFile)) {
21-
debugLog('Wrapper file exists')
22-
gradleCommand = (isWindows ? '' : './') + gradleWrapperFile
23-
gradleWrapper = true
24-
} else {
25-
debugLog('Wrapper file not found')
26-
}
27-
} catch (err) {
28-
debugLog('Error trying to determine gradle command.')
29-
debugLog(err)
5+
let gradleCommand = null;
6+
let gradleWrapper = false;
7+
8+
debugLog("Determining gradle command");
9+
10+
try {
11+
const isWindows = process.platform === "win32";
12+
debugLog("isWindows: " + isWindows);
13+
const gradleWrapperFile = isWindows ? "gradlew.bat" : "gradlew";
14+
15+
debugLog(`Checking if wrapper file ${gradleWrapperFile} exists`);
16+
if (existsSync(gradleWrapperFile)) {
17+
debugLog("Wrapper file exists");
18+
gradleCommand = (isWindows ? "" : "./") + gradleWrapperFile;
19+
gradleWrapper = true;
20+
} else {
21+
debugLog("Wrapper file not found");
3022
}
31-
32-
if (!gradleCommand) {
33-
const gradleVersion = spawnSync('gradle', ['--version'])
34-
if (gradleVersion.status === 0) {
35-
gradleCommand = 'gradle'
36-
}
23+
} catch (err) {
24+
debugLog("Error trying to determine gradle command.");
25+
debugLog(err);
26+
}
27+
28+
if (!gradleCommand) {
29+
const gradleVersion = spawnSync("gradle", ["--version"]);
30+
if (gradleVersion.status === 0) {
31+
gradleCommand = "gradle";
3732
}
33+
}
3834

39-
debugLog(`Determined gradle command: ${gradleCommand}, wrapper: ${gradleWrapper}`)
35+
debugLog(`Determined gradle command: ${gradleCommand}, wrapper: ${gradleWrapper}`);
4036

41-
return {
42-
gradleCommand,
43-
gradleWrapper
44-
}
37+
return {
38+
gradleCommand,
39+
gradleWrapper,
40+
};
4541
}
4642

4743
module.exports = {
48-
determineGradleCommand
49-
}
44+
determineGradleCommand,
45+
};

0 commit comments

Comments
 (0)