@digicroz/node-server-kit 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -138,7 +138,8 @@ export const b2fPortalInit = async (b2fPortalProjects) => {
|
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
const repositoryDistTrpcApiPath = join(repositoryBackedPortalDirPath, sectionDistTrpcApiPath.replace(clientRootDirPath, ""));
|
|
141
|
-
const repositoryPrismaClientPath = join(repositoryBackedPortalDirPath,
|
|
141
|
+
const repositoryPrismaClientPath = join(repositoryBackedPortalDirPath, "_prisma", "generated-client");
|
|
142
|
+
// console.log({ repositoryBackedPortalDirPath, repositoryPrismaClientPath })
|
|
142
143
|
// createModuleFiles(sectionSrcTrpcApiRoutesPath)
|
|
143
144
|
// create zod files
|
|
144
145
|
// createZodFiles(sectionSrcTrpcApiRoutesPath)
|
|
@@ -194,7 +195,7 @@ export const b2fPortalInit = async (b2fPortalProjects) => {
|
|
|
194
195
|
// "index.d.ts",
|
|
195
196
|
// "library.js",
|
|
196
197
|
// "library.d.ts",
|
|
197
|
-
".
|
|
198
|
+
".ts",
|
|
198
199
|
],
|
|
199
200
|
});
|
|
200
201
|
if (section.needNextJsPatch) {
|
|
@@ -6,9 +6,9 @@ import crypto from "node:crypto"; // Added crypto for file hashing
|
|
|
6
6
|
async function getFileHash(filePath) {
|
|
7
7
|
try {
|
|
8
8
|
const fileBuffer = await fsPromises.readFile(filePath);
|
|
9
|
-
const hashSum = crypto.createHash(
|
|
9
|
+
const hashSum = crypto.createHash("sha1");
|
|
10
10
|
hashSum.update(fileBuffer);
|
|
11
|
-
return hashSum.digest(
|
|
11
|
+
return hashSum.digest("hex");
|
|
12
12
|
}
|
|
13
13
|
catch (error) {
|
|
14
14
|
console.error(`Error calculating hash for file ${filePath}:`, error);
|
|
@@ -33,7 +33,7 @@ export async function syncFilesAndFolders({ sourceDirPath, targetDirPath, fileNa
|
|
|
33
33
|
try {
|
|
34
34
|
const fileContent = await fsPromises.readFile(jsonFilePath, "utf8");
|
|
35
35
|
// Handle empty file case
|
|
36
|
-
if (fileContent.trim() ===
|
|
36
|
+
if (fileContent.trim() === "") {
|
|
37
37
|
fileDetails = {};
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
@@ -53,7 +53,7 @@ export async function syncFilesAndFolders({ sourceDirPath, targetDirPath, fileNa
|
|
|
53
53
|
else {
|
|
54
54
|
await fsPromises.writeFile(jsonFilePath, "{}");
|
|
55
55
|
}
|
|
56
|
-
async function updateFileDetails({ fileName, sourceFilePath, mtime, hash }) {
|
|
56
|
+
async function updateFileDetails({ fileName, sourceFilePath, mtime, hash, }) {
|
|
57
57
|
// const stats = await fsPromises.stat(sourceFilePath);
|
|
58
58
|
fileDetails[fileName] = {
|
|
59
59
|
sourceFilePath,
|
|
@@ -102,7 +102,8 @@ export async function syncFilesAndFolders({ sourceDirPath, targetDirPath, fileNa
|
|
|
102
102
|
else {
|
|
103
103
|
// Check if file matches patterns
|
|
104
104
|
if (fileNamePatterns.length === 0 ||
|
|
105
|
-
fileNamePatterns.some((pattern) => fileName.includes(pattern))) {
|
|
105
|
+
fileNamePatterns.some((pattern) => fileName.includes(pattern))) {
|
|
106
|
+
// Get source file hash and modified time
|
|
106
107
|
let sourceStats;
|
|
107
108
|
let sourceFileModifiedTime;
|
|
108
109
|
let sourceFileHash;
|
|
@@ -121,10 +122,11 @@ export async function syncFilesAndFolders({ sourceDirPath, targetDirPath, fileNa
|
|
|
121
122
|
!fileDetails[fileName] ||
|
|
122
123
|
!fileDetails[fileName]?.hash || // If hash doesn't exist (backwards compatibility)
|
|
123
124
|
fileDetails[fileName]?.hash !== sourceFileHash // Primary check: compare file hashes
|
|
124
|
-
) {
|
|
125
|
+
) {
|
|
126
|
+
// Copy or replace the file in the target directory
|
|
125
127
|
try {
|
|
126
128
|
await fsPromises.copyFile(sourcePath, targetPath);
|
|
127
|
-
console.log(`
|
|
129
|
+
console.log(`Synced file: ${path.relative(sourceDirPath, sourcePath)}`);
|
|
128
130
|
}
|
|
129
131
|
catch (error) {
|
|
130
132
|
console.error(`Error copying file from ${sourcePath} to ${targetPath}:`, error);
|
|
@@ -148,7 +150,8 @@ export async function syncFilesAndFolders({ sourceDirPath, targetDirPath, fileNa
|
|
|
148
150
|
const targetFilePath = path.join(targetDir, fileName);
|
|
149
151
|
// Check if the source file exists
|
|
150
152
|
const sourceExists = fs.existsSync(sourceFilePath);
|
|
151
|
-
if (!sourceExists) {
|
|
153
|
+
if (!sourceExists) {
|
|
154
|
+
// Delete the file from the target directory
|
|
152
155
|
if (fs.existsSync(targetFilePath)) {
|
|
153
156
|
try {
|
|
154
157
|
await fsPromises.unlink(targetFilePath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fs from
|
|
2
|
-
import * as path from
|
|
3
|
-
import { startProgress, successProgress, failProgress, updateProgress } from
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { startProgress, successProgress, failProgress, updateProgress, } from "../utils/progress.js";
|
|
4
4
|
/**
|
|
5
5
|
* Deletes all files in the target directory and copies all files from source directory
|
|
6
6
|
* @param sourcePath - Source directory path
|
|
@@ -31,7 +31,7 @@ export async function deleteAndCopy(sourcePath, targetPath) {
|
|
|
31
31
|
// Copy all files from source to target
|
|
32
32
|
updateProgress(spinner, `Copying files from ${sourcePath} to ${targetPath}`);
|
|
33
33
|
await copyDirectoryRecursive(sourcePath, targetPath, spinner);
|
|
34
|
-
successProgress(spinner, `Successfully
|
|
34
|
+
successProgress(spinner, `Successfully synced all files from ${path.basename(sourcePath)} to ${path.basename(targetPath)}`);
|
|
35
35
|
}
|
|
36
36
|
catch (error) {
|
|
37
37
|
failProgress(spinner, `Error during deleteAndCopy operation`);
|
|
@@ -54,11 +54,11 @@ export const transfer2Shared = async () => {
|
|
|
54
54
|
for (const project of b2fPortalProjects) {
|
|
55
55
|
const projectSpinner = startProgress(`Processing project: ${project.projectName}`);
|
|
56
56
|
try {
|
|
57
|
-
const
|
|
58
|
-
// console.log('
|
|
59
|
-
if (!fs.existsSync(
|
|
60
|
-
failProgress(projectSpinner, "
|
|
61
|
-
console.log({
|
|
57
|
+
const serverS2cPath = join(clientSrcDirPath, "_server-s2c");
|
|
58
|
+
// console.log('serverS2cPath', serverS2cPath);
|
|
59
|
+
if (!fs.existsSync(serverS2cPath)) {
|
|
60
|
+
failProgress(projectSpinner, "serverS2cPath does not exist");
|
|
61
|
+
console.log({ serverS2cPath: serverS2cPath });
|
|
62
62
|
projectProgress.incrementFailed(`Failed: ${project.projectName}`);
|
|
63
63
|
continue;
|
|
64
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digicroz/node-server-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "NodeJS Backend Kit - A powerful TypeScript utility for managing backend projects with features like B2F Portal integration, cross-project validation, and Next.js support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -77,4 +77,4 @@
|
|
|
77
77
|
"rimraf": "^6.0.1",
|
|
78
78
|
"simple-git": "^3.27.0"
|
|
79
79
|
}
|
|
80
|
-
}
|
|
80
|
+
}
|
|
File without changes
|
|
File without changes
|