Skip to content

Commit

Permalink
feat: adds react example template
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarenaldi committed Jan 8, 2025
1 parent f03d4f1 commit 2b91a91
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 88 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pnpm clean
Create a new package:

```bash
pnpm new:lib
pnpm new:package
```

### IDE Setup <!-- omit in toc -->
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}
},
{
"include": ["./examples/**/*.ts"],
"include": ["./examples/**/*.ts", "./examples/**/*.tsx"],
"linter": {
"rules": {
"style": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"clean": "rimraf packages/*/dist",
"lint": "biome check",
"lint:fix": "biome check --write",
"new:lib": "NODE_OPTIONS='--import tsx' plop --plopfile=plopfile.ts",
"new:package": "NODE_OPTIONS='--import tsx' plop --plopfile=plopfile.ts",
"prepublish": "pnpm run build",
"test:client": "vitest --project @lens-protocol/client --no-file-parallelism",
"test:react": "vitest --project @lens-protocol/react --no-file-parallelism",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"msw": "^2.7.0",
"tsup": "^8.3.5",
"typescript": "^5.6.3",
"viem": "^2.21.53",
"viem": "^2.22.4",
"zksync-ethers": "^6.15.3",
"zod": "^3.23.8"
},
Expand Down
5 changes: 1 addition & 4 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"react-dom": "^18.3.1",
"tsup": "^8.3.5",
"typescript": "^5.6.3",
"viem": "^2.21.33"
"viem": "^2.22.4"
},
"peerDependencies": {
"@types/react": "^18.3.12",
Expand All @@ -55,9 +55,6 @@
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"wagmi": {
"optional": true
}
},
"license": "MIT"
Expand Down
17 changes: 13 additions & 4 deletions plopfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import type { NodePlopAPI } from 'plop';

export default function (plop: NodePlopAPI) {
plop.setGenerator('lib', {
description: 'Generate a new library package',
description: 'Generate a new package',
prompts: [
{
type: 'list',
name: 'template',
message: 'Choose a template:',
choices: [
{ name: 'Library', value: { name: 'lib', dest: 'packages' } },
{ name: 'React Example', value: { name: 'example-react', dest: 'examples' } },
],
},
{
type: 'input',
name: 'name',
Expand All @@ -18,9 +27,9 @@ export default function (plop: NodePlopAPI) {
actions: [
{
type: 'addMany',
destination: 'packages/{{name}}',
base: 'templates/lib/',
templateFiles: 'templates/lib/**',
destination: '{{template.dest}}/{{name}}',
base: 'templates/{{template.name}}/',
templateFiles: 'templates/{{template.name}}/**',
},
],
});
Expand Down
100 changes: 24 additions & 76 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packages:
- "packages/*"
- '!examples/*'
3 changes: 3 additions & 0 deletions templates/example-react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{description}}

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/lens-protocol/lens-sdk/tree/next/examples/{{name}})
13 changes: 13 additions & 0 deletions templates/example-react/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/lens.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css">
<title>{{description}}</title>
</head>
<body id="root">
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions templates/example-react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "{{name}}",
"description": "{{description}}",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite"
},
"dependencies": {
"@lens-protocol/react": "file:../../packages/react",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react-swc": "^3.7.2",
"typescript": "^5.6.3",
"vite": "^5.4.9"
}
}
19 changes: 19 additions & 0 deletions templates/example-react/public/lens.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b91a91

Please sign in to comment.