Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobispo committed Nov 12, 2024
2 parents 3aed193 + b76565a commit 5c4736b
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 41 deletions.
2 changes: 1 addition & 1 deletion LARAC/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ":CommonsCompressPlus"
implementation ":CommonsLangPlus"
Expand Down
2 changes: 1 addition & 1 deletion LARAI/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
implementation "junit:junit:4.11"
implementation "junit:junit:4.13.1"

implementation ':CommonsLangPlus'
implementation ':GitPlus'
Expand Down
2 changes: 1 addition & 1 deletion LanguageSpecification/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
implementation "junit:junit:4.11"
implementation "junit:junit:4.13.1"

implementation ':SpecsUtils'
implementation ':tdrcLibrary'
Expand Down
2 changes: 1 addition & 1 deletion LaraApi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':SpecsUtils'
implementation ':CommonsLangPlus'
Expand Down
2 changes: 1 addition & 1 deletion LaraCommonLanguage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':jOptions'
implementation ':SpecsUtils'
Expand Down
2 changes: 1 addition & 1 deletion LaraCommonLanguageApi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':SpecsUtils'
implementation ':LaraUtils'
Expand Down
2 changes: 1 addition & 1 deletion LaraDoc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':CommonsLangPlus'
implementation ':GsonPlus'
Expand Down
2 changes: 1 addition & 1 deletion LaraFramework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}

dependencies {
implementation "junit:junit:4.11"
implementation "junit:junit:4.13.1"

implementation ':GearmanPlus'
implementation ':jOptions'
Expand Down
2 changes: 1 addition & 1 deletion LaraLoc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':jOptions'
implementation ':SpecsUtils'
Expand Down
2 changes: 1 addition & 1 deletion LaraUnit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':jOptions'
implementation ':SpecsUtils'
Expand Down
2 changes: 1 addition & 1 deletion LaraUtils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"
implementation ':SpecsUtils'
implementation ':tdrcLibrary'
}
Expand Down
2 changes: 1 addition & 1 deletion WeaverGenerator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':GuiHelper'
implementation ':JavaGenerator'
Expand Down
2 changes: 1 addition & 1 deletion WeaverInterface/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}

dependencies {
testImplementation "junit:junit:4.11"
testImplementation "junit:junit:4.13.1"

implementation ':JsEngine'
implementation ':jOptions'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,52 +33,47 @@
public class WeaverApiManager {

private final static String CHECKSUM_FILENAME = "checksum.txt";
private final static String NPM_FOLDERNAME = "npm";
private final static String NODE_MODULES_FOLDERNAME = "node_modules";
private final static String CORE_FOLDERNAME = "core";

private final File baseFolder;
private final File coreFolder;
private final File npmFolder;

private WeaverApiManager(File baseFolder) {
this.baseFolder = baseFolder;
private WeaverApiManager(File coreFolder, File npmFolder) {
this.coreFolder = coreFolder;
this.npmFolder = npmFolder;
}

public File getBaseFolder() {
return baseFolder;
}

public File getNpmFolder() {
return new File(getBaseFolder(), NPM_FOLDERNAME);
private File getNpmFolder() {
return npmFolder;
}

public File getNodeModulesFolder() {
return new File(getNpmFolder(), NODE_MODULES_FOLDERNAME);
}

public File getCoreFolder() {
return new File(getBaseFolder(), CORE_FOLDERNAME);
return coreFolder;
}

/**
*
* @return a list of folders inside the node_modules folder that correspond to the base folders that laraImport
* should look for APIs
* should look for APIs
*/
public List<File> getNpmApiFolders() {
var moduleFolders = SpecsIo.getFolders(getNodeModulesFolder());

var packageFolders = new ArrayList<File>();
for (var folder : moduleFolders) {
if (folder.getName().startsWith("@")) {
// It's a scope for packages.
// Add subfolders to packageFolders.
packageFolders.addAll(SpecsIo.getFolders(folder));
}
else {
} else {
packageFolders.add(folder);
}
}

var apiFolders = new ArrayList<File>();
for (var packageFolder : packageFolders) {
var apiFolder = new File(packageFolder, "api");
Expand All @@ -96,9 +91,8 @@ public List<File> getNpmApiFolders() {
}

/**
*
* @return a list of files named core.js inside the node_modules folder that should be executed to enable the core
* LARA environment
* LARA environment
*/
public List<File> getNpmCoreFiles() {

Expand Down Expand Up @@ -127,18 +121,23 @@ public static WeaverApiManager newInstance(WeaverEngine engine) {
var baseFoldername = weaverId + "_apis";
var baseFolder = SpecsIo.getTempFolder(baseFoldername);

// Ensure there are two folders inside, npm and core
prepareNpmFolder(baseFolder, engine);
prepareCoreFolder(baseFolder, engine);
// Ensure there is a core folder inside
var coreFolder = prepareCoreFolder(baseFolder, engine);

SpecsLogs.debug(() -> "Weaver API manager: using '" + coreFolder.getAbsolutePath() + "' as code folder");

// For compatibility reasons with ESM and GraalVM, node_modules folder should be on the working directory
var npmFolder = prepareNpmFolder(SpecsIo.getWorkingDir(), engine);

SpecsLogs.debug(() -> "Weaver API manager: using '" + npmFolder.getAbsolutePath() + "' as npm folder with node_modules folder inside");

// Get base folder
SpecsLogs.debug(() -> "Weaver API manager: using '" + baseFolder.getAbsolutePath() + "' as base folder");
return new WeaverApiManager(baseFolder);
return new WeaverApiManager(coreFolder, npmFolder);
}

private static File prepareNpmFolder(File baseFolder, WeaverEngine engine) {
// private static File prepareNpmFolder(File baseFolder, WeaverEngine engine) {
private static File prepareNpmFolder(File npmFolder, WeaverEngine engine) {
// Ensure there is an npm folder
var npmFolder = SpecsIo.mkdir(baseFolder, NPM_FOLDERNAME);
//var npmFolder = SpecsIo.mkdir(baseFolder, NPM_FOLDERNAME);

// Ensure it has a node_modules folder
var nodeModulesFolder = SpecsIo.mkdir(npmFolder, NODE_MODULES_FOLDERNAME);
Expand Down Expand Up @@ -244,7 +243,6 @@ private static void extractNpmResources(File destination, WeaverEngine engine) {
}

/**
*
* @param resourcesFolder
* @return if true, means that resources need to be extracted to files, false means that folder can be reused as-is
*/
Expand Down

0 comments on commit 5c4736b

Please sign in to comment.