Skip to content

Commit 288b8f2

Browse files
Merge branch 'fix/release' of github.com:internxt/node-win into fix/release
2 parents ea797c0 + bc3dde0 commit 288b8f2

File tree

20 files changed

+312
-320
lines changed

20 files changed

+312
-320
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=crlf
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Check PR size
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
check_pr_size:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Calculate changed lines
17+
id: diff_check
18+
run: |
19+
# Get the target branch commit (base) and the PR branch commit (head)
20+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
21+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
22+
echo "Base SHA: $BASE_SHA"
23+
echo "Head SHA: $HEAD_SHA"
24+
25+
# Compute the merge base between the two branches
26+
MERGE_BASE=$(git merge-base "$HEAD_SHA" "$BASE_SHA")
27+
echo "Merge Base: $MERGE_BASE"
28+
29+
# Calculate added and deleted lines between the merge base and the head commit
30+
TOTAL_CHANGED=$(git diff --numstat "$MERGE_BASE" "$HEAD_SHA" \
31+
| grep -v "yarn.lock" \
32+
| awk '{ added += $1; deleted += $2 } END { print added + deleted }')
33+
34+
# Default to 0 if nothing is output
35+
TOTAL_CHANGED=${TOTAL_CHANGED:-0}
36+
echo "Total changed lines: $TOTAL_CHANGED"
37+
38+
# Make the total available for later steps
39+
echo "total=$TOTAL_CHANGED" >> "$GITHUB_OUTPUT"
40+
41+
- name: Fail if too many changes
42+
if: ${{ steps.diff_check.outputs.total > 500 }}
43+
run: |
44+
echo "PR has ${{ steps.diff_check.outputs.total }} changed lines, which exceeds the 500-line limit."
45+
echo "Please reduce the size of this PR."
46+
exit 1

.github/workflows/publish-npm.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish package to npmjs
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
packages: write
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 18
23+
24+
- name: Install dependencies
25+
run: yarn install --ignore-scripts
26+
27+
- name: Create .npmrc file
28+
run: |
29+
touch .npmrc
30+
echo "registry=https://registry.npmjs.org/" >> .npmrc
31+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
32+
33+
- name: Publish package
34+
run: npm publish --scope=@internxt --access public

.github/workflows/publish.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/pull-request.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Some pull request checks
1+
name: Pull request checks
22

33
on:
44
pull_request:
55

66
jobs:
7-
type-check:
8-
runs-on: ubuntu-latest
7+
checks:
8+
runs-on: windows-latest
99

1010
steps:
1111
- name: Checkout code
@@ -22,5 +22,8 @@ jobs:
2222
- name: Run TypeScript compiler
2323
run: yarn tsc
2424

25-
# - name: Run Vitest
26-
# run: yarn vitest:once
25+
- name: Run Prettier
26+
run: yarn prettier . --check
27+
28+
- name: Run tests
29+
run: yarn test:once

binding.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"native-src/sync_root_interface/callbacks/FetchPlaceholder/FetchPlaceholder.cpp",
3030
"native-src/sync_root_interface/callbacks/NotifyDelete/NotifyDeleteCallback.cpp",
3131
"native-src/sync_root_interface/callbacks/NotifyRename/NotifyRenameCallback.cpp",
32+
"native-src/sync_root_interface/callbacks/NotifyRename/RenameTransferContext.cpp",
3233
"native-src/virtual_drive/Wrappers.cpp"
3334
],
3435
"include_dirs": [

examples/populate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import VirtualDrive from "@/virtual-drive";
2-
31
import { execSync } from "child_process";
42
import { join } from "path";
53
import { v4 } from "uuid";
64

5+
import VirtualDrive from "@/virtual-drive";
6+
77
import settings from "./settings";
88

99
const rootFileName1 = v4();

examples/utils.ts

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import fs from "fs";
2+
import path from "path";
33

44
interface FileDetail {
5-
path: string;
6-
size: number;
7-
baseDir: string;
5+
path: string;
6+
size: number;
7+
baseDir: string;
88
}
99

1010
function readFilesRecursively(dir: string, fileList: FileDetail[] = []): FileDetail[] {
11-
fs.readdirSync(dir).forEach(file => {
12-
const filePath = path.join(dir, file);
13-
if (fs.statSync(filePath).isDirectory()) {
14-
readFilesRecursively(filePath, fileList);
15-
} else {
16-
fileList.push({
17-
path: filePath,
18-
size: fs.statSync(filePath).size,
19-
baseDir: dir
20-
});
21-
}
22-
});
23-
return fileList;
11+
fs.readdirSync(dir).forEach((file) => {
12+
const filePath = path.join(dir, file);
13+
if (fs.statSync(filePath).isDirectory()) {
14+
readFilesRecursively(filePath, fileList);
15+
} else {
16+
fileList.push({
17+
path: filePath,
18+
size: fs.statSync(filePath).size,
19+
baseDir: dir,
20+
});
21+
}
22+
});
23+
return fileList;
2424
}
2525

2626
function createFilesWithSize(sourceFolder: string, destFolder: string): void {
27-
const files: FileDetail[] = readFilesRecursively(sourceFolder);
27+
const files: FileDetail[] = readFilesRecursively(sourceFolder);
2828

29-
if (!fs.existsSync(destFolder)) {
30-
fs.mkdirSync(destFolder, { recursive: true });
31-
}
32-
33-
files.forEach(file => {
34-
const relativePath = path.relative(file.baseDir, file.path);
35-
const destFilePath = path.join(file.baseDir.replace(sourceFolder, destFolder), relativePath);//path.join(destFolder, relativePath);
36-
const destFileDir = file.baseDir.replace(sourceFolder, destFolder);//path.dirname(destFilePath);
29+
if (!fs.existsSync(destFolder)) {
30+
fs.mkdirSync(destFolder, { recursive: true });
31+
}
3732

38-
if (!fs.existsSync(destFileDir)){
39-
fs.mkdirSync(destFileDir, { recursive: true });
40-
}
33+
files.forEach((file) => {
34+
const relativePath = path.relative(file.baseDir, file.path);
35+
const destFilePath = path.join(file.baseDir.replace(sourceFolder, destFolder), relativePath); //path.join(destFolder, relativePath);
36+
const destFileDir = file.baseDir.replace(sourceFolder, destFolder); //path.dirname(destFilePath);
4137

42-
fs.writeFileSync(destFilePath, Buffer.alloc(file.size));
43-
});
38+
if (!fs.existsSync(destFileDir)) {
39+
fs.mkdirSync(destFileDir, { recursive: true });
40+
}
4441

42+
fs.writeFileSync(destFilePath, Buffer.alloc(file.size));
43+
});
4544
}
4645

47-
export { createFilesWithSize };
46+
export { createFilesWithSize };
Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import VirtualDrive from '@/virtual-drive';
2-
import { v4 as uuidv4 } from 'uuid';
1+
import { v4 as uuidv4 } from "uuid";
2+
3+
import VirtualDrive from "@/virtual-drive";
34

45
interface GenerateOptions {
5-
rootPath: string
6+
rootPath: string;
67
depth: number;
78
filesPerFolder: number;
89
foldersPerLevel: number;
@@ -26,18 +27,7 @@ function randomNormal(mean: number, stdDev: number): number {
2627
}
2728

2829
function getRandomExtension(): string {
29-
const extensions = [
30-
".txt",
31-
".pdf",
32-
".rar",
33-
".jpg",
34-
".docx",
35-
".xlsx",
36-
".mp4",
37-
".mkv",
38-
".json",
39-
""
40-
];
30+
const extensions = [".txt", ".pdf", ".rar", ".jpg", ".docx", ".xlsx", ".mp4", ".mkv", ".json", ""];
4131
const index = Math.floor(Math.random() * extensions.length);
4232
return extensions[index];
4333
}
@@ -47,17 +37,11 @@ async function createStructureRecursively(
4737
currentPath: string,
4838
level: number,
4939
options: GenerateOptions,
50-
result: Record<string, string>
40+
result: Record<string, string>,
5141
): Promise<void> {
5242
if (level < 0) return;
5343

54-
const {
55-
filesPerFolder,
56-
foldersPerLevel,
57-
meanSize,
58-
stdDev,
59-
timeOffset
60-
} = options;
44+
const { filesPerFolder, foldersPerLevel, meanSize, stdDev, timeOffset } = options;
6145

6246
for (let i = 0; i < filesPerFolder; i++) {
6347
const fileName = `file_${generateRandomId()}${getRandomExtension()}`;
@@ -69,13 +53,7 @@ async function createStructureRecursively(
6953
const createdAt = Date.now() - (timeOffset || 0);
7054
const updatedAt = Date.now() - (timeOffset || 0) + 2000;
7155

72-
drive.createFileByPath(
73-
fullPath,
74-
fileId,
75-
fileSize,
76-
createdAt,
77-
updatedAt
78-
);
56+
drive.createFileByPath(fullPath, fileId, fileSize, createdAt, updatedAt);
7957

8058
result[fileId] = fullPath;
8159
}
@@ -88,22 +66,13 @@ async function createStructureRecursively(
8866
const createdAt = Date.now() - (timeOffset || 0) - 10000; // Ejemplo
8967
const updatedAt = Date.now() - (timeOffset || 0);
9068

91-
drive.createFolderByPath(
92-
newFolderPath,
93-
folderId,
94-
1000,
95-
createdAt,
96-
updatedAt
97-
);
69+
drive.createFolderByPath(newFolderPath, folderId, 1000, createdAt, updatedAt);
9870

9971
await createStructureRecursively(drive, newFolderPath, level - 1, options, result);
10072
}
10173
}
10274

103-
async function generateRandomFilesAndFolders(
104-
drive: VirtualDrive,
105-
options: GenerateOptions
106-
): Promise<Record<string, string>> {
75+
async function generateRandomFilesAndFolders(drive: VirtualDrive, options: GenerateOptions): Promise<Record<string, string>> {
10776
const { rootPath } = options;
10877

10978
const result: Record<string, string> = {};
@@ -114,4 +83,4 @@ async function generateRandomFilesAndFolders(
11483
}
11584

11685
export { generateRandomFilesAndFolders };
117-
export type { GenerateOptions }
86+
export type { GenerateOptions };

gyp.config.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"gyp_file": "binding.gyp",
3-
"source_dirs": ["native-src/**/*.cpp"],
4-
"ignored_source_dirs": [],
5-
"include_dirs": ["include"],
6-
"ignored_include_dirs": []
7-
}
2+
"gyp_file": "binding.gyp",
3+
"source_dirs": ["native-src/**/*.cpp"],
4+
"ignored_source_dirs": [],
5+
"include_dirs": ["include"],
6+
"ignored_include_dirs": []
7+
}

0 commit comments

Comments
 (0)