Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ed9612b
Add Typescript Tsfmt to Maven Plugin
source-knights Mar 26, 2020
0e429a5
Update README.md
source-knights Mar 26, 2020
bb72ebd
Update README to include tsfmt maven plugin
source-knights Mar 26, 2020
ae05010
Update CHANGES.md
source-knights Mar 26, 2020
588990a
Update CHANGES.md
source-knights Mar 26, 2020
e973a2e
Fix unit test, correct xml end tag
source-knights Mar 26, 2020
2ebe163
Spotless apply
source-knights Mar 26, 2020
6a71794
Merge branch 'master' of https://github.com/source-knights/spotless
source-knights Mar 26, 2020
588aa43
Spotless apply
source-knights Mar 26, 2020
528e708
Merge branch 'master' into master
nedtwigg Mar 28, 2020
811c661
Make the Typescript defaults a little less expensive to compute, and …
nedtwigg Mar 29, 2020
90a1870
Condense the typescript docs for plugin-maven.
nedtwigg Mar 29, 2020
97beb15
DRY on test files - reveals that tsfmtInline and tsconfig are both no…
nedtwigg Mar 29, 2020
8c10f56
Make it easier to run single maven-plugin tests from the IDE.
nedtwigg Mar 29, 2020
7bd2220
Fix warning about -color
nedtwigg Mar 29, 2020
e9da142
Fix types in the inline config.
nedtwigg Mar 29, 2020
2641254
Fix buildDir going into Tsfmt
source-knights Mar 30, 2020
9ac7a49
Fix tsconfig file
source-knights Mar 30, 2020
33b13f6
spotless apply
source-knights Mar 30, 2020
80cc770
Fix issue with FileLocator and tsconfig file
source-knights Mar 30, 2020
daff537
spotless apply
source-knights Mar 30, 2020
839bcbd
spotless apply
source-knights Mar 30, 2020
56ddfcb
add tsconfig test to plugin gradle
source-knights Mar 30, 2020
5593769
Make the buildDir a non-optional part of FileLocator.
nedtwigg Mar 31, 2020
5f4bbfa
Give FileLocator an in-place locator capability.
nedtwigg Mar 31, 2020
6d21884
Make the gradle tests use the same test files as the maven and lib te…
nedtwigg Mar 31, 2020
9567b07
Remove @Nullable from the maven plugin.
nedtwigg Mar 31, 2020
2f77a77
Revert all ned's commits since the last good commit by @source-knights
nedtwigg Apr 2, 2020
3d791da
Put the baseDir into FileLocator, and ensure that names match their "…
nedtwigg Apr 2, 2020
f5d9e07
Make the gradle tests use the same test files as the maven and lib te…
nedtwigg Mar 31, 2020
7d21bf4
Extracted `Tsfmt.locateFile` into `Tsfmt.locateLocal`.
nedtwigg Apr 2, 2020
1bb33d6
Remove maven-plugin info from the lib changelog.
nedtwigg Apr 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Give FileLocator an in-place locator capability.
  • Loading branch information
nedtwigg committed Mar 31, 2020
commit 5f4bbfa5616f46acbf65c08d362e85d6ff26e5cd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.Objects;
import java.util.UUID;

import javax.annotation.Nullable;

import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.FileResourceCreationException;
import org.codehaus.plexus.resource.loader.ResourceNotFoundException;
Expand All @@ -38,7 +40,11 @@ public FileLocator(ResourceManager resourceManager, File buildDir) {
this.buildDir = Objects.requireNonNull(buildDir);
}

public File locateFile(String path) {
/**
* Resolves the given file (not folder) from the project directory, but does so by copying it to a random
* filename with the same extension in the build directory.
*/
public @Nullable File locateFile(@Nullable String path) {
if (isNullOrEmpty(path)) {
return null;
}
Expand All @@ -58,7 +64,14 @@ private static String tmpOutputFileName(String path) {
return TMP_RESOURCE_FILE_PREFIX + UUID.randomUUID() + '.' + extension;
}

public File getBuildDir() {
return this.buildDir;
/**
* Resolves the given file or folder from the project directory, doesn't have to exist.
*/
public File resolve(String path) {
if (path.isEmpty() || path.equals(".")) {
return buildDir;
} else {
return new File(buildDir, path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.diffplug.spotless.maven.typescript;

import static com.diffplug.common.base.Strings.isNullOrEmpty;

import java.io.File;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -59,22 +57,8 @@ public class Tsfmt implements FormatterStepFactory {
@Parameter
private Map<String, String> config;

private File locateFile(String path) {
if (isNullOrEmpty(path)) {
return null;
}

File exists = new File(path);
if (exists.exists()) {
return exists;
}

throw new RuntimeException("Unable to locate file with path: " + path);
}

@Override
public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {

Map<String, String> devDependencies = TsFmtFormatterStep.defaultDevDependencies();
if (typescriptFormatterVersion != null) {
devDependencies.put("typescript-formatter", typescriptFormatterVersion);
Expand All @@ -100,13 +84,13 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
}
configInline = null;
if (this.tsconfigFile != null) {
configFile = new TypedTsFmtConfigFile(TsConfigFileType.TSCONFIG, locateFile(tsconfigFile));
configFile = new TypedTsFmtConfigFile(TsConfigFileType.TSCONFIG, stepConfig.getFileLocator().resolve(tsconfigFile));
} else if (this.tsfmtFile != null) {
configFile = new TypedTsFmtConfigFile(TsConfigFileType.TSFMT, locateFile(tsfmtFile));
configFile = new TypedTsFmtConfigFile(TsConfigFileType.TSFMT, stepConfig.getFileLocator().resolve(tsfmtFile));
} else if (this.tslintFile != null) {
configFile = new TypedTsFmtConfigFile(TsConfigFileType.TSLINT, locateFile(tslintFile));
configFile = new TypedTsFmtConfigFile(TsConfigFileType.TSLINT, stepConfig.getFileLocator().resolve(tslintFile));
} else if (this.vscodeFile != null) {
configFile = new TypedTsFmtConfigFile(TsConfigFileType.VSCODE, locateFile(vscodeFile));
configFile = new TypedTsFmtConfigFile(TsConfigFileType.VSCODE, stepConfig.getFileLocator().resolve(vscodeFile));
} else {
throw new Error("Programming error: the xors did not match the cases");
}
Expand All @@ -129,7 +113,7 @@ public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) {
throw onlyOneConfig();
}

File buildDir = stepConfig.getFileLocator().getBuildDir();
File buildDir = stepConfig.getFileLocator().resolve(".");
return TsFmtFormatterStep.create(devDependencies, stepConfig.getProvisioner(), buildDir, npm, configFile, configInline);
}

Expand Down