-
Notifications
You must be signed in to change notification settings - Fork 5
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 + getMetadata.ts + manifest.json #145
base: main
Are you sure you want to change the base?
Changes from all commits
2783fe3
7df1a2c
944a741
a5c1290
f158bb8
14ddaf4
ec2d358
e8d6227
0816599
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-eth": patch | ||
--- | ||
|
||
templates: added template for tsconfig.json file |
This file was deleted.
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 | ||
...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,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, | ||
|
@@ -14,7 +17,7 @@ export const getMetadata = ({ | |
description: string; | ||
imageRelativePath?: string; | ||
}): Metadata => { | ||
const imageUrl = `${baseUrl}${imageRelativePath}`; | ||
const imageUrl = \`\${baseUrl}\${imageRelativePath}\`; | ||
|
||
return { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh yeah makes sense, my bad. Can we have an corresponding args.mjs file for this file? I don't see it in https://github.com/portdeveloper/manifest-test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. export const titleTemplate = "%s | My PWA App"
export const extraIcons = {
shortcut: "/favicon.ico",
apple: [{ url: "/icons/apple-touch-icon.png", sizes: "180x180" }]
}
export const extraMetadata = {
applicationName: 'title',
manifest: "/manifest.json",
appleWebApp: {
capable: true,
statusBarStyle: "default",
title: 'title'
},
formatDetection: {
telephone: false
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/portdeveloper/test-everything Here is a repo with all the changed files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If I understand it right you can theoretically do (writing it without trying)
but since that part is always the same I think it's ok that it already stringifyed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
metadataBase: new URL(baseUrl), | ||
|
@@ -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 ') : ''} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have you tried There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not work since there is no object there, the "..." just gets transferred to the created file |
||
}, | ||
${extraMetadata[0] ? Object.entries(extraMetadata[0]).map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(',\n ') : ''} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here but with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}; | ||
}; | ||
` | ||
|
||
export default withDefaults(contents, { | ||
titleTemplate: '', | ||
extraIcons: {}, | ||
extraMetadata: {} | ||
}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh yeah makes sense! So people need to pas
export const iconPath = ''
to omit that field.What if people forgot to add
export const iconPath = ''
but also haveicons
in their template, will it still work as expected?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/portdeveloper/test-everything
yes i tested it with this extension which has all the args mjs files for the changed files in this PR