Skip to content

Setup a New Single Package#697

Merged
CarlosCortizasCT merged 20 commits intomainfrom
cm-single-package-release
Apr 24, 2025
Merged

Setup a New Single Package#697
CarlosCortizasCT merged 20 commits intomainfrom
cm-single-package-release

Conversation

@CarlosCortizasCT
Copy link
Copy Markdown
Contributor

@CarlosCortizasCT CarlosCortizasCT commented Oct 23, 2024

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.json files in the presets/all-packages subdirectories are autogenerated files (using preconstruct) and are needed to be able to consume each model independently.

@CarlosCortizasCT CarlosCortizasCT added 🚧 Status: WIP fe-chapter-rotation Tasks coming from frontend chapter work labels Oct 23, 2024
@CarlosCortizasCT CarlosCortizasCT self-assigned this Oct 23, 2024
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 23, 2024

🦋 Changeset detected

Latest commit: 810ef7b

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

This PR includes changesets to release 49 packages
Name Type
@commercetools-test-data/generators Minor
@commercetools-test-data/product-type Minor
@commercetools-test-data/type Minor
@commercetools-test-data/product Minor
@commercetools/composable-commerce-test-data Minor
@commercetools-test-data/cart-discount Minor
@commercetools-test-data/cart Minor
@commercetools-test-data/product-discount Minor
@commercetools-test-data/product-projection Minor
@commercetools-test-data/category Minor
@commercetools-test-data/channel Minor
@commercetools-test-data/inventory-entry Minor
@commercetools-test-data/standalone-price Minor
@commercetools-test-data/discount-code Minor
@commercetools-test-data/order Minor
@commercetools-test-data/quote-request Minor
@commercetools-test-data/quote Minor
@commercetools-test-data/staged-quote Minor
@commercetools-test-data/commons Minor
@commercetools-test-data/store Minor
@commercetools-test-data/payment Minor
@commercetools-test-data/associate-role Minor
@commercetools-test-data/attribute-group Minor
@commercetools-test-data/business-unit Minor
@commercetools-test-data/custom-application Minor
@commercetools-test-data/custom-object Minor
@commercetools-test-data/custom-view Minor
@commercetools-test-data/customer-group Minor
@commercetools-test-data/customer Minor
@commercetools-test-data/customers-search-list-my-view Minor
@commercetools-test-data/discounts-custom-view Minor
@commercetools-test-data/organization Minor
@commercetools-test-data/platform-limits Minor
@commercetools-test-data/product-selection Minor
@commercetools-test-data/product-tailoring Minor
@commercetools-test-data/review Minor
@commercetools-test-data/shipping-method Minor
@commercetools-test-data/shopping-list Minor
@commercetools-test-data/state Minor
@commercetools-test-data/tax-category Minor
@commercetools-test-data/user Minor
@commercetools-test-data/zone Minor
@commercetools-test-data/organization-extension Minor
@commercetools-test-data/project-extension Minor
@commercetools-test-data/core Minor
@commercetools-test-data/graphql-types Minor
@commercetools-test-data/filter-values Minor
@commercetools-test-data/project Minor
@commercetools-test-data/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

@bradd123 bradd123 force-pushed the cm-single-package-release branch from 419d3c7 to a686107 Compare March 31, 2025 10:46
@bradd123 bradd123 changed the title [PoC] Single package release FEC-181: Setup a New Single Package Apr 4, 2025
@@ -1,78 +1,157 @@
{
"name": "@commercetools-frontend/test-data",
"name": "@commercetools/composable-commerce-test-data",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Renamed the package name to follow the latest NCR naming convention.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread presets/all-packages/package.json
});
}

// 3. Update the single package preset
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to:

  1. Create a file in the source folder where we export the new model
  2. Update the package.json to 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.
  3. We create the "proxy" package.json for the independent entry point (using preconstruct)
  4. We install the new internal dependency

@@ -1,5 +1,5 @@
import { AttributeLocalizedEnumValue } from '@commercetools/platform-sdk';
import { TLocalizedStringGraphql } from '@commercetools-test-data/commons/src';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixing an incorrect import.

orderHint: ValueOf<CategoryOrderHints>;
__typename: 'CategoryOrderHint';
};
export type TCategoryOrderHintGraphql = TCtpCategoryOrderHint;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixing an incorrect import.

@commercetools commercetools deleted a comment from bradd123 Apr 8, 2025
@@ -0,0 +1,6 @@
{
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is how we re-export an internal package so it can be consumed independently.

@@ -0,0 +1 @@
export default {};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't want to export everything at once. Consumers will need to import whatever they need independently.

@CarlosCortizasCT CarlosCortizasCT marked this pull request as ready for review April 8, 2025 12:00
@CarlosCortizasCT CarlosCortizasCT requested review from a team as code owners April 8, 2025 12:00
@CarlosCortizasCT CarlosCortizasCT requested review from a team and tdeekens April 8, 2025 12:01
Comment thread presets/all-packages/README.md Outdated
Comment thread presets/all-packages/README.md Outdated
@CarlosCortizasCT CarlosCortizasCT changed the title FEC-181: Setup a New Single Package Setup a New Single Package Apr 15, 2025
const presetPackageJson = (
await import(join(presetDirectoryPath, 'package.json'))
).default;
presetPackageJson.files.push(modelCodename);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe worth to add some guards here if the structure isn't expected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 🙏

Copy link
Copy Markdown
Contributor

@ismaelocaramelo ismaelocaramelo left a comment

Choose a reason for hiding this comment

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

LTGM, I've just added a small doubt without having full context.

@CarlosCortizasCT CarlosCortizasCT merged commit de2f642 into main Apr 24, 2025
8 checks passed
@CarlosCortizasCT CarlosCortizasCT deleted the cm-single-package-release branch April 24, 2025 11:00
@ct-changesets ct-changesets Bot mentioned this pull request Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fe-chapter-rotation Tasks coming from frontend chapter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants