Skip to content

Commit

Permalink
Updated a bunch of dependencies (foambubble#1160)
Browse files Browse the repository at this point in the history
* Updated typescript and vscode engine version to support workspace trust

* updates tsdx to dts, and updated a other deps too

* updated eslint configuration

* Updated node version

* Update lerna

* Updated github action configuration

* removed glob library
  • Loading branch information
riccardoferretti committed Feb 10, 2023
1 parent 2a14dc0 commit d0ee71b
Show file tree
Hide file tree
Showing 41 changed files with 6,040 additions and 7,828 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
"sourceType": "module"
},
"env": { "node": true, "es6": true },
"plugins": ["@typescript-eslint", "import", "jest"],
"plugins": ["jest"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:jest/recommended"
],
"rules": {
"no-redeclare": "off",
"no-unused-vars": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-unused-vars": "warn",
"import/no-extraneous-dependencies": [
"error",
{
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ on:
jobs:
lint:
name: Lint
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v1
- name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '12'
node-version: '18'
- name: Restore Dependencies and VS Code test instance
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
Expand All @@ -36,19 +36,19 @@ jobs:
name: Build and Test
strategy:
matrix:
os: [macos-10.15, ubuntu-18.04, windows-2019]
os: [macos-12, ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '12'
node-version: '18'
- name: Restore Dependencies and VS Code test instance
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@
},
"devDependencies": {
"all-contributors-cli": "^6.16.1",
"lerna": "^3.22.1"
"lerna": "^6.4.1"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint"
}
},
"prettier": {
"arrowParens": "avoid",
"printWidth": 80,
"semi": true,
"singleQuote": true,
Expand Down
39 changes: 22 additions & 17 deletions packages/foam-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
"workspaceContains:.vscode/foam.json"
],
"main": "./out/extension.js",
"capabilities": {
"untrustedWorkspaces": {
"supported": "limited",
"description": "No expressions are allowed in filters."
}
},
"contributes": {
"markdown.markdownItPlugins": true,
"markdown.previewStyles": [
Expand Down Expand Up @@ -457,7 +463,7 @@
"test:unit": "node ./out/test/run-tests.js --unit",
"pretest:e2e": "yarn build",
"test:e2e": "node ./out/test/run-tests.js --e2e",
"lint": "tsdx lint src",
"lint": "dts lint src",
"clean": "rimraf out",
"watch": "tsc --build ./tsconfig.json --watch",
"vscode:start-debugging": "yarn clean && yarn watch",
Expand All @@ -471,32 +477,31 @@
},
"devDependencies": {
"@types/dateformat": "^3.0.1",
"@types/glob": "^7.1.1",
"@types/jest": "^27.5.1",
"@types/lodash": "^4.14.157",
"@types/markdown-it": "^12.0.1",
"@types/micromatch": "^4.0.1",
"@types/node": "^13.11.0",
"@types/picomatch": "^2.2.1",
"@types/remove-markdown": "^0.1.1",
"@types/vscode": "^1.47.1",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"esbuild": "^0.14.45",
"eslint": "^6.8.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^25.3.0",
"glob": "^7.1.6",
"@types/vscode": "^1.70.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"esbuild": "^0.17.7",
"eslint": "^8.33.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"husky": "^4.2.5",
"jest": "^26.2.2",
"jest-extended": "^0.11.5",
"jest": "^27.5.1",
"jest-extended": "^3.2.3",
"markdown-it": "^12.0.4",
"micromatch": "^4.0.2",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
"tsdx": "^0.13.2",
"ts-jest": "^27.1.5",
"dts-cli": "^1.6.3",
"tslib": "^2.0.0",
"typescript": "^3.9.5",
"typescript": "^4.9.5",
"vscode-test": "^1.3.0",
"wait-for-expect": "^3.0.2"
},
Expand All @@ -506,7 +511,7 @@
"github-slugger": "^1.4.0",
"gray-matter": "^4.0.2",
"lodash": "^4.17.21",
"lru-cache": "^7.12.0",
"lru-cache": "^7.14.1",
"markdown-it-regex": "^0.2.0",
"remark-frontmatter": "^2.0.0",
"remark-parse": "^8.0.2",
Expand Down
35 changes: 8 additions & 27 deletions packages/foam-vscode/src/core/model/graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ describe('Graph', () => {
const noteD = createTestNote({ uri: '/Page D.md' });
const noteE = createTestNote({ uri: '/page e.md' });

workspace
.set(noteA)
.set(noteB)
.set(noteC)
.set(noteD)
.set(noteE);
workspace.set(noteA).set(noteB).set(noteC).set(noteD).set(noteE);
const graph = FoamGraph.fromWorkspace(workspace);

expect(graph.getBacklinks(noteB.uri).map(l => l.source)).toEqual([
Expand Down Expand Up @@ -69,9 +64,7 @@ describe('Graph', () => {
uri: '/note-b.md',
links: [{ to: noteA.uri.path }, { to: noteA.uri.path }],
});
const ws = createTestWorkspace()
.set(noteA)
.set(noteB);
const ws = createTestWorkspace().set(noteA).set(noteB);
const graph = FoamGraph.fromWorkspace(ws);
expect(graph.getBacklinks(noteA.uri)).toEqual([
{
Expand All @@ -95,9 +88,7 @@ describe('Graph', () => {
uri: '/note-b.md',
links: [{ to: noteA.uri.path }, { to: noteA.uri.path }],
});
const ws = createTestWorkspace()
.set(noteA)
.set(noteB);
const ws = createTestWorkspace().set(noteA).set(noteB);
const graph = FoamGraph.fromWorkspace(ws, true);

expect(graph.getBacklinks(noteA.uri).length).toEqual(2);
Expand Down Expand Up @@ -165,9 +156,7 @@ describe('Graph', () => {
uri: '/path/to/more/attachment-b.pdf',
});
const ws = createTestWorkspace();
ws.set(noteA)
.set(attachmentA)
.set(attachmentB);
ws.set(noteA).set(attachmentA).set(attachmentB);
const graph = FoamGraph.fromWorkspace(ws);

expect(graph.getBacklinks(attachmentA.uri).map(l => l.source)).toEqual([
Expand All @@ -189,9 +178,7 @@ describe('Graph', () => {
uri: '/path/to/attachment-a.pdf',
});
const ws = createTestWorkspace();
ws.set(noteA)
.set(attachmentA)
.set(attachmentABis);
ws.set(noteA).set(attachmentA).set(attachmentABis);
const graph = FoamGraph.fromWorkspace(ws);

expect(graph.getLinks(noteA.uri).map(l => l.target)).toEqual([
Expand All @@ -211,9 +198,7 @@ describe('Graph', () => {
uri: '/path/to/attachment-a.pdf',
});
const ws = createTestWorkspace();
ws.set(noteA)
.set(attachmentABis)
.set(attachmentA);
ws.set(noteA).set(attachmentABis).set(attachmentA);
const graph = FoamGraph.fromWorkspace(ws);

expect(graph.getLinks(noteA.uri).map(l => l.target)).toEqual([
Expand Down Expand Up @@ -323,9 +308,7 @@ describe('Regenerating graph after workspace changes', () => {
uri: '/path/to/more/page-c.md',
});
const ws = createTestWorkspace();
ws.set(noteA)
.set(noteB)
.set(noteC);
ws.set(noteA).set(noteB).set(noteC);
let graph = FoamGraph.fromWorkspace(ws);

expect(graph.getLinks(noteA.uri).map(l => l.target)).toEqual([noteB.uri]);
Expand Down Expand Up @@ -512,9 +495,7 @@ describe('Updating graph on workspace state', () => {
uri: '/path/to/more/page-c.md',
});
const ws = createTestWorkspace();
ws.set(noteA)
.set(noteB)
.set(noteC);
ws.set(noteA).set(noteB).set(noteC);
const graph = FoamGraph.fromWorkspace(ws, true);

expect(graph.getLinks(noteA.uri).map(l => l.target)).toEqual([noteB.uri]);
Expand Down
3 changes: 2 additions & 1 deletion packages/foam-vscode/src/core/model/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import * as pathUtils from '../utils/path';

const _empty = '';
const _slash = '/';
const _regexp = /^(([^:/?#]{2,}?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
const _regexp =
/^(([^:/?#]{2,}?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;

export class URI {
readonly scheme: string;
Expand Down
16 changes: 3 additions & 13 deletions packages/foam-vscode/src/core/model/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ describe('Identifier computation', () => {
const third = createTestNote({
uri: '/another/path/for/page-a.md',
});
const ws = new FoamWorkspace()
.set(first)
.set(second)
.set(third);
const ws = new FoamWorkspace().set(first).set(second).set(third);

expect(ws.getIdentifier(first.uri)).toEqual('to/page-a');
expect(ws.getIdentifier(second.uri)).toEqual('way/for/page-a');
Expand All @@ -120,10 +117,7 @@ describe('Identifier computation', () => {
const third = createTestNote({
uri: '/another/path/for/page-a.md',
});
const ws = new FoamWorkspace()
.set(first)
.set(second)
.set(third);
const ws = new FoamWorkspace().set(first).set(second).set(third);

expect(ws.getIdentifier(first.uri.withFragment('section name'))).toEqual(
'to/page-a#section name'
Expand Down Expand Up @@ -176,11 +170,7 @@ describe('Identifier computation', () => {
const noteD = createTestNote({ uri: '/path/to/note-d.md' });
const noteABis = createTestNote({ uri: '/path/to/another/note-a.md' });

workspace
.set(noteA)
.set(noteB)
.set(noteC)
.set(noteD);
workspace.set(noteA).set(noteB).set(noteC).set(noteD);
expect(workspace.getIdentifier(noteABis.uri)).toEqual('another/note-a');
expect(
workspace.getIdentifier(noteABis.uri, [noteB.uri, noteA.uri])
Expand Down
29 changes: 6 additions & 23 deletions packages/foam-vscode/src/core/services/markdown-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ describe('Link resolution', () => {
);
const noteB = createNoteFromMarkdown('Page b', '/path/one/page b.md');
const noteB2 = createNoteFromMarkdown('Page b 2', '/path/two/page b.md');
workspace
.set(noteA)
.set(noteB)
.set(noteB2);
workspace.set(noteA).set(noteB).set(noteB2);
expect(workspace.resolveLink(noteA, noteA.links[0])).toEqual(noteB2.uri);
});

Expand All @@ -63,10 +60,7 @@ describe('Link resolution', () => {
const noteA = createNoteFromMarkdown('Link to [[page b]]', '/page-a.md');
const noteB = createNoteFromMarkdown('Page b', '/path/one/page b.md');
const noteB2 = createNoteFromMarkdown('Page b2', '/path/two/page b.md');
workspace
.set(noteA)
.set(noteB)
.set(noteB2);
workspace.set(noteA).set(noteB).set(noteB2);
expect(workspace.resolveLink(noteA, noteA.links[0])).toEqual(noteB.uri);
});

Expand All @@ -80,10 +74,7 @@ describe('Link resolution', () => {
const noteB3 = createTestNote({ uri: '/path/to/yet/page-b.md' });

const ws = createTestWorkspace();
ws.set(noteA)
.set(noteB1)
.set(noteB2)
.set(noteB3);
ws.set(noteA).set(noteB1).set(noteB2).set(noteB3);

expect(ws.resolveLink(noteA, noteA.links[0])).toEqual(noteB2.uri);
expect(ws.resolveLink(noteA, noteA.links[1])).toEqual(noteB3.uri);
Expand All @@ -97,10 +88,7 @@ describe('Link resolution', () => {
);
const noteB = createNoteFromMarkdown('Page b', '/path/one/page b.md');
const noteB2 = createNoteFromMarkdown('Page b2', '/path/two/page b.md');
workspace
.set(noteA)
.set(noteB)
.set(noteB2);
workspace.set(noteA).set(noteB).set(noteB2);
expect(workspace.resolveLink(noteA, noteA.links[0])).toEqual(noteB2.uri);
expect(workspace.resolveLink(noteA, noteA.links[1])).toEqual(noteB.uri);
});
Expand Down Expand Up @@ -157,9 +145,7 @@ describe('Link resolution', () => {
],
});
const noteB = createTestNote({ uri: '/somewhere/PAGE-B.md' });
const ws = createTestWorkspace()
.set(noteA)
.set(noteB);
const ws = createTestWorkspace().set(noteA).set(noteB);

expect(ws.resolveLink(noteA, noteA.links[0])).toEqual(
noteB.uri.withFragment('section')
Expand Down Expand Up @@ -258,10 +244,7 @@ describe('Link resolution', () => {
);

const ws = createTestWorkspace();
ws.set(noteA)
.set(noteB)
.set(noteC)
.set(noteD);
ws.set(noteA).set(noteB).set(noteC).set(noteD);

expect(ws.resolveLink(noteB, noteB.links[0])).toEqual(noteA.uri);
expect(ws.resolveLink(noteC, noteC.links[0])).toEqual(noteA.uri);
Expand Down
5 changes: 1 addition & 4 deletions packages/foam-vscode/src/core/utils/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,4 @@ export function isNumeric(value: string): boolean {
}

export const hash = (text: string) =>
crypto
.createHash('sha1')
.update(text)
.digest('hex');
crypto.createHash('sha1').update(text).digest('hex');
6 changes: 4 additions & 2 deletions packages/foam-vscode/src/core/utils/hashtags.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isSome } from './core';
const HASHTAG_REGEX = /(?<=^|\s)#([0-9]*[\p{L}\p{Emoji_Presentation}/_-][\p{L}\p{Emoji_Presentation}\p{N}/_-]*)/gmu;
const WORD_REGEX = /(?<=^|\s)([0-9]*[\p{L}\p{Emoji_Presentation}/_-][\p{L}\p{Emoji_Presentation}\p{N}/_-]*)/gmu;
const HASHTAG_REGEX =
/(?<=^|\s)#([0-9]*[\p{L}\p{Emoji_Presentation}/_-][\p{L}\p{Emoji_Presentation}\p{N}/_-]*)/gmu;
const WORD_REGEX =
/(?<=^|\s)([0-9]*[\p{L}\p{Emoji_Presentation}/_-][\p{L}\p{Emoji_Presentation}\p{N}/_-]*)/gmu;

export const extractHashtags = (
text: string
Expand Down
Loading

0 comments on commit d0ee71b

Please sign in to comment.