Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor everything :) #26

Merged
merged 43 commits into from
Nov 24, 2021
Merged

Refactor everything :) #26

merged 43 commits into from
Nov 24, 2021

Conversation

bezoerb
Copy link
Member

@bezoerb bezoerb commented Nov 13, 2021

I had to disable tests for the grow plugin as ts-jest doesn't seem to play nice with the monorepo/esm construct

@bezoerb bezoerb mentioned this pull request Nov 13, 2021
Copy link
Contributor

@tharders tharders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schaffe es heute nicht das alles anzuschauen, aber schon mal mein bisheriges Feedback

.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
packages/contentful-ssg-plugin-grow/src/index.ts Outdated Show resolved Hide resolved
packages/contentful-ssg/src/__test__/mock.ts Show resolved Hide resolved
@bezoerb bezoerb marked this pull request as ready for review November 17, 2021 08:07
CONTRIBUTING.md Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
packages/contentful-ssg/README.md Outdated Show resolved Hide resolved
packages/contentful-ssg/README.md Outdated Show resolved Hide resolved
packages/contentful-ssg/README.md Outdated Show resolved Hide resolved
packages/contentful-ssg/README.md Outdated Show resolved Hide resolved
packages/contentful-ssg/README.md Outdated Show resolved Hide resolved
"main": "./dist/index.js",
"type": "module",
"typings": "./dist/types.d.ts",
"exports": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da sind ja einige Dateien drinne.
Zusammen mit den typesVersions frage ich mich ob man das nicht vereinfachen kann, indem man die logik aus der index in eine weitere datei schiebt und in der index ein objekt exportiert was die hier genannten sachen enthält?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ich will das ungern alles in einem großen object drin haben...

ggf. will man ja auch nur z.B. den toml converter oder den object helper importieren.
Dann finde ich das so schöner:

import {snakeCaseKeys} from '@jungvonmatt/contentful-ssg/helper/object';
import toml from '@jungvonmatt/contentful-ssg/converter/toml';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So viele interne export Punkte können aber schnell zum Problem werden, wenn man was refactoren will.
Das sind ja quasi alles Schnittstellen die man genau in der Struktur nach außen gibt und die sich nicht ändern dürfen wenn man kompatibel bleiben woll.
Vielleicht statt einem großem Objekt dann mehrere kleine, aber auf oberster Ebene? (index, helper, transformer, ...)?
Das sind dann nur Typisierte Hüllen. Ich. meine sowas habe ich schon mal woanders gesehen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ich check das nochmal ;)

packages/contentful-ssg/package.json Outdated Show resolved Hide resolved
packages/contentful-ssg/src/helper/config.ts Outdated Show resolved Hide resolved
packages/contentful-ssg/src/helper/config.ts Outdated Show resolved Hide resolved
packages/contentful-ssg/src/helper/file-manager.ts Outdated Show resolved Hide resolved
packages/contentful-ssg/src/helper/object.ts Outdated Show resolved Hide resolved
packages/contentful-ssg/src/index.ts Outdated Show resolved Hide resolved
packages/contentful-ssg/src/tasks/transform.ts Outdated Show resolved Hide resolved
packages/cssg-plugin-grow/src/index.fixme.ts Show resolved Hide resolved
tsconfig.old.json Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved

### Runtime Hooks
**before**
```js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da wir typescript unterstützen wäre es doch super, wenn wir hier die Beispiele in Typescript schreiben.
Wer JavaScript nutzen will muss die Typen dann einfach weglassen.
Würde das ganze meiner Meinung nach verdeutlichen.

Copy link
Member Author

@bezoerb bezoerb Nov 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finde ich schwierig... Da man durch den Typ auch nicht mehr weiß.
In der Readme gibt's leider kein type hinting.

Und die Funktion zu typisieren wäre dann mit Parameter Types und Allen möglichen Return Types schon etwas unübersichtlich finde ich:
z.B. bei einem Transform Hook:

(transformContext: TransformContext, runtimeContext: RuntimeContext, prev: KeyValueMap): KeyValueMap | Promise<KeyValueMap> => {
...
}

packages/contentful-ssg/README.md Outdated Show resolved Hide resolved
packages/contentful-ssg/README.md Outdated Show resolved Hide resolved
packages/contentful-ssg/src/lib/error.ts Outdated Show resolved Hide resolved
return [...this.ignoredFiles].length;
}

get ignoredFiles() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich fände es übersichtlicher, wenn alle Funktionen einen Return Type definieren müssen.
Ausnahme wäre nur eine Funktion die nur void zurück gibt.
Die Regel ist bei XO leider deaktiviert

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der return type ergibt sich doch an sich automatisch aus dem context

errors: StatsEntry[] = [];
skipped: StatsEntry[] = [];

constructor(config: Config) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mit dem aktuellen Typescript kann man schreiben

constructor(private readonly config: Config) {}

Da lässt man die config field Deklaration oben auch weg.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dann kann ich die aber in den tests nicht mehr ändern, oder?

packages/contentful-ssg/src/types.ts Outdated Show resolved Hide resolved
tsconfigRootDir: __dirname,
extraFileExtensions: [".cjs"]
},
ignorePatterns: ['**/*.cjs','src/**/*.test.ts', 'src/__test__/*',"src/**/*.fixme.ts"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich finde auch Tests sollten sich an Linter Settings halten.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dann müsste ich die auch in der tsconfig.json freischalten

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: src/tasks/setup.test.ts.
The file must be included in at least one of the projects provided.

kann man später nochmal nachziehen ;)

@bezoerb bezoerb merged commit 0f7b3ba into main Nov 24, 2021
@bezoerb bezoerb deleted the feature/typescript branch November 24, 2021 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants