Skip to content

Refactor/monorepo #12

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

Merged
merged 7 commits into from
Mar 21, 2025
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
6 changes: 6 additions & 0 deletions .changeset/ten-views-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@chialab/sveltekit-utils": minor
"@chialab/sveltekit-dev-utils": minor
---

Refactor to monorepo with configs and utils packages
45 changes: 0 additions & 45 deletions .eslintrc.cjs

This file was deleted.

28 changes: 11 additions & 17 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,26 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: yarn

- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Setup Yarn cache
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: pnpm

- name: Install project dependencies
run: yarn install
run: pnpm install

- name: Check
run: yarn run check
run: pnpm run check
working-directory: packages/utils

- name: Check eslint
run: yarn run eslint-check
run: pnpm run eslint-check
working-directory: packages/utils

- name: Check prettier
run: yarn run prettier-check
run: pnpm run prettier-check
working-directory: packages/utils
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: yarn
cache: pnpm

- name: Install project dependencies
run: yarn install
run: pnpm install

- name: Build project
run: yarn build
run: pnpm build
working-directory: packages/utils

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn changeset publish
publish: pnpm changeset publish
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
26 changes: 10 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,17 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn

- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Setup Yarn cache
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: pnpm

- name: Install project dependencies
run: yarn install
run: pnpm install

- name: Setup Playwright cache
uses: actions/cache@v4
Expand All @@ -42,12 +33,15 @@ jobs:
key: ${{ runner.os }}-playwright

- name: Install Playwright browsers
run: yarn run playwright install --with-deps
run: pnpm playwright install --with-deps
working-directory: packages/utils

- name: Check
run: yarn run test:unit:coverage
run: pnpm run test:unit:coverage
working-directory: packages/utils

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
directory: packages/utils
token: ${{ secrets.CODECOV_TOKEN }}
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.DS_Store
node_modules
/dist
/.svelte-kit
dist
/package
/public
/.env.production
/.env.*.local
public
.env.production
.env.*.local
/*.log
/tests/coverage/
**/tests/coverage/
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
*.tsbuildinfo
.pnpm-cache
.svelte-kit
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,59 @@
# SvelteKit Utils

**SvelteKit Utils** is a set of libraries and utilities to improve the development experience with [SvelteKit](https://kit.svelte.dev/).
**SvelteKit Utils** is a collection of utilities and configurations to improve the development experience with [SvelteKit](https://kit.svelte.dev/).
There are actually 2 packages in this repository:
- @chialab/sveltekit-utils: A set of utility types and functions
- @chialab/sveltekit-dev-utils: A set of configurations (eslint, stylelint, prettier)

`sveltekit-dev-utils` package is meant to be used as a dev dependency, while `sveltekit-utils` is meant to be used as a dependency.

## Usage

Package is distribuited as NPM packages through the official NPM registry.
Packages are distribuited as NPM packages through the official NPM registry.

### Install

Then, you can use the `npm` cli or the `yarn` package manager to install the package as a dependency:
You can use the `npm` cli or the `pnpm` package manager to install the package as a dependency:

```
```sh
npm install @chialab/sveltekit-utils
```

```sh
pnpm add @chialab/sveltekit-utils
```

```sh
npm install @chialab/sveltekit-dev-utils
```

```sh
pnpm add @chialab/sveltekit-dev-utils
```

`svelte-dev-utils` exports 3 config that you can use as follows:

For example for the eslint config create the `eslint.config.js` file in the root of your project and add the following:

```js
import cfg from '@chialab/sveltekit-dev-utils/eslint-config';

export default cfg;
```
yarn add @chialab/sveltekit-utils

You can extend the config as follows:

```js
import cfg from '@chialab/sveltekit-dev-utils/eslint-config';

export default [
...cfg,
{
rules: {
'no-console': 'off'
}
}
];
```

## License
Expand Down
85 changes: 5 additions & 80 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,86 +1,11 @@
{
"name": "@chialab/sveltekit-utils",
"name": "@chialab/sveltekit-tools",
"version": "0.0.2",
"license": "MIT",
"version": "0.1.0-alpha.2",
"description": "A collection of utilities and configurations for SvelteKit projects.",
"type": "module",
"files": [
"dist",
".eslintrc.cjs"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"svelte": "./dist/index.js",
"default": "./dist/index.js"
},
"./server": {
"types": "./dist/server/index.d.ts",
"node": "./dist/server/index.js",
"svelte": null,
"default": null
},
"./logger": {
"types": "./dist/logger.d.ts",
"default": "./dist/logger.js"
},
"./utils": {
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.js"
}
},
"scripts": {
"dev": "vite dev",
"start": "yarn dev",
"build": "svelte-kit sync && svelte-package",
"app:build": "vite build",
"app:preview-build": "vite preview | pino-pretty",
"test:unit": "vitest run",
"test:unit:coverage": "vitest run --coverage",
"test:unit:watch": "vitest watch",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"eslint-check": "eslint --ignore-path .gitignore . --ext .js,.cjs,.ts,.svelte",
"eslint-fix": "eslint --fix --ignore-path .gitignore . --ext .js,.cjs,.ts,.svelte",
"prettier-check": "prettier --check \"./**/*.{json,css,js,cjs,ts,svelte}\"",
"prettier-fix": "prettier --write \"./**/*.{json,css,js,cjs,ts,svelte}\"",
"lint": "yarn run check && yarn run eslint-check && yarn run prettier-fix",
"lint-fix-all": "yarn run eslint-fix && yarn run prettier-fix"
},
"dependencies": {
"@heyputer/kv.js": "fquffio/kv.js#fix/strict-mode",
"cookie": "^1.0.2",
"pino": "^9.5.0",
"redis": "^4.7.0",
"xml-js": "^1.6.11"
},
"devDependencies": {
"@changesets/cli": "^2.27.10",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.8.1",
"@sveltejs/package": "^2.3.7",
"@sveltejs/vite-plugin-svelte": "^5.0.0",
"@types/node": "^22.9.1",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@vitest/browser": "^3.0.5",
"@vitest/coverage-v8": "^3.0.5",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.46.0",
"pino-pretty": "^13.0.0",
"playwright": "^1.50.1",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.3.1",
"svelte": "^5.0.0",
"svelte-check": "^4.1.4",
"tslib": "^2.8.1",
"typescript": "^5.6.3",
"vite": "^6.0.0",
"vitest": "^3.0.5"
},
"peerDependencies": {
"@sveltejs/kit": "^2.0.0",
"svelte": "^4.2.1 || ^5.0.0"
"@changesets/cli": "^2.27.10"
},
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
"packageManager": "pnpm@10.6.2+sha256.20072a1f6edd17646ea9234bf32c42d563dad37b2973e97a2dde5c17774a824d"
}
1 change: 1 addition & 0 deletions .prettierignore → packages/dev-utils/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
pnpm-workspace.yaml
.pnpm-cache
5 changes: 3 additions & 2 deletions .prettierrc → packages/dev-utils/.prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
/** @type {import('prettier').Config} */
export default {
"printWidth": 120,
"tabWidth": 2,
"useTabs": true,
Expand All @@ -11,4 +12,4 @@
"endOfLine": "auto",
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
};
Loading