Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
willybrauner committed Feb 6, 2024
1 parent aa80e33 commit adfe4ca
Show file tree
Hide file tree
Showing 46 changed files with 187 additions and 186 deletions.
2 changes: 1 addition & 1 deletion apps/front/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ return new Promise((resolve) => {
// duplicate route with lang if the router is configured on this way
"/fr",
"/fr/work",
"/fr/work/first-work",
"/fr/work/first-work"
])
})
```
Expand Down
4 changes: 2 additions & 2 deletions apps/front/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export default {

// Build htaccess
htaccessTemplateFilePath: resolve(
"config/tasks/build-htaccess/templates/.htaccess.template",
),
"config/tasks/build-htaccess/templates/.htaccess.template"
)
}
14 changes: 7 additions & 7 deletions apps/front/config/tasks/build-htaccess/build-htaccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const _createHtaccessFile = async ({ outputPath, htaccessTemplatePath }) => {
if (!templateExist) {
console.log(
"htaccess template doesn't exit. You need to create manually the template file in",
htaccessTemplatePath,
htaccessTemplatePath
)
return
}
Expand All @@ -39,7 +39,7 @@ const _createHtpasswdFile = async ({ outputPath, user, password }) => {
log("create htpasswd file", {
outputPath,
user,
password,
password
})

if (!outputPath || !user || !password) {
Expand Down Expand Up @@ -74,7 +74,7 @@ const _htpasswdLinkInHtaccess = async ({ newHtaccessFilePath, serverWebRootPath
AuthType Basic
AuthName "Restricted Area"
Require valid-user
`,
`
]
.join("\n")
.replace(/ +/g, "")
Expand All @@ -90,14 +90,14 @@ const _htpasswdLinkInHtaccess = async ({ newHtaccessFilePath, serverWebRootPath
*/
const _rewriteHttpToHttpsInHtaccess = async (newHtaccessFilePath) => {
debug("rewrite http to https in htaccess", {
newHtaccessFilePath,
newHtaccessFilePath
})

const template = [
`# Force http to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
`,
`
]
.join("\n")
.replace(/ +/g, "")
Expand All @@ -115,12 +115,12 @@ export default async ({
user,
password,
outputPath,
htaccessTemplatePath,
htaccessTemplatePath
}) => {
// create htaccess file and get returned newHtaccessFilePath
const newHtaccessFilePath = await _createHtaccessFile({
outputPath,
htaccessTemplatePath,
htaccessTemplatePath
})

if (!newHtaccessFilePath) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const viteChersiteCustomLogger = ({
protocol,
host,
port,
base,
base
}: {
protocol: "http" | "https"
host: string
Expand Down
4 changes: 2 additions & 2 deletions apps/front/config/vite-plugins/vite-plugin-build-dotenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import buildDotenv from "../tasks/build-dotenv/build-dotenv"
export default function buildDotenvPlugin({
envVars = process.env,
dotenvOutDir,
additionalVarKeys,
additionalVarKeys
}: {
envVars: { [x: string]: any }
dotenvOutDir: string[]
Expand All @@ -14,6 +14,6 @@ export default function buildDotenvPlugin({
name: "vite-plugin-dotenv",
buildStart: async () => {
await buildDotenv({ envVars, dotenvOutDir, additionalVarKeys })
},
}
}
}
6 changes: 3 additions & 3 deletions apps/front/config/vite-plugins/vite-plugin-build-htaccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function buildHtaccessPlugin({
serverWebRootPath,
htaccessTemplatePath,
outputPath,
enable,
enable
}: {
user: string | undefined
password: string | undefined
Expand All @@ -29,8 +29,8 @@ export default function buildHtaccessPlugin({
serverWebRootPath,
password,
htaccessTemplatePath,
outputPath,
outputPath
})
},
}
}
}
2 changes: 1 addition & 1 deletion apps/front/config/vite-plugins/vite-plugin-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export default function htmlPlugin(env) {
name: "html-transform",
transformIndexHtml(html) {
return html.replace(/<!-- VITE_APP_URL -->/gm, `${env.VITE_APP_URL}`)
},
}
}
}
2 changes: 1 addition & 1 deletion apps/front/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
4 changes: 2 additions & 2 deletions apps/front/prerender/__tests__/ManifestParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const url = import.meta.url

const manifestRaw = fs.readFileSync(
path.join(path.dirname(fileURLToPath(url)), `fixtures/manifest.json`),
{ encoding: "utf8" },
{ encoding: "utf8" }
)

it("should return assets list", () => {
Expand All @@ -23,7 +23,7 @@ it("should return a list of assets by type", () => {

extensions.forEach((e) => {
expect(
assetsByType[e].every((f) => f.split(".")[f.split(".").length - 1] === e),
assetsByType[e].every((f) => f.split(".")[f.split(".").length - 1] === e)
).toBe(true)
})
})
Expand Down
6 changes: 3 additions & 3 deletions apps/front/prerender/exe-prerender-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ app.get("/generate", async (req, res) => {
app.listen(port, () => {
console.log("")
console.log(
`> Generate all pages ${chalk.blue(`http://localhost:${port}/generate`)}`,
`> Generate all pages ${chalk.blue(`http://localhost:${port}/generate`)}`
)
console.log(
`> Generate specific page ${chalk.blue(
`http://localhost:${port}/generate?url=/my-page/url`,
)}`,
`http://localhost:${port}/generate?url=/my-page/url`
)}`
)
})
6 changes: 3 additions & 3 deletions apps/front/prerender/helpers/ManifestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class ManifestParser {
} else {
return {
...a,
[ext]: [b],
[ext]: [b]
}
}
}, {})
Expand Down Expand Up @@ -157,10 +157,10 @@ export class ManifestParser {
...a,
jsonManifest[b].file,
...(jsonManifest[b]?.assets || []),
...(jsonManifest[b]?.css || []),
...(jsonManifest[b]?.css || [])
]
: a,
[],
[]
)
.filter((e) => e)

Expand Down
4 changes: 2 additions & 2 deletions apps/front/prerender/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const prerender = async (urls: string[], outDirStatic = config.outDirStat
},
onError(x) {
console.error(x)
},
}
})
} catch (e) {
console.log(e)
Expand All @@ -63,7 +63,7 @@ const createHtmlFile = async (
urls: string[],
url: string,
outDir: string,
dom: ReactElement<any, string | JSXElementConstructor<any>>,
dom: ReactElement<any, string | JSXElementConstructor<any>>
): Promise<void> => {
// Prepare file
if (isRouteIndex(url, urls)) url = `${url}/index`
Expand Down
14 changes: 7 additions & 7 deletions apps/front/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const isSSL = protocol === "https"
if (isSSL) {
if (!(await mfs.fileExists("key.pem")) || !(await mfs.fileExists("cert.pem"))) {
console.error(
"You need to generate a key and a cert file with openssl in the apps/front/ directory. Follow the README documentation 'setup-local-ssl'.",
"You need to generate a key and a cert file with openssl in the apps/front/ directory. Follow the README documentation 'setup-local-ssl'."
)
process.exit(1)
}
Expand All @@ -39,7 +39,7 @@ const isSSL = protocol === "https"

// dev script to inject
const devScripts = {
js: [{ tag: "script", attr: { type: "module", src: "/src/index.tsx" } }],
js: [{ tag: "script", attr: { type: "module", src: "/src/index.tsx" } }]
}

// Create Vite server in middleware mode.
Expand All @@ -54,9 +54,9 @@ const isSSL = protocol === "https"
// },
middlewareMode: true,
https: (isSSL && { key, cert }) || false,
cors: false,
cors: false
},
appType: "custom",
appType: "custom"
})

// use vite's connect instance as middleware
Expand All @@ -65,7 +65,7 @@ const isSSL = protocol === "https"
try {
// Transforms the ESM source code to be usable in Node.js
const { render } = await vite.ssrLoadModule(
`${config.srcDir}/server/index-server.tsx`,
`${config.srcDir}/server/index-server.tsx`
)
// Get react-dom from the render method
const dom = await render(req.originalUrl, devScripts, false)
Expand All @@ -79,7 +79,7 @@ const isSSL = protocol === "https"
onError(e) {
res.statusCode = 500
console.error(e)
},
}
})
} catch (e) {
vite.ssrFixStacktrace(e)
Expand Down Expand Up @@ -111,6 +111,6 @@ const isSSL = protocol === "https"
* Let's go!
*/
;(isProduction ? createProdServer : createDevServer)().then(({ app, sslServer }) =>
(sslServer ?? app).listen(port),
(sslServer ?? app).listen(port)
)
})()
2 changes: 1 addition & 1 deletion apps/front/src/components/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function App(props: IProps) {
const manageTransitions = async ({
previousPage,
currentPage,
unmountPreviousPage,
unmountPreviousPage
}: TManageTransitions): Promise<void> => {
const $current = currentPage?.$element

Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/components/baseButton/BaseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function BaseButton(props: IProps, ref: MutableRefObject<any>) {
css.root,
props.className,
css[`root_${props.type}`],
css[`root_${props.tag}`],
css[`root_${props.tag}`]
)

/**
Expand Down
24 changes: 12 additions & 12 deletions apps/front/src/components/cookiesBanner/CookiesBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const log = debug(`front:${componentName}`)

export enum ETrackingType {
GOOGLE_ANALYTICS,
GOOGLE_TAG_MANAGER,
GOOGLE_TAG_MANAGER
}

export interface ITracking {
Expand Down Expand Up @@ -45,7 +45,7 @@ CookiesBanner.defaultProps = {
showPolicyText: "Show our policy",
showPolicyLink: "https://cher-ami.tv",
labelButtonAccept: "yes",
labelButtonRefuse: "no",
labelButtonRefuse: "no"
}

/**
Expand Down Expand Up @@ -104,15 +104,15 @@ export function CookiesBanner(props: IProps) {
// targets script DOM by ids
const $gTagManagerScript = document.getElementById("__gaTagManagerScript")
const $gTagManagerDataLayerScript = document.getElementById(
"__gTagManagerDataLayerScript",
"__gTagManagerDataLayerScript"
)
const $gTagManagerNoScript = document.getElementById("__gaTagManagerNoScript")

// if injection script tags is enable
if (injectScriptTags) {
if ($gTagManagerScript || $gTagManagerDataLayerScript || $gTagManagerNoScript) {
log(
"$gTagManagerNoScript or $gTagManagerNoScript already exist in DOM, NOT create new scripts. return. ",
"$gTagManagerNoScript or $gTagManagerNoScript already exist in DOM, NOT create new scripts. return. "
)
return
}
Expand All @@ -130,8 +130,8 @@ export function CookiesBanner(props: IProps) {
$gTagManagerNoScript,
// auto generated when script is injected in DOM, we remove it too.
document.querySelector(
`script[src="https://www.googletagmanager.com/gtm.js?id=${trackingID}"]`,
),
`script[src="https://www.googletagmanager.com/gtm.js?id=${trackingID}"]`
)
]

log("remove script tags from DOM.")
Expand All @@ -147,7 +147,7 @@ export function CookiesBanner(props: IProps) {
*/
const googleAnalyticsInjection = (
injectScriptTags: boolean,
trackingID: string,
trackingID: string
): void => {
if (!trackingID) return

Expand All @@ -168,7 +168,7 @@ export function CookiesBanner(props: IProps) {
`window.dataLayer = window.dataLayer || [];`,
`function gtag(){dataLayer.push(arguments);}`,
`gtag('js', new Date());`,
`gtag('config', '${trackingID}');`,
`gtag('config', '${trackingID}');`
].join("\n")
// add ID
trackingScript.setAttribute("id", "__ga_tracking")
Expand Down Expand Up @@ -196,8 +196,8 @@ export function CookiesBanner(props: IProps) {
$tracking,
// auto generated when script is injected in DOM, we remove it too.
document.querySelector(
'script[src$="https://www.google-analytics.com/analytics.js"]',
),
'script[src$="https://www.google-analytics.com/analytics.js"]'
)
]

log("remove script tags from DOM.")
Expand Down Expand Up @@ -278,7 +278,7 @@ export function CookiesBanner(props: IProps) {
show: boolean = true,
el = rootRef?.current as HTMLElement,
modifier = css.root_show,
modifierHide = css.root_hide,
modifierHide = css.root_hide
): void => {
if (show) {
el?.classList?.add(modifier)
Expand Down Expand Up @@ -317,7 +317,7 @@ export function CookiesBanner(props: IProps) {
} else {
log(
"init > localStorageChoiceExist() doesnt exist, anim show component",
localStorageChoiceExist(),
localStorageChoiceExist()
)
// add show class
CookiesBannerService.show()
Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/components/lazyImage/LazyImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function LazyImage(props: IProps) {
alt={props?.alt}
style={{
...(props.aspectRatio ? { aspectRatio: `${props.aspectRatio}` } : {}),
...(props.style || {}),
...(props.style || {})
}}
/>
)
Expand Down
Loading

0 comments on commit adfe4ca

Please sign in to comment.