initial setup

This commit is contained in:
Max Peintner
2023-04-03 11:45:27 +02:00
commit c1c9ccbf03
37 changed files with 4335 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
module.exports = {
extends: ["next", "turbo", "prettier"],
rules: {
"@next/next/no-html-link-for-pages": "off",
},
parserOptions: {
babelOptions: {
presets: [require.resolve("next/babel")],
},
},
};

View File

@@ -0,0 +1,15 @@
{
"name": "eslint-config-zitadel",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"eslint-config-next": "latest",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "7.28.0",
"eslint-config-turbo": "latest"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["zitadel"],
};

View File

@@ -0,0 +1,31 @@
{
"name": "@zitadel/core",
"version": "0.0.0",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"sideEffects": false,
"license": "MIT",
"files": [
"dist/**"
],
"scripts": {
"build": "tsup src/index.tsx --format esm,cjs --dts --external react",
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"devDependencies": {
"@zitadel/tsconfig": "workspace:*",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"@types/react": "^17.0.13",
"@types/react-dom": "^17.0.8",
"react": "^17.0.2",
"tsup": "^5.10.1",
"typescript": "^4.5.3"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1,11 @@
import * as React from "react";
export interface ButtonProps {
children: React.ReactNode;
}
export function Button(props: ButtonProps) {
return <button>{props.children}</button>;
}
Button.displayName = "Button";

View File

@@ -0,0 +1,2 @@
import * as React from "react";
export { Button, type ButtonProps } from "./Button";

View File

@@ -0,0 +1,5 @@
{
"extends": "@zitadel/tsconfig/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true
},
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Next.js",
"extends": "./base.json",
"compilerOptions": {
"allowJs": true,
"declaration": false,
"declarationMap": false,
"incremental": true,
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"noEmit": true,
"resolveJsonModule": true,
"rootDir": "src",
"target": "es5"
},
"include": ["src", "next-env.d.ts"],
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 14",
"extends": "./base.json",
"compilerOptions": {
"lib": ["ES2020"],
"module": "commonjs",
"target": "ES2020"
}
}

View File

@@ -0,0 +1,9 @@
{
"name": "@zitadel/tsconfig",
"version": "0.0.0",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1,11 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "React Library",
"extends": "./base.json",
"compilerOptions": {
"jsx": "react-jsx",
"lib": ["dom", "ES2015"],
"module": "ESNext",
"target": "es6"
}
}

View File

@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["zitadel"],
};

View File

@@ -0,0 +1,31 @@
{
"name": "@zitadel/utils",
"version": "0.0.0",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"sideEffects": false,
"license": "MIT",
"files": [
"dist/**"
],
"scripts": {
"build": "tsup src/index.tsx --format esm,cjs --dts --external react",
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"devDependencies": {
"@zitadel/tsconfig": "workspace:*",
"@types/react": "^17.0.13",
"@types/react-dom": "^17.0.8",
"eslint": "^7.32.0",
"eslint-config-zitadel": "workspace:*",
"react": "^17.0.2",
"tsup": "^5.10.1",
"typescript": "^4.5.3"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1,3 @@
export { toSlug } from "./toSlug";
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
export { usePrevious } from "./usePrevious";

View File

@@ -0,0 +1,18 @@
/**
* Return a slugified copy of a string.
*
* @param {string} str The string to be slugified
* @return {string} The slugified string.
*/
export function toSlug(str: string): string {
let s = str;
if (!s) {
return "";
}
s = s.toLowerCase().trim();
s = s.replace(/ & /g, " and ");
s = s.replace(/[ ]+/g, "-");
s = s.replace(/[-]+/g, "-");
s = s.replace(/[^a-z0-9-]+/g, "");
return s;
}

View File

@@ -0,0 +1,13 @@
import * as React from "react";
/**
* On the server, React emits a warning when calling `useLayoutEffect`.
* This is because neither `useLayoutEffect` nor `useEffect` run on the server.
* We use this safe version which suppresses the warning by replacing it with a noop on the server.
*
* See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
*/
const useIsomorphicLayoutEffect =
typeof window !== "undefined" ? React.useLayoutEffect : () => {};
export { useIsomorphicLayoutEffect };

View File

@@ -0,0 +1,17 @@
import * as React from "react";
function usePrevious<T>(value: T) {
// The ref object is a generic container whose current property is mutable ...
// ... and can hold any value, similar to an instance property on a class
const ref = React.useRef<T>(value);
// Store current value in ref
React.useEffect(() => {
ref.current = value;
}, [value]); // Only re-run if value changes
// Return previous value (happens before update in useEffect above)
return ref.current;
}
export { usePrevious };

View File

@@ -0,0 +1,5 @@
{
"extends": "@zitadel/tsconfig/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}