Skip to content

Commit

Permalink
Merge branch 'master' of github.com:LoopPerfect/buckaroo into release…
Browse files Browse the repository at this point in the history
…/1.3.0
  • Loading branch information
njlr committed Aug 11, 2017
2 parents 2d82f2b + 64e9340 commit 420be83
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 10 deletions.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--- Provide a general summary of the issue in the Title above -->

## Description
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->

## Expected Behavior
<!--- Tell us what should happen -->

## Actual Behavior
<!--- Tell us what happens instead -->

## Possible Fix
<!--- Not obligatory, but suggest a fix or reason for the bug -->

## Steps to Reproduce
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- How has this bug affected you? What were you trying to accomplish? -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used:
* Operating System and Architecture:
34 changes: 34 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->

## Related Issue
<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
8 changes: 7 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
buckaroo (1.2.0) unstable; urgency=medium
buckaroo (1.2.1) stable; urgency=low
* Cookbooks are fetched automatically if they don't exist

-- Gaetano Checinski <[email protected]> Wed, 20 Jul 2017 17:00:00 +0100


buckaroo (1.2.0) stable; urgency=medium

* New Architecture based on Rx
* Dependency resolver now async
Expand Down
2 changes: 1 addition & 1 deletion debian/buckaroo.equivs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Homepage: https://buckaroo.pm
Standards-Version: 3.9.2

Package: buckaroo
Version: 1.2.0
Version: 1.2.1
Maintainer: [email protected]
Depends: openjdk-8-jre
Recommends: buck, watchmen, nailgun
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.hash.HashCode;
import com.google.common.io.MoreFiles;
import com.google.common.jimfs.Jimfs;
import com.loopperfect.buckaroo.*;
import com.loopperfect.buckaroo.serialization.Serializers;
Expand Down Expand Up @@ -87,6 +88,14 @@ public void installDirectlyFromGitHub1() throws Exception {

final FileSystem fs = Jimfs.newFileSystem();

// Workaround: JimFs does not implement .toFile;
// We clone and fail buckaroo-recipes if it does not exist, so we create it.
MoreFiles.createParentDirectories(fs.getPath(
System.getProperty("user.home"),
".buckaroo",
"buckaroo-recipes",
".git"));

final ImmutableList<PartialDependency> partialDependencies = ImmutableList.of(
PartialDependency.of(
Identifier.of("github"),
Expand All @@ -112,6 +121,14 @@ public void installDirectlyFromGitHub2() throws Exception {

final FileSystem fs = Jimfs.newFileSystem();

// Workaround: JimFs does not implement .toFile;
// We clone and fail buckaroo-recipes if it does not exist, so we create it.
MoreFiles.createParentDirectories(fs.getPath(
System.getProperty("user.home"),
".buckaroo",
"buckaroo-recipes",
".git"));

final ImmutableList<PartialDependency> partialDependencies = ImmutableList.of(
PartialDependency.of(
Identifier.of("github"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.MoreFiles;
import com.google.common.jimfs.Jimfs;
import com.google.gson.JsonParseException;
import com.loopperfect.buckaroo.*;
Expand All @@ -24,6 +25,14 @@ public void emptyProject() throws Exception {

final FileSystem fs = Jimfs.newFileSystem();

// Workaround: JimFs does not implement .toFile;
// We clone and fail buckaroo-recipes if it does not exist, so we create it.
MoreFiles.createParentDirectories(fs.getPath(
System.getProperty("user.home"),
".buckaroo",
"buckaroo-recipes",
".git"));

final Project project = Project.of();

EvenMoreFiles.writeFile(
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/com/loopperfect/buckaroo/tasks/CommonTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ public static Single<ReadConfigFileEvent> readConfigFile(final Path path) {
.subscribeOn(Schedulers.io());
}


public static Observable<Event> maybeInitCookbooks(final FileSystem fs, final BuckarooConfig config) {

final Path configFolder = fs.getPath(
System.getProperty("user.home"),
".buckaroo");

return Observable.merge(config.cookbooks
.stream()
.filter(cookbook -> !Files.exists(configFolder.resolve(cookbook.name.toString())))
.map(cookbook ->
UpdateTasks.updateCookbook(configFolder, cookbook))
.collect(toImmutableList())
);
}

public static Single<ReadConfigFileEvent> readAndMaybeGenerateConfigFile(final FileSystem fs) {
Preconditions.checkNotNull(fs);
return Single.fromCallable(() -> {
Expand All @@ -174,9 +190,11 @@ public static Single<ReadConfigFileEvent> readAndMaybeGenerateConfigFile(final F
}
return Either.orThrow(Serializers.parseConfig(EvenMoreFiles.read(configFilePath)));
}).map(ReadConfigFileEvent::of)
.subscribeOn(Schedulers.io());
.cache()
.subscribeOn(Schedulers.io());
}


public static Single<FileHashEvent> hash(final Path path) {

Preconditions.checkNotNull(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.nio.file.Path;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.loopperfect.buckaroo.tasks.CommonTasks.maybeInitCookbooks;

public final class InstallTasks {

Expand Down Expand Up @@ -56,7 +57,11 @@ public static Observable<Event> installDependency(
return Process.chain(

// Read the config file
Process.of(CommonTasks.readAndMaybeGenerateConfigFile(projectDirectory.getFileSystem())),
Process.usingLastAsResult(CommonTasks.readAndMaybeGenerateConfigFile(projectDirectory.getFileSystem()).toObservable())
.mapStates(x->(Event)x)
.chain(x -> Process.of(
maybeInitCookbooks(projectDirectory.getFileSystem(), x.config), Single.just(x)
)),

(ReadConfigFileEvent readConfigFileEvent) -> {

Expand Down
15 changes: 12 additions & 3 deletions src/main/java/com/loopperfect/buckaroo/tasks/ResolveTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import com.loopperfect.buckaroo.serialization.Serializers;
import com.loopperfect.buckaroo.sources.RecipeSources;
import io.reactivex.Observable;
import io.reactivex.Single;

import java.nio.file.FileSystem;
import java.nio.file.Path;

import static com.loopperfect.buckaroo.tasks.CommonTasks.maybeInitCookbooks;

public final class ResolveTasks {

private ResolveTasks() {
Expand All @@ -25,9 +28,15 @@ public static Observable<Event> resolveDependencies(final Path projectDirectory)

final Path projectFilePath = projectDirectory.resolve("buckaroo.json").toAbsolutePath();

final Process<Event, ReadConfigFileEvent> p = Process.of(
Observable.just((Event)Notification.of("Resolving dependencies... ")),
CommonTasks.readAndMaybeGenerateConfigFile(projectDirectory.getFileSystem()));
final Process<Event, ReadConfigFileEvent> p = Process.usingLastAsResult(
Observable.just((Event)Notification.of("Resolving dependencies... "))
).chain(x->
Process.usingLastAsResult(CommonTasks.readAndMaybeGenerateConfigFile(
projectDirectory.getFileSystem()).toObservable()
).mapStates(y->(Event)y)
).chain(x -> Process.of(
maybeInitCookbooks(projectDirectory.getFileSystem(), x.config), Single.just(x)
));

return p.chain(config -> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private UpdateTasks() {

}

private static Observable<Event> updateCookbook(final Path folder, final RemoteCookbook cookbook) {
public static Observable<Event> updateCookbook(final Path folder, final RemoteCookbook cookbook) {

Preconditions.checkNotNull(folder);
Preconditions.checkNotNull(cookbook);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static Component render(final DependencyInstallationEvent event) {
Preconditions.checkNotNull(event);
return StackLayout.of(
FlowLayout.of(
Text.of("Downloading: ", Color.GRAY),
Text.of("Downloading: ", Color.CYAN),
render(event.progress.getValue0().identifier)),
ListLayout.of(render(event.progress.getValue1())));
}
Expand All @@ -170,7 +170,7 @@ public static Component render(final FetchRecipeProgressEvent event) {
Preconditions.checkNotNull(event);
return StackLayout.of(
FlowLayout.of(
Text.of("Downloading: ", Color.GRAY),
Text.of("Downloading: ", Color.CYAN),
render(event.identifier)),
ListLayout.of(render(event.progress)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.MoreFiles;
import com.google.common.jimfs.Jimfs;
import com.loopperfect.buckaroo.*;
import com.loopperfect.buckaroo.Process;
Expand Down Expand Up @@ -65,6 +66,14 @@ public void completeDependenciesFailsGracefully() throws Exception {

final FileSystem fs = Jimfs.newFileSystem();

// Workaround: JimFs does not implement .toFile;
// We clone and fail buckaroo-recipes if it does not exist, so we create it.
MoreFiles.createParentDirectories(fs.getPath(
System.getProperty("user.home"),
".buckaroo",
"buckaroo-recipes",
".git"));

final RecipeSource recipeSource = LazyCookbookRecipeSource.of(fs.getPath("nocookbookhere"));

final ImmutableList<PartialDependency> partialDependencies = ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.MoreFiles;
import com.google.common.jimfs.Jimfs;
import com.loopperfect.buckaroo.*;
import com.loopperfect.buckaroo.serialization.Serializers;
Expand All @@ -29,6 +30,14 @@ public void uninstallRemovesTheDependencyFromTheProjectFile() throws Exception {

Files.write(fs.getPath("buckaroo.json"), Serializers.serialize(project).getBytes(Charsets.UTF_8));

// Workaround: JimFs does not implement .toFile;
// We clone and fail buckaroo-recipes if it does not exist, so we create it.
MoreFiles.createParentDirectories(fs.getPath(
System.getProperty("user.home"),
".buckaroo",
"buckaroo-recipes",
".git"));

UninstallTasks.uninstallInWorkingDirectory(
fs,
ImmutableList.of(PartialRecipeIdentifier.of(Identifier.of("example")))).toList().blockingGet();
Expand Down

0 comments on commit 420be83

Please sign in to comment.