orgnote-api 0.17.5 → 0.18.0
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.
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/mappers/index.d.ts +1 -0
- package/mappers/index.js +1 -0
- package/mappers/orgnode-to-note.d.ts +3 -0
- package/mappers/orgnode-to-note.js +11 -0
- package/package.json +1 -1
- package/tools/__tests__/find-note-files-diff.spec.js +1 -1
- package/tools/__tests__/join.spec.js +6 -1
- package/tools/__tests__/split-path.spec.d.ts +1 -0
- package/tools/__tests__/split-path.spec.js +27 -0
- package/tools/find-notes-files-diff.js +3 -2
- package/tools/index.d.ts +2 -1
- package/tools/index.js +2 -1
- package/tools/join-path.js +7 -0
- package/tools/split-path.d.ts +1 -0
- package/tools/split-path.js +3 -0
- package/tools/join.js +0 -3
- /package/tools/{join.d.ts → join-path.d.ts} +0 -0
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './orgnode-to-note';
|
package/mappers/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './orgnode-to-note';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { splitPath } from 'src/tools';
|
|
2
|
+
export function orgnodeToNote(orgnode, fileInfo) {
|
|
3
|
+
return {
|
|
4
|
+
id: orgnode.meta.id,
|
|
5
|
+
meta: orgnode.meta,
|
|
6
|
+
filePath: splitPath(fileInfo.path),
|
|
7
|
+
touchedAt: new Date(fileInfo.atime).toISOString(),
|
|
8
|
+
updatedAt: new Date(Math.max(fileInfo.mtime, fileInfo.ctime)).toISOString(),
|
|
9
|
+
createdAt: new Date(fileInfo.ctime).toISOString(),
|
|
10
|
+
};
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { findNoteFilesDiff } from '../find-notes-files-diff';
|
|
|
4
4
|
import { statSync } from 'fs';
|
|
5
5
|
import { rmSync } from 'fs';
|
|
6
6
|
import { getFileName } from '../get-file-name';
|
|
7
|
-
import { join } from '../join';
|
|
7
|
+
import { join } from '../join-path';
|
|
8
8
|
const testFilesFolder = 'src/tools/__tests__/miscellaneous/';
|
|
9
9
|
const nestedFolder = 'nested-folder/';
|
|
10
10
|
const fn = (fileName) => `${testFilesFolder}${fileName}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
|
-
import { join } from '../join';
|
|
2
|
+
import { join } from '../join-path';
|
|
3
3
|
test('Should join file paths', () => {
|
|
4
4
|
const samples = [
|
|
5
5
|
['dir1', 'subdir2', 'file'],
|
|
@@ -12,3 +12,8 @@ test('Should join file paths', () => {
|
|
|
12
12
|
expect(result).toMatchSnapshot();
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
|
+
test('Should not take slashes from the path array into account.', () => {
|
|
16
|
+
const path = ['/', 'this', '/', 'is-path', 'qwe'];
|
|
17
|
+
const result = join(...path);
|
|
18
|
+
expect(result).toBe('this/is-path/qwe');
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
import { splitPath } from 'src/tools';
|
|
3
|
+
test('Should correctly split various paths with different formats', () => {
|
|
4
|
+
const pathExpected = [
|
|
5
|
+
['/some/long/path/file.txt', ['some', 'long', 'path', 'file.txt']],
|
|
6
|
+
['/a/b/c/d.txt', ['a', 'b', 'c', 'd.txt']],
|
|
7
|
+
['/singlefile.txt', ['singlefile.txt']],
|
|
8
|
+
['/folder/', ['folder']],
|
|
9
|
+
['relative/path/to/file', ['relative', 'path', 'to', 'file']],
|
|
10
|
+
['/leading/slash/', ['leading', 'slash']],
|
|
11
|
+
['no/leading/slash', ['no', 'leading', 'slash']],
|
|
12
|
+
['/trailing/slash/', ['trailing', 'slash']],
|
|
13
|
+
];
|
|
14
|
+
pathExpected.forEach(([path, expected]) => {
|
|
15
|
+
expect(splitPath(path)).toEqual(expected);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
test('Should handle edge cases like empty paths or root', () => {
|
|
19
|
+
const pathExpected = [
|
|
20
|
+
['', []],
|
|
21
|
+
['/', []],
|
|
22
|
+
['//', []],
|
|
23
|
+
];
|
|
24
|
+
pathExpected.forEach(([path, expected]) => {
|
|
25
|
+
expect(splitPath(path)).toEqual(expected);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getStringPath } from './get-string-path';
|
|
2
2
|
import { isOrgFile } from './is-org-file';
|
|
3
|
-
import { join } from './join';
|
|
3
|
+
import { join } from './join-path';
|
|
4
4
|
export async function findNoteFilesDiff({ fileInfo, readDir, lastSync, storedNotesInfo, dirPath, }) {
|
|
5
5
|
const orgFilePaths = await readOrgFilesRecursively({
|
|
6
6
|
fileInfo,
|
|
@@ -79,7 +79,8 @@ export async function readOrgFilesRecursively({ fileInfo, readDir, dirPath, }) {
|
|
|
79
79
|
if (!isOrgFile(f.name)) {
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
const fullFilePath = getFullPath(f.name);
|
|
83
|
+
collectedPaths.push(fullFilePath);
|
|
83
84
|
}
|
|
84
85
|
return collectedPaths;
|
|
85
86
|
}
|
package/tools/index.d.ts
CHANGED
package/tools/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function splitPath(path: string): string[];
|
package/tools/join.js
DELETED
|
File without changes
|