🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

forji

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forji - npm Package Compare versions

Comparing version
1.0.4
to
1.0.5
+23
-6
dist/index.js

@@ -28,4 +28,11 @@ // src/index.ts

}
function isFolder(content, name) {
if (name && name.includes("$"))
return false;
return typeof content === "object" && content !== null && !Array.isArray(content);
}
// src/ProjectBuilder.ts
var FOLDER_MARKER = Symbol("FOLDER");
class ProjectBuilder {

@@ -54,3 +61,6 @@ static instance;

}
isFolder(content) {
isFolder(content, name) {
if (name.includes("$")) {
return false;
}
return typeof content === "object" && content !== null && !Array.isArray(content);

@@ -61,11 +71,17 @@ }

const processedName = normalizeFileName(this.processVariables(name, variables));
if (this.isFolder(content)) {
if (this.isFolder(content, name)) {
const folderPath = posix.join(currentPath, processedName);
this.pathContentMap.set(folderPath, null);
this.pathContentMap.set(folderPath, FOLDER_MARKER);
await this.analyzeStructure(content, folderPath, variables);
} else {
if (content === null || content === undefined) {
continue;
}
const filePath = posix.join(currentPath, processedName);
const fileContent = this.processVariables(content, variables);
this.pathContentMap.set(filePath, fileContent);
this.pathContentMap.set(posix.dirname(filePath), null);
const parentDir = posix.dirname(filePath);
if (!this.pathContentMap.has(parentDir)) {
this.pathContentMap.set(parentDir, FOLDER_MARKER);
}
}

@@ -75,3 +91,3 @@ }

async createFolders() {
const folders = Array.from(this.pathContentMap.entries()).filter(([_, content]) => content === null).map(([path]) => path).sort((a, b) => a.split("/").length - b.split("/").length);
const folders = Array.from(this.pathContentMap.entries()).filter(([_, content]) => content === FOLDER_MARKER).map(([path]) => path).sort((a, b) => a.split("/").length - b.split("/").length);
for (const dir of folders) {

@@ -87,3 +103,3 @@ await mkdir(dir, { recursive: true });

async createFiles() {
const files = Array.from(this.pathContentMap.entries()).filter(([_, content]) => content !== null);
const files = Array.from(this.pathContentMap.entries()).filter(([_, content]) => content !== FOLDER_MARKER);
await Promise.all(files.map(async ([path, content]) => {

@@ -202,2 +218,3 @@ try {

normalizeFileName,
isFolder,
getPath,

@@ -204,0 +221,0 @@ getFolder,

export declare function normalizeFileName(name: string): string;
export declare function fileExists(directory: string, fileName: string): Promise<boolean>;
export declare function isFolder(content: any, name: string): boolean;
{
"name": "forji",
"version": "1.0.4",
"version": "1.0.5",
"description": "Library for building project structures with dynamic folder/file names",

@@ -5,0 +5,0 @@ "type": "module",