Skip to content

Commit

Permalink
Add Knip (#2835)
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Obermair <[email protected]>
  • Loading branch information
manuelblum and johnnyomair authored Dec 18, 2024
1 parent 900b039 commit b8817b8
Show file tree
Hide file tree
Showing 183 changed files with 832 additions and 1,611 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-dots-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-api": patch
---

Add `BlocksBlockInputInterface` to the public API
5 changes: 5 additions & 0 deletions .changeset/four-forks-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/admin-date-time": patch
---

Add `DatePickerNavigationClassKey`, `DatePickerNavigationProps`, `DateTimePickerClassKey`, `FinalFormTimePickerProps`, `TimePickerClassKey`, and `TimeRangePickerClassKey` to the public API
5 changes: 5 additions & 0 deletions .changeset/khaki-zebras-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-site": patch
---

Add `AdminMessageType`, `IAdminContentScopeMessage`, `IAdminGraphQLApiUrlMessage`, `IAdminHoverComponentMessage`, `IAdminShowOnlyVisibleMessage`, `IFrameHoverComponentMessage`, `IFrameLocationMessage`, `IFrameMessage`, `IFrameMessageType`, `IFrameOpenLinkMessage`, `IFrameSelectComponentMessage`, and `IReadyIFrameMessage` to the public API
5 changes: 5 additions & 0 deletions .changeset/lucky-books-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/admin-color-picker": patch
---

Add `ColorPickerNoColorPreviewProps` to the public API
5 changes: 5 additions & 0 deletions .changeset/sharp-apes-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/admin": patch
---

Add `AppHeaderFillSpaceProps`, `ClearInputAdornmentClassKey`, `ToolbarActionButtonClassKey`, `ToolbarActionButton`, `CrudMoreActionsMenuClassKey`, `GridActionsColDef`, `GridBaseColDef`, `GridSingleSelectColDef`, and `TableDndOrderClassKey` to the public API
5 changes: 5 additions & 0 deletions .changeset/spicy-bottles-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-site": patch
---

Add `AdminMessageType`, `IAdminContentScopeMessage`, `IAdminGraphQLApiUrlMessage`, `IAdminHoverComponentMessage`, `IAdminShowOnlyVisibleMessage`, `IFrameHoverComponentMessage`, `IFrameLocationMessage`, `IFrameMessage`, `IFrameMessageType`, `IFrameOpenLinkMessage`, `IFrameSelectComponentMessage`, and `IReadyIFrameMessage` to the public API
5 changes: 5 additions & 0 deletions .changeset/wicked-coins-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/blocks-admin": patch
---

Add `BlocksBlockOutput`, `ListBlockOutput`, `OneOfBlockOutput`, `OneOfBlockPreviewState`, and `OptionalBlockOutput` to the public API
5 changes: 3 additions & 2 deletions demo/admin/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { resolve } from "node:path";

import { CodegenConfig } from "@graphql-codegen/cli";
import { readFileSync } from "fs";
import { buildSchema } from "graphql";

const schema = buildSchema(readFileSync("./schema.gql").toString());

const schema = buildSchema(readFileSync(resolve(__dirname, "./schema.gql")).toString());
const rootBlocks = Object.keys(schema.getTypeMap()).filter((type) => type.endsWith("BlockData") || type.endsWith("BlockInput"));

const config: CodegenConfig = {
Expand Down
13 changes: 0 additions & 13 deletions demo/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,18 @@
"@comet/admin": "workspace:*",
"@comet/admin-date-time": "workspace:*",
"@comet/admin-icons": "workspace:*",
"@comet/admin-react-select": "workspace:*",
"@comet/admin-rte": "workspace:*",
"@comet/admin-theme": "workspace:*",
"@comet/blocks-admin": "workspace:*",
"@comet/cms-admin": "workspace:*",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@fontsource-variable/roboto-flex": "^5.0.14",
"@mui/lab": "^6.0.0-beta.10",
"@mui/material": "^6.0.0",
"@mui/system": "^6.0.0",
"@mui/x-data-grid": "^7.22.3",
"@mui/x-data-grid-pro": "^7.22.3",
"change-case": "^5.2.0",
"dnd-core": "^16.0.0",
"draft-js": "^0.11.0",
"exceljs": "^4.4.0",
"file-saver": "^2.0.0",
"final-form": "^4.0.0",
"graphql": "^15.0.0",
"graphql-tag": "^2.0.0",
Expand All @@ -57,18 +51,15 @@
"react-dom": "^17.0.2",
"react-final-form": "^6.0.0",
"react-intl": "^6.0.0",
"react-is": "^17.0.2",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-select": "^3.0.0",
"use-debounce": "^6.0.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"@comet/cli": "workspace:*",
"@comet/eslint-config": "workspace:*",
"@formatjs/cli": "^6.0.0",
"@gitbeaker/node": "^25.0.0",
"@graphql-codegen/add": "^3.0.0",
"@graphql-codegen/cli": "^2.0.0",
"@graphql-codegen/fragment-matcher": "^2.0.0",
Expand All @@ -78,19 +69,15 @@
"@graphql-codegen/typescript": "^2.0.0",
"@graphql-codegen/typescript-operations": "^2.0.0",
"@swc/plugin-emotion": "^2.5.120",
"@types/draft-js": "^0.11.10",
"@types/lodash.isequal": "^4.0.0",
"@types/node": "^22.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-is": "^17.0.0",
"@types/react-router": "^5.0.0",
"@types/react-router-dom": "^5.0.0",
"@types/react-select": "^3.0.0",
"@types/uuid": "^7.0.0",
"@vitejs/plugin-react-swc": "^3.6.0",
"chokidar-cli": "^2.0.0",
"cosmiconfig-toml-loader": "^1.0.0",
"dotenv-cli": "^4.0.0",
"eslint": "^8.0.0",
"eslint-plugin-graphql": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions demo/admin/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"private": true,
"dependencies": {
"compression": "^1.7.4",
"express": "^4.18.2"
"express": "^4.18.2",
"helmet": "^7.0.0"
},
"scripts": {
"preserve": "envsubst < \"../build/index.html\" > \"/tmp/index.html\" && mv /tmp/index.html ../build/index.html",
"serve": "node server.js"
}
}
45 changes: 36 additions & 9 deletions demo/admin/server/server.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
/* eslint-disable no-undef */
const express = require("express");
const compression = require("compression");
const helmet = require("helmet");
const fs = require("fs");

const app = express();
const port = process.env.APP_PORT ?? 3000;

// Read index.html file
let indexFile = fs.readFileSync("build/index.html", "utf8");

// Replace environment variables
indexFile = indexFile.replace(/\$([A-Z_]+)/g, (match, p1) => {
return process.env[p1] || "";
});

app.use(compression());
app.use(
helmet({
contentSecurityPolicy: {
directives: {
"script-src": ["'self'", "'unsafe-inline'"],
"img-src": ["'self'", "https:", "data:"],
"default-src": ["'self'", "https:"],
"media-src": ["'self'", "https:"],
"style-src": ["'self'", "https:", "'unsafe-inline'"],
"font-src": ["'self'", "https:", "data:"],
},
},
xXssProtection: false,
strictTransportSecurity: {
maxAge: 63072000,
includeSubDomains: true,
preload: true,
},
}),
);

app.get("/status/health", (req, res) => {
res.send("OK!");
});

// Serve static build an cache for 30d
app.use(
express.static("../build", {
express.static("./build", {
setHeaders: (res, path, stat) => {
if (path.endsWith(".html")) {
// Don't cache the index.html at all
// implemented as suggested by https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#preventing_caching
res.setHeader("cache-control", "no-store, max-age: 0");
} else if (path.endsWith(".js")) {
if (path.endsWith(".js")) {
// The js file is static and the index.html uses a parameter as cache buster
// implemented as suggested by https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#caching_static_assets
res.setHeader("cache-control", "public, max-age=31536000, immutable");
} else {
// Icons and Fonts could be changed over time
// Icons and Fonts could be changed over time, cache for 7d
res.setHeader("cache-control", "public, max-age=604800, immutable");
}
},
Expand All @@ -33,7 +58,9 @@ app.use(

// As a fallback, route everything to index.html
app.get("*", (req, res) => {
res.sendFile(`index.html`, { root: `${__dirname}/../build/` });
// Don't cache the index.html at all to make sure applications updates are applied
// implemented as suggested by https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#preventing_storing
res.send(indexFile, { headers: { "cache-control": "no-store" } });
});

app.listen(port, () => {
Expand Down
1 change: 1 addition & 0 deletions demo/admin/src/common/ContentScopeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function useContentScope(): UseContentScopeApi<ContentScope> {

// @TODO (maybe): make factory in library to statically create Provider

/** @knipignore */
export function useContentScopeConfig(p: ContentScopeConfigProps): void {
return useContentScopeConfigLibrary(p);
}
Expand Down
6 changes: 2 additions & 4 deletions demo/admin/src/config.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SiteConfig } from "@comet/cms-admin";
import { createContext, PropsWithChildren, useContext } from "react";

import cometConfig from "./comet-config.json";
Expand Down Expand Up @@ -26,16 +25,15 @@ export function createConfig() {
};
}

export type SitesConfig = Record<string, SiteConfig>;

export type Config = ReturnType<typeof createConfig>;
type Config = ReturnType<typeof createConfig>;

const ConfigContext = createContext<Config | undefined>(undefined);

export function ConfigProvider({ config, children }: PropsWithChildren<{ config: Config }>) {
return <ConfigContext.Provider value={config}>{children}</ConfigContext.Provider>;
}

/** @knipignore */
export function useConfig(): Config {
const config = useContext(ConfigContext);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from "@apollo/client";

export const predefinedPageFormFragment = gql`
const predefinedPageFormFragment = gql`
fragment PredefinedPageForm on PredefinedPage {
type
}
Expand Down
8 changes: 0 additions & 8 deletions demo/admin/src/news/generated/NewsForm.gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ export const newsFormQuery = gql`
${newsFormFragment}
`;

export const newsFormCheckForChangesQuery = gql`
query NewsFormCheckForChanges($id: ID!) {
news(id: $id) {
updatedAt
}
}
`;

export const createNewsMutation = gql`
mutation CreateNews($scope: NewsContentScopeInput!, $input: NewsInput!) {
createNews(scope: $scope, input: $input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// You may choose to use this file as scaffold by moving this file out of generated folder and removing this comment.
import { gql } from "@apollo/client";

export const productFormFragment = gql`
const productFormFragment = gql`
fragment CreateCapProductFormDetails on Product {
title
slug
Expand Down
8 changes: 0 additions & 8 deletions demo/admin/src/products/generated/ProductForm.gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ export const productFormQuery = gql`
${productFormFragment}
`;

export const productFormCheckForChangesQuery = gql`
query ProductFormCheckForChanges($id: ID!) {
product(id: $id) {
updatedAt
}
}
`;

export const createProductMutation = gql`
mutation CreateProduct($input: ProductInput!) {
createProduct(input: $input) {
Expand Down
1 change: 0 additions & 1 deletion demo/admin/src/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createCometTheme } from "@comet/admin-theme";
import type {} from "@mui/lab/themeAugmentation";

export const theme = createCometTheme();
86 changes: 0 additions & 86 deletions demo/api/block-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,92 +589,6 @@
}
]
},
{
"name": "FooterLinkSection",
"fields": [
{
"name": "title",
"kind": "String",
"nullable": false
},
{
"name": "links",
"kind": "Block",
"block": "LinkList",
"nullable": false
}
],
"inputFields": [
{
"name": "title",
"kind": "String",
"nullable": false
},
{
"name": "links",
"kind": "Block",
"block": "LinkList",
"nullable": false
}
]
},
{
"name": "FooterTopLinks",
"fields": [
{
"name": "blocks",
"kind": "NestedObjectList",
"object": {
"fields": [
{
"name": "key",
"kind": "String",
"nullable": false
},
{
"name": "visible",
"kind": "Boolean",
"nullable": false
},
{
"name": "props",
"kind": "Block",
"block": "FooterLinkSection",
"nullable": false
}
]
},
"nullable": false
}
],
"inputFields": [
{
"name": "blocks",
"kind": "NestedObjectList",
"object": {
"fields": [
{
"name": "key",
"kind": "String",
"nullable": false
},
{
"name": "visible",
"kind": "Boolean",
"nullable": false
},
{
"name": "props",
"kind": "Block",
"block": "FooterLinkSection",
"nullable": false
}
]
},
"nullable": false
}
]
},
{
"name": "FullWidthImage",
"fields": [
Expand Down
Loading

0 comments on commit b8817b8

Please sign in to comment.