Skip to content

Commit

Permalink
Switch to tsup for package builds + enable noImplicitAny #1018
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps committed Dec 2, 2024
1 parent 121f416 commit 325ae2e
Show file tree
Hide file tree
Showing 49 changed files with 1,178 additions and 601 deletions.
7 changes: 7 additions & 0 deletions browser/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ publish
.husky
.nohup
.swc
.tsup
*/lib
*/dist
*/dev-dist
Expand All @@ -26,3 +27,9 @@ data-browser/coverage
!.yarn/versions
.DS_Store
**/.trunk/*

**/tomic-lib-**.tgz
**/tomic-react-**.tgz
**/tomic-svelte-**.tgz
**/tomic-cli-**.tgz
**/tomic-create-template-**.tgz
5 changes: 5 additions & 0 deletions browser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ This changelog covers all five packages, as they are (for now) updated as a whol
- `resource.props` is now writeable: `resource.props.name = 'New Name'`.
- Added `store.preloadResourceTree()` method, see docs for more info.
- Fix generated ontologies not working in a Next.js server context.
- Fix types masquerading as esm module in cjs build.

### @tomic/react

- Add cjs build.

### @tomic/cli

Expand Down
6 changes: 6 additions & 0 deletions browser/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ all:
BUILD +build
BUILD +test
BUILD +lint
BUILD +lint-package
BUILD +typedoc

deps:
Expand All @@ -18,6 +19,7 @@ deps:
COPY react/package.json react/.
COPY svelte/package.json svelte/.
COPY cli/package.json cli/.
COPY create-template/package.json create-template/.
RUN pnpm install --frozen-lockfile --shamefully-hoist
COPY . .

Expand All @@ -30,6 +32,10 @@ lint:
FROM +deps
RUN pnpm run lint

lint-package:
FROM +deps
RUN pnpm run lint-package

build:
FROM +deps
RUN pnpm run build
Expand Down
13 changes: 11 additions & 2 deletions browser/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"version": "0.40.0",
"author": "Polle Pas",
"homepage": "https://docs.atomicdata.dev/js-cli",
"repository": {
"type": "git",
"url": "git+https://github.com/atomicdata-dev/atomic-server.git"
},
"bugs": {
"url": "https://github.com/atomicdata-dev/atomic-server/issues"
},
"dependencies": {
"@tomic/lib": "workspace:*",
"chalk": "^5.3.0",
Expand All @@ -9,7 +17,7 @@
"devDependencies": {
"typescript": "^5.6.3"
},
"description": "",
"description": "Generate types from Atomic Data ontologies",
"license": "MIT",
"name": "@tomic/cli",
"publishConfig": {
Expand All @@ -19,7 +27,8 @@
"build": "tsc",
"lint": "eslint ./src --ext .js,.ts",
"lint-fix": "eslint ./src --ext .js,.ts --fix",
"prepublishOnly": "pnpm run build && pnpm run lint-fix",
"prepublishOnly": "pnpm run build && pnpm run lint && pnpm run lint-package",
"lint-package": "pnpm dlx publint",
"watch": "tsc --build --watch",
"start": "pnpm watch",
"tsc": "pnpm exec tsc --build",
Expand Down
11 changes: 10 additions & 1 deletion browser/create-template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"version": "0.40.0",
"author": "Polle Pas",
"homepage": "https://docs.atomicdata.dev/create-template/atomic-template",
"repository": {
"type": "git",
"url": "git+https://github.com/atomicdata-dev/atomic-server.git"
},
"bugs": {
"url": "https://github.com/atomicdata-dev/atomic-server/issues"
},
"dependencies": {
"@tomic/lib": "workspace:*",
"chalk": "^5.3.0",
Expand All @@ -20,7 +28,8 @@
"build": "tsc",
"lint": "eslint ./src --ext .js,.ts",
"lint-fix": "eslint ./src --ext .js,.ts --fix",
"prepublishOnly": "pnpm run build && pnpm run lint-fix",
"prepublishOnly": "pnpm run build && pnpm run lint && pnpm run lint-package",
"lint-package": "pnpm dlx publint",
"watch": "tsc --build --watch",
"start": "pnpm exec tsc --build --watch",
"tsc": "pnpm exec tsc --build",
Expand Down
9 changes: 4 additions & 5 deletions browser/data-browser/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserRouter } from 'react-router-dom';
import { HelmetProvider } from 'react-helmet-async';
import { StoreContext, Store } from '@tomic/react';
import { StyleSheetManager } from 'styled-components';
import { StyleSheetManager, type ShouldForwardProp } from 'styled-components';

import { GlobalStyle, ThemeWrapper } from './styling';
import { AppRoutes } from './routes/Routes';
Expand Down Expand Up @@ -75,15 +75,15 @@ if (isDev()) {
}

// This implements the default behavior from styled-components v5
function shouldForwardProp(propName, target) {
const shouldForwardProp: ShouldForwardProp<'web'> = (propName, target) => {
if (typeof target === 'string') {
// For HTML elements, forward the prop if it is a valid HTML attribute
return isPropValid(propName);
}

// For other elements, forward all props
return true;
}
};

/** Entrypoint of the application. This is where providers go. */
function App(): JSX.Element {
Expand All @@ -97,11 +97,10 @@ function App(): JSX.Element {
<HotKeysWrapper>
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
<ThemeWrapper>
{/* @ts-ignore TODO: Check if types are fixed or upgrade styled-components to 6.0.0 */}
<GlobalStyle />
{/* @ts-ignore fallback component type too strict */}
<ErrBoundary FallbackComponent={CrashPage}>
{/* Default form validation provider. Does not do anyting on its own but will make sure useValidation works without context*/}
{/* Default form validation provider. Does not do anything on its own but will make sure useValidation works without context*/}
<FormValidationContextProvider
onValidationChange={() => undefined}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const processCurrencyFile = (xmlStr: string): string => {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlStr, 'text/xml');
const currencyNodes = xmlDoc.getElementsByTagName('CcyNtry');
const currencyMap = {};
const currencyMap: Record<string, string> = {};

for (let i = 0; i < currencyNodes.length; i++) {
const currencyNode = currencyNodes[i];
Expand All @@ -22,7 +22,10 @@ export const processCurrencyFile = (xmlStr: string): string => {

const currencyName =
currencyNode.getElementsByTagName('CcyNm')[0]?.textContent;
currencyMap[code] = currencyName;

if (currencyName) {
currencyMap[code] = currencyName;
}
}

return JSON.stringify(currencyMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const SlashCommands = Extension.create({
return {
suggestion: {
char: '/',
// @ts-expect-error Tiptap typing is not very good or clear so they're just any.
command: ({ editor, range, props }) => {
props.command({ editor, range });
},
Expand All @@ -46,7 +47,7 @@ export const suggestion: Partial<SuggestionOptions> = {
icon: FaListUl,
command: ({ editor, range }) =>
editor.chain().focus().deleteRange(range).toggleBulletList().run(),
},
} as CommandItem,
{
title: 'Codeblock',
icon: FaCode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useId } from 'react';
import { IconButton } from '../IconButton/IconButton';
import { DropdownTriggerRenderFunction } from './DropdownTrigger';
import {
DropdownTriggerRenderFunction,
type DropdownTriggerProps,
} from './DropdownTrigger';

/** Builds a default trigger for a dropdown menu using an IconButton.
* Make sure the component stays mounted when the menu is open in order to have proper focus management.
Expand All @@ -11,7 +14,7 @@ export const buildDefaultTrigger = (
ButtonComp: typeof IconButton = IconButton,
): DropdownTriggerRenderFunction => {
const Comp = (
{ onClick, menuId, isActive },
{ onClick, menuId, isActive }: DropdownTriggerProps,
ref: React.Ref<HTMLButtonElement>,
) => {
const id = useId();
Expand Down
64 changes: 0 additions & 64 deletions browser/data-browser/src/components/SearchFilter.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions browser/data-browser/src/components/Searchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function Searchbar({
}
};

function handleChange(e) {
const handleChange: React.ChangeEventHandler<HTMLInputElement> = e => {
setInput(e.target.value);

try {
Expand All @@ -52,9 +52,9 @@ export function Searchbar({
} catch (_err) {
navigate(searchURL(e.target.value, scope), { replace: true });
}
}
};

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
const handleSubmit: React.FormEventHandler<HTMLFormElement> = event => {
if (!subject) {
return;
}
Expand Down
11 changes: 4 additions & 7 deletions browser/data-browser/src/components/TableEditor/TableEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'react';
import { styled } from 'styled-components';
import { FixedSizeList, ListOnScrollProps } from 'react-window';
import Autosizer from 'react-virtualized-auto-sizer';
import Autosizer, { type VerticalSize } from 'react-virtualized-auto-sizer';
import { Cell, IndexCell } from './Cell';
import { TableRow } from './TableRow';
import { TableHeader, TableHeadingComponent } from './TableHeader';
Expand Down Expand Up @@ -157,7 +157,7 @@ function FancyTableInner<T>({
);

const List = useCallback(
({ height }) => (
({ height }: VerticalSize) => (
<StyledFixedSizeList
height={height}
width='100%'
Expand Down Expand Up @@ -186,7 +186,6 @@ function FancyTableInner<T>({
<VisuallyHidden id={ariaUsageId}>
<p>{ARIA_TABLE_USAGE}</p>
</VisuallyHidden>
{/* @ts-ignore */}
<Table
aria-labelledby={labelledBy}
aria-rowcount={itemCount}
Expand Down Expand Up @@ -234,13 +233,12 @@ interface TableProps {
totalContentHeight: number;
}

// @ts-ignore
const Table = styled.div.attrs<TableProps>(p => ({
style: {
'--table-template-columns': p.gridTemplateColumns,
'--table-content-width': p.contentRowWidth,
},
}))<TableProps>`
} as Record<string, string>,
}))`
--table-height: 80vh;
--table-row-height: ${p => p.rowHeight}px;
--table-inner-padding: 0.5rem;
Expand All @@ -257,7 +255,6 @@ const Table = styled.div.attrs<TableProps>(p => ({
&:focus-visible {
outline: none;
/* border-color: ${p => p.theme.colors.main}; */
box-shadow: 0 0 0 2px ${p => p.theme.colors.main};
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface ApplyTemplateDialogProps {
bindOpen: (open: boolean) => void;
}

const stableArray = [];
const stableArray: string[] = [];

export function ApplyTemplateDialog({
template,
Expand Down
Loading

0 comments on commit 325ae2e

Please sign in to comment.