Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template for tsconfig.json #145

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/soft-shrimps-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-eth": patch
---

templates: added template for tsconfig.json file
5 changes: 0 additions & 5 deletions templates/base/packages/nextjs/public/manifest.json

This file was deleted.

15 changes: 15 additions & 0 deletions templates/base/packages/nextjs/public/manifest.json.template.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { stringify, withDefaults } from '../../../../utils.js'

const contents = ({ name, description, iconPath, extraContent }) => stringify({
name: name[0],
description: description[0],
...(iconPath[0] && { iconPath: iconPath[0] }), // Only include iconPath if it's provided
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If extension developer doesn't pass the iconPath it will default to "logo.svg" right? So we don't need this check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of icon, we are gonna have icons, like the example below:
https://github.com/serwist/serwist/blob/main/examples/next-web-push/public/manifest.json
So, we don't need the icon if the dev does not provide it.

...extraContent[0]
})

export default withDefaults(contents, {
name: "Scaffold-ETH 2 DApp",
description: "A DApp built with Scaffold-ETH",
iconPath: "logo.svg",
extraContent: []
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
import { stringify, withDefaults } from '../../../utils.js'

const contents = ({ extraPlugins, extraCompilerOptions }) => `${stringify({
"compilerOptions": {
"target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"],
Expand All @@ -20,9 +22,23 @@
"plugins": [
{
"name": "next"
}
]
},
...extraPlugins[0]
],
...extraCompilerOptions[0]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
})}`

export default withDefaults(contents, {
extraPlugins: [],
extraCompilerOptions: {}
})
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { stringify, withDefaults } from '../../../../../utils.js'

const contents = ({ titleTemplate, extraIcons, extraMetadata }) => `
import type { Metadata } from "next";

const baseUrl = process.env.VERCEL_PROJECT_PRODUCTION_URL
? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}`
: `http://localhost:${process.env.PORT || 3000}`;
const titleTemplate = "%s | Scaffold-ETH 2";
? \`https://\${process.env.VERCEL_PROJECT_PRODUCTION_URL}\`
: \`http://localhost:\${process.env.PORT || 3000}\`;
const titleTemplate = "${titleTemplate[0] || '%s | Scaffold-ETH 2'}";

export const getMetadata = ({
title,
Expand All @@ -14,7 +17,7 @@ export const getMetadata = ({
description: string;
imageRelativePath?: string;
}): Metadata => {
const imageUrl = `${baseUrl}${imageRelativePath}`;
const imageUrl = \`\${baseUrl}\${imageRelativePath}\`;

return {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't understand how to templatize getMetadata.ts

I think we can wrap this whole object inside the${stringify({...})} then inside you can extraMetadata ?

Screenshot 2024-11-04 at 9 14 08 PM

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgive me if i get this wrong but then it cannot read baseUrl (If we stringify the return)
image

metadataBase: new URL(baseUrl),
Expand Down Expand Up @@ -45,6 +48,15 @@ export const getMetadata = ({
},
icons: {
icon: [{ url: "/favicon.png", sizes: "32x32", type: "image/png" }],
${extraIcons[0] ? Object.entries(extraIcons[0]).map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(',\n ') : ''}
},
${extraMetadata[0] ? Object.entries(extraMetadata[0]).map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(',\n ') : ''}
};
};
`

export default withDefaults(contents, {
titleTemplate: '',
extraIcons: {},
extraMetadata: {}
})
Loading