Skip to content

Commit

Permalink
🔨 downgrade dependencies to avoid ESM for now
Browse files Browse the repository at this point in the history
Also fixed a few other issues
  • Loading branch information
danyx23 committed Oct 30, 2023
1 parent 3e14287 commit 0e1f343
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 411 deletions.
2 changes: 1 addition & 1 deletion adminSiteClient/ChartEditorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
IReactionDisposer,
} from "mobx"
import { Prompt, Redirect } from "react-router-dom"
import { extractDetailsFromSyntax } from "@ourworldindata/components"
import {
Bounds,
capitalize,
Expand All @@ -19,6 +18,7 @@ import {
get,
set,
groupBy,
extractDetailsFromSyntax,
} from "@ourworldindata/utils"
import { Grapher, Topic, GrapherInterface } from "@ourworldindata/grapher"
import { Admin } from "./Admin.js"
Expand Down
3 changes: 2 additions & 1 deletion baker/SiteBaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ import {
OwidGdocPublished,
clone,
LinkedChart,
extractDetailsFromSyntax,
} from "@ourworldindata/utils"
import { extractDetailsFromSyntax } from "@ourworldindata/components"

import { execWrapper } from "../db/execWrapper.js"
import { countryProfileSpecs } from "../site/countryProfileProjects.js"
import {
Expand Down
37 changes: 0 additions & 37 deletions devTools/dodParserTestGenerator/generate-test.ts

This file was deleted.

8 changes: 0 additions & 8 deletions devTools/dodParserTestGenerator/tsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"@types/jsonwebtoken": "^9.0.0",
"@types/lodash": "^4.14.185",
"@types/md5": "^2.3.2",
"@types/mdast": "^4.0.2",
"@types/mdast": "^3.0",
"@types/minimist": "^1.2.2",
"@types/mousetrap": "^1.6.9",
"@types/mysql": "^2.15.21",
Expand Down Expand Up @@ -155,7 +155,7 @@
"lodash": "^4.17.20",
"mathjax-full": "^3.1.0",
"md5": "^2.3.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-from-markdown": "^0.8.0",
"minimist": "^1.2.6",
"mobx": "^5.15.7",
"mobx-formatters": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
FontFamily,
} from "@ourworldindata/utils"
import { TextWrap } from "../TextWrap/TextWrap.js"
import { fromMarkdown } from "mdast-util-from-markdown"
import { Root, Node, RootContentMap } from "mdast"
import fromMarkdown from "mdast-util-from-markdown"
import { Root, Content } from "mdast"

Check failure on line 16 in packages/@ourworldindata/components/src/MarkdownTextWrap/MarkdownTextWrap.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unable to resolve path to module 'mdast'

Check failure on line 16 in packages/@ourworldindata/components/src/MarkdownTextWrap/MarkdownTextWrap.tsx

View workflow job for this annotation

GitHub Actions / eslint

Unable to resolve path to module 'mdast'
import { match } from "ts-pattern"

const SUPERSCRIPT_NUMERALS = {
Expand Down Expand Up @@ -749,9 +749,9 @@ function convertMarkdownRootToIRTokens(node: Root): IRToken[] {
return node.children.flatMap(convertMarkdownNodeToIRTokens)
}

function convertMarkdownNodeToIRTokens(
node: RootContentMap[keyof RootContentMap]
): IRToken[] {
// When using mdast types version 4 this should be typed as:
// node: RootContentMap[keyof RootContentMap]
function convertMarkdownNodeToIRTokens(node: Content): IRToken[] {
const converted = match(node)
.with(
{
Expand Down Expand Up @@ -970,6 +970,14 @@ function convertMarkdownNodeToIRTokens(
return [new IRText(item.value)]
}
)
.with(
{
type: "footnote",
},
(item) => {
return item.children.flatMap(convertMarkdownNodeToIRTokens)
}
)
.exhaustive()
return converted
}
15 changes: 15 additions & 0 deletions packages/@ourworldindata/utils/src/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1794,3 +1794,18 @@ export const formatAuthors = ({

return authorsText
}

/** Works for:
* #dod:text
* #dod:text-hyphenated
* #dod:text_underscored
* #dod:text_underscored-and-hyphenated
* Duplicated in parser.ts
*/
export const detailOnDemandRegex = /#dod:([\w\-_]+)/

export function extractDetailsFromSyntax(str: string): string[] {
return [...str.matchAll(new RegExp(detailOnDemandRegex, "g"))].map(
([_, term]) => term
)
}
3 changes: 2 additions & 1 deletion packages/@ourworldindata/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ export {
without,
zip,
lowercaseObjectKeys,
detailOnDemandRegex,
extractDetailsFromSyntax,
} from "./Util.js"

export { isPresent } from "./isPresent.js"
Expand Down Expand Up @@ -609,5 +611,4 @@ export {
IMAGES_DIRECTORY,
gdocUrlRegex,
gdocIdRegex,
detailOnDemandRegex,
} from "./GdocsConstants.js"
57 changes: 42 additions & 15 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,47 @@
},
"files": [],
"references": [
{ "path": "./gridLang" },
{ "path": "./gitCms" },
{ "path": "./explorer" },
{ "path": "./datapage" },
{ "path": "./site" },
{ "path": "./settings" },
{ "path": "./adminSiteClient" },
{ "path": "./adminSiteServer" },
{ "path": "./devTools/svgTester" },
{ "path": "./devTools/schema" },
{ "path": "./devTools/schemaProcessor" },
{ "path": "./devTools/dodParserTestGenerator" },
{ "path": "./devTools/uploadWordpressImagesToObjStorage" },
{ "path": "./devTools/explorerTools" },
{ "path": "./devTools/regionsUpdater" }
{
"path": "./gridLang"
},
{
"path": "./gitCms"
},
{
"path": "./explorer"
},
{
"path": "./datapage"
},
{
"path": "./site"
},
{
"path": "./settings"
},
{
"path": "./adminSiteClient"
},
{
"path": "./adminSiteServer"
},
{
"path": "./devTools/svgTester"
},
{
"path": "./devTools/schema"
},
{
"path": "./devTools/schemaProcessor"
},
{
"path": "./devTools/uploadWordpressImagesToObjStorage"
},
{
"path": "./devTools/explorerTools"
},
{
"path": "./devTools/regionsUpdater"
}
]
}
Loading

0 comments on commit 0e1f343

Please sign in to comment.