Skip to content

Commit

Permalink
chore: skeleton-react package cleanup (#2672)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 committed May 18, 2024
1 parent 210e923 commit 79415cc
Show file tree
Hide file tree
Showing 49 changed files with 2,007 additions and 1,745 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "pnpm -F @skeletonlabs/skeleton test",
"preinstall": "npx only-allow pnpm",
"postinstall": "pnpm -r sync",
"dev": "pnpm --no-sort --filter=skeleton.dev dev",
"dev": "pnpm --no-sort --filter=next.skeleton.dev dev",
"csa": "node ./packages/create-skeleton-app/src/index.js --types=typescript --prettier --eslint --playwright=false --vitest=false --codeblocks --popups --typography --forms -t=skeleton --skeletontemplate=welcome -p=sites --monorepo --inspector",
"csl": "node ./packages/create-skeleton-app/src/index.js --types=typescript --library --prettier --eslint --playwright --vitest --codeblocks --popups --typography --forms -t=skeleton --skeletontemplate=bare -p=packages --monorepo --inspector",
"templategen": "node ./scripts/template-gen.js",
Expand Down Expand Up @@ -53,7 +53,6 @@
"rimraf": "^5.0.5",
"shelljs": "^0.8.5"
},
"packageManager": "pnpm@8.14.0",
"engines": {
"pnpm": ">=8.14.0"
},
Expand Down
22 changes: 12 additions & 10 deletions packages/skeleton-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build": "vite build",
"package": "tsc --project tsconfig.package.json",
"package:watch": "tsc --project tsconfig.package.json --watch",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"test": "vitest run",
"test:watch": "vitest",
"schema": "node ./scripts/generator.js"
},
"publishConfig": {
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
Expand All @@ -25,25 +26,26 @@
"./dist/index.d.ts"
]
}
},
"registry": "http://localhost:4873"
}
},
"types": "./src/lib/index.ts",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./src/lib/index.ts",
"default": "./src/lib/index.ts"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./*": "./src/lib/*"
"./schemas": "./src/lib/schemas.ts"
},
"files": [
"./dist/**/*.js",
"./dist/**/*.map",
"./dist/**/*.tsx",
"./dist/**/*.d.ts",
"./dist/**/*.cjs",
"./dist/**/*.d.cts",
"!./dist/**/*.test.*"
"!./dist/**/*.test.*",
"!./dist/**/schema.json",
"!./dist/schemas.js",
"!./dist/schemas.d.ts"
],
"dependencies": {
"react": "^18.2.0",
Expand Down
56 changes: 29 additions & 27 deletions packages/skeleton-react/scripts/generator.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
import { promises as fs } from "fs";
import { execSync } from 'node:child_process';
import { execSync } from "node:child_process";

const config = {
dirPath: 'src/components',
inputFileName: 'types.ts',
outputFileName: 'schema.json',
dirPath: "src/lib/components",
inputFileName: "types.ts",
outputFileName: "schema.json",
};

async function init() {
const list = await fs.readdir(config.dirPath, { recursive: true });
list.forEach(async (file) => {
// Exclude all but types.ts files
if (!file.includes(config.inputFileName)) return;

// The full path with filename and extension
const filePath = `${config.dirPath}/${file}`;

// The path containing the types file
const locationPath = filePath.replace(config.inputFileName, "");

// DEBUG: Limit to Accordion Only ---------
// if (!file.includes("Accordion")) return;
// ----------------------------------------

// Execute Generator
// https://github.com/YousefED/typescript-json-schema?tab=readme-ov-file
execSync(`typescript-json-schema --propOrder=true --esModuleInterop --required=true '${filePath}' '*' --out '${locationPath}/${config.outputFileName}'`);

// Log
console.log('Schema generated for', filePath);
});
const list = await fs.readdir(config.dirPath, { recursive: true });
list.forEach(async (file) => {
// Exclude all but types.ts files
if (!file.includes(config.inputFileName)) return;

// The full path with filename and extension
const filePath = `${config.dirPath}/${file}`;

// The path containing the types file
const locationPath = filePath.replace(config.inputFileName, "");

// DEBUG: Limit to Accordion Only ---------
// if (!file.includes("Accordion")) return;
// ----------------------------------------

// Execute Generator
// https://github.com/YousefED/typescript-json-schema?tab=readme-ov-file
execSync(
`typescript-json-schema --propOrder=true --esModuleInterop --required=true '${filePath}' '*' --out '${locationPath}/${config.outputFileName}'`
);

// Log
console.log("Schema generated for", filePath);
});
}

init();
init();
10 changes: 5 additions & 5 deletions packages/skeleton-react/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { describe, expect, it } from "vitest";
import { render } from "@testing-library/react";
import App from "./App";
import App from "./App.js";

describe("App", () => {
it("renders the component", () => {
const { getByTestId } = render(<App />);
expect(getByTestId("app")).toBeInTheDocument();
});
it("renders the component", () => {
const { getByTestId } = render(<App />);
expect(getByTestId("app")).toBeInTheDocument();
});
});
96 changes: 48 additions & 48 deletions packages/skeleton-react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import { Suspense } from "react";
import { RouterProvider } from "react-router-dom";
import { router } from "./router";
import { router } from "./router.js";

function App() {
return (
<div
className="h-screen grid grid-cols-[320px_minmax(0,_1fr)]"
data-testid="app"
>
{/* Nav */}
<div className="bg-surface-100-900 p-8 overflow-y-auto space-y-8">
<a
className="bg-blue-500 text-white p-2 type-scale-3 font-bold font-mono"
href="/"
>
skeleton-react
</a>
<hr className="hr" />
{/* Components */}
<div className="space-y-8">
<span className="font-bold">Components</span>
<nav className="flex flex-col gap-2 type-scale-2">
{/* <a className="anchor" href="/components/test">
return (
<div
className="h-screen grid grid-cols-[320px_minmax(0,_1fr)]"
data-testid="app"
>
{/* Nav */}
<div className="bg-surface-100-900 p-8 overflow-y-auto space-y-8">
<a
className="bg-blue-500 text-white p-2 type-scale-3 font-bold font-mono"
href="/"
>
skeleton-react
</a>
<hr className="hr" />
{/* Components */}
<div className="space-y-8">
<span className="font-bold">Components</span>
<nav className="flex flex-col gap-2 type-scale-2">
{/* <a className="anchor" href="/components/test">
Test
</a> */}
<a className="anchor" href="/components/accordions">
Accordions
</a>
<a className="anchor" href="/components/avatars">
Avatars
</a>
<a className="anchor" href="/components/app-bars">
App Bars
</a>
<a className="anchor" href="/components/progress">
Progress
</a>
<a className="anchor" href="/components/tabs">
Tabs
</a>
</nav>
</div>
</div>
{/* Page */}
<main className="p-8 overflow-y-auto">
{/* --- Route Slot --- */}
<Suspense fallback={<div>Loading...</div>}>
<RouterProvider router={router} />
</Suspense>
{/* --- / --- */}
</main>
</div>
);
<a className="anchor" href="/components/accordions">
Accordions
</a>
<a className="anchor" href="/components/avatars">
Avatars
</a>
<a className="anchor" href="/components/app-bars">
App Bars
</a>
<a className="anchor" href="/components/progress">
Progress
</a>
<a className="anchor" href="/components/tabs">
Tabs
</a>
</nav>
</div>
</div>
{/* Page */}
<main className="p-8 overflow-y-auto">
{/* --- Route Slot --- */}
<Suspense fallback={<div>Loading...</div>}>
<RouterProvider router={router} />
</Suspense>
{/* --- / --- */}
</main>
</div>
);
}

export default App;

0 comments on commit 79415cc

Please sign in to comment.