Skip to content

Commit

Permalink
Merge a20f66a into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 21, 2024
2 parents 78f95d3 + a20f66a commit f77e9e0
Show file tree
Hide file tree
Showing 93 changed files with 2,071 additions and 1,451 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

57 changes: 0 additions & 57 deletions .eslintrc.json

This file was deleted.

File renamed without changes.
26 changes: 0 additions & 26 deletions apps/decap/.eslintignore

This file was deleted.

25 changes: 0 additions & 25 deletions apps/decap/.eslintrc.json

This file was deleted.

15 changes: 15 additions & 0 deletions apps/decap/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig, frontend } from '@custom/eslint-config';

export default defineConfig([
...frontend,
{
ignores: [
'build/**',
'dist/**',
'node_modules/**',
'storybook-static/**',
'static/stories/webforms/**',
'vite.config.ts.**',
],
},
]);
8 changes: 4 additions & 4 deletions apps/decap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"prep:vite": "vite build",
"prep:scripts": "tsup",
"start": "GIT_REPO_DIRECTORY=../../ pnpm netlify-cms-proxy-server",
"test:static": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.eslintignore\"",
"test:static": "tsc --noEmit && eslint . --quiet",
"test:unit": "vitest run --passWithNoTests"
},
"peerDependencies": {
Expand Down Expand Up @@ -36,15 +36,15 @@
},
"devDependencies": {
"@amazeelabs/decap-cms-backend-token-auth": "^1.2.1",
"@custom/eslint-config": "workspace:*",
"@types/node": "^18",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"netlify-cms-proxy-server": "^1.3.24",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vite": "^5.0.10"
"vite": "^5.0.10",
"vitest": "^1.1.1"
}
}
1 change: 1 addition & 0 deletions apps/decap/src/collections/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export const getPages: SilverbackSource<DecapPageSource> = () => {
.forEach((file) => {
const content = yaml.parse(fs.readFileSync(`${dir}/${file}`, 'utf-8'));
const id = Object.values(content)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map((page: any) => page.id)
.filter((id) => !!id)
.pop();
Expand Down
5 changes: 4 additions & 1 deletion apps/decap/src/helpers/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const responsiveImage: GraphQLFieldResolver<

export async function query<TOperation extends AnyOperationId>(
operation: TOperation,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
rootValue: any,
variables: OperationVariables<TOperation> = {},
getAssetUrl: (path: string) => string,
Expand Down Expand Up @@ -86,6 +87,7 @@ export async function query<TOperation extends AnyOperationId>(

export function useQuery<TOperation extends AnyOperationId>(
operation: TOperation,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
rootValue: any,
variables: OperationVariables<TOperation> = {},
getAssetUrl: (path: string) => string,
Expand Down Expand Up @@ -116,6 +118,7 @@ export type useQueryType = typeof useQuery;

export function createPreview<TOperation extends AnyOperationId>(
query: TOperation,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
schema: ZodType<any, ZodTypeDef, unknown>,
Component: React.FC<{
preview: Exclude<OperationResult<TOperation>['preview'], undefined>;
Expand Down Expand Up @@ -151,7 +154,7 @@ export function createPreview<TOperation extends AnyOperationId>(
{data?.preview ? (
<Component preview={data.preview} />
) : (
<div className="flex flex-col items-center mb-8 pt-12 pb-36">
<div className="mb-8 flex flex-col items-center pb-36 pt-12">
<p>Loading...</p>
<p>Please make sure all required fields are filled.</p>
</div>
Expand Down
5 changes: 2 additions & 3 deletions apps/decap/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@custom/schema';
import { Page } from '@custom/ui/routes/Page';
import CMS from 'decap-cms-app';
import { InitOptions } from 'decap-cms-core';
import { CmsBackendType, InitOptions } from 'decap-cms-core';

import css from '../node_modules/@custom/ui/build/styles.css?raw';
import { PageCollection, pageSchema } from './collections/page';
Expand Down Expand Up @@ -37,7 +37,6 @@ const cmsConfig: InitOptions = {
load_config_file: false,
publish_mode: 'editorial_workflow',
media_folder: 'apps/decap/media',
// @ts-ignore
backend: import.meta.env.DEV
? {
// In development, use the in-memory backend.
Expand All @@ -53,7 +52,7 @@ const cmsConfig: InitOptions = {
}
: {
// Otherwise, its production. Use the token auth backend.
name: 'token-auth',
name: 'token-auth' as CmsBackendType,
api_root: '/.netlify/functions/github-proxy',
repo: import.meta.env.VITE_DECAP_REPO,
branch: import.meta.env.VITE_DECAP_BRANCH,
Expand Down
25 changes: 0 additions & 25 deletions apps/preview/.eslintrc.json

This file was deleted.

8 changes: 8 additions & 0 deletions apps/preview/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig, frontend } from '@custom/eslint-config';

export default defineConfig([
...frontend,
{
ignores: ['build/**', 'dist/**', 'vite.config.ts.**'],
},
]);
8 changes: 2 additions & 6 deletions apps/preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"test:static": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.gitignore\"",
"test:static": "tsc --noEmit && eslint . --quiet",
"dev:app": "vite",
"dev:server": "tsx watch server/index.ts",
"prep:app": "vite build",
"prep:server": "swc ./server -d ./build",
"start": "node build/index.js"
},
"dependencies": {
"@custom/eslint-config": "workspace:*",
"@custom/schema": "workspace:*",
"@custom/ui": "workspace:*",
"cookie-parser": "^1.4.6",
Expand All @@ -37,12 +38,7 @@
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"@types/simple-oauth2": "^5.0.7",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"tsx": "^4.7.1",
"typescript": "^5.2.2",
"vite": "^5.2.0"
Expand Down
15 changes: 7 additions & 8 deletions apps/preview/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ app.get('/oauth/callback', async (req, res) => {
};

try {
// @ts-ignore options due to missing redirect_uri.
const accessToken = await client.getToken(options);
const accessToken = await client.getToken(
// @ts-expect-error Missing redirect_uri.
options,
);
console.log('/oauth/callback accessToken', accessToken);
persistAccessToken(accessToken, req);

Expand All @@ -127,12 +129,9 @@ app.get('/oauth/callback', async (req, res) => {
}
} catch (error) {
console.error(error);
return (
res
.status(500)
// @ts-ignore
.json(`Authentication failed with error: ${error.message}`)
);
return res
.status(500)
.json(`Authentication failed with error: ${error.message}`);
}
});

Expand Down
6 changes: 3 additions & 3 deletions apps/preview/server/utils/oAuth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const initializeSession = (server: Express): void => {
const sessionMaxAgeInMilliseconds = SESSION_MAX_AGE * 1000;
const MemoryStore = createMemoryStore(session);

const config = {
const config: Parameters<typeof session>[0] = {
secret:
oAuth2Config.sessionSecret || crypto.randomBytes(64).toString('hex'),
resave: true, // seems to be needed for MemoryStore
Expand All @@ -106,7 +106,6 @@ export const initializeSession = (server: Express): void => {

if (oAuth2Config.environmentType === 'production') {
server.set('trust proxy', 1); // trust first proxy
// @ts-ignore
config.cookie.secure = true; // serve secure cookies
}

Expand Down Expand Up @@ -172,6 +171,7 @@ const encrypt = (text: string): string => {
let encrypted = cipher.update(text);
encrypted = Buffer.concat([encrypted, cipher.final()]);
return iv.toString('hex') + ':' + encrypted.toString('hex');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
throw new Error('Encryption failed.');
}
Expand All @@ -184,7 +184,6 @@ const decrypt = (encryptedText: string): string => {

try {
const textParts = encryptedText.split(':');
// @ts-ignore
const iv = Buffer.from(textParts.shift(), 'hex');

const encryptedData = Buffer.from(textParts.join(':'), 'hex');
Expand All @@ -198,6 +197,7 @@ const decrypt = (encryptedText: string): string => {
const decrypted = decipher.update(encryptedData);
const decryptedText = Buffer.concat([decrypted, decipher.final()]);
return decryptedText.toString();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
throw new Error('Decryption failed.');
}
Expand Down
4 changes: 3 additions & 1 deletion apps/preview/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ declare global {
}
}

const updates$ = webSocket<any>({
type PreviewRefresh = Parameters<ReturnType<typeof usePreviewRefresh>>[0];

const updates$ = webSocket<PreviewRefresh>({
url: `${window.location.origin.replace('http', 'ws')}/__preview`,
}).pipe(
retry({
Expand Down
3 changes: 3 additions & 0 deletions apps/publisher/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { base, defineConfig } from '@custom/eslint-config';

export default defineConfig([...base]);
6 changes: 4 additions & 2 deletions apps/publisher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"@amazeelabs/publisher": "^2.5.5"
},
"scripts": {
"test:static": "tsc --noEmit && eslint '**/*.{ts,tsx,js,jsx}' --ignore-path='./.gitignore'",
"test:static": "tsc --noEmit && eslint . --quiet",
"dev": "cd ../website && pnpm clean && cd - && publisher",
"open": "open http://127.0.0.1:8000/___status/"
},
"devDependencies": {
"@types/node": "^18"
"@custom/eslint-config": "workspace:*",
"@types/node": "^18",
"typescript": "^5.3.3"
}
}
Loading

0 comments on commit f77e9e0

Please sign in to comment.