Skip to content

Commit 6a4712e

Browse files
authored
Merge pull request #5 from Gaboso/1.3.3
Liberação da versão 1.3.3
2 parents de35d9c + 682c67c commit 6a4712e

13 files changed

Lines changed: 143 additions & 79 deletions

File tree

CHANGELOG.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
1-
## Notas de Release
1+
# Changelog
22

3-
Este arquivo descreve o conteúdo de cada release do projeto.
3+
All notable changes to this project will be documented in this file.
44

5-
# 1.3.2
5+
## [1.3.3] - 2018-01-20
66

7-
* Correções e melhorias internasa além da limpeza de codigo.
7+
### Added
8+
- Função de iniciar o jar sem passar paramêtro do workspace.
9+
- Classe FileHelper, para auxiliar ações envolvendo arquivos.
10+
- Classe OsHelper, para auxiliar ações envolvendo propreidades do SO.
811

9-
# 1.3.1
12+
### Changed
13+
- Estrutura interna de pacotes.
14+
- Estrutura do Changelog do projeto.
1015

11-
* Adição de suporte ao Linux.
16+
## [1.3.2] - 2018-01-18
1217

18+
### Changed
19+
- Correções e melhorias internas além da limpeza de codigo.
1320

14-
# 1.2
21+
## [1.3.1] - 2017-12-20
1522

16-
* Correção na maneira que o log é gerado.
17-
* Adição de módulo para projetos que utilizam Grunt.
23+
### Added
24+
- Suporte ao Linux.
1825

19-
-----
26+
## [1.2] - 2017-07-12
2027

21-
# 1.1
28+
### Added
29+
- Módulo para projetos que utilizam Grunt.
30+
### Changed
31+
- Correção na maneira que o log é gerado.
2232

23-
* Correção nos links internos presentes no README.
24-
* Modificado processo de build para executar com o `mvn install`.
25-
* Alterado nome final do jar para o nome do `artifactId` ficando reduzido a `scriptum.jar`
26-
* Ajuste dos exemplos no README.md para se adequar ao novo nome do jar.
33+
## [1.1] - 2017-04-30
2734

28-
-----
35+
### Changed
36+
- Correção nos links internos presentes no README.
37+
- Modificado processo de build para executar com o `mvn install`.
38+
- Alterado nome final do jar para o nome do `artifactId` ficando reduzido a `scriptum.jar`
39+
- Ajuste dos exemplos no README.md para se adequar ao novo nome do jar.
2940

30-
# 1.0
41+
## [1.0] - 2017-04-30
3142

32-
* Módulo de atualização do Git
33-
* Módulo de instalação do Maven
34-
* Módulo de atualização e instalação do npm
35-
* Módulo de atualização e instalação do bower
43+
### Added
44+
- Módulo de atualização do Git
45+
- Módulo de instalação do Maven
46+
- Módulo de atualização e instalação do npm
47+
- Módulo de atualização e instalação do bower

META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Manifest-Version: 1.3.2
1+
Manifest-Version: 1.3.3
22
Main-Class: br.com.gaboso.Scriptum
33

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ __1° passo__: Execute o arquivo __`build.bat`__ para (_Windows_) ou o __`build.
1919

2020

2121
__2° passo__: Após a execução do primeiro passo, sera gerado o arquivo __`scriptum.jar`__ no diretorio
22-
`target`, para executar utilize o seguinte comando: __`java -jar scriptum.jar [caminho do workspace]`__.
22+
`target`, há duas maneiras de execução:
23+
* Passar como paramêtro o caminho do workspace: __`java -jar scriptum.jar [caminho do workspace]`__.
24+
* Exemplo do comando: __`java -jar scriptum.jar C:\workspace`__
25+
* Não passar o paramêtro que o Scriptum irá utilizar como workspace o diretorio onde o __`scriptum.jar`__ estiver: __`java -jar scriptum.jar`__.
26+
* Exemplo do comando: __`java -jar scriptum.jar`__
27+
2328

2429

25-
Exemplo do comando: __`java -jar scriptum.jar C:\workspace`__
2630

2731
-----
2832

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>br.com.gaboso</groupId>
88
<artifactId>scriptum</artifactId>
9-
<version>1.3.2</version>
9+
<version>1.3.3</version>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/br/com/gaboso/Scriptum.java

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,60 @@
11
package br.com.gaboso;
22

3+
import br.com.gaboso.helper.FileHelper;
34
import br.com.gaboso.module.BowerModule;
45
import br.com.gaboso.module.GitModule;
56
import br.com.gaboso.module.GruntModule;
67
import br.com.gaboso.module.MavenModule;
78
import br.com.gaboso.module.NpmModule;
8-
import org.apache.log4j.Logger;
99

1010
import java.io.File;
11-
import java.util.ArrayList;
1211
import java.util.List;
1312

1413
/**
1514
* @author Gaboso
1615
* @since 19/04/2017
17-
* <p>
18-
* Scriptum
16+
* <p>Scriptum</p>
1917
*/
2018
public class Scriptum {
2119

22-
private static final Logger LOGGER = Logger.getLogger(Scriptum.class);
23-
2420
public static void main(String[] args) {
25-
if (args.length > 0) {
26-
Scriptum scriptum = new Scriptum();
27-
List<File> folders = scriptum.getFoldersFromWorkspace(args[0]);
21+
String workspaceDir;
2822

29-
for (File file : folders) {
30-
scriptum.analyzeFolders(file);
31-
}
23+
if (args.length > 0) {
24+
workspaceDir = args[0];
25+
} else {
26+
workspaceDir = FileHelper.getJarDir();
3227
}
33-
}
3428

35-
private List<File> getFoldersFromWorkspace(String path) {
36-
File fileInitial = new File(path);
37-
File[] listFiles = fileInitial.listFiles();
38-
List<File> folders = new ArrayList<>();
29+
List<File> folders = FileHelper.getFoldersFromWorkspace(workspaceDir);
3930

40-
if (listFiles != null) {
41-
LOGGER.info("------------- LISTA DE DIRETORIOS DO WORKSPACE -------------");
42-
for (File file : listFiles) {
43-
if (file.isDirectory()) {
44-
folders.add(file);
45-
LOGGER.info(file.getName());
46-
}
47-
}
48-
LOGGER.info("------------------------------------------------------------");
31+
for (File file : folders) {
32+
Scriptum.analyzeFolders(file);
4933
}
5034

51-
return folders;
5235
}
5336

54-
private void analyzeFolders(File file) {
37+
private static void analyzeFolders(File file) {
5538
File[] listFiles = file.listFiles();
5639

57-
//Is Git Project
5840
if (GitModule.isProject(file.getPath())) {
5941
GitModule.executeCommands(file.getName(), file.getPath());
6042
}
6143

6244
if (listFiles != null) {
6345

64-
//Is Maven Project
6546
if (MavenModule.isProject(listFiles)) {
6647
MavenModule.executeCommands(file.getName(), file.getPath());
6748
}
6849

69-
//Is npm Project
7050
if (NpmModule.isProject(listFiles)) {
7151
NpmModule.executeCommands(file.getName(), file.getPath());
7252
}
7353

74-
//Is Bower Project
7554
if (BowerModule.isProject(listFiles)) {
7655
BowerModule.executeCommands(file.getName(), file.getPath());
7756
}
7857

79-
//Is Grunt Project
8058
if (GruntModule.isProject(listFiles)) {
8159
GruntModule.executeCommands(file.getName(), file.getPath());
8260
}

src/main/java/br/com/gaboso/module/helper/CommandHelper.java renamed to src/main/java/br/com/gaboso/helper/CommandHelper.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package br.com.gaboso.module.helper;
1+
package br.com.gaboso.helper;
22

33
import org.apache.log4j.Logger;
44

@@ -20,23 +20,22 @@ private CommandHelper() {
2020
private static final Logger LOGGER = Logger.getLogger(CommandHelper.class);
2121

2222
public static void executeCMD(String cmd) {
23-
24-
boolean isWindows = System.getProperty("os.name").contains("Windows");
25-
String runner = isWindows ? "cmd.exe" : "/bin/bash";
26-
String option = isWindows ? "/c" : "-c";
23+
String runner = OsHelper.getRunner();
24+
String option = OsHelper.getOption();
2725

2826
ProcessBuilder builder = new ProcessBuilder(runner, option, cmd);
2927
builder.redirectErrorStream(true);
3028

3129
try {
32-
Process p = builder.start();
33-
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
34-
String line;
30+
Process process = builder.start();
31+
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
3532

3633
while (true) {
37-
line = r.readLine();
38-
if (line == null)
34+
String line = reader.readLine();
35+
36+
if (line == null) {
3937
break;
38+
}
4039

4140
LOGGER.info(line);
4241
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package br.com.gaboso.helper;
2+
3+
import br.com.gaboso.Scriptum;
4+
import org.apache.log4j.Logger;
5+
6+
import java.io.File;
7+
import java.net.URISyntaxException;
8+
import java.security.CodeSource;
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
public class FileHelper {
13+
14+
private static final Logger LOGGER = Logger.getLogger(FileHelper.class);
15+
16+
private FileHelper() {
17+
}
18+
19+
public static String getJarDir() {
20+
CodeSource codeSource = Scriptum.class.getProtectionDomain().getCodeSource();
21+
22+
try {
23+
File jarFile = new File(codeSource.getLocation().toURI().getPath());
24+
return jarFile.getParentFile().getPath();
25+
} catch (URISyntaxException | NullPointerException e) {
26+
LOGGER.error(e.getMessage(), e);
27+
}
28+
29+
return "";
30+
}
31+
32+
public static List<File> getFoldersFromWorkspace(String path) {
33+
File fileInitial = new File(path);
34+
File[] listFiles = fileInitial.listFiles();
35+
List<File> folders = new ArrayList<>();
36+
37+
if (listFiles != null) {
38+
LOGGER.info("------------- LISTA DE DIRETORIOS DO WORKSPACE -------------");
39+
for (File file : listFiles) {
40+
if (file.isDirectory()) {
41+
folders.add(file);
42+
LOGGER.info(file.getName());
43+
}
44+
}
45+
LOGGER.info("------------------------------------------------------------");
46+
}
47+
48+
return folders;
49+
}
50+
51+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package br.com.gaboso.helper;
2+
3+
public class OsHelper {
4+
5+
private OsHelper() {
6+
}
7+
8+
public static String getRunner() {
9+
return isWindows() ? "cmd.exe" : "/bin/bash";
10+
}
11+
12+
public static String getOption() {
13+
return isWindows() ? "/c" : "-c";
14+
}
15+
16+
private static boolean isWindows() {
17+
return System.getProperty("os.name").contains("Windows");
18+
}
19+
20+
}

src/main/java/br/com/gaboso/module/BowerModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package br.com.gaboso.module;
22

33
import br.com.gaboso.format.Formatter;
4-
import br.com.gaboso.module.helper.CommandHelper;
4+
import br.com.gaboso.helper.CommandHelper;
55
import org.apache.log4j.Logger;
66

77
import java.io.File;

src/main/java/br/com/gaboso/module/GitModule.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package br.com.gaboso.module;
22

33
import br.com.gaboso.format.Formatter;
4-
import br.com.gaboso.module.helper.CommandHelper;
4+
import br.com.gaboso.helper.CommandHelper;
5+
import br.com.gaboso.helper.OsHelper;
56
import org.apache.log4j.Logger;
67

78
import java.io.BufferedReader;
@@ -22,17 +23,16 @@ private GitModule() {
2223
}
2324

2425
public static boolean isProject(String path) {
25-
boolean isWindows = System.getProperty("os.name").contains("Windows");
26-
String runner = isWindows ? "cmd.exe" : "/bin/bash";
27-
String option = isWindows ? "/c" : "-c";
26+
String runner = OsHelper.getRunner();
27+
String option = OsHelper.getOption();
2828

2929
ProcessBuilder builder = new ProcessBuilder(runner, option, "cd " + path + "/ && git rev-parse --is-inside-work-tree");
3030
builder.redirectErrorStream(true);
3131

3232
try {
33-
Process p = builder.start();
34-
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
35-
String line = r.readLine();
33+
Process process = builder.start();
34+
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
35+
String line = reader.readLine();
3636
return "true".equals(line);
3737

3838
} catch (IOException e) {

0 commit comments

Comments
 (0)