Skip to content
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

feat(devex): nx #27595

Closed
wants to merge 7 commits into from
Closed
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: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ temp_test_run_data.json
.eslintcache

# ignore all dagster tmp directories that may be created
tmp*/
tmp*/


.nx/cache
.nx/workspace-data
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ posthog/templates/email/*
common/hogvm/typescript/src/stl/bytecode.ts
rust/
livestream/

/.nx/cache
/.nx/workspace-data
7 changes: 7 additions & 0 deletions common/hogql_parser/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "hogql_parser",
"sourceRoot": "./",
"projectType": "library",
"targets": {}
}
7 changes: 7 additions & 0 deletions common/hogvm/python/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "hogvm-py",
"sourceRoot": "./",
"projectType": "library",
"targets": {}
}
20 changes: 20 additions & 0 deletions common/hogvm/typescript/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "hogvm-ts",
"sourceRoot": "./src",
"projectType": "library",
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"options": {
"jestConfig": "./jest.config.ts"
}
}
}
}
16 changes: 16 additions & 0 deletions common/plugin_transpiler/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "plugin-transpiler",
"root": ".",
"sourceRoot": "./src",
"projectType": "library",
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build"]
},
"outputs": ["dist"]
}
}
}
8 changes: 8 additions & 0 deletions ee/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "ee",
"sourceRoot": ".",
"projectType": "library",
"implicitDependencies": [],
"targets": {}
}
15 changes: 15 additions & 0 deletions frontend/@posthog/apps-common/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "apps-common",
"sourceRoot": "./src",
"projectType": "library",
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build"]
},
"outputs": ["dist"]
}
}
}
15 changes: 15 additions & 0 deletions frontend/@posthog/lemon-ui/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "lemon-ui",
"sourceRoot": "./src",
"projectType": "library",
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build"]
},
"outputs": ["dist"]
}
}
}
30 changes: 30 additions & 0 deletions frontend/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "frontend",
"sourceRoot": "./src",
"projectType": "library",
"implicitDependencies": ["hogvm-ts", "lemon-ui", "apps-common"],
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build"],
"cwd": "."
},
"outputs": ["./dist"]
},
"serve": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm start"],
"cwd": "."
}
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "./jest.config.ts"
}
}
}
}
148 changes: 148 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {
"build": {
"outputs": ["{projectRoot}/frontend/dist"],
"cache": true
},
"build:esbuild": {
"outputs": ["{projectRoot}/frontend/dist"],
"cache": true
},
"schema:build": {
"outputs": ["{projectRoot}/posthog/schema.py", "frontend/src/queries/schema.json"],
"cache": true
},
"schema:build:json": {
"outputs": ["{projectRoot}/frontend/src/queries/schema.json"],
"cache": true
},
"schema:build:python": {
"outputs": ["{projectRoot}/posthog/schema.py"],
"cache": true
},
"grammar:build": {
"outputs": ["{projectRoot}/posthog/hogql/grammar"],
"cache": true
},
"grammar:build:python": {
"outputs": ["{projectRoot}/posthog/hogql/grammar"],
"cache": true
},
"grammar:build:cpp": {
"outputs": ["{projectRoot}/hogql_parser"],
"cache": true
},
"packages:build:apps-common": {
"outputs": ["{projectRoot}/frontend/@posthog/apps-common/dist"],
"cache": true
},
"packages:build:lemon-ui": {
"outputs": ["{projectRoot}/frontend/@posthog/lemon-ui/dist"],
"cache": true
},
"editor:update-tsd": {
"outputs": ["{projectRoot}/frontend/src/scenes/plugins/source/types/packages.json"],
"cache": true
},
"copy-scripts": {
"cache": true
},
"test": {
"cache": true
},
"test:unit": {
"cache": true
},
"jest": {
"cache": true
},
"test:visual:update": {
"cache": true
},
"test:visual:update:docker": {
"cache": true
},
"test:visual:debug": {
"cache": true
},
"test:visual:ci:update": {
"cache": true
},
"test:visual:ci:verify": {
"cache": true
},
"clean": {
"cache": true
},
"packages:build": {
"cache": true
},
"typescript:check": {
"cache": true
},
"lint:js": {
"cache": true
},
"lint:css": {
"cache": true
},
"format:backend": {
"cache": true
},
"format:frontend": {
"cache": true
},
"format": {
"cache": true
},
"typegen:write": {
"cache": true
},
"typegen:check": {
"cache": true
},
"typegen:clean": {
"cache": true
},
"build-storybook": {
"cache": true
},
"visualize-toolbar-bundle": {
"cache": true
}
},
"defaultBase": "master",
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
{
"plugin": "@nx/storybook/plugin",
"options": {
"serveStorybookTargetName": "serve:storybook",
"buildStorybookTargetName": "build:storybook",
"testStorybookTargetName": "test-storybook",
"staticStorybookTargetName": "static-storybook"
}
},
{
"plugin": "@nx/jest/plugin",
"options": {
"targetName": "jest:test"
}
},
{
"plugin": "@nx/cypress/plugin",
"options": {
"targetName": "e2e",
"openTargetName": "open-cypress",
"componentTestingTargetName": "component-test",
"ciTargetName": "e2e-ci"
}
}
]
}
28 changes: 18 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
"scripts": {
"copy-scripts": "mkdir -p frontend/dist/ && ./bin/copy-posthog-js",
"test": "pnpm test:unit && pnpm test:visual",
"test:unit": "jest --testPathPattern='(frontend/|products/|common/)'",
"jest": "jest",
"test:unit": "nx jest:test --testPathPattern='(frontend/|products/|common/)'",
"jest": "nx jest:test",
"test:visual:update": "rm -rf frontend/__snapshots__/__failures__/ && docker compose -f docker-compose.playwright.yml run --rm -it --build playwright pnpm test:visual:update:docker --url http://host.docker.internal:6006",
"test:visual:update:docker": "NODE_OPTIONS=--max-old-space-size=6144 test-storybook -u --browsers chromium webkit --no-index-json",
"test:visual:debug": "PWDEBUG=1 NODE_OPTIONS=--max-old-space-size=6144 test-storybook --browsers chromium webkit --no-index-json",
"test:visual:ci:update": "test-storybook -u --no-index-json --maxWorkers=2",
"test:visual:ci:verify": "test-storybook --ci --no-index-json --maxWorkers=2",
"test:visual:update:docker": "NODE_OPTIONS=--max-old-space-size=6144 nx test-storybook -u --browsers chromium webkit --no-index-json",
"test:visual:debug": "PWDEBUG=1 NODE_OPTIONS=--max-old-space-size=6144 nx test-storybook --browsers chromium webkit --no-index-json",
"test:visual:ci:update": "nx test-storybook -u --no-index-json --maxWorkers=2",
"test:visual:ci:verify": "nx test-storybook --ci --no-index-json --maxWorkers=2",
"start": "concurrently -n ESBUILD,TYPEGEN -c yellow,green \"pnpm start-http\" \"pnpm run typegen:watch\"",
"start-http": "pnpm clean && pnpm copy-scripts && pnpm build:esbuild --dev",
"start-docker": "pnpm start-http --host 0.0.0.0",
"clean": "rm -rf frontend/dist && mkdir frontend/dist",
"build": "pnpm copy-scripts && pnpm build:esbuild",
"build:esbuild": "DEBUG=0 node frontend/build.mjs",
"build:esbuild": "DEBUG=0 nx exec -- node frontend/build.mjs",
"schema:build": "pnpm run schema:build:json && pnpm run schema:build:python",
"schema:build:json": "ts-node bin/build-schema-json.mjs && prettier --write frontend/src/queries/schema.json",
"schema:build:python": "bash bin/build-schema-python.sh",
Expand All @@ -53,8 +53,8 @@
"typegen:check": "kea-typegen check",
"typegen:watch": "kea-typegen watch --delete --show-ts-errors",
"typegen:clean": "find frontend/src products common -type f -name '*Type.ts' -delete",
"storybook": "DEBUG=0 storybook dev -p 6006",
"build-storybook": "DEBUG=0 storybook build",
"storybook": "DEBUG=0 nx serve:storybook -p 6006",
"build-storybook": "DEBUG=0 nx build:storybook",
"dev:migrate:postgres": "export DEBUG=1 && source env/bin/activate && python manage.py migrate",
"dev:migrate:clickhouse": "export DEBUG=1 && source env/bin/activate && python manage.py migrate_clickhouse",
"prepare": "husky install",
Expand Down Expand Up @@ -209,6 +209,12 @@
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@cypress/webpack-preprocessor": "^5.17.1",
"@nx/cypress": "20.3.1",
"@nx/eslint": "20.3.1",
"@nx/jest": "20.3.1",
"@nx/playwright": "20.3.1",
"@nx/storybook": "20.3.1",
"@nx/web": "20.3.1",
"@playwright/test": "1.45.0",
"@sentry/types": "7.112.1",
"@storybook/addon-a11y": "^7.6.4",
Expand Down Expand Up @@ -303,6 +309,7 @@
"mockdate": "^3.0.5",
"monaco-editor-webpack-plugin": "^7.0.1",
"msw": "^0.49.0",
"nx": "20.3.1",
"path-browserify": "^1.0.1",
"pixelmatch": "^5.3.0",
"pngjs": "^6.0.0",
Expand Down Expand Up @@ -397,5 +404,6 @@
},
"browser": {
"path": "path-browserify"
}
},
"nx": {}
}
2 changes: 1 addition & 1 deletion plugin-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"typescript:compile": "tsc -b",
"typescript:check": "tsc --noEmit -p .",
"compile": "pnpm typescript:compile",
"lint": "eslint .",
"lint": "nx lint",
"lint:fix": "eslint --fix .",
"prettier": "prettier --write .",
"prettier:check": "prettier --check .",
Expand Down
22 changes: 22 additions & 0 deletions plugin-server/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://json.schemastore.org/nx",
"name": "plugin-server",
"sourceRoot": "./src",
"projectType": "application",
"implicitDependencies": ["hogvm-ts", "cyclotron-node"],
"targets": {
"build": {
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build"]
},
"outputs": ["dist"]
},
"test": {
"executor": "@nx/jest",
"options": {
"jestConfig": "./jest.config.ts"
}
}
}
}
Loading
Loading