Setup a New Single Package#697
Conversation
🦋 Changeset detectedLatest commit: 810ef7b The changes in this PR will be included in the next version bump. This PR includes changesets to release 49 packages
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 |
419d3c7 to
a686107
Compare
| @@ -1,78 +1,157 @@ | |||
| { | |||
| "name": "@commercetools-frontend/test-data", | |||
| "name": "@commercetools/composable-commerce-test-data", | |||
There was a problem hiding this comment.
Renamed the package name to follow the latest NCR naming convention.
There was a problem hiding this comment.
| }); | ||
| } | ||
|
|
||
| // 3. Update the single package preset |
There was a problem hiding this comment.
We need to:
- Create a file in the source folder where we export the new model
- Update the
package.jsonto make sure we have a new entry point for the new model, we include its source in the dist package and we add the internal dependency. - We create the "proxy"
package.jsonfor the independent entry point (usingpreconstruct) - We install the new internal dependency
| @@ -1,5 +1,5 @@ | |||
| import { AttributeLocalizedEnumValue } from '@commercetools/platform-sdk'; | |||
| import { TLocalizedStringGraphql } from '@commercetools-test-data/commons/src'; | |||
There was a problem hiding this comment.
Fixing an incorrect import.
| orderHint: ValueOf<CategoryOrderHints>; | ||
| __typename: 'CategoryOrderHint'; | ||
| }; | ||
| export type TCategoryOrderHintGraphql = TCtpCategoryOrderHint; |
There was a problem hiding this comment.
Use the generated GraphQL types is better.
| @@ -1,5 +1,5 @@ | |||
| import { CustomFieldLocalizedEnumValue } from '@commercetools/platform-sdk'; | |||
| import { TLocalizedStringGraphql } from '@commercetools-test-data/commons/src'; | |||
| import { TLocalizedStringGraphql } from '@commercetools-test-data/commons'; | |||
There was a problem hiding this comment.
Fixing an incorrect import.
| @@ -0,0 +1,6 @@ | |||
| { | |||
There was a problem hiding this comment.
All these package.json files are autogenerated by preconstruct and required for it to be able to export independent entry points.
| @@ -0,0 +1 @@ | |||
| export * from '@commercetools-test-data/attribute-group'; | |||
There was a problem hiding this comment.
This is how we re-export an internal package so it can be consumed independently.
| @@ -0,0 +1 @@ | |||
| export default {}; | |||
There was a problem hiding this comment.
We don't want to export everything at once. Consumers will need to import whatever they need independently.
| const presetPackageJson = ( | ||
| await import(join(presetDirectoryPath, 'package.json')) | ||
| ).default; | ||
| presetPackageJson.files.push(modelCodename); |
There was a problem hiding this comment.
maybe worth to add some guards here if the structure isn't expected?
There was a problem hiding this comment.
Not sure if I follow.
Are you worried about the structure of the package.json file import?
If that's the case, the file is managed by us and the files property is mandatory. Without it the preset would not work so I think it's safe to assume it will exists.
Please let me know if I misunderstood your comment 🙏
ismaelocaramelo
left a comment
There was a problem hiding this comment.
LTGM, I've just added a small doubt without having full context.
The goal of this PR is to publish a single package for all the models. We are currently publishing 40+ packages every time we release a new version of the test data models which is not good for the repository maintainability nor for its consumers.
The goal of this task is to set up a new package in this repository which aggregates all the test data models so we only need to release that one and consumers can simplify the way they use test data models and also how they stay up to date with the latest changes
Note for reviewers: all the new
package.jsonfiles in thepresets/all-packagessubdirectories are autogenerated files (usingpreconstruct) and are needed to be able to consume each model independently.