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

feat(starter-template): add starter template in TypeScript #2615

Merged
merged 48 commits into from
Jun 30, 2022

Conversation

kark
Copy link
Contributor

@kark kark commented May 16, 2022

Summary

The aim of this PR is to add a stater template in TypeScript.

Closes #2297
Ref: #1668

@kark kark added the 🚧 Status: WIP Work in progress label May 16, 2022
@changeset-bot
Copy link

changeset-bot bot commented May 16, 2022

🦋 Changeset detected

Latest commit: 8a61737

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
@commercetools-frontend/application-config Minor
@commercetools-frontend/sdk Minor
@commercetools-frontend/application-components Minor
merchant-center-application-template-starter-typescript Minor
@commercetools-frontend/create-mc-app Minor
merchant-center-application-template-starter Minor
@commercetools-frontend/i18n Minor
@commercetools-frontend/application-shell Minor
@commercetools-frontend/cypress Minor
@commercetools-frontend/mc-dev-authentication Minor
@commercetools-frontend/mc-html-template Minor
@commercetools-frontend/mc-scripts Minor
playground Patch
@commercetools-local/visual-testing-app Patch
@commercetools-website/components-playground Patch
@commercetools-backend/eslint-config-node Minor
@commercetools-backend/express Minor
@commercetools-backend/loggers Minor
@commercetools-frontend/actions-global Minor
@commercetools-frontend/application-shell-connectors Minor
@commercetools-frontend/assets Minor
@commercetools-frontend/babel-preset-mc-app Minor
@commercetools-frontend/browser-history Minor
@commercetools-frontend/constants Minor
@commercetools-frontend/eslint-config-mc-app Minor
@commercetools-frontend/jest-preset-mc-app Minor
@commercetools-frontend/jest-stylelint-runner Minor
@commercetools-frontend/l10n Minor
@commercetools-frontend/notifications Minor
@commercetools-frontend/permissions Minor
@commercetools-frontend/react-notifications Minor
@commercetools-frontend/sentry Minor
@commercetools-frontend/url-utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot temporarily deployed to Preview May 16, 2022 09:24 Destroyed
@github-actions
Copy link
Contributor

github-actions bot commented May 16, 2022

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-ccbxm4k22-commercetools.vercel.app
https://appkit-sha-b445289fe54f8eaad466a444d368450622a850b9.commercetools.vercel.app
https://appkit-pr-2615.commercetools.vercel.app

Built with commit 8a61737.
This pull request is being automatically deployed with vercel-action

@kark kark force-pushed the kk-starter-typescript branch from 0a12339 to b83357b Compare May 16, 2022 09:31
@github-actions github-actions bot temporarily deployed to Preview May 16, 2022 09:36 Destroyed
@kark kark force-pushed the kk-starter-typescript branch from b83357b to 853bd9f Compare May 16, 2022 10:10
@github-actions github-actions bot temporarily deployed to Preview May 16, 2022 10:16 Destroyed
@kark kark changed the title feat(starter-template): add starter template in TypeScipt feat(starter-template): add starter template in TypeScript May 16, 2022
@kark kark force-pushed the kk-starter-typescript branch 2 times, most recently from 5929cb4 to 6374c1e Compare May 18, 2022 14:17
@github-actions github-actions bot temporarily deployed to Preview May 18, 2022 14:23 Destroyed
@kark kark force-pushed the kk-starter-typescript branch from 6374c1e to 67138d0 Compare May 19, 2022 08:34
@github-actions github-actions bot temporarily deployed to Preview May 19, 2022 08:38 Destroyed
@kark kark marked this pull request as ready for review May 19, 2022 10:16
@kark kark requested a review from a team May 19, 2022 10:16
@kark kark removed the 🚧 Status: WIP Work in progress label May 19, 2022
@github-actions github-actions bot temporarily deployed to Preview May 24, 2022 09:53 Destroyed
Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

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

Super awesome job 💪

I just left some questions/suggestions for better understanding.

@@ -0,0 +1,12 @@
import { Builder } from '@commercetools-test-data/core';
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if we could use the Channel our test-data package provides instead of creating this whole directory.
(maybe as a follow-up task)

Copy link
Contributor Author

@kark kark May 27, 2022

Choose a reason for hiding this comment

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

I actually tried that and with the current implementation of the Channel model in @commercetools-test-data/channel I was not able to get the gql response modelled properly. I haven’t worked with test-data repo much (perhaps I did not use it properly) but it seems that the Transformer in its current shape does not allow to customize the name like:

import * as Channel from "@commercetools-test-data/channel";

const channel = Channel.random()
  .name(LocalizedString.presets.empty().en(name))
  .key("some-key")
  .buildGraphql();

The name is always randomly generated so I wouldn’t be able to test the channel name update.

Copy link
Member

Choose a reason for hiding this comment

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

Can you show what the error is?

And yes, we should use the model from the test-data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, there’s no error. It only works differently. I created a playground to isolate the issue.
TL;DR: channels transformer from @commercetools-test-data/channel works differently from the current solution - nameAllLocales is random, not based on the provided name

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it seems something needs to be adjusted in the test-models package.
We even have some preset channels over there which doesn't seem to return the expected data:

import * as Channel from "@commercetools-test-data/channel";

const channel: TChannel = Channel.presets.foodStore().buildGraphql();

console.log(
  "channel test data:",
  {
    key: channel.key,
    name: JSON.stringify(channel.name),
    nameAllLocales: JSON.stringify(channel.nameAllLocales)
  }
);

// This is what it renders: (expected other localized names)
channel test data:
{
  key: "food-store-key",
  name: "{}",
  nameAllLocales: "[
    {"locale":"de","value":"distinctio nihil magni ut deleniti","__typename":"LocalizedString"},
    {"locale":"en","value":"sint aut est","__typename":"LocalizedString"},
    {"locale":"fr","value":"eos nihil ratione est","__typename":"LocalizedString"}
  ]"
}

Copy link
Contributor Author

@kark kark Jun 7, 2022

Choose a reason for hiding this comment

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

As suggested, I used Channel data model from @commercetools-test-data/channel in tests (updated in 05150c1).

As noted 👆to make all test cases work (also including parts testing name and nameAllLocales that I removed for the time being) that repo would have to be refactored and it seems to me some breaking changes would need to be introduced there (and I guess to other packages in the test data repo too). I don’t feel 100% confident about those changes 😕 as I don't understand why the implementation of the model transformers is different in the first place.

I was wondering if that could be done as a follow up once @emmenko is back.

Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT Jun 10, 2022

Choose a reason for hiding this comment

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

Totally agree about working on the test-data repo in a different task as a follow up. However, I would personally keep the tests with our local test-data utilities until we can use the external ones.

@emmenko emmenko marked this pull request as draft May 27, 2022 09:20
@emmenko emmenko added the 🚧 Status: WIP Work in progress label May 27, 2022
@kark kark force-pushed the kk-starter-typescript branch from 79daaab to d2c7bb4 Compare May 27, 2022 09:35
@github-actions github-actions bot temporarily deployed to Preview May 27, 2022 09:38 Destroyed
@github-actions github-actions bot temporarily deployed to Preview May 27, 2022 09:40 Destroyed
@github-actions github-actions bot temporarily deployed to Preview May 30, 2022 06:34 Destroyed
@kark kark force-pushed the kk-starter-typescript branch from e515ecf to 24b692b Compare June 2, 2022 08:55
Copy link
Contributor

@Rhotimee Rhotimee left a comment

Choose a reason for hiding this comment

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

Good job 🙌🏽
I left some minor suggestions.

@@ -2,4 +2,4 @@
'@commercetools-frontend/application-components': patch
---

Accessibility improvements of the `TabHeader` component.
Accessibility improvements of the `<TabHeader>` component.
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Why use the angle brackets here?
Do you mean <TabHeader />?

Copy link
Member

Choose a reason for hiding this comment

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

It's just my way of indicating that it's a React component, same as HTML elements are usually documented (e.g. <div>, etc.)

@emmenko emmenko merged commit d6bfecf into main Jun 30, 2022
@emmenko emmenko deleted the kk-starter-typescript branch June 30, 2022 15:03
@ghost ghost mentioned this pull request Jun 30, 2022
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.

TS version of the starter kit
4 participants