-
Notifications
You must be signed in to change notification settings - Fork 25
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
Improve monorepo setup and tooling #93
Changes from all commits
8dc986a
07eaafe
8d29c21
947ce3e
133a58f
9ea2f92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@commercetools/history-sdk': minor | ||
'@commercetools/importapi-sdk': minor | ||
'@commercetools/ml-sdk': minor | ||
'@commercetools/platform-sdk': minor | ||
--- | ||
|
||
Update development tooling and monorepo setup. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit $1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
12 | ||
14 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CHANGELOG.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Contributing | ||
|
||
Hi, thanks for taking an interest in contributing to the **TypeScript SDK** repository. We welcome any kind of contribution, from reporting issues or idea to submitting pull requests for bug fixes, improvements, new features, etc. | ||
|
||
Please take a moment to review this document in order to make the contribution process straightforward and effective for everyone involved. | ||
|
||
## Core ideas | ||
|
||
The repository primarily contains SDK packages in TypeScript generated from the commercetools platform API reference. | ||
|
||
## Repository structure | ||
|
||
This repository is managed as a monorepo, meaning it contains multiple (sub)packages located in the [`packages`](./packages) directory. | ||
|
||
``` | ||
packages/ | ||
... | ||
``` | ||
|
||
### Development tools | ||
|
||
At commercetools we use the following development tools: | ||
|
||
#### Yarn | ||
|
||
We use [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to manage dependencies between multiple packages. | ||
|
||
#### Jest | ||
|
||
We use [Jest](https://jestjs.io/) as the main framework for testing. Additionally, we take advantage of the Jest runners to run other tasks such as ESLint. | ||
|
||
#### Prettier | ||
|
||
We rely on [Prettier](https://prettier.io/) to consistently format our code. | ||
|
||
#### TypeScript | ||
|
||
We prefer to implement our UI components using [TypeScript](https://www.typescriptlang.org/). This has the benefit of provide packages with type declarations, thus a better developer experience, but also to have the codebase more maintainable and less error-prone. | ||
|
||
#### Preconstruct | ||
|
||
We rely on [Preconstruct](https://preconstruct.tools/) to build the packages. | ||
|
||
#### Commitlint | ||
|
||
Commit messages should follow a [conventional commit format](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional). | ||
|
||
## Opening an Issue | ||
|
||
In general, it's a good idea to open an issue first, no matter if it's a bug report, a new feature, etc. Doing so allows maintainers and other contributors to be aware of the context when an associated pull request is provided. It also gives a chance to provide early feedback and suggestions on what the pull request should focus on and what the expectations, avoiding unnecessary work during a pull request. | ||
|
||
## Submitting a Pull Request | ||
|
||
Good pull requests, such as patches, improvements, and new features, are a fantastic help. They should remain focused in scope and avoid containing unrelated commits. | ||
|
||
If possible, please try to provide a [related issue first](#opening-an-issue), where the topic is discussed and agreed upon before starting to work on that. This is helpful for both you and the maintainers to be familiar with the changes beforehand. | ||
|
||
## Getting started | ||
|
||
1. Clone the repository. | ||
2. Run `yarn` in the root folder to install the dependencies. | ||
|
||
Some useful commands to work with the repository: | ||
|
||
- `yarn test` and `yarn test --watch` | ||
- `yarn typecheck` | ||
- `yarn build` | ||
|
||
## Adding changesets | ||
|
||
commercetools sdk-typescript uses [changesets](https://github.com/atlassian/changesets) to do versioning and creating changelogs. | ||
|
||
As a contributor you need to add a changeset by running `yarn changeset`. | ||
The command will prompt to select the packages that should be bumped, their associated semver bump types and some markdown which will be inserted into the changelogs. | ||
|
||
When opening a Pull Request, a `changeset-bot` checks that the Pull Request contains a changeset. A changeset is **NOT required**, as things like documentation or other changes in the repository itself generally don't need a changeset. | ||
|
||
## Releasing packages | ||
|
||
commercetools sdk-typescript uses [changesets](https://github.com/atlassian/changesets) to do versioning and publishing a release. | ||
|
||
A [Changesets release GitHub Action](https://github.com/changesets/action) opens a `Version Packages` Pull Request whenever there are some changesets that have not been released yet. | ||
|
||
When the `Version Packages` Pull Request gets merged, the Changesets release GitHub Action will automatically trigger the release. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
# commercetools typescript sdks | ||
|
||
<img src="http://dev.commercetools.com/assets/img/CT-logo.svg" width="550px" alt="CT-logo"></img> | ||
<h2 align="center">commercetools TypeScript SDKs 💅</h2> | ||
<p align="center"> | ||
<i>✨ Monorepository with generated TypeScript SDKs for the commercetools platform 🛠</i> | ||
</p> | ||
|
||
## Introduction | ||
|
||
This repository contains the commercetools platform, import-api and machine learning packages for typescript generated from our api reference. | ||
|
||
<p align="center"> | ||
|
||
</p> | ||
This repository contains several SDK packages generated from the commercetools platform API reference. | ||
|
||
## Support | ||
|
||
|
@@ -23,10 +20,13 @@ If you have any urgent issues regarding this repository please create a support | |
| [`platform-sdk`](/packages/platform-sdk) | [![platform-sdk Version][platform-sdk-icon]][platform-sdk-version] | | ||
| [`importapi-sdk`](/packages/importapi-sdk) | [![importapi-sdk Version][importapi-sdk-icon]][importapi-sdk-version] | | ||
| [`ml-sdk`](/packages/ml-sdk) | [![ml-sdk Version][ml-sdk-icon]][ml-sdk-version] | | ||
| [`history-sdk`](/packages/history-sdk) | [![history-sdk Version][history-sdk-icon]][history-sdk-version] | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was it forgotten or was it omitted on purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note sure, but I think it's fine to have it as part of the packages listed in the README.md |
||
|
||
[platform-sdk-version]: https://www.npmjs.com/package/@commercetools/platform-sdk | ||
[platform-sdk-icon]: https://img.shields.io/npm/v/@commercetools/platform-sdk.svg?style=flat-square | ||
[importapi-sdk-version]: https://www.npmjs.com/package/@commercetools/platform-sdk | ||
[importapi-sdk-icon]: https://img.shields.io/npm/v/@commercetools/platform-sdk.svg?style=flat-square | ||
[ml-sdk-version]: https://www.npmjs.com/package/@commercetools/platform-sdk | ||
[ml-sdk-icon]: https://img.shields.io/npm/v/@commercetools/platform-sdk.svg?style=flat-square | ||
[importapi-sdk-version]: https://www.npmjs.com/package/@commercetools/importapi-sdk | ||
[importapi-sdk-icon]: https://img.shields.io/npm/v/@commercetools/importapi-sdk.svg?style=flat-square | ||
[ml-sdk-version]: https://www.npmjs.com/package/@commercetools/ml-sdk | ||
[ml-sdk-icon]: https://img.shields.io/npm/v/@commercetools/ml-sdk.svg?style=flat-square | ||
[history-sdk-version]: https://www.npmjs.com/package/@commercetools/history-sdk | ||
[history-sdk-icon]: https://img.shields.io/npm/v/@commercetools/history-sdk.svg?style=flat-square |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* @type {import('@babel/core').TransformOptions} | ||
*/ | ||
module.exports = { | ||
presets: ['@babel/env', '@babel/preset-typescript'], | ||
plugins: ['@babel/proposal-class-properties'], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
module.exports = { extends: ['@commitlint/config-conventional'] } | ||
/* eslint-disable */ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
parserPreset: { | ||
parserOpts: { | ||
// Allow to write a "scope" with slashes | ||
// E.g. `refactor(app/my-component): something` | ||
headerPattern: /^(\w*)(?:\(([\w\$\.\/\-\* ]*)\))?\: (.*)$/, | ||
}, | ||
}, | ||
rules: { | ||
'header-max-length': [0, 'always', 100], | ||
}, | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @type {import('@jest/types').Config.ProjectConfig} | ||
*/ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.js$': 'babel-jest', | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
testRegex: '\\.(test|spec)\\.[j|t]sx?$', | ||
moduleFileExtensions: ['ts', 'js', 'json'], | ||
watchPlugins: ['jest-watch-typeahead/filename'], | ||
reporters: [ | ||
'default', | ||
process.env.CI === 'true' | ||
? [ | ||
'jest-junit', | ||
{ outputName: 'results.xml', outputDirectory: 'test-results' }, | ||
] | ||
Comment on lines
+17
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know why are we using and storing test results as artifacts? Are they used somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, but I will also look into it. |
||
: null, | ||
].filter(Boolean), | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,48 @@ | ||
{ | ||
"name": "root", | ||
"name": "commercetools-sdk-typescript", | ||
"private": true, | ||
"devDependencies": { | ||
"@changesets/changelog-github": "0.4.0", | ||
"@changesets/cli": "2.16.0", | ||
"@commitlint/config-conventional": "8.3.4", | ||
"@rollup/plugin-typescript": "3.0.0", | ||
"husky": "4.3.8", | ||
"lerna": "3.20.2", | ||
"prettier": "1.19.1", | ||
"rimraf": "3.0.2" | ||
}, | ||
"workspaces": ["packages/*"], | ||
"scripts": { | ||
"generate": "lerna run generate && yarn format", | ||
"prepare": "husky install", | ||
"postinstall": "manypkg check && preconstruct dev", | ||
"generate": "manypkg run generate && yarn format", | ||
"format": "prettier --write '**/*.{js,ts,json,md}'", | ||
"build": "lerna run build", | ||
"test": "lerna run test", | ||
"pre-commit": "lerna run precommit", | ||
"build": "preconstruct build", | ||
"test": "jest --maxWorkers=2", | ||
"typecheck": "tsc --noEmit", | ||
"changeset": "changeset", | ||
"changeset:version-and-format": "changeset version && prettier --write --parser json '**/package.json'" | ||
}, | ||
"workspaces": ["packages/*"], | ||
"dependencies": { | ||
"@babel/core": "7.15.0", | ||
"@babel/plugin-proposal-class-properties": "7.14.5", | ||
"@babel/preset-env": "7.15.0", | ||
"@babel/preset-typescript": "7.15.0", | ||
"@changesets/changelog-github": "0.4.0", | ||
"@changesets/cli": "2.16.0", | ||
"@commitlint/cli": "13.1.0", | ||
"@commitlint/config-conventional": "13.1.0", | ||
"@manypkg/cli": "0.18.0", | ||
"@preconstruct/cli": "2.1.0", | ||
"@types/jest": "27.0.0", | ||
"@types/node": "14.14.31", | ||
"babel-jest": "27.0.6", | ||
"husky": "7.0.1", | ||
"jest": "27.0.6", | ||
"jest-junit": "12.2.0", | ||
"jest-watch-typeahead": "0.6.4", | ||
"lint-staged": "11.1.2", | ||
"prettier": "1.19.1", | ||
"rimraf": "3.0.2", | ||
"ts-jest": "27.0.4", | ||
"tsc-files": "1.1.2", | ||
"typescript": "4.3.5" | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts,json,md}": "yarn format" | ||
"*.{js,json,md}": ["prettier --write"], | ||
"*.ts": ["prettier --write", "tsc-files --noEmit"] | ||
}, | ||
"preconstruct": { | ||
"packages": ["packages/*"] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimized image for circleci