Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 11 additions & 10 deletions jo-ssg/src/test/java/com/g2forge/joint/ssg/TestJoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
import com.g2forge.alexandria.media.MediaType;
import com.g2forge.alexandria.test.HAssert;
import com.g2forge.gearbox.command.converter.IMethodArgument;
import com.g2forge.gearbox.command.converter.dumb.ArgumentRenderer;
import com.g2forge.gearbox.command.converter.argumentrenderer.ASimpleArgumentRenderer;
import com.g2forge.gearbox.command.converter.argumentrenderer.ArgumentRenderer;
import com.g2forge.gearbox.command.converter.argumentrenderer.ToStringArgumentRenderer;
import com.g2forge.gearbox.command.converter.dumb.DumbCommandConverter;
import com.g2forge.gearbox.command.converter.dumb.IArgumentRenderer;
import com.g2forge.gearbox.command.converter.dumb.Named;
import com.g2forge.gearbox.command.converter.dumb.ToStringArgumentRenderer;
import com.g2forge.gearbox.command.converter.dumb.Working;
import com.g2forge.gearbox.command.process.MetaCommandArgument;
import com.g2forge.gearbox.command.process.ProcessBuilderRunner;
import com.g2forge.gearbox.command.process.redirect.IRedirect;
import com.g2forge.gearbox.command.proxy.CommandProxyFactory;
Expand All @@ -76,31 +77,31 @@

public class TestJoint {
public interface IJoint {
public class ComponentsArgumentRenderer implements IArgumentRenderer<Set<Joint.Component>> {
public class ComponentsArgumentRenderer extends ASimpleArgumentRenderer<Set<Joint.Component>> {
@Override
public List<String> render(IMethodArgument<Set<Joint.Component>> argument) {
protected List<String> renderSimple(IMethodArgument<Set<Joint.Component>> argument) {
return HCollection.asList("--components", argument.get().stream().map(Object::toString).collect(Collectors.joining(",")));
}
}

public default Stream<String> joint(@Working Path pwd, Path input, Path output, @Named(value = "--operation", joined = false) @ArgumentRenderer(ToStringArgumentRenderer.class) Operation operation, @ArgumentRenderer(ComponentsArgumentRenderer.class) Set<Joint.Component> components) {
throw new ModifyProcessInvocationException(processInvocation -> {
final CommandInvocation<IRedirect, IRedirect> inputCommand = processInvocation.getCommandInvocation();
final CommandInvocationBuilder<IRedirect, IRedirect> commandBuilder = inputCommand.toBuilder();
final CommandInvocation<MetaCommandArgument, IRedirect, IRedirect> inputCommand = processInvocation.getCommandInvocation();
final CommandInvocationBuilder<MetaCommandArgument, IRedirect, IRedirect> commandBuilder = inputCommand.toBuilder();
commandBuilder.clearArguments();

final PathSpec pathSpec = HPlatform.getPlatform().getPathSpec();

// Add the java executable
commandBuilder.argument(System.getProperty("java.home") + pathSpec.getFileSeparator() + "bin" + pathSpec.getFileSeparator() + "java");
commandBuilder.argument(new MetaCommandArgument(System.getProperty("java.home") + pathSpec.getFileSeparator() + "bin" + pathSpec.getFileSeparator() + "java", null));
// Uncomment to enable debugging of the child process
//commandBuilder.argument("-Xdebug");
//commandBuilder.argument("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9000");
// Add the classpath
commandBuilder.argument("-cp").argument(System.getProperty("java.class.path"));
commandBuilder.argument(new MetaCommandArgument("-cp", null)).argument(new MetaCommandArgument(System.getProperty("java.class.path"), null));

// Add the joint class
commandBuilder.argument(Joint.class.getName());
commandBuilder.argument(new MetaCommandArgument(Joint.class.getName(), null));
// Add the joint arguments
commandBuilder.arguments(inputCommand.getArguments().subList(1, inputCommand.getArguments().size()));

Expand Down
18 changes: 2 additions & 16 deletions jo-ui/src/main/java/com/g2forge/joint/ui/UIBuildComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;

Expand All @@ -17,14 +16,10 @@
import com.g2forge.alexandria.java.function.IConsumer1;
import com.g2forge.alexandria.java.io.HIO;
import com.g2forge.alexandria.java.io.HTextIO;
import com.g2forge.gearbox.command.converter.IMethodArgument;
import com.g2forge.gearbox.command.converter.dumb.ArgumentRenderer;
import com.g2forge.gearbox.command.converter.dumb.Command;
import com.g2forge.gearbox.command.converter.dumb.Constant;
import com.g2forge.gearbox.command.converter.dumb.DumbCommandConverter;
import com.g2forge.gearbox.command.converter.dumb.EnvPath;
import com.g2forge.gearbox.command.converter.dumb.HDumbCommandConverter;
import com.g2forge.gearbox.command.converter.dumb.IArgumentRenderer;
import com.g2forge.gearbox.command.converter.dumb.Named;
import com.g2forge.gearbox.command.converter.dumb.Working;
import com.g2forge.gearbox.command.process.ProcessBuilderRunner;
Expand Down Expand Up @@ -107,23 +102,14 @@ public void invoke(IConversionContext context) {
}

public static interface IAngular extends ICommandInterface {
public class NonNullArgumentRenderer implements IArgumentRenderer<Object> {
@Override
public List<String> render(IMethodArgument<Object> argument) {
final Object value = argument.get();
if (value == null) return HCollection.emptyList();
return HDumbCommandConverter.computeString(argument, value.toString());
}
}

@Command({})
public Stream<String> build(@Working Path working, @EnvPath Path node, @Constant({ "run", "build", "--", "--prod" }) Path npm, @Named(value = "--output-path", joined = false) Path output, @Named(value = "--base-href", joined = false) @ArgumentRenderer(NonNullArgumentRenderer.class) String baseHref);
public Stream<String> build(@Working Path working, @EnvPath Path node, @Constant({ "run", "build", "--", "--prod" }) Path npm, @Named(value = "--output-path", joined = false) Path output, @Named(value = "--base-href", joined = false, skipNull = true) String baseHref);

@Command({})
public Stream<String> maps(@Working Path working, @EnvPath Path node, @Constant({ "run", "maps" }) Path npm, Path output);

@Command({})
public Stream<String> serve(@Working Path working, @EnvPath Path node, @Constant({ "run", "serve", "--" }) Path npm, @Named(value = "--port", joined = false) @ArgumentRenderer(NonNullArgumentRenderer.class) Integer port);
public Stream<String> serve(@Working Path working, @EnvPath Path node, @Constant({ "run", "serve", "--" }) Path npm, @Named(value = "--port", joined = false, skipNull = true) Integer port);
}

public static class NonServeFileConversion extends FileConversion {
Expand Down