Skip to content

Commit c3a94be

Browse files
authored
Switch to pnpm; Update CRA (tone-row#329)
* chore(module): remove module * chore(pkg): update node version * chore(pkg): remove vscode folder * chore(pkg): nvmrc to node-version * chore(cra): update to react-scripts 5
1 parent 609a93a commit c3a94be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+13645
-15484
lines changed

.github/workflows/benchmark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- uses: actions/checkout@v2
99
- uses: actions/setup-node@v1
1010
with:
11-
node-version: 14.x
11+
node-version: 16.x
1212
- name: Install Deps
1313
run: yarn
1414
- name: Benchmark

.github/workflows/e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup Node
3434
uses: actions/setup-node@v1
3535
with:
36-
node-version: 14.x
36+
node-version: 16.x
3737
- name: Install Playwright
3838
run: |
3939
yarn global add [email protected]

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- uses: actions/checkout@v2
99
- uses: actions/setup-node@v1
1010
with:
11-
node-version: 14.x
11+
node-version: 16.x
1212
- name: Install Dependencies
1313
run: yarn
1414
- name: Test

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ yarn-error.log
77
.env.test.local
88
.env.production.local
99
.vercel
10-
TODO.md
10+
TODO.md
11+
.vscode

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16.17.0

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
auto-install-peers=true

.nvmrc

-1
This file was deleted.

.vscode/launch.json

-15
This file was deleted.

.vscode/settings.json

-4
This file was deleted.

app/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = {
4545
"react/react-in-jsx-scope": "off",
4646
"@typescript-eslint/explicit-module-boundary-types": "off",
4747
"@typescript-eslint/no-explicit-any": "off",
48-
"@typescript-eslint/ban-ts-comment": "warn",
48+
"@typescript-eslint/ban-ts-comment": "off",
4949
"@typescript-eslint/ban-types": "off",
5050
"react/prop-types": 0,
5151
"@typescript-eslint/no-empty-interface": 0,

app/package.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"@sentry/tracing": "^6.18.1",
2323
"@stripe/react-stripe-js": "^1.6.0",
2424
"@stripe/stripe-js": "^1.19.1",
25+
"@supabase/gotrue-js": "^1.22.22",
26+
"@supabase/postgrest-js": "^0.38.0",
2527
"@supabase/supabase-js": "^1.24.0",
28+
"@svgr/webpack": "^6.3.1",
2629
"@testing-library/jest-dom": "^5.11.4",
2730
"@testing-library/react": "^11.1.0",
2831
"@testing-library/user-event": "^12.1.10",
@@ -33,19 +36,22 @@
3336
"@types/node": "^12.0.0",
3437
"@types/react": "^17.0.0",
3538
"@types/react-dom": "^17.0.0",
39+
"buffer": "^6.0.3",
3640
"core-js": "^3.18.1",
3741
"cytoscape": "^3.20.0",
3842
"cytoscape-dagre": "^2.3.2",
3943
"cytoscape-elk": "^2.0.2",
4044
"cytoscape-klay": "^3.1.4",
4145
"date-fns": "^2.25.0",
4246
"deepmerge": "^4.2.2",
47+
"eslint": "^8.3.0",
4348
"file-saver": "^2.0.5",
4449
"flagged": "^2.0.1",
4550
"framer-motion": "^4.1.17",
4651
"gray-matter": "^4.0.2",
4752
"lodash.throttle": "^4.1.1",
4853
"lz-string": "^1.4.4",
54+
"make-plural": "^7.1.0",
4955
"moniker": "^0.1.2",
5056
"phosphor-react": "^1.3.1",
5157
"re-resizable": "^6.9.0",
@@ -57,7 +63,7 @@
5763
"react-icons": "^4.3.1",
5864
"react-query": "^3.26.0",
5965
"react-router-dom": "^5.2.0",
60-
"react-scripts": "4.0.3",
66+
"react-scripts": "5.0.1",
6167
"react-select": "^4.3.1",
6268
"react-use-localstorage": "^3.5.3",
6369
"stripe": "^8.179.0",
@@ -124,8 +130,9 @@
124130
"@types/strip-comments": "^2.0.0",
125131
"@types/svg-parser": "^2.0.1",
126132
"@types/svgo": "^2.6.0",
127-
"@typescript-eslint/eslint-plugin": "^4.26.1",
128-
"@typescript-eslint/parser": "^4.26.1",
133+
"@types/testing-library__jest-dom": "^5.14.5",
134+
"@typescript-eslint/eslint-plugin": "^5",
135+
"@typescript-eslint/parser": "^5",
129136
"axios": "^0.27.2",
130137
"benchmark": "^2.1.4",
131138
"concurrently": "^6.0.0",
@@ -140,6 +147,7 @@
140147
"eslint-plugin-simple-import-sort": "^7.0.0",
141148
"jest-canvas-mock": "^2.3.1",
142149
"minimist": "^1.2.5",
150+
"monaco-editor": "^0.34.0",
143151
"msw": "^0.36.8",
144152
"prettier": "^2.3.1",
145153
"ts-unused-exports": "^7.0.3",

app/src/components/ClearTextButton.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function ClearTextButton({ handleClear }: { handleClear: () => void }) {
2929
dialogProps={{
3030
isOpen: dialogOpen,
3131
onDismiss: () => setDialogOpen(false),
32+
"aria-label": t`Clear text`,
3233
}}
3334
>
3435
<Trans>Clear text?</Trans>

app/src/components/Graph.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ const Graph = memo(
152152
userStyle: string;
153153
}>({ content: "", layout: "", userStyle: "" });
154154

155+
// Memoize values, return previous values if parsing fails
155156
const { content, layout, userStyle } = useMemo(() => {
156157
try {
157158
const { data, content } = frontmatter(stripComments(textToParse), {
@@ -166,7 +167,8 @@ const Graph = memo(
166167
};
167168
lastValues.current = values;
168169
return values;
169-
} catch {
170+
} catch (error) {
171+
console.error(error);
170172
return lastValues.current;
171173
}
172174
}, [textToParse]);

app/src/components/GraphWrapper.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ReactNode, useContext } from "react";
2-
import { useRouteMatch } from "react-router";
2+
import { useRouteMatch } from "react-router-dom";
33

44
import { HiddenGraphOptions } from "../lib/helpers";
55
import { useFullscreen, useIsValidSponsor } from "../lib/hooks";

app/src/components/LoginForm.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ import { login } from "../lib/queries";
88
import { Box, Type } from "../slang";
99
import styles from "./LoginForm.module.css";
1010
import { Button, Input, Notice, Section } from "./Shared";
11-
11+
type Fields = {
12+
email: string;
13+
};
1214
export function LoginForm({ heading }: { heading: ReactNode }) {
13-
const { register, handleSubmit } = useForm();
15+
const { register, handleSubmit } = useForm<Fields>();
1416
const [success, setSuccess] = useState(false);
1517
const { mutate, isLoading, error } = useMutation(login, {
1618
onSuccess: () => setSuccess(true),
1719
});
20+
1821
const onSubmit = useCallback(
19-
({ email }: { email: string }) => {
22+
({ email }: Fields) => {
2023
mutate(email);
2124
},
2225
[mutate]

app/src/components/MenuNext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { memo, useContext, useRef, useState } from "react";
1818
import { useForm } from "react-hook-form";
1919
import { useMutation } from "react-query";
20-
import { useHistory, useRouteMatch } from "react-router";
20+
import { useHistory, useRouteMatch } from "react-router-dom";
2121

2222
import { gaChangeTab, gaCopyChart, gaNewChart } from "../lib/analytics";
2323
import {

app/src/components/Navigation.tsx

+17-9
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,12 @@ export default function Charts() {
9090
</Box>
9191
);
9292
}
93-
93+
type Fields = {
94+
chartTitle: string;
95+
};
9496
function LocalCharts() {
9597
const { setShowing } = useContext(AppContext);
96-
const { watch, register, handleSubmit } = useForm();
98+
const { watch, register, handleSubmit } = useForm<Fields>();
9799
const title = watch("chartTitle");
98100
const [charts, setCharts] = useState<string[]>([]);
99101
const { push } = useHistory();
@@ -103,7 +105,7 @@ function LocalCharts() {
103105
const [copy, setCopy] = useState("");
104106

105107
const onSubmit = useCallback(
106-
({ chartTitle }: { chartTitle: string }) => {
108+
({ chartTitle }: Fields) => {
107109
if (chartTitle) {
108110
push(`/${chartTitle}`);
109111
setShowing("editor");
@@ -341,7 +343,9 @@ function CopyChart({
341343
</Dialog>
342344
);
343345
}
344-
346+
type CreateNewFields = {
347+
name: string;
348+
};
345349
function HostedCharts() {
346350
const validSponsor = useIsValidSponsor();
347351
const { session, setShowing } = useContext(AppContext);
@@ -356,10 +360,11 @@ function HostedCharts() {
356360
},
357361
});
358362
const { data: charts } = useCharts();
359-
const { register, watch, handleSubmit } = useForm();
363+
const { register, watch, handleSubmit } = useForm<CreateNewFields>();
360364
const name = watch("name");
365+
361366
const onSubmit = useCallback(
362-
({ name }: { name: string }) => {
367+
({ name }: CreateNewFields) => {
363368
session?.user?.id && mutate({ name, user_id: session?.user?.id });
364369
},
365370
[mutate, session?.user?.id]
@@ -478,15 +483,17 @@ function CopyHostedChart({
478483
</Dialog>
479484
);
480485
}
481-
486+
type CopyHostedFields = {
487+
name: string;
488+
};
482489
function CopyHostedChartInner({
483490
isOpen,
484491
onDismiss,
485492
}: {
486493
isOpen: boolean | number;
487494
onDismiss: () => void;
488495
}) {
489-
const { register, handleSubmit, watch } = useForm();
496+
const { register, handleSubmit, watch } = useForm<CopyHostedFields>();
490497
const copyName = watch("name");
491498
const { push } = useHistory();
492499
const newChart = useMutation("makeChart", makeChart, {
@@ -500,7 +507,8 @@ function CopyHostedChartInner({
500507
typeof isOpen === "number" ? isOpen.toString() : undefined
501508
);
502509
const { session } = useContext(AppContext);
503-
function onSubmit({ name }: { name: string }) {
510+
511+
function onSubmit({ name }: CopyHostedFields) {
504512
if (chart && session?.user?.id) {
505513
newChart.mutate({
506514
name,

app/src/components/SponsorDashboard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
33
import { ReactNode, useCallback, useContext, useState } from "react";
44
import { useForm } from "react-hook-form";
55
import { useMutation } from "react-query";
6-
import { useHistory } from "react-router";
6+
import { useHistory } from "react-router-dom";
77

88
import { formatCents, formatDate, formatRelative } from "../lib/helpers";
99
import {

app/src/components/useDownloadHandlers.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ export default function useDownloadHandlers(
5555

5656
// Add font file if necessary
5757
let fontString = "";
58-
if (graphTheme.font?.files) {
59-
for (const { url, name } of graphTheme.font?.files) {
58+
const files = graphTheme.font.files;
59+
if (files) {
60+
for (const { url, name } of files) {
6061
if (!(url in window.__flowchartFunBase64EncodedFonts)) {
6162
const fontUrl = `/fonts/${url}`;
6263
const font = await fetch(fontUrl)

app/src/index.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ import "core-js/features/object/entries";
55

66
import * as Sentry from "@sentry/react";
77
import { Integrations } from "@sentry/tracing";
8+
import { Buffer } from "buffer";
89
import React from "react";
910
import ReactDOM from "react-dom";
1011

1112
import pkg from "../package.json";
1213
import App from "./components/App";
1314
import reportWebVitals from "./reportWebVitals";
1415

16+
// Fixes Webpack 5 Buffer polyfill issue
17+
declare global {
18+
interface Window {
19+
Buffer: typeof Buffer;
20+
}
21+
}
22+
window.Buffer = Buffer;
23+
1524
Sentry.init({
1625
release: `flowchartfun@${pkg.version}`,
1726
dsn: "https://[email protected]/5673697",

app/src/lib/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const editorOptions: EditorProps["options"] = {
3939
insertSpaces: true,
4040
wordBasedSuggestions: false,
4141
occurrencesHighlight: false,
42-
renderLineHighlight: false,
43-
highlightActiveIndentGuide: false,
42+
// TODO: choose the correct render line highlight, used to be false
43+
renderLineHighlight: "none",
4444
scrollBeyondLastLine: false,
4545
overviewRulerBorder: false,
4646
lineDecorationsWidth: "10px",

app/src/lib/parseText.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ describe("parseText", () => {
315315
});
316316

317317
test.skip("line number should account for yaml length, passed in", () => {
318-
const edges = parseText(`a\n\t(5)`, getSize, 4).filter(edgesOnly);
318+
const edges = parseText(`a\n\t(5)`, getSize).filter(edgesOnly);
319319
expect(edges).toContainEqual({
320320
data: {
321321
id: "N14e_5:0",
@@ -328,9 +328,9 @@ describe("parseText", () => {
328328
});
329329

330330
test("should produce the same ID's regardless of line number start'", () => {
331-
const resultA = parseText(`a\nb`, getSize, 0);
331+
const resultA = parseText(`a\nb`, getSize);
332332
const idsA = resultA.map((n) => n.data.id);
333-
const resultB = parseText(`a\nb`, getSize, 1);
333+
const resultB = parseText(`a\nb`, getSize);
334334
const idsB = resultB.map((n) => n.data.id);
335335
expect(idsA).toEqual(idsB);
336336
});

app/src/lib/registerLanguage.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { palette } from "../slang/config";
66
export const languageId = "flowchartfun";
77
export const themeNameLight = "flowchartfun-light";
88
export const themeNameDark = "flowchartfun-dark";
9+
import type { editor } from "monaco-editor";
910

10-
const lightTheme = {
11+
const lightTheme: editor.IStandaloneThemeData = {
1112
base: "vs",
1213
inherit: true,
14+
colors: {},
1315
rules: [
1416
{ token: "nodeIdAndClass", foreground: palette.purple[0] },
1517
{
@@ -23,9 +25,10 @@ const lightTheme = {
2325
],
2426
};
2527

26-
const darkTheme = {
28+
const darkTheme: editor.IStandaloneThemeData = {
2729
base: "vs-dark",
2830
inherit: true,
31+
colors: {},
2932
rules: [
3033
// ID
3134
{ token: "nodeIdAndClass", foreground: palette.purple[0] },

app/src/pages/Edit.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const Edit = memo(function Edit() {
6969
>
7070
<Editor
7171
value={text}
72+
// @ts-ignore
7273
wrapperClassName={styles.Editor}
7374
defaultLanguage={languageId}
7475
options={editorOptions}

0 commit comments

Comments
 (0)