nx: Initialize nx (#5235)

* nx: Initialize nx
https://nx.dev/getting-started/adding-to-existing

* fix: Migrator ordering issue for vitest scripts

* nit: trailing newline

* deps: Updated select dependencies to fix Storybook with pnpm

* fix: Add explicit knip entry point for current workspace
...since it's not inferred from the script now.
This commit is contained in:
Alexander Brown
2025-08-27 23:11:03 -07:00
committed by GitHub
parent f3d9f4cffb
commit d0eee738b7
9 changed files with 3273 additions and 1492 deletions

9
.gitignore vendored
View File

@@ -76,3 +76,12 @@ vite.config.mts.timestamp-*.mjs
*storybook.log *storybook.log
storybook-static storybook-static
.nx/cache
.nx/workspace-data
.cursor/rules/nx-rules.mdc
.github/instructions/nx.instructions.md
vite.config.*.timestamp*
vitest.config.*.timestamp*

View File

@@ -17,9 +17,10 @@ export default [
'src/scripts/*', 'src/scripts/*',
'src/extensions/core/*', 'src/extensions/core/*',
'src/types/vue-shim.d.ts', 'src/types/vue-shim.d.ts',
// Generated files that don't need linting
'src/types/comfyRegistryTypes.ts', 'src/types/comfyRegistryTypes.ts',
'src/types/generatedManagerTypes.ts' 'src/types/generatedManagerTypes.ts',
'**/vite.config.*.timestamp*',
'**/vitest.config.*.timestamp*'
] ]
}, },
{ {

View File

@@ -74,7 +74,7 @@ const config: KnipConfig = {
// Workspace configuration for monorepo-like structure // Workspace configuration for monorepo-like structure
workspaces: { workspaces: {
'.': { '.': {
entry: ['src/main.ts'] entry: ['src/main.ts', 'playwright.i18n.config.ts']
} }
} }
} }

40
nx.json Normal file
View File

@@ -0,0 +1,40 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
{
"plugin": "@nx/storybook/plugin",
"options": {
"serveStorybookTargetName": "storybook",
"buildStorybookTargetName": "build-storybook",
"testStorybookTargetName": "test-storybook",
"staticStorybookTargetName": "static-storybook"
}
},
{
"plugin": "@nx/vite/plugin",
"options": {
"buildTargetName": "build",
"testTargetName": "test",
"serveTargetName": "serve",
"devTargetName": "dev",
"previewTargetName": "preview",
"serveStaticTargetName": "serve-static",
"typecheckTargetName": "typecheck",
"buildDepsTargetName": "build-deps",
"watchDepsTargetName": "watch-deps"
}
},
{
"plugin": "@nx/playwright/plugin",
"options": {
"targetName": "e2e"
}
}
]
}

View File

@@ -8,22 +8,22 @@
"description": "Official front-end implementation of ComfyUI", "description": "Official front-end implementation of ComfyUI",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"scripts": { "scripts": {
"dev": "vite", "dev": "nx serve",
"dev:electron": "vite --config vite.electron.config.mts", "dev:electron": "nx serve --config vite.electron.config.mts",
"build": "pnpm typecheck && vite build", "build": "pnpm typecheck && nx build",
"build:types": "vite build --config vite.types.config.mts && node scripts/prepare-types.js", "build:types": "nx build --config vite.types.config.mts && node scripts/prepare-types.js",
"zipdist": "node scripts/zipdist.js", "zipdist": "node scripts/zipdist.js",
"typecheck": "vue-tsc --noEmit", "typecheck": "vue-tsc --noEmit",
"format": "prettier --write './**/*.{js,ts,tsx,vue,mts}' --cache", "format": "prettier --write './**/*.{js,ts,tsx,vue,mts}' --cache",
"format:check": "prettier --check './**/*.{js,ts,tsx,vue,mts}' --cache", "format:check": "prettier --check './**/*.{js,ts,tsx,vue,mts}' --cache",
"format:no-cache": "prettier --write './**/*.{js,ts,tsx,vue,mts}'", "format:no-cache": "prettier --write './**/*.{js,ts,tsx,vue,mts}'",
"format:check:no-cache": "prettier --check './**/*.{js,ts,tsx,vue,mts}'", "format:check:no-cache": "prettier --check './**/*.{js,ts,tsx,vue,mts}'",
"test:browser": "npx playwright test", "test:browser": "npx nx e2e",
"test:unit": "vitest run tests-ui/tests", "test:unit": "nx run test tests-ui/tests",
"test:component": "vitest run src/components/", "test:component": "nx run test src/components/",
"preinstall": "npx only-allow pnpm", "preinstall": "npx only-allow pnpm",
"prepare": "husky || true && git config blame.ignoreRevsFile .git-blame-ignore-revs || true", "prepare": "husky || true && git config blame.ignoreRevsFile .git-blame-ignore-revs || true",
"preview": "vite preview", "preview": "nx preview",
"lint": "eslint src --cache", "lint": "eslint src --cache",
"lint:fix": "eslint src --cache --fix", "lint:fix": "eslint src --cache --fix",
"lint:no-cache": "eslint src", "lint:no-cache": "eslint src",
@@ -31,18 +31,23 @@
"knip": "knip --cache", "knip": "knip --cache",
"knip:no-cache": "knip", "knip:no-cache": "knip",
"locale": "lobe-i18n locale", "locale": "lobe-i18n locale",
"collect-i18n": "playwright test --config=playwright.i18n.config.ts", "collect-i18n": "nx e2e --config=playwright.i18n.config.ts",
"json-schema": "tsx scripts/generate-json-schema.ts", "json-schema": "tsx scripts/generate-json-schema.ts",
"storybook": "storybook dev -p 6006", "storybook": "nx storybook -p 6006",
"build-storybook": "storybook build" "build-storybook": "nx build-storybook"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.8.0", "@eslint/js": "^9.8.0",
"@executeautomation/playwright-mcp-server": "^1.0.5", "@executeautomation/playwright-mcp-server": "^1.0.6",
"@iconify/json": "^2.2.245", "@iconify/json": "^2.2.245",
"@iconify/tailwind": "^1.2.0", "@iconify/tailwind": "^1.2.0",
"@intlify/eslint-plugin-vue-i18n": "^3.2.0", "@intlify/eslint-plugin-vue-i18n": "^3.2.0",
"@lobehub/i18n-cli": "^1.20.0", "@lobehub/i18n-cli": "^1.25.1",
"@nx/eslint": "21.4.1",
"@nx/playwright": "21.4.1",
"@nx/storybook": "21.4.1",
"@nx/vite": "21.4.1",
"@nx/web": "21.4.1",
"@pinia/testing": "^0.1.5", "@pinia/testing": "^0.1.5",
"@playwright/test": "^1.52.0", "@playwright/test": "^1.52.0",
"@storybook/addon-docs": "^9.1.1", "@storybook/addon-docs": "^9.1.1",
@@ -55,6 +60,7 @@
"@types/semver": "^7.7.0", "@types/semver": "^7.7.0",
"@types/three": "^0.169.0", "@types/three": "^0.169.0",
"@vitejs/plugin-vue": "^5.1.4", "@vitejs/plugin-vue": "^5.1.4",
"@vitest/ui": "^3.0.0",
"@vue/test-utils": "^2.4.6", "@vue/test-utils": "^2.4.6",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.19",
"chalk": "^5.3.0", "chalk": "^5.3.0",
@@ -70,14 +76,16 @@
"happy-dom": "^15.11.0", "happy-dom": "^15.11.0",
"husky": "^9.0.11", "husky": "^9.0.11",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"ink": "^4.2.0", "ink": "^6.2.2",
"jiti": "2.4.2",
"knip": "^5.62.0", "knip": "^5.62.0",
"lint-staged": "^15.2.7", "lint-staged": "^15.2.7",
"lucide-vue-next": "^0.540.0", "lucide-vue-next": "^0.540.0",
"nx": "21.4.1",
"postcss": "^8.4.39", "postcss": "^8.4.39",
"prettier": "^3.3.2", "prettier": "^3.3.2",
"react": "^18.3.1", "react": "^19.1.1",
"react-reconciler": "^0.29.2", "react-reconciler": "^0.32.0",
"storybook": "^9.1.1", "storybook": "^9.1.1",
"tailwindcss": "^3.4.4", "tailwindcss": "^3.4.4",
"tsx": "^4.15.6", "tsx": "^4.15.6",
@@ -90,7 +98,7 @@
"vite-plugin-dts": "^4.3.0", "vite-plugin-dts": "^4.3.0",
"vite-plugin-html": "^3.2.2", "vite-plugin-html": "^3.2.2",
"vite-plugin-vue-devtools": "^7.7.6", "vite-plugin-vue-devtools": "^7.7.6",
"vitest": "^2.0.0", "vitest": "^3.2.4",
"vue-tsc": "^2.1.10", "vue-tsc": "^2.1.10",
"zip-dir": "^2.0.0", "zip-dir": "^2.0.0",
"zod-to-json-schema": "^3.24.1" "zod-to-json-schema": "^3.24.1"

4651
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,4 +12,5 @@ onlyBuiltDependencies:
- '@playwright/browser-firefox' - '@playwright/browser-firefox'
- '@playwright/browser-webkit' - '@playwright/browser-webkit'
- esbuild - esbuild
- nx
- oxc-resolver - oxc-resolver

View File

@@ -334,12 +334,9 @@ describe('LinkConnector Integration', () => {
} = graph.getNodeById(nodeId)! } = graph.getNodeById(nodeId)!
expect(input.link).toBeNull() expect(input.link).toBeNull()
// @ts-expect-error toBeOneOf not in type definitions
expect(output.links?.length).toBeOneOf([0, undefined]) expect(output.links?.length).toBeOneOf([0, undefined])
// @ts-expect-error toBeOneOf not in type definitions
expect(input._floatingLinks?.size).toBeOneOf([0, undefined]) expect(input._floatingLinks?.size).toBeOneOf([0, undefined])
// @ts-expect-error toBeOneOf not in type definitions
expect(output._floatingLinks?.size).toBeOneOf([0, undefined]) expect(output._floatingLinks?.size).toBeOneOf([0, undefined])
} }
}) })
@@ -537,12 +534,9 @@ describe('LinkConnector Integration', () => {
} = graph.getNodeById(nodeId)! } = graph.getNodeById(nodeId)!
expect(input.link).toBeNull() expect(input.link).toBeNull()
// @ts-expect-error toBeOneOf not in type definitions
expect(output.links?.length).toBeOneOf([0, undefined]) expect(output.links?.length).toBeOneOf([0, undefined])
// @ts-expect-error toBeOneOf not in type definitions
expect(input._floatingLinks?.size).toBeOneOf([0, undefined]) expect(input._floatingLinks?.size).toBeOneOf([0, undefined])
// @ts-expect-error toBeOneOf not in type definitions
expect(output._floatingLinks?.size).toBeOneOf([0, undefined]) expect(output._floatingLinks?.size).toBeOneOf([0, undefined])
} }
}) })
@@ -856,12 +850,9 @@ describe('LinkConnector Integration', () => {
} = graph.getNodeById(nodeId)! } = graph.getNodeById(nodeId)!
expect(input.link).toBeNull() expect(input.link).toBeNull()
// @ts-expect-error toBeOneOf not in type definitions
expect(output.links?.length).toBeOneOf([0, undefined]) expect(output.links?.length).toBeOneOf([0, undefined])
// @ts-expect-error toBeOneOf not in type definitions
expect(input._floatingLinks?.size).toBeOneOf([0, undefined]) expect(input._floatingLinks?.size).toBeOneOf([0, undefined])
// @ts-expect-error toBeOneOf not in type definitions
expect(output._floatingLinks?.size).toBeOneOf([0, undefined]) expect(output._floatingLinks?.size).toBeOneOf([0, undefined])
} }
}) })

View File

@@ -12,16 +12,12 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"resolveJsonModule": true, "resolveJsonModule": true,
/* Linting */
"strict": true, "strict": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"downlevelIteration": true, "downlevelIteration": true,
"noImplicitOverride": true, "noImplicitOverride": true,
/* AllowJs during migration phase */
"allowJs": true, "allowJs": true,
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
@@ -29,7 +25,7 @@
}, },
"typeRoots": ["src/types", "node_modules/@types"], "typeRoots": ["src/types", "node_modules/@types"],
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./", "rootDir": "./"
}, },
"include": [ "include": [
"src/**/*", "src/**/*",