Skip to content

Commit

Permalink
Merge pull request #28 from tanainc/odin/run_in_node_19
Browse files Browse the repository at this point in the history
Add file extensions so dist-files work as ESM in node 19+
  • Loading branch information
odinho authored Jun 3, 2024
2 parents 0e9adb7 + d4c5191 commit 7c54241
Show file tree
Hide file tree
Showing 22 changed files with 893 additions and 1,749 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ node_modules
dist
.env
datasets
yarn-error.log
yarn-error.log

.yarn/*
!.yarn/plugins
Binary file removed .yarn/install-state.gz
Binary file not shown.
15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@
"format": "prettier --write \"src/**/*.ts\"",
"lint": "eslint --ext .ts src/",
"prepack": "rm -rf dist/ && ./node_modules/.bin/tsc --project tsconfig.build.json",
"build": "yarn prepare",
"build": "yarn prepack",
"convert:roam": "yarn build && node --experimental-modules --es-module-specifier-resolution=node dist/runner.js roam",
"convert:workflowy": "yarn build && node --experimental-modules --es-module-specifier-resolution=node dist/runner.js workflowy",
"convert:logseq": "yarn build && node --experimental-modules --es-module-specifier-resolution=node dist/runner.js logseq",
"test": "jest"
"test": "vitest"
},
"devDependencies": {
"@babel/preset-env": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@jest/globals": "^29.6.2",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.9",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"eslint": "^8.21.0",
"jest": "^29.6.2",
"prettier": "^3.0.1",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"vitest": "^1.6.0"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -72,10 +70,5 @@
}
]
},
"jest": {
"testMatch": [
"**/?(*.)+(test).[t]s?(x)"
]
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion src/converters/IConverter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TanaIntermediateFile } from '../types/types';
import { TanaIntermediateFile } from '../types/types.js';

export interface IConverter {
convert(fileContent: string): TanaIntermediateFile | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/converters/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from '@jest/globals';
import { expect, test } from 'vitest';
import {
findPreceedingAlias,
getAttributeDefinitionsFromName,
Expand Down
12 changes: 6 additions & 6 deletions src/converters/logseq/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import {
TanaIntermediateNode,
TanaIntermediateFile,
TanaIntermediateSummary,
} from '../../types/types';
} from '../../types/types.js';
import {
enrichRoam,
findGroups,
getBracketLinks,
getCodeIfCodeblock,
idgenerator,
isIndexWithinBackticks,
} from '../../utils/utils';
import { IConverter } from '../IConverter';
import { hasImages, dateStringToUSDateUID, dateStringToYMD } from '../common';
} from '../../utils/utils.js';
import { IConverter } from '../IConverter.js';
import { hasImages, dateStringToUSDateUID, dateStringToYMD } from '../common.js';
import {
hasDuplicateProperties,
isDone,
isTodo,
replaceLogseqSyntax,
setNodeAsDone,
setNodeAsTodo,
} from './logseqUtils';
import { LogseqBlock, LogseqFile } from './types';
} from './logseqUtils.js';
import { LogseqBlock, LogseqFile } from './types.js';

const DATE_REGEX = /^\w+\s\d{1,2}\w{2},\s\d+$/;

Expand Down
4 changes: 2 additions & 2 deletions src/converters/logseq/logseqUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TanaIntermediateNode } from '../../types/types';
import { LogseqBlock } from './types';
import { TanaIntermediateNode } from '../../types/types.js';
import { LogseqBlock } from './types.js';

// TODO and DONE in roam
const TODO_FLAG = 'TODO';
Expand Down
6 changes: 3 additions & 3 deletions src/converters/logseq/tests/logseq.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */

import { expect, test } from '@jest/globals';
import { expectImage } from '../../../testUtils/testUtils';
import { getField, importLogseqFile } from './testUtils';
import { expect, test } from 'vitest';
import { expectImage } from '../../../testUtils/testUtils.js';
import { getField, importLogseqFile } from './testUtils.js';

test('Summary smoketest', async () => {
const [file] = importLogseqFile('smoketest.json');
Expand Down
2 changes: 1 addition & 1 deletion src/converters/logseq/tests/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LogseqConverter } from '..';
import { IdLookupHelper, importFileAndGetHelpers } from '../../../testUtils/testUtils';
import { IdLookupHelper, importFileAndGetHelpers } from '../../../testUtils/testUtils.js';

export function importLogseqFile(fileToLoad: string) {
return importFileAndGetHelpers(new LogseqConverter(), `./src/converters/logseq/tests/fixtures/${fileToLoad}`);
Expand Down
10 changes: 5 additions & 5 deletions src/converters/roam/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import {
TanaIntermediateNode,
TanaIntermediateFile,
TanaIntermediateSummary,
} from '../../types/types';
} from '../../types/types.js';
import {
enrichRoam,
findGroups,
getBracketLinks,
getCodeIfCodeblock,
idgenerator,
isIndexWithinBackticks,
} from '../../utils/utils';
import { IConverter } from '../IConverter';
} from '../../utils/utils.js';
import { IConverter } from '../IConverter.js';
import {
getAttributeDefinitionsFromName,
getValueForAttribute,
hasField,
hasImages,
dateStringToUSDateUID,
dateStringToYMD,
} from '../common';
import { isDone, isTodo, replaceRoamSyntax, setNodeAsDone, setNodeAsTodo } from './roamUtils';
} from '../common.js';
import { isDone, isTodo, replaceRoamSyntax, setNodeAsDone, setNodeAsTodo } from './roamUtils.js';

type RoamNode = {
uid: string;
Expand Down
2 changes: 1 addition & 1 deletion src/converters/roam/roamUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TanaIntermediateNode } from '../../types/types';
import { TanaIntermediateNode } from '../../types/types.js';

// TODO and DONE in roam
const TODO_FLAG = '{{[[TODO]]}} ';
Expand Down
6 changes: 3 additions & 3 deletions src/converters/roam/tests/roam.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */

import { expect, test } from '@jest/globals';
import { expectField, expectImage } from '../../../testUtils/testUtils';
import { importRoamFile } from './testUtils';
import { expect, test } from 'vitest';
import { expectField, expectImage } from '../../../testUtils/testUtils.js';
import { importRoamFile } from './testUtils.js';

test('Smoke test import preview ', async () => {
const [file] = importRoamFile('smoketest.json');
Expand Down
2 changes: 1 addition & 1 deletion src/converters/roam/tests/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RoamConverter } from '..';
import { importFileAndGetHelpers } from '../../../testUtils/testUtils';
import { importFileAndGetHelpers } from '../../../testUtils/testUtils.js';

export function importRoamFile(fileToLoad: string) {
return importFileAndGetHelpers(new RoamConverter(), `./src/converters/roam/tests/fixtures/${fileToLoad}`);
Expand Down
6 changes: 3 additions & 3 deletions src/converters/workflowy/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TanaIntermediateFile, TanaIntermediateNode, TanaIntermediateSummary } from '../../types/types';
import { idgenerator } from '../../utils/utils';
import { opml2js, Sub, TheOutline } from './opml2js';
import { TanaIntermediateFile, TanaIntermediateNode, TanaIntermediateSummary } from '../../types/types.js';
import { idgenerator } from '../../utils/utils.js';
import { opml2js, Sub, TheOutline } from './opml2js.js';

export class WorkflowyConverter {
private nodesForImport: Map<string, TanaIntermediateNode> = new Map();
Expand Down
4 changes: 2 additions & 2 deletions src/converters/workflowy/tests/opml2sj.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@jest/globals';
import { opml2js } from '../opml2js';
import { expect, test } from 'vitest';
import { opml2js } from '../opml2js.js';

test('note support ', async () => {
const opml = `
Expand Down
4 changes: 2 additions & 2 deletions src/converters/workflowy/tests/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WorkflowyConverter } from '..';
import { TanaIntermediateFile, TanaIntermediateNode } from '../../../types/types';
import { importFileAndGetHelpers } from '../../../testUtils/testUtils';
import { TanaIntermediateFile, TanaIntermediateNode } from '../../../types/types.js';
import { importFileAndGetHelpers } from '../../../testUtils/testUtils.js';

export type IdLookupHelper = (id: string | undefined) => TanaIntermediateNode | undefined;

Expand Down
4 changes: 2 additions & 2 deletions src/converters/workflowy/tests/workflowy.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@jest/globals';
import { importWorkflowyFile } from './testUtils';
import { expect, test } from 'vitest';
import { importWorkflowyFile } from './testUtils.js';

test('Smoke test import preview ', async () => {
const [file, , fn] = importWorkflowyFile('smoketest.opml');
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './converters/roam';
export * from './converters/workflowy';
export * from './converters/logseq';
export * from './types/types';
export * from './converters/roam/index.js';
export * from './converters/workflowy/index.js';
export * from './converters/logseq/index.js';
export * from './types/types.js';
2 changes: 1 addition & 1 deletion src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { exit } from 'process';
import * as fs from 'fs';

import { TanaIntermediateFile } from './types/types';
import { TanaIntermediateFile } from './types/types.js';
import { RoamConverter } from './converters/roam/index.js';
import { WorkflowyConverter } from './converters/workflowy/index.js';
import { LogseqConverter } from './converters/logseq/index.js';
Expand Down
6 changes: 3 additions & 3 deletions src/testUtils/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as fs from 'fs';
import { expect } from '@jest/globals';
import { expect } from 'vitest';
import { fail } from 'assert';
import { TanaIntermediateNode, TanaIntermediateFile } from '../types/types';
import { IConverter } from '../converters/IConverter';
import { TanaIntermediateNode, TanaIntermediateFile } from '../types/types.js';
import { IConverter } from '../converters/IConverter.js';

export type IdLookupHelper = (id: string | undefined) => TanaIntermediateNode | undefined;

Expand Down
4 changes: 2 additions & 2 deletions src/testUtils/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@jest/globals';
import { findGroups, getBracketLinks, isIndexWithinBackticks, replaceTokenWithHtml } from '../utils/utils';
import { expect, test } from 'vitest';
import { findGroups, getBracketLinks, isIndexWithinBackticks, replaceTokenWithHtml } from '../utils/utils.js';

test('isIndexWithinBackticks', () => {
expect(isIndexWithinBackticks(0, '```fooo```')).toBe(false);
Expand Down
Loading

0 comments on commit 7c54241

Please sign in to comment.