Skip to content

Commit

Permalink
chore: add solid application template
Browse files Browse the repository at this point in the history
  • Loading branch information
jdanil committed Jul 28, 2024
1 parent b6bef41 commit 44fda0c
Show file tree
Hide file tree
Showing 49 changed files with 1,380 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ This provides a separation of concerns and allows for sustainable growth.
- [plugin](templates/plugin/README.md) - template to bootstrap new plugins.
- [react-application](templates/react-application/README.md) - template to bootstrap new react applications.
- [react-library](templates/react-library/README.md) - template to bootstrap new react libraries.
- [solid-application](templates/react-application/README.md) - template to bootstrap new solid applications.

## Stack

Expand Down
2 changes: 1 addition & 1 deletion applications/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"start": "yarn start:development",
"start:development": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack serve --config webpack/config/development.ts",
"start:production": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack serve --config webpack/config/production.ts",
"test": "yarn compile && jest --config .jestrc.json --passWithNoTests",
"test": "yarn compile && jest --config .jestrc.json",
"test:ci": "yarn test --ci",
"test:ci:branch": "yarn test:ci --changedSince master"
},
Expand Down
2 changes: 1 addition & 1 deletion templates/react-application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"start": "yarn start:development",
"start:development": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack serve --config webpack/config/development.ts",
"start:production": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack serve --config webpack/config/production.ts",
"test": "yarn compile && jest --config .jestrc.json --passWithNoTests",
"test": "yarn compile && jest --config .jestrc.json",
"test:ci": "yarn test --ci",
"test:ci:branch": "yarn test:ci --changedSince master"
},
Expand Down
2 changes: 1 addition & 1 deletion templates/react-application/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "@playwright/test";
// eslint-disable-next-line node/no-process-env -- check `process.env` to detect ci environment
const CI = !!process.env.CI;
const ROOT_DIR = "playwright";
const URL = "http://localhost:8080";
const URL = "http://localhost:3520";

// eslint-disable-next-line no-restricted-exports, import/no-default-export -- playwright requires default export
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion templates/react-application/webpack/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
overlay: false,
},
historyApiFallback: true,
port: 8080,
port: 3520,
},
entry: sourcePath("index.tsx"),
experiments: {
Expand Down
6 changes: 6 additions & 0 deletions templates/solid-application/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
> 5%
last 1 versions
Firefox ESR
not dead
not ie >= 11
not ie_mob >= 11
14 changes: 14 additions & 0 deletions templates/solid-application/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.css
*.ejs
*.json
*.md
*.svg
*.tgz
*.tsbuildinfo
*.yaml
build/
cache/
coverage/
dist/
playwright/artifacts/
playwright/report/
41 changes: 41 additions & 0 deletions templates/solid-application/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extends:
- "@package/eslint-config"
overrides:
- files:
- "src/index.{[cm]js,[jt]s?(x)}"
rules:
filenames/no-index: off # whitelist entry point
import/no-unused-modules: off # whitelist entry point
- files:
- "playwright/**/*"
settings:
disable/plugins:
- jest # plugin mistakes playwright tests for jest tests
- testing-library # plugin mistakes playwright test for jest tests
- files:
- "src/**/*"
rules:
node/file-extension-in-import: off # src code does not run on node runtime
node/no-unsupported-features/es-syntax: off # src code does not run on node runtime
- files:
- "!playwright/**/*"
rules: # plugin mistakes jest tests for playwright tests
playwright/no-duplicate-hooks: off
playwright/no-standalone-expect: off
playwright/require-top-level-describe: off
- files:
- "test/resolver.js"
settings:
disable/plugins:
- "@typescript-eslint" # resolver cannot be typescript
parserOptions:
project: "./tsconfig.eslint.json"
rules:
unicorn/prevent-abbreviations:
- error
- allowList:
Props: true # common abbreviation
i18n: true # common numeronym
props: true # common abbreviation
settings:
import/internal-regex: ^@(application|component|library|service)
21 changes: 21 additions & 0 deletions templates/solid-application/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# cache
cache/

# eslint
.eslintcache

# jest
coverage/

# playwright
playwright/artifacts/
playwright/report/

# typescript
*.tsbuildinfo
build/

# webpack
dist/
7 changes: 7 additions & 0 deletions templates/solid-application/.jestrc.development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"moduleNameMapper": {
"\\.css$": "<rootDir>/test/style-mock.ts"
},
"preset": "@package/jest-config/presets/development",
"roots": ["<rootDir>/src"]
}
25 changes: 25 additions & 0 deletions templates/solid-application/.jestrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"moduleNameMapper": {
"^.+\\.css$": "<rootDir>/test/style-mock.ts"
},
"preset": "@package/jest-config",
"resolver": "./test/resolver.js",
"roots": ["<rootDir>/src"],
"setupFilesAfterEnv": [
"@testing-library/jest-dom",
"jest-extended/all",
"<rootDir>/test/setup.ts"
],
"testEnvironment": "./test/jsdom.ts",
"transform": {
"^.+\\.m?[jt]sx?$": [
"ts-jest",
{
"babelConfig": {
"presets": ["@babel/preset-env", "solid"]
},
"tsconfig": "./tsconfig.test.json"
}
]
}
}
9 changes: 9 additions & 0 deletions templates/solid-application/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"*": [
"eslint --cache --cache-strategy=content --fix",
"prettier --cache --write"
],
"*.{[cm]js,[jt]s?(x)}": ["yarn test --bail --findRelatedTests"],
"*.md": ["markdownlint --fix"],
"webpack/**/*": ["yarn build:development:test", "yarn build:production:test"]
}
3 changes: 3 additions & 0 deletions templates/solid-application/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@package/markdownlint-config"
}
5 changes: 5 additions & 0 deletions templates/solid-application/.markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/
cache/
coverage/
dist/
node_modules/
3 changes: 3 additions & 0 deletions templates/solid-application/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.tgz
.*ignore
.browserslistrc
13 changes: 13 additions & 0 deletions templates/solid-application/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
...require("@package/prettier-config"),
overrides: [
{
files: "*.ejs",
options: { parser: "html" },
},
{
files: "*.svg",
options: { parser: "html" },
},
],
};
31 changes: 31 additions & 0 deletions templates/solid-application/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# `@application/solid-application`

A solid application.

## Stack

- [Jest](https://facebook.github.io/jest/) - JavaScript testing framework.
- [SolidJS](https://www.solidjs.com/) - JavaScript library for building user interfaces.
- [Testing Library](https://testing-library.com/) - Testing utilities.
- [TypeScript](https://www.typescriptlang.org/) - A typed superset of JavaScript that compiles to plain JavaScript.

## To Do

- [ ] update `package.json` manifest description
- [ ] update `README.md` title
- [ ] update `README.md` description
- [ ] add package to root `README.md` structure
- [ ] update port number
- [ ] remove this checklist

```typescript
import("node:crypto").then(({ createHash }) => {
const input = "<package.name>";

const hashRaw = createHash("whirlpool").update(input);
const hashHex = hashRaw.digest("hex");
const hashInt = parseInt(hashHex, 16) % Math.pow(10, 4);

console.log(hashInt);
});
```
14 changes: 14 additions & 0 deletions templates/solid-application/bundlesize.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": [
{
"path": "./dist/**/main.?(m)js",
"maxSize": "100 kB",
"compression": "brotli"
},
{
"path": "./dist/**/*.?(m)js",
"maxSize": "750 kB",
"compression": "brotli"
}
]
}
112 changes: 112 additions & 0 deletions templates/solid-application/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"name": "@application/solid-application",
"version": "0.1.0",
"private": true,
"description": "> TODO: description",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/jdanil/skunkworks.git",
"directory": "templates/solid-application"
},
"main": "dist/index.js",
"directories": {
"dist": "dist"
},
"files": [
"dist"
],
"engines": {
"node": "^20 || >=22"
},
"scripts": {
"build": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack --config webpack/config/production.ts",
"build:development:test": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack configtest webpack/config/development.ts",
"build:production:test": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack configtest webpack/config/production.ts",
"bundlesize": "bundlesize",
"clean": "run-p 'clean:*'",
"clean:test": "yarn test --clearCache",
"clean:tsc": "yarn compile --clean",
"clean:webpack": "rimraf dist",
"compile": "tsc --build",
"format": "prettier --cache",
"format:all": "yarn format .",
"format:all:check": "yarn format:all --check",
"format:all:write": "yarn format:all --write",
"format:diff": "pretty-quick",
"format:diff:check": "yarn format:diff --check",
"format:diff:write": "yarn format:diff",
"lint": "run-s lint:es lint:md",
"lint:all": "run-s 'lint:*:all'",
"lint:diff": "run-s 'lint:*:diff'",
"lint:es": "eslint --cache --cache-strategy=content",
"lint:es:all": "yarn lint:es \"**/*\"",
"lint:es:diff": "FILES=$(git diff --diff-filter=ACMRTUB --name-only --relative master); [ -z ${FILES} ] || yarn lint:es --no-error-on-unmatched-pattern ${FILES}",
"lint:md": "markdownlint",
"lint:md:all": "yarn lint:md \"**/*.md\"",
"lint:md:diff": "FILES=$(git diff --diff-filter=ACMRTUB --name-only --relative master); [ -z ${FILES} ] || yarn lint:md:all",
"playwright": "playwright test",
"precommit": "lint-staged",
"prepack": "yarn build",
"start": "yarn start:development",
"start:development": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack serve --config webpack/config/development.ts",
"start:production": "TS_NODE_PROJECT=\"webpack/config/tsconfig.json\" webpack serve --config webpack/config/production.ts",
"test": "yarn compile && jest --config .jestrc.json",
"test:ci": "yarn test --ci",
"test:ci:branch": "yarn test:ci --changedSince master"
},
"dependencies": {
"solid-js": "1.8.19"
},
"devDependencies": {
"@babel/core": "7.24.9",
"@babel/preset-env": "7.25.0",
"@jest/globals": "29.7.0",
"@package/eslint-config": "workspace:*",
"@package/jest-config": "workspace:*",
"@package/markdownlint-config": "workspace:*",
"@package/prettier-config": "workspace:*",
"@package/tsconfig": "workspace:*",
"@playwright/test": "1.45.3",
"@solidjs/testing-library": "0.8.9",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.4.8",
"@testing-library/user-event": "14.5.2",
"@types/jest": "29.5.12",
"@types/node": "20.14.12",
"babel-loader": "9.1.3",
"babel-preset-solid": "1.8.19",
"bundlesize": "0.18.2",
"css-loader": "7.1.2",
"eslint": "8.57.0",
"fork-ts-checker-webpack-plugin": "9.0.2",
"html-webpack-plugin": "5.6.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-extended": "4.0.2",
"jest-when": "3.6.0",
"lint-staged": "12.1.7",
"markdownlint-cli": "0.41.0",
"mini-css-extract-plugin": "2.9.0",
"msw": "2.3.4",
"npm-run-all": "4.1.5",
"postcss": "8.4.40",
"postcss-loader": "8.1.1",
"prettier": "3.3.3",
"pretty-quick": "4.0.0",
"rimraf": "6.0.1",
"style-loader": "4.0.0",
"ts-jest": "29.2.3",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
"tslib": "2.6.3",
"typescript": "5.5.4",
"webpack": "5.93.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "5.0.4",
"webpack-merge": "6.0.1"
},
"msw": {
"workerDirectory": "public"
}
}
3 changes: 3 additions & 0 deletions templates/solid-application/package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Package

Annotations for `package.json` manifest file.
33 changes: 33 additions & 0 deletions templates/solid-application/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { defineConfig } from "@playwright/test";

// eslint-disable-next-line node/no-process-env -- check `process.env` to detect ci environment
const CI = !!process.env.CI;
const ROOT_DIR = "playwright";
const URL = "http://localhost:7824";

// eslint-disable-next-line no-restricted-exports, import/no-default-export -- playwright requires default export
export default defineConfig({
forbidOnly: CI,
fullyParallel: true,
outputDir: `${ROOT_DIR}/artifacts`,
reporter: [
["html", { outputFolder: `${ROOT_DIR}/report` }],
[CI ? "dot" : "list"],
],
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- retries
retries: CI ? 3 : 0,
testDir: `${ROOT_DIR}/tests`,
use: {
baseURL: URL,
screenshot: "only-on-failure",
trace: "on-first-retry",
video: "on-first-retry",
},
webServer: {
command: "yarn start:production",
reuseExistingServer: !CI,
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- timeout
timeout: 90 * 1000,
url: URL,
},
});
Loading

0 comments on commit 44fda0c

Please sign in to comment.