Skip to content

Commit

Permalink
Merge pull request #1 from svelte-plugins/updates
Browse files Browse the repository at this point in the history
 🏗 refactor(scripts): update readme and build scripts to simplify dev
  • Loading branch information
dysfunc authored Nov 25, 2023
2 parents e5de333 + efe6036 commit f191a03
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 54 deletions.
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,107 @@

A Svelte seed project for creating components.

## TLDR;

```vim
> npm i
> npx husky install
> chmod +x .husky/post-merge && chmod +x .husky/pre-commit && cp .husky/post-merge .git/hooks
> npm start
```

## Setting up development envirnoment

1. Install dependencies

```vim
> npm i
```

2. Install `husky` hooks

```vim
> npx husky install
```

3. Make sure husky scripts are executable and copied to .git/hooks

```vim
> chmod +x .husky/post-merge && chmod +x .husky/pre-commit && cp .husky/post-merge .git/hooks
```

4. Start the component dev server and the document server

```vim
> npm start
```
5. Happy coding! You're changes will be automatically rebuilt and reflected immediately on the docs.
## Testing
Running either of these commands will execute all unit tests.
| Command | Notes |
| -------------------------------- | ---------------------------------------------------- |
| `npm test` | Single run with no coverage report |
| `npm test:watch` | Watches for changes |
| `npm test:coverage` | Executes tests and launches a coverage report |
Run all tests
```vim
> npm test
```

Run a specific test
```vim
> npm test [path-to-test-file]
```

Run all tests and generate a code coverage report
```vim
> npm test:coverage
```

## Deploying Documentation

Run the deploy command to automaically build the docs source and push it to `gh-pages`.

```vim
> npm run deploy
```

## Publishing Package

You can publish your package via `NPM`:

1. Adjust the major, minor or patch version in the `version` property of your `package.json`.
2. [Login](https://www.npmjs.com/login) or [create](https://www.npmjs.com/signup) an `NPM` account.
3. Run `npm run publish`

If you are looking for a private publish or other types, follow the guide [here](https://gist.github.com/coolaj86/1318304).

## Stack
### Framework
- [Svelte](https://svelte.dev/) - Blazing fast frontend framework that enhances HTML, CSS & JS

### Testing
- [Vitest](https://vitest.dev/) - Next Generation Testing Framework

### CI/CD
- [GitHub Actions](https://docs.github.com/en/actions) - Automate, customize, and execute workflows in your repository with GitHub Actions.

### Development
- [Vite](https://vitejs.dev/) - Next Generation Frontend Tooling
- [Babel](https://babeljs.io/) - JavaScript compiler that allows next generation JS, today
- [Prettier](https://prettier.io/) - An opinionated code formatter
- [ESLint](https://eslint.org/) - A static code analysis tool for finding issues in your code
- [Husky](https://typicode.github.io/husky/) - Hooks for running linting, formatting, etc when you push or commit
- [Lint-staged](https://github.com/lint-staged/lint-staged) - Run linters on git staged files

## Changelog

[Changelog](CHANGELOG.md)
Expand Down
57 changes: 13 additions & 44 deletions docs/package-lock.json

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

1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@svelte-plugins/svelte-component-template": "../",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"autoprefixer": "^10.4.16",
"sass": "^1.69.5",
"svelte": "^4.2.7",
"svelte-prismjs": "^1.0.2",
"vite": "^5.0.2"
Expand Down
5 changes: 4 additions & 1 deletion docs/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default defineConfig(({ command, mode }) => {
},
plugins: [
svelte()
]
],
server: {
open: true
}
}
})
4 changes: 2 additions & 2 deletions package-lock.json

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

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@svelte-plugins/svelte-component-template",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",
"description": "A Svelte seed project for creating components.",
"author": "Kieran Boyle (https://github.com/dysfunc)",
Expand All @@ -17,7 +17,7 @@
"homepage": "@svelte-plugins/svelte-component-template",
"bugs": "@svelte-plugins/svelte-component-template/issues",
"keywords": [
"components",
"library",
"component",
"template",
"seed",
Expand All @@ -31,12 +31,17 @@
"/dist"
],
"scripts": {
"start": "npm --prefix ./docs install && vite & npm --prefix ./docs run dev",
"dev": "vite",
"bundle": "vite build",
"deploy": "npx gh-pages -d docs/build",
"build": "vite build",
"build:docs": "npm --prefix ./docs run build",
"deploy": "npm run build:docs && npx gh-pages -d docs/build",
"publish": "npm run build && npm publish --access=public",
"lint": "eslint -c ./.eslintrc.json --fix \"src/**/*.{.js,svelte}\"",
"format": "prettier --write \"src/**/*.{js,json,svelte}\"",
"test": "vitest --run --coverage"
"test": "vitest --run",
"test:watch": "vitest",
"test:coverage": "vitest --run --coverage && open ./coverage/index.html"
},
"devDependencies": {
"@babel/core": "^7.23.3",
Expand All @@ -63,7 +68,10 @@
"exports": {
".": {
"types": "./src/index.d.ts",
"svelte": "./src/index.js"
"svelte": "./src/index.js",
"require": "./dist/index.js",
"module": "./dist/index.mjs",
"default": "./src/index.js"
}
}
}
8 changes: 7 additions & 1 deletion src/component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ export interface ComponentProps {
* The text to display in the component.
* @default 'Hello!'
*/
text: string;
content: string;

/**
* Whether the component is disabled.
* @default false
*/
disabled: boolean;
}

export default class Component extends SvelteComponent<
Expand Down

0 comments on commit f191a03

Please sign in to comment.