Skip to content

Commit

Permalink
Reorg (#50)
Browse files Browse the repository at this point in the history
Reorganize the repo to be in a site/package configuration to make deploy to npm etc easy.
  • Loading branch information
mcnuttandrew authored Jul 6, 2023
1 parent 1396a8a commit ce79e03
Show file tree
Hide file tree
Showing 125 changed files with 10,055 additions and 12,123 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Test and lint
on: [push]
jobs:
build-and-deploy:
test-and-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/[email protected]

- name: Install 🔧
run: yarn
working-directory: ./packages/prong

- name: Test
- name: Test 🔬
run: yarn test
working-directory: ./packages/prong

- name: Lint
- name: Lint 🧵
run: yarn lint
working-directory: ./packages/prong
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Additionally a number of libraries have been forked to support this work, see sr
## Quick start example usage

```tsx
import React, { useState } from "react";
import { useState } from "react";

import Editor from "../components/Editor";
import standardBundle from "../projections/standard-bundle";
Expand Down
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

107 changes: 18 additions & 89 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,90 +1,19 @@
{
"name": "prong",
"version": "0.1.0",
"private": true,
"dependencies": {
"@codemirror/commands": "^6.1.2",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lint": "^6.1.0",
"@codemirror/view": "^6.7.0",
"@json-schema-tools/traverse": "^1.10.1",
"@lezer/common": "^1.0.2",
"@lezer/json": "^1.0.0",
"codemirror": "^6.0.1",
"d3-scale-chromatic": "^3.0.0",
"d3-shape": "^3.2.0",
"jsonc-parser": "^3.0.0",
"lodash.isequal": "^4.5.0",
"lodash.merge": "^4.6.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-markdown": "^7.1.0",
"react-syntax-highlighter": "^15.5.0",
"seedrandom": "^3.0.5"
},
"devDependencies": {
"@codemirror/lang-javascript": "^6.1.4",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/d3": "^7.4.0",
"@types/friendly-words": "^1.2.0",
"@types/jest": "^26.0.15",
"@types/json-schema": "^7.0.11",
"@types/lodash.isequal": "^4.5.5",
"@types/lodash.merge": "^4.6.7",
"@types/node": "^12.0.0",
"@types/react": "^17.0.44",
"@types/react-dom": "^17.0.0",
"@types/react-syntax-highlighter": "^15.5.7",
"@types/seedrandom": "^3.0.5",
"d3-array": "^3.2.1",
"d3-scale": "^4.0.2",
"estree-walker": "^3.0.3",
"friendly-words": "^1.2.0",
"react-colorful": "^5.6.1",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-router": "^6.4.2",
"react-router-dom": "^6.4.2",
"react-scripts": "4.0.3",
"react-vega": "^7.6.0",
"typescript": "^4.1.2",
"vega": "^5.22.1",
"vega-datasets": "^2.5.4",
"vega-embed": "^6.21.3",
"vega-expression": "^5.0.0",
"vega-lite": "^5.6.1",
"vega-themes": "^2.12.1"
},
"scripts": {
"start": "REACT_APP_DISABLE_LIVE_RELOAD=true react-scripts start",
"trad-start": "react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN='true' react-scripts build && npm run prep-data-prod && npm run cp-quiets && npm run cp-docs",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src",
"cp-quiets": "cp src/examples/Quiet* ./public/",
"cp-docs": "cp README.md ./public/",
"prep-data-prod": "rm -rf build/data && mkdir build/data && cp node_modules/vega-datasets/data/* ./build/data/",
"prep-data": "rm -rf public/data && mkdir public/data && cp node_modules/vega-datasets/data/* ./public/data/"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
"name": "prong",
"private": true,
"scripts": {
"start:docs": "cd sites/docs && yarn dev",
"start:prong": "cd packages/prong && yarn dev",
"start": "run-p start:docs start:prong"
},
"devDependencies": {
"lerna": "^4.0.0",
"npm-run-all": "^4.1.5"
},
"workspaces": {
"packages": [
"packages/*",
"sites/*"
]
}
}
46 changes: 46 additions & 0 deletions packages/prong/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint-env node */

module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:react-hooks/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: true,
tsconfigRootDir: __dirname,
},
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-unsafe-argument": 0,
"@typescript-eslint/no-unsafe-assignment": 0,
"@typescript-eslint/no-unsafe-member-access": 0,
"@typescript-eslint/no-unsafe-return": 0,
"@typescript-eslint/no-non-null-asserted-optional-chain": 0,
"react-refresh/only-export-components": 0,
"no-unused-vars": "off",
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-unused-vars": [
"warn", // or "error"
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
},
};
24 changes: 24 additions & 0 deletions packages/prong/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
15 changes: 15 additions & 0 deletions packages/prong/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#333333" />
<meta name="description" content="Discount projectional json editors" />
<title>Prong</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions packages/prong/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
70 changes: 70 additions & 0 deletions packages/prong/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "prong",
"version": "0.0.0",
"scripts": {
"dev": " vite build --watch --config vite.config.ts",
"build": "tsc && vite build",
"preview": "vite preview",
"test": "jest",
"prepack": "json -f package.json -I -e \"delete this.devDependencies; delete this.dependencies\"",
"lint": "eslint src/"
},
"dependencies": {
"@codemirror/commands": "^6.1.2",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lint": "^6.1.0",
"@codemirror/view": "^6.7.0",
"@json-schema-tools/traverse": "^1.10.1",
"@lezer/common": "^1.0.2",
"@lezer/json": "^1.0.0",
"codemirror": "^6.0.1",
"jsonc-parser": "^3.0.0",
"lodash.isequal": "^4.5.0",
"react": "^17.0.2",
"react-colorful": "^5.6.1",
"react-dom": "^17.0.2",
"react-markdown": "^7.1.0"
},
"devDependencies": {
"@babel/core": "^7.16.12",
"@jest/globals": "^29.6.1",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/d3": "^7.4.0",
"@types/jest": "^29.5.2",
"@types/json-schema": "^7.0.11",
"@types/lodash.isequal": "^4.5.5",
"@types/node": "^20.4.0",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"@vitejs/plugin-react": "^1.1.4",
"acorn-jsx": "^5.3.2",
"babel-loader": "^8.2.3",
"jest": "^29.6.1",
"json": "^11.0.0",
"ts-jest": "^29.1.1",
"typescript": "^4.5.5",
"vite": "^2.7.13",
"vite-jest": "^0.1.4",
"vite-plugin-dts": "^0.9.9"
},
"license": "UNLICENSED",
"peerDependencies": {
"react": "^16.8.0 || 17.x",
"react-dom": "^16.8.0 || 17.x"
},
"files": [
"dist"
],
"main": "./dist/prong.umd.js",
"module": "./dist/prong.es.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/prong.es.js",
"require": "./dist/prong.umd.js"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import { useEffect, useRef, useState } from "react";

import { json } from "@codemirror/lang-json";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import React from "react";
import { Component } from "react";

type Props = Record<string, any>;
interface State {
hasError: boolean;
}

export default class ErrorBoundary extends React.Component<Props, State> {
export default class ErrorBoundary extends Component<Props, State> {
constructor(props: any) {
super(props);
this.state = { hasError: false };
}

static getDerivedStateFromError(error: any) {
static getDerivedStateFromError() {
// Update state so the next render will show the fallback UI.
return { hasError: true };
}

componentDidCatch(error: any, errorInfo: any) {
componentDidCatch(error: any, _errorInfo: any) {
console.error(error);
// You can also log the error to an error reporting service
// logErrorToMyService(error, errorInfo);
Expand Down
6 changes: 6 additions & 0 deletions packages/prong/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { default as Editor } from "./components/Editor";
export { default as StandardBundle } from "./projections/standard-bundle";
export * as utils from "./lib/utils";
export { default as prettifier } from "./lib/vendored/prettifier";

export { type Projection, type ProjectionProps } from "./lib/projections";
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { generateMenuContent } from "./compute-menu-contents";
import { findNodeByText } from "./test-utils";
import { createNodeMap } from "./utils";
import { vegaCode } from "../examples/example-data";
import VegaSchema from "../constants/vega-schema.json";
import { vegaCode } from "../../../../sites/docs/src/examples/example-data";
import { materializeAnyOfOption } from "./menu-content/schema-based";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const VegaSchema = require("../../../../sites/docs/src/constants/vega-schema.json");
const schema = {
$id: "https://example.com/arrays.schema.json",
$schema: "https://json-schema.org/draft/2020-12/schema",
Expand Down Expand Up @@ -63,11 +63,11 @@ test("generateMenuContent - fruit", async () => {
});

test("generateMenuContent - vega", async () => {
const targ = findNodeByText(vegaCode, `"transform"`)!.parent?.lastChild
const target = findNodeByText(vegaCode, `"transform"`)!.parent?.lastChild
?.firstChild?.nextSibling!;
const nodeMap = await createNodeMap(VegaSchema, vegaCode);
// expect(nodeMap).toMatchSnapshot();
const menuContent = generateMenuContent(targ, nodeMap, vegaCode);
const menuContent = generateMenuContent(target, nodeMap, vegaCode);
expect(menuContent).toMatchSnapshot();
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { filterContents } from "./search";
import { findNodeByText } from "./test-utils";
import { generateMenuContent } from "./compute-menu-contents";
import VegaLiteV5Schema from "../constants/vega-lite-v5-schema.json";
import VegaLiteV5Schema from "../../../../sites/docs/src/constants/vega-lite-v5-schema.json";
import { createNodeMap } from "./utils";
const updatedSchema = {
...VegaLiteV5Schema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setIn, syntaxNodeToKeyPath, syntaxNodeToAbsPath } from "./utils";
import { vegaCode } from "../examples/example-data";
import { vegaCode } from "../../../../sites/docs/src/examples/example-data";
import { findNodeByText } from "./test-utils";
const exampleData = `{
"a": {
Expand Down
Loading

0 comments on commit ce79e03

Please sign in to comment.