Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends:
- "@commitlint/config-angular"
- '@commitlint/config-angular'
rules:
'header-max-length': [2, 'always', 100]
4 changes: 2 additions & 2 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://docs.github.com/en/enterprise-cloud@latest/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment
# The copilot-setup-steps.yml workflow won't trigger unless it's present on your main branch.
name: "Copilot Setup Steps"
name: 'Copilot Setup Steps'

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
Expand Down Expand Up @@ -33,4 +33,4 @@ jobs:
cache: 'npm'

- name: GitHub registry Auth & Install Dependencies
run: npm ci
run: npm ci
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
name: Check for execution
uses: shiftcode/[email protected]
with:
skipOnCommitMsg: "[skip_build]"
skipOnCommitMsg: '[skip_build]'
githubToken: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx lint-staged && npx lerna exec --concurrency 1 --stream lint-staged
npx lerna exec --concurrency 1 --stream lint-staged && npx lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
./package.json:
- npx sort-package-json

'*':
- npm run format:staged
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@

Public helper packages with commonly used utilities / helpers.

> [![@shiftcode/branch-utilities](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Fbranch-utilities%2Fpackage.json&label=%40shiftcode%2Fbranch-utilities)](packages/branch-utilities) \
> functions to read information about the current branch either locally or inside Github actions.

>[![@shiftcode/branch-utilities](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Fbranch-utilities%2Fpackage.json&label=%40shiftcode%2Fbranch-utilities)](packages/branch-utilities) \
>functions to read information about the current branch either locally or inside Github actions.
> [![@shiftcode/eslint-config-recommended](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Feslint-config-recommended%2Fpackage.json&label=%40shiftcode%2Feslint-config-recommended)](packages/eslint-config-recommended) \
> Our recommended config for eslint. We provide two versions, one for usage in node projects and one for Angular.

>[![@shiftcode/eslint-config-recommended](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Feslint-config-recommended%2Fpackage.json&label=%40shiftcode%2Feslint-config-recommended)](packages/eslint-config-recommended) \
>Our recommended config for eslint. We provide two versions, one for usage in node projects and one for Angular.
> [![@shiftcode/eslint-plugin-rules](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Feslint-plugin-rules%2Fpackage.json&label=%40shiftcode%2Feslint-plugin-rules)](packages/eslint-plugin-rules) \
> Contains some custom es lint rules. Those are used in our recommended eslint config.

>[![@shiftcode/eslint-plugin-rules](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Feslint-plugin-rules%2Fpackage.json&label=%40shiftcode%2Feslint-plugin-rules)](packages/eslint-plugin-rules) \
>Contains some custom es lint rules. Those are used in our recommended eslint config.

>[![@shiftcode/publish-helper](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Fpublish-helper%2Fpackage.json&label=%40shiftcode%2Fpublish-helper)](packages/publish-helper)\
>scripts to prepare and publish libs inside mono-repos with lerna
> [![@shiftcode/publish-helper](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Fpublish-helper%2Fpackage.json&label=%40shiftcode%2Fpublish-helper)](packages/publish-helper)\
> scripts to prepare and publish libs inside mono-repos with lerna

>[![@shiftcode/utilities](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Futilities%2Fpackage.json&label=%40shiftcode%2Futilities)](packages/utilities)\
>various utility functions, constants and helper types - usable in Node and Browsers
> [![@shiftcode/utilities](https://img.shields.io/github/package-json/v/shiftcode/sc-commons-public?filename=packages%2Futilities%2Fpackage.json&label=%40shiftcode%2Futilities)](packages/utilities)\
> various utility functions, constants and helper types - usable in Node and Browsers

## Usage

Add a `.npmrc` file to the root of your project:

```
@shiftcode:registry=https://npm.pkg.github.com
```

## Quick Start
* `npm i`
* `npm run build`
* start developing

- `npm i`
- `npm run build`
- start developing

## Versioning

When opening a PR lerna publishes a new prerelease version with the preId `-prXX.{COUNT}`.
By creating this version lerna creates a commit with the updated versions in the package.json. It does not update the `peerDependencies` versions.

Expand All @@ -39,26 +41,31 @@ After merging the PR back to the master a new release is published with the grad
> ensure your branch is named correctly by the convention `#XX-name` where `XX` is your github issue number.

### Hint

If it happens that you already have another commit locally, before updating the branch with this `build(release):..` commit:
> use `rebase` instead of `merge`

> use `rebase` instead of `merge`

## Anatomy of the repo

We use lerna to manage the packages.

- For lerna to know the topological order of packages, we define the dependencies between the packages in each individual package as `devDependency`
- For testing reasons we compile against the source code to run tests without prior compiling of the source, this requires `tsconfig.paths` definitions and also `moduleNameMapper` in `jest.config.js`

## ES Version

We support two runtimes: `node` and `latest browser versions`.

### Node 22
Node 22 (which is also supported by AWS Lambda) supports [97%](https://node.green/#ES2022) of `es2022` features

Node 22 (which is also supported by AWS Lambda) supports [97%](https://node.green/#ES2022) of `es2022` features
(no version supports 100%) and [100%](https://node.green/#ES2023) of `es2023` features.
The only `es2022` feature that is currently not supported and needs a polyfill when using it is
[RegExp Match Indices (shows up in flags)](https://node.green/#ES2022-features-RegExp-Match-Indices---hasIndices-----d--flag-) (see [2ality blog](https://2ality.com/2019/12/regexp-match-indices.html) for insights).
[RegExp Match Indices (shows up in flags)](https://node.green/#ES2022-features-RegExp-Match-Indices---hasIndices-----d--flag-) (see [2ality blog](https://2ality.com/2019/12/regexp-match-indices.html) for insights).
Polyfill can be found here: https://www.npmjs.com/package/regexp-match-indices.

### Browser

For modern browsers the latest fully supported version is `es2023` (see [can-i-use](https://caniuse.com/?search=es2023))
which therefore is the target for `@shiftcode/utilities` package (see [package README](./packages/utilities/README.md)).
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"scripts": {
"build:ci": "lerna run build",
"build:lint:ci": "lerna run build --scope @shiftcode/eslint-plugin-rules && lerna run build --scope @shiftcode/eslint-config-recommended",
"format": "lerna run format",
"format:ci": "lerna run format:ci",
"format": "prettier --write .",
"format:ci": "prettier --check .",
"format:staged": "prettier --write --ignore-unknown",
"lint:ci": "lerna run lint:ci",
"prepare": "husky",
"publish-libs": "node packages/publish-helper/dist/publish-lib",
Expand Down
9 changes: 3 additions & 6 deletions packages/branch-utilities/.lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Reformat all .ts / .js
"**/*.(t|j)s":
- npm run format:staged
'{src,test}/**/*.(t|j)s':
- npm run lint:staged

# sort package.json keys
./package.json:
- sort-package-json
'./package.json':
- sort-package-json
2 changes: 1 addition & 1 deletion packages/branch-utilities/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shiftcode/branch-utilities",
"version": "5.1.0",
"version": "5.1.1-pr67.0",
"description": "Utilities for local and ci to get branch name and stage",
"repository": "https://github.com/shiftcode/sc-commons-public",
"license": "MIT",
Expand Down
6 changes: 1 addition & 5 deletions packages/branch-utilities/tsconfig.jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@
"compilerOptions": {
"baseUrl": "./"
},
"include": [
"src/**/*.spec.ts",
"test/**/*.ts"
]
"include": ["src/**/*.spec.ts", "test/**/*.ts"]
}

6 changes: 1 addition & 5 deletions packages/branch-utilities/tsconfig.lint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"baseUrl": "./",
"types": ["jest", "node"]
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
],
"include": ["src/**/*.ts", "test/**/*.ts"],
"exclude": []
}

7 changes: 2 additions & 5 deletions packages/eslint-config-recommended/.lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Reformat all .ts / .js
"**/*.(t|j)s":
- npm run format:staged
'{src,test}/**/*.(t|j)s':
- npm run lint:staged

# sort package.json keys
./package.json:
'./package.json':
- sort-package-json
9 changes: 5 additions & 4 deletions packages/eslint-config-recommended/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

> 🎯 Target runtime: es2023 ([Node >= 20](https://node.green/#ES2023))


This module provides an eslint default rule-set configuration for shiftcode projects.

### remark

By using this module, the [@shiftcode/eslint-plugin-rules](../eslint-plugin-rules) module will be automatically installed
as dependency.

## usage

the module only exports a single function `defineScTsConfig` which can be used to create the eslint configuration.
it is basically a wrapper around the new eslint `defineConfig` function but already includes the setup for typescript,
some rules with default configurations and will ensure the prettier rules (disabling formatting rules) are included at last.
Expand All @@ -32,13 +33,13 @@ export default defineScTsConfig(
rules: {
'@typescript-eslint/explicit-function-return-type': 'error',
},
}
},
)
```

## Additional configurations

Additionally on the submodule `/angular` the `defineScAngularConfig` function is exported
Additionally on the submodule `/angular` the `defineScAngularConfig` function is exported
which includes angular-specific rules and configurations.

```js
Expand All @@ -59,7 +60,7 @@ export default defineScAngularConfig(
rules: {
'@angular-eslint/component-selector': ['error', { type: 'element', prefix: 'gf', style: 'kebab-case' }],
},
}
},
)
```

Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-recommended/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shiftcode/eslint-config-recommended",
"version": "6.0.0",
"version": "6.0.1-pr67.0",
"description": "default shiftcode config for eslint",
"repository": "https://github.com/shiftcode/sc-commons-public",
"license": "UNLICENSED",
Expand Down Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@eslint/js": "^9.37.0",
"@shiftcode/eslint-plugin-rules": "^5.0.0",
"@shiftcode/eslint-plugin-rules": "^5.0.1-pr67.0",
"eslint": "^9.37.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.32.0",
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config-recommended/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
"declarationDir": "./dist",
"types": ["node"]
},
"include": [
"src/**/*.ts"
]
"include": ["src/**/*.ts"]
}
6 changes: 1 addition & 5 deletions packages/eslint-config-recommended/tsconfig.lint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"@shiftcode/eslint-plugin-rules": ["../eslint-plugin-rules/src/index.ts"]
}
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
],
"include": ["src/**/*.ts", "test/**/*.ts"],
"exclude": []
}

9 changes: 3 additions & 6 deletions packages/eslint-plugin-rules/.lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Reformat all .ts / .js
"**/*.(t|j)s":
- npm run format:staged
'{src,test}/**/*.(t|j)s':
- npm run lint:staged

# sort package.json keys
./package.json:
- sort-package-json
'./package.json':
- sort-package-json
Loading