diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7affbb57..182ff8e8 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,6 @@ concurrency: permissions: contents: read -env: - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ secrets.TURBO_TEAM }} - jobs: lint: runs-on: ubuntu-latest @@ -33,9 +29,6 @@ jobs: - name: Lint run: pnpm run lint - - name: Spell check - run: pnpm -F documentation run spellcheck - type-check: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/commonality.yml b/.github/workflows/commonality.yml index 122f1b5a..13b7678f 100644 --- a/.github/workflows/commonality.yml +++ b/.github/workflows/commonality.yml @@ -2,26 +2,34 @@ name: Commonality on: push: - branches: [main] - pull_request: - branches: [main] - -env: - FORCE_COLOR: 1 + branches: + - '*' jobs: - validate: - timeout-minutes: 10 + publish: + name: Publish Commonality runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout code uses: actions/checkout@v4 - - name: Setup - uses: ./.github/actions/setup + - name: Enable Corepack + run: corepack enable + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install - - name: Check - run: pnpm exec commonality check + - name: Build + run: pnpm build - - name: Constrain - run: pnpm exec commonality constrain + - name: Publish Commonality + run: pnpm exec commonality publish + env: + COMMONALITY_PROJECT_ID: ${{ secrets.COMMONALITY_PROJECT_ID }} + COMMONALITY_PUBLISH_KEY: ${{ secrets.COMMONALITY_PUBLISH_KEY }} diff --git a/.github/workflows/package-preview.yml b/.github/workflows/package-preview.yml new file mode 100644 index 00000000..0604523b --- /dev/null +++ b/.github/workflows/package-preview.yml @@ -0,0 +1,25 @@ +name: Publish Package Preview +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - run: corepack enable + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Publish Preview + run: pnpx pkg-pr-new publish --pnpm './apps/commonality' './packages/utils-core' diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml deleted file mode 100644 index f860abd8..00000000 --- a/.github/workflows/playwright.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Playwright Tests -on: - push: - branches: [main] - pull_request: - branches: [main] -jobs: - e2e-studio: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - name: Checkout respository - uses: actions/checkout@v4 - - - name: Setup - uses: ./.github/actions/setup - - - name: Install Playwright Browsers - run: pnpm -F studio exec playwright install --with-deps - - - name: Run Playwright tests - run: pnpm -F studio exec playwright test - - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 diff --git a/.husky/pre-commit b/.husky/pre-commit index dd323696..618c2bfb 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -pnpm run lint:fix \ No newline at end of file + diff --git a/apps/commonality/package.json b/apps/commonality/package.json index e9bc9331..c2c9cb7b 100644 --- a/apps/commonality/package.json +++ b/apps/commonality/package.json @@ -43,13 +43,13 @@ "postbuild": "tsc --emitDeclarationOnly --declaration", "lint": "eslint ./src --fix", "test": "vitest", - "test:integration": "vitest --config=vite.integration.config.ts", + "test:integration": "vitest --config=vitest.integration.config.ts", "type-check": "tsc --noEmit", "lint:fix": "eslint . --fix" }, "dependencies": { - "@antfu/install-pkg": "^0.3.1", - "@commonalityco/studio": "workspace:*", + "@antfu/install-pkg": "^0.3.3", + "@clack/prompts": "^0.7.0", "@sindresorhus/slugify": "^2.2.1", "boxen": "^7.1.1", "chalk": "^5.3.0", @@ -59,26 +59,28 @@ "detect-indent": "^7.0.1", "find-up": "^6.3.0", "fs-extra": "^11.2.0", - "get-port": "^7.0.0", + "get-port": "^7.1.0", + "git-branch": "^2.0.1", "globby": "^13.2.2", - "import-meta-resolve": "^4.0.0", + "import-meta-resolve": "^4.1.0", "ip": "^1.1.9", "jest-diff": "^29.7.0", - "jiti": "^1.21.0", + "jiti": "^1.21.6", + "ky": "^1.5.0", "local-pkg": "^0.5.0", "lodash-es": "^4.17.21", - "micromatch": "^4.0.5", - "nanoid": "^5.0.6", + "micromatch": "^4.0.7", + "nanoid": "^5.0.7", "ora": "^7.0.1", "pathe": "^1.1.2", - "pino": "^8.19.0", + "pino": "^8.21.0", "prompts": "^2.4.2", "std-env": "^3.7.0", "strip-ansi": "^7.1.0", - "update-notifier": "^7.0.0", + "update-notifier": "^7.2.0", "wait-on": "^7.2.0", - "yaml": "^2.3.4", - "zod": "^3.22.4" + "yaml": "^2.5.0", + "zod": "^3.23.8" }, "devDependencies": { "@commonalityco/config-tsconfig": "workspace:*", @@ -92,21 +94,22 @@ "@commonalityco/utils-core": "workspace:*", "@commonalityco/utils-file": "workspace:*", "@commonalityco/utils-onboarding": "workspace:*", - "@swc/core": "^1.4.2", + "@swc/core": "^1.7.2", "@types/fs-extra": "^11.0.4", + "@types/git-branch": "^2.0.5", "@types/ip": "^1.1.3", "@types/lodash-es": "^4.17.12", "@types/mock-fs": "^4.13.4", - "@types/node": "^20.11.20", + "@types/node": "^20.14.12", "@types/prompts": "^2.4.9", "@types/wait-on": "^5.3.4", "eslint-config-commonality": "workspace:*", "execa": "^8.0.1", "mock-fs": "^5.2.0", "npm-run-all": "^4.1.5", - "rimraf": "^5.0.5", - "tsup": "^8.0.2", - "typescript": "^5.3.3", - "vitest": "^0.34.6" + "rimraf": "^5.0.9", + "tsup": "^8.2.3", + "typescript": "^5.5.4", + "vitest": "^2.0.4" } -} \ No newline at end of file +} diff --git a/apps/commonality/src/cli/cli.ts b/apps/commonality/src/cli/cli.ts index 79728b48..cf40846e 100644 --- a/apps/commonality/src/cli/cli.ts +++ b/apps/commonality/src/cli/cli.ts @@ -1,8 +1,5 @@ import { Command } from 'commander'; -import { constrain } from './commands/constrain.js'; -import { studio } from './commands/studio.js'; -import { check } from './commands/check.js'; -import { init } from './commands/init.js'; +import { publish } from './commands/publish.js'; import packageJson from '../../package.json'; const program = new Command(); @@ -16,9 +13,5 @@ program .description('Build bigger with the tools you already love') .version(packageJson.version); -program.addCommand(init); -program.addCommand(check); -program.addCommand(constrain); -program.addCommand(studio); - +program.addCommand(publish); program.parse(process.argv); diff --git a/apps/commonality/src/cli/commands/check.test.ts b/apps/commonality/src/cli/commands/check.test.ts deleted file mode 100644 index 3cad37c4..00000000 --- a/apps/commonality/src/cli/commands/check.test.ts +++ /dev/null @@ -1,789 +0,0 @@ -import { beforeEach, describe, expect, it, test, vi } from 'vitest'; -import { runChecks } from './check.js'; -import { ConformanceResult } from '@commonalityco/utils-conformance'; -import process from 'node:process'; -import console from 'node:console'; -import { PackageType, Status } from '@commonalityco/utils-core/constants'; -import stripAnsi from 'strip-ansi'; -import prompts from 'prompts'; - -vi.mock('node:process', async () => ({ - default: { - ...(await vi.importActual('node:process')), - exit: vi.fn(), - }, -})); - -vi.mock('node:console', async () => ({ - default: { - ...(await vi.importActual('node:console')), - log: vi.fn().mockImplementation(() => {}), - }, -})); - -vi.mock('std-env', () => { - return { - isCI: false, - }; -}); - -const mockError = new Error('this-is-an-error'); -mockError.stack = 'mock-stack'; - -const getConsoleCalls = () => { - return vi - .mocked(console.log) - .mock.calls.map((call) => - call.map((item) => (typeof item === 'string' ? stripAnsi(item) : item)), - ); -}; - -describe('runChecks', () => { - beforeEach(() => { - vi.mocked(process.exit).mockReset(); - vi.mocked(console.log).mockReset(); - }); - - describe('when there are no results', () => { - it('should show an empty state message', async () => { - await runChecks({ - verbose: false, - getResults: async () => [], - onFix: vi.fn(), - }); - - expect(console.log).toHaveBeenCalledTimes(1); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - You don't have any checks configured. - - Create powerful conformance rules that run like tests and can be shared like lint rules. - - https://docs.commonality.co/checks", - ], - ] - `); - }); - - it('output should match snapshot', async () => { - await runChecks({ - verbose: false, - getResults: async () => { - throw mockError; - }, - onFix: vi.fn(), - }); - - expect(console.log).toHaveBeenCalledTimes(1); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - Error: this-is-an-error - mock-stack", - ], - ] - `); - }); - }); - - describe('when there is an error getting results', () => { - it('should exit the process with status code 1', async () => { - await runChecks({ - verbose: false, - getResults: async () => { - throw mockError; - }, - onFix: vi.fn(), - }); - - expect(process.exit).toHaveBeenCalledWith(1); - }); - - it('output should match snapshot', async () => { - await runChecks({ - verbose: false, - getResults: async () => { - throw mockError; - }, - onFix: vi.fn(), - }); - - expect(console.log).toHaveBeenCalledTimes(1); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - Error: this-is-an-error - mock-stack", - ], - ] - `); - }); - }); - - describe('when all checks pass', () => { - test('when verbose is false it should match the snapshot', async () => { - await runChecks({ - verbose: false, - getResults: async () => { - return [ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - }, - ] satisfies ConformanceResult[]; - }, - onFix: vi.fn(), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ✓ pkg-one (2) - - Packages: 0 failed 0 warnings 1 passed (1) - Checks: 0 failed 0 warnings 2 passed (2)", - ], - ] - `); - }); - - test('when verbose is true it should match the snapshot', async () => { - await runChecks({ - verbose: true, - getResults: async () => { - return [ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { - message: 'This package should be cool', - }, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { - message: 'This package should be cool', - }, - }, - ] satisfies ConformanceResult[]; - }, - onFix: vi.fn(), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ❯ pkg-one (1) - ✓ pass This package should be cool - │ - ❯ pkg-two (1) - ✓ pass This package should be cool - │ - - Packages: 0 failed 0 warnings 2 passed (2) - Checks: 0 failed 0 warnings 2 passed (2)", - ], - ] - `); - }); - }); - - describe('when checks fail', () => { - it('should not call process.exit when there are only warnings', async () => { - await runChecks({ - verbose: false, - getResults: async () => { - return [ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - }, - ]; - }, - onFix: vi.fn(), - }); - - expect(process.exit).not.toHaveBeenCalled(); - }); - - it('should exit the process with status code 1 when there are failures', async () => { - await runChecks({ - verbose: false, - getResults: async () => { - return [ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Fail, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - }, - ]; - }, - onFix: vi.fn(), - }); - - expect(process.exit).toHaveBeenCalledWith(1); - }); - - test('when verbose is false it should match the snapshot', async () => { - await runChecks({ - verbose: false, - getResults: async () => { - return [ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - }, - ]; - }, - onFix: vi.fn(), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ✓ pkg-one (1) - ❯ pkg-two (1) - ⚠ warn This package should be cool - │ - - Packages: 0 failed 1 warnings 1 passed (2) - Checks: 0 failed 1 warnings 1 passed (2)", - ], - ] - `); - }); - - test('when verbose is true it should match the snapshot', async () => { - await runChecks({ - verbose: true, - getResults: async () => { - return [ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { - message: 'This package should be awesome', - }, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { - message: 'This package should be cool', - path: 'package.json', - suggestion: `I\nam\na\nmultiline\nstring`, - }, - }, - ]; - }, - onFix: vi.fn(), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ❯ pkg-one (1) - ✓ pass This package should be awesome - │ - ❯ pkg-two (1) - ⚠ warn This package should be cool - │ package.json - │ I - │ am - │ a - │ multiline - │ string - │ - - Packages: 0 failed 1 warnings 1 passed (2) - Checks: 0 failed 1 warnings 1 passed (2)", - ], - ] - `); - }); - - test('when there are fixes and the user does not choose to run them', async () => { - prompts.inject([false]); - - await runChecks({ - verbose: false, - getResults: vi - .fn() - .mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]) - .mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]), - onFix: vi.fn(), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ✓ pkg-one (1) - ❯ pkg-two (1) - ⚠ warn This package should be cool - │ - - Packages: 0 failed 1 warnings 1 passed (2) - Checks: 0 failed 1 warnings 1 passed (2)", - ], - [], - ] - `); - }); - - test('when there are fixes and the command is run in CI', async () => { - vi.doMock('std-env', () => { - return { - isCI: true, - }; - }); - - await runChecks({ - verbose: false, - getResults: vi - .fn() - .mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]) - .mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]), - onFix: vi.fn(), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ✓ pkg-one (1) - ❯ pkg-two (1) - ⚠ warn This package should be cool - │ - - Packages: 0 failed 1 warnings 1 passed (2) - Checks: 0 failed 1 warnings 1 passed (2)", - ], - [], - ] - `); - }); - - test('when there are fixes and the user chooses to run them and it is successful', async () => { - prompts.inject([true]); - - await runChecks({ - verbose: false, - getResults: vi - .fn() - .mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]) - .mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]), - onFix: vi.fn(), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ✓ pkg-one (1) - ❯ pkg-two (1) - ⚠ warn This package should be cool - │ - - Packages: 0 failed 1 warnings 1 passed (2) - Checks: 0 failed 1 warnings 1 passed (2)", - ], - [], - [ - "", - ], - [ - " - ✓ pkg-one (1) - ✓ pkg-two (1) - - Packages: 0 failed 0 warnings 2 passed (2) - Checks: 0 failed 0 warnings 2 passed (2)", - ], - ] - `); - }); - - test('when user chooses to run fixes and it throws it should match the snapshot', async () => { - prompts.inject([true]); - - await runChecks({ - verbose: false, - getResults: vi.fn().mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]), - onFix: vi.fn().mockRejectedValue(mockError), - }); - - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ✓ pkg-one (1) - ❯ pkg-two (1) - ⚠ warn This package should be cool - │ - - Packages: 0 failed 1 warnings 1 passed (2) - Checks: 0 failed 1 warnings 1 passed (2)", - ], - [], - [ - "", - ], - [ - " - Error: this-is-an-error - mock-stack", - ], - ] - `); - }); - - test('when user chooses to run fixes and it throws it should exit with status code 1', async () => { - prompts.inject([true]); - - await runChecks({ - verbose: false, - getResults: vi.fn().mockResolvedValueOnce([ - { - id: 'CONFORMER_NAME/ONE', - filter: '*', - status: Status.Pass, - package: { - path: '/path', - name: 'pkg-one', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be awesome' }, - fix: () => {}, - }, - { - id: 'CONFORMER_NAME/TWO', - filter: '*', - status: Status.Warn, - package: { - path: '/path', - name: 'pkg-two', - version: '1.0.0', - type: PackageType.NODE, - }, - message: { message: 'This package should be cool' }, - fix: () => {}, - }, - ]), - onFix: vi.fn().mockRejectedValue(mockError), - }); - - expect(process.exit).toHaveBeenCalledTimes(1); - expect(process.exit).toHaveBeenCalledWith(1); - }); - }); -}); diff --git a/apps/commonality/src/cli/commands/check.ts b/apps/commonality/src/cli/commands/check.ts deleted file mode 100644 index a3b140e2..00000000 --- a/apps/commonality/src/cli/commands/check.ts +++ /dev/null @@ -1,311 +0,0 @@ -/* eslint-disable unicorn/no-process-exit */ -import type { ConformanceResult } from '@commonalityco/utils-conformance'; -import { getConformanceResults } from '@commonalityco/utils-conformance/get-conformance-results'; -import { runFixes } from '@commonalityco/utils-conformance/run-fixes'; -import { Command } from 'commander'; -import { - getProjectConfig, - getRootDirectory, -} from '@commonalityco/data-project'; -import { getPackages } from '@commonalityco/data-packages'; -import { getTagsData } from '@commonalityco/data-tags'; -import { getCodeownersData } from '@commonalityco/data-codeowners'; -import ora from 'ora'; -import c from 'chalk'; -import prompts from 'prompts'; -import process from 'node:process'; -import { Logger } from '../utils/logger'; -import { Status } from '@commonalityco/utils-core/constants'; -import { isCI } from 'std-env'; -import { getResolvedChecks } from '@commonalityco/utils-conformance/get-resolved-checks'; -import console from 'node:console'; -import { logger } from '@commonalityco/utils-core/logger'; -import { validateProjectStructure } from '../utils/validate-project-structure'; - -const command = new Command(); - -const checksSpinner = ora('Running checks...'); - -class ConformLogger extends Logger { - constructor() { - super(); - } - - addEmptyMessage() { - const title = c.bold(`You don't have any checks configured.`); - const body = - 'Create powerful conformance rules that run like tests and can be shared like lint rules.'; - const link = 'https://docs.commonality.co/checks'; - - this.output += `\n${title}\n\n${body}\n\n${link}`; - } - - addCheckName({ result }: { result: ConformanceResult }) { - let status; - if (result.status === Status.Pass) { - status = c.green('✓ pass'); - } else if (result.status === Status.Fail) { - status = c.red('✘ fail'); - } else { - status = c.yellow('⚠ warn'); - } - - const title = result.message.message; - - this.output += `\n${status} ${title}`; - } -} - -const createResultsMap = (results: ConformanceResult[]) => { - const resultsMap = new Map>(); - - for (const result of results) { - const packageName = result.package.name; - const existingResultsForPackage = resultsMap.get(packageName); - - if (existingResultsForPackage) { - existingResultsForPackage.add(result); - } else { - resultsMap.set(packageName, new Set([result])); - } - } - - return resultsMap; -}; - -const getPackageCounts = (resultsMap: Map>) => { - let failPackageCount = 0; - let warnPackageCount = 0; - const totalPackageCount = resultsMap.size; - - for (const packageResults of resultsMap.values()) { - const invalidResults = [...packageResults].filter( - (result) => result.status !== Status.Pass, - ); - - if (invalidResults.some((result) => result.status === Status.Fail)) { - failPackageCount++; - continue; - } - - if (invalidResults.some((result) => result.status === Status.Warn)) { - warnPackageCount++; - continue; - } - } - - return { - totalPackageCount, - passPackageCount: totalPackageCount - failPackageCount - warnPackageCount, - failPackageCount, - warnPackageCount, - }; -}; - -const getCheckCounts = (results: ConformanceResult[]) => { - const failCheckCount = results.filter( - (result) => result.status === Status.Fail, - ).length; - const warnCheckCount = results.filter( - (result) => result.status === Status.Warn, - ).length; - const passCheckCount = results.filter( - (result) => result.status === Status.Pass, - ).length; - - return { - totalCheckCount: results.length, - passCheckCount, - failCheckCount, - warnCheckCount, - }; -}; - -const reportConformanceResults = ({ - logger, - verbose, - results, -}: { - logger: ConformLogger; - verbose: boolean; - results: ConformanceResult[]; -}) => { - if (results.length === 0) { - logger.addEmptyMessage(); - logger.write(); - return; - } - - const resultsMap = createResultsMap(results); - const packageCounts = getPackageCounts(resultsMap); - const checkCounts = getCheckCounts(results); - - for (const packageName of resultsMap.keys()) { - const resultsForPackage = resultsMap.get(packageName); - - if (!resultsForPackage) { - continue; - } - - const hasInvalidResults = [...resultsForPackage].some( - (result) => result.status !== Status.Pass, - ); - - logger.addPackageName({ - verbose, - status: hasInvalidResults ? 'fail' : 'pass', - packageName, - count: resultsForPackage.size, - }); - - for (const result of resultsForPackage) { - if (result.status !== Status.Pass || verbose) { - logger.addCheckName({ result }); - - if (result.message.path) { - logger.addSubText(c.dim(result.message.path)); - } - - if (result.message.suggestion) { - logger.addSubText(result.message.suggestion); - } - - logger.addSubText(); - } - } - } - - logger.addTotal({ - title: '\nPackages:', - totalCount: packageCounts.totalPackageCount, - passCount: packageCounts.passPackageCount, - warnCount: packageCounts.warnPackageCount, - failCount: packageCounts.failPackageCount, - }); - - logger.addTotal({ - title: ' Checks:', - totalCount: checkCounts.totalCheckCount, - passCount: checkCounts.passCheckCount, - warnCount: checkCounts.warnCheckCount, - failCount: checkCounts.failCheckCount, - }); - - logger.write(); -}; - -export const runChecks = async ({ - verbose, - getResults, - onFix = () => Promise.resolve(), -}: { - verbose: boolean; - getResults: () => Promise; - onFix: (results: ConformanceResult[]) => Promise; -}) => { - const logger = new ConformLogger(); - - try { - const run = async () => { - const results = await getResults(); - checksSpinner.stop(); - reportConformanceResults({ verbose, results, logger }); - - const fixableResults = results.filter( - (result) => result.status !== Status.Pass && result.fix, - ); - - if (fixableResults && fixableResults.length > 0 && !isCI) { - console.log(); - const response = await prompts({ - type: 'confirm', - name: 'shouldRunFixes', - message: `Found ${fixableResults.length} auto-fixable checks. Run fixes?`, - initial: false, - }); - - if (response.shouldRunFixes) { - logger.clearScreen(); - await onFix(fixableResults); - await run(); - } - } - - const hasErrors = results.some((result) => result.status === Status.Fail); - - if (hasErrors) { - process.exit(1); - } - }; - - await run(); - } catch (error) { - logger.writeError(error); - process.exit(1); - } -}; - -const action = async ({ - verbose, - debug, -}: { - verbose: boolean; - debug: boolean; -}) => { - if (debug) { - logger.level = 'debug'; - } - - await validateProjectStructure({ - directory: process.cwd(), - command, - }); - - checksSpinner.start(); - - const rootDirectory = await getRootDirectory(); - const projectConfig = await getProjectConfig({ rootDirectory }); - const packages = await getPackages({ rootDirectory }); - const tagsData = await getTagsData({ rootDirectory, packages }); - const codeownersData = await getCodeownersData({ rootDirectory, packages }); - const checks = getResolvedChecks({ - projectConfig: projectConfig?.config, - rootDirectory, - }); - - if (checks.unresolved.length > 0) { - checksSpinner.stop(); - for (const unresolved of checks.unresolved) { - console.log(c.yellow(`\nCould not resolve check: ${unresolved}`)); - } - } - - return runChecks({ - verbose, - onFix: (results) => { - return runFixes({ - conformanceResults: results, - allPackages: packages, - rootDirectory, - tagsData, - codeownersData, - }); - }, - getResults: () => { - return getConformanceResults({ - conformersByPattern: checks.resolved ?? {}, - rootDirectory, - packages, - tagsData, - codeownersData, - }); - }, - }); -}; - -export const check = command - .name('check') - .description('Validate that packages pass conformance checks') - .option('--verbose', 'Show the result of all checks') - .option('--debug', 'Show additional logs') - .action(action); diff --git a/apps/commonality/src/cli/commands/constrain.test.ts b/apps/commonality/src/cli/commands/constrain.test.ts deleted file mode 100644 index 29576ed7..00000000 --- a/apps/commonality/src/cli/commands/constrain.test.ts +++ /dev/null @@ -1,320 +0,0 @@ -import { beforeEach, describe, expect, test, vi } from 'vitest'; -import { reportConstraintResults } from './constrain'; -import { DependencyType } from '@commonalityco/utils-core/constants'; -import stripAnsi from 'strip-ansi'; -import { ConstraintResult } from '@commonalityco/types'; - -import process from 'node:process'; -import console from 'node:console'; - -vi.mock('node:process', async () => ({ - default: { - ...(await vi.importActual('node:process')), - exit: vi.fn(), - }, -})); - -vi.mock('node:console', async () => ({ - default: { - ...(await vi.importActual('node:console')), - log: vi.fn().mockImplementation(() => {}), - }, -})); - -const getConsoleCalls = () => { - return vi - .mocked(console.log) - .mock?.calls?.map((call) => call.map((item) => stripAnsi(item))); -}; - -describe('constrain', () => { - beforeEach(() => { - vi.mocked(process.exit).mockReset(); - vi.mocked(console.log).mockReset(); - }); - - test('when allow all constraints match dependencies with no tags and verbose is false it displays the correct output', async () => { - const results = [ - { - constraint: { - allow: '*', - }, - dependencyPath: [ - { - source: 'pkg-one', - target: 'pkg-two', - type: DependencyType.PRODUCTION, - version: '1.0.0', - }, - ], - filter: '*', - foundTags: undefined, - isValid: true, - }, - ] satisfies ConstraintResult[]; - - await reportConstraintResults({ - results, - verbose: false, - }); - - expect(process.exit).not.toHaveBeenCalled(); - expect(getConsoleCalls()).toMatchInlineSnapshot( - ` - [ - [ - " - ✓ pkg-one (1) - - Packages: 0 failed 1 passed (1) - Constraints: 0 failed 1 passed (1)", - ], - ] - `, - ); - }); - - test('when allow all constraints match dependencies with no tags and verbose is true it displays the correct output', async () => { - const results = [ - { - constraint: { - allow: '*', - }, - dependencyPath: [ - { - source: 'pkg-one', - target: 'pkg-two', - type: DependencyType.PRODUCTION, - version: '1.0.0', - }, - ], - filter: '*', - foundTags: undefined, - isValid: true, - }, - ] satisfies ConstraintResult[]; - - await reportConstraintResults({ - results, - verbose: true, - }); - - expect(process.exit).not.toHaveBeenCalled(); - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ❯ pkg-one (1) - ↳ pass pkg-two prod - │ Allowed: * - │ Found: No tags found - │ - - Packages: 0 failed 1 passed (1) - Constraints: 0 failed 1 passed (1)", - ], - ] - `); - }); - - test('when allow constraints match dependencies with invalid tags and verbose is false it displays the correct output', async () => { - const results = [ - { - constraint: { - allow: ['tag-two'], - }, - dependencyPath: [ - { - source: 'pkg-one', - target: 'pkg-two', - type: DependencyType.PRODUCTION, - version: '1.0.0', - }, - ], - filter: 'tag-one', - foundTags: ['tag-three'], - isValid: false, - }, - ] satisfies ConstraintResult[]; - - await reportConstraintResults({ - results, - verbose: false, - }); - - expect(process.exit).toHaveBeenCalledWith(1); - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ❯ pkg-one (1) - ↳ fail pkg-two prod - │ Allowed: #tag-two - │ Found: #tag-three - │ - - Packages: 1 failed 0 passed (1) - Constraints: 1 failed 0 passed (1)", - ], - ] - `); - }); - - test('when disallow constraints match dependencies with invalid tags and verbose is false it displays the correct output', async () => { - const results = [ - { - constraint: { - disallow: ['tag-three'], - }, - dependencyPath: [ - { - source: 'pkg-one', - target: 'pkg-two', - type: DependencyType.PRODUCTION, - version: '1.0.0', - }, - ], - filter: 'tag-one', - foundTags: ['tag-three'], - isValid: false, - }, - ] satisfies ConstraintResult[]; - - await reportConstraintResults({ - results, - verbose: false, - }); - - expect(process.exit).toHaveBeenCalledWith(1); - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ❯ pkg-one (1) - ↳ fail pkg-two prod - │ Disallowed: #tag-three - │ Found: #tag-three - │ - - Packages: 1 failed 0 passed (1) - Constraints: 1 failed 0 passed (1)", - ], - ] - `); - }); - - test('when disallow constraints match dependencies with invalid tags and verbose is true it displays the correct output', async () => { - const results = [ - { - constraint: { - disallow: ['tag-three'], - }, - dependencyPath: [ - { - source: 'pkg-one', - target: 'pkg-two', - type: DependencyType.PRODUCTION, - version: '1.0.0', - }, - ], - filter: 'tag-one', - foundTags: ['tag-three'], - isValid: false, - }, - ] satisfies ConstraintResult[]; - - await reportConstraintResults({ - results, - verbose: true, - }); - - expect(process.exit).toHaveBeenCalledWith(1); - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ❯ pkg-one (1) - ↳ fail pkg-two prod - │ Disallowed: #tag-three - │ Found: #tag-three - │ - - Packages: 1 failed 0 passed (1) - Constraints: 1 failed 0 passed (1)", - ], - ] - `); - }); - - test('when disallow constraints match transitive dependencies with invalid tags and verbose is true it displays the correct output', async () => { - const results = [ - { - constraint: { - disallow: ['tag-three'], - }, - dependencyPath: [ - { - source: 'pkg-one', - target: 'pkg-two', - type: DependencyType.PRODUCTION, - version: '1.0.0', - }, - { - source: 'pkg-two', - target: 'pkg-three', - type: DependencyType.PRODUCTION, - version: '1.0.0', - }, - ], - filter: 'tag-one', - foundTags: ['tag-three'], - isValid: false, - }, - ] satisfies ConstraintResult[]; - - await reportConstraintResults({ - results, - verbose: true, - }); - - expect(process.exit).toHaveBeenCalledWith(1); - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - ❯ pkg-one (1) - ↳ fail pkg-two prod → pkg-three prod - │ Disallowed: #tag-three - │ Found: #tag-three - │ - - Packages: 1 failed 0 passed (1) - Constraints: 1 failed 0 passed (1)", - ], - ] - `); - }); - - test('when there are no results', async () => { - const results = [] satisfies ConstraintResult[]; - - await reportConstraintResults({ - results, - verbose: true, - }); - - expect(process.exit).not.toHaveBeenCalled(); - expect(getConsoleCalls()).toMatchInlineSnapshot(` - [ - [ - " - You don't have any constraints configured. - - Prevent endless dependency debugging by limiting the which packages can depend on each other. - - https://docs.commonality.co/constraints", - ], - ] - `); - }); -}); diff --git a/apps/commonality/src/cli/commands/constrain.ts b/apps/commonality/src/cli/commands/constrain.ts deleted file mode 100644 index ad00cfc5..00000000 --- a/apps/commonality/src/cli/commands/constrain.ts +++ /dev/null @@ -1,276 +0,0 @@ -#!/usr/bin/env node -import { Command } from 'commander'; -import { getConstraintResults } from '@commonalityco/data-constraints'; -import { ConstraintResult } from '@commonalityco/types'; -import ora from 'ora'; -import c from 'chalk'; -import { Logger } from '../utils/logger.js'; -import { DependencyType } from '@commonalityco/utils-core/constants'; -import { - getProjectConfig, - getRootDirectory, -} from '@commonalityco/data-project'; -import { getTagsData } from '@commonalityco/data-tags'; -import { getDependencies, getPackages } from '@commonalityco/data-packages'; -import process from 'node:process'; -import { validateProjectStructure } from '../utils/validate-project-structure.js'; - -const constraintSpinner = ora('Validating constraints...'); - -const command = new Command(); - -class ConstrainLogger extends Logger { - constructor() { - super(); - } - - addEmptyMessage() { - const title = c.bold(`You don't have any constraints configured.`); - const body = `Prevent endless dependency debugging by limiting the which packages can depend on each other.`; - const link = 'https://docs.commonality.co/constraints'; - - this.output += `\n${title}\n\n${body}\n\n${link}`; - } - - addConstraintTitle({ result }: { result: ConstraintResult }) { - const statusText = result.isValid ? c.green('↳ pass') : c.red('↳ fail'); - const arrowText = result.isValid ? c.green('→') : c.red('→'); - - const dependencyTextByType = { - [DependencyType.PRODUCTION]: c.dim('prod'), - [DependencyType.DEVELOPMENT]: c.dim('dev'), - [DependencyType.PEER]: c.dim('peer'), - }; - - const dependencyText = result.dependencyPath - .map((dep) => { - const typeText = c.dim(dependencyTextByType[dep.type]); - - return `${dep.target} ${typeText}`; - }) - .join(` ${arrowText} `); - - this.output += `\n${statusText} ${dependencyText}`; - } - - addConstraintTable({ result }: { result: ConstraintResult }) { - const extraPad = 'disallow' in result.constraint ? ' ' : ''; - const foundExtraPad = 'disallow' in result.constraint ? ' ' : ' '; - - if ('allow' in result.constraint) { - const allowTagsText = - typeof result.constraint.allow === 'string' && - result.constraint.allow === '*' - ? c.green(result.constraint.allow) - : result.constraint.allow - .map((tag) => `#${tag}`) - .map((tag) => - result.foundTags?.map((tag) => `#${tag}`).includes(tag) - ? c.green(tag) - : tag, - ) - .join(', '); - - this.addSubText(`Allowed:${extraPad} ${allowTagsText}`); - } - - if ('disallow' in result.constraint) { - const disallowTagsText = - typeof result.constraint.disallow === 'string' && - result.constraint.disallow === '*' - ? c.red(result.constraint.disallow) - : result.constraint.disallow - .map((tag) => `#${tag}`) - .map((tag) => - result.foundTags?.map((tag) => `#${tag}`).includes(tag) - ? c.red(tag) - : tag, - ) - .join(', '); - - this.addSubText(`Disallowed: ${disallowTagsText}`); - } - - if (result.foundTags) { - const foundTagsText = result.foundTags - .map((tag) => `#${tag}`) - .map((tag) => { - if ( - 'disallow' in result.constraint && - typeof result.constraint.disallow === 'string' && - result.constraint.disallow === '*' - ) { - return c.red(tag); - } - - if ( - 'allow' in result.constraint && - typeof result.constraint.allow === 'string' && - result.constraint.allow === '*' - ) { - return c.green(tag); - } - - if ( - 'disallow' in result.constraint && - Array.isArray(result.constraint.disallow) && - result.constraint.disallow.map((tag) => `#${tag}`).includes(tag) - ) { - return c.red(tag); - } - - if ( - 'allow' in result.constraint && - Array.isArray(result.constraint.allow) && - result.constraint.allow.map((tag) => `#${tag}`).includes(tag) - ) { - return c.green(tag); - } - - return tag; - }) - .join(', '); - - this.addSubText(`Found:${foundExtraPad} ${foundTagsText}`); - } else { - this.addSubText(`Found:${foundExtraPad} No tags found`); - } - - this.addSubText(); - } -} - -export const reportConstraintResults = async ({ - logger = new ConstrainLogger(), - results, - verbose, -}: { - logger?: ConstrainLogger; - results: ConstraintResult[]; - verbose: boolean; -}) => { - if (results.length === 0) { - logger.addEmptyMessage(); - logger.write(); - return; - } - // This is keyed by packageName - const resultsMap = new Map>(); - - for (const result of results) { - const packageName = result.dependencyPath[0].source; - const existingResultsForPackage = resultsMap.get(packageName); - - if (existingResultsForPackage) { - existingResultsForPackage.add(result); - } else { - resultsMap.set(packageName, new Set([result])); - } - } - - let failPackageCount = 0; - - for (const packageResults of resultsMap.values()) { - const invalidResults = [...packageResults].filter( - (result) => !result.isValid, - ); - - if (invalidResults.some((result) => !result.isValid)) { - failPackageCount++; - } - } - - const failConstraintCount = results.filter( - (result) => !result.isValid, - ).length; - - for (const packageName of resultsMap.keys()) { - const resultsForPackage = resultsMap.get(packageName); - - if (!resultsForPackage) { - continue; - } - - const hasInvalidResults = [...resultsForPackage].some( - (result) => !result.isValid, - ); - - logger.addPackageName({ - verbose, - status: hasInvalidResults ? 'fail' : 'pass', - packageName, - count: resultsForPackage.size, - }); - - for (const result of resultsForPackage) { - if (!result.isValid || verbose) { - logger.addConstraintTitle({ result }); - logger.addConstraintTable({ result }); - } - } - } - - logger.addTotal({ - title: '\nPackages: ', - totalCount: resultsMap.size, - passCount: resultsMap.size - failPackageCount, - failCount: failPackageCount, - }); - - logger.addTotal({ - title: 'Constraints:', - totalCount: results.length, - failCount: failConstraintCount, - passCount: results.length - failConstraintCount, - }); - - logger.write(); - - if (failConstraintCount > 0) { - process.exit(1); - } -}; - -const action = async (options: { verbose: boolean }) => { - await validateProjectStructure({ - directory: process.cwd(), - command, - }); - - const logger = new ConstrainLogger(); - - constraintSpinner.start(); - - const rootDirectory = await getRootDirectory(); - - const _projectConfig = getProjectConfig({ rootDirectory }); - const _dependencies = getDependencies({ rootDirectory }); - - const packages = await getPackages({ rootDirectory }); - - const _tagsData = getTagsData({ rootDirectory, packages }); - - const projectConfig = await _projectConfig; - const dependencies = await _dependencies; - const tagsData = await _tagsData; - - const results = await getConstraintResults({ - dependencies, - constraints: projectConfig?.config.constraints, - tagsData, - }); - - constraintSpinner.stop(); - - await reportConstraintResults({ - results, - verbose: options.verbose, - logger, - }); -}; - -export const constrain = command - .name('constrain') - .description('Validate that dependencies adhere to your constraints') - .option('--verbose', 'Show the result of all constraints') - .action(action); diff --git a/apps/commonality/src/cli/commands/init.ts b/apps/commonality/src/cli/commands/init.ts deleted file mode 100644 index fb014358..00000000 --- a/apps/commonality/src/cli/commands/init.ts +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env node -import { Command } from 'commander'; -import ora from 'ora'; -import { - installCommonality, - getInstallChecks, - getInstallCommonality, - installChecks, - createConfig, -} from '@commonalityco/utils-onboarding'; -import { - getProjectConfig, - getRootDirectory, -} from '@commonalityco/data-project'; -import console from 'node:console'; -import c from 'chalk'; - -const command = new Command(); - -const logNextSteps = ({ - shouldInstallChecks, -}: { - shouldInstallChecks: boolean; -}) => { - console.log(); - - console.log(` ${c.bold(`You're all set up! Here's what to try next:`)}`); - - if (shouldInstallChecks) { - console.log( - `\n${c.blue( - ' npx commonality check', - )}\n Try running the checks we've set up for you`, - ); - } - - console.log(`\n Check out our getting started guide for more info:`); - console.log( - ` ${c.underline('https://www.docs.commonality.co/quickstart')}\n`, - ); -}; - -export const action = async ({ - rootDirectory, - verbose, -}: { - rootDirectory: string; - verbose?: boolean; -}) => { - console.log( - `\n ${c.bold.blue( - 'Welcome to Commonality!', - )} \n\n Let’s get you set up.\n`, - ); - - // Prompts - const shouldInstallCommonality = await getInstallCommonality({ - rootDirectory, - }); - const projectConfig = await getProjectConfig({ rootDirectory }); - - const shouldInstallChecks = await getInstallChecks({ rootDirectory }); - - // Confirmation - if (!shouldInstallCommonality && !shouldInstallChecks && !projectConfig) { - console.log(c.green(`\n Your project is already set up with Commonality`)); - logNextSteps({ shouldInstallChecks: true }); - return; - } - - const configFileName = `.commonality/config.json`; - // Generation - try { - console.log(); - - if (shouldInstallCommonality) { - const commonalitySpinner = ora(); - - commonalitySpinner.start( - 'Installing commonality, this might take a couple of minutes.', - ); - - await installCommonality({ rootDirectory, verbose }); - - commonalitySpinner.succeed('Installed commonality'); - } - - if (shouldInstallChecks) { - const checksSpinner = ora(); - - checksSpinner.start( - 'Installing commonality-checks-recommended, this might take a couple of minutes.', - ); - - await installChecks({ rootDirectory }); - - checksSpinner.succeed('Installed commonality-checks-recommended'); - } - - if (!projectConfig) { - const configSpinner = ora(); - - configSpinner.start(`Creating ${configFileName}`); - - await createConfig({ - rootDirectory, - includeChecks: shouldInstallChecks, - }); - - configSpinner.succeed(`Created ${configFileName}`); - } - - logNextSteps({ shouldInstallChecks }); - } catch (error) { - if (verbose) { - console.error(error); - console.log(c.red(` Something went wrong, please try again.`)); - } - } -}; - -const safeGetRootDirectory = async () => { - try { - return await getRootDirectory(); - } catch { - console.log( - `${c.bold( - '\nUnable to find a lockfile', - )}\n\nThis command must be run within a project managed by a JavaScript package manager`, - ); - process.exit(1); - } -}; - -export const init = command - .name('init') - .description('Setup Commonality in your project') - .option('--verbose', 'Show additional logging output') - .action(async (options: { verbose?: boolean }) => { - const rootDirectory = await safeGetRootDirectory(); - - action({ - rootDirectory, - verbose: options.verbose, - }); - }); diff --git a/apps/commonality/src/cli/commands/publish.ts b/apps/commonality/src/cli/commands/publish.ts new file mode 100644 index 00000000..8c06ee43 --- /dev/null +++ b/apps/commonality/src/cli/commands/publish.ts @@ -0,0 +1,112 @@ +/* eslint-disable unicorn/no-process-exit */ +import { getRootDirectory } from '@commonalityco/data-project'; +import { getCodeownersData } from '@commonalityco/data-codeowners'; +import { Command } from 'commander'; +import { + createSnapshotSchema, + CreateSnapshotSchema as CreateSnapshotSchemaType, +} from '@commonalityco/utils-core'; +import { getDependencies, getPackages } from '@commonalityco/data-packages'; +import ky, { HTTPError } from 'ky'; +import * as prompts from '@clack/prompts'; +import gitBranch from 'git-branch'; + +const command = new Command(); + +const publishSpinner = prompts.spinner(); + +export const publish = command + .name('publish') + .description('Publish a snapshot of your project to Commonality') + .option('--verbose', 'Show additional logging output') + .option( + '--api ', + 'The API URL to publish to', + process.env.COMMONALITY_API_URL ?? + 'https://app.commonality.co/api/v1/publish', + ) + .requiredOption( + '--project ', + 'The project ID to publish to', + process.env.COMMONALITY_PROJECT_ID, + ) + .requiredOption( + '--key ', + 'The publish key to publish with', + process.env.COMMONALITY_PUBLISH_KEY, + ) + .action(async (options) => { + try { + publishSpinner.start('Publishing snapshot...'); + + const { api, project, key, verbose } = options; + + const rootDirectory = await getRootDirectory(); + const blocks = await getPackages({ rootDirectory }); + + const codeowners = await getCodeownersData({ + rootDirectory, + packages: blocks, + }); + const dependencies = await getDependencies({ rootDirectory }); + + const data = { + publishKey: key, + projectId: project, + codeowners, + blocks, + dependencies, + gitBranch: await gitBranch(), + } satisfies CreateSnapshotSchemaType; + + const result = createSnapshotSchema.safeParse(data); + + if (!result.success) { + if (verbose) { + console.error(result.error); + } + + publishSpinner.stop('Failed to publish snapshot'); + prompts.log.error('Invalid snapshot data: ' + result.error); + return; + } + + try { + const response = await ky + .post(api, { + json: result.data, + }) + .json<{ message: string }>(); + + publishSpinner.stop(response.message); + } catch (error) { + if (error instanceof HTTPError) { + const errorJson = (await error.response.json()) as { + message: string; + }; + + if (verbose) { + console.error(error); + } + + publishSpinner.stop('Failed to publish snapshot'); + prompts.log.error(errorJson.message); + } else { + if (verbose) { + console.error(error); + } + + publishSpinner.stop('Failed to publish snapshot'); + } + + process.exit(1); + } + } catch (error) { + if (options.verbose) { + console.error(error); + } + + publishSpinner.stop('Failed to publish snapshot'); + process.exit(1); + } + }); diff --git a/apps/commonality/src/cli/commands/studio.ts b/apps/commonality/src/cli/commands/studio.ts deleted file mode 100644 index 58da86e6..00000000 --- a/apps/commonality/src/cli/commands/studio.ts +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env node -import { Command } from 'commander'; -import getPort from 'get-port'; -import { validateProjectStructure } from '../utils/validate-project-structure.js'; -import { getRootDirectory } from '@commonalityco/data-project'; -import chalk from 'chalk'; -import waitOn from 'wait-on'; -import url from 'node:url'; -import { resolveModule } from 'local-pkg'; -import ora from 'ora'; -import boxen from 'boxen'; -import ip from 'ip'; - -const command = new Command(); - -const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); - -const DEPENDENCY_NAME = '@commonalityco/studio'; - -const spinner = ora('Starting Commonality Studio...'); - -export const studio = command - .name('studio') - .description('Open Commonality Studio') - .option('--verbose', 'Show additional logging output') - .option( - '--port ', - 'The port that Commonality Studio will run on', - '8888', - ) - .action( - async (options: { - verbose?: boolean; - port?: string; - install?: boolean; - }) => { - await validateProjectStructure({ - directory: process.cwd(), - command, - }); - - const preferredPort = Number(options.port); - const verbose = Boolean(options.verbose); - - try { - console.log(); - spinner.start(); - - const rootDirectory = await getRootDirectory(); - - const resolved = resolveModule(DEPENDENCY_NAME, { - paths: [rootDirectory, __dirname], - }); - - if (!resolved) { - console.log( - '\nCommonality Studio is not installed, try running the install command for your package manager.', - ); - return; - } - - const studio = await import(resolved); - - const port = await getPort({ - port: preferredPort, - }); - - const { kill } = studio.startStudio({ - port, - rootDirectory, - debug: verbose, - }); - - const handleExit = () => { - kill(); - console.log('\nSuccessfully exited Commonality Studio'); - process.exit(); - }; - - process.on('SIGINT', handleExit); - process.on('SIGTERM', handleExit); - - const localUrl = `http://localhost:${port}/`; - const networkUrl = `http://${ip.address()}:${port}/`; - - await waitOn({ resources: [localUrl], timeout: 10_000 }); - - spinner.stop(); - - console.log( - boxen( - `${chalk.bold.underline('Welcome to Commonality Studio')}` + - `\n\nLocal: ${chalk.blue.bold(localUrl)}` + - `\nNetwork: ${chalk.blue.bold(networkUrl)}` + - chalk.dim('\n\n(press ctrl-c to quit)'), - { padding: 1, borderColor: 'gray' }, - ), - ); - } catch (error) { - spinner.fail('Failed to start Commonality Studio'); - - if (verbose) { - console.log(error); - } - } - }, - ); diff --git a/apps/commonality/src/cli/utils/validate-project-structure.test.ts b/apps/commonality/src/cli/utils/validate-project-structure.test.ts index 52e7d5a6..9738826a 100644 --- a/apps/commonality/src/cli/utils/validate-project-structure.test.ts +++ b/apps/commonality/src/cli/utils/validate-project-structure.test.ts @@ -19,6 +19,11 @@ const consoleMock = { }; describe('validateProjectStructure', () => { + const temporaryDirectoryPath = path.join( + process.env['RUNNER_TEMP'] || os.tmpdir(), + 'validate-project-structure-', + ); + beforeEach(() => { vi.stubGlobal('console', consoleMock); }); @@ -28,7 +33,6 @@ describe('validateProjectStructure', () => { }); describe('when there is no lockfile', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), @@ -62,7 +66,6 @@ describe('validateProjectStructure', () => { }); describe('when there is no root package', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), @@ -98,7 +101,6 @@ describe('validateProjectStructure', () => { }); describe('when there is an invalid root package.json', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), @@ -134,7 +136,6 @@ describe('validateProjectStructure', () => { }); describe('when running at the root of a valid project', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), @@ -167,7 +168,6 @@ describe('validateProjectStructure', () => { }); describe('displays a warning for skipped packages', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), @@ -201,7 +201,6 @@ describe('validateProjectStructure', () => { }); describe('when running within a sub-directory of a valid project', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), diff --git a/apps/commonality/test/integration/check.test.ts b/apps/commonality/test/integration/check.test.ts deleted file mode 100644 index 8807b945..00000000 --- a/apps/commonality/test/integration/check.test.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { describe, test, expect, vi } from 'vitest'; -import fs from 'fs-extra'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { execa } from 'execa'; -import os from 'node:os'; -import stripAnsi from 'strip-ansi'; - -const binPath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../bin.js', -); - -describe('check', () => { - test( - 'logs the URL to open Commonality Studio in a pnpm monorepo', - async () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); - const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); - - const fixturePath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../test/fixtures/with-configuration', - ); - await fs.copy(fixturePath, temporaryPath); - - const cliProcess = execa(binPath, ['check', '--debug'], { - cwd: temporaryPath, - stdout: 'pipe', - }); - - let output = ''; - - cliProcess.stdout?.on('data', (data) => { - console.log('pnpm:', data.toString()); - output += stripAnsi(data.toString()); - }); - cliProcess.stderr?.on('data', (data) => { - console.log('pnpm:', data.toString()); - output += stripAnsi(data.toString()); - }); - - await vi.waitFor( - () => { - expect(output).toContain('⚠ packages/pkg-two/package.json'); - }, - { timeout: 50_000 }, - ); - - await vi.waitFor( - () => { - expect(output).toContain('✓ pkg-one (1)'); - }, - { timeout: 50_000 }, - ); - - await vi.waitFor( - () => { - expect(output).toContain( - `Packages: 0 failed 0 warnings 1 passed (1)`, - ); - }, - { timeout: 100_000 }, - ); - - cliProcess?.kill(); - - await fs.remove(temporaryPath); - }, - { timeout: 200_000 }, - ); -}); diff --git a/apps/commonality/test/integration/init.test.ts b/apps/commonality/test/integration/init.test.ts deleted file mode 100644 index 728efea8..00000000 --- a/apps/commonality/test/integration/init.test.ts +++ /dev/null @@ -1,262 +0,0 @@ -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { describe, expect, it, vi } from 'vitest'; -import { execa } from 'execa'; -import stripAnsi from 'strip-ansi'; -import os from 'node:os'; -import fs from 'fs-extra'; - -const binPath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../bin.js', -); - -describe('init', () => { - it('shows an error if run outside a project', async () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); - const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); - - const initProcess = execa(binPath, ['init', '--verbose'], { - cwd: temporaryPath, - stdout: 'pipe', - env: { - DO_NOT_TRACK: '1', - }, - }); - - let initOutput = ''; - initProcess.stdout?.on('data', (data) => { - console.log({ out: data.toString() }); - initOutput += stripAnsi(data.toString()); - }); - initProcess.stderr?.on('data', (data) => { - console.log({ err: data.toString() }); - initOutput += stripAnsi(data.toString()); - }); - - await vi.waitFor( - () => { - expect(initOutput).toContain(`Unable to find a lockfile`); - }, - { timeout: 100_000 }, - ); - }); - - describe.each([ - { - fixtureName: 'kitchen-sink', - }, - { - fixtureName: 'kitchen-sink-yarn', - }, - { - fixtureName: 'kitchen-sink-npm', - }, - ])('when the package manager is $packageManager', ({ fixtureName }) => { - it( - 'initializes a new project with checks', - async () => { - const temporaryDirectoryPath = - process.env['RUNNER_TEMP'] || os.tmpdir(); - const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); - - const fixturePath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - `../../test/fixtures/${fixtureName}`, - ); - - await fs.copy(fixturePath, temporaryPath); - await execa('corepack', ['install'], { - cwd: temporaryPath, - }); - const initProcess = execa(binPath, ['init', '--verbose'], { - cwd: temporaryPath, - stdout: 'pipe', - env: { - DO_NOT_TRACK: '1', - }, - }); - - let initOutput = ''; - initProcess.stdout?.on('data', (data) => { - console.log({ out: data.toString() }); - initOutput += stripAnsi(data.toString()); - }); - initProcess.stderr?.on('data', (data) => { - console.log({ err: data.toString() }); - initOutput += stripAnsi(data.toString()); - }); - - await vi.waitFor( - () => { - expect(initOutput).toContain( - `Would you like to install our recommended checks?`, - ); - }, - { timeout: 100_000 }, - ); - - initProcess.stdin?.write('\n'); - - await vi.waitFor(() => { - expect(initOutput).toContain(`Installing commonality`); - }); - await vi.waitFor( - () => { - expect(initOutput).toContain(`Installed commonality`); - }, - { timeout: 250_000 }, - ); - - await vi.waitFor(() => { - expect(initOutput).toContain( - `Installing commonality-checks-recommended`, - ); - }); - await vi.waitFor( - () => { - expect(initOutput).toContain( - `Installed commonality-checks-recommended`, - ); - }, - { timeout: 250_000 }, - ); - - await vi.waitFor(() => { - expect(initOutput).toContain(`Creating .commonality/config.json`); - }); - await vi.waitFor( - () => { - expect(initOutput).toContain(`Created .commonality/config.json`); - }, - { timeout: 100_000 }, - ); - - await vi.waitFor(() => { - expect(initOutput).toContain(`You're all set up!`); - }); - - const configExists = await fs.exists( - path.resolve(temporaryPath, '.commonality/config.json'), - ); - - expect(configExists).toBe(true); - - const configContent = await fs.readJSON( - path.resolve(temporaryPath, '.commonality/config.json'), - ); - - expect(configContent).toEqual({ - $schema: 'https://commonality.co/config.json', - checks: { - '*': [ - 'recommended/has-readme', - 'recommended/has-codeowner', - 'recommended/valid-package-name', - 'recommended/unique-dependency-types', - 'recommended/sorted-dependencies', - 'recommended/matching-dev-peer-versions', - 'recommended/consistent-external-version', - 'recommended/extends-repository-field', - ], - }, - constraints: {}, - }); - }, - { timeout: 250_000 }, - ); - - it( - 'initializes a new project with no checks', - async () => { - const temporaryDirectoryPath = - process.env['RUNNER_TEMP'] || os.tmpdir(); - const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); - - const fixturePath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - `../../test/fixtures/${fixtureName}`, - ); - - await fs.copy(fixturePath, temporaryPath); - await execa('corepack', ['install'], { - cwd: temporaryPath, - }); - - const initProcess = execa(binPath, ['init', '--verbose'], { - cwd: temporaryPath, - stdout: 'pipe', - env: { - DO_NOT_TRACK: '1', - }, - }); - - let initOutput = ''; - initProcess.stdout?.on('data', (data) => { - console.log({ out: data.toString() }); - initOutput += stripAnsi(data.toString()); - }); - initProcess.stderr?.on('data', (data) => { - console.log({ err: data.toString() }); - initOutput += stripAnsi(data.toString()); - }); - - await vi.waitFor( - () => { - expect(initOutput).toContain( - `Would you like to install our recommended checks?`, - ); - }, - { timeout: 100_000 }, - ); - - initProcess.stdin?.write('\u001B[D'); - initProcess.stdin?.write('\n'); - - await vi.waitFor( - () => { - expect(initOutput).toContain(`Installing commonality`); - }, - { timeout: 100_000 }, - ); - await vi.waitFor( - () => { - expect(initOutput).toContain(`Installed commonality`); - }, - { timeout: 250_000 }, - ); - - await vi.waitFor(() => { - expect(initOutput).toContain(`Creating .commonality/config.json`); - }); - await vi.waitFor( - () => { - expect(initOutput).toContain(`Created .commonality/config.json`); - }, - { timeout: 100_000 }, - ); - - await vi.waitFor(() => { - expect(initOutput).toContain(`You're all set up!`); - }); - - const configExists = await fs.exists( - path.resolve(temporaryPath, '.commonality/config.json'), - ); - - expect(configExists).toBe(true); - - const configContent = await fs.readJSON( - path.resolve(temporaryPath, '.commonality/config.json'), - ); - - expect(configContent).toEqual({ - $schema: 'https://commonality.co/config.json', - checks: {}, - constraints: {}, - }); - }, - { timeout: 250_000 }, - ); - }); -}); diff --git a/apps/commonality/test/integration/smoke.test.ts b/apps/commonality/test/integration/smoke.test.ts index 64e7e09b..059d5cdb 100644 --- a/apps/commonality/test/integration/smoke.test.ts +++ b/apps/commonality/test/integration/smoke.test.ts @@ -12,8 +12,12 @@ const binPath = path.resolve( ); describe('smoke', () => { + const temporaryDirectoryPath = path.join( + process.env['RUNNER_TEMP'] || os.tmpdir(), + 'smoke-', + ); + it('shows the default help information', async () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( diff --git a/apps/commonality/test/integration/studio.test.ts b/apps/commonality/test/integration/studio.test.ts deleted file mode 100644 index 69ce6751..00000000 --- a/apps/commonality/test/integration/studio.test.ts +++ /dev/null @@ -1,205 +0,0 @@ -import { describe, test, expect, vi } from 'vitest'; -import fs from 'fs-extra'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { execa } from 'execa'; -import os from 'node:os'; -import getPort from 'get-port'; -import stripAnsi from 'strip-ansi'; - -const binPath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../bin.js', -); - -describe.concurrent('studio', () => { - test( - 'logs the URL to open Commonality Studio in a pnpm monorepo', - async () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); - const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); - const preferredPort = await getPort(); - - const fixturePath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../test/fixtures/kitchen-sink', - ); - await fs.copy(fixturePath, temporaryPath); - - const cliProcess = execa( - binPath, - ['studio', '--verbose', '--port', String(preferredPort)], - { - cwd: temporaryPath, - stdout: 'pipe', - }, - ); - - let output = ''; - - cliProcess.stdout?.on('data', (data) => { - console.log('pnpm:', data.toString()); - output += stripAnsi(data.toString()); - }); - cliProcess.stderr?.on('data', (data) => { - console.log('pnpm:', data.toString()); - output += stripAnsi(data.toString()); - }); - - await vi.waitFor( - () => { - expect(output).toContain('Starting Commonality Studio...'); - }, - { timeout: 50_000 }, - ); - - await vi.waitFor( - () => { - expect(output).toContain( - `Local: http://localhost:${preferredPort}`, - ); - }, - { timeout: 100_000 }, - ); - - cliProcess.kill('SIGTERM', { - forceKillAfterTimeout: 2000, - }); - - await vi.waitFor(() => { - expect(output).toContain(`Successfully exited Commonality Studio`); - }); - - cliProcess?.kill(); - - await fs.remove(temporaryPath); - }, - { timeout: 200_000 }, - ); - - test( - 'logs the URL to open Commonality Studio in an npm monorepo', - async () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); - const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); - const preferredPort = await getPort(); - - const fixturePath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../test/fixtures/kitchen-sink-npm', - ); - await fs.copy(fixturePath, temporaryPath); - - const cliProcess = execa( - binPath, - ['studio', '--verbose', '--port', String(preferredPort)], - { - cwd: temporaryPath, - stdout: 'pipe', - }, - ); - - let output = ''; - cliProcess.stdout?.on('data', (data) => { - console.log('npm:', data.toString()); - output += stripAnsi(data.toString()); - }); - cliProcess.stderr?.on('data', (data) => { - console.log('npm:', data.toString()); - output += stripAnsi(data.toString()); - }); - - await vi.waitFor( - () => { - expect(output).toContain('Starting Commonality Studio...'); - }, - { timeout: 50_000 }, - ); - - await vi.waitFor( - () => { - expect(output).toContain( - `Local: http://localhost:${preferredPort}`, - ); - }, - { timeout: 100_000 }, - ); - - cliProcess.kill('SIGTERM', { - forceKillAfterTimeout: 2000, - }); - - await vi.waitFor(() => { - expect(output).toContain(`Successfully exited Commonality Studio`); - }); - - cliProcess?.kill(); - - await fs.remove(temporaryPath); - }, - { timeout: 200_000 }, - ); - - test( - 'logs the URL to open Commonality Studio in a yarn monorepo', - async () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); - const temporaryPath = fs.mkdtempSync(temporaryDirectoryPath); - const preferredPort = await getPort(); - - const fixturePath = path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../test/fixtures/kitchen-sink-yarn', - ); - await fs.copy(fixturePath, temporaryPath); - - const cliProcess = execa( - binPath, - ['studio', '--verbose', '--port', String(preferredPort)], - { - cwd: temporaryPath, - stdout: 'pipe', - }, - ); - - let output = ''; - cliProcess.stdout?.on('data', (data) => { - console.log('yarn:', data.toString()); - output += stripAnsi(data.toString()); - }); - cliProcess.stderr?.on('data', (data) => { - console.log('yarn:', data.toString()); - output += stripAnsi(data.toString()); - }); - - await vi.waitFor( - () => { - expect(output).toContain('Starting Commonality Studio...'); - }, - { timeout: 50_000 }, - ); - - await vi.waitFor( - () => { - expect(output).toContain( - `Local: http://localhost:${preferredPort}`, - ); - }, - { timeout: 100_000 }, - ); - - cliProcess.kill('SIGTERM', { - forceKillAfterTimeout: 2000, - }); - - await vi.waitFor(() => { - expect(output).toContain(`Successfully exited Commonality Studio`); - }); - - cliProcess?.kill(); - - await fs.remove(temporaryPath); - }, - { timeout: 60_000 }, // 1 minute - ); -}); diff --git a/apps/commonality/vite.integration.config.ts b/apps/commonality/vitest.integration.config.ts similarity index 100% rename from apps/commonality/vite.integration.config.ts rename to apps/commonality/vitest.integration.config.ts diff --git a/apps/studio/.eslintrc.json b/apps/studio/.eslintrc.json deleted file mode 100644 index bffb357a..00000000 --- a/apps/studio/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "next/core-web-vitals" -} diff --git a/apps/studio/.gitignore b/apps/studio/.gitignore deleted file mode 100644 index c39028dc..00000000 --- a/apps/studio/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts -/test-results/ -/playwright-report/ -/blob-report/ -/playwright/.cache/ - diff --git a/apps/studio/.npmignore b/apps/studio/.npmignore deleted file mode 100644 index 18110b98..00000000 --- a/apps/studio/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ -src -scripts -test -cypress -.turbo -.next/cache diff --git a/apps/studio/.vscode/settings.json b/apps/studio/.vscode/settings.json deleted file mode 100644 index b0ef59cf..00000000 --- a/apps/studio/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "typescript.tsdk": "../../node_modules/.pnpm/typescript@4.9.5/node_modules/typescript/lib", - "typescript.enablePromptUseWorkspaceTsdk": true -} \ No newline at end of file diff --git a/apps/studio/CHANGELOG.md b/apps/studio/CHANGELOG.md deleted file mode 100644 index 72f97ce0..00000000 --- a/apps/studio/CHANGELOG.md +++ /dev/null @@ -1,705 +0,0 @@ -# @commonalityco/dashboard - -## 0.2.57 - -### Patch Changes - -- ce1791f: fix studio versioning - -## 0.2.55 - -### Patch Changes - -- Updated dependencies [bfddcb3] - - @commonalityco/feature-graph@0.1.0 - -## 0.2.54 - -### Patch Changes - -- 5b8761b: Update layout of graph and deprecate packages -- Updated dependencies [5b8761b] - - @commonalityco/feature-graph@0.0.1 - -## 0.2.53 - -### Patch Changes - -- c064bff: updates dependency dialog and fixes constraints in studio -- 4ea105d: removes telemetry for CLI and Studio - -## 0.2.52 - -### Patch Changes - -- 7ba2c80: Make graph more responsive - -## 0.2.51 - -### Patch Changes - -- 67dadac: Allow for yarn berry workspaces definition - -## 0.2.50 - -### Patch Changes - -- 4f0f69c: Update dependency graph to use @xyflow/react - -## 0.2.49 - -### Patch Changes - -- b27e7a1: Adds anonymous telemetry to commonality and studio. View current telemetry status with `commonality telemetry list`. - -## 0.2.48 - -### Patch Changes - -- 8afb72a: Fixes a bug where codeowner paths would not match a path to a package directory - -## 0.2.47 - -### Patch Changes - -- 56baf27: Fixes an issue where package.json files with missing "name" properties would cause any command to throw an error. We now ignore these invalid packages and continue with the command while displaying an error. - -## 0.2.46 - -### Patch Changes - -- 65ee18a: This release addresses some common feedback around checks and initial setup. - - We are moving from a TS/JS configuration file to a JSON file (`.commonality/config.json`). It's common for developers to create custom checks during initial setup and the `.commonality` directory, will now act as a folder to organize these checks before moving them into a package. - - ```json - { - "checks": { - "*": [ - "has-client-eslint-config", - "recommended/sorted-dependencies", - "@scope/team/custom-check" - ] - } - } - ``` - - How checks are resolved in the JSON format: - - 1. Checks can be configured with a path to a local file, relative to the `.commonality` folder. Given a path `has-foo`, Commonality will first look for a file named "has-foo" within the `.commonality` folder. You can also pass a relative path like `./testing/has-foo` or `testing/has-foo` to organize checks within the `.commonality` folder. - 2. Checks can be configured via import path. Given a path `@scope/team/custom-check`, Commonality will look for a default export from an entry point named `custom-check` in the package named `@scope/team`. This logic follows the same convention as `import.meta.resolve`. - 3. Checks can be configured via a shortened import path. Given a path `test/has-foo`, if there is no file located at `.commonality/test/has-foo.ts` then it will look for a package named `commonality-checks-test` with an entry point named `has-foo`. This allows for a standard convention and a more readable configuration file similar to eslint. - - Previously the `message` property for a check object allowed a function that could be used to dynamically create an error message. There ended up being a lot of duplicated logic between the `message` and `validate` function and in some cases the two could become out of sync for certain cases. This change change the `message` property to only expect a string, ensuring that the happy path message will always be shown when running `check --verbose`. To create a dynamic message, simply return a message object from the `validate` function. Now, Commonality will return a `fail` or `warn` status for any check who's `validate` function returns a value other than `true.` - - We now automatically create an id for each check on file resolution so the name property is no longer required to parallelize check functions. - -## 0.2.45 - -### Patch Changes - -- 4e64f3e: Fixes issue where missing files prevented Studio from starting up - -## 0.2.44 - -### Patch Changes - -- d719a75: Updates logging information for Studio failures - -## 0.2.43 - -### Patch Changes - -- 9458463: Fix issue where graph would reload multiple times on initial page load - -## 0.2.42 - -### Patch Changes - -- 0faea77: Fixes an issue where the repository field check was creating an incorrectly formatted repository field - -## 0.2.41 - -### Patch Changes - -- a88e9ba: Removes the tag filter from checks and constraints UI for clarity - -## 0.2.40 - -### Patch Changes - -- b453952: Adds hasTextFile and hasJsonFile utility checks. Adds @commonalityco/studio as a dependency to commonality. - -## 0.2.39 - -### Patch Changes - -- 7e440ac: Moves checks and constraints into dedicated modal -- a8cda3c: Drastically reduce bundle size by deduping and selectively importing - -## 0.2.38 - -### Patch Changes - -- 4661b6b: Display dependency constraints in searchable modal - -## 0.2.37 - -### Patch Changes - -- cd668c3: Include updates to upstream packages - -## 0.2.36 - -### Patch Changes - -- 3f1e821: Improve tag editing and constraints UX in Commonality Studio - -## 0.2.35 - -### Patch Changes - -- e4e3ba0: Update color palette to all neutral and fix tailwind global.css issue - -## 0.2.34 - -### Patch Changes - -- 447c12d: Fixes an issue where checks were incorrectly rendering in Commonality Studio -- 665a457: Link all @commonalityco packages and fix missing checks - -## 0.2.33 - -### Patch Changes - -- d9e7a5d: fix(studio): add PATH variable for server starting - -## 0.2.32 - -### Patch Changes - -- 70ac615: Fixes an issue where you could not exit out of the studio process if the Commonality Studio port never becomes available -- 202b591: Fixes initialization issues with Commonality Studio and broken links - -## 0.2.31 - -### Patch Changes - -- 74e1a9c: update engines - -## 0.2.30 - -### Patch Changes - -- d693d39: Update Commonality Studio styles - -## 0.2.29 - -### Patch Changes - -- 4bd3547: Create granular packages - -## 0.2.28 - -### Patch Changes - -- 129d264: stability - -## 0.2.27 - -### Patch Changes - -- 25fcefa: Fix studio startup - -## 0.2.26 - -### Patch Changes - -- Updated dependencies [33f249e] - - @commonalityco/feature-conformance@0.0.20 - -## 0.2.25 - -### Patch Changes - -- 2fdde68: Export start script\ - -## 0.2.24 - -### Patch Changes - -- Updated dependencies [1a98bec] - - @commonalityco/feature-conformance@0.0.19 - -## 0.2.23 - -### Patch Changes - -- ad4a813: Finalize Commonality Studio, checks, and constraints -- Updated dependencies [ad4a813] - - @commonalityco/feature-conformance@0.0.18 - - @commonalityco/feature-constraints@0.0.18 - - @commonalityco/ui-design-system@0.0.13 - - @commonalityco/data-codeowners@0.0.17 - - @commonalityco/data-packages@0.0.18 - - @commonalityco/utils-package@0.0.11 - - @commonalityco/data-project@0.0.12 - - @commonalityco/ui-package@0.0.16 - - @commonalityco/utils-core@0.0.11 - - @commonalityco/data-tags@0.0.13 - - @commonalityco/ui-core@0.0.15 - -## 0.2.22 - -### Patch Changes - -- 99531bd: Cache result of graph calculations -- Updated dependencies [99531bd] - - @commonalityco/data-graph-worker@0.0.9 - - @commonalityco/data-codeowners@0.0.16 - - @commonalityco/data-graph@0.0.12 - - @commonalityco/ui-package@0.0.15 - - @commonalityco/ui-graph@0.0.15 - - @commonalityco/feature-graph@0.0.13 - -## 0.2.20 - -### Patch Changes - -- 97987b9: fix bugs in package table -- Updated dependencies [97987b9] - - @commonalityco/ui-package@0.0.14 - - @commonalityco/ui-core@0.0.14 - - @commonalityco/ui-graph@0.0.14 - -## 0.2.19 - -### Patch Changes - -- e9a5bc2: Add table view to Studio -- Updated dependencies [e9a5bc2] - - @commonalityco/data-graph-worker@0.0.8 - - @commonalityco/ui-design-system@0.0.12 - - @commonalityco/data-codeowners@0.0.15 - - @commonalityco/data-violations@0.0.15 - - @commonalityco/data-documents@0.0.12 - - @commonalityco/data-packages@0.0.17 - - @commonalityco/feature-graph@0.0.13 - - @commonalityco/utils-package@0.0.10 - - @commonalityco/data-project@0.0.11 - - @commonalityco/utils-graph@0.0.11 - - @commonalityco/data-graph@0.0.11 - - @commonalityco/utils-core@0.0.10 - - @commonalityco/data-tags@0.0.12 - - @commonalityco/ui-graph@0.0.14 - - @commonalityco/ui-core@0.0.13 - -## 0.2.17 - -### Patch Changes - -- a7a22e3: bundle CLI -- Updated dependencies [a7a22e3] - - @commonalityco/feature-graph@0.0.12 - -## 0.2.16 - -### Patch Changes - -- ffbc45c: Fixed graph color and reduced bundle size dramatically -- Updated dependencies [ffbc45c] - - @commonalityco/ui-design-system@0.0.11 - - @commonalityco/data-violations@0.0.14 - - @commonalityco/feature-graph@0.0.11 - - @commonalityco/utils-package@0.0.9 - - @commonalityco/utils-graph@0.0.10 - - @commonalityco/data-graph@0.0.10 - - @commonalityco/utils-core@0.0.9 - - @commonalityco/ui-graph@0.0.13 - - @commonalityco/ui-core@0.0.12 - - @commonalityco/data-documents@0.0.11 - - @commonalityco/data-packages@0.0.16 - - @commonalityco/data-project@0.0.10 - - @commonalityco/data-tags@0.0.11 - -## 0.2.15 - -### Patch Changes - -- 5b61b0e: Reduce bundle size -- Updated dependencies [5b61b0e] - - @commonalityco/data-graph-worker@0.0.7 - - @commonalityco/ui-design-system@0.0.10 - - @commonalityco/feature-graph@0.0.10 - - @commonalityco/utils-package@0.0.8 - - @commonalityco/utils-graph@0.0.9 - - @commonalityco/data-graph@0.0.9 - - @commonalityco/utils-core@0.0.8 - - @commonalityco/ui-graph@0.0.12 - - @commonalityco/ui-core@0.0.11 - - @commonalityco/data-documents@0.0.10 - - @commonalityco/data-packages@0.0.15 - - @commonalityco/data-project@0.0.9 - - @commonalityco/data-tags@0.0.10 - -## 0.2.14 - -### Patch Changes - -- 91bfd71: Unify into commonality package -- Updated dependencies [91bfd71] - - @commonalityco/data-graph-worker@0.0.6 - - @commonalityco/ui-design-system@0.0.9 - - @commonalityco/data-codeowners@0.0.14 - - @commonalityco/data-violations@0.0.13 - - @commonalityco/data-documents@0.0.9 - - @commonalityco/data-packages@0.0.14 - - @commonalityco/feature-graph@0.0.9 - - @commonalityco/data-project@0.0.8 - - @commonalityco/data-graph@0.0.8 - - @commonalityco/data-tags@0.0.9 - - @commonalityco/ui-graph@0.0.11 - - @commonalityco/ui-core@0.0.10 - - @commonalityco/utils-graph@0.0.8 - - @commonalityco/utils-package@0.0.7 - -## 0.2.13 - -### Patch Changes - -- Updated dependencies [e4075d7] - - @commonalityco/utils-graph@0.0.8 - -## 0.2.12 - -### Patch Changes - -- Updated dependencies [26e1636] - - @commonalityco/data-graph-worker@0.0.5 - - @commonalityco/ui-design-system@0.0.8 - - @commonalityco/data-violations@0.0.12 - - @commonalityco/data-packages@0.0.13 - - @commonalityco/feature-graph@0.0.8 - - @commonalityco/utils-graph@0.0.7 - - @commonalityco/data-graph@0.0.7 - - @commonalityco/utils-core@0.0.7 - - @commonalityco/ui-graph@0.0.10 - - @commonalityco/ui-core@0.0.9 - - @commonalityco/data-documents@0.0.8 - - @commonalityco/data-project@0.0.7 - - @commonalityco/data-tags@0.0.8 - - @commonalityco/utils-package@0.0.7 - -## 0.2.11 - -### Patch Changes - -- Updated dependencies [986fdbf] - - @commonalityco/ui-design-system@0.0.7 - - @commonalityco/ui-graph@0.0.9 - -## 0.2.10 - -### Patch Changes - -- Updated dependencies [a7691a8] - - @commonalityco/ui-design-system@0.0.6 - - @commonalityco/data-codeowners@0.0.13 - - @commonalityco/data-violations@0.0.11 - - @commonalityco/data-documents@0.0.7 - - @commonalityco/data-packages@0.0.12 - - @commonalityco/utils-package@0.0.6 - - @commonalityco/data-project@0.0.6 - - @commonalityco/utils-graph@0.0.6 - - @commonalityco/utils-core@0.0.6 - - @commonalityco/data-tags@0.0.7 - -## 0.2.9 - -### Patch Changes - -- 0457822: add link command -- Updated dependencies [0457822] - - @commonalityco/data-codeowners@0.0.12 - -## 0.2.8 - -### Patch Changes - -- a4e018c: Bundle CLI -- Updated dependencies [a4e018c] - - @commonalityco/data-codeowners@0.0.11 - -## 0.2.7 - -### Patch Changes - -- 37f1a87: Distribute dist/ - -## 0.2.6 - -### Patch Changes - -- ee3504f: Distribute studio /dist -- Updated dependencies [ee3504f] - - @commonalityco/data-graph-worker@0.0.4 - - @commonalityco/ui-design-system@0.0.5 - - @commonalityco/data-codeowners@0.0.10 - - @commonalityco/data-violations@0.0.10 - - @commonalityco/data-documents@0.0.6 - - @commonalityco/data-packages@0.0.11 - - @commonalityco/feature-graph@0.0.7 - - @commonalityco/utils-package@0.0.5 - - @commonalityco/data-project@0.0.5 - - @commonalityco/utils-graph@0.0.5 - - @commonalityco/data-graph@0.0.6 - - @commonalityco/utils-core@0.0.5 - - @commonalityco/data-tags@0.0.6 - - @commonalityco/ui-graph@0.0.8 - - @commonalityco/ui-core@0.0.8 - -## 0.2.5 - -### Patch Changes - -- dadeafb: Convert to ESM -- Updated dependencies [dadeafb] - - @commonalityco/data-codeowners@0.0.9 - - @commonalityco/data-documents@0.0.5 - - @commonalityco/data-graph@0.0.5 - - @commonalityco/data-graph-worker@0.0.3 - - @commonalityco/data-packages@0.0.10 - - @commonalityco/data-project@0.0.4 - - @commonalityco/data-tags@0.0.5 - - @commonalityco/data-violations@0.0.9 - - @commonalityco/feature-graph@0.0.6 - - @commonalityco/ui-core@0.0.6 - - @commonalityco/ui-design-system@0.0.4 - - @commonalityco/ui-graph@0.0.7 - - @commonalityco/utils-core@0.0.4 - - @commonalityco/utils-graph@0.0.4 - - @commonalityco/utils-package@0.0.4 - -## 0.2.4 - -### Patch Changes - -- Updated dependencies [479b297] - - @commonalityco/ui-graph@0.0.6 - - @commonalityco/ui-core@0.0.5 - -## 0.2.3 - -### Patch Changes - -- Updated dependencies [b03ab98] - - @commonalityco/data-packages@0.0.9 - -## 0.2.2 - -### Patch Changes - -- 597a229: Instantiate worker within application -- Updated dependencies [597a229] - - @commonalityco/data-graph-worker@0.0.2 - - @commonalityco/feature-graph@0.0.5 - - @commonalityco/data-graph@0.0.4 - -## 0.2.0 - -### Minor Changes - -- ed774a4: Lock step compatibility - -## 0.1.15 - -### Patch Changes - -- fb47c73: update build output - -## 0.1.14 - -### Patch Changes - -- d562884: Add zero state and feedback button - -## 0.1.13 - -### Patch Changes - -- 7d2d1da: ignore weird files and point to latest studio - -## 0.1.12 - -### Patch Changes - -- f82e714: "facepalm" - -## 0.1.11 - -### Patch Changes - -- 77244cc: Ugh - -## 0.1.10 - -### Patch Changes - -- c8fe893: Remove bundle analyzer from prod deps - -## 0.1.9 - -### Patch Changes - -- 24d85da: Remove internal deps from server.js - -## 0.1.8 - -### Patch Changes - -- d4515ef: prod to dev deps - -## 0.1.7 - -### Patch Changes - -- 76174e7: Add server.js to files - -## 0.1.6 - -### Patch Changes - -- fb9e932: update - -## 0.1.5 - -### Patch Changes - -- 94f9a78: Fix build output - -## 0.1.4 - -### Patch Changes - -- 3ff8242: Fix build target for CLI -- Updated dependencies [3ff8242] - - @commonalityco/data-documents@0.0.3 - - @commonalityco/data-tags@0.0.3 - -## 0.1.3 - -### Patch Changes - -- da2c556: Initial release -- Updated dependencies [da2c556] - - @commonalityco/types@0.0.9 - - @commonalityco/ui-core@0.0.2 - - @commonalityco/utils-core@0.0.2 - - @commonalityco/ui-design-system@0.0.2 - - @commonalityco/feature-graph@0.0.2 - - @commonalityco/ui-graph@0.0.2 - - @commonalityco/utils-graph@0.0.2 - - @commonalityco/data-codeowners@0.0.7 - - @commonalityco/data-documents@0.0.2 - - @commonalityco/data-packages@0.0.7 - - @commonalityco/data-project@0.0.2 - - @commonalityco/data-tags@0.0.2 - - @commonalityco/data-violations@0.0.7 - -## 0.1.2 - -### Patch Changes - -- 76ea8f2: Initial release -- Updated dependencies [76ea8f2] - - @commonalityco/ui-description-list@0.0.3 - - @commonalityco/ui-step-indicator@0.0.3 - - @commonalityco/ui-dropdown-menu@0.0.3 - - @commonalityco/codeowners@0.0.5 - - @commonalityco/ui-icon-button@0.0.3 - - @commonalityco/snapshot@0.0.6 - - @commonalityco/ui-form-error@0.0.3 - - @commonalityco/ui-side-panel@0.0.3 - - @commonalityco/ui-text-input@0.0.3 - - @commonalityco/ui-accordion@0.0.3 - - @commonalityco/ui-card-link@0.0.3 - - @commonalityco/ui-container@0.0.3 - - @commonalityco/ui-directory@0.0.3 - - @commonalityco/ui-paginator@0.0.3 - - @commonalityco/ui-checkbox@0.0.3 - - @commonalityco/ui-nav-link@0.0.3 - - @commonalityco/ui-skeleton@0.0.3 - - @commonalityco/types@0.0.7 - - @commonalityco/ui-divider@0.0.3 - - @commonalityco/ui-heading@0.0.3 - - @commonalityco/ui-popover@0.0.3 - - @commonalityco/ui-section@0.0.3 - - @commonalityco/ui-snippet@0.0.3 - - @commonalityco/ui-spinner@0.0.3 - - @commonalityco/ui-tooltip@0.0.3 - - @commonalityco/ui-avatar@0.0.3 - - @commonalityco/ui-button@0.0.3 - - @commonalityco/ui-center@0.0.3 - - @commonalityco/ui-dialog@0.0.3 - - @commonalityco/ui-select@0.0.3 - - @commonalityco/ui-toggle@0.0.3 - - @commonalityco/ui-label@0.0.3 - - @commonalityco/ui-radio@0.0.3 - - @commonalityco/ui-table@0.0.3 - - @commonalityco/ui-theme@0.0.3 - - @commonalityco/ui-toast@0.0.3 - - @commonalityco/ui-card@0.0.3 - - @commonalityco/ui-icon@0.0.3 - - @commonalityco/ui-link@0.0.3 - - @commonalityco/ui-tab@0.0.3 - - @commonalityco/ui-text@0.0.3 - - @commonalityco/ui-tag@0.0.3 - -## 0.1.1 - -### Patch Changes - -- 66e2af0: Initial publish -- Updated dependencies [66e2af0] - - @commonalityco/ui-description-list@0.0.2 - - @commonalityco/ui-step-indicator@0.0.2 - - @commonalityco/ui-dropdown-menu@0.0.2 - - @commonalityco/codeowners@0.0.4 - - @commonalityco/ui-icon-button@0.0.2 - - @commonalityco/snapshot@0.0.5 - - @commonalityco/ui-form-error@0.0.2 - - @commonalityco/ui-side-panel@0.0.2 - - @commonalityco/ui-text-input@0.0.2 - - @commonalityco/ui-accordion@0.0.2 - - @commonalityco/ui-card-link@0.0.2 - - @commonalityco/ui-container@0.0.2 - - @commonalityco/ui-directory@0.0.2 - - @commonalityco/ui-paginator@0.0.2 - - @commonalityco/ui-checkbox@0.0.2 - - @commonalityco/ui-nav-link@0.0.2 - - @commonalityco/ui-skeleton@0.0.2 - - @commonalityco/types@0.0.6 - - @commonalityco/ui-divider@0.0.2 - - @commonalityco/ui-heading@0.0.2 - - @commonalityco/ui-popover@0.0.2 - - @commonalityco/ui-section@0.0.2 - - @commonalityco/ui-snippet@0.0.2 - - @commonalityco/ui-spinner@0.0.2 - - @commonalityco/ui-tooltip@0.0.2 - - @commonalityco/ui-avatar@0.0.2 - - @commonalityco/ui-button@0.0.2 - - @commonalityco/ui-center@0.0.2 - - @commonalityco/ui-dialog@0.0.2 - - @commonalityco/ui-select@0.0.2 - - @commonalityco/ui-toggle@0.0.2 - - @commonalityco/ui-label@0.0.2 - - @commonalityco/ui-radio@0.0.2 - - @commonalityco/ui-table@0.0.2 - - @commonalityco/ui-theme@0.0.2 - - @commonalityco/ui-toast@0.0.2 - - @commonalityco/ui-card@0.0.2 - - @commonalityco/ui-icon@0.0.2 - - @commonalityco/ui-link@0.0.2 - - @commonalityco/ui-tab@0.0.2 - - @commonalityco/ui-text@0.0.2 - - @commonalityco/ui-tag@0.0.2 diff --git a/apps/studio/README.md b/apps/studio/README.md deleted file mode 100644 index b353d141..00000000 --- a/apps/studio/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# @commonalityco/studio -> The Next.js application that powers Commonality Studio -## Installation - -```sh -npm install @commonalityco/studio -``` \ No newline at end of file diff --git a/apps/studio/commonality.json b/apps/studio/commonality.json deleted file mode 100644 index 43ad6695..00000000 --- a/apps/studio/commonality.json +++ /dev/null @@ -1 +0,0 @@ -{"tags":["application"]} diff --git a/apps/studio/cypress.config.ts b/apps/studio/cypress.config.ts deleted file mode 100644 index 59356045..00000000 --- a/apps/studio/cypress.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from 'cypress'; -import path from 'path'; - -export default defineConfig({ - e2e: { - setupNodeEvents(on, config) { - // implement node event listeners here - }, - baseUrl: 'http://localhost:3000', - }, -}); diff --git a/apps/studio/cypress/e2e/smoke.cy.ts b/apps/studio/cypress/e2e/smoke.cy.ts deleted file mode 100644 index bceb50ba..00000000 --- a/apps/studio/cypress/e2e/smoke.cy.ts +++ /dev/null @@ -1,17 +0,0 @@ -describe('when visiting the index page', () => { - it('loads correctly', () => { - cy.visit('/').contains('monorepo'); - }); -}); - -describe('when visiting any other page', () => { - it('redirects back to the index page', () => { - cy.visit('/random-url').url().should('eq', 'http://localhost:3000/'); - }); -}); - -describe('clicking on a node', () => { - it('passes', () => { - cy.get('canvas').get(''); - }); -}); diff --git a/apps/studio/cypress/fixtures/example.json b/apps/studio/cypress/fixtures/example.json deleted file mode 100644 index 02e42543..00000000 --- a/apps/studio/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} diff --git a/apps/studio/cypress/support/commands.ts b/apps/studio/cypress/support/commands.ts deleted file mode 100644 index 2ed74fb3..00000000 --- a/apps/studio/cypress/support/commands.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// -// *********************************************** -// This example commands.ts shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -// -// declare global { -// namespace Cypress { -// interface Chainable { -// login(email: string, password: string): Chainable -// drag(subject: string, options?: Partial): Chainable -// dismiss(subject: string, options?: Partial): Chainable -// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable -// } -// } -// } - -export {}; diff --git a/apps/studio/cypress/support/e2e.ts b/apps/studio/cypress/support/e2e.ts deleted file mode 100644 index 598ab5f0..00000000 --- a/apps/studio/cypress/support/e2e.ts +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example support/e2e.ts is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands'; - -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/apps/studio/cypress/tsconfig.json b/apps/studio/cypress/tsconfig.json deleted file mode 100644 index 44cb4f86..00000000 --- a/apps/studio/cypress/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": ["es5", "dom"], - "types": ["cypress", "node"], - "isolatedModules": true - }, - "include": ["**/*.ts"] -} diff --git a/apps/studio/e2e/smoke.spec.ts b/apps/studio/e2e/smoke.spec.ts deleted file mode 100644 index 89df8189..00000000 --- a/apps/studio/e2e/smoke.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('smoke - constraints', async ({ page }) => { - await page.goto('/'); - - await expect(page.getByTestId('dependency-graph')).toBeVisible(); -}); diff --git a/apps/studio/env.d.ts b/apps/studio/env.d.ts deleted file mode 100644 index 8cadbb66..00000000 --- a/apps/studio/env.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -namespace NodeJS { - interface ProcessEnv { - COMMONALITY_ROOT_DIRECTORY: string; - NODE_ENV: string; - } -} diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/package.json b/apps/studio/fixtures/kitchen-sink-pnpm/package.json deleted file mode 100644 index 9c111d1c..00000000 --- a/apps/studio/fixtures/kitchen-sink-pnpm/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "monorepo" -} diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-four/package.json b/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-four/package.json deleted file mode 100644 index 192b6204..00000000 --- a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-four/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "pkg-four" -} diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-one/commonality.json b/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-one/commonality.json deleted file mode 100644 index 7123cb85..00000000 --- a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-one/commonality.json +++ /dev/null @@ -1 +0,0 @@ -{"tags":[]} diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-one/package.json b/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-one/package.json deleted file mode 100644 index 2d8e8514..00000000 --- a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-one/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "pkg-one", - "dependencies": { - "pkg-two": "*", - "pkg-four": "*" - } -} diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-three/package.json b/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-three/package.json deleted file mode 100644 index 69608633..00000000 --- a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-three/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "pkg-three" -} diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-two/package.json b/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-two/package.json deleted file mode 100644 index 0199303b..00000000 --- a/apps/studio/fixtures/kitchen-sink-pnpm/packages/pkg-two/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "pkg-two", - "dependencies": { - "pkg-three": "*" - } -} diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/pnpm-lock.yaml b/apps/studio/fixtures/kitchen-sink-pnpm/pnpm-lock.yaml deleted file mode 100644 index e69de29b..00000000 diff --git a/apps/studio/fixtures/kitchen-sink-pnpm/pnpm-workspace.yaml b/apps/studio/fixtures/kitchen-sink-pnpm/pnpm-workspace.yaml deleted file mode 100644 index 222c943f..00000000 --- a/apps/studio/fixtures/kitchen-sink-pnpm/pnpm-workspace.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - - './packages/**' - - './apps/**' diff --git a/apps/studio/next.config.js b/apps/studio/next.config.js deleted file mode 100644 index 3b64cd9b..00000000 --- a/apps/studio/next.config.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - reactStrictMode: true, - transpilePackages: [ - '@commonalityco/ui-design-system', - '@commonalityco/ui-core', - '@commonalityco/feature-graph', - ], - async redirects() { - return [ - { - source: '/:path+', - destination: '/', - permanent: false, // Set to true if you want the redirect to be permanent - basePath: false, - }, - ]; - }, -}; diff --git a/apps/studio/package.json b/apps/studio/package.json deleted file mode 100644 index 2816dfa8..00000000 --- a/apps/studio/package.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "name": "@commonalityco/studio", - "description": "The Next.js application that powers Commonality Studio", - "version": "0.2.57", - "publishConfig": { - "access": "public" - }, - "engines": { - "node": ">=18.17.0" - }, - "scripts": { - "dev": "COMMONALITY_ROOT_DIRECTORY='../../' NODE_ENV=development node server.js --turbo", - "build": "next build && pnpm run clean-cache", - "clean-cache": "rimraf .next/cache", - "analyze": "ANALYZE=true next build", - "start": "NODE_ENV=production node server.js", - "lint": "eslint .", - "test": "vitest", - "e2e": "playwright test", - "e2e:ui": "playwright test --ui", - "type-check": "tsc --noEmit", - "lint:fix": "eslint . --fix" - }, - "main": "./start.mjs", - "files": [ - ".next/", - "start.mjs", - "next.config.js", - "server.js", - "dist/" - ], - "dependencies": { - "@xyflow/react": "12.0.0-next.11", - "@xyflow/system": "^0.0.17", - "chokidar": "^3.6.0", - "execa": "^8.0.1", - "framer-motion": "^11.0.5", - "jotai": "^2.6.5", - "lz-string": "^1.5.0", - "next": "14.0.4", - "nuqs": "^1.17.0", - "socket.io": "^4.7.4", - "socket.io-client": "^4.7.4" - }, - "devDependencies": { - "@babel/core": "^7.23.9", - "@babel/preset-env": "^7.23.9", - "@commonalityco/config-tailwind": "workspace:*", - "@commonalityco/data-codeowners": "workspace:*", - "@commonalityco/data-constraints": "workspace:*", - "@commonalityco/data-packages": "workspace:*", - "@commonalityco/data-project": "workspace:*", - "@commonalityco/data-tags": "workspace:*", - "@commonalityco/types": "workspace:*", - "@commonalityco/ui-core": "workspace:*", - "@commonalityco/ui-design-system": "workspace:*", - "@commonalityco/feature-graph": "workspace:*", - "@commonalityco/utils-conformance": "workspace:*", - "@commonalityco/utils-core": "workspace:*", - "@commonalityco/utils-package": "workspace:*", - "@hookform/resolvers": "^3.3.4", - "@next/bundle-analyzer": "^13.5.6", - "@playwright/test": "^1.41.2", - "@tanstack/react-query": "^4.36.1", - "@tanstack/react-query-devtools": "^5.24.0", - "@tanstack/react-table": "^8.13.2", - "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^14.2.1", - "@testing-library/user-event": "^14.5.2", - "@total-typescript/ts-reset": "^0.5.1", - "@types/fs-extra": "^11.0.4", - "@types/lodash-es": "^4.17.12", - "@types/node": "^20.11.20", - "@types/react": "^18.2.57", - "@types/react-dom": "^18.2.19", - "@types/resolve": "^1.20.6", - "@vitejs/plugin-react-swc": "^3.6.0", - "autoprefixer": "^10.4.17", - "bufferutil": "^4.0.8", - "class-variance-authority": "^0.7.0", - "clsx": "^2.1.0", - "cookies-next": "^4.1.1", - "cypress": "^13.6.5", - "date-fns": "^2.30.0", - "eslint-config-next": "^14.1.0", - "fs-extra": "^11.2.0", - "get-port": "^7.0.0", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0", - "lodash-es": "^4.17.21", - "lucide-react": "^0.317.0", - "next-themes": "^0.2.1", - "open-editor": "^4.1.1", - "path-browserify": "^1.0.1", - "pino": "^8.19.0", - "postcss": "^8.4.35", - "prettier": "^3.2.5", - "prettier-plugin-tailwindcss": "^0.5.11", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-hook-form": "^7.50.1", - "rimraf": "^5.0.5", - "server-only": "^0.0.1", - "start-server-and-test": "^2.0.3", - "strip-ansi": "^7.1.0", - "tailwindcss": "^3.4.1", - "ts-node": "^10.9.2", - "typescript": "^5.3.3", - "utf-8-validate": "^6.0.3", - "vite-tsconfig-paths": "^4.3.1", - "which-collection": "^1.0.1", - "zod": "^3.22.4" - }, - "repository": { - "type": "git", - "url": "https://github.com/commonalityco/commonality", - "directory": "apps/studio" - } -} diff --git a/apps/studio/playwright.config.ts b/apps/studio/playwright.config.ts deleted file mode 100644 index 29973144..00000000 --- a/apps/studio/playwright.config.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { defineConfig, devices } from '@playwright/test'; - -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// require('dotenv').config(); - -/** - * See https://playwright.dev/docs/test-configuration. - */ -export default defineConfig({ - testDir: './e2e', - /* Run tests in files in parallel */ - fullyParallel: true, - /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: !!process.env.CI, - /* Retry on CI only */ - retries: process.env.CI ? 2 : 0, - /* Opt out of parallel tests on CI. */ - workers: process.env.CI ? 1 : undefined, - /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', - /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ - use: { - /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: 'http://127.0.0.1:8888', - - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', - }, - - /* Configure projects for major browsers */ - projects: [ - { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, - }, - - { - name: 'firefox', - use: { ...devices['Desktop Firefox'] }, - }, - - { - name: 'webkit', - use: { ...devices['Desktop Safari'] }, - }, - - /* Test against mobile viewports. */ - // { - // name: 'Mobile Chrome', - // use: { ...devices['Pixel 5'] }, - // }, - // { - // name: 'Mobile Safari', - // use: { ...devices['iPhone 12'] }, - // }, - - /* Test against branded browsers. */ - // { - // name: 'Microsoft Edge', - // use: { ...devices['Desktop Edge'], channel: 'msedge' }, - // }, - // { - // name: 'Google Chrome', - // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, - // }, - ], - - /* Run your local dev server before starting the tests */ - webServer: { - command: `COMMONALITY_ROOT_DIRECTORY="./fixtures/kitchen-sink-pnpm/" node server.js`, - url: 'http://127.0.0.1:8888', - reuseExistingServer: !process.env.CI, - }, -}); diff --git a/apps/studio/postcss.config.js b/apps/studio/postcss.config.js deleted file mode 100644 index 12a703d9..00000000 --- a/apps/studio/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/apps/studio/server.js b/apps/studio/server.js deleted file mode 100644 index 8b637924..00000000 --- a/apps/studio/server.js +++ /dev/null @@ -1,101 +0,0 @@ -const path = require('node:path'); -const http = require('node:http'); -const { parse } = require('node:url'); -const next = require('next'); -const { Server } = require('socket.io'); -const chokidar = require('chokidar'); - -const port = parseInt(process.env.PORT || '8888', 10); -const dev = process.env.NODE_ENV !== 'production'; - -if (!process.env.COMMONALITY_ROOT_DIRECTORY) { - throw new Error('COMMONALITY_ROOT_DIRECTORY not set'); -} else { - process.env.COMMONALITY_ROOT_DIRECTORY = path.resolve( - process.env.COMMONALITY_ROOT_DIRECTORY, - ); -} - -/** @type {string} */ -const rootDirectory = path.resolve(process.env.COMMONALITY_ROOT_DIRECTORY); -const app = next({ dev, port }); -const handle = app.getRequestHandler(); - -/** - * @async - * @returns {Promise>} The created server. - */ -const createNextServer = async () => { - await app.prepare(); - - return http - .createServer((req, res) => { - const parsedUrl = parse(req.url || '', true); - - handle(req, res, parsedUrl); - }) - .listen(port); -}; - -const createWebsocketConnection = async (server) => { - const io = new Server(server); - - io.on('connection', (socket) => { - const globsToWatch = [ - 'CODEOWNERS', - '.github/CODEOWNERS', - '.gitlab/CODEOWNERS', - 'docs/CODEOWNERS', - '**/**/package.json', - '**/**/commonality.json', - '.commonality/**', - ]; - - const watcher = chokidar.watch(globsToWatch, { - ignored: [/node_modules/, /.next/, /dist/], - ignoreInitial: true, - persistent: true, - cwd: rootDirectory, - }); - - watcher - .on('ready', () => { - console.log('watching for file changes'); - }) - .on('add', async (path) => { - socket.emit('project-updated', { - message: `File ${path} has been added`, - }); - }) - .on('change', async (path) => { - socket.emit('project-updated', { - message: `File ${path} has been changed`, - }); - }) - .on('error', (error) => { - console.log(error); - }); - - socket.on('disconnect', () => { - watcher.close(); - }); - }); -}; - -const startServer = async () => { - try { - const server = await createNextServer(); - - await createWebsocketConnection(server); - - console.log( - `> Server listening at http://localhost:${port} as ${ - dev ? 'development' : 'production' - }`, - ); - } catch (error) { - console.log(error); - } -}; - -startServer(); diff --git a/apps/studio/src/actions/metadata.ts b/apps/studio/src/actions/metadata.ts deleted file mode 100644 index 822d5ba4..00000000 --- a/apps/studio/src/actions/metadata.ts +++ /dev/null @@ -1,17 +0,0 @@ -'use server'; -import { setTags } from '@commonalityco/data-tags'; -import { Package } from '@commonalityco/types'; - -export async function setTagsAction({ - pkg, - tags, -}: { - pkg: Package; - tags: string[]; -}): Promise { - return setTags({ - pkg, - tags, - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); -} diff --git a/apps/studio/src/app/error.tsx b/apps/studio/src/app/error.tsx deleted file mode 100644 index 767e3648..00000000 --- a/apps/studio/src/app/error.tsx +++ /dev/null @@ -1,34 +0,0 @@ -'use client'; // Error components must be Client Components - -import { Button } from '@commonalityco/ui-design-system'; -import { useEffect } from 'react'; - -export default function Error({ - error, - reset, -}: { - error: Error; - reset: () => void; -}) { - useEffect(() => { - // Log the error to an error reporting service - console.error(error); - }, [error]); - - return ( -
-
-

Oops

-

Something has gone wrong

- -
-
- ); -} diff --git a/apps/studio/src/app/favicon.ico b/apps/studio/src/app/favicon.ico deleted file mode 100644 index 5c2d9152..00000000 Binary files a/apps/studio/src/app/favicon.ico and /dev/null differ diff --git a/apps/studio/src/app/globals.css b/apps/studio/src/app/globals.css deleted file mode 100644 index fa6b9db8..00000000 --- a/apps/studio/src/app/globals.css +++ /dev/null @@ -1,38 +0,0 @@ -@import '@xyflow/react/dist/style.css'; -@import '@commonalityco/config-tailwind/globals.css'; - -@tailwind base; -@tailwind components; -@tailwind utilities; - -@layer base { - body { - @apply bg-background text-foreground text-sm; - } - - * { - @apply border-border; - } -} - -@layer components { - .react-flow__minimap { - @apply bg-interactive border-muted-foreground/25 overflow-hidden rounded-md border shadow; - } - - .react-flow__minimap-mask { - @apply fill-muted-foreground opacity-[0.09]; - } - - .react-flow__minimap-node { - @apply fill-muted-foreground; - } - - .react-flow__nodesselection-rect { - @apply bg-muted-foreground/10 border-muted-foreground border; - } - - .react-flow__background-pattern.dots { - @apply fill-zinc-500 dark:fill-zinc-500/75; - } -} diff --git a/apps/studio/src/app/last-update-time.tsx b/apps/studio/src/app/last-update-time.tsx deleted file mode 100644 index e6ecf075..00000000 --- a/apps/studio/src/app/last-update-time.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { formatRelative } from 'date-fns'; -import { useRouter } from 'next/navigation'; -import { useEffect, useState } from 'react'; -import { io } from 'socket.io-client'; -import debounce from 'lodash-es/debounce'; - -function LastUpdateTime() { - const router = useRouter(); - const [count, setCount] = useState(0); - const [lastUpdated, setLastUpdated] = useState(new Date()); - - useEffect(() => { - const createSocketConnection = async () => { - const socket = io(); - - socket.on('connect', () => { - console.log('Watching for updates...'); - }); - - socket.on( - 'project-updated', - debounce((data) => { - router.refresh(); - - setLastUpdated(new Date()); - }, 500), - ); - socket.on('disconnect', () => { - console.log('Stopped watching for updates...'); - }); - }; - - createSocketConnection(); - }, [router]); - - useEffect(() => { - const id = setInterval(() => { - setCount(count + 1); - - if (count > 60) { - clearInterval(id); - } - }, 1000); - - return () => clearInterval(id); - }, [count]); - - return ( -
- {`Last updated ${formatRelative(new Date(), lastUpdated)}`} -
- ); -} - -export default LastUpdateTime; diff --git a/apps/studio/src/app/layout.tsx b/apps/studio/src/app/layout.tsx deleted file mode 100644 index 5ba0b8c7..00000000 --- a/apps/studio/src/app/layout.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import './globals.css'; -import { clsx } from 'clsx'; -import { firaCode, inter } from '@/constants/fonts'; -import { Providers } from '@/app/providers'; -import { cookies } from 'next/headers'; -import StudioNavigation from './studio-navigation'; -import { getProjectData } from '@/data/project'; - -export const dynamic = 'force-dynamic'; - -export const metadata = { - title: 'Commonality Studio', - icons: { - icon: './favicon.ico', - }, -}; - -export default async function RootLayout({ - children, -}: { - children: React.ReactNode; -}) { - const project = await getProjectData(); - const cookieStore = cookies(); - const defaultTheme = cookieStore.get('commonality:theme')?.value; - - return ( - - - - - {children} - - - - ); -} diff --git a/apps/studio/src/app/lazy-graph.tsx b/apps/studio/src/app/lazy-graph.tsx deleted file mode 100644 index 0e90bb3b..00000000 --- a/apps/studio/src/app/lazy-graph.tsx +++ /dev/null @@ -1,18 +0,0 @@ -'use client'; -import { ComponentProps } from 'react'; -import dynamic from 'next/dynamic'; -import { GraphLoading } from '@commonalityco/feature-graph'; - -const Graph = dynamic( - () => import('@commonalityco/feature-graph').then((mod) => mod.Graph), - { - ssr: false, - loading: () => , - }, -); - -function LazyGraph(props: ComponentProps) { - return ; -} - -export default LazyGraph; diff --git a/apps/studio/src/app/page.tsx b/apps/studio/src/app/page.tsx deleted file mode 100644 index adefd58f..00000000 --- a/apps/studio/src/app/page.tsx +++ /dev/null @@ -1,221 +0,0 @@ -import React, { Suspense } from 'react'; -import { getTagsData } from '@/data/tags'; -import { getPackagesData } from '@/data/packages'; -import { getDependenciesData } from '@/data/dependencies'; -import { getCodeownersData } from '@/data/codeowners'; -import { getConstraintsData } from '@/data/constraints'; -import { cookies } from 'next/headers'; -import { - GraphControlBar, - GraphDirection, - GraphFilterSidebar, - GraphProviders, - getEdges, - getNodes, - GraphLayoutLeftSidebar, - GraphLayoutMain, - GraphLayoutRoot, - getElementsWithLayout, - GraphEmpty, - COOKIE_FILTER_SIDEBAR, - GraphLayoutRightSidebar, - GraphContextSidebar, - PackageToolbar, - COOKIE_GRAPH_LAYOUT, -} from '@commonalityco/feature-graph'; -import * as z from 'zod'; -import { - DependencyType, - Theme, - numberSafeParse, -} from '@commonalityco/utils-core'; -import { - colorParser, - directionParser, - packagesParser, -} from '@commonalityco/feature-graph/query-parsers'; -import { getConnectedEdges } from '@xyflow/system'; -import LazyGraph from './lazy-graph'; -import { EditTagsButton } from '@/components/edit-tags-dialog'; -import { Provider } from 'jotai'; -import { getConformanceResultsData } from '@/data/conformance'; -import { getProjectData } from '@/data/project'; -import { unstable_cache } from 'next/cache'; - -const getSnapshot = unstable_cache( - async () => { - const [ - tagsData, - packages, - dependencies, - results, - codeownersData, - checkResults, - project, - ] = await Promise.all([ - getTagsData(), - getPackagesData(), - getDependenciesData(), - getConstraintsData(), - getCodeownersData(), - getConformanceResultsData(), - getProjectData(), - ]); - - return { - tagsData, - packages, - dependencies, - results, - codeownersData, - checkResults, - project, - }; - }, - [], - { revalidate: false }, -); - -async function GraphPage({ - searchParams, -}: { - searchParams?: { - packages?: string; - direction: GraphDirection; - color: DependencyType[]; - }; -}) { - const cookieStore = cookies(); - const defaultLayoutCookie = cookieStore.get(COOKIE_FILTER_SIDEBAR); - const graphLayout = cookieStore.get(COOKIE_GRAPH_LAYOUT); - const defaultTheme = cookieStore.get('commonality:theme')?.value as - | Theme.Light - | Theme.Dark - | undefined; - - const getDefaultLayout = () => { - try { - if (defaultLayoutCookie) { - const parsedLayout = JSON.parse(defaultLayoutCookie.value); - const layoutSchema = z.union([ - z.tuple([z.number(), z.number(), z.number()]), - z.undefined(), - ]); - return layoutSchema.parse(parsedLayout); - } - } catch (err) { - return undefined; - } - }; - - const defaultLayout = getDefaultLayout(); - - const { - tagsData, - packages, - dependencies, - results, - codeownersData, - checkResults, - project, - } = await getSnapshot(); - - const packagesQuery = packagesParser.parseServerSide(searchParams?.packages); - const colorQuery = colorParser.parseServerSide(searchParams?.color); - const directionQuery = directionParser.parseServerSide( - searchParams?.direction, - ); - - const allNodes = getNodes({ - packages, - dependencies, - tagsData, - }); - - const allEdges = getEdges({ - results, - dependencies, - theme: defaultTheme ?? Theme.Light, - activeDependencyTypes: colorQuery ?? [DependencyType.PRODUCTION], - }); - - const getShownElements = () => { - const filteredNodes = - packagesQuery !== null - ? allNodes.filter((node) => - packagesQuery?.some((pkgName) => pkgName === node.id), - ) - : allNodes; - - const connectedEdges = getConnectedEdges(filteredNodes, allEdges); - - const elements = getElementsWithLayout({ - nodes: filteredNodes, - edges: connectedEdges, - direction: directionQuery ?? GraphDirection.LeftToRight, - }); - - return elements; - }; - - const shownElements = getShownElements(); - - const parsedGraphLayout = JSON.parse(graphLayout?.value ?? '[]'); - - return ( - - - - - - - - {shownElements.nodes.length === 0 ? ( - - ) : ( - <> - - - - - - - )} - - - } - /> - - - - - ); -} - -export default GraphPage; diff --git a/apps/studio/src/app/providers.tsx b/apps/studio/src/app/providers.tsx deleted file mode 100644 index 26858b82..00000000 --- a/apps/studio/src/app/providers.tsx +++ /dev/null @@ -1,24 +0,0 @@ -'use client'; -import { Toaster } from '@commonalityco/ui-design-system/toast'; -import { ThemeProvider, useTheme } from 'next-themes'; - -function ToasterWithTheme() { - const { theme } = useTheme(); - - return ; -} - -export function Providers({ - children, - defaultTheme, -}: { - children: React.ReactNode; - defaultTheme?: string; -}) { - return ( - - {children} - - - ); -} diff --git a/apps/studio/src/app/studio-navigation.tsx b/apps/studio/src/app/studio-navigation.tsx deleted file mode 100644 index 4b5876a8..00000000 --- a/apps/studio/src/app/studio-navigation.tsx +++ /dev/null @@ -1,96 +0,0 @@ -'use client'; -import { - Navigation, - NavigationLogo, - Divider, - ThemeButton, - BunLogo, -} from '@commonalityco/ui-core'; -import { useTheme } from 'next-themes'; -import { Button } from '@commonalityco/ui-design-system'; -import Link from 'next/link'; -import { setCookie } from 'cookies-next'; -import { ExternalLink } from 'lucide-react'; -import { PackageManager } from '@commonalityco/utils-core'; -import { NpmLogo, PnpmLogo, YarnLogo } from '@commonalityco/ui-core'; - -import dynamic from 'next/dynamic'; - -const LastUpdateTime = dynamic(() => import('./last-update-time'), { - ssr: false, -}); - -const COOKIE_KEY = 'commonality:theme'; - -const IconByPackageManager = { - [PackageManager.NPM]: NpmLogo, - [PackageManager.PNPM]: PnpmLogo, - [PackageManager.YARN]: YarnLogo, - [PackageManager.BUN]: BunLogo, -}; - -function StudioNavigation({ - title, - defaultTheme, - packageManager, -}: { - title: string; - defaultTheme?: string; - packageManager: PackageManager; -}) { - const { setTheme } = useTheme(); - const PackageManagerIcon = IconByPackageManager[packageManager]; - - return ( -
- -
-
- - - - - -

{title}

-
-
- - - - - { - setCookie(COOKIE_KEY, theme); - setTheme(theme); - }} - /> -
-
-
-
- ); -} - -export default StudioNavigation; diff --git a/apps/studio/src/components/edit-tags-dialog.tsx b/apps/studio/src/components/edit-tags-dialog.tsx deleted file mode 100644 index 46a43468..00000000 --- a/apps/studio/src/components/edit-tags-dialog.tsx +++ /dev/null @@ -1,147 +0,0 @@ -'use client'; -import { - CreatebleSelect, - Button, - Dialog, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, - FormField, - FormItem, - FormControl, - FormMessage, - Form, - DialogDescription, - toast, - DialogTrigger, -} from '@commonalityco/ui-design-system'; -import { formatTagName } from '@commonalityco/utils-core'; -import React, { useTransition } from 'react'; -import { useForm } from 'react-hook-form'; -import { zodResolver } from '@hookform/resolvers/zod'; -import * as z from 'zod'; -import { setTagsAction } from '@/actions/metadata'; -import { useAtomValue } from 'jotai'; -import { useRouter } from 'next/navigation'; -import { TagsData } from '@commonalityco/types'; -import { selectedPackagesAtom } from '@commonalityco/feature-graph'; -import { Tags } from 'lucide-react'; - -const formSchema = z.object({ - tags: z.array(z.object({ label: z.string(), value: z.string() })), -}); - -function EditTagsDialogContent({ tagsData }: { tagsData: TagsData[] }) { - const router = useRouter(); - - const selectedPackages = useAtomValue(selectedPackagesAtom); - const selectedPackage = selectedPackages[0]; - - const [isPending, startTransition] = useTransition(); - - const allTags = [...new Set(tagsData.map((data) => data.tags).flat())]; - const pkgTags = tagsData.find( - (data) => data.packageName === selectedPackage?.name, - )?.tags; - - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - tags: pkgTags?.map((existingTag) => ({ - value: existingTag, - label: formatTagName(existingTag), - })), - }, - }); - - function onSubmit(values: z.infer) { - if (!selectedPackage) return; - - const newTags = values.tags.map((item) => item.value); - - startTransition(async () => { - const configPath = await setTagsAction({ - pkg: selectedPackage, - tags: newTags, - }); - router.refresh(); - - toast.success('Tags updated', { - description: configPath, - }); - }); - } - - if (!selectedPackage) return; - - return ( - <> - - - Edit tags - - {`We will create or update the`} - - commonality.json - - file for{' '} - - {selectedPackage.name} - {' '} - with the tags you select. - - -
- - ( - - - - 'Start typing to create a new tag' - } - formatCreateLabel={(inputValue) => { - return `Create ${formatTagName(inputValue)}`; - }} - value={value} - onChange={onChange} - name={name} - options={allTags.map((tag) => ({ - label: formatTagName(tag), - value: tag, - }))} - /> - - - - )} - /> - - - - - -
- - ); -} - -export function EditTagsButton({ tagsData }: { tagsData: TagsData[] }) { - return ( - - - - - - - ); -} diff --git a/apps/studio/src/constants/fonts.ts b/apps/studio/src/constants/fonts.ts deleted file mode 100644 index ac2e30e8..00000000 --- a/apps/studio/src/constants/fonts.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Inter, Fira_Code, Vollkorn } from 'next/font/google'; - -export const inter = Inter({ - subsets: ['latin'], - variable: '--font-inter', -}); - -export const firaCode = Fira_Code({ - subsets: ['latin'], - variable: '--font-fira-code', - display: 'swap', -}); diff --git a/apps/studio/src/data/codeowners.ts b/apps/studio/src/data/codeowners.ts deleted file mode 100644 index 5cceab79..00000000 --- a/apps/studio/src/data/codeowners.ts +++ /dev/null @@ -1,15 +0,0 @@ -'use server'; -import { cache } from 'react'; -import { getCodeownersData as getCodeownersDatas } from '@commonalityco/data-codeowners'; -import { getPackages } from '@commonalityco/data-packages'; - -export const getCodeownersData = cache(async () => { - const packages = await getPackages({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - - return getCodeownersDatas({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - packages, - }); -}); diff --git a/apps/studio/src/data/conformance.ts b/apps/studio/src/data/conformance.ts deleted file mode 100644 index 4f459f70..00000000 --- a/apps/studio/src/data/conformance.ts +++ /dev/null @@ -1,50 +0,0 @@ -'use server'; -import { getProjectConfig } from '@commonalityco/data-project'; -import { getPackagesData } from './packages'; -import { getTagsData } from '@commonalityco/data-tags'; -import { - getConformanceResults, - getResolvedChecks, -} from '@commonalityco/utils-conformance'; -import { getCodeownersData } from '@commonalityco/data-codeowners'; -import { Status } from '@commonalityco/utils-core'; - -const StatusSortValue = { - [Status.Pass]: 2, - [Status.Warn]: 1, - [Status.Fail]: 0, -}; - -export const getConformanceResultsData = async () => { - const packages = await getPackagesData(); - const projectConfig = await getProjectConfig({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - const tagsData = await getTagsData({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - packages, - }); - const codeownersData = await getCodeownersData({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - packages, - }); - - const checks = getResolvedChecks({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - projectConfig: projectConfig?.config, - }); - - const results = await getConformanceResults({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - conformersByPattern: checks.resolved ?? {}, - packages, - tagsData, - codeownersData, - }); - - return results.map(({ fix, ...result }) => { - return { - ...result, - }; - }); -}; diff --git a/apps/studio/src/data/constraints.ts b/apps/studio/src/data/constraints.ts deleted file mode 100644 index 686f11e1..00000000 --- a/apps/studio/src/data/constraints.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { getDependencies, getPackages } from '@commonalityco/data-packages'; -import { getProjectConfig } from '@commonalityco/data-project'; -import { getTagsData } from '@commonalityco/data-tags'; -import { getConstraintResults } from '@commonalityco/data-constraints'; - -export const getConstraintsData = async () => { - const projectConfig = await getProjectConfig({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - const packages = await getPackages({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - const dependencies = await getDependencies({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - const tagsData = await getTagsData({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - packages, - }); - - return getConstraintResults({ - tagsData, - dependencies, - constraints: projectConfig?.config.constraints, - }); -}; diff --git a/apps/studio/src/data/dependencies.ts b/apps/studio/src/data/dependencies.ts deleted file mode 100644 index 60752aaf..00000000 --- a/apps/studio/src/data/dependencies.ts +++ /dev/null @@ -1,12 +0,0 @@ -'use server'; -import { getDependencies } from '@commonalityco/data-packages'; - -export const preload = () => { - getDependenciesData(); -}; - -export const getDependenciesData = async () => { - return getDependencies({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); -}; diff --git a/apps/studio/src/data/packages.ts b/apps/studio/src/data/packages.ts deleted file mode 100644 index 4100163b..00000000 --- a/apps/studio/src/data/packages.ts +++ /dev/null @@ -1,14 +0,0 @@ -'use server'; -import { getPackages } from '@commonalityco/data-packages'; - -export const preload = () => { - void getPackagesData(); -}; - -export const getPackagesData = async () => { - const packagesData = await getPackages({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - - return packagesData.sort((a, b) => a.name.localeCompare(b.name)); -}; diff --git a/apps/studio/src/data/project.ts b/apps/studio/src/data/project.ts deleted file mode 100644 index 3a31ee41..00000000 --- a/apps/studio/src/data/project.ts +++ /dev/null @@ -1,28 +0,0 @@ -'use server'; -import { getPackageManager } from '@commonalityco/data-project/get-package-manager'; -import { getRootPackageName } from '@commonalityco/data-packages'; -import { getProjectConfig } from '@commonalityco/data-project'; - -export const preload = () => { - getProjectData(); -}; - -export const getProjectData = async () => { - const packageManager = await getPackageManager({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - - const rootPackageName = await getRootPackageName({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - - const config = await getProjectConfig({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - - return { - name: rootPackageName, - packageManager, - config, - }; -}; diff --git a/apps/studio/src/data/tags.ts b/apps/studio/src/data/tags.ts deleted file mode 100644 index af4ba0fb..00000000 --- a/apps/studio/src/data/tags.ts +++ /dev/null @@ -1,15 +0,0 @@ -'use server'; -import { cache } from 'react'; -import { getTagsData as getTagsDatas } from '@commonalityco/data-tags'; -import { getPackages } from '@commonalityco/data-packages'; - -export const getTagsData = cache(async () => { - const packages = await getPackages({ - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); - - return getTagsDatas({ - packages, - rootDirectory: process.env.COMMONALITY_ROOT_DIRECTORY, - }); -}); diff --git a/apps/studio/src/public/next.svg b/apps/studio/src/public/next.svg deleted file mode 100644 index 5174b28c..00000000 --- a/apps/studio/src/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/studio/src/public/thirteen.svg b/apps/studio/src/public/thirteen.svg deleted file mode 100644 index 8977c1bd..00000000 --- a/apps/studio/src/public/thirteen.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/studio/src/public/vercel.svg b/apps/studio/src/public/vercel.svg deleted file mode 100644 index d2f84222..00000000 --- a/apps/studio/src/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/studio/src/types/globals.d.ts b/apps/studio/src/types/globals.d.ts deleted file mode 100644 index 401c88fe..00000000 --- a/apps/studio/src/types/globals.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ThemeName } from 'constants/ThemeName'; - -declare global { - interface Window { - COMMONALITY_THEME: ThemeName.Dark | ThemeName.Light; - } -} diff --git a/apps/studio/src/types/launch-editor.d.ts b/apps/studio/src/types/launch-editor.d.ts deleted file mode 100644 index 5165f100..00000000 --- a/apps/studio/src/types/launch-editor.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'launch-editor'; diff --git a/apps/studio/start.mjs b/apps/studio/start.mjs deleted file mode 100644 index cc61e360..00000000 --- a/apps/studio/start.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import { execa } from 'execa'; -import url from 'node:url'; - -const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); - -/** - * Starts a studio server process. - * @param {Object} options - The configuration options for starting the studio. - * @param {number} options.port - The port on which the server will listen. - * @param {string} options.rootDirectory - The root directory for the server. - * @param {boolean} options.debug - Flag to enable debug mode (stdout and stderr). - * @returns {{ kill: () => void }} An object with a kill function to terminate the server process. - */ -export const startStudio = ({ port, rootDirectory, debug }) => { - const serverProcess = execa('node', ['server.js'], { - stdout: debug ? 'inherit' : 'ignore', - stderr: debug ? 'inherit' : 'ignore', - cwd: __dirname, - env: { - PATH: process.env.PATH, - NODE_ENV: 'production', - PORT: port?.toString(), - COMMONALITY_ROOT_DIRECTORY: rootDirectory, - }, - }); - - return { - kill: () => { - serverProcess.kill(); - }, - }; -}; diff --git a/apps/studio/tailwind.config.cjs b/apps/studio/tailwind.config.cjs deleted file mode 100644 index 7d506294..00000000 --- a/apps/studio/tailwind.config.cjs +++ /dev/null @@ -1,25 +0,0 @@ -// @ts-check -const path = require('path'); -const baseConfig = require('@commonalityco/config-tailwind'); - -const getPkgPattern = (pkgName) => { - const rootPath = path - .dirname(require.resolve(pkgName)) - .replace('/dist', '/src'); - - return path.join(rootPath, '**/*.{js,jsx,ts,tsx}'); -}; - -/** @type {import('tailwindcss').Config} */ -module.exports = { - ...baseConfig, - content: [ - './app/**/*.{js,ts,jsx,tsx,css}', - './pages/**/*.{js,ts,jsx,tsx}', - './components/**/*.{js,ts,jsx,tsx}', - './src/**/*.{js,ts,jsx,tsx,css}', - getPkgPattern('@commonalityco/ui-design-system'), - getPkgPattern('@commonalityco/ui-core'), - getPkgPattern('@commonalityco/feature-graph'), - ], -}; diff --git a/apps/studio/test/setup.ts b/apps/studio/test/setup.ts deleted file mode 100644 index e368482a..00000000 --- a/apps/studio/test/setup.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { afterEach } from 'vitest'; -import { cleanup } from '@testing-library/react'; -import '@testing-library/jest-dom'; - -afterEach(() => { - cleanup(); -}); diff --git a/apps/studio/tsconfig.json b/apps/studio/tsconfig.json deleted file mode 100644 index fc945c6b..00000000 --- a/apps/studio/tsconfig.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "compilerOptions": { - "target": "ES6", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./src/*"] - }, - "incremental": false, - "types": ["@testing-library/jest-dom"] - }, - "include": [ - "next-env.d.ts", - "env.d.ts", - "./**/*.ts", - "./**/*.tsx", - ".next/types/**/*.ts", - "src/types/globals.d.ts", - "servers/dev-server.ts" - ], - "exclude": ["node_modules", ".next"] -} diff --git a/apps/studio/vitest.config.ts b/apps/studio/vitest.config.ts deleted file mode 100644 index 755a256a..00000000 --- a/apps/studio/vitest.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import path from 'path'; -import { defineConfig } from 'vitest/config'; -import tsconfigPaths from 'vite-tsconfig-paths'; -import react from '@vitejs/plugin-react-swc'; - -export default defineConfig({ - test: { - include: ['src/**/*.{test,spec}.?(c|m)[jt]s?(x)'], - globals: true, - environment: 'jsdom', - setupFiles: ['./test/setup.ts'], - }, - - plugins: [tsconfigPaths(), react()], - resolve: { - alias: { - '@/': path.resolve(__dirname, './src'), - }, - }, -}); diff --git a/apps/workshop/.eslintignore b/apps/workshop/.eslintignore deleted file mode 100644 index e8177b10..00000000 --- a/apps/workshop/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -graph-machine.typegen.d.ts -graph-machine.typegen.ts -postcss.config.js -tailwind.config.js -README.ts \ No newline at end of file diff --git a/apps/workshop/.eslintrc.cjs b/apps/workshop/.eslintrc.cjs deleted file mode 100644 index 97414f7d..00000000 --- a/apps/workshop/.eslintrc.cjs +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - root: true, - extends: ['commonality'], -}; diff --git a/apps/workshop/.gitignore b/apps/workshop/.gitignore deleted file mode 100644 index a547bf36..00000000 --- a/apps/workshop/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/apps/workshop/.storybook/globals.css b/apps/workshop/.storybook/globals.css deleted file mode 100644 index 4229010f..00000000 --- a/apps/workshop/.storybook/globals.css +++ /dev/null @@ -1,15 +0,0 @@ -@import '@commonalityco/config-tailwind/globals.css'; - -@tailwind base; -@tailwind components; -@tailwind utilities; - -@layer base { - body { - @apply text-sm bg-background text-foreground; - } - - * { - @apply border-border; - } -} diff --git a/apps/workshop/.storybook/main.ts b/apps/workshop/.storybook/main.ts deleted file mode 100644 index b9568ece..00000000 --- a/apps/workshop/.storybook/main.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { dirname, join } from "path"; -import { StorybookConfig } from '@storybook/react-vite'; -import { mergeConfig } from 'vite'; - -const config: StorybookConfig = { - stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], - addons: [ - getAbsolutePath("@storybook/addon-links"), - getAbsolutePath("@storybook/addon-essentials"), - getAbsolutePath("@storybook/addon-interactions"), - getAbsolutePath("@storybook/addon-a11y"), - getAbsolutePath("storybook-addon-variants"), - ], - async viteFinal(config, { configType }) { - return mergeConfig(config, { - define: { 'process.env': {} }, - }); - }, - framework: { - name: getAbsolutePath("@storybook/react-vite"), - options: {}, - }, - docs: { - autodocs: 'tag', - }, -}; -export default config; - -function getAbsolutePath(value: string): any { - return dirname(require.resolve(join(value, "package.json"))); -} diff --git a/apps/workshop/.storybook/preview-head.html b/apps/workshop/.storybook/preview-head.html deleted file mode 100644 index e1bd0c27..00000000 --- a/apps/workshop/.storybook/preview-head.html +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/apps/workshop/.storybook/preview.tsx b/apps/workshop/.storybook/preview.tsx deleted file mode 100644 index d76b9919..00000000 --- a/apps/workshop/.storybook/preview.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react'; -import { Preview } from '@storybook/react'; - -import './globals.css'; - -const preview: Preview = { - decorators: [ - (Story) => ( -
- -
- ), - ], - parameters: { - backgrounds: { - default: 'light', - values: [ - { - name: 'light', - value: '#fff', - }, - { - name: 'dark', - value: 'hsl(240 6% 8.5%)', - }, - ], - }, - // actions: { argTypesRegex: '^on.*' }, - controls: { - matchers: { - color: /(background|color)$/i, - date: /Date$/, - }, - }, - }, -}; - -export const decorators = []; - -export default preview; diff --git a/apps/workshop/CHANGELOG.md b/apps/workshop/CHANGELOG.md deleted file mode 100644 index 6074897c..00000000 --- a/apps/workshop/CHANGELOG.md +++ /dev/null @@ -1,469 +0,0 @@ -# workshop - -## 1.0.39 - -### Patch Changes - -- Updated dependencies [bfddcb3] - - @commonalityco/feature-graph@0.1.0 - -## 1.0.38 - -### Patch Changes - -- 5b8761b: Update layout of graph and deprecate packages -- Updated dependencies [5b8761b] - - @commonalityco/ui-design-system@0.2.42 - - @commonalityco/feature-graph@0.0.1 - - @commonalityco/utils-core@0.2.42 - - @commonalityco/ui-core@0.2.41 - -## 1.0.37 - -### Patch Changes - -- Updated dependencies [c064bff] - - @commonalityco/ui-graph@0.2.46 - - @commonalityco/ui-constraints@0.2.46 - - @commonalityco/ui-core@0.2.41 - - @commonalityco/ui-design-system@0.2.41 - - @commonalityco/ui-package@0.2.38 - -## 1.0.36 - -### Patch Changes - -- Updated dependencies [7ba2c80] - - @commonalityco/ui-design-system@0.2.41 - - @commonalityco/ui-constraints@0.2.46 - - @commonalityco/ui-graph@0.2.45 - - @commonalityco/ui-core@0.2.41 - - @commonalityco/ui-conformance@0.2.41 - - @commonalityco/ui-package@0.2.38 - -## 1.0.35 - -### Patch Changes - -- 4f0f69c: Update dependency graph to use @xyflow/react -- Updated dependencies [4f0f69c] - - @commonalityco/ui-design-system@0.2.40 - - @commonalityco/ui-conformance@0.2.41 - - @commonalityco/ui-constraints@0.2.45 - - @commonalityco/ui-package@0.2.38 - - @commonalityco/utils-core@0.2.41 - - @commonalityco/ui-graph@0.2.44 - - @commonalityco/ui-core@0.2.40 - -## 1.0.34 - -### Patch Changes - -- Updated dependencies [ca229a7] -- Updated dependencies [ca229a7] - - @commonalityco/utils-core@0.2.40 - - @commonalityco/ui-conformance@0.2.40 - - @commonalityco/types@0.2.38 - - @commonalityco/ui-constraints@0.2.44 - - @commonalityco/ui-core@0.2.39 - - @commonalityco/ui-graph@0.2.43 - - @commonalityco/ui-package@0.2.37 - -## 1.0.33 - -### Patch Changes - -- 65ee18a: This release addresses some common feedback around checks and initial setup. - - We are moving from a TS/JS configuration file to a JSON file (`.commonality/config.json`). It's common for developers to create custom checks during initial setup and the `.commonality` directory, will now act as a folder to organize these checks before moving them into a package. - - ```json - { - "checks": { - "*": [ - "has-client-eslint-config", - "recommended/sorted-dependencies", - "@scope/team/custom-check" - ] - } - } - ``` - - How checks are resolved in the JSON format: - - 1. Checks can be configured with a path to a local file, relative to the `.commonality` folder. Given a path `has-foo`, Commonality will first look for a file named "has-foo" within the `.commonality` folder. You can also pass a relative path like `./testing/has-foo` or `testing/has-foo` to organize checks within the `.commonality` folder. - 2. Checks can be configured via import path. Given a path `@scope/team/custom-check`, Commonality will look for a default export from an entry point named `custom-check` in the package named `@scope/team`. This logic follows the same convention as `import.meta.resolve`. - 3. Checks can be configured via a shortened import path. Given a path `test/has-foo`, if there is no file located at `.commonality/test/has-foo.ts` then it will look for a package named `commonality-checks-test` with an entry point named `has-foo`. This allows for a standard convention and a more readable configuration file similar to eslint. - - Previously the `message` property for a check object allowed a function that could be used to dynamically create an error message. There ended up being a lot of duplicated logic between the `message` and `validate` function and in some cases the two could become out of sync for certain cases. This change change the `message` property to only expect a string, ensuring that the happy path message will always be shown when running `check --verbose`. To create a dynamic message, simply return a message object from the `validate` function. Now, Commonality will return a `fail` or `warn` status for any check who's `validate` function returns a value other than `true.` - - We now automatically create an id for each check on file resolution so the name property is no longer required to parallelize check functions. - -- Updated dependencies [65ee18a] - - @commonalityco/ui-conformance@0.2.40 - - @commonalityco/ui-constraints@0.2.43 - - @commonalityco/utils-core@0.2.39 - - @commonalityco/types@0.2.38 - - @commonalityco/ui-graph@0.2.42 - - @commonalityco/ui-core@0.2.39 - - @commonalityco/ui-package@0.2.37 - -## 1.0.32 - -### Patch Changes - -- Updated dependencies [0508b8f] - - @commonalityco/utils-core@0.2.38 - - @commonalityco/types@0.2.37 - - @commonalityco/ui-conformance@0.2.39 - - @commonalityco/ui-constraints@0.2.42 - - @commonalityco/ui-core@0.2.39 - - @commonalityco/ui-graph@0.2.41 - - @commonalityco/ui-package@0.2.37 - -## 1.0.31 - -### Patch Changes - -- Updated dependencies [9458463] - - @commonalityco/ui-constraints@0.2.41 - - @commonalityco/ui-graph@0.2.40 - -## 1.0.30 - -### Patch Changes - -- 0faea77: Fixes an issue where the repository field check was creating an incorrectly formatted repository field -- Updated dependencies [0faea77] - - @commonalityco/ui-design-system@0.2.39 - - @commonalityco/ui-conformance@0.2.39 - - @commonalityco/ui-constraints@0.2.40 - - @commonalityco/ui-package@0.2.37 - - @commonalityco/utils-core@0.2.37 - - @commonalityco/ui-graph@0.2.39 - - @commonalityco/ui-core@0.2.39 - - @commonalityco/types@0.2.37 - -## 1.0.29 - -### Patch Changes - -- Updated dependencies [52d572a] - - @commonalityco/ui-design-system@0.2.38 - - @commonalityco/ui-conformance@0.2.38 - - @commonalityco/ui-constraints@0.2.39 - - @commonalityco/ui-core@0.2.38 - - @commonalityco/ui-package@0.2.36 - -## 1.0.28 - -### Patch Changes - -- a88e9ba: Removes the tag filter from checks and constraints UI for clarity -- Updated dependencies [a88e9ba] - - @commonalityco/ui-conformance@0.2.38 - - @commonalityco/ui-constraints@0.2.39 - - @commonalityco/ui-graph@0.2.38 - -## 1.0.27 - -### Patch Changes - -- Updated dependencies [a8cda3c] -- Updated dependencies [7e440ac] -- Updated dependencies [7e440ac] -- Updated dependencies [7e440ac] - - @commonalityco/ui-graph@0.2.37 - - @commonalityco/ui-constraints@0.2.38 - - @commonalityco/ui-core@0.2.38 - - @commonalityco/ui-conformance@0.2.37 - - @commonalityco/ui-design-system@0.2.37 - - @commonalityco/ui-package@0.2.36 - -## 1.0.26 - -### Patch Changes - -- Updated dependencies [4661b6b] - - @commonalityco/ui-constraints@0.2.37 - - @commonalityco/ui-design-system@0.2.37 - - @commonalityco/ui-core@0.2.37 - - @commonalityco/ui-conformance@0.2.36 - - @commonalityco/ui-package@0.2.36 - -## 1.0.25 - -### Patch Changes - -- 3f1e821: Improve tag editing and constraints UX in Commonality Studio -- Updated dependencies [3f1e821] - - @commonalityco/ui-graph@0.2.36 - - @commonalityco/ui-conformance@0.2.36 - - @commonalityco/ui-constraints@0.2.36 - - @commonalityco/ui-design-system@0.2.36 - - @commonalityco/ui-package@0.2.36 - - @commonalityco/utils-core@0.2.36 - - @commonalityco/ui-core@0.2.36 - - @commonalityco/types@0.2.36 - -## 1.0.24 - -### Patch Changes - -- Updated dependencies [447c12d] - - @commonalityco/ui-conformance@0.2.34 - -## 1.0.23 - -### Patch Changes - -- Updated dependencies [202b591] - - @commonalityco/ui-graph@0.0.4 - - @commonalityco/ui-constraints@0.0.5 - -## 1.0.22 - -### Patch Changes - -- Updated dependencies [74e1a9c] -- Updated dependencies [74e1a9c] - - @commonalityco/ui-constraints@0.0.4 - - @commonalityco/ui-design-system@0.0.15 - - @commonalityco/ui-package@0.0.18 - - @commonalityco/ui-conformance@0.0.2 - - @commonalityco/ui-graph@0.0.3 - - @commonalityco/ui-core@0.0.16 - -## 1.0.21 - -### Patch Changes - -- Updated dependencies [d693d39] - - @commonalityco/ui-graph@0.0.3 - - @commonalityco/ui-constraints@0.0.3 - - @commonalityco/ui-core@0.0.16 - - @commonalityco/ui-design-system@0.0.14 - - @commonalityco/ui-package@0.0.17 - -## 1.0.20 - -### Patch Changes - -- 4bd3547: Create granular packages -- Updated dependencies [4bd3547] - - @commonalityco/ui-graph@0.0.2 - - @commonalityco/ui-conformance@0.0.2 - - @commonalityco/ui-constraints@0.0.2 - - @commonalityco/ui-design-system@0.0.14 - - @commonalityco/ui-package@0.0.17 - - @commonalityco/utils-core@0.0.12 - - @commonalityco/ui-core@0.0.16 - - @commonalityco/types@0.0.16 - -## 1.0.19 - -### Patch Changes - -- Updated dependencies [33f249e] - - @commonalityco/feature-conformance@0.0.20 - -## 1.0.18 - -### Patch Changes - -- Updated dependencies [1a98bec] - - @commonalityco/feature-conformance@0.0.19 - -## 1.0.17 - -### Patch Changes - -- ad4a813: Finalize Commonality Studio, checks, and constraints -- Updated dependencies [ad4a813] - - @commonalityco/feature-conformance@0.0.18 - - @commonalityco/feature-constraints@0.0.18 - - @commonalityco/ui-design-system@0.0.13 - - @commonalityco/ui-package@0.0.16 - - @commonalityco/utils-core@0.0.11 - - @commonalityco/ui-core@0.0.15 - - @commonalityco/types@0.0.15 - -## 1.0.16 - -### Patch Changes - -- Updated dependencies [99531bd] - - @commonalityco/data-graph-worker@0.0.9 - - @commonalityco/ui-package@0.0.15 - - @commonalityco/ui-graph@0.0.15 - - @commonalityco/feature-graph@0.0.13 - -## 1.0.15 - -### Patch Changes - -- 97987b9: fix bugs in package table -- Updated dependencies [97987b9] - - @commonalityco/ui-package@0.0.14 - - @commonalityco/ui-core@0.0.14 - - @commonalityco/ui-graph@0.0.14 - -## 1.0.14 - -### Patch Changes - -- e9a5bc2: Add table view to Studio -- Updated dependencies [e9a5bc2] - - @commonalityco/data-graph-worker@0.0.8 - - @commonalityco/ui-design-system@0.0.12 - - @commonalityco/feature-graph@0.0.13 - - @commonalityco/utils-graph@0.0.11 - - @commonalityco/utils-core@0.0.10 - - @commonalityco/ui-graph@0.0.14 - - @commonalityco/ui-core@0.0.13 - - @commonalityco/types@0.0.14 - -## 1.0.13 - -### Patch Changes - -- Updated dependencies [a7a22e3] - - @commonalityco/feature-graph@0.0.12 - -## 1.0.12 - -### Patch Changes - -- Updated dependencies [ffbc45c] - - @commonalityco/ui-design-system@0.0.11 - - @commonalityco/feature-graph@0.0.11 - - @commonalityco/utils-graph@0.0.10 - - @commonalityco/utils-core@0.0.9 - - @commonalityco/ui-graph@0.0.13 - - @commonalityco/ui-core@0.0.12 - -## 1.0.11 - -### Patch Changes - -- 5b61b0e: Reduce bundle size -- Updated dependencies [5b61b0e] - - @commonalityco/ui-design-system@0.0.10 - - @commonalityco/feature-graph@0.0.10 - - @commonalityco/utils-graph@0.0.9 - - @commonalityco/utils-core@0.0.8 - - @commonalityco/ui-graph@0.0.12 - - @commonalityco/ui-core@0.0.11 - -## 1.0.10 - -### Patch Changes - -- Updated dependencies [91bfd71] - - @commonalityco/ui-design-system@0.0.9 - - @commonalityco/feature-graph@0.0.9 - - @commonalityco/ui-graph@0.0.11 - - @commonalityco/ui-core@0.0.10 - - @commonalityco/types@0.0.13 - -## 1.0.9 - -### Patch Changes - -- Updated dependencies [e4075d7] - - @commonalityco/utils-graph@0.0.8 - -## 1.0.8 - -### Patch Changes - -- Updated dependencies [26e1636] - - @commonalityco/ui-design-system@0.0.8 - - @commonalityco/feature-graph@0.0.8 - - @commonalityco/utils-graph@0.0.7 - - @commonalityco/utils-core@0.0.7 - - @commonalityco/ui-graph@0.0.10 - - @commonalityco/ui-core@0.0.9 - -## 1.0.7 - -### Patch Changes - -- Updated dependencies [986fdbf] - - @commonalityco/ui-design-system@0.0.7 - - @commonalityco/ui-graph@0.0.9 - -## 1.0.6 - -### Patch Changes - -- Updated dependencies [a7691a8] - - @commonalityco/ui-design-system@0.0.6 - - @commonalityco/utils-graph@0.0.6 - - @commonalityco/utils-core@0.0.6 - -## 1.0.5 - -### Patch Changes - -- ee3504f: Distribute studio /dist -- Updated dependencies [ee3504f] - - @commonalityco/ui-design-system@0.0.5 - - @commonalityco/feature-graph@0.0.7 - - @commonalityco/utils-graph@0.0.5 - - @commonalityco/utils-core@0.0.5 - - @commonalityco/ui-graph@0.0.8 - - @commonalityco/ui-core@0.0.8 - - @commonalityco/types@0.0.12 - -## 1.0.4 - -### Patch Changes - -- dadeafb: Convert to ESM -- Updated dependencies [dadeafb] - - @commonalityco/feature-graph@0.0.6 - - @commonalityco/types@0.0.11 - - @commonalityco/ui-core@0.0.6 - - @commonalityco/ui-design-system@0.0.4 - - @commonalityco/ui-graph@0.0.7 - - @commonalityco/utils-core@0.0.4 - - @commonalityco/utils-graph@0.0.4 - -## 1.0.3 - -### Patch Changes - -- fb47c73: update build output -- Updated dependencies [fb47c73] - - @commonalityco/feature-graph@0.0.4 - - @commonalityco/types@0.0.10 - - @commonalityco/ui-core@0.0.4 - - @commonalityco/ui-design-system@0.0.3 - - @commonalityco/ui-graph@0.0.4 - - @commonalityco/utils-core@0.0.3 - - @commonalityco/utils-graph@0.0.3 - -## 1.0.2 - -### Patch Changes - -- d562884: Add zero state and feedback button -- Updated dependencies [d562884] - - @commonalityco/feature-graph@0.0.3 - - @commonalityco/ui-graph@0.0.3 - - @commonalityco/ui-core@0.0.3 - -## 1.0.1 - -### Patch Changes - -- da2c556: Initial release -- Updated dependencies [da2c556] - - @commonalityco/types@0.0.9 - - @commonalityco/ui-core@0.0.2 - - @commonalityco/utils-core@0.0.2 - - @commonalityco/ui-design-system@0.0.2 - - @commonalityco/feature-graph@0.0.2 - - @commonalityco/ui-graph@0.0.2 - - @commonalityco/utils-graph@0.0.2 diff --git a/apps/workshop/README.md b/apps/workshop/README.md deleted file mode 100644 index 6c32deda..00000000 --- a/apps/workshop/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# workshop -> The Storybook application for developing Commonality UI components -## Installation - -```sh -npm install workshop -``` \ No newline at end of file diff --git a/apps/workshop/commonality.json b/apps/workshop/commonality.json deleted file mode 100644 index 43ad6695..00000000 --- a/apps/workshop/commonality.json +++ /dev/null @@ -1 +0,0 @@ -{"tags":["application"]} diff --git a/apps/workshop/index.html b/apps/workshop/index.html deleted file mode 100644 index e0d1c840..00000000 --- a/apps/workshop/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite + React + TS - - -
- - - diff --git a/apps/workshop/package.json b/apps/workshop/package.json deleted file mode 100644 index b768c29e..00000000 --- a/apps/workshop/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "workshop", - "description": "The Storybook application for developing Commonality UI components", - "private": true, - "version": "1.0.39", - "scripts": { - "dev": "storybook dev -p 6006", - "lint": "eslint .", - "lint:fix": "eslint . --fix", - "type-check": "tsc --noEmit" - }, - "dependencies": { - "@commonalityco/feature-graph": "workspace:*", - "@commonalityco/ui-core": "workspace:*", - "@commonalityco/ui-design-system": "workspace:*", - "@commonalityco/utils-core": "workspace:*", - "@storybook/test": "^8.0.0", - "@tremor/react": "^3.14.1", - "next-themes": "^0.2.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "storybook-addon-variants": "^0.2.0" - }, - "devDependencies": { - "@commonalityco/config-tailwind": "workspace:*", - "@commonalityco/config-tsconfig": "workspace:*", - "@commonalityco/types": "workspace:*", - "@storybook/addon-a11y": "^8.0.0", - "@storybook/addon-docs": "^8.0.0", - "@storybook/addon-essentials": "^8.0.0", - "@storybook/addon-interactions": "^8.0.0", - "@storybook/addon-links": "^8.0.0", - "@storybook/addons": "^7.6.17", - "@storybook/blocks": "^8.0.0", - "@storybook/cli": "^8.0.0", - "@storybook/react": "^8.0.0", - "@storybook/react-vite": "^8.0.0", - "@types/react": "^18.2.57", - "@types/react-dom": "^18.2.19", - "@vitejs/plugin-react": "^4.2.1", - "@vitejs/plugin-react-swc": "^3.6.0", - "autoprefixer": "^10.4.17", - "eslint-config-commonality": "workspace:*", - "postcss": "^8.4.35", - "postcss-loader": "^7.3.4", - "prop-types": "^15.8.1", - "storybook": "^8.0.0", - "storybook-dark-mode": "^4.0.0", - "tailwindcss": "^3.4.1", - "typescript": "^5.3.3", - "vite": "^4.5.2", - "webpack": "^5.90.3" - }, - "repository": { - "type": "git", - "url": "https://github.com/commonalityco/commonality", - "directory": "apps/workshop" - } -} \ No newline at end of file diff --git a/apps/workshop/postcss.config.js b/apps/workshop/postcss.config.js deleted file mode 100644 index 12a703d9..00000000 --- a/apps/workshop/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/apps/workshop/public/FiraCode.var.woff2 b/apps/workshop/public/FiraCode.var.woff2 deleted file mode 100644 index e755a9dc..00000000 Binary files a/apps/workshop/public/FiraCode.var.woff2 and /dev/null differ diff --git a/apps/workshop/public/Inter-roman.var.woff2 b/apps/workshop/public/Inter-roman.var.woff2 deleted file mode 100644 index 6a256a06..00000000 Binary files a/apps/workshop/public/Inter-roman.var.woff2 and /dev/null differ diff --git a/apps/workshop/public/vite.svg b/apps/workshop/public/vite.svg deleted file mode 100644 index e7b8dfb1..00000000 --- a/apps/workshop/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/workshop/src/assets/README.ts b/apps/workshop/src/assets/README.ts deleted file mode 100644 index 76064748..00000000 --- a/apps/workshop/src/assets/README.ts +++ /dev/null @@ -1,70 +0,0 @@ -const readme = `# Xornet Ipsum - -Xornet ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. - -## Installation - -Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. - -This is a link - -\`\`\`bash -npm install xornet-ipsum -\`\`\` - -## Usage - -Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. - -\`\`\`javascript -const xornetIpsum = require('xornet-ipsum'); - -// Generate 5 paragraphs with default options -const paragraphs = xornetIpsum.generate(5); -console.log(paragraphs); -\`\`\` - -## Configuration - -Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. - -| Option | Type | Default | Description | -|-----------------|---------|---------|-------------------------------------------| -| \`paragraphs\` | Integer | 5 | Number of paragraphs to generate | -| \`sentences\` | Integer | 4 | Number of sentences per paragraph | -| \`words\` | Integer | 8 | Number of words per sentence | -| \`includeHeader\` | Boolean | false | Include header text in the output | - -### Example - -In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. - -\`\`\`javascript -const xornetIpsum = require('xornet-ipsum'); -// This is a reaaaaaaaaaaaaaaaaaaaaaallllllllllllllllllllyyyyyyyyyyyyyy loonnggggggggggggggggggg lineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee -const options = { - paragraphs: 7, - sentences: 6, - words: 12, - includeHeader: true -}; - -const text = xornetIpsum.generate(options); -console.log(text); -\`\`\` - -## Contributing - -Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. - -1. Fork the repository -2. Create your feature branch (\`git checkout -b feature/new-feature\`) -3. Commit your changes (\`git commit -am 'Add some feature'\`) -4. Push to the branch (\`git push origin feature/new-feature\`) -5. Create a new Pull Request - -## License - -Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.`; - -export default readme; diff --git a/apps/workshop/src/assets/react copy.svg b/apps/workshop/src/assets/react copy.svg deleted file mode 100644 index 6c87de9b..00000000 --- a/apps/workshop/src/assets/react copy.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/workshop/src/assets/react.svg b/apps/workshop/src/assets/react.svg deleted file mode 100644 index 6c87de9b..00000000 --- a/apps/workshop/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/apps/workshop/src/fonts/font-face.css b/apps/workshop/src/fonts/font-face.css deleted file mode 100644 index 2625ff95..00000000 --- a/apps/workshop/src/fonts/font-face.css +++ /dev/null @@ -1,17 +0,0 @@ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 100 900; - src: url('./Inter-roman.var.woff2') format('woff2 supports variations'), - url('./Inter-roman.var.woff2') format('woff2-variations'); - font-variation-settings: 'wght' 400; -} - -@font-face { - font-family: 'Fira Code'; - font-style: normal; - font-weight: 100 900; - src: url('./FiraCode.var.woff2') format('woff2 supports variations'), - url('./FiraCode.var.woff2') format('woff2-variations'); - font-variation-settings: 'wght' 400; -} diff --git a/apps/workshop/src/stories/colors.stories.tsx b/apps/workshop/src/stories/colors.stories.tsx deleted file mode 100644 index ea3b3df9..00000000 --- a/apps/workshop/src/stories/colors.stories.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { cn } from '@commonalityco/ui-design-system'; -import { Meta, StoryObj } from '@storybook/react'; - -function Shell({ children }: { children: React.ReactNode }) { - return
{children}
; -} - -function Chip({ - className, - children, -}: { - className: string; - children: React.ReactNode; -}) { - return ( -
- {children} -
- ); -} - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Colors', - component: Shell, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Light: Story = { - args: { - children: ( - <> - -

Primary

-
- -

Secondary

-
- -

Accent

-
- -

Muted

-
- -

Success

-
- -

Destructive

-
- - ), - }, -}; - -export const Dark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - args: { - children: ( - <> - -

Primary

-
- -

Secondary

-
- -

Accent

-
- -

Muted

-
- -

Success

-
- -

Destructive

-
- - ), - }, -}; diff --git a/apps/workshop/src/stories/constraints/graph.stories.tsx b/apps/workshop/src/stories/constraints/graph.stories.tsx deleted file mode 100644 index 1ab2452c..00000000 --- a/apps/workshop/src/stories/constraints/graph.stories.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { DependencyType, PackageType } from '@commonalityco/utils-core'; -import { Dependency, Package } from '@commonalityco/types'; -import { getEdges, getNodes, Graph } from '@commonalityco/feature-graph'; - -const meta: Meta = { - title: 'Graph', - component: Graph, - tags: ['autodocs'], - parameters: { - layout: 'fullscreen', - }, - args: {}, - decorators: [ - (Story) => ( -
- -
- ), - ], -}; - -export default meta; -type Story = StoryObj; - -const pkgOne = { - name: '@scope/pkg-a', - path: 'packages/pkg-a', - version: '1.0.0', - description: 'This is package A', - type: PackageType.NODE, -} satisfies Package; - -const pkgTwo = { - name: '@scope/pkg-b', - path: 'packages/pkg-b', - version: '1.0.0', - description: 'This is package B', - type: PackageType.NODE, -} satisfies Package; - -const pkgThree = { - name: '@scope/pkg-c', - path: 'packages/pkg-c', - version: '1.0.0', - description: 'This is package C', - type: PackageType.NODE, -} satisfies Package; - -const pkgFour = { - name: '@scope/pkg-d', - path: 'packages/pkg-d', - version: '1.0.0', - description: 'This is package D', - type: PackageType.NODE, -} satisfies Package; - -const pkgFive = { - name: '@scope/pkg-e', - path: 'packages/pkg-e', - version: '1.0.0', - description: 'This is package E', - type: PackageType.NODE, -} satisfies Package; - -const packages = [ - pkgOne, - pkgTwo, - pkgThree, - pkgFour, - pkgFive, -] satisfies Package[]; - -const dependencies = [ - { - type: DependencyType.PRODUCTION, - version: '1.0.0', - source: '@scope/pkg-a', - target: '@scope/pkg-b', - }, - { - type: DependencyType.DEVELOPMENT, - version: '1.0.0', - source: '@scope/pkg-a', - target: '@scope/pkg-c', - }, - { - type: DependencyType.DEVELOPMENT, - version: '1.0.0', - source: '@scope/pkg-d', - target: '@scope/pkg-', - }, - { - type: DependencyType.PEER, - version: '1.0.0', - source: '@scope/pkg-a', - target: '@scope/pkg-d', - }, - { - type: DependencyType.PEER, - version: '1.0.0', - source: '@scope/pkg-a', - target: '@scope/pkg-e', - }, -] satisfies Dependency[]; - -export const Default = { - args: { - nodes: getNodes({ - packages, - dependencies, - tagsData: [{ packageName: '@scope/pkg-a', tags: ['tag-a', 'tag-b'] }], - }), - edges: getEdges({ - dependencies, - theme: 'light', - activeDependencyTypes: [], - results: [], - }), - }, -} satisfies Story; diff --git a/apps/workshop/src/stories/constraints/sidebar.stories.tsx b/apps/workshop/src/stories/constraints/sidebar.stories.tsx deleted file mode 100644 index a66f5dfb..00000000 --- a/apps/workshop/src/stories/constraints/sidebar.stories.tsx +++ /dev/null @@ -1,267 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { GraphFilterSidebar } from '@commonalityco/feature-graph'; -import { Package } from '@commonalityco/types'; -import { PackageType } from '@commonalityco/utils-core'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'GraphFilterSidebar', - component: GraphFilterSidebar, - tags: ['autodocs'], - argTypes: {}, - decorators: [ - (Story) => ( -
- -
- ), - ], -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -const pkgOne = { - path: `/path/to/package-one`, - name: `@scope/one`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const pkgTwo = { - path: `/path/to/package-two`, - name: `@scope/two`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const pkgThree = { - path: `/path/to/package-three`, - name: `@scope/three`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const pkgFour = { - path: `/path/to/package-four`, - name: `@scope/four`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const pkgFive = { - path: `/path/to/package-five-looooooooooooooonnnnnngggggggg`, - name: `@scope/five-looooooooooooooonnnnnngggggggg`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -export const KitchenSink: Story = { - args: { - packages: [pkgOne, pkgTwo, pkgThree, pkgFour, pkgFive], - tagsData: [ - { packageName: '@scope/one', tags: ['tag-one', 'tag-two'] }, - { packageName: '@scope/two', tags: ['tag-three'] }, - { packageName: '@scope/three', tags: ['tag-four'] }, - { packageName: '@scope/four', tags: ['tag-five'] }, - { - packageName: '@scope/five', - tags: [ - 'tag-sixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - ], - }, - ], - codeownersData: [ - { - packageName: '@scope/one', - codeowners: ['@team-one'], - }, - { - packageName: '@scope/two', - codeowners: ['@team-two'], - }, - { - packageName: '@scope/three', - codeowners: ['@team-three'], - }, - { - packageName: '@scope/four', - codeowners: ['@team-four'], - }, - { - packageName: '@scope/five', - codeowners: [ - '@team-fiveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', - ], - }, - ], - }, -}; - -export const ZeroPackages: Story = { - args: { - initialSearch: 'tag', - - packages: [], - tagsData: [], - codeownersData: [], - }, -}; - -export const ZeroTags: Story = { - args: { - initialSearch: '@scope', - - packages: [pkgOne, pkgTwo, pkgThree, pkgFour, pkgFive], - tagsData: [], - codeownersData: [ - { - packageName: '@scope/one', - codeowners: ['@team-one'], - }, - { - packageName: '@scope/two', - codeowners: ['@team-two'], - }, - { - packageName: '@scope/three', - codeowners: ['@team-three'], - }, - { - packageName: '@scope/four', - codeowners: ['@team-four'], - }, - { - packageName: '@scope/five', - codeowners: ['@team-five'], - }, - ], - }, -}; - -export const ZeroCodeowners: Story = { - args: { - initialSearch: 'tag', - - packages: [pkgOne, pkgTwo, pkgThree, pkgFour, pkgFive], - tagsData: [ - { packageName: '@scope/one', tags: ['tag-one', 'tag-two'] }, - { packageName: '@scope/two', tags: ['tag-three'] }, - { packageName: '@scope/three', tags: ['tag-four'] }, - { packageName: '@scope/four', tags: ['tag-five'] }, - { packageName: '@scope/five', tags: ['tag-six'] }, - ], - codeownersData: [ - { - packageName: '@owner/one', - codeowners: [], - }, - { - packageName: '@owner/two', - codeowners: [], - }, - { - packageName: '@owner/three', - codeowners: [], - }, - { - packageName: '@owner/four', - codeowners: [], - }, - { - packageName: '@owner/five', - codeowners: [], - }, - ], - }, -}; - -export const ZeroItems: Story = { - args: { - initialSearch: 'zzzzzz', - - packages: [], - tagsData: [], - codeownersData: [], - }, -}; - -export const EmptyPackages: Story = { - args: { - packages: [], - tagsData: [], - codeownersData: [], - }, -}; - -export const EmptyTags: Story = { - args: { - packages: [pkgOne, pkgTwo, pkgThree, pkgFour, pkgFive], - tagsData: [], - codeownersData: [ - { - packageName: '@scope/one', - codeowners: ['@team-one'], - }, - { - packageName: '@scope/two', - codeowners: ['@team-two'], - }, - { - packageName: '@scope/three', - codeowners: ['@team-three'], - }, - { - packageName: '@scope/four', - codeowners: ['@team-four'], - }, - { - packageName: '@scope/five', - codeowners: ['@team-five'], - }, - ], - }, -}; - -export const EmptyCodeowners: Story = { - args: { - packages: [pkgOne, pkgTwo, pkgThree, pkgFour, pkgFive], - tagsData: [ - { packageName: '@scope/one', tags: ['tag-one', 'tag-two'] }, - { packageName: '@scope/two', tags: ['tag-three'] }, - { packageName: '@scope/three', tags: ['tag-four'] }, - { packageName: '@scope/four', tags: ['tag-five'] }, - { packageName: '@scope/five', tags: ['tag-six'] }, - ], - codeownersData: [ - { - packageName: '@owner/one', - codeowners: [], - }, - { - packageName: '@owner/two', - codeowners: [], - }, - { - packageName: '@owner/three', - codeowners: [], - }, - { - packageName: '@owner/four', - codeowners: [], - }, - { - packageName: '@owner/five', - codeowners: [], - }, - ], - }, -}; - -export const EmptyItems: Story = { - args: { - packages: [], - tagsData: [], - codeownersData: [], - }, -}; diff --git a/apps/workshop/src/stories/dependency-context.stories.tsx b/apps/workshop/src/stories/dependency-context.stories.tsx deleted file mode 100644 index 0f9b68d9..00000000 --- a/apps/workshop/src/stories/dependency-context.stories.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react'; - -import { DependencyContext } from '@commonalityco/feature-graph'; -import { DependencyType } from '@commonalityco/utils-core'; - -const meta: Meta = { - component: DependencyContext, -}; - -export default meta; -type Story = StoryObj; - -/* - *👇 Render functions are a framework specific feature to allow you control on how the component renders. - * See https://storybook.js.org/docs/api/csf - * to learn how to use render functions. - */ -export const KitchenSink: Story = { - render: () => ( - - ), -}; - -export const Empty: Story = { - render: () => ( - - ), -}; diff --git a/apps/workshop/src/stories/design-system/badge.stories.tsx b/apps/workshop/src/stories/design-system/badge.stories.tsx deleted file mode 100644 index dc94059c..00000000 --- a/apps/workshop/src/stories/design-system/badge.stories.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Badge } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Badge', - component: Badge, - tags: ['autodocs'], - argTypes: {}, - args: { - children: 'Hello Badge', - }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Default: Story = { - args: {}, -}; - -export const DefaultDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - args: { - className: 'dark', - }, -}; - -export const Secondary: Story = { - args: { - variant: 'secondary', - }, -}; - -export const SecondaryDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - args: { - variant: 'secondary', - className: 'dark', - }, -}; - -export const Destructive: Story = { - args: { - variant: 'destructive', - }, -}; - -export const DestructiveDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - args: { - variant: 'destructive', - className: 'dark', - }, -}; - -export const Success: Story = { - args: { - variant: 'success', - }, -}; - -export const SuccessDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - args: { - variant: 'success', - className: 'dark', - }, -}; - -export const Outline: Story = { - args: { - variant: 'outline', - }, -}; - -export const OutlineDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - args: { - variant: 'outline', - className: 'dark', - }, -}; diff --git a/apps/workshop/src/stories/design-system/button.stories.tsx b/apps/workshop/src/stories/design-system/button.stories.tsx deleted file mode 100644 index 259ce000..00000000 --- a/apps/workshop/src/stories/design-system/button.stories.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; - -import { Button } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Button', - component: Button, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Primary: Story = { - args: { - size: 'lg', - variant: 'default', - children: 'Click me', - }, -}; - -export const PrimaryDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - decorators: [ - (Story) => ( -
- -
- ), - ], - args: { - size: 'lg', - variant: 'default', - children: 'Click me', - }, -}; - -export const Sm: Story = { - args: { - size: 'sm', - variant: 'secondary', - children: 'Click me', - }, -}; - -export const Md: Story = { - args: { - size: 'default', - variant: 'secondary', - children: 'Click me', - }, -}; - -export const Lg: Story = { - args: { - size: 'lg', - variant: 'secondary', - children: 'Click me', - }, -}; - -export const Secondary: Story = { - args: { - size: 'lg', - variant: 'secondary', - children: 'Click me', - }, -}; - -export const SecondaryDark: Story = { - args: { - size: 'lg', - variant: 'secondary', - children: 'Click me', - }, - parameters: { - backgrounds: { default: 'dark' }, - }, - decorators: [ - (Story) => ( -
- -
- ), - ], -}; - -export const Outline: Story = { - args: { - size: 'lg', - variant: 'outline', - children: 'Click me', - }, -}; - -export const OutlineDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - decorators: [ - (Story) => ( -
- -
- ), - ], - args: { - size: 'lg', - variant: 'outline', - children: 'Click me', - }, -}; - -export const Ghost: Story = { - args: { - size: 'lg', - variant: 'ghost', - children: 'Click me', - }, -}; - -export const GhostDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - decorators: [ - (Story) => ( -
- -
- ), - ], - args: { - size: 'lg', - variant: 'ghost', - children: 'Click me', - }, -}; - -export const Destructive: Story = { - args: { - size: 'lg', - variant: 'destructive', - children: 'Click me', - }, -}; - -export const Link: Story = { - args: { - size: 'lg', - variant: 'link', - children: 'Click me', - }, -}; diff --git a/apps/workshop/src/stories/design-system/checkbox.stories.tsx b/apps/workshop/src/stories/design-system/checkbox.stories.tsx deleted file mode 100644 index 6c7966cd..00000000 --- a/apps/workshop/src/stories/design-system/checkbox.stories.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Checkbox, Label } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Checkbox', - component: Checkbox, - tags: ['autodocs'], - argTypes: {}, - args: { - id: 'foo', - }, - decorators: [ - (Story) => ( -
- - -
- ), - ], -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Primary: Story = { - args: {}, -}; diff --git a/apps/workshop/src/stories/design-system/dropdown-menu.stories.tsx b/apps/workshop/src/stories/design-system/dropdown-menu.stories.tsx deleted file mode 100644 index 59cadf73..00000000 --- a/apps/workshop/src/stories/design-system/dropdown-menu.stories.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { - Button, - DropdownMenu, - DropdownMenuContent, - DropdownMenuRadioGroup, - DropdownMenuRadioItem, - DropdownMenuTrigger, -} from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/DropdownMenu', - component: DropdownMenu, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Default: Story = { - args: { - children: ( - <> - - - - - - System - Light - Dark - - - - ), - }, -}; - -export const DefaultDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - decorators: [ - (Story) => ( -
- -
- ), - ], - args: { - children: ( - <> - - - - - - System - Light - Dark - - - - ), - }, -}; diff --git a/apps/workshop/src/stories/design-system/input.stories.tsx b/apps/workshop/src/stories/design-system/input.stories.tsx deleted file mode 100644 index 20b86fdc..00000000 --- a/apps/workshop/src/stories/design-system/input.stories.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Input } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Text Input', - component: Input, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -export const Default: Story = {}; diff --git a/apps/workshop/src/stories/design-system/kbd.stories.tsx b/apps/workshop/src/stories/design-system/kbd.stories.tsx deleted file mode 100644 index aaab28b4..00000000 --- a/apps/workshop/src/stories/design-system/kbd.stories.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Kbd } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Kbd', - component: Kbd, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Default: Story = { - args: { - children: 'crtl + k', - }, -}; diff --git a/apps/workshop/src/stories/design-system/label.stories.tsx b/apps/workshop/src/stories/design-system/label.stories.tsx deleted file mode 100644 index 2f92cb95..00000000 --- a/apps/workshop/src/stories/design-system/label.stories.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Label } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Label', - component: Label, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Default: Story = { - args: { - children: 'Hello I am a label', - }, -}; diff --git a/apps/workshop/src/stories/design-system/select.stories.tsx b/apps/workshop/src/stories/design-system/select.stories.tsx deleted file mode 100644 index ad6707f7..00000000 --- a/apps/workshop/src/stories/design-system/select.stories.tsx +++ /dev/null @@ -1,223 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { - Button, - Popover, - PopoverContent, - PopoverTrigger, - Select, -} from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Select', - component: Select, - tags: ['autodocs'], - argTypes: {}, - args: { - className: 'max-', - }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Default: Story = { - args: { - menuIsOpen: true, - defaultValue: { value: 'chocolate', label: 'Chocolate' }, - options: [ - { value: 'chocolate', label: 'Chocolate' }, - { value: 'strawberry', label: 'Strawberry' }, - { - value: 'vanilla', - label: - 'Vanillaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - }, - ], - }, -}; - -export const DefaultDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - decorators: [ - (Story) => ( -
- -
- ), - ], - args: { - className: 'dark', - menuIsOpen: true, - defaultValue: { value: 'chocolate', label: 'Chocolate' }, - options: [ - { value: 'chocolate', label: 'Chocolate' }, - { value: 'strawberry', label: 'Strawberry' }, - { - value: 'vanilla', - label: - 'Vanillaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - }, - ], - }, -}; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const PopoverMode: Story = { - decorators: [ - (Story) => ( - - - - - - - - - ), - ], - args: { - autoFocus: true, - menuIsOpen: true, - backspaceRemovesValue: false, - controlShouldRenderValue: false, - hideSelectedOptions: false, - closeMenuOnSelect: false, - isClearable: false, - variant: 'inline', - defaultValue: { value: 'chocolate', label: 'Chocolate' }, - options: [ - { value: 'chocolate', label: 'Chocolate' }, - { value: 'strawberry', label: 'Strawberry' }, - { - value: 'vanilla', - label: - 'Vanillaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - }, - ], - }, -}; - -export const PopoverModeMulti: Story = { - decorators: [ - (Story) => ( - - - - - - - - - ), - ], - args: { - isMulti: true, - autoFocus: true, - menuIsOpen: true, - backspaceRemovesValue: false, - controlShouldRenderValue: false, - hideSelectedOptions: false, - closeMenuOnSelect: false, - isClearable: false, - variant: 'inline', - defaultValue: { value: 'chocolate', label: 'Chocolate' }, - options: [ - { value: 'chocolate', label: 'Chocolate' }, - { value: 'strawberry', label: 'Strawberry' }, - { - value: 'vanilla', - label: - 'Vanillaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - }, - ], - }, -}; - -export const PopoverModeDark: Story = { - parameters: { - backgrounds: { default: 'dark' }, - }, - decorators: [ - (Story) => ( -
- - - - - - - - -
- ), - ], - args: { - className: 'dark', - autoFocus: true, - menuIsOpen: true, - backspaceRemovesValue: false, - closeMenuOnSelect: false, - controlShouldRenderValue: false, - hideSelectedOptions: false, - isClearable: false, - variant: 'inline', - defaultValue: { value: 'chocolate', label: 'Chocolate' }, - options: [ - { value: 'chocolate', label: 'Chocolate' }, - { value: 'strawberry', label: 'Strawberry' }, - { - value: 'vanilla', - label: - 'Vanillaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - }, - ], - }, -}; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const SynchronousGhost: Story = { - args: { - variant: 'ghost', - menuIsOpen: true, - defaultValue: { value: 'chocolate', label: 'Chocolate' }, - options: [ - { value: 'chocolate', label: 'Chocolate' }, - { value: 'strawberry', label: 'Strawberry' }, - { - value: 'vanilla', - label: - 'Vanillaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - }, - ], - }, -}; - -export const SynchronousMulti: Story = { - args: { - closeMenuOnSelect: false, - // menuIsOpen: true, - isMulti: true, - defaultValue: [ - { value: 'chocolate-1', label: 'Chocolate' }, - { value: 'strawberry-1', label: 'Strawberry' }, - ], - options: [ - { value: 'chocolate-1', label: 'Chocolate' }, - { value: 'strawberry-1', label: 'Strawberry' }, - { value: 'vanilla-1', label: 'Vanilla' }, - { value: 'chocolate-2', label: 'Chocolate' }, - { value: 'strawberry-2', label: 'Strawberry' }, - { value: 'vanilla-2', label: 'Vanilla' }, - { value: 'chocolate-3', label: 'Chocolate' }, - { value: 'strawberry-3', label: 'Strawberry' }, - { value: 'vanilla-3', label: 'Vanilla' }, - { value: 'chocolate-4', label: 'Chocolate' }, - { value: 'strawberry-4', label: 'Strawberry' }, - { value: 'vanilla-4', label: 'Vanilla' }, - ], - }, -}; diff --git a/apps/workshop/src/stories/design-system/sheet.stories.tsx b/apps/workshop/src/stories/design-system/sheet.stories.tsx deleted file mode 100644 index 85705bba..00000000 --- a/apps/workshop/src/stories/design-system/sheet.stories.tsx +++ /dev/null @@ -1,163 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { - Sheet, - Button, - Input, - Label, - SheetClose, - SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, - SheetTitle, - SheetTrigger, - ScrollArea, -} from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Sheet', - component: Sheet, - tags: ['autodocs'], - args: { - open: true, - }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Default: Story = { - args: { - children: ( - <> - - - - - - Edit profile - - Make changes to your profile here. Click save when you're done. - - -
-
- - -
-
- - -
-
- - - - - -
- - ), - }, -}; - -export const StressTest: Story = { - args: { - children: ( - <> - - - - - - - This is a - looooooooooooooooooooooooooonnnnnnnnnnnnnnngggggggggggggg title - - - This is some - loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong - content, like - realllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllly - long. - - - -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Mauris - sit amet massa vitae tortor condimentum lacinia quis vel. In - egestas erat imperdiet sed euismod nisi porta lorem mollis. - Lacinia quis vel eros donec ac odio tempor. Diam vel quam - elementum pulvinar etiam non quam. Nisi quis eleifend quam - adipiscing vitae proin. Rutrum quisque non tellus orci ac auctor - augue mauris. Nulla porttitor massa id neque aliquam vestibulum - morbi blandit. Mauris cursus mattis molestie a. Quam nulla - porttitor massa id neque aliquam vestibulum. Ultrices gravida - dictum fusce ut placerat orci nulla. Fermentum posuere urna nec - tincidunt praesent semper feugiat. Sit amet porttitor eget dolor - morbi non arcu risus. Leo integer malesuada nunc vel risus - commodo. Eget magna fermentum iaculis eu non diam. Est ante in - nibh mauris cursus mattis. Scelerisque mauris pellentesque - pulvinar pellentesque habitant morbi. Ligula ullamcorper malesuada - proin libero nunc consequat interdum. Magna fringilla urna - porttitor rhoncus dolor purus. Sodales ut eu sem integer vitae - justo. Ut ornare lectus sit amet est placerat. Velit euismod in - pellentesque massa placerat duis ultricies lacus sed. Mauris - ultrices eros in cursus turpis massa tincidunt dui. Pulvinar neque - laoreet suspendisse interdum consectetur libero id faucibus. Velit - aliquet sagittis id consectetur purus ut faucibus pulvinar - elementum. Non sodales neque sodales ut etiam sit amet nisl purus. - Molestie nunc non blandit massa enim nec. Mattis enim ut tellus - elementum sagittis vitae. Laoreet sit amet cursus sit amet dictum - sit amet justo. Donec adipiscing tristique risus nec feugiat in. - Commodo ullamcorper a lacus vestibulum sed arcu non. Lectus sit - amet est placerat in egestas. Iaculis eu non diam phasellus - vestibulum lorem sed risus ultricies. Nam aliquam sem et tortor - consequat id. Diam sollicitudin tempor id eu nisl nunc mi. Cursus - euismod quis viverra nibh cras pulvinar mattis nunc sed. At - volutpat diam ut venenatis. Orci eu lobortis elementum nibh. - Laoreet suspendisse interdum consectetur libero id faucibus nisl. - Nulla pharetra diam sit amet nisl. Mauris pellentesque pulvinar - pellentesque habitant. Adipiscing enim eu turpis egestas pretium - aenean. Diam ut venenatis tellus in metus vulputate eu. Lacinia at - quis risus sed vulputate odio ut. Vulputate dignissim suspendisse - in est. Suspendisse sed nisi lacus sed viverra tellus in hac. - Sodales ut etiam sit amet. Diam quam nulla porttitor massa id - neque aliquam vestibulum. Etiam non quam lacus suspendisse - faucibus. Mattis rhoncus urna neque viverra justo nec ultrices dui - sapien. In hendrerit gravida rutrum quisque non tellus orci. - Rutrum quisque non tellus orci ac auctor augue mauris. At ultrices - mi tempus imperdiet nulla malesuada pellentesque. Nullam non nisi - est sit amet. Non curabitur gravida arcu ac tortor dignissim. Nisi - est sit amet facilisis magna etiam tempor. Feugiat in ante metus - dictum at tempor commodo ullamcorper. Ornare quam viverra orci - sagittis eu volutpat odio. Viverra aliquet eget sit amet tellus - cras adipiscing. Orci ac auctor augue mauris augue neque gravida - in. Sociis natoque penatibus et magnis dis parturient montes. Sit - amet mauris commodo quis imperdiet. Augue eget arcu dictum varius - duis at consectetur lorem donec. Tortor at auctor urna nunc id. - Egestas pretium aenean pharetra magna ac placerat. At varius vel - pharetra vel turpis nunc eget. Nunc id cursus metus aliquam - eleifend mi in. Nisi est sit amet facilisis magna etiam tempor - orci eu. Purus faucibus ornare suspendisse sed nisi lacus sed - viverra. Sagittis orci a scelerisque purus semper eget duis at. - Sagittis eu volutpat odio facilisis. -

-
- - - - - -
- - ), - }, -}; diff --git a/apps/workshop/src/stories/design-system/snippet.stories.tsx b/apps/workshop/src/stories/design-system/snippet.stories.tsx deleted file mode 100644 index d3004601..00000000 --- a/apps/workshop/src/stories/design-system/snippet.stories.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Snippet } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Snippet', - component: Snippet, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Large: Story = { - args: { - size: 'lg', - children: 'pnpx commonality init', - }, -}; - -export const Medium: Story = { - args: { - size: 'md', - children: 'pnpx commonality init', - }, -}; - -export const Small: Story = { - args: { - size: 'sm', - children: 'pnpx commonality init', - }, -}; diff --git a/apps/workshop/src/stories/design-system/switch.stories.tsx b/apps/workshop/src/stories/design-system/switch.stories.tsx deleted file mode 100644 index f66ada69..00000000 --- a/apps/workshop/src/stories/design-system/switch.stories.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Switch } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Switch', - component: Switch, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Primary: Story = { - args: {}, -}; diff --git a/apps/workshop/src/stories/design-system/table.stories.tsx b/apps/workshop/src/stories/design-system/table.stories.tsx deleted file mode 100644 index 87393e39..00000000 --- a/apps/workshop/src/stories/design-system/table.stories.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Table', - component: Table, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Primary: Story = { - args: { - children: ( - <> - - - Name - Age - - - - - Alice - 1 - - - Bob - 2 - - - Ralph - 2 - - - - ), - }, -}; diff --git a/apps/workshop/src/stories/design-system/toggle.stories.tsx b/apps/workshop/src/stories/design-system/toggle.stories.tsx deleted file mode 100644 index 79b2f887..00000000 --- a/apps/workshop/src/stories/design-system/toggle.stories.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Toggle } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Toggle', - component: Toggle, - tags: ['autodocs'], - argTypes: {}, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args -export const Default: Story = { - args: { - children: 'This is some text.', - }, -}; diff --git a/apps/workshop/src/stories/design-system/tooltip.stories.tsx b/apps/workshop/src/stories/design-system/tooltip.stories.tsx deleted file mode 100644 index 2c9b3b43..00000000 --- a/apps/workshop/src/stories/design-system/tooltip.stories.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { - Tooltip, - TooltipTrigger, - TooltipContent, - TooltipProvider, -} from '@commonalityco/ui-design-system'; -import { Button } from '@commonalityco/ui-design-system'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Design System/Tooltip', - component: TooltipContent, - tags: ['autodocs'], - argTypes: {}, - decorators: [ - (Story) => ( - - - - - - - - - ), - ], -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -export const Default: Story = { - args: { - children: 'Hello', - }, -}; - -export const Open: Story = { - args: { - children: 'Hello', - }, -}; diff --git a/apps/workshop/src/stories/package-context.stories.tsx b/apps/workshop/src/stories/package-context.stories.tsx deleted file mode 100644 index b00b21c8..00000000 --- a/apps/workshop/src/stories/package-context.stories.tsx +++ /dev/null @@ -1,162 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react'; - -import { PackageContext } from '@commonalityco/feature-graph'; -import { DependencyType, PackageType, Status } from '@commonalityco/utils-core'; - -const meta: Meta = { - component: PackageContext, -}; - -export default meta; -type Story = StoryObj; - -/* - *👇 Render functions are a framework specific feature to allow you control on how the component renders. - * See https://storybook.js.org/docs/api/csf - * to learn how to use render functions. - */ -export const KitchenSink: Story = { - render: () => ( - - ), -}; - -export const AllPassing: Story = { - render: () => ( - - ), -}; - -export const Empty: Story = { - render: () => ( - - ), -}; diff --git a/apps/workshop/src/stories/project-context.stories.tsx b/apps/workshop/src/stories/project-context.stories.tsx deleted file mode 100644 index 5b8c1a73..00000000 --- a/apps/workshop/src/stories/project-context.stories.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react'; - -import { PackageContext, ProjectContext } from '@commonalityco/feature-graph'; -import { - DependencyType, - PackageManager, - PackageType, - Status, -} from '@commonalityco/utils-core'; - -const meta: Meta = { - component: PackageContext, -}; - -export default meta; -type Story = StoryObj; - -/* - *👇 Render functions are a framework specific feature to allow you control on how the component renders. - * See https://storybook.js.org/docs/api/csf - * to learn how to use render functions. - */ -export const KitchenSink: Story = { - render: () => ( - - ), -}; - -export const Empty: Story = { - render: () => ( - - ), -}; diff --git a/apps/workshop/src/stories/ui-core/navigation-button.stories.tsx b/apps/workshop/src/stories/ui-core/navigation-button.stories.tsx deleted file mode 100644 index 49be9ac5..00000000 --- a/apps/workshop/src/stories/ui-core/navigation-button.stories.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { NavigationButton } from '@commonalityco/ui-core'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Core/NavigationButton', - component: NavigationButton, - tags: ['autodocs'], - argTypes: {}, - parameters: { - layout: 'fullscreen', - }, - args: { - children: 'Click me', - }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args - -export const NotActive: Story = { - args: { - active: false, - }, -}; - -export const Active: Story = { - args: { - active: true, - }, -}; diff --git a/apps/workshop/src/stories/ui-core/navigation.stories.tsx b/apps/workshop/src/stories/ui-core/navigation.stories.tsx deleted file mode 100644 index e3ea401b..00000000 --- a/apps/workshop/src/stories/ui-core/navigation.stories.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { Divider, Navigation, NavigationLogo } from '@commonalityco/ui-core'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Core/Navigation', - component: Navigation, - tags: ['autodocs'], - argTypes: {}, - parameters: { - layout: 'fullscreen', - }, -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args - -export const Simple: Story = { - args: { - children: ( - <> -
- - -
- - ), - }, -}; diff --git a/apps/workshop/src/stories/ui-core/theme-picker-button.stories.tsx b/apps/workshop/src/stories/ui-core/theme-picker-button.stories.tsx deleted file mode 100644 index 13088c8b..00000000 --- a/apps/workshop/src/stories/ui-core/theme-picker-button.stories.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Meta, StoryObj } from '@storybook/react'; -import { ThemeButton } from '@commonalityco/ui-core'; -import { ThemeProvider } from 'next-themes'; - -// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction -const meta = { - title: 'Core/Theme Button', - component: ThemeButton, - tags: ['autodocs'], - argTypes: {}, - parameters: { - layout: 'fullscreen', - }, - decorators: [ - (Story) => ( - - - - ), - ], -} satisfies Meta; - -export default meta; -type Story = StoryObj; - -// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args - -export const Simple: Story = { - args: {}, -}; diff --git a/apps/workshop/src/tailwind.css b/apps/workshop/src/tailwind.css deleted file mode 100644 index b49168ff..00000000 --- a/apps/workshop/src/tailwind.css +++ /dev/null @@ -1 +0,0 @@ -@import '@commonalityco/ui-design-system/src/styles/globals.css'; diff --git a/apps/workshop/src/vite-env.d.ts b/apps/workshop/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2..00000000 --- a/apps/workshop/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/apps/workshop/tailwind.config.js b/apps/workshop/tailwind.config.js deleted file mode 100644 index 41f8d197..00000000 --- a/apps/workshop/tailwind.config.js +++ /dev/null @@ -1,20 +0,0 @@ -const path = require('node:path'); -const baseConfig = require('@commonalityco/config-tailwind'); - -const getPkgPattern = (pkgName) => { - return path.join( - path.dirname(require.resolve(pkgName)), - '**/*.{js,jsx,ts,tsx}', - ); -}; - -module.exports = { - ...baseConfig, - content: [ - './node_modules/@tremor/**/*.{js,ts,jsx,tsx}', - './src/**/*.{js,ts,jsx,tsx}', - getPkgPattern('@commonalityco/ui-design-system'), - getPkgPattern('@commonalityco/ui-core'), - getPkgPattern('@commonalityco/feature-graph'), - ], -}; diff --git a/apps/workshop/tsconfig.json b/apps/workshop/tsconfig.json deleted file mode 100644 index 85c33316..00000000 --- a/apps/workshop/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "@commonalityco/config-tsconfig/react.json", - "include": ["./src/**/*.ts", "./src/**/*.tsx"] -} diff --git a/apps/workshop/tsconfig.node.json b/apps/workshop/tsconfig.node.json deleted file mode 100644 index b5376a7d..00000000 --- a/apps/workshop/tsconfig.node.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true - }, - "include": ["vitest.config.ts"] -} diff --git a/apps/workshop/vite.config.js b/apps/workshop/vite.config.js deleted file mode 100644 index 0466183a..00000000 --- a/apps/workshop/vite.config.js +++ /dev/null @@ -1,6 +0,0 @@ -import { defineConfig } from 'vite'; -import react from '@vitejs/plugin-react'; - -export default defineConfig({ - plugins: [react()], -}); diff --git a/package.json b/package.json index 76f9826d..91600d80 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@commonalityco/monorepo", "version": "0.0.1", - "packageManager": "pnpm@8.15.3", + "packageManager": "pnpm@9.3.0", "description": "", "repository": "https://github.com/commonalityco/commonality", "contributors": [ @@ -19,8 +19,8 @@ "lint": "turbo run lint --cache-dir=.turbo", "prepare": "husky install", "test:integration": "CI=true turbo run test:integration", - "test:watch": "vitest run --watch", - "test": "vitest run", + "test:watch": "turbo watch test --cache-dir=.turbo", + "test": "turbo run test --cache-dir=.turbo", "type-check": "turbo run type-check --cache-dir=.turbo", "unlink-all": "ts-node scripts/unlink-all.ts", "knip": "knip" @@ -29,28 +29,25 @@ "author": "", "license": "ISC", "dependencies": { - "@changesets/cli": "^2.27.1", + "@changesets/cli": "^2.27.7", "@commonalityco/config-tsconfig": "workspace:*", "@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/parser": "^6.21.0", - "@vitest/coverage-v8": "^0.34.6", "commonality": "workspace:*", "commonality-checks-recommended": "workspace:*", - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-config-commonality": "workspace:*", - "eslint-plugin-unused-imports": "^3.1.0", + "eslint-plugin-unused-imports": "^3.2.0", "execa": "^8.0.1", "husky": "^8.0.3", + "knip": "^5.25.1", "npm-run-all": "^4.1.5", - "prettier": "^3.2.5", - "prettier-plugin-tailwindcss": "^0.5.11", + "pkg-pr-new": "^0.0.15", + "prettier": "^3.3.2", + "prettier-plugin-tailwindcss": "^0.5.14", "ts-node": "^10.9.2", - "turbo": "^1.12.4", - "typescript": "^5.4.2", - "vitest": "^0.34.6" - }, - "devDependencies": { - "@commonalityco/studio": "workspace:^", - "knip": "^5.0.4" + "turbo": "2.0.6", + "typescript": "^5.5.3", + "vitest": "^2.0.2" } } diff --git a/packages/commonality-checks-recommended/package.json b/packages/commonality-checks-recommended/package.json index 4dfccfa3..30dac156 100644 --- a/packages/commonality-checks-recommended/package.json +++ b/packages/commonality-checks-recommended/package.json @@ -40,7 +40,8 @@ "eslint-config-commonality": "workspace:*", "mock-fs": "^5.2.0", "tsup": "^8.0.2", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vitest": "^2.0.2" }, "dependencies": { "lodash-es": "^4.17.21", diff --git a/packages/commonality-checks-recommended/src/consistent-external-version.test.ts b/packages/commonality-checks-recommended/src/consistent-external-version.test.ts index 5f893e5c..0716c846 100644 --- a/packages/commonality-checks-recommended/src/consistent-external-version.test.ts +++ b/packages/commonality-checks-recommended/src/consistent-external-version.test.ts @@ -117,11 +117,11 @@ describe('consistent-external-version', () => { // @ts-expect-error expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Object { - \\"dependencies\\": Object { - \\"package3\\": \\"3.0.0\\", - + \\"package3\\": \\"1.0.0\\", + "dependencies": Object { + "package3": "3.0.0", + + "package3": "1.0.0", }, - \\"devDependencies\\": Object {}, + "devDependencies": Object {}, }" `); }); diff --git a/packages/commonality-checks-recommended/src/extends-repository-field.test.ts b/packages/commonality-checks-recommended/src/extends-repository-field.test.ts index 80b93c7b..72d5067c 100644 --- a/packages/commonality-checks-recommended/src/extends-repository-field.test.ts +++ b/packages/commonality-checks-recommended/src/extends-repository-field.test.ts @@ -74,10 +74,10 @@ describe('extendsRepositoryField', () => { expect(result.suggestion).toMatchInlineSnapshot(` " Object {} + Object { - + \\"repository\\": Object { - + \\"directory\\": \\"packages/pkg-a\\", - + \\"type\\": \\"git\\", - + \\"url\\": \\"https://github.com/npm/cli.git\\", + + "repository": Object { + + "directory": "packages/pkg-a", + + "type": "git", + + "url": "https://github.com/npm/cli.git", + }, + }" `); @@ -153,13 +153,13 @@ describe('extendsRepositoryField', () => { // @ts-expect-error expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Object { - \\"repository\\": Object { - \\"directory\\": \\"packages/pkg-b\\", - \\"type\\": \\"gitt\\", - \\"url\\": \\"https://github.com/npm/clii.git\\", - + \\"directory\\": \\"packages/pkg-a\\", - + \\"type\\": \\"git\\", - + \\"url\\": \\"https://github.com/npm/cli.git\\", + "repository": Object { + "directory": "packages/pkg-b", + "type": "gitt", + "url": "https://github.com/npm/clii.git", + + "directory": "packages/pkg-a", + + "type": "git", + + "url": "https://github.com/npm/cli.git", }, }" `); @@ -204,10 +204,10 @@ describe('extendsRepositoryField', () => { expect(result.suggestion).toMatchInlineSnapshot(` " Object {} + Object { - + \\"repository\\": Object { - + \\"directory\\": \\"packages/pkg-a\\", - + \\"type\\": \\"git\\", - + \\"url\\": \\"https://github.com/npm/cli.git\\", + + "repository": Object { + + "directory": "packages/pkg-a", + + "type": "git", + + "url": "https://github.com/npm/cli.git", + }, + }" `); @@ -283,13 +283,13 @@ describe('extendsRepositoryField', () => { // @ts-expect-error expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Object { - \\"repository\\": Object { - \\"directory\\": \\"packages/pkg-b\\", - \\"type\\": \\"gitt\\", - \\"url\\": \\"https://github.com/npm/clii.git\\", - + \\"directory\\": \\"packages/pkg-a\\", - + \\"type\\": \\"git\\", - + \\"url\\": \\"https://github.com/npm/cli.git\\", + "repository": Object { + "directory": "packages/pkg-b", + "type": "gitt", + "url": "https://github.com/npm/clii.git", + + "directory": "packages/pkg-a", + + "type": "git", + + "url": "https://github.com/npm/cli.git", }, }" `); diff --git a/packages/commonality-checks-recommended/src/has-json-file.test.ts b/packages/commonality-checks-recommended/src/has-json-file.test.ts index 5bc626b8..2d4ad34c 100644 --- a/packages/commonality-checks-recommended/src/has-json-file.test.ts +++ b/packages/commonality-checks-recommended/src/has-json-file.test.ts @@ -49,7 +49,7 @@ describe('hasJsonFile', () => { expect(result.suggestion).toMatchInlineSnapshot(` " Object {} + Object { - + \\"key\\": \\"value\\", + + "key": "value", + }" `); }); diff --git a/packages/commonality-checks-recommended/src/has-text-file.test.ts b/packages/commonality-checks-recommended/src/has-text-file.test.ts index a0e58229..05f18bb6 100644 --- a/packages/commonality-checks-recommended/src/has-text-file.test.ts +++ b/packages/commonality-checks-recommended/src/has-text-file.test.ts @@ -52,8 +52,8 @@ describe('hasTextFile', () => { // @ts-expect-error expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Array [ - \\"Hello World\\", - + \\"Hello Universe\\", + "Hello World", + + "Hello Universe", ]" `); }); diff --git a/packages/commonality-checks-recommended/src/matching-dev-peer-versions.test.ts b/packages/commonality-checks-recommended/src/matching-dev-peer-versions.test.ts index 1e2a5cd1..68b07d01 100644 --- a/packages/commonality-checks-recommended/src/matching-dev-peer-versions.test.ts +++ b/packages/commonality-checks-recommended/src/matching-dev-peer-versions.test.ts @@ -32,9 +32,9 @@ describe('matching-dev-peer-versions', () => { expect(result.suggestion).toMatchInlineSnapshot( ` " Object { - \\"devDependencies\\": undefined, - + \\"devDependencies\\": Object { - + \\"pkg-b\\": \\"^18.0.0\\", + "devDependencies": undefined, + + "devDependencies": Object { + + "pkg-b": "^18.0.0", + }, }" `, @@ -67,9 +67,9 @@ describe('matching-dev-peer-versions', () => { // @ts-expect-error - expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Object { - \\"devDependencies\\": Object { - \\"pkg-b\\": \\"^17.0.2\\", - + \\"pkg-b\\": \\"^18.0.0\\", + "devDependencies": Object { + "pkg-b": "^17.0.2", + + "pkg-b": "^18.0.0", }, }" `); diff --git a/packages/commonality-checks-recommended/src/unique-dependency-types.test.ts b/packages/commonality-checks-recommended/src/unique-dependency-types.test.ts index 0d87928e..ffff9b54 100644 --- a/packages/commonality-checks-recommended/src/unique-dependency-types.test.ts +++ b/packages/commonality-checks-recommended/src/unique-dependency-types.test.ts @@ -46,13 +46,13 @@ describe('unique-dependency-types', () => { // @ts-expect-error - expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Object { - \\"dependencies\\": Object { - \\"pkg-a\\": \\"1.0.0\\", + "dependencies": Object { + "pkg-a": "1.0.0", }, - \\"devDependencies\\": Object { - \\"pkg-a\\": \\"1.0.0\\", + "devDependencies": Object { + "pkg-a": "1.0.0", }, - + \\"devDependencies\\": Object {}, + + "devDependencies": Object {}, }" `); }); @@ -78,13 +78,13 @@ describe('unique-dependency-types', () => { // @ts-expect-error - expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Object { - \\"dependencies\\": Object { - \\"pkg-a\\": \\"1.0.0\\", + "dependencies": Object { + "pkg-a": "1.0.0", }, - \\"optionalDependencies\\": Object { - \\"pkg-a\\": \\"1.0.0\\", + "optionalDependencies": Object { + "pkg-a": "1.0.0", }, - + \\"optionalDependencies\\": Object {}, + + "optionalDependencies": Object {}, }" `); }); @@ -113,15 +113,15 @@ describe('unique-dependency-types', () => { // @ts-expect-error - expecting message object expect(result.suggestion).toMatchInlineSnapshot(` " Object { - \\"dependencies\\": Object { - \\"pkg-a\\": \\"1.0.0\\", + "dependencies": Object { + "pkg-a": "1.0.0", }, - + \\"dependencies\\": Object {}, - \\"devDependencies\\": Object { - \\"pkg-a\\": \\"1.0.0\\", + + "dependencies": Object {}, + "devDependencies": Object { + "pkg-a": "1.0.0", }, - \\"optionalDependencies\\": Object { - \\"pkg-a\\": \\"1.0.0\\", + "optionalDependencies": Object { + "pkg-a": "1.0.0", }, }" `); diff --git a/packages/data-codeowners/package.json b/packages/data-codeowners/package.json index d51665d5..0504dac6 100644 --- a/packages/data-codeowners/package.json +++ b/packages/data-codeowners/package.json @@ -37,7 +37,8 @@ "@types/micromatch": "^4.0.6", "@types/node": "^20.11.20", "eslint-config-commonality": "workspace:*", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vitest": "^2.0.2" }, "repository": { "type": "git", diff --git a/packages/data-codeowners/test/fixtures/missing-file/pnpm-workspace.yaml b/packages/data-codeowners/test/fixtures/missing-file/pnpm-workspace.yaml index 600b4bb4..b189c800 100644 --- a/packages/data-codeowners/test/fixtures/missing-file/pnpm-workspace.yaml +++ b/packages/data-codeowners/test/fixtures/missing-file/pnpm-workspace.yaml @@ -1,2 +1,7 @@ packages: - 'packages/**' + +catalog: + react: ^18.2.0 + react-dom: '^18.2.0' + lucide-react: '^0.396.0' diff --git a/packages/data-constraints/package.json b/packages/data-constraints/package.json index 1adc84fe..c792162c 100644 --- a/packages/data-constraints/package.json +++ b/packages/data-constraints/package.json @@ -24,11 +24,12 @@ "@commonalityco/types": "workspace:*", "@commonalityco/utils-core": "workspace:*", "eslint-config-commonality": "workspace:*", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vitest": "^2.0.2" }, "repository": { "type": "git", "url": "https://github.com/commonalityco/commonality", "directory": "packages/data-constraints" } -} \ No newline at end of file +} diff --git a/packages/data-constraints/src/get-constraint-results.test.ts b/packages/data-constraints/src/get-constraint-results.test.ts index 53667540..d24e73c3 100644 --- a/packages/data-constraints/src/get-constraint-results.test.ts +++ b/packages/data-constraints/src/get-constraint-results.test.ts @@ -89,7 +89,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -128,7 +128,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -167,7 +167,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -206,7 +206,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -247,7 +247,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -263,7 +263,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -304,7 +304,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -320,7 +320,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -361,7 +361,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -408,7 +408,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -424,7 +424,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-c', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -465,7 +465,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -524,19 +524,19 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, { source: 'pkg-b', target: 'pkg-c', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, { source: 'pkg-c', target: 'pkg-d', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -553,19 +553,19 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'development', + type: DependencyType.DEVELOPMENT, version: '1.0.0', }, { source: 'pkg-b', target: 'pkg-c', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, { source: 'pkg-c', target: 'pkg-d', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -605,7 +605,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -645,7 +645,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -685,7 +685,7 @@ describe('get-constraint-results', () => { { source: 'pkg-a', target: 'pkg-b', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -774,7 +774,7 @@ describe('get-constraint-results', () => { { source: 'pkg-one', target: 'pkg-two', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -790,7 +790,7 @@ describe('get-constraint-results', () => { { source: 'pkg-one', target: 'pkg-three', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -806,7 +806,7 @@ describe('get-constraint-results', () => { { source: 'pkg-one', target: 'pkg-four', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -822,7 +822,7 @@ describe('get-constraint-results', () => { { source: 'pkg-four', target: 'pkg-six', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], @@ -838,7 +838,7 @@ describe('get-constraint-results', () => { { source: 'pkg-three', target: 'pkg-one', - type: 'production', + type: DependencyType.PRODUCTION, version: '1.0.0', }, ], diff --git a/packages/data-packages/package.json b/packages/data-packages/package.json index 73f599dc..443d5e52 100644 --- a/packages/data-packages/package.json +++ b/packages/data-packages/package.json @@ -40,7 +40,8 @@ "@types/fs-extra": "^11.0.4", "@types/node": "^20.11.20", "eslint-config-commonality": "workspace:*", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vitest": "^2.0.2" }, "repository": { "type": "git", diff --git a/packages/data-packages/src/get-dependencies.test.ts b/packages/data-packages/src/get-dependencies.test.ts index 0961653a..6c6a6481 100644 --- a/packages/data-packages/src/get-dependencies.test.ts +++ b/packages/data-packages/src/get-dependencies.test.ts @@ -32,7 +32,7 @@ describe('getDependencies', () => { const expectedDependencies = [ { source: 'pkg-one', - target: 'pkg-two', + target: '@scope/pkg-two', type: DependencyType.PRODUCTION, version: '1.0.0', }, diff --git a/packages/data-packages/src/get-package.test.ts b/packages/data-packages/src/get-package.test.ts index ba8ffe2b..37d28c41 100644 --- a/packages/data-packages/src/get-package.test.ts +++ b/packages/data-packages/src/get-package.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { getPackage } from './get-package'; import path from 'node:path'; -import { PackageType } from '@commonalityco/utils-core'; +import { BlockType } from '@commonalityco/utils-core'; import { fileURLToPath } from 'node:url'; describe('getPackage', () => { @@ -51,8 +51,12 @@ describe('getPackage', () => { name: 'pkg-one', description: 'pkg-one description', path: 'packages/pkg-one', - type: PackageType.NODE, + type: BlockType.NODE, version: '1.0.0', + churn: 0.3, + complexity: 0.3, + license: 'MIT', + privacy: 'PRIVATE', }); }); }); diff --git a/packages/data-packages/src/get-package.ts b/packages/data-packages/src/get-package.ts index 0a7f4ffa..0e4b05a1 100644 --- a/packages/data-packages/src/get-package.ts +++ b/packages/data-packages/src/get-package.ts @@ -1,27 +1,24 @@ import { Package, PackageJson } from '@commonalityco/types'; import path from 'node:path'; import fs from 'fs-extra'; -import { PackageType } from '@commonalityco/utils-core/constants'; +import { BlockType } from '@commonalityco/utils-core/constants'; +import { privacyEnum } from '@commonalityco/utils-core'; -const typeOrder = new Set([ - PackageType.NEXT, - PackageType.REACT, - PackageType.NODE, -]); +const typeOrder = new Set([BlockType.NEXT, BlockType.REACT, BlockType.NODE]); const DepNamesByPackageType = { - [PackageType.REACT]: 'react', - [PackageType.NEXT]: 'next', + [BlockType.REACT]: 'react', + [BlockType.NEXT]: 'next', }; const getType = (dependencies?: Record) => { if (!dependencies) { - return PackageType.NODE; + return BlockType.NODE; } for (const type of typeOrder) { - if (type === PackageType.NODE) { - return PackageType.NODE; + if (type === BlockType.NODE) { + return BlockType.NODE; } const depName = DepNamesByPackageType[type]; @@ -34,7 +31,7 @@ const getType = (dependencies?: Record) => { return type; } - return PackageType.NODE; + return BlockType.NODE; }; export const getPackage = async ({ @@ -57,6 +54,25 @@ export const getPackage = async ({ return; } + const getPrivacy = () => { + if (packageJson.private === true) { + return privacyEnum.enum.PRIVATE; + } + if (packageJson.publishConfig?.access === 'restricted') { + return privacyEnum.enum.PRIVATE; + } + if (packageJson?.name?.startsWith('@')) { + // Scoped packages default to private + return packageJson.private === false + ? privacyEnum.enum.PUBLIC + : privacyEnum.enum.PRIVATE; + } + // Unscoped packages default to public + return packageJson.private + ? privacyEnum.enum.PRIVATE + : privacyEnum.enum.PUBLIC; + }; + return { name: packageJson.name, description: packageJson.description, @@ -66,5 +82,9 @@ export const getPackage = async ({ ...packageJson.devDependencies, }), version: packageJson.version ?? '', + churn: 0.3, + complexity: 0.3, + license: packageJson.license, + privacy: getPrivacy(), } satisfies Package; }; diff --git a/packages/data-packages/src/get-packages.test.ts b/packages/data-packages/src/get-packages.test.ts index 14848069..5f3df686 100644 --- a/packages/data-packages/src/get-packages.test.ts +++ b/packages/data-packages/src/get-packages.test.ts @@ -1,7 +1,7 @@ import path from 'node:path'; import { getPackages } from './get-packages'; import { describe, expect, it } from 'vitest'; -import { PackageType } from '@commonalityco/utils-core'; +import { BlockType } from '@commonalityco/utils-core'; import { fileURLToPath } from 'node:url'; describe('getPackages', () => { @@ -20,7 +20,11 @@ describe('getPackages', () => { version: '1.0.0', description: 'root description', path: '.', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, + license: undefined, + privacy: 'PUBLIC', }, ]); }); @@ -40,14 +44,22 @@ describe('getPackages', () => { version: '1.0.0', description: 'pkg-one description', path: 'packages/pkg-one', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, + license: 'MIT', + privacy: 'PRIVATE', }, { - name: 'pkg-two', + name: '@scope/pkg-two', version: '1.0.0', description: 'pkg-two description', path: 'packages/pkg-two', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, + license: undefined, + privacy: 'PRIVATE', }, ]); }); diff --git a/packages/data-packages/src/index.ts b/packages/data-packages/src/index.ts index dc0ed82a..946a0fe0 100644 --- a/packages/data-packages/src/index.ts +++ b/packages/data-packages/src/index.ts @@ -1,3 +1,4 @@ +export { getInvalidPackages } from './get-invalid-packages'; export { getPackages } from './get-packages'; export { getRootPackageName } from './get-root-package-name'; export { getDependencies } from './get-dependencies'; diff --git a/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-one/package.json b/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-one/package.json index 554ad2d0..0ce78f45 100644 --- a/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-one/package.json +++ b/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-one/package.json @@ -2,8 +2,10 @@ "name": "pkg-one", "description": "pkg-one description", "version": "1.0.0", + "license": "MIT", + "private": true, "dependencies": { - "pkg-two": "1.0.0", + "@scope/pkg-two": "1.0.0", "external-dep": "1.0.0" } } diff --git a/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-two/package.json b/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-two/package.json index e219806d..68d32fc0 100644 --- a/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-two/package.json +++ b/packages/data-packages/test/fixtures/kitchen-sink/packages/pkg-two/package.json @@ -1,5 +1,5 @@ { - "name": "pkg-two", + "name": "@scope/pkg-two", "description": "pkg-two description", "version": "1.0.0" } diff --git a/packages/data-project/package.json b/packages/data-project/package.json index 392d3c9f..82ccb247 100644 --- a/packages/data-project/package.json +++ b/packages/data-project/package.json @@ -34,7 +34,8 @@ "@types/node": "^20.11.20", "eslint-config-commonality": "workspace:*", "mock-fs": "^5.2.0", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vitest": "^2.0.2" }, "dependencies": { "@commonalityco/utils-core": "workspace:*", diff --git a/packages/data-tags/package.json b/packages/data-tags/package.json index 29601f9a..61355655 100644 --- a/packages/data-tags/package.json +++ b/packages/data-tags/package.json @@ -30,7 +30,8 @@ "@types/fs-extra": "^11.0.4", "@types/node": "^20.11.20", "eslint-config-commonality": "workspace:*", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "vitest": "^2.0.2" }, "dependencies": { "@commonalityco/utils-core": "workspace:*", diff --git a/packages/data-tags/test/get-tags-data.test.ts b/packages/data-tags/test/get-tags-data.test.ts index 85589318..78c95cfd 100644 --- a/packages/data-tags/test/get-tags-data.test.ts +++ b/packages/data-tags/test/get-tags-data.test.ts @@ -2,7 +2,7 @@ import { Package, TagsData } from '@commonalityco/types'; import path from 'node:path'; import { describe, test, expect } from 'vitest'; import { getTagsData } from '../src/get-tags-data.js'; -import { PackageType } from '@commonalityco/utils-core'; +import { BlockType } from '@commonalityco/utils-core'; import { fileURLToPath } from 'node:url'; describe('getTagsData', () => { @@ -18,19 +18,25 @@ describe('getTagsData', () => { name: 'pkg-one', path: 'packages/pkg-one', version: '0.0.0', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, }, { name: 'pkg-two', path: 'packages/pkg-two', version: '0.0.0', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, }, { name: 'pkg-three', path: 'packages/pkg-three', version: '0.0.0', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, }, ] satisfies Package[]; @@ -60,19 +66,25 @@ describe('getTagsData', () => { name: 'pkg-one', path: 'packages/pkg-one', version: '0.0.0', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, }, { name: 'pkg-two', path: 'packages/pkg-two', version: '0.0.0', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, }, { name: 'pkg-three', path: 'packages/pkg-three', version: '0.0.0', - type: PackageType.NODE, + type: BlockType.NODE, + churn: 0.3, + complexity: 0.3, }, ] satisfies Package[]; diff --git a/packages/data-tags/test/set-tags.test.ts b/packages/data-tags/test/set-tags.test.ts index 80d15835..f1d0edb9 100644 --- a/packages/data-tags/test/set-tags.test.ts +++ b/packages/data-tags/test/set-tags.test.ts @@ -4,11 +4,15 @@ import os from 'node:os'; import path from 'node:path'; import { setTags } from '../src/set-tags'; import { fileURLToPath } from 'node:url'; -import { PackageType } from '@commonalityco/utils-core'; +import { BlockType } from '@commonalityco/utils-core'; describe('setTags', () => { + const temporaryDirectoryPath = path.join( + process.env['RUNNER_TEMP'] || os.tmpdir(), + 'set-tags-', + ); + describe('when setting tags for a package with no configuration file', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = mkdtempSync(temporaryDirectoryPath); const emptyFixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), @@ -29,7 +33,7 @@ describe('setTags', () => { pkg: { name: 'pkg-one', path: './packages/pkg-one', - type: PackageType.NEXT, + type: BlockType.NEXT, version: '1.0.0', }, tags: ['tag-one'], @@ -48,8 +52,10 @@ describe('setTags', () => { pkg: { name: 'pkg-one', path: './packages/pkg-one', - type: PackageType.NEXT, + type: BlockType.NEXT, version: '1.0.0', + churn: 0.5, + complexity: 0.5, }, tags: ['tag-one'], }); @@ -61,7 +67,6 @@ describe('setTags', () => { }); describe('when setting tags for a package with existing tags', () => { - const temporaryDirectoryPath = process.env['RUNNER_TEMP'] || os.tmpdir(); const temporaryPath = mkdtempSync(temporaryDirectoryPath); const fixturePath = path.resolve( path.dirname(fileURLToPath(import.meta.url)), @@ -82,7 +87,7 @@ describe('setTags', () => { pkg: { name: 'pkg-one', path: './packages/pkg-one', - type: PackageType.NEXT, + type: BlockType.NEXT, version: '1.0.0', }, tags: ['tag-one', 'new-tag'], diff --git a/packages/feature-graph/.eslintrc.json b/packages/feature-graph/.eslintrc.json deleted file mode 100644 index 49a16ad6..00000000 --- a/packages/feature-graph/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "root": true, - "extends": [ - "commonality" - ] -} \ No newline at end of file diff --git a/packages/feature-graph/.npmignore b/packages/feature-graph/.npmignore deleted file mode 100644 index 56affc6d..00000000 --- a/packages/feature-graph/.npmignore +++ /dev/null @@ -1 +0,0 @@ -*.test.* \ No newline at end of file diff --git a/packages/feature-graph/CHANGELOG.md b/packages/feature-graph/CHANGELOG.md deleted file mode 100644 index 5b30fd45..00000000 --- a/packages/feature-graph/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# @commonalityco/feature-graph - -## 0.1.0 - -### Minor Changes - -- bfddcb3: release feature-graph - -## 0.0.1 - -### Patch Changes - -- 5b8761b: Update layout of graph and deprecate packages -- Updated dependencies [5b8761b] - - @commonalityco/ui-design-system@0.2.42 - - @commonalityco/ui-core@0.2.41 diff --git a/packages/feature-graph/README.md b/packages/feature-graph/README.md deleted file mode 100644 index f30a29f7..00000000 --- a/packages/feature-graph/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# @commonalityco/feature-graph - -> Get conformance information about a local project - -## Installation - -```sh -npm install @commonalityco/feature-graph -``` diff --git a/packages/feature-graph/commonality.json b/packages/feature-graph/commonality.json deleted file mode 100644 index 0b832860..00000000 --- a/packages/feature-graph/commonality.json +++ /dev/null @@ -1 +0,0 @@ -{"tags":["feature"]} diff --git a/packages/feature-graph/package.json b/packages/feature-graph/package.json deleted file mode 100644 index 7e14b8e7..00000000 --- a/packages/feature-graph/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@commonalityco/feature-graph", - "description": "UI primitives for building the Commonality Studio graph", - "version": "0.1.0", - "type": "module", - "publishConfig": { - "access": "public" - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "exports": { - ".": "./dist/index.js", - "./query-parsers": "./dist/query/query-parsers.js", - "./package-toolbar": "./dist/components/package-toolbar.js", - "./graph-control-bar": "./dist/components/graph-control-bar.js" - }, - "license": "MIT", - "scripts": { - "build": "tsc --build", - "dev": "tsc --watch", - "lint": "eslint .", - "lint:fix": "eslint . --fix", - "test": "vitest", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@commonalityco/config-tailwind": "workspace:*", - "@commonalityco/config-tsconfig": "workspace:*", - "@commonalityco/types": "workspace:*", - "@commonalityco/ui-core": "workspace:*", - "@commonalityco/ui-design-system": "workspace:*", - "@commonalityco/utils-conformance": "workspace:*", - "@commonalityco/utils-core": "workspace:*", - "@testing-library/jest-dom": "^6.4.2", - "@testing-library/react": "^14.2.1", - "@testing-library/user-event": "^14.5.2", - "@types/dagre": "^0.7.52", - "@types/lodash-es": "^4.17.12", - "@types/react": "^18.2.57", - "eslint-config-commonality": "workspace:*", - "jotai": "^2.6.5", - "lz-string": "^1.5.0", - "nuqs": "^1.17.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "typescript": "^5.3.3", - "vitest": "^0.34.6" - }, - "peerDependencies": { - "@commonalityco/ui-core": "*", - "@commonalityco/ui-design-system": "*", - "jotai": "^2", - "react": ">=18", - "react-dom": ">=18" - }, - "dependencies": { - "@nivo/pie": "^0.85.1", - "@tanstack/react-table": "^8.13.2", - "@tremor/react": "^3.14.1", - "@xyflow/react": "12.0.0-next.11", - "@xyflow/system": "^0.0.17", - "cookies-next": "^4.1.1", - "dagre": "^0.8.5", - "framer-motion": "^11.0.5", - "lodash-es": "^4.17.21", - "lucide-react": "^0.317.0", - "react-resizable-panels": "^0.0.54" - }, - "repository": { - "type": "git", - "url": "https://github.com/commonalityco/commonality", - "directory": "packages/feature-graph" - } -} \ No newline at end of file diff --git a/packages/feature-graph/src/atoms/graph-atoms.ts b/packages/feature-graph/src/atoms/graph-atoms.ts deleted file mode 100644 index e78f718b..00000000 --- a/packages/feature-graph/src/atoms/graph-atoms.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable unicorn/no-null */ -import { Dependency, Package } from '@commonalityco/types'; -import { atom } from 'jotai'; - -export const selectedDependenciesAtom = atom([]); - -export const selectedPackagesAtom = atom([]); - -export const isGraphLoadingAtom = atom(false); diff --git a/packages/feature-graph/src/components/constraints-onboarding-card.tsx b/packages/feature-graph/src/components/constraints-onboarding-card.tsx deleted file mode 100644 index 514cd233..00000000 --- a/packages/feature-graph/src/components/constraints-onboarding-card.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { - Button, - Card, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from '@commonalityco/ui-design-system'; -import { ExternalLink, ShieldCheck } from 'lucide-react'; - -export function ConstraintsOnboardingCard() { - return ( - - -
-
- -
-
- - Structure your dependency graph - - Create boundaries in your codebase by limiting which packages can - depend on one another. - -
- - - -
- ); -} diff --git a/packages/feature-graph/src/components/dependency-context.tsx b/packages/feature-graph/src/components/dependency-context.tsx deleted file mode 100644 index f58247b4..00000000 --- a/packages/feature-graph/src/components/dependency-context.tsx +++ /dev/null @@ -1,328 +0,0 @@ -'use client'; -import { - Badge, - Card, - Label, - ScrollArea, - Separator, - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, - cn, -} from '@commonalityco/ui-design-system'; -import { - CornerDownRight, - Dot, - Network, - Package, - ShieldCheck, - ShieldClose, -} from 'lucide-react'; -import { DependencyType, formatTagName } from '@commonalityco/utils-core'; -import { ConstraintResult, Dependency } from '@commonalityco/types'; -import { ConstraintsOnboardingCard } from './constraints-onboarding-card'; -import { GradientFade } from '@commonalityco/ui-core'; - -const TextByType = { - [DependencyType.PRODUCTION]: 'production', - [DependencyType.DEVELOPMENT]: 'development', - [DependencyType.PEER]: 'peer', -}; - -function IconContainer({ type }: { type: DependencyType }) { - return ( -
- -
- ); -} - -function ConstraintsTagsContainer({ - tags, - - labelId, - allPackagesText, -}: { - tags: string[] | '*'; - labelId: string; - allPackagesText: string; -}) { - return ( -
- - {tags === '*' ? ( - {allPackagesText} - ) : ( - tags.map((tag) => { - return ( - - {formatTagName(tag)} - - ); - }) - )} - -
- ); -} - -function TagsContainer({ - children, - ...rest -}: { children: React.ReactNode } & React.ComponentProps<'dd'>) { - return ( -
- {children} -
- ); -} - -export function DependencyContext({ - constraintResults, - dependency, -}: { - constraintResults: ConstraintResult[]; - dependency: Dependency; -}) { - const dependencyResults = constraintResults.filter((result) => - result.dependencyPath.some( - (path) => - path.source === dependency.source && - path.target === dependency.target && - path.type === dependency.type, - ), - ); - const invalidCount = dependencyResults.filter( - (result) => !result.isValid, - ).length; - const validCount = dependencyResults.length - invalidCount; - - return ( -
-
- -
-
-

{dependency.source}

-
- -

{dependency.target}

-
-
- - -
- -

{dependency.version}

- -
-
-

- {TextByType[dependency.type]} -

-
-
-
- - - - - {dependencyResults.length > 0 ? ( - <> -
- - -

0, - 'text-muted-foreground': validCount === 0, - })} - > - {validCount} -

-
- - -

0, - 'text-muted-foreground': invalidCount === 0, - })} - > - {invalidCount} -

-
-
- -
- {dependencyResults.map((dependencyResult) => { - return ( -
-
- - - - {dependencyResult.isValid ? ( - <> - - - ) : ( - <> - - - )} - - - {dependencyResult.isValid - ? 'Valid constraint' - : 'Invalid constraint'} - - - - - - -

- {dependencyResult.filter} -

-
- - {dependencyResult.filter === '*' - ? 'This constraint is applied to all packages' - : `This constraint is applied to packages with this tag`} - -
-
-
- -
-

Dependency path

- -
- {dependencyResult.dependencyPath.map((path, index) => ( -
-

- - {path.source} -

- {index === 0 ? ( -
- {'allow' in dependencyResult.constraint ? ( - <> -
- Allowed: -
- - - ) : undefined} - {'disallow' in dependencyResult.constraint ? ( - <> -
- Disallowed: -
- - - ) : undefined} -
- ) : ( -
- )} - - {index + 1 === - dependencyResult.dependencyPath.length ? ( -
-

- - - {path.target} - -

-
-
- Found: -
-
- -
-
- -
- ) : undefined} -
- ))} -
-
-
- ); - })} -
- - ) : ( - - )} - - -
- ); -} diff --git a/packages/feature-graph/src/components/dependency-edge.tsx b/packages/feature-graph/src/components/dependency-edge.tsx deleted file mode 100644 index fffeb73e..00000000 --- a/packages/feature-graph/src/components/dependency-edge.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import { DependencyType } from '@commonalityco/utils-core'; -import { - BaseEdge, - Edge, - EdgeLabelRenderer, - EdgeProps, - getBezierPath, -} from '@xyflow/react'; -import { DependencyEdgeData } from '../utilities/get-edges'; -import { cn } from '@commonalityco/ui-design-system'; -import { ShieldX } from 'lucide-react'; - -const TEXT_BY_TYPE = { - [DependencyType.DEVELOPMENT]: 'dev', - [DependencyType.PEER]: 'peer', - [DependencyType.PRODUCTION]: 'prod', -}; - -export function DependencyEdge({ - id, - sourceX, - sourceY, - targetX, - targetY, - data, - targetPosition, - sourcePosition, - selected, - ...props -}: EdgeProps>) { - const [edgePath, labelX, labelY] = getBezierPath({ - targetPosition, - sourcePosition, - sourceX, - sourceY, - targetX, - targetY, - }); - - const highlighted = - data?.active || - data?.activeDependencyTypes.includes(data.dependency.type) || - selected; - - return ( - <> - !result.isValid), - }, - )} - /> - - - {data?.results.some((result) => !result.isValid) ? ( - - - - - {data?.results.length} - - ) : ( - - {data?.dependency.type ? TEXT_BY_TYPE[data.dependency.type] : ''} - - )} - - - - ); -} diff --git a/packages/feature-graph/src/components/graph-context-sidebar.tsx b/packages/feature-graph/src/components/graph-context-sidebar.tsx deleted file mode 100644 index ea5779ea..00000000 --- a/packages/feature-graph/src/components/graph-context-sidebar.tsx +++ /dev/null @@ -1,103 +0,0 @@ -'use client'; -import { useAtom } from 'jotai'; -import { - selectedDependenciesAtom, - selectedPackagesAtom, -} from '../atoms/graph-atoms'; -import { - CodeownersData, - ConstraintResult, - Package, - TagsData, -} from '@commonalityco/types'; -import { ConformanceResult } from '@commonalityco/utils-conformance'; -import { getConformanceScore } from '@commonalityco/utils-conformance/get-conformance-score'; -import { PackageContext } from './package-context'; -import { DependencyContext } from './dependency-context'; -import { ProjectContext } from './project-context'; -import { PackageManager, Status } from '@commonalityco/utils-core'; - -export function GraphContextSidebar({ - packages = [], - tagsData = [], - codeownersData = [], - checkResults = [], - constraintResults = [], - packageManager, - packageHeaderContent, - projectName, -}: { - packages: Package[]; - tagsData: TagsData[]; - codeownersData: CodeownersData[]; - checkResults: ConformanceResult[]; - constraintResults: ConstraintResult[]; - packageHeaderContent?: React.ReactNode; - packageManager: PackageManager; - projectName: string; -}) { - const [selectedDependencies] = useAtom(selectedDependenciesAtom); - const [selectedPackages] = useAtom(selectedPackagesAtom); - - if (selectedPackages.length === 1 && selectedPackages[0] !== undefined) { - const selectedPackage = selectedPackages[0]; - - return ( - - ); - } - - if ( - selectedDependencies.length === 1 && - selectedDependencies[0] !== undefined - ) { - const selectedDependency = selectedDependencies[0]; - - return ( - - ); - } - - const score = getConformanceScore(checkResults); - const checkPassCount = checkResults.filter( - (result) => result.status === Status.Pass, - ).length; - const checkWarnCount = checkResults.filter( - (result) => result.status === Status.Warn, - ).length; - const checkFailCount = checkResults.filter( - (result) => result.status === Status.Fail, - ).length; - - const constraintPassCount = constraintResults.filter( - (result) => result.isValid, - ).length; - const constraintFailCount = constraintResults.filter( - (result) => !result.isValid, - ).length; - - return ( - - ); -} diff --git a/packages/feature-graph/src/components/graph-control-bar.tsx b/packages/feature-graph/src/components/graph-control-bar.tsx deleted file mode 100644 index 6c1dcf8b..00000000 --- a/packages/feature-graph/src/components/graph-control-bar.tsx +++ /dev/null @@ -1,248 +0,0 @@ -'use client'; -import { useReactFlow } from '@xyflow/react'; -import { GraphDirection } from '../utilities/types'; -import { - Button, - DropdownMenu, - DropdownMenuCheckboxItem, - DropdownMenuContent, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuShortcut, - DropdownMenuTrigger, - Separator, - ToggleGroup, - ToggleGroupItem, - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, - cn, -} from '@commonalityco/ui-design-system'; -import { - ArrowDownFromLine, - ArrowRightFromLine, - ChevronDown, - Maximize, - Minus, - Plus, -} from 'lucide-react'; -import { useState } from 'react'; -import { DependencyType } from '@commonalityco/utils-core'; -import { useDirectionQuery, useColorQuery } from '../query/query-hooks'; - -function ButtonTooltip({ - children, - text, -}: { - children: React.ReactNode; - text: string; -}) { - return ( - - - - {children} - - - {text} - - - ); -} - -function ColorDot({ className }: { className?: string }) { - return ( -
- ); -} -function ColorDropdown({ - defaultDependencyTypes = [], - onHighlightChange, -}: { - defaultDependencyTypes?: DependencyType[]; - onHighlightChange: (dependencyTypes: DependencyType[]) => void; -}) { - const [isOpen, setIsOpen] = useState(false); - const [checkedDependencyTypes, setCheckedDependencyTypes] = useState< - DependencyType[] - >(defaultDependencyTypes); - - const reactFlow = useReactFlow(); - - const onColorChange = (depedencyType: DependencyType, checked: boolean) => { - const newDependencyTypes = checked - ? [...checkedDependencyTypes, depedencyType] - : checkedDependencyTypes.filter((type) => type !== depedencyType); - - setCheckedDependencyTypes(newDependencyTypes); - - reactFlow.setEdges((currentEdges) => - currentEdges.map((currentEdge) => { - return { - ...currentEdge, - data: { - ...currentEdge.data, - activeDependencyTypes: newDependencyTypes, - }, - }; - }), - ); - - onHighlightChange(newDependencyTypes); - }; - - const dependencyTypeToText = { - [DependencyType.PRODUCTION]: 'Production', - [DependencyType.DEVELOPMENT]: 'Development', - [DependencyType.PEER]: 'Peer', - }; - - return ( - - - - - setIsOpen(false)} - onEscapeKeyDown={() => setIsOpen(false)} - > - Dependency Type - - {[ - { type: DependencyType.PRODUCTION, color: 'bg-emerald-600' }, - { type: DependencyType.DEVELOPMENT, color: 'bg-sky-600' }, - { type: DependencyType.PEER, color: 'bg-purple-600' }, - ].map(({ type, color }) => ( - onColorChange(type, checked)} - > - {dependencyTypeToText[type]} - -
- - - ))} - - - ); -} - -export function GraphControlBar() { - const [directionQuery, setDirectionQuery] = useDirectionQuery(); - const [highlightQuery, setHighlightQuery] = useColorQuery(); - const reactFlow = useReactFlow(); - - return ( -
-
-
- - - - - setDirectionQuery(direction) - } - > - - - - - - - - - - - - - - - - - - -
- - - -
- -
- - - -
-
-
-
- ); -} diff --git a/packages/feature-graph/src/components/graph-empty.tsx b/packages/feature-graph/src/components/graph-empty.tsx deleted file mode 100644 index 87b5d714..00000000 --- a/packages/feature-graph/src/components/graph-empty.tsx +++ /dev/null @@ -1,22 +0,0 @@ -'use client'; -import { Button, cn } from '@commonalityco/ui-design-system'; -import { PackageSearch } from 'lucide-react'; -import { useInteractions } from '../context/interaction-context'; - -export function GraphEmpty() { - const interactions = useInteractions(); - - return ( -
-
- -

No packages match your filters

- -
-
- ); -} diff --git a/packages/feature-graph/src/components/graph-filter-sidebar.test.tsx b/packages/feature-graph/src/components/graph-filter-sidebar.test.tsx deleted file mode 100644 index 6aa0aa0f..00000000 --- a/packages/feature-graph/src/components/graph-filter-sidebar.test.tsx +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @vitest-environment jsdom - */ -import { GraphFilterSidebar } from './graph-filter-sidebar'; -import { render, screen } from '@testing-library/react'; -import { ComponentPropsWithoutRef } from 'react'; -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { Package } from '@commonalityco/types'; -import { PackageType } from '@commonalityco/utils-core'; -import { GraphInteractionProvider } from '../context/interaction-context'; -import * as queryHooks from '../query/query-hooks'; - -const renderSidebar = (properties: { - initialSearch: ComponentPropsWithoutRef< - typeof GraphFilterSidebar - >['initialSearch']; - packages: ComponentPropsWithoutRef['packages']; - tagsData: ComponentPropsWithoutRef['tagsData']; - codeownersData: ComponentPropsWithoutRef< - typeof GraphFilterSidebar - >['codeownersData']; -}) => { - render( - - - , - ); -}; - -const packageOne = { - path: `/path/to/package-one`, - name: `@scope/one`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const packageTwo = { - path: `/path/to/package-two`, - name: `@scope/two`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const packageThree = { - path: `/path/to/package-three`, - name: `@scope/three`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const packageFour = { - path: `/path/to/package-four`, - name: `@scope/four`, - version: '1.0.0', - type: PackageType.NODE, -} satisfies Package; - -const packageFive = { - path: `/path/to/package-five-looooooooooooooonnnnnngggggggg`, - name: `@scope/five-looooooooooooooonnnnnngggggggg`, - version: '1.0.0', - tags: ['tag-five'], - owners: ['@team-five'], - type: PackageType.NODE, -}; - -describe('', () => { - beforeEach(() => { - vi.spyOn(queryHooks, 'usePackagesQuery').mockReturnValue([[], vi.fn()]); - }); - - describe('when there is no search', () => { - const initialSearch = undefined; - - describe('when there are no packages', () => { - it('displays the empty state', () => { - renderSidebar({ - initialSearch, - packages: [], - tagsData: [], - codeownersData: [], - }); - - expect(screen.getByText('Create your first package')); - }); - }); - - describe('when there are no tags', () => { - it('displays the empty state', () => { - renderSidebar({ - initialSearch, - packages: [ - packageOne, - packageTwo, - packageThree, - packageFour, - packageFive, - ], - tagsData: [], - codeownersData: [ - { - packageName: '@scope/one', - codeowners: ['@team-one'], - }, - { - packageName: '@scope/two', - codeowners: ['@team-two'], - }, - { - packageName: '@scope/three', - codeowners: ['@team-three'], - }, - { - packageName: '@scope/four', - codeowners: ['@team-four'], - }, - { - packageName: '@scope/five', - codeowners: ['@team-five'], - }, - ], - }); - - expect(screen.getByText('Get started with tags')).toBeTruthy(); - - const link = screen.getByRole('link', { name: 'Learn more' }); - - expect(link).toBeTruthy(); - expect(link.getAttribute('href')).toEqual( - 'https://docs.commonality.co/tags', - ); - }); - }); - - describe('when there are no codeowners', () => { - it('displays the empty state', () => { - renderSidebar({ - initialSearch, - packages: [ - packageOne, - packageTwo, - packageThree, - packageFour, - packageFive, - ], - tagsData: [ - { packageName: '@scope/one', tags: ['tag-one', 'tag-two'] }, - { packageName: '@scope/two', tags: ['tag-three'] }, - { packageName: '@scope/three', tags: ['tag-four'] }, - { packageName: '@scope/four', tags: ['tag-five'] }, - { packageName: '@scope/five', tags: ['tag-six'] }, - ], - codeownersData: [ - { - packageName: '@owner/one', - codeowners: [], - }, - { - packageName: '@owner/two', - codeowners: [], - }, - { - packageName: '@owner/three', - codeowners: [], - }, - { - packageName: '@owner/four', - codeowners: [], - }, - { - packageName: '@owner/five', - codeowners: [], - }, - ], - }); - - expect(screen.getByText('Assign ownership')); - }); - }); - }); - - describe('when there is a search', () => { - describe('when there are no packages', () => { - it('displays the zero state', async () => { - renderSidebar({ - initialSearch: 'zzzzzzzz', - packages: [], - tagsData: [], - codeownersData: [], - }); - - expect(screen.getAllByText('No matches found')).toHaveLength(1); - }); - }); - - describe('when there are no tags', () => { - it('displays the zero state', () => { - renderSidebar({ - initialSearch: '@scope', - packages: [ - packageOne, - packageTwo, - packageThree, - packageFour, - packageFive, - ], - tagsData: [], - codeownersData: [ - { - packageName: '@scope/one', - codeowners: ['@team-one'], - }, - { - packageName: '@scope/two', - codeowners: ['@team-two'], - }, - { - packageName: '@scope/three', - codeowners: ['@team-three'], - }, - { - packageName: '@scope/four', - codeowners: ['@team-four'], - }, - { - packageName: '@scope/five', - codeowners: ['@team-five'], - }, - ], - }); - - expect(screen.getByText('No matching tags')).toBeTruthy(); - }); - }); - - describe('when there are no codeowners', () => { - it('displays the zero state', () => { - renderSidebar({ - initialSearch: 'tag', - packages: [ - packageOne, - packageTwo, - packageThree, - packageFour, - packageFive, - ], - tagsData: [ - { packageName: '@scope/one', tags: ['tag-one', 'tag-two'] }, - { packageName: '@scope/two', tags: ['tag-three'] }, - { packageName: '@scope/three', tags: ['tag-four'] }, - { packageName: '@scope/four', tags: ['tag-five'] }, - { packageName: '@scope/five', tags: ['tag-six'] }, - ], - codeownersData: [ - { - packageName: '@owner/one', - codeowners: [], - }, - { - packageName: '@owner/two', - codeowners: [], - }, - { - packageName: '@owner/three', - codeowners: [], - }, - { - packageName: '@owner/four', - codeowners: [], - }, - { - packageName: '@owner/five', - codeowners: [], - }, - ], - }); - - expect(screen.getByText('No matching codeowners')).toBeTruthy(); - }); - }); - }); -}); diff --git a/packages/feature-graph/src/components/graph-filter-sidebar.tsx b/packages/feature-graph/src/components/graph-filter-sidebar.tsx deleted file mode 100644 index 0aa11621..00000000 --- a/packages/feature-graph/src/components/graph-filter-sidebar.tsx +++ /dev/null @@ -1,685 +0,0 @@ -'use client'; -import { CodeownersData, Package, TagsData } from '@commonalityco/types'; -import { GradientFade, getIconForPackage } from '@commonalityco/ui-core'; -import { - Badge, - Button, - Card, - CardDescription, - CardFooter, - CardHeader, - CardTitle, - Input, - ScrollArea, - Text, - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from '@commonalityco/ui-design-system'; -import { - Box, - ExternalLink, - Eye, - EyeOff, - Focus, - Tags, - Users, -} from 'lucide-react'; -import { ComponentProps, useMemo, useState } from 'react'; -import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels'; -import { useInteractions } from '../context/interaction-context'; -import { usePackagesQuery } from '../query/query-hooks'; -import { setCookie } from 'cookies-next'; -import { COOKIE_FILTER_SIDEBAR } from '../constants/cookie-names'; - -function ShowHideButton({ - visible, - onHide, - onShow, -}: { - visible: boolean; - onHide: ComponentProps['onClick']; - onShow: ComponentProps['onClick']; -}) { - return ( -
- - - - - - {visible ? 'Hide' : 'Show'} - - -
- ); -} - -function FocusButton({ - onClick, - children, -}: { - onClick: ComponentProps['onClick']; - children?: string; -}) { - return ( - - - - - - {children} - - - ); -} - -function PackagesFilterSection({ - packages, - visiblePackages, - onHide, - onShow, - onFocus, - search, -}: { - visiblePackages: Package[]; - packages: Package[]; - onHide: (packageName: string) => void; - onShow: (packageName: string) => void; - onFocus: (packageName: string) => void; - search: string; -}) { - const getPlaceholder = () => { - if (search) { - return No matching packages; - } - - return ( - - -
-
- -
-
- - Create your first package - - Start building your composable ecosystem of packages. - -
- - - -
- ); - }; - - return ( - <> -
-

Packages

-

- {visiblePackages.length} - of - {packages.length} -

-
- -
- - - - {packages.length > 0 - ? packages.map((package_) => { - const isPackageVisible = Boolean( - visiblePackages?.some( - (packageName) => packageName.name === package_.name, - ), - ); - - const IconForPackage = getIconForPackage(package_.type); - - return ( -
-
- -

- {package_.name} -

-
- -
- onHide(package_.name)} - onShow={() => onShow(package_.name)} - /> - onFocus(package_.name)}> - Focus - -
-
- ); - }) - : getPlaceholder()} - -
-
- - ); -} - -function TagsFilterSection({ - tagData, - visiblePackages, - onHide, - onFocus, - onShow, - search, -}: { - visiblePackages?: Package[]; - onHide: (tag: string) => void; - onShow: (tag: string) => void; - onFocus: (tag: string) => void; - tagData: TagsData[]; - search: string; -}) { - const allTags: string[] = useMemo(() => { - if (tagData.length === 0) { - return []; - } - - const uniqueTags = [ - ...new Set( - tagData - ?.map((data) => data.tags) - .flat() - .filter(Boolean), - ), - ]; - - return uniqueTags.sort((a, b) => a.localeCompare(b)); - }, [tagData]); - - const visibleTagCount = useMemo(() => { - const visibleTags = new Set(); - for (const package_ of visiblePackages || []) { - for (const data of tagData) { - if (data.packageName === package_.name) { - for (const tag of data.tags) { - if (allTags.includes(tag)) { - visibleTags.add(tag); - } - } - } - } - } - return visibleTags.size; - }, [visiblePackages, tagData, allTags]); - - const getPlaceholder = () => { - if (search) { - return No matching tags; - } - - return ( - - -
-
- -
-
- - Get started with tags - - Add tags to a package to enforce dependency constraints and - categorize packages in your ecosystem. - -
- - - -
- ); - }; - - return ( - <> -
-

Tags

-

- {visibleTagCount} - of - {allTags.length} -

-
- - - {allTags.length > 0 - ? allTags.map((tag) => { - const isTagVisible = Boolean( - visiblePackages?.some((package_) => { - const tagsForPackage = tagData.find( - (data) => data.packageName === package_.name, - ); - - if (tagsForPackage) { - return tagsForPackage.tags.includes(tag); - } - - return false; - }), - ); - - return ( -
-
-
- - {tag} - -
-
- -
- onShow(tag)} - onHide={() => onHide(tag)} - /> - onFocus(tag)}> - Focus - -
-
- ); - }) - : getPlaceholder()} - -
- - ); -} - -function CodeownersFilterSection({ - ownerData, - visiblePackages, - onHide, - onShow, - onFocus, - search, -}: { - search: string; - ownerData: CodeownersData[]; - visiblePackages?: Package[]; - onHide: (team: string) => void; - onShow: (team: string) => void; - onFocus: (team: string) => void; -}) { - const allOwners: string[] = useMemo(() => { - if (ownerData.length === 0) { - return []; - } - - const uniqueOwners = [ - ...new Set( - ownerData - ?.map((data) => data.codeowners) - .flat() - .filter(Boolean), - ), - ]; - - return uniqueOwners.sort((a, b) => a.localeCompare(b)); - }, [ownerData]); - - const visibleOwners = useMemo(() => { - const visibleOwners = new Set(); - for (const package_ of visiblePackages || []) { - for (const data of ownerData) { - if (data.packageName === package_.name) { - for (const owner of data.codeowners) { - if (allOwners.includes(owner)) { - visibleOwners.add(owner); - } - } - } - } - } - return visibleOwners.size; - }, [visiblePackages, ownerData, allOwners]); - - const getPlaceholder = () => { - if (search) { - return No matching codeowners; - } - - return ( - - -
-
- -
-
- - Assign ownership - - Create a CODEOWNERS file to - assign ownership of packages in your project - -
- - - -
- ); - }; - - return ( - <> -
-

Codeowners

-

- {visibleOwners} - of - {allOwners.length} -

-
- - - {allOwners.length > 0 - ? allOwners.map((owner) => { - const isTeamVisible = Boolean( - visiblePackages?.some((package_) => { - const ownersForPackage = ownerData.find( - (data) => data.packageName === package_.name, - ); - - if (ownersForPackage) { - return ownersForPackage.codeowners.includes(owner); - } - - return false; - }), - ); - - return ( -
-
- - {owner} - -
- -
-
- onShow(owner)} - onHide={() => onHide(owner)} - /> -
-
- onFocus(owner)}> - Focus - -
-
-
- ); - }) - : getPlaceholder()} - -
- - ); -} - -function ResizeBar() { - return ( - -
- - ); -} - -export function GraphFilterSidebar({ - packages, - tagsData, - codeownersData, - defaultLayout, - initialSearch = '', -}: { - packages: Package[]; - tagsData: TagsData[]; - codeownersData: CodeownersData[]; - defaultLayout?: [number, number, number]; - initialSearch?: string; -}) { - const interactions = useInteractions(); - const [packagesQuery] = usePackagesQuery(); - - const [search, setSearch] = useState(initialSearch); - - const visiblePackages = packagesQuery - ? packages.filter((pkg) => packagesQuery.includes(pkg.name)) - : packages; - - const filteredOwners = search - ? codeownersData.filter((data) => - data.codeowners.some((codeowner) => codeowner.includes(search)), - ) - : codeownersData; - - const filteredTags = search - ? tagsData.filter((data) => data.tags.some((tag) => tag.includes(search))) - : tagsData; - - const filteredPackages = search - ? packages.filter((package_) => package_.name.includes(search)) - : packages; - - const noMatchingItems = - filteredOwners.length === 0 && - filteredTags.length === 0 && - filteredPackages.length === 0; - - return ( -
-
-
-
- - -
- setSearch(event.target.value)} - /> - - {noMatchingItems && search ? ( -
- No matches found -
- ) : ( - { - setCookie(COOKIE_FILTER_SIDEBAR, sizes); - }} - > - - interactions.focus([packageName])} - onHide={(packageName) => interactions.hide([packageName])} - onShow={(packageName) => interactions.show([packageName])} - search={search} - /> - - - - { - const packageNames = tagsData - .filter((data) => data.tags.includes(tag)) - .map((data) => data.packageName); - - interactions.focus(packageNames); - }} - onHide={(tag) => { - const packageNames = tagsData - .filter((data) => data.tags.includes(tag)) - .map((data) => data.packageName); - - interactions.hide(packageNames); - }} - onShow={(tag) => { - const packageNames = tagsData - .filter((data) => data.tags.includes(tag)) - .map((data) => data.packageName); - - interactions.show(packageNames); - }} - search={search} - /> - - - - { - const packageNames = codeownersData - .filter((data) => data.codeowners.includes(codeowner)) - .map((pkg) => pkg.packageName); - - interactions.focus(packageNames); - }} - onHide={(codeowner) => { - const packageNames = codeownersData - .filter((data) => data.codeowners.includes(codeowner)) - .map((pkg) => pkg.packageName); - - interactions.hide(packageNames); - }} - onShow={(codeowner) => { - const packageNames = codeownersData - .filter((data) => data.codeowners.includes(codeowner)) - .map((pkg) => pkg.packageName); - - interactions.show(packageNames); - }} - search={search} - /> - - - )} -
-
-
- ); -} diff --git a/packages/feature-graph/src/components/graph-layout.tsx b/packages/feature-graph/src/components/graph-layout.tsx deleted file mode 100644 index 7c5cdaf5..00000000 --- a/packages/feature-graph/src/components/graph-layout.tsx +++ /dev/null @@ -1,247 +0,0 @@ -'use client'; -import { cn } from '@commonalityco/ui-design-system/cn'; -import { - ImperativePanelHandle, - Panel, - PanelGroup, - PanelResizeHandle, -} from 'react-resizable-panels'; -import { setCookie } from 'cookies-next'; -import { COOKIE_GRAPH_LAYOUT } from '../constants/cookie-names'; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from '@commonalityco/ui-design-system'; - -import React, { useRef, useState } from 'react'; - -const CollapseButton = ({ - className, - onClick, - openDirection, - open, -}: { - className?: string; - onClick: () => void; - open: boolean; - openDirection?: 'left' | 'right'; -}) => { - return ( - -
-
-
-
- - ); -}; - -export function GraphLayoutRoot({ - children, - className, -}: { - children?: React.ReactNode; - className?: string; -}) { - return ( - { - setCookie(COOKIE_GRAPH_LAYOUT, sizes); - }} - direction="horizontal" - className={cn( - 'relative grid h-full max-h-screen min-h-0 w-full grid-cols-1 items-stretch overflow-hidden md:grid-cols-[auto_1fr]', - className, - )} - > - {children} - - ); -} - -export function GraphLayoutLeftSidebar({ - children, - className, - defaultSize, -}: { - children?: React.ReactNode; - className?: string; - defaultSize: number; -}) { - const [collapsed, setCollapsed] = useState(!defaultSize); - const panel = useRef(null); - - return ( - <> - { - setCollapsed(collapse); - }} - id="left-sidebar" - order={1} - defaultSize={defaultSize} - minSize={20} - className={cn( - 'relative z-20 hidden h-full shrink-0 grow-0 md:block', - className, - )} - > -
{children}
-
-
- -
- - - - { - if (collapsed) { - panel.current?.expand(); - } else { - panel.current?.collapse(); - } - setCollapsed(!collapsed); - }} - /> - - - {collapsed ? 'Show filters' : 'Hide filters'} - - - -
- - ); -} - -export function GraphLayoutRightSidebar({ - children, - className, - defaultSize, -}: { - children?: React.ReactNode; - className?: string; - defaultSize: number; -}) { - const panel = useRef(null); - const [collapsed, setCollapsed] = useState(!defaultSize); - - return ( - <> -
- -
- - - - { - if (collapsed) { - panel.current?.expand(); - setCollapsed(false); - } else { - panel.current?.collapse(); - setCollapsed(true); - } - }} - /> - - - {collapsed ? 'Show context' : 'Hide context'} - - - -
- { - setCollapsed(collapse); - }} - ref={panel} - id="context" - collapsible - order={3} - defaultSize={defaultSize} - minSize={20} - className={cn( - 'relative z-20 hidden h-full shrink-0 grow-0 overflow-visible md:block', - className, - )} - > -
{children}
-
- - ); -} - -export function GraphLayoutMain({ - children, - className, - defaultSize, -}: { - children?: React.ReactNode; - className?: string; - defaultSize: number; -}) { - return ( - -
- {children} -
-
- ); -} diff --git a/packages/feature-graph/src/components/graph-loading.tsx b/packages/feature-graph/src/components/graph-loading.tsx deleted file mode 100644 index 4e8bcfa1..00000000 --- a/packages/feature-graph/src/components/graph-loading.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { cn } from '@commonalityco/ui-design-system'; -import { Loader2 } from 'lucide-react'; - -export function GraphLoading() { - return ( -
- -
- ); -} diff --git a/packages/feature-graph/src/components/graph.tsx b/packages/feature-graph/src/components/graph.tsx deleted file mode 100644 index cf9ce24e..00000000 --- a/packages/feature-graph/src/components/graph.tsx +++ /dev/null @@ -1,253 +0,0 @@ -'use client'; -import { GradientFade } from '@commonalityco/ui-core'; -import { - Background, - BackgroundVariant, - ConnectionLineType, - Edge, - MiniMap, - Node, - OnSelectionChangeParams, - ReactFlow, - getConnectedEdges, - getIncomers, - getOutgoers, - useEdgesState, - useNodesState, -} from '@xyflow/react'; -import React, { useCallback } from 'react'; -import { PackageNode } from './package-node'; -import { DependencyEdge } from './dependency-edge'; -import { useSetAtom } from 'jotai'; -import { - selectedDependenciesAtom, - selectedPackagesAtom, -} from '../atoms/graph-atoms'; -import { Dependency, Package } from '@commonalityco/types'; - -const nodeTypes = { - package: PackageNode, -}; - -const edgeTypes = { - dependency: DependencyEdge, -}; - -export const Graph = ({ - dependencies, - packages, - nodes, - edges, - theme, -}: { - dependencies: Dependency[]; - packages: Package[]; - nodes: Node[]; - edges: Edge[]; - theme: 'light' | 'dark'; -}) => { - const [controlledNodes, setNodes, onNodesChange] = useNodesState(nodes); - const [controlledEdges, setEdges, onEdgesChange] = useEdgesState(edges); - - const setSelectedPackages = useSetAtom(selectedPackagesAtom); - const setSelectedDependencies = useSetAtom(selectedDependenciesAtom); - - const onSelectionChange = useCallback( - ({ nodes, edges }: OnSelectionChangeParams) => { - const selectedPackages = nodes - .map((node) => packages.find((pkg) => pkg.name === node.id)) - .filter(Boolean) as Package[]; - - const selectedDependencies = edges - .map((edge) => { - return dependencies.find( - (dep) => - dep.source === edge.source && - dep.target === edge.target && - dep.type === (edge.data?.dependency as Dependency)?.type, - ); - }) - .filter(Boolean) as Dependency[]; - - setSelectedPackages(selectedPackages); - setSelectedDependencies(selectedDependencies); - }, - [setSelectedPackages, setSelectedDependencies, packages, dependencies], - ); - - const onNodeMouseLeave = useCallback( - (_event: React.MouseEvent, _node: Node) => { - setNodes((currentNodes) => { - return currentNodes.map((currentNode) => { - return { - ...currentNode, - muted: false, - }; - }); - }); - - setEdges((currentEdges) => - currentEdges.map((currentEdge) => { - if (!currentEdge.data) return currentEdge; - - return { - ...currentEdge, - data: { - ...currentEdge.data, - active: false, - muted: false, - }, - }; - }), - ); - }, - [edges, setNodes, setEdges], - ); - - const onNodeMouseEnter = useCallback( - (_event: React.MouseEvent, node: Node) => { - const connectedEdges = getConnectedEdges([node], edges); - const outgoers = getOutgoers(node, nodes, edges); - const incomers = getIncomers(node, nodes, edges); - const neighbors = [node, ...outgoers, ...incomers]; - - setNodes((currentNodes) => { - return currentNodes.map((currentNode) => { - return currentNode.id === node.id - ? { - ...currentNode, - muted: !neighbors.some((neighbor) => neighbor.id === node.id), - } - : currentNode; - }); - }); - - setEdges((currentEdges) => - currentEdges.map((currentEdge) => { - if (!currentEdge.data) return currentEdge; - - const isActive = connectedEdges.some( - (edge) => edge.id === currentEdge.id, - ); - - return { - ...currentEdge, - data: { - ...currentEdge.data, - active: isActive, - muted: !isActive, - }, - }; - }), - ); - }, - [edges, nodes], - ); - - const onEdgeMouseLeave = useCallback( - (_event: React.MouseEvent, edge: Edge) => { - setEdges((currentEdges) => - currentEdges.map((currentEdge: Edge) => { - if (!currentEdge.data) { - return currentEdge; - } else if (currentEdge.id === edge.id) { - return { - ...currentEdge, - data: { - ...currentEdge.data, - active: false, - }, - }; - } else { - return currentEdge; - } - }), - ); - }, - [], - ); - - const onEdgeMouseEnter = useCallback( - (_event: React.MouseEvent, edge: Edge) => { - setEdges((currentEdges) => - currentEdges.map((currentEdge) => { - if (!currentEdge.data) return currentEdge; - - return currentEdge.id === edge.id - ? { - ...currentEdge, - data: { - ...currentEdge.data, - active: true, - }, - } - : currentEdge; - }), - ); - }, - [], - ); - - const onEdgeClick = useCallback( - (event: React.MouseEvent, edge: Edge) => { - const depdendency = dependencies.find( - (dep) => dep.source === edge.source && dep.target === edge.target, - ); - - if (!depdendency) return; - }, - [dependencies], - ); - - return ( -
-
- - - - - - - - - -
-
- ); -}; diff --git a/packages/feature-graph/src/components/package-context.tsx b/packages/feature-graph/src/components/package-context.tsx deleted file mode 100644 index c82d6bdf..00000000 --- a/packages/feature-graph/src/components/package-context.tsx +++ /dev/null @@ -1,428 +0,0 @@ -'use client'; -import { - Badge, - Card, - CardDescription, - CardFooter, - CardHeader, - CardTitle, - Button, - Label, - ScrollArea, - Separator, - cn, - Table, - TableHeader, - TableRow, - TableHead, - TableBody, - TableCell, -} from '@commonalityco/ui-design-system'; -import { Status } from '@commonalityco/utils-core'; -import { GradientFade, getIconForPackage } from '@commonalityco/ui-core'; -import { CodeownersData, Package, TagsData } from '@commonalityco/types'; -import { ConformanceResult } from '@commonalityco/utils-conformance'; -import { getConformanceScore } from '@commonalityco/utils-conformance/get-conformance-score'; -import { - ChevronDown, - ChevronUp, - ExternalLink, - PackageCheck, -} from 'lucide-react'; -import { ResponsivePie } from '@nivo/pie'; - -import { - ColumnDef, - ColumnFiltersState, - SortingState, - VisibilityState, - flexRender, - getCoreRowModel, - getFilteredRowModel, - getPaginationRowModel, - getSortedRowModel, - useReactTable, -} from '@tanstack/react-table'; -import { useState } from 'react'; - -const StatusSortValue = { - [Status.Pass]: 2, - [Status.Warn]: 1, - [Status.Fail]: 0, -}; - -const columns: ColumnDef[] = [ - { - accessorKey: 'status', - maxSize: 100, - header: ({ column }) => { - const isSorted = column.getIsSorted(); - - return ( - - ); - }, - cell: ({ row }) => { - const status: Status = row.getValue('status'); - - return ( -
- {status} -
- ); - }, - sortingFn: (rowA, rowB, columnId) => { - const statusA = rowA.original.status; - const statusB = rowB.original.status; - const statusAValue = StatusSortValue[statusA]; - const statusBValue = StatusSortValue[statusB]; - - return statusAValue - statusBValue; - }, - }, - { - id: 'selector', - header: 'Selector', - accessorFn: (row) => row.filter, - cell: ({ row }) => { - const selector: string = row.getValue('selector'); - - if (selector !== '*') { - return {selector}; - } - - return

All packages

; - }, - }, - { - id: 'message', - header: 'Message', - accessorFn: (row) => row.message.message, - }, -]; - -export function ConformanceTable({ data }: { data: ConformanceResult[] }) { - const [sorting, setSorting] = useState([]); - const [columnFilters, setColumnFilters] = useState([]); - const [columnVisibility, setColumnVisibility] = useState({}); - const [rowSelection, setRowSelection] = useState({}); - - const table = useReactTable({ - data, - columns, - onSortingChange: setSorting, - onColumnFiltersChange: setColumnFilters, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - getSortedRowModel: getSortedRowModel(), - getFilteredRowModel: getFilteredRowModel(), - onColumnVisibilityChange: setColumnVisibility, - onRowSelectionChange: setRowSelection, - - state: { - sorting, - columnFilters, - columnVisibility, - rowSelection, - }, - }); - - return ( - <> -
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? undefined - : flexRender( - header.column.columnDef.header, - header.getContext(), - )} - - ); - })} - - ))} - - - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender( - cell.column.columnDef.cell, - cell.getContext(), - )} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
-
-
- - -
-
- - ); -} - -export function PackageContext({ - pkg, - checkResults, - codeownersData, - tagsData, - headerContent, -}: { - pkg: Package; - checkResults: ConformanceResult[]; - codeownersData: CodeownersData[]; - tagsData: TagsData[]; - headerContent?: React.ReactNode; -}) { - const packageResults = checkResults.filter( - (result) => result.package.name === pkg.name, - ); - const tags = tagsData.find((tag) => tag.packageName === pkg.name)?.tags ?? []; - const Icon = getIconForPackage(pkg.type); - - const codeowners = - codeownersData.find((data) => data.packageName === pkg.name)?.codeowners ?? - []; - - const passCount = packageResults.filter( - (result) => result.status === Status.Pass, - ).length; - const warnCount = packageResults.filter( - (result) => result.status === Status.Warn, - ).length; - const failCount = packageResults.filter( - (result) => result.status === Status.Fail, - ).length; - - const isTotalCount = - passCount === packageResults.length || - warnCount === packageResults.length || - failCount === packageResults.length; - return ( -
-
- - {headerContent} -
-

{pkg.name}

- - -
- - {pkg.description ? ( -

{pkg.description}

- ) : ( -

No description

- )} - -

{pkg.version}

- -
- {codeowners.length > 0 ? ( - codeowners.map((codeowner) => ( - - {codeowner} - - )) - ) : ( - No codeowners - )} -
- -
- {tags.map((tag) => ( - - {tag} - - ))} -
-
- - - -
- -
- -

- {packageResults.length > 0 - ? `${packageResults.length} checks` - : 'No checks configured'} -

-
-
-

{`${getConformanceScore(packageResults)}%`}

-
- -
-
-
- - -

0, - 'text-muted-foreground': warnCount === 0, - })} - > - {warnCount} -

-
- - -

0, - 'text-muted-foreground': failCount === 0, - })} - > - {failCount} -

-
-
- -
-
- {packageResults.length === 0 && ( - - -
-
- -
-
- - Codify your best practices - - Scale a consistently amazing developer experience with dynamic - conformance checks that are run like tests and shared like lint - rules. - -
- - - -
- )} - -
-
- ); -} diff --git a/packages/feature-graph/src/components/package-node.tsx b/packages/feature-graph/src/components/package-node.tsx deleted file mode 100644 index 4a96fd7f..00000000 --- a/packages/feature-graph/src/components/package-node.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { Handle, Node, type NodeProps } from '@xyflow/react'; -import { Position } from '@xyflow/system'; -import { PackageNodeData } from '../utilities/get-nodes'; -import { getIconForPackage } from '@commonalityco/ui-core'; -import { cn } from '@commonalityco/ui-design-system'; -import { DependencyType } from '@commonalityco/utils-core'; - -export function PackageNode({ - isConnectable, - data, - width, - height, - selected, - ...rest -}: NodeProps>) { - const Icon = getIconForPackage(data.package.type); - - return ( -
-
- {data.input ? ( - - ) : undefined} - -
-

- {data.package.name} -

- -
- - {data.output ? ( - <> - - - - - ) : undefined} -
-
- ); -} diff --git a/packages/feature-graph/src/components/package-toolbar.tsx b/packages/feature-graph/src/components/package-toolbar.tsx deleted file mode 100644 index 537c98fb..00000000 --- a/packages/feature-graph/src/components/package-toolbar.tsx +++ /dev/null @@ -1,82 +0,0 @@ -'use client'; -import { - Button, - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from '@commonalityco/ui-design-system'; -import { EyeOff, Focus } from 'lucide-react'; -import { NodeToolbar } from '@xyflow/react'; -import { Position } from '@xyflow/system'; -import { useAtom } from 'jotai'; -import { selectedPackagesAtom } from '../atoms/graph-atoms'; -import { useInteractions } from '../context/interaction-context'; - -export function ToolbarButton({ - children, - text, - onClick, -}: { - children: React.ReactNode; - text: string; - onClick?: () => void; -}) { - return ( - - - - - - - {text} - - - - ); -} - -export function PackageToolbar() { - const [selectedPackages, setSelectedPackages] = useAtom(selectedPackagesAtom); - const interactions = useInteractions(); - - const isVisible = Number(selectedPackages?.length) > 0; - const selectedNodeIds = selectedPackages.map((pkg) => pkg.name); - - return ( - pkg.name)} - position={Position.Bottom} - className="bg-primary light flex origin-top gap-1 rounded-lg p-1" - > - { - interactions.focus(selectedNodeIds); - setSelectedPackages([]); - }} - > - - - - { - interactions.hide(selectedNodeIds); - setSelectedPackages([]); - }} - > - - - - ); -} diff --git a/packages/feature-graph/src/components/project-context.tsx b/packages/feature-graph/src/components/project-context.tsx deleted file mode 100644 index 8da5cebf..00000000 --- a/packages/feature-graph/src/components/project-context.tsx +++ /dev/null @@ -1,388 +0,0 @@ -'use client'; -import { - Card, - Label, - Table, - TableHeader, - TableRow, - TableHead, - TableBody, - TableCell, - Button, - cn, - Badge, - Separator, - ScrollArea, -} from '@commonalityco/ui-design-system'; -import { ConformanceResult } from '@commonalityco/utils-conformance'; -import { PackageManager, Status } from '@commonalityco/utils-core'; -import { ResponsivePie } from '@nivo/pie'; -import { - BunLogo, - GradientFade, - NpmLogo, - PnpmLogo, - YarnLogo, -} from '@commonalityco/ui-core'; -import { - ColumnDef, - ColumnFiltersState, - SortingState, - VisibilityState, - flexRender, - getCoreRowModel, - getFilteredRowModel, - getPaginationRowModel, - getSortedRowModel, - useReactTable, -} from '@tanstack/react-table'; -import { ChevronDown, ChevronUp } from 'lucide-react'; -import { useState } from 'react'; - -const StatusSortValue = { - [Status.Pass]: 2, - [Status.Warn]: 1, - [Status.Fail]: 0, -}; - -const IconByPackageManager = { - [PackageManager.NPM]: NpmLogo, - [PackageManager.PNPM]: PnpmLogo, - [PackageManager.YARN]: YarnLogo, - [PackageManager.BUN]: BunLogo, -}; - -const columns: ColumnDef[] = [ - { - accessorKey: 'status', - maxSize: 100, - header: ({ column }) => { - const isSorted = column.getIsSorted(); - - return ( - - ); - }, - cell: ({ row }) => { - const status: Status = row.getValue('status'); - - return ( -
- {status} -
- ); - }, - sortingFn: (rowA, rowB) => { - const statusA = rowA.original.status; - const statusB = rowB.original.status; - const statusAValue = StatusSortValue[statusA]; - const statusBValue = StatusSortValue[statusB]; - - return statusAValue - statusBValue; - }, - }, - { - id: 'selector', - header: 'Selector', - accessorFn: (row) => row.filter, - cell: ({ row }) => { - const selector: string = row.getValue('selector'); - - if (selector !== '*') { - return ( - - {selector} - - ); - } - - return

All packages

; - }, - }, - { - id: 'message', - accessorFn: (row) => row.message.message, - header: 'Message', - cell: ({ row }) => ( -
-

- {row.original.package?.name} -

-

{row.getValue('message')}

-
- ), - }, -]; - -function ProjectConformanceTable({ data }: { data: ConformanceResult[] }) { - const [sorting, setSorting] = useState([]); - const [columnFilters, setColumnFilters] = useState([]); - const [columnVisibility, setColumnVisibility] = useState({}); - const [rowSelection, setRowSelection] = useState({}); - - const table = useReactTable({ - data, - columns, - onSortingChange: setSorting, - onColumnFiltersChange: setColumnFilters, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - getSortedRowModel: getSortedRowModel(), - getFilteredRowModel: getFilteredRowModel(), - onColumnVisibilityChange: setColumnVisibility, - onRowSelectionChange: setRowSelection, - state: { - sorting, - columnFilters, - columnVisibility, - rowSelection, - }, - }); - - return ( -
-
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? undefined - : flexRender( - header.column.columnDef.header, - header.getContext(), - )} - - ); - })} - - ))} - - - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender( - cell.column.columnDef.cell, - cell.getContext(), - )} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
-
-
- - -
-
-
- ); -} - -export function ProjectContext({ - packageCount, - projectName, - packageManager = PackageManager.NPM, - checkCount, - score, - checkPassCount, - checkWarnCount, - checkFailCount, - checkResults, - constraintPassCount, - constraintFailCount, -}: { - packageManager: PackageManager; - projectName: string; - packageCount: number; - checkCount: number; - score: number; - constraintPassCount: number; - constraintFailCount: number; - checkFailCount: number; - checkWarnCount: number; - checkPassCount: number; - checkResults: ConformanceResult[]; -}) { - const PackageManagerIcon = IconByPackageManager[packageManager]; - const total = checkPassCount + checkWarnCount + checkFailCount; - const isTotalCount = - checkPassCount === total || - checkWarnCount === total || - checkFailCount === total; - - return ( -
- -

{projectName}

- - - -
- - -

0, - 'text-muted-foreground': constraintPassCount === 0, - })} - > - {constraintPassCount} -

-
- - -

0, - 'text-muted-foreground': constraintFailCount === 0, - })} - > - {constraintFailCount} -

-
-
- - -
- -
- -

- {checkCount > 0 - ? `${checkCount} checks` - : 'No checks configured'} -

-
-
-

{`${score}%`}

-
- -
-
-
- - - -

0, - 'text-muted-foreground': checkWarnCount === 0, - })} - > - {checkWarnCount} -

-
- - -

0, - 'text-muted-foreground': checkFailCount === 0, - })} - > - {checkFailCount} -

-
- - -
- -
-
- ); -} diff --git a/packages/feature-graph/src/constants/cookie-names.ts b/packages/feature-graph/src/constants/cookie-names.ts deleted file mode 100644 index a9eaf417..00000000 --- a/packages/feature-graph/src/constants/cookie-names.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const COOKIE_GRAPH_LAYOUT = 'commonality:graph-layout'; - -export const COOKIE_FILTER_SIDEBAR = 'commonality:filter-sidebar'; diff --git a/packages/feature-graph/src/context/graph-providers.tsx b/packages/feature-graph/src/context/graph-providers.tsx deleted file mode 100644 index 846bf507..00000000 --- a/packages/feature-graph/src/context/graph-providers.tsx +++ /dev/null @@ -1,30 +0,0 @@ -'use client'; -import { Edge, Node, ReactFlowProvider } from '@xyflow/react'; -import { GraphInteractionProvider } from './interaction-context'; - -export function GraphProviders({ - children, - allNodes, - allEdges, - defaultNodes, - defaultEdges, -}: { - children: React.ReactNode; - allNodes: Node[]; - allEdges: Edge[]; - defaultNodes: Node[]; - defaultEdges: Edge[]; -}) { - return ( - - - {children} - - - ); -} diff --git a/packages/feature-graph/src/context/interaction-context.tsx b/packages/feature-graph/src/context/interaction-context.tsx deleted file mode 100644 index 2a3c3f8d..00000000 --- a/packages/feature-graph/src/context/interaction-context.tsx +++ /dev/null @@ -1,89 +0,0 @@ -'use client'; -import { createContext, useContext, ReactNode } from 'react'; -import { usePackagesQuery } from '../query/query-hooks'; -import { Node, Edge, getIncomers, getOutgoers } from '@xyflow/react'; - -interface InteractionContextType { - hideAll: () => void; - showAll: () => void; - show: (packageNames: string[]) => void; - focus: (packageNames: string[]) => void; - hide: (packageNames: string[]) => void; -} - -const GraphInteractionContext = createContext< - InteractionContextType | undefined ->(undefined); - -export function useInteractions() { - const context = useContext(GraphInteractionContext); - - if (context === undefined) { - throw new Error( - 'useInteractions must be used within a GraphInteractionProvider', - ); - } - - return context; -} - -interface GraphInteractionProviderProps { - children: ReactNode; - allNodes: Node[]; - allEdges: Edge[]; -} - -export const GraphInteractionProvider = ({ - children, - allNodes, - allEdges, -}: GraphInteractionProviderProps) => { - const [packagesQuery, setPackagesQuery] = usePackagesQuery(); - const visibleNodes = packagesQuery - ? allNodes.filter((node) => packagesQuery.includes(node.id)) - : allNodes; - - const interactions: InteractionContextType = { - hideAll: () => setPackagesQuery([]), - showAll: () => setPackagesQuery(allNodes.map((node) => node.id)), - show: (packageNames: string[]) => { - const newNodes = allNodes.filter((node) => - packageNames.includes(node.id), - ); - - setPackagesQuery([...visibleNodes, ...newNodes].map((node) => node.id)); - }, - focus: (packageNames: string[]) => { - const selectedNodes = allNodes.filter((node) => - packageNames.includes(node.id), - ); - - if (selectedNodes.length === 0) return; - - const incomers = selectedNodes.flatMap((selectedPkg) => - getIncomers(selectedPkg, allNodes, allEdges), - ); - - const outgoers = selectedNodes.flatMap((selectedPkg) => - getOutgoers(selectedPkg, allNodes, allEdges), - ); - - setPackagesQuery( - [...selectedNodes, ...incomers, ...outgoers].map((node) => node.id), - ); - }, - hide: (packageNames: string[]) => { - const newNodes = visibleNodes.filter( - (node) => !packageNames.includes(node.id), - ); - - setPackagesQuery(newNodes.map((node) => node.id)); - }, - }; - - return ( - - {children} - - ); -}; diff --git a/packages/feature-graph/src/images/next-logo.svg b/packages/feature-graph/src/images/next-logo.svg deleted file mode 100644 index fb82b198..00000000 --- a/packages/feature-graph/src/images/next-logo.svg +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/feature-graph/src/images/node-logo.svg b/packages/feature-graph/src/images/node-logo.svg deleted file mode 100644 index ec377f45..00000000 --- a/packages/feature-graph/src/images/node-logo.svg +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/feature-graph/src/images/react-logo.svg b/packages/feature-graph/src/images/react-logo.svg deleted file mode 100644 index 4a4aae16..00000000 --- a/packages/feature-graph/src/images/react-logo.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/packages/feature-graph/src/images/storybook-logo.svg b/packages/feature-graph/src/images/storybook-logo.svg deleted file mode 100644 index 8da9af9c..00000000 --- a/packages/feature-graph/src/images/storybook-logo.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/feature-graph/src/index.ts b/packages/feature-graph/src/index.ts deleted file mode 100644 index 0e8895c4..00000000 --- a/packages/feature-graph/src/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -export * from './query/query-parsers'; -export * from './query/query-hooks'; - -export * from './components/package-toolbar'; -export * from './components/graph-control-bar'; -export * from './components/graph'; -export * from './components/graph-loading'; -export * from './components/graph-filter-sidebar'; -export * from './components/graph-layout'; -export * from './components/graph-empty'; -export * from './components/graph-context-sidebar'; - -export * from './components/dependency-context'; -export * from './components/package-context'; -export * from './components/project-context'; - -export * from './utilities/types'; -export * from './utilities/get-elements-with-layout'; -export * from './utilities/get-nodes'; -export * from './utilities/get-edges'; - -export * from './context/graph-providers'; - -export * from './constants/cookie-names'; - -export * from './atoms/graph-atoms'; diff --git a/packages/feature-graph/src/query/query-hooks.ts b/packages/feature-graph/src/query/query-hooks.ts deleted file mode 100644 index 863d89f8..00000000 --- a/packages/feature-graph/src/query/query-hooks.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { useQueryState } from 'nuqs'; -import { - colorParser, - directionParser, - hideFiltersParser, - packagesParser, -} from './query-parsers'; -import { GraphDirection } from '../utilities/types'; -import { DependencyType } from '@commonalityco/utils-core'; - -export const useDirectionQuery = () => { - return useQueryState( - 'direction', - directionParser - .withDefault(GraphDirection.LeftToRight) - .withOptions({ shallow: false }), - ); -}; - -export const useColorQuery = () => { - return useQueryState( - 'color', - colorParser - .withDefault([DependencyType.PRODUCTION]) - .withOptions({ shallow: false }), - ); -}; - -export const usePackagesQuery = () => { - return useQueryState( - 'packages', - packagesParser.withOptions({ shallow: false }), - ); -}; - -export const useHideFiltersQuery = () => { - return useQueryState( - 'hideFilters', - hideFiltersParser.withOptions({ shallow: false }), - ); -}; - -export const useHideContextQuery = () => { - return useQueryState( - 'hideContext', - hideFiltersParser.withOptions({ shallow: false }), - ); -}; diff --git a/packages/feature-graph/src/query/query-parsers.ts b/packages/feature-graph/src/query/query-parsers.ts deleted file mode 100644 index 9014c73e..00000000 --- a/packages/feature-graph/src/query/query-parsers.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { - decompressFromEncodedURIComponent, - compressToEncodedURIComponent, -} from 'lz-string'; -import { GraphDirection } from '../utilities/types'; -import { DependencyType } from '@commonalityco/utils-core'; -import { - ParserBuilder, - createParser, - parseAsArrayOf, - parseAsBoolean, - parseAsStringEnum, -} from 'nuqs'; - -export const directionParser: ReturnType< - typeof parseAsStringEnum -> = parseAsStringEnum( - Object.values(GraphDirection), -).withDefault(GraphDirection.LeftToRight); - -export const colorParser: ReturnType> = - parseAsArrayOf( - parseAsStringEnum(Object.values(DependencyType)), - ).withDefault([DependencyType.PRODUCTION]); - -export const packagesParser: ParserBuilder = createParser({ - parse: (input) => JSON.parse(decompressFromEncodedURIComponent(input)), - serialize: (input) => compressToEncodedURIComponent(JSON.stringify(input)), -}); - -export const hideFiltersParser = parseAsBoolean.withDefault(false); -export const hideContextParser = parseAsBoolean.withDefault(false); diff --git a/packages/feature-graph/src/utilities/get-edges.ts b/packages/feature-graph/src/utilities/get-edges.ts deleted file mode 100644 index 65284a62..00000000 --- a/packages/feature-graph/src/utilities/get-edges.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { ConstraintResult, Dependency } from '@commonalityco/types'; -import { DependencyType } from '@commonalityco/utils-core'; -import { type Edge } from '@xyflow/react'; -import { MarkerType } from '@xyflow/system'; - -const edgeType = 'dependency'; - -export type DependencyEdgeData = { - dependency: Dependency; - results: ConstraintResult[]; - theme: 'light' | 'dark'; - active: boolean; - muted: boolean; - activeDependencyTypes: DependencyType[]; -}; - -export const getEdges = ({ - dependencies, - results = [], - theme, - activeDependencyTypes = [], -}: { - dependencies: Dependency[]; - results: ConstraintResult[]; - theme: 'light' | 'dark'; - activeDependencyTypes: DependencyType[]; -}): Edge[] => { - return dependencies.map((dependency) => { - return { - id: `${dependency.source}-${dependency.target}-${dependency.type}`, - source: dependency.source, - target: dependency.target, - sourceHandle: dependency.type, - data: { - results: results.filter((result) => - result.dependencyPath.some( - (depPath) => - depPath.source === dependency.source && - depPath.target === dependency.target && - depPath.type === dependency.type, - ), - ), - dependency, - theme, - active: false, - muted: false, - activeDependencyTypes, - }, - type: edgeType, - markerEnd: { - type: MarkerType.ArrowClosed, - width: 20, - height: 20, - }, - } satisfies Edge; - }); -}; diff --git a/packages/feature-graph/src/utilities/get-elements-with-layout.ts b/packages/feature-graph/src/utilities/get-elements-with-layout.ts deleted file mode 100644 index ea46ac38..00000000 --- a/packages/feature-graph/src/utilities/get-elements-with-layout.ts +++ /dev/null @@ -1,60 +0,0 @@ -import dagre from 'dagre'; -import { Edge, Node } from '@xyflow/react'; -import { Position } from '@xyflow/system'; -import { GraphDirection } from './types'; - -export const getElementsWithLayout = ({ - nodes, - edges, - direction = GraphDirection.TopToBottom, -}: { - nodes: Node[]; - edges: Edge[]; - direction?: GraphDirection; -}): { nodes: Node[]; edges: Edge[]; height?: number; width?: number } => { - const dagreGraph = new dagre.graphlib.Graph(); - dagreGraph.setDefaultEdgeLabel(() => ({})); - - const isHorizontal = direction === GraphDirection.LeftToRight; - - dagreGraph.setGraph({ - rankdir: direction, - nodesep: 50, - ranksep: 200, - }); - - for (const node of nodes) { - dagreGraph.setNode(node.id, { width: node.width, height: node.height }); - } - - for (const edge of edges) { - dagreGraph.setEdge(edge.source, edge.target); - } - - dagre.layout(dagreGraph); - - for (const node of nodes) { - const nodeWithPosition = dagreGraph.node(node.id); - node.targetPosition = isHorizontal ? Position.Left : Position.Top; - node.sourcePosition = isHorizontal ? Position.Right : Position.Bottom; - - // We are shifting the dagre node position (anchor=center center) to the top left - // so it matches the React Flow node anchor point (top left). - node.position = { - x: nodeWithPosition.x - (node.width ?? 250) / 2, - y: nodeWithPosition.y - (node.height ?? 100) / 2, - }; - - node; - continue; - } - - const graph = dagreGraph.graph(); - - return { - height: graph.height, - width: graph.width, - nodes, - edges, - }; -}; diff --git a/packages/feature-graph/src/utilities/get-nodes.ts b/packages/feature-graph/src/utilities/get-nodes.ts deleted file mode 100644 index 80f50e40..00000000 --- a/packages/feature-graph/src/utilities/get-nodes.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Dependency, Package, TagsData } from '@commonalityco/types'; -import { Node } from '@xyflow/react'; - -const position = { x: 0, y: 0 }; - -export type PackageNodeData = { - label: string; - package: Package; - output?: Dependency; - input?: Dependency; - tags: string[]; - muted: boolean; -}; - -export const getNodes = ({ - packages, - dependencies, - tagsData, -}: { - packages: Package[]; - dependencies: Dependency[]; - tagsData: TagsData[]; -}): Node[] => { - return packages.map((pkg) => { - const input = dependencies.find((dep) => dep.target === pkg.name); - const output = dependencies.find((dep) => dep.source === pkg.name); - - const tags = tagsData - .filter((data) => data.packageName === pkg.name) - .flatMap((data) => data.tags); - - return { - id: pkg.name, - type: 'package', - width: 400, - height: 68, - draggable: false, - data: { - label: pkg.name, - package: pkg, - input, - output, - tags, - muted: false, - }, - connectable: false, - position, - }; - }); -}; diff --git a/packages/feature-graph/src/utilities/types.ts b/packages/feature-graph/src/utilities/types.ts deleted file mode 100644 index e96354b4..00000000 --- a/packages/feature-graph/src/utilities/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type HandleDirection = 'TB' | 'LR' | 'RL' | 'BT'; - -export enum GraphDirection { - TopToBottom = 'TB', - LeftToRight = 'LR', -} diff --git a/packages/feature-graph/tailwind.config.js b/packages/feature-graph/tailwind.config.js deleted file mode 100644 index 9a5527c7..00000000 --- a/packages/feature-graph/tailwind.config.js +++ /dev/null @@ -1,7 +0,0 @@ -import baseConfig from '@commonalityco/config-tailwind'; - -/** @type {import('tailwindcss').Config} */ -export default { - ...baseConfig, - content: ['./src/**/*.{js,ts,jsx,tsx}'], -}; diff --git a/packages/feature-graph/test/setup.ts b/packages/feature-graph/test/setup.ts deleted file mode 100644 index e368482a..00000000 --- a/packages/feature-graph/test/setup.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { afterEach } from 'vitest'; -import { cleanup } from '@testing-library/react'; -import '@testing-library/jest-dom'; - -afterEach(() => { - cleanup(); -}); diff --git a/packages/feature-graph/tsconfig.json b/packages/feature-graph/tsconfig.json deleted file mode 100644 index e0882888..00000000 --- a/packages/feature-graph/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "@commonalityco/config-tsconfig/react.json", - "include": ["src/**/*.ts", "src/**/*.tsx"], - "compilerOptions": { - "outDir": "./dist", - "typeRoots": ["./node_modules/@types"], - "rootDir": "./src", - "skipLibCheck": true - } -} diff --git a/packages/feature-graph/vitest.config.ts b/packages/feature-graph/vitest.config.ts deleted file mode 100644 index c4b302dc..00000000 --- a/packages/feature-graph/vitest.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { defineConfig } from 'vitest/config'; - -export default defineConfig({ - test: { - globals: true, - environment: 'jsdom', - setupFiles: ['./test/setup.ts'], - }, -}); diff --git a/packages/types/package.json b/packages/types/package.json index 453b8d05..3667eb23 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -37,5 +37,8 @@ "type": "git", "url": "https://github.com/commonalityco/commonality", "directory": "packages/types" + }, + "dependencies": { + "zod": "^3.23.8" } } \ No newline at end of file diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index fde1c108..05768c78 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,8 +1,15 @@ import { DependencyType, AllPackagesWildcard, - PackageType, + BlockType, } from '@commonalityco/utils-core'; +import { z } from 'zod'; + +export const privacyEnum = z.enum(['PUBLIC', 'PRIVATE']); + +export const dependencyTypeEnum = z.enum(['PRODUCTION', 'DEVELOPMENT', 'PEER']); + +export const blockTypeEnum = z.enum(['REACT', 'NODE', 'NEXT']); export type Constraint = | { @@ -56,12 +63,30 @@ export type Tag = string; export type TagsData = { packageName: string; tags: Tag[] }; +const blockSchema = z.object({ + path: z.string(), + type: blockTypeEnum, + name: z.string(), + description: z.string().optional(), + version: z.string(), + churn: z.number(), + complexity: z.number(), + license: z.string().optional(), + privacy: privacyEnum, +}); + +export type Block = z.infer; + export type Package = { path: string; - type: PackageType; + type: BlockType; name: string; description?: string; version: string; + churn: number; + complexity: number; + license?: string; + privacy: z.infer; }; export type Workspace = { diff --git a/packages/ui-core/.eslintrc.json b/packages/ui-core/.eslintrc.json deleted file mode 100644 index 49a16ad6..00000000 --- a/packages/ui-core/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "root": true, - "extends": [ - "commonality" - ] -} \ No newline at end of file diff --git a/packages/ui-core/.npmignore b/packages/ui-core/.npmignore deleted file mode 100644 index 56affc6d..00000000 --- a/packages/ui-core/.npmignore +++ /dev/null @@ -1 +0,0 @@ -*.test.* \ No newline at end of file diff --git a/packages/ui-core/CHANGELOG.md b/packages/ui-core/CHANGELOG.md deleted file mode 100644 index e7c825d3..00000000 --- a/packages/ui-core/CHANGELOG.md +++ /dev/null @@ -1,169 +0,0 @@ -# @commonalityco/ui-core - -## 0.2.41 - -### Patch Changes - -- 7ba2c80: Make graph more responsive -- Updated dependencies [7ba2c80] - - @commonalityco/ui-design-system@0.2.41 - -## 0.2.40 - -### Patch Changes - -- 4f0f69c: Update dependency graph to use @xyflow/react -- Updated dependencies [4f0f69c] - - @commonalityco/ui-design-system@0.2.40 - - @commonalityco/utils-core@0.2.41 - -## 0.2.39 - -### Patch Changes - -- 0faea77: Fixes an issue where the repository field check was creating an incorrectly formatted repository field -- Updated dependencies [0faea77] - - @commonalityco/ui-design-system@0.2.39 - - @commonalityco/utils-core@0.2.37 - -## 0.2.38 - -### Patch Changes - -- 7e440ac: Moves edit configuration button to top level navigation - - @commonalityco/ui-design-system@0.2.37 - -## 0.2.37 - -### Patch Changes - -- 4661b6b: Display dependency constraints in searchable modal -- Updated dependencies [4661b6b] - - @commonalityco/ui-design-system@0.2.37 - -## 0.2.36 - -### Patch Changes - -- 3f1e821: Improve tag editing and constraints UX in Commonality Studio -- Updated dependencies [3f1e821] - - @commonalityco/ui-design-system@0.2.36 - -## 0.0.16 - -### Patch Changes - -- 4bd3547: Create granular packages -- Updated dependencies [4bd3547] - - @commonalityco/ui-design-system@0.0.14 - -## 0.0.15 - -### Patch Changes - -- ad4a813: Finalize Commonality Studio, checks, and constraints -- Updated dependencies [ad4a813] - - @commonalityco/ui-design-system@0.0.13 - - @commonalityco/types@0.0.15 - -## 0.0.14 - -### Patch Changes - -- 97987b9: fix bugs in package table - -## 0.0.13 - -### Patch Changes - -- e9a5bc2: Add table view to Studio -- Updated dependencies [e9a5bc2] - - @commonalityco/ui-design-system@0.0.12 - - @commonalityco/types@0.0.14 - -## 0.0.12 - -### Patch Changes - -- ffbc45c: Fixed graph color and reduced bundle size dramatically -- Updated dependencies [ffbc45c] - - @commonalityco/ui-design-system@0.0.11 - -## 0.0.11 - -### Patch Changes - -- 5b61b0e: Reduce bundle size -- Updated dependencies [5b61b0e] - - @commonalityco/ui-design-system@0.0.10 - -## 0.0.10 - -### Patch Changes - -- 91bfd71: Unify into commonality package -- Updated dependencies [91bfd71] - - @commonalityco/ui-design-system@0.0.9 - - @commonalityco/types@0.0.13 - -## 0.0.9 - -### Patch Changes - -- 26e1636: Publish foundational packages -- Updated dependencies [26e1636] - - @commonalityco/ui-design-system@0.0.8 - -## 0.0.8 - -### Patch Changes - -- ee3504f: Distribute studio /dist -- Updated dependencies [ee3504f] - - @commonalityco/ui-design-system@0.0.5 - - @commonalityco/types@0.0.12 - -## 0.0.7 - -### Patch Changes - -- 5fafb8f: use client for markdown - -## 0.0.6 - -### Patch Changes - -- dadeafb: Convert to ESM -- Updated dependencies [dadeafb] - - @commonalityco/types@0.0.11 - - @commonalityco/ui-design-system@0.0.4 - -## 0.0.5 - -### Patch Changes - -- 479b297: Fix range of peerDependencies - -## 0.0.4 - -### Patch Changes - -- fb47c73: update build output -- Updated dependencies [fb47c73] - - @commonalityco/types@0.0.10 - - @commonalityco/ui-design-system@0.0.3 - -## 0.0.3 - -### Patch Changes - -- d562884: Add zero state and feedback button - -## 0.0.2 - -### Patch Changes - -- da2c556: Initial release -- Updated dependencies [da2c556] - - @commonalityco/types@0.0.9 - - @commonalityco/ui-design-system@0.0.2 diff --git a/packages/ui-core/README.md b/packages/ui-core/README.md deleted file mode 100644 index 9324b87b..00000000 --- a/packages/ui-core/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# @commonalityco/ui-core -> Presentational components used to build Commonality applications -## Installation - -```sh -npm install @commonalityco/ui-core -``` \ No newline at end of file diff --git a/packages/ui-core/commonality.json b/packages/ui-core/commonality.json deleted file mode 100644 index 86b0c992..00000000 --- a/packages/ui-core/commonality.json +++ /dev/null @@ -1 +0,0 @@ -{"tags":["ui"]} diff --git a/packages/ui-core/package.json b/packages/ui-core/package.json deleted file mode 100644 index 5e76f651..00000000 --- a/packages/ui-core/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@commonalityco/ui-core", - "description": "Presentational components used to build Commonality applications", - "type": "module", - "version": "0.2.41", - "publishConfig": { - "access": "public" - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "exports": { - ".": "./dist/index.js" - }, - "sideEffects": false, - "dependencies": { - "@radix-ui/react-slot": "^1.0.2", - "class-variance-authority": "^0.7.0", - "tailwind-merge": "^1.14.0" - }, - "devDependencies": { - "@commonalityco/config-tailwind": "workspace:*", - "@commonalityco/config-tsconfig": "workspace:*", - "@commonalityco/ui-design-system": "workspace:*", - "@commonalityco/utils-core": "workspace:*", - "@types/react": "^18.2.57", - "eslint-config-commonality": "workspace:*", - "lucide-react": "^0.317.0", - "next": "14.0.4", - "next-themes": "^0.2.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "tailwindcss": "^3.4.1", - "typescript": "^5.3.3" - }, - "license": "MIT", - "peerDependencies": { - "@commonalityco/ui-design-system": "*", - "@commonalityco/utils-core": "*", - "lucide-react": "^0.x", - "next": "14.0.4", - "next-themes": "^0.x", - "react": ">=18", - "react-dom": ">=18" - }, - "scripts": { - "lint": "eslint .", - "lint:fix": "eslint . --fix", - "build": "tsc --build", - "dev": "tsc --watch", - "test": "vitest", - "type-check": "tsc --noEmit" - }, - "engines": { - "node": ">=16" - }, - "repository": { - "type": "git", - "url": "https://github.com/commonalityco/commonality", - "directory": "packages/ui-core" - } -} diff --git a/packages/ui-core/src/bun-logo.tsx b/packages/ui-core/src/bun-logo.tsx deleted file mode 100644 index 114d7fde..00000000 --- a/packages/ui-core/src/bun-logo.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import cn from '@commonalityco/ui-design-system/cn'; - -export function BunLogo({ className }: { className?: string }) { - return ( - - Bun Logo - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/packages/ui-core/src/divider.tsx b/packages/ui-core/src/divider.tsx deleted file mode 100644 index 102df44b..00000000 --- a/packages/ui-core/src/divider.tsx +++ /dev/null @@ -1,16 +0,0 @@ -export function Divider({ className }: { className?: string }) { - return ( - - - - ); -} - -export default Divider; diff --git a/packages/ui-core/src/download.svg b/packages/ui-core/src/download.svg deleted file mode 100644 index 7ef15001..00000000 --- a/packages/ui-core/src/download.svg +++ /dev/null @@ -1 +0,0 @@ -Bun Logo \ No newline at end of file diff --git a/packages/ui-core/src/get-icon-for-package.ts b/packages/ui-core/src/get-icon-for-package.ts deleted file mode 100644 index 14c383e9..00000000 --- a/packages/ui-core/src/get-icon-for-package.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { PackageType } from '@commonalityco/utils-core'; -import { LogoNode } from './images/logo-node'; -import { LogoReact } from './images/logo-react'; -import { LogoNext } from './images/logo-next'; - -const ComponentByType = { - [PackageType.NEXT]: LogoNext, - [PackageType.REACT]: LogoReact, - [PackageType.NODE]: LogoNode, -}; - -export const getIconForPackage = (type: PackageType) => { - return ComponentByType[type] ?? LogoNode; -}; diff --git a/packages/ui-core/src/gradient-fade.tsx b/packages/ui-core/src/gradient-fade.tsx deleted file mode 100644 index f1abce32..00000000 --- a/packages/ui-core/src/gradient-fade.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, { HTMLAttributes } from 'react'; -import { cva, VariantProps } from 'class-variance-authority'; -import { twMerge } from 'tailwind-merge'; - -const gradientFadeStyles = cva( - 'pointer-events-none sticky z-5 from-background', - { - variants: { - placement: { - top: 'h-6 top-0 bg-gradient-to-b', - bottom: 'h-6 bottom-0 bg-gradient-to-t', - left: 'w-6 left-0 bg-gradient-to-r', - right: 'w-6 right-0 bg-gradient-to-l', - }, - }, - }, -); - -interface GradientFadeProperties - extends VariantProps, - HTMLAttributes<'div'> {} - -export function GradientFade({ placement, className }: GradientFadeProperties) { - return ( -
- ); -} - -export default GradientFade; diff --git a/packages/ui-core/src/images/logo-next.tsx b/packages/ui-core/src/images/logo-next.tsx deleted file mode 100644 index 09ba0fc8..00000000 --- a/packages/ui-core/src/images/logo-next.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import React from 'react'; -export function LogoNext(properties: JSX.IntrinsicElements['svg']) { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/packages/ui-core/src/images/logo-node.tsx b/packages/ui-core/src/images/logo-node.tsx deleted file mode 100644 index f01bffd6..00000000 --- a/packages/ui-core/src/images/logo-node.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -export function LogoNode(properties: JSX.IntrinsicElements['svg']) { - return ( - - - - ); -} diff --git a/packages/ui-core/src/images/logo-react.tsx b/packages/ui-core/src/images/logo-react.tsx deleted file mode 100644 index 29119c4d..00000000 --- a/packages/ui-core/src/images/logo-react.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -export function LogoReact(properties: JSX.IntrinsicElements['svg']) { - return ( - - - - - - - ); -} diff --git a/packages/ui-core/src/images/storybook-logo.svg b/packages/ui-core/src/images/storybook-logo.svg deleted file mode 100644 index 9adb848c..00000000 --- a/packages/ui-core/src/images/storybook-logo.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/packages/ui-core/src/index.ts b/packages/ui-core/src/index.ts deleted file mode 100644 index c0d30301..00000000 --- a/packages/ui-core/src/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export { Navigation } from './navigation'; -export { ThemeButton } from './theme-button'; -export { Logo } from './logo'; -export { GradientFade } from './gradient-fade'; -export { NpmLogo } from './npm-logo'; -export { PnpmLogo } from './pnpm-logo'; -export { YarnLogo } from './yarn-logo'; -export { BunLogo } from './bun-logo'; -export { NavigationLogo } from './navigation-logo'; -export { Divider } from './divider'; -export { ThemeButtonLoading } from './theme-button-loading'; -export { NavigationButton } from './navigation-button'; -export { WordLogo } from './word-logo'; -export { WordLogoFull } from './word-logo-full'; -export * from './get-icon-for-package'; diff --git a/packages/ui-core/src/logo.tsx b/packages/ui-core/src/logo.tsx deleted file mode 100644 index 5e24d548..00000000 --- a/packages/ui-core/src/logo.tsx +++ /dev/null @@ -1,33 +0,0 @@ -export function Logo(properties: JSX.IntrinsicElements['svg']) { - return ( - - - - - - - - - - - - ); -} diff --git a/packages/ui-core/src/navigation-button.tsx b/packages/ui-core/src/navigation-button.tsx deleted file mode 100644 index fa93e5ff..00000000 --- a/packages/ui-core/src/navigation-button.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { cn } from '@commonalityco/ui-design-system/cn'; -import { Slot } from '@radix-ui/react-slot'; -import React from 'react'; - -interface NavigationButtonProperties - extends React.AnchorHTMLAttributes { - asChild?: boolean; - active?: boolean; -} - -export const NavigationButton = React.forwardRef< - HTMLAnchorElement, - NavigationButtonProperties ->(({ asChild, active, className, children, ...properties }, reference) => { - const Comp = asChild ? Slot : 'a'; - - return ( - -
- {children} -
-
- ); -}); diff --git a/packages/ui-core/src/navigation-logo.tsx b/packages/ui-core/src/navigation-logo.tsx deleted file mode 100644 index 39be6f04..00000000 --- a/packages/ui-core/src/navigation-logo.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { Logo } from './logo'; - -export function NavigationLogo() { - return ; -} - -export default NavigationLogo; diff --git a/packages/ui-core/src/navigation.tsx b/packages/ui-core/src/navigation.tsx deleted file mode 100644 index d03ad1e2..00000000 --- a/packages/ui-core/src/navigation.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { cn } from '@commonalityco/ui-design-system/cn'; -import React from 'react'; - -interface NavigationProperties { - children?: React.ReactNode; - className?: string; -} - -export function Navigation({ children, className }: NavigationProperties) { - return ( -
- {children} -
- ); -} - -export default Navigation; diff --git a/packages/ui-core/src/npm-logo.tsx b/packages/ui-core/src/npm-logo.tsx deleted file mode 100644 index 12eb9ee8..00000000 --- a/packages/ui-core/src/npm-logo.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { cn } from '@commonalityco/ui-design-system/cn'; - -export function NpmLogo({ className }: { className?: string }) { - return ( - - - - - - - - - ); -} - -export default NpmLogo; diff --git a/packages/ui-core/src/pnpm-logo.tsx b/packages/ui-core/src/pnpm-logo.tsx deleted file mode 100644 index 82a455fc..00000000 --- a/packages/ui-core/src/pnpm-logo.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import { cn } from '@commonalityco/ui-design-system/cn'; - -export function PnpmLogo({ className }: { className?: string }) { - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} - -export default PnpmLogo; diff --git a/packages/ui-core/src/theme-button-loading.tsx b/packages/ui-core/src/theme-button-loading.tsx deleted file mode 100644 index 911bca78..00000000 --- a/packages/ui-core/src/theme-button-loading.tsx +++ /dev/null @@ -1,5 +0,0 @@ -export function ThemeButtonLoading() { - return
; -} - -export default ThemeButtonLoading; diff --git a/packages/ui-core/src/theme-button.tsx b/packages/ui-core/src/theme-button.tsx deleted file mode 100644 index 78d6b273..00000000 --- a/packages/ui-core/src/theme-button.tsx +++ /dev/null @@ -1,102 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ -'use client'; -import React, { ComponentProps, useState } from 'react'; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuRadioGroup, - DropdownMenuRadioItem, - DropdownMenuTrigger, -} from '@commonalityco/ui-design-system/dropdown-menu'; -import { - Tooltip, - TooltipTrigger, - TooltipProvider, - TooltipContent, -} from '@commonalityco/ui-design-system/tooltip'; -import { Button } from '@commonalityco/ui-design-system/button'; -import { Monitor, Sun, Moon, LucideIcon } from 'lucide-react'; -import { cn } from '@commonalityco/ui-design-system/cn'; - -interface ThemeButtonProperties - extends Omit, 'label' | 'use'> { - onThemeChange?: (theme: string) => void; - defaultTheme?: string; -} - -const IconByTheme: Record = { - dark: Moon, - light: Sun, - system: Monitor, -}; - -export function ThemeButton({ - onThemeChange = () => {}, - defaultTheme = 'system', - className, - ...properties -}: ThemeButtonProperties) { - const [isTooltipOpen, setIsTooltipOpen] = useState(false); - const [theme, setTheme] = useState(defaultTheme); - const Icon = theme ? IconByTheme[theme] : undefined; - - return ( - setIsTooltipOpen(false)}> - - - - - - - - - - Change theme - - - - event.preventDefault()} - > - {theme && ( - { - setTheme(value); - - onThemeChange(value); - }} - > - - - System - - - - Light - - - - Dark - - - )} - - - ); -} diff --git a/packages/ui-core/src/theme.ts b/packages/ui-core/src/theme.ts deleted file mode 100644 index 1a3b6ed6..00000000 --- a/packages/ui-core/src/theme.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum Theme { - Dark = 'dark', - Light = 'light', - System = 'system', -} diff --git a/packages/ui-core/src/word-logo-full.tsx b/packages/ui-core/src/word-logo-full.tsx deleted file mode 100644 index a8288dc7..00000000 --- a/packages/ui-core/src/word-logo-full.tsx +++ /dev/null @@ -1,75 +0,0 @@ -export function WordLogoFull() { - return ( - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/packages/ui-core/src/word-logo.tsx b/packages/ui-core/src/word-logo.tsx deleted file mode 100644 index 2963700f..00000000 --- a/packages/ui-core/src/word-logo.tsx +++ /dev/null @@ -1,23 +0,0 @@ -export function WordLogo() { - return ( - - - - - - - - - - - ); -} diff --git a/packages/ui-core/src/yarn-logo.tsx b/packages/ui-core/src/yarn-logo.tsx deleted file mode 100644 index a4945e0d..00000000 --- a/packages/ui-core/src/yarn-logo.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { cn } from '@commonalityco/ui-design-system/cn'; - -export function YarnLogo({ className }: { className?: string }) { - return ( - - - - - - - ); -} - -export default YarnLogo; diff --git a/packages/ui-core/tailwind.config.js b/packages/ui-core/tailwind.config.js deleted file mode 100644 index 9a5527c7..00000000 --- a/packages/ui-core/tailwind.config.js +++ /dev/null @@ -1,7 +0,0 @@ -import baseConfig from '@commonalityco/config-tailwind'; - -/** @type {import('tailwindcss').Config} */ -export default { - ...baseConfig, - content: ['./src/**/*.{js,ts,jsx,tsx}'], -}; diff --git a/packages/ui-core/tsconfig.json b/packages/ui-core/tsconfig.json deleted file mode 100644 index 54cc7700..00000000 --- a/packages/ui-core/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "@commonalityco/config-tsconfig/react.json", - "include": ["src/**/*.ts", "src/**/*.tsx"], - "compilerOptions": { - "outDir": "./dist", - "typeRoots": ["./node_modules/@types"], - "rootDir": "./src" - } -} diff --git a/packages/ui-core/vitest.config.ts b/packages/ui-core/vitest.config.ts deleted file mode 100644 index 701d5ef6..00000000 --- a/packages/ui-core/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({}) \ No newline at end of file diff --git a/packages/ui-design-system/.eslintrc.json b/packages/ui-design-system/.eslintrc.json deleted file mode 100644 index 63ff83f8..00000000 --- a/packages/ui-design-system/.eslintrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": ["commonality"] -} diff --git a/packages/ui-design-system/.npmignore b/packages/ui-design-system/.npmignore deleted file mode 100644 index 56affc6d..00000000 --- a/packages/ui-design-system/.npmignore +++ /dev/null @@ -1 +0,0 @@ -*.test.* \ No newline at end of file diff --git a/packages/ui-design-system/CHANGELOG.md b/packages/ui-design-system/CHANGELOG.md deleted file mode 100644 index 287039bf..00000000 --- a/packages/ui-design-system/CHANGELOG.md +++ /dev/null @@ -1,128 +0,0 @@ -# @commonalityco/ui-design-system - -## 0.2.42 - -### Patch Changes - -- 5b8761b: Update layout of graph and deprecate packages - -## 0.2.41 - -### Patch Changes - -- 7ba2c80: Make graph more responsive - -## 0.2.40 - -### Patch Changes - -- 4f0f69c: Update dependency graph to use @xyflow/react - -## 0.2.39 - -### Patch Changes - -- 0faea77: Fixes an issue where the repository field check was creating an incorrectly formatted repository field - -## 0.2.38 - -### Patch Changes - -- 52d572a: Add new project flow with commonality init - -## 0.2.37 - -### Patch Changes - -- 4661b6b: Display dependency constraints in searchable modal - -## 0.2.36 - -### Patch Changes - -- 3f1e821: Improve tag editing and constraints UX in Commonality Studio - -## 0.0.15 - -### Patch Changes - -- 74e1a9c: update engines -- 74e1a9c: update checks package namne - -## 0.0.14 - -### Patch Changes - -- 4bd3547: Create granular packages - -## 0.0.13 - -### Patch Changes - -- ad4a813: Finalize Commonality Studio, checks, and constraints - -## 0.0.12 - -### Patch Changes - -- e9a5bc2: Add table view to Studio - -## 0.0.11 - -### Patch Changes - -- ffbc45c: Fixed graph color and reduced bundle size dramatically - -## 0.0.10 - -### Patch Changes - -- 5b61b0e: Reduce bundle size - -## 0.0.9 - -### Patch Changes - -- 91bfd71: Unify into commonality package - -## 0.0.8 - -### Patch Changes - -- 26e1636: Publish foundational packages - -## 0.0.7 - -### Patch Changes - -- 986fdbf: Fix peers - -## 0.0.6 - -### Patch Changes - -- a7691a8: Add skeleton and dep updates - -## 0.0.5 - -### Patch Changes - -- ee3504f: Distribute studio /dist - -## 0.0.4 - -### Patch Changes - -- dadeafb: Convert to ESM - -## 0.0.3 - -### Patch Changes - -- fb47c73: update build output - -## 0.0.2 - -### Patch Changes - -- da2c556: Initial release diff --git a/packages/ui-design-system/README.md b/packages/ui-design-system/README.md deleted file mode 100644 index cc28abd4..00000000 --- a/packages/ui-design-system/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# @commonalityco/ui-design-system -> UI primitives built with shadcn -## Installation - -```sh -npm install @commonalityco/ui-design-system -``` \ No newline at end of file diff --git a/packages/ui-design-system/commonality.json b/packages/ui-design-system/commonality.json deleted file mode 100644 index 86b0c992..00000000 --- a/packages/ui-design-system/commonality.json +++ /dev/null @@ -1 +0,0 @@ -{"tags":["ui"]} diff --git a/packages/ui-design-system/components.json b/packages/ui-design-system/components.json deleted file mode 100644 index fbdfea36..00000000 --- a/packages/ui-design-system/components.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "new-york", - "rsc": true, - "tailwind": { - "config": "tailwind.config.js", - "css": "src/styles/globals.css", - "baseColor": "zinc", - "cssVariables": true - }, - "aliases": { - "components": "src/components", - "utils": "src/utils" - } -} \ No newline at end of file diff --git a/packages/ui-design-system/package.json b/packages/ui-design-system/package.json deleted file mode 100644 index bdd71735..00000000 --- a/packages/ui-design-system/package.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "name": "@commonalityco/ui-design-system", - "description": "UI primitives built with shadcn", - "version": "0.2.42", - "publishConfig": { - "access": "public" - }, - "sideEffects": false, - "type": "module", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "exports": { - ".": "./dist/index.js", - "./cn": "./dist/cn.js", - "./tooltip": "./dist/tooltip.js", - "./button": "./dist/button.js", - "./toast": "./dist/toast.js", - "./dropdown-menu": "./dist/dropdown-menu.js" - }, - "files": [ - "dist" - ], - "dependencies": { - "@radix-ui/react-accordion": "^1.1.2", - "@radix-ui/react-checkbox": "^1.0.4", - "@radix-ui/react-dialog": "^1.0.5", - "@radix-ui/react-dropdown-menu": "^2.0.6", - "@radix-ui/react-hover-card": "^1.0.7", - "@radix-ui/react-label": "^2.0.2", - "@radix-ui/react-popover": "^1.0.7", - "@radix-ui/react-radio-group": "^1.1.3", - "@radix-ui/react-scroll-area": "^1.0.5", - "@radix-ui/react-separator": "^1.0.3", - "@radix-ui/react-slot": "^1.0.2", - "@radix-ui/react-switch": "^1.0.3", - "@radix-ui/react-tabs": "^1.0.4", - "@radix-ui/react-toast": "^1.1.5", - "@radix-ui/react-toggle": "^1.0.3", - "@radix-ui/react-toggle-group": "^1.0.4", - "@radix-ui/react-tooltip": "^1.0.7", - "class-variance-authority": "^0.7.0", - "clsx": "^2.1.0", - "cmdk": "^0.2.1", - "react-hook-form": "^7.50.1", - "react-select": "^5.8.0", - "sonner": "^1.4.0", - "tailwind-merge": "^1.14.0" - }, - "devDependencies": { - "@commonalityco/config-tailwind": "workspace:*", - "@commonalityco/config-tsconfig": "workspace:*", - "@types/react": "^18.2.57", - "eslint-config-commonality": "workspace:*", - "lucide-react": "^0.317.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "tailwindcss": "^3.4.1", - "typescript": "^5.3.3" - }, - "license": "MIT", - "peerDependencies": { - "lucide-react": "^0.x", - "react": ">=18", - "react-dom": ">=18" - }, - "scripts": { - "lint": "eslint .", - "lint:fix": "eslint . --fix", - "build": "tsc --build", - "dev": "tsc --watch", - "type-check": "tsc --noEmit" - }, - "repository": { - "type": "git", - "url": "https://github.com/commonalityco/commonality", - "directory": "packages/ui-design-system" - } -} \ No newline at end of file diff --git a/packages/ui-design-system/src/accordion.tsx b/packages/ui-design-system/src/accordion.tsx deleted file mode 100644 index e5700497..00000000 --- a/packages/ui-design-system/src/accordion.tsx +++ /dev/null @@ -1,60 +0,0 @@ -'use client'; - -import * as React from 'react'; -import * as AccordionPrimitive from '@radix-ui/react-accordion'; -import { ChevronDown } from 'lucide-react'; - -import { cn } from './cn'; - -const Accordion = AccordionPrimitive.Root; - -const AccordionItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => ( - -)); -AccordionItem.displayName = 'AccordionItem'; - -const AccordionTrigger = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...properties }, reference) => ( - - svg]:rotate-180', - className, - )} - {...properties} - > - {children} - - - -)); -AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName; - -const AccordionContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...properties }, reference) => ( - -
{children}
-
-)); -AccordionContent.displayName = AccordionPrimitive.Content.displayName; - -export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }; diff --git a/packages/ui-design-system/src/alert.tsx b/packages/ui-design-system/src/alert.tsx deleted file mode 100644 index 07b07656..00000000 --- a/packages/ui-design-system/src/alert.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import * as React from 'react'; -import { VariantProps, cva } from 'class-variance-authority'; -import { cn } from './cn'; - -const alertVariants = cva( - 'relative w-full rounded-lg border p-4 [&>svg]:absolute [&>svg]:text-foreground [&>svg]:left-4 [&>svg]:top-4 [&>svg+div]:translate-y-[-3px] [&:has(svg)]:pl-11', - { - variants: { - variant: { - default: 'bg-background text-foreground', - destructive: - 'text-destructive border-destructive/50 dark:border-destructive [&>svg]:text-destructive text-destructive', - }, - }, - defaultVariants: { - variant: 'default', - }, - }, -); - -const Alert = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & VariantProps ->(({ className, variant, ...properties }, reference) => ( -
-)); -Alert.displayName = 'Alert'; - -const AlertTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => ( -
-)); -AlertTitle.displayName = 'AlertTitle'; - -const AlertDescription = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => ( -
-)); -AlertDescription.displayName = 'AlertDescription'; - -export { Alert, AlertTitle, AlertDescription }; diff --git a/packages/ui-design-system/src/badge.tsx b/packages/ui-design-system/src/badge.tsx deleted file mode 100644 index 827bdf8d..00000000 --- a/packages/ui-design-system/src/badge.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import * as React from 'react'; -import { cva, type VariantProps } from 'class-variance-authority'; -import { cn } from './cn'; - -const badgeVariants = cva( - 'inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 truncate antialiased', - { - variants: { - variant: { - default: - 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80', - secondary: - 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80', - destructive: - 'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80', - success: - 'border-transparent bg-success text-success-foreground shadow hover:bg-success/80', - outline: 'text-foreground bg-background', - }, - }, - defaultVariants: { - variant: 'default', - }, - }, -); - -export interface BadgeProperties - extends React.HTMLAttributes, - VariantProps {} - -function Badge({ className, variant, ...properties }: BadgeProperties) { - return ( -
- ); -} - -export { Badge, badgeVariants }; diff --git a/packages/ui-design-system/src/button.tsx b/packages/ui-design-system/src/button.tsx deleted file mode 100644 index e5cb131f..00000000 --- a/packages/ui-design-system/src/button.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import * as React from 'react'; -import { Slot } from '@radix-ui/react-slot'; -import { cva, type VariantProps } from 'class-variance-authority'; - -import { cn } from './cn'; - -const buttonVariants = cva( - 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 min-w-fit', - { - variants: { - variant: { - default: - 'border border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/90', - destructive: - 'border border-transparent bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90', - outline: - 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground text-foreground', - secondary: - 'border border-transparent bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80', - ghost: - 'border border-transparent hover:bg-accent text-accent-foreground', - link: 'text-primary underline-offset-4 hover:underline', - }, - size: { - default: 'h-9 px-4 py-2 space-x-1', - sm: 'h-8 rounded-md px-3 text-xs', - lg: 'h-10 rounded-md px-8', - xl: 'h-12 rounded-md px-9 text-lg font-semibold', - icon: 'h-9 w-9 shrink-0', - }, - }, - defaultVariants: { - variant: 'default', - size: 'default', - }, - }, -); - -export interface ButtonProperties - extends React.ButtonHTMLAttributes, - VariantProps { - asChild?: boolean; -} - -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...properties }, reference) => { - const Comp = asChild ? Slot : 'button'; - return ( - - ); - }, -); -Button.displayName = 'Button'; - -export { Button, buttonVariants }; diff --git a/packages/ui-design-system/src/card.tsx b/packages/ui-design-system/src/card.tsx deleted file mode 100644 index a937dae7..00000000 --- a/packages/ui-design-system/src/card.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { cva, VariantProps } from 'class-variance-authority'; -import * as React from 'react'; -import { cn } from './cn'; - -const cardVariants = cva('text-card-foreground rounded-lg border antialiased', { - variants: { - variant: { - default: 'shadow bg-card', - secondary: 'bg-muted', - }, - }, - defaultVariants: { - variant: 'default', - }, -}); - -const Card = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & VariantProps ->(({ className, variant, ...properties }, reference) => ( -
-)); -Card.displayName = 'Card'; - -const CardHeader = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => ( -
-)); -CardHeader.displayName = 'CardHeader'; - -const CardTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => ( -

-)); -CardTitle.displayName = 'CardTitle'; - -const CardDescription = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => ( -

-)); -CardDescription.displayName = 'CardDescription'; - -const CardContent = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => ( -

-)); -CardContent.displayName = 'CardContent'; - -const CardFooter = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => ( -
-)); -CardFooter.displayName = 'CardFooter'; - -export { - Card, - CardHeader, - CardFooter, - CardTitle, - CardDescription, - CardContent, -}; diff --git a/packages/ui-design-system/src/checkbox.tsx b/packages/ui-design-system/src/checkbox.tsx deleted file mode 100644 index 931d70cc..00000000 --- a/packages/ui-design-system/src/checkbox.tsx +++ /dev/null @@ -1,30 +0,0 @@ -'use client'; - -import * as React from 'react'; -import * as CheckboxPrimitive from '@radix-ui/react-checkbox'; - -import { cn } from './cn'; -import { Check } from 'lucide-react'; - -export const Checkbox = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => ( - - - - - -)); -Checkbox.displayName = CheckboxPrimitive.Root.displayName; - -export default Checkbox; diff --git a/packages/ui-design-system/src/cn.ts b/packages/ui-design-system/src/cn.ts deleted file mode 100644 index 9d67c50c..00000000 --- a/packages/ui-design-system/src/cn.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { clsx, type ClassValue } from 'clsx'; -import { twMerge } from 'tailwind-merge'; - -export function cn(...inputs: ClassValue[]) { - return twMerge(clsx(inputs)); -} - -export default cn; diff --git a/packages/ui-design-system/src/command.tsx b/packages/ui-design-system/src/command.tsx deleted file mode 100644 index 53be5405..00000000 --- a/packages/ui-design-system/src/command.tsx +++ /dev/null @@ -1,154 +0,0 @@ -'use client'; - -import * as React from 'react'; -import { DialogProps } from '@radix-ui/react-dialog'; -import { Command as CommandPrimitive } from 'cmdk'; -import { cn } from './cn'; -import { Dialog, DialogContent } from './dialog'; -import { Search } from 'lucide-react'; - -const Command = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -Command.displayName = CommandPrimitive.displayName; - -interface CommandDialogProps extends DialogProps {} - -const CommandDialog = ({ children, ...props }: CommandDialogProps) => { - return ( - - - - {children} - - - - ); -}; - -const CommandInput = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( -
- - -
-)); - -CommandInput.displayName = CommandPrimitive.Input.displayName; - -const CommandList = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); - -CommandList.displayName = CommandPrimitive.List.displayName; - -const CommandEmpty = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->((props, ref) => ( - -)); - -CommandEmpty.displayName = CommandPrimitive.Empty.displayName; - -const CommandGroup = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); - -CommandGroup.displayName = CommandPrimitive.Group.displayName; - -const CommandSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -CommandSeparator.displayName = CommandPrimitive.Separator.displayName; - -const CommandItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); - -CommandItem.displayName = CommandPrimitive.Item.displayName; - -const CommandShortcut = ({ - className, - ...props -}: React.HTMLAttributes) => { - return ( - - ); -}; -CommandShortcut.displayName = 'CommandShortcut'; - -export { - Command, - CommandDialog, - CommandInput, - CommandList, - CommandEmpty, - CommandGroup, - CommandItem, - CommandShortcut, - CommandSeparator, -}; diff --git a/packages/ui-design-system/src/dialog.tsx b/packages/ui-design-system/src/dialog.tsx deleted file mode 100644 index 7db785d2..00000000 --- a/packages/ui-design-system/src/dialog.tsx +++ /dev/null @@ -1,120 +0,0 @@ -'use client'; - -import * as React from 'react'; -import * as DialogPrimitive from '@radix-ui/react-dialog'; - -import { cn } from './cn'; -import { X } from 'lucide-react'; - -const Dialog = DialogPrimitive.Root; - -const DialogTrigger = DialogPrimitive.Trigger; - -const DialogPortal = ({ ...properties }: DialogPrimitive.DialogPortalProps) => ( - -); -DialogPortal.displayName = DialogPrimitive.Portal.displayName; - -const DialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => ( - -)); -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; - -const DialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...properties }, reference) => ( - - - - {children} - - - Close - - - -)); -DialogContent.displayName = DialogPrimitive.Content.displayName; - -const DialogHeader = ({ - className, - ...properties -}: React.HTMLAttributes) => ( -
-); -DialogHeader.displayName = 'DialogHeader'; - -const DialogFooter = ({ - className, - ...properties -}: React.HTMLAttributes) => ( -
-); -DialogFooter.displayName = 'DialogFooter'; - -const DialogTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => ( - -)); -DialogTitle.displayName = DialogPrimitive.Title.displayName; - -const DialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => ( - -)); -DialogDescription.displayName = DialogPrimitive.Description.displayName; - -export { - Dialog, - DialogTrigger, - DialogContent, - DialogHeader, - DialogFooter, - DialogTitle, - DialogDescription, -}; diff --git a/packages/ui-design-system/src/dropdown-menu.tsx b/packages/ui-design-system/src/dropdown-menu.tsx deleted file mode 100644 index 3614c268..00000000 --- a/packages/ui-design-system/src/dropdown-menu.tsx +++ /dev/null @@ -1,201 +0,0 @@ -'use client'; - -import * as React from 'react'; -import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; -import { Check, ChevronRight, Circle } from 'lucide-react'; - -import { cn } from './cn'; - -const DropdownMenu = DropdownMenuPrimitive.Root; - -const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; - -const DropdownMenuGroup = DropdownMenuPrimitive.Group; - -const DropdownMenuPortal = DropdownMenuPrimitive.Portal; - -const DropdownMenuSub = DropdownMenuPrimitive.Sub; - -const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; - -const DropdownMenuSubTrigger = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({ className, inset, children, ...properties }, reference) => ( - - {children} - - -)); -DropdownMenuSubTrigger.displayName = - DropdownMenuPrimitive.SubTrigger.displayName; - -const DropdownMenuSubContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => ( - -)); -DropdownMenuSubContent.displayName = - DropdownMenuPrimitive.SubContent.displayName; - -const DropdownMenuContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, sideOffset = 4, ...properties }, reference) => ( - - - -)); -DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; - -const DropdownMenuItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({ className, inset, ...properties }, reference) => ( - -)); -DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; - -const DropdownMenuCheckboxItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, checked, ...properties }, reference) => ( - - - - - - - {children} - -)); -DropdownMenuCheckboxItem.displayName = - DropdownMenuPrimitive.CheckboxItem.displayName; - -const DropdownMenuRadioItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...properties }, reference) => ( - - - - - - - {children} - -)); -DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName; - -const DropdownMenuLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({ className, inset, ...properties }, reference) => ( - -)); -DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName; - -const DropdownMenuSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => ( - -)); -DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName; - -const DropdownMenuShortcut = ({ - className, - ...properties -}: React.HTMLAttributes) => { - return ( - - ); -}; -DropdownMenuShortcut.displayName = 'DropdownMenuShortcut'; - -export { - DropdownMenu, - DropdownMenuTrigger, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuCheckboxItem, - DropdownMenuRadioItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuShortcut, - DropdownMenuGroup, - DropdownMenuPortal, - DropdownMenuSub, - DropdownMenuSubContent, - DropdownMenuSubTrigger, - DropdownMenuRadioGroup, -}; diff --git a/packages/ui-design-system/src/form.tsx b/packages/ui-design-system/src/form.tsx deleted file mode 100644 index 7fce735b..00000000 --- a/packages/ui-design-system/src/form.tsx +++ /dev/null @@ -1,179 +0,0 @@ -'use client'; -import * as React from 'react'; -import * as LabelPrimitive from '@radix-ui/react-label'; -import { Slot } from '@radix-ui/react-slot'; -import { - Controller, - ControllerProps, - FieldPath, - FieldValues, - FormProvider, - useFormContext, -} from 'react-hook-form'; -import { cn } from './cn'; -import { Label } from './label'; - -const Form = FormProvider; - -type FormFieldContextValue< - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, -> = { - name: TName; -}; - -const FormFieldContext = React.createContext( - {} as FormFieldContextValue, -); - -const FormField = < - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath, ->({ - ...properties -}: ControllerProps) => { - return ( - - - - ); -}; - -const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext); - const itemContext = React.useContext(FormItemContext); - const { getFieldState, formState } = useFormContext(); - - const fieldState = getFieldState(fieldContext.name, formState); - - if (!fieldContext) { - throw new Error('useFormField should be used within '); - } - - const { id } = itemContext; - - return { - id, - name: fieldContext.name, - formItemId: `${id}-form-item`, - formDescriptionId: `${id}-form-item-description`, - formMessageId: `${id}-form-item-message`, - ...fieldState, - }; -}; - -type FormItemContextValue = { - id: string; -}; - -const FormItemContext = React.createContext( - {} as FormItemContextValue, -); - -const FormItem = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...properties }, reference) => { - const id = React.useId(); - - return ( - -
- - ); -}); -FormItem.displayName = 'FormItem'; - -const FormLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...properties }, reference) => { - const { error, formItemId } = useFormField(); - - return ( -