Skip to content

Commit

Permalink
feat(workspace-tools): Added lint and format tasks and improved c…
Browse files Browse the repository at this point in the history
…ache input management
  • Loading branch information
sullivanpj committed Jun 21, 2024
1 parent b4b3323 commit f2ade20
Show file tree
Hide file tree
Showing 39 changed files with 481 additions and 447 deletions.
34 changes: 0 additions & 34 deletions .prettierignore

This file was deleted.

6 changes: 3 additions & 3 deletions crates/storm-config/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "crates/storm-config/src",
"targets": {},
"tags": []
}
"// targets": "to see all targets run: nx show project storm-config --web",
"targets": {}
}
6 changes: 3 additions & 3 deletions crates/storm-workspace/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "crates/storm-workspace/src",
"targets": {},
"tags": []
}
"// targets": "to see all targets run: nx show project storm-workspace --web",
"targets": {}
}
46 changes: 24 additions & 22 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@ pre-commit:
prepare:
files: "git diff --name-only HEAD @{push}"
glob: "**/{lefthook.yml,biome.json}"
run: "pnpm lefthook install"
prebuild:
glob: "**/*"
run: "pnpm build-all"
stage_fixed: true
run: "pnpm lefthook install && git update-index"
schema-gen:
glob: "packages/config/src/schema.ts"
run: 'pnpm nx generate @storm-software/workspace-tools:config-schema --outputFile="./packages/config/schemas/storm.schema.json"'
stage_fixed: true
run: 'pnpm nx generate @storm-software/workspace-tools:config-schema --outputFile="./packages/config/schemas/storm.schema.json" && git update-index'
validate:
glob: "**/*"
run: "node ./dist/packages/git-tools/bin/pre-commit.js {staged_files}"
stage_fixed: true
run: "node ./dist/packages/git-tools/bin/pre-commit.js {staged_files} && git update-index"
build:
glob: "**/*"
run: "pnpm build-all"

# lint:
# glob: "**/*.{js,ts,rs,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
# run: "pnpm lint"
Expand All @@ -47,18 +45,22 @@ pre-commit:
# files: "git diff --name-only HEAD @{push}"
# glob: "**/*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
# run: "pnpm exec prettier {staged_files} --check --ignore-unknown --no-error-on-unmatched-pattern --cache && git update-index"
readme:
files: "git diff --name-only HEAD @{push}"
glob: "**/{README.md,package.json,executors.json,generators.json}"
run: "pnpm format-readme && git update-index"
format:
files: "git diff --name-only HEAD @{push}"
glob: "**/*"
run: "pnpm exec prettier {staged_files} --write --ignore-unknown --no-error-on-unmatched-pattern --cache && git update-index"
postbuild:
glob: "**/*"
run: "pnpm build-all"
stage_fixed: true
# toml:
# files: "git diff --name-only HEAD @{push}"
# glob: "**/*.{toml}"
# run: "pnpm format-toml && git update-index"
# readme:
# files: "git diff --name-only HEAD @{push}"
# glob: "**/{README.md,package.json,executors.json,generators.json}"
# run: "pnpm format-readme && git update-index"
# format:
# files: "git diff --name-only HEAD @{push}"
# glob: "**/*"
# run: "pnpm exec prettier {staged_files} --write --ignore-unknown --no-error-on-unmatched-pattern --cache && git update-index"
# postbuild:
# files: "git diff --name-only HEAD @{push}"
# glob: "**/*"
# run: "pnpm build-all && git update-index"

commit-msg:
commands:
Expand All @@ -81,7 +83,7 @@ post-merge:
commands:
validate:
glob: "**/*"
run: "node ./dist/packages/git-tools/bin/post-merge.js {staged_files}"
run: "node ./dist/packages/git-tools/bin/post-merge.js {staged_files} && git update-index"
stage_fixed: true

post-checkout:
Expand Down
204 changes: 44 additions & 160 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,167 +1,51 @@
{
"$schema": "https://cdn.jsdelivr.net/npm/nx/schemas/nx-schema.json",
"extends": "./packages/workspace-tools/config/nx.json",
"namedInputs": {
"globalTesting": [
"{workspaceRoot}/jest.config.ts",
"{workspaceRoot}/jest.preset.js",
"{workspaceRoot}/benches/**/*",
"{workspaceRoot}/e2e/**/*",
"{workspaceRoot}/tests/**/*",
"{workspaceRoot}/testing/**/*",
"{workspaceRoot}/coverage/**/*"
],
"globalShared": [
"{workspaceRoot}/assets/**/*",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/.gitattributes",
"{workspaceRoot}/.gitignore",
"{workspaceRoot}/nx.json",
"{workspaceRoot}/.nxignore",
"{workspaceRoot}/storm.json",
"{workspaceRoot}/storm.*.json",
"{workspaceRoot}/.storm/config.json",
"{workspaceRoot}/.storm/config.*.json",
"{workspaceRoot}/storm.yaml",
"{workspaceRoot}/storm.*.yaml",
"{workspaceRoot}/.storm/config.yaml",
"{workspaceRoot}/.storm/config.*.yaml",
"{workspaceRoot}/storm.toml",
"{workspaceRoot}/storm.*.toml",
"{workspaceRoot}/.storm/config.toml",
"{workspaceRoot}/.storm/config.*.toml",
"{workspaceRoot}/storm.config.js",
"{workspaceRoot}/.env",
"{workspaceRoot}/.env.local"
],
"globalRust": [
"globalShared",
"{workspaceRoot}/Cargo.toml",
"{workspaceRoot}/Cargo.lock",
"{workspaceRoot}/.cargo/config.toml",
"{workspaceRoot}/rust-toolchain",
"{workspaceRoot}/rustfmt.toml",
"{workspaceRoot}/deny.toml"
],
"globalTypeScript": [
"globalShared",
"{workspaceRoot}/tsconfig.*.json",
"{workspaceRoot}/.npmrc",
"{workspaceRoot}/.npmignore",
"{workspaceRoot}/package.json",
"{workspaceRoot}/pnpm-workspace.yaml",
"{workspaceRoot}/pnpm-lock.yaml",
"{workspaceRoot}/package-lock.yaml",
"{workspaceRoot}/yarn-lock.yaml",
"{workspaceRoot}/bun.lockb",
"{workspaceRoot}/biome.toml",
"{workspaceRoot}/biome.json",
"{workspaceRoot}/lefthook.yaml",
"{workspaceRoot}/.markdownlint.json",
"{workspaceRoot}/eslint.config.js",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintrc.cjs",
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/.prettierrc",
"{workspaceRoot}/.prettierignore"
],
"globalDocs": [
"globalRust",
"globalTypeScript",
"{workspaceRoot}/api-extractor.json",
"{workspaceRoot}/tsdoc.json",
"{workspaceRoot}/typedoc.json",
"{workspaceRoot}/contentlayer.config.ts",
"{workspaceRoot}/*.md",
"{workspaceRoot}/*.mdx",
"{workspaceRoot}/docs/**/*",
"{workspaceRoot}/.storybook/**/*"
],
"global": ["globalRust", "globalTypeScript", "globalTesting", "globalDocs"],
"defaultTesting": [
"globalTesting",
"{projectRoot}/jest.config.ts",
"{projectRoot}/benches/**/*",
"{projectRoot}/e2e/**/*",
"{projectRoot}/tests/**/*",
"{projectRoot}/testing/**/*",
"{projectRoot}/tsconfig.spec.json",
"{projectRoot}/src/test-setup.[jt]s",
"{projectRoot}/test-setup.[jt]s",
"{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"{projectRoot}/tsconfig.spec.json"
],
"defaultShared": [
"globalShared",
"{projectRoot}/project.json",
"{projectRoot}/README.md",
"{projectRoot}/CHANGELOG.md",
"{projectRoot}/.env",
"{projectRoot}/.env.local"
],
"defaultRust": [
"globalRust",
"defaultShared",
"{projectRoot}/**/*.rs",
"{projectRoot}/Cargo.toml",
"{projectRoot}/.cargo/config.toml",
{
"runtime": "node -p '`${process.platform}_${process.arch}`'"
"targetDefaults": {
"lint-ls": {
"cache": true,
"outputs": ["{workspaceRoot}/{projectRoot}"],
"dependsOn": ["^lint-ls"],
"executor": "nx:run-commands",
"options": {
"command": "pnpm exec ls-lint --config=\"./packages/linting-tools/src/ls-lint/ls-lint.yml\" ",
"color": true
}
],
"defaultTypeScript": [
"globalTypeScript",
"defaultShared",
"{projectRoot}/package.json",
"{projectRoot}/eslint.config.js",
"{projectRoot}/.eslintrc.json",
"{projectRoot}/.eslintrc.cjs",
"{projectRoot}/.eslintignore",
"{projectRoot}/tsconfig.json",
"{projectRoot}/tsconfig.*.json",
"{projectRoot}/**/*.ts",
"{projectRoot}/**/*.tsx",
"{projectRoot}/**/*.js",
"{projectRoot}/**/*.jsx",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/tsconfig.storybook.json",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)"
],
"defaultDocs": [
"globalDocs",
"defaultRust",
"defaultTypeScript",
"{projectRoot}/api-extractor.json",
"{projectRoot}/tsdoc.json",
"{projectRoot}/typedoc.json",
"{projectRoot}/contentlayer.config.ts",
"{projectRoot}/**/*.md",
"{projectRoot}/**/*.mdx",
"{projectRoot}/docs/**/*",
"{projectRoot}/.storybook/**/*",
"{projectRoot}/tsconfig.storybook.json",
"{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)"
],
"default": [
"global",
"defaultRust",
"defaultTypeScript",
"defaultTesting",
"defaultDocs"
],
"production": [
"defaultRust",
"defaultTypeScript",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/tsconfig.storybook.json",
"!{projectRoot}/.storybook/**/*",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
]
},
"format-toml": {
"cache": true,
"inputs": ["config_linting", "{projectRoot}/**/*.toml"],
"outputs": ["{workspaceRoot}/{projectRoot}/**/*.toml"],
"dependsOn": ["^format-toml"],
"executor": "nx:run-commands",
"options": {
"command": "pnpm exec taplo format --colors=\"always\" --config=\"./packages/linting-tools/src/taplo/.taplo.toml\" --cache-path=\"tmp/taplo/{projectRoot}\"",
"color": true
}
},
"format-readme": {
"cache": true,
"inputs": [
"config_linting",
"{projectRoot}/{README.md,package.json,Cargo.toml,executors.json,generators.json}"
],
"outputs": ["{workspaceRoot}/{projectRoot}/README.md"],
"dependsOn": ["^format-readme"],
"executor": "nx:run-commands",
"options": {
"command": "node ./dist/packages/git-tools/bin/git.js readme-gen --templates=\"./packages/git-tools/src/readme/templates\"",
"color": true
}
},
"format-prettier": {
"cache": true,
"inputs": ["config_linting", "typescript", "^production"],
"dependsOn": ["^format-prettier"],
"options": {
"command": "pnpm exec prettier \"{projectRoot}/**/*\" --write --ignore-unknown --no-error-on-unmatched-pattern --config=\"packages/prettier/src/config.json\" --ignore-path=\"packages/prettier/src/.prettierignore\" --cache --cache-location=\"tmp/prettier/{projectRoot}\" ",
"color": true
}
}
},
"release": {
"projects": ["packages/*", "crates/*"],
Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@
"scripts": {
"adr": "pnpm log4brains adr new",
"adr-preview": "pnpm log4brains preview",
"build": "nx affected -t build --parallel=1",
"build-all": "nx run-many -t build --all --parallel=1 --verbose",
"build-all": "nx affected -t build --parallel=1 --verbose",
"build-plugins": "node -r esbuild-register tools/scripts/build-plugins.ts",
"clean": "rimraf dist",
"clean:packages": "rimraf dist/packages",
"commit": "node ./dist/packages/git-tools/bin/git.js commit",
"dep-graph": "nx dep-graph",
"e2e": "nx e2e",
"format-prettier": "pnpm exec prettier **/* --write --cache",
"format": "nx format:write",
"format-prettier": "pnpm exec prettier --write --ignore-unknown --no-error-on-unmatched-pattern --config=\"prettier.config.js\" --ignore-path=\"./packages/prettier/src/.prettierignore\" --cache --cache-location=\"./tmp/prettier\" ",
"format-readme": "node ./dist/packages/git-tools/bin/git.js readme-gen --templates=\"./dist/packages/git-tools/readme/templates\"",
"format-toml": "pnpm exec taplo format --config=\"./dist/packages/linting-tools/taplo/.taplo.toml\"",
"format-toml": "pnpm exec taplo format --config=\"./dist/packages/linting-tools/taplo/.taplo.toml\" --cache-path=\"./tmp/taplo\"",
"help": "nx help",
"lint": "node ./dist/packages/linting-tools/bin/lint.js all --skip-cspell --skip-deps-version --skip-alex",
"lint-filenames": "pnpm exec ls-lint --config=\"./dist/packages/linting-tools/ls-lint/ls-lint.yml\"",
"lint-prettier": "pnpm exec prettier **/* --check --cache",
"lint": "node ./dist/packages/linting-tools/bin/lint.js all --skip-cspell --skip-alex",
"lint-ls": "pnpm exec ls-lint --config=\"./dist/packages/linting-tools/ls-lint/ls-lint.yml\"",
"lint-prettier": "pnpm exec prettier --check --config=\"prettier.config.js\" --ignore-path=\"./packages/prettier/src/.prettierignore\" --cache ",
"lint-toml": "pnpm exec taplo format --check --config=\"./dist/packages/linting-tools/taplo/.taplo.toml\"",
"local-registry": "nx local-registry @storm-software/storm-ops",
"nx": "nx",
Expand Down Expand Up @@ -129,9 +129,12 @@
"namespace": "@storm-software",
"nx": {
"includedScripts": [
"lint-ls",
"lint",
"format",
"format-readme",
"format-prettier",
"format-toml",
"commit",
"release"
]
Expand Down
2 changes: 1 addition & 1 deletion packages/build-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages

<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />

[![Version](https://img.shields.io/badge/version-0.10.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;
[![Version](https://img.shields.io/badge/version-0.11.0-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;
[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with docusaurus](https://img.shields.io/badge/documented_with-docusaurus-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://docusaurus.io/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)

> [!IMPORTANT]
Expand Down
Loading

0 comments on commit f2ade20

Please sign in to comment.