Skip to content

Commit

Permalink
Monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
Coyenn committed Aug 14, 2023
1 parent 6d8c47c commit ceb1a12
Show file tree
Hide file tree
Showing 14 changed files with 2,862 additions and 93 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v2

- name: Install Dependencies
run: pnpm i

- name: Build
run: pnpm build

- name: Publish to NPM
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./packages/core/package.json
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
node_modules
dist
.turbo
.env
.cache
.DS_Store
*.log
*.local
2 changes: 1 addition & 1 deletion examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "simple",
"version": "1.0.0",
"description": "",
"main": "index.js",
"main": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
8 changes: 8 additions & 0 deletions examples/simple/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ProjectConfiguration } from "open-headless";
import { typo3 } from "open-headless/connectors";

const config: ProjectConfiguration = {
name: "My Project",
cmsConnector: typo3,
cmsPath: "http://cms.my-project.com",
};
24 changes: 8 additions & 16 deletions examples/simple/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */

/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand All @@ -23,12 +21,11 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"module": "commonjs", /* Specify what module code is generated. */
"rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
Expand All @@ -42,12 +39,10 @@
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
Expand All @@ -72,17 +67,15 @@
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */

/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -101,9 +94,8 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"private": true,
"scripts": {
"build": "turbo build",
"dev": "turbo dev --no-cache --continue"
},
"devDependencies": {
"turbo": "^1.10.12"
}
}
13 changes: 9 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"version": "0.0.1",
"scripts": {
"build": "tsup",
"watch": "tsup --watch",
"dev": "tsup --watch",
"eslint:check": "eslint --ext .ts,.tsx .",
"eslint:fix": "eslint --fix --ext .ts,.tsx .",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write ."
},
"tsup": {
"entry": [
"src/**/*.ts"
"./src/**/*.ts"
],
"splitting": false,
"sourcemap": true,
Expand All @@ -25,8 +25,9 @@
},
"author": "Tim Ritter <t-ritter-mail@web.de>",
"license": "ISC",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
Expand All @@ -42,6 +43,10 @@
"require": "./dist/connectors/index.js"
}
},
"files": [
"./dist/**/*",
"./dist/connectors/**/*"
],
"devDependencies": {
"@types/eslint": "^8.44.2",
"@types/node": "^20.4.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/connectors/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from '@/connectors/typo3';
export { default as typo3 } from "@/connectors/typo3";
68 changes: 68 additions & 0 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Holds the central configuration of your project.
*/
interface ProjectConfiguration {
name: string;
cmsConnector: CmsConnector;
cmsPath: string;
}

interface IdentifiableObject {
id: string;
}

/**
* The PageMeta holds metainformation about the page.
* For example, this can be used to hold properties relevant for SEO.
*/
interface PageMeta {
title?: string;
description?: string;
}

/**
* The content you see on a website is made up of so called 'content elements'.
* They are the smallest building blocks of a page.
* A section, a hero image, a text block are all content elements.
*/
interface ContentElement extends IdentifiableObject {
name: string;
type: string;
content?: { [key: string]: unknown };
}

interface PageLayout extends IdentifiableObject {
name: string;
}

interface Page extends IdentifiableObject {
layout: PageLayout;
meta: PageMeta;
content: ContentElement[];
}

interface Redirect extends IdentifiableObject {
statusCode?: number;
target: string;
}

type CmsResponse = Page | Redirect;

/**
* A CmsConnector is a connector to a content management system (CMS).
* It is used to request data the CMS.
*/
interface CmsConnector {
requestPage(path?: string, cmsPath?: string): Promise<Page | Redirect>;
}

export type {
ProjectConfiguration,
CmsConnector,
CmsResponse,
Page,
Redirect,
PageMeta,
ContentElement,
IdentifiableObject,
};
69 changes: 1 addition & 68 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1 @@
/**
* Holds the central configuration of your project.
*/
interface ProjectConfiguration {
name: string;
cmsConnector: CmsConnector;
cmsPath: string;
}

interface IdentifiableObject {
id: string;
}

/**
* The PageMeta holds metainformation about the page.
* For example, this can be used to hold properties relevant for SEO.
*/
interface PageMeta {
title?: string;
description?: string;
}

/**
* The content you see on a website is made up of so called 'content elements'.
* They are the smallest building blocks of a page.
* A section, a hero image, a text block are all content elements.
*/
interface ContentElement extends IdentifiableObject {
name: string;
type: string;
content?: { [key: string]: unknown };
}

interface PageLayout extends IdentifiableObject {
name: string;
}

interface Page extends IdentifiableObject {
layout: PageLayout;
meta: PageMeta;
content: ContentElement[];
}

interface Redirect extends IdentifiableObject {
statusCode?: number;
target: string;
}

type CmsResponse = Page | Redirect;

/**
* A CmsConnector is a connector to a content management system (CMS).
* It is used to request data the CMS.
*/
interface CmsConnector {
requestPage(path?: string, cmsPath?: string): Promise<Page | Redirect>;
}

export type {
ProjectConfiguration,
CmsConnector,
CmsResponse,
Page,
Redirect,
PageMeta,
ContentElement,
IdentifiableObject,
};
export * from '@/core';
15 changes: 12 additions & 3 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"declaration": true,
"declarationDir": "./dist/types",
"baseUrl": "./src",
Expand All @@ -21,7 +25,9 @@
"noUncheckedIndexedAccess": true,
"tsBuildInfoFile": "dist/.tsbuildinfo",
"paths": {
"@/*": ["./*"]
"@/*": [
"./*"
]
}
},
"include": [
Expand All @@ -31,5 +37,8 @@
"src/**/*.cjs",
"src/**/*.mjs"
],
"exclude": ["node_modules", "dist"]
"exclude": [
"node_modules",
"dist"
]
}
Loading

0 comments on commit ceb1a12

Please sign in to comment.