Skip to content

Commit

Permalink
version 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclefevre committed Nov 23, 2020
1 parent 82ae0d4 commit c3a9530
Show file tree
Hide file tree
Showing 27 changed files with 562 additions and 115 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# v2.0.7 - 2020.11.23
## New features
- upgraded React based stacks to use react-scripts v4.0.1
- added links to documentation in ORDS.js
- display information about the possible upgrade version in the help
- allows to run DRAGON commands inside a stack folder using a specific redirect operator
- added stack environment requirements infrastructure
- added JDK v11 requirements including manual installation steps
- added Node.js v14.15.1 requirements including manual installation steps

# v2.0.6 - 2020.11.18
## Fixes
- creating stacks or loading JSON data is possible after the database has been provisioned
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ __... in 5 minutes.__
[![DRAGON Stack - React Frontend / Autonomous Backend](https://img.youtube.com/vi/DzI9yyAiRjY/0.jpg)](https://www.youtube.com/watch?v=DzI9yyAiRjY)

## Download
The latest stable release is v2.0.6.
The latest stable release is v2.0.7.

### Linux and OCI Cloud Shell
```
rm -f ./dragon-linux-x86_64-2.0.6
wget https://github.com/loiclefevre/dragon/releases/download/v2.0.6/dragon-linux-x86_64-2.0.6
rm -f ./dragon-linux-x86_64-2.0.7
wget https://github.com/loiclefevre/dragon/releases/download/v2.0.7/dragon-linux-x86_64-2.0.7
chmod +x dragon-linux-*
```
Learn about [OCI Cloud shell](https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/cloudshellintro.htm).

### Windows
```
powershell wget https://github.com/loiclefevre/dragon/releases/download/v2.0.6/dragon-windows-x86_64-2.0.6.exe -OutFile dragon-windows-x86_64-2.0.6.exe
powershell wget https://github.com/loiclefevre/dragon/releases/download/v2.0.7/dragon-windows-x86_64-2.0.7.exe -OutFile dragon-windows-x86_64-2.0.7.exe
```
### MAC OS
```
curl -L -O https://github.com/loiclefevre/dragon/releases/download/v2.0.6/dragon-osx-x86_64-2.0.6
curl -L -O https://github.com/loiclefevre/dragon/releases/download/v2.0.7/dragon-osx-x86_64-2.0.7
chmod +x dragon-osx-*
```

Expand Down Expand Up @@ -136,17 +136,17 @@ Example from OCI Cloud Shell (Linux):

Linux and OCI Cloud Shell:
```
$ ./dragon-linux-x86_64-2.0.6
$ ./dragon-linux-x86_64-2.0.7
```

Windows:
```
> dragon-windows-x86_64-2.0.6.exe
> dragon-windows-x86_64-2.0.7.exe
```

MAC OS:
```
$ ./dragon-osx-x86_64-2.0.6
$ ./dragon-osx-x86_64-2.0.7
```

### Loading JSON data
Expand All @@ -155,19 +155,19 @@ If you need to create JSON collections during the provisioning process, you may

To load JSON data as well as provisioning (Linux and OCI Cloud Shell):
```
$ ./dragon-linux-x86_64-2.0.6 -loadjson
$ ./dragon-linux-x86_64-2.0.7 -loadjson
```

To load JSON data as well as provisioning and finally create a React application (Linux and OCI Cloud Shell):
```
$ ./dragon-linux-x86_64-2.0.6 -loadjson -create-react-app myfrontend
$ ./dragon-linux-x86_64-2.0.7 -loadjson -create-react-app myfrontend
```

### Destroying your database

To destroy your database (Linux and OCI Cloud Shell):
```
$ ./dragon-linux-x86_64-2.0.6 -destroy
$ ./dragon-linux-x86_64-2.0.7 -destroy
```

## Stacks
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.oracle</groupId>
<artifactId>dragon</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>

<name>Dragon Stack</name>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/oracle/dragon/DragonStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void main(final String[] args) {

session.loadLocalConfiguration(true);

// may override dbName
// may override dbName...
session.analyzeCommandLineParameters(args);

session.loadConfigurationFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.oracle.dragon.model;

public class LocalDragonConfiguration {
private String redirect;

private String databaseServiceURL;
private String sqlDevWebAdmin;
private String sqlDevWeb;
Expand Down Expand Up @@ -121,4 +123,12 @@ public String getExtractedWallet() {
public void setExtractedWallet(String extractedWallet) {
this.extractedWallet = extractedWallet;
}

public String getRedirect() {
return redirect;
}

public void setRedirect(String redirect) {
this.redirect = redirect;
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/oracle/dragon/model/StackMetadata.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.oracle.dragon.model;

import com.oracle.dragon.stacks.EnvironmentRequirement;

public class StackMetadata {
private String url;
private String[] files;
private int skipDirectoryLevel;
private EnvironmentRequirement[] requires;

public StackMetadata() {
}
Expand Down Expand Up @@ -35,4 +38,12 @@ public int getSkipDirectoryLevel() {
public void setSkipDirectoryLevel(int skipDirectoryLevel) {
this.skipDirectoryLevel = skipDirectoryLevel;
}

public EnvironmentRequirement[] getRequires() {
return requires;
}

public void setRequires(EnvironmentRequirement[] requires) {
this.requires = requires;
}
}
72 changes: 72 additions & 0 deletions src/main/java/com/oracle/dragon/model/Version.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.oracle.dragon.model;

public class Version implements Comparable<Version> {
private int major;
private int middle;
private int minor;

public Version(String version) {
int dot = version.indexOf('.');
major = Integer.parseInt(version.substring(0, dot));
int firstDot = dot;
dot = version.indexOf('.', dot + 1);
middle = Integer.parseInt(version.substring(firstDot + 1, dot));
minor = Integer.parseInt(version.substring(version.lastIndexOf('.') + 1, version.length()));
}

public Version(int major, int middle, int minor) {
this.major = major;
this.middle = middle;
this.minor = minor;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Version version = (Version) o;

if (major != version.major) return false;
if (middle != version.middle) return false;
return minor == version.minor;
}

@Override
public int hashCode() {
int result = major;
result = 31 * result + middle;
result = 31 * result + minor;
return result;
}

private int getLongVersion() {
return 1000000 * major + 1000 * middle + minor;
}

@Override
public int compareTo(Version o) {
if (getLongVersion() < o.getLongVersion()) return -1;
else if (getLongVersion() > o.getLongVersion()) return 1;
else return 0;
}

public int getMajor() {
return major;
}

public int getMiddle() {
return middle;
}

public int getMinor() {
return minor;
}

public static boolean isAboveVersion(String latestVersion, String currentVersion) {
Version current = new Version(currentVersion);
Version maybeNewVersion = new Version(latestVersion);

return current.compareTo(maybeNewVersion) < 0;
}
}
72 changes: 67 additions & 5 deletions src/main/java/com/oracle/dragon/stacks/CodeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.oracle.dragon.model.LocalDragonConfiguration;
import com.oracle.dragon.model.StackMetadata;
import com.oracle.dragon.stacks.requirements.EnvironmentRequirementDeserializer;
import com.oracle.dragon.util.DSSession;
import com.oracle.dragon.util.ZipUtil;
import com.oracle.dragon.util.exception.DSException;
import com.oracle.dragon.util.exception.LoadStackMetadataException;
import com.oracle.dragon.util.exception.StackFileDownloadException;
import com.oracle.dragon.util.exception.StackFileNotFoundException;
import com.oracle.dragon.util.exception.*;
import org.stringtemplate.v4.ST;

import java.io.*;
Expand All @@ -25,7 +24,9 @@
import java.util.Map;
import java.util.stream.Collectors;

import static com.oracle.dragon.util.DSSession.EXECUTABLE_NAME;
import static com.oracle.dragon.util.Console.Style.ANSI_BRIGHT;
import static com.oracle.dragon.util.Console.Style.ANSI_RESET;
import static com.oracle.dragon.util.DSSession.*;

public class CodeGenerator {
private final StackType type;
Expand Down Expand Up @@ -55,9 +56,14 @@ public void work() throws DSException {

String rootResourcesDir = "stacks/";
final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
final SimpleModule indexKeyModule = new SimpleModule();
indexKeyModule.addDeserializer(EnvironmentRequirement.class, new EnvironmentRequirementDeserializer());
mapper.registerModule(indexKeyModule);


if (override != null) {
switch (type) {

case REACT:
section.print("overriding");
try {
Expand All @@ -78,11 +84,18 @@ public void work() throws DSException {
extractFileContent(path, new File(dest, subDir), inputStream);
}
}
} catch( com.fasterxml.jackson.databind.JsonMappingException me ){
section.printlnKO();
throw new UnknownEnvironmentRequirementForStackException(me.getMessage());
} catch (IOException e) {
section.printlnKO();
throw new LoadStackMetadataException(type.humanName, e);
}

section.printlnOK(type.humanName + ": " + name+"#"+override);

// environment requirements checking...
String envRequirement = processEnvironmentRequirements(platform,OCICloudShell);

final ST st = new ST(
new BufferedReader(
Expand All @@ -93,9 +106,12 @@ public void work() throws DSException {
st.add("path", dest.getAbsolutePath());
st.add("override", override);
st.add("executable", EXECUTABLE_NAME);
st.add("envRequirement", envRequirement);

System.out.println(st.render());

generateStackLocalConfigFile(dest);

break;
}
} else {
Expand Down Expand Up @@ -124,10 +140,15 @@ public void work() throws DSException {
}
}

} catch( com.fasterxml.jackson.databind.JsonMappingException me ){
section.printlnKO();
throw new UnknownEnvironmentRequirementForStackException(me.getMessage());
} catch (IOException e) {
section.printlnKO();
throw new LoadStackMetadataException(type.humanName, e);
}


section.printlnOK(type.humanName + ": " + name);

final Map<String, String> patchParameters = new HashMap<>();
Expand All @@ -139,6 +160,9 @@ public void work() throws DSException {
section.printlnOK();
}

// environment requirements checking...
String envRequirement = processEnvironmentRequirements(platform,OCICloudShell);

final ST st = new ST(
new BufferedReader(
new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(rootResourcesDir + type.resourceDir + "/message.st"), StandardCharsets.UTF_8))
Expand All @@ -147,15 +171,52 @@ public void work() throws DSException {
st.add("name", name);
st.add("path", dest.getAbsolutePath());
st.add("executable", EXECUTABLE_NAME);
st.add("envRequirement", envRequirement);

for (String key : patchParameters.keySet()) {
st.add(key, patchParameters.get(key));
}

System.out.println(st.render());

generateStackLocalConfigFile(dest);
}
}

private void generateStackLocalConfigFile(File dest) {
try (PrintWriter out = new PrintWriter(new File(dest,DSSession.LOCAL_CONFIGURATION_FILENAME))) {
out.println("{\"redirect\": \"..\"}");
} catch (FileNotFoundException ignored) {
}
}

private String processEnvironmentRequirements(DSSession.Platform platform, boolean OCICloudShell) {
section = DSSession.Section.StackEnvironmentValidation;
for(EnvironmentRequirement er:stackMetadata.getRequires()) {
section.print("requires "+er.name()+" for "+platform.name());
if(er.isPresent(platform)) {
section.printlnOK();
} else {
final StringBuilder help = new StringBuilder("\n");

help.append(er.getDescription());
help.append('\n');

for(String c:er.getCommands(platform,OCICloudShell)) {
help.append(" ").append(ANSI_BRIGHT).append(c).append(ANSI_RESET).append('\n');
}

help.append("\nAnd then...\n");

section.printlnOK();

return help.toString();
}
}

return " ";
}

private InputStream downloadFile(String url) throws DSException {
try {
final HttpRequest requestDownload = HttpRequest.newBuilder()
Expand Down Expand Up @@ -211,6 +272,7 @@ private void downloadFile(String url, File dest, int skipDirLevel) throws DSExce
}

} catch (Exception e) {
section.printlnKO();
throw new StackFileDownloadException(url, e);
}
}
Expand Down
Loading

0 comments on commit c3a9530

Please sign in to comment.