diff --git a/lib/.npmignore b/lib/.npmignore new file mode 100644 index 00000000..3753aa02 --- /dev/null +++ b/lib/.npmignore @@ -0,0 +1,2 @@ +*.test.* + diff --git a/lib/getStaticTypes.test.ts b/lib/getStaticTypes.test.ts new file mode 100644 index 00000000..37397750 --- /dev/null +++ b/lib/getStaticTypes.test.ts @@ -0,0 +1,30 @@ +// @ts-expect-error No types +import getStaticTypes from './getStaticTypes'; +import { resolve } from 'node:path'; + +describe('getStaticTypes', () => { + it('should get static types from typescript components', async () => { + const result = await getStaticTypes({ + cwd: resolve(__dirname, '../cypress/projects/typescript'), + }); + + expect(result).toMatchInlineSnapshot(` + { + "Bar": { + "color": [ + "red", + "blue", + "black", + ], + }, + "Foo": { + "color": [ + "red", + "blue", + "black", + ], + }, + } + `); + }); +}); diff --git a/package.json b/package.json index 73e4b920..1447927e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "format": "prettier --write '**/*.{js,md,ts,tsx}'", "version": "changeset version", "release": "changeset publish", - "test": "jest src", + "test": "jest src lib", "post-commit-status": "node scripts/postCommitStatus.js", "deploy-preview": "surge -p ./cypress/projects/themed/dist" }, @@ -125,6 +125,7 @@ "@octokit/rest": "^19.0.5", "@testing-library/cypress": "^10.0.1", "@types/jest": "^29.2.4", + "@types/node": "^18.11.9", "@types/react-helmet": "^6.1.6", "@types/react-transition-group": "^4.4.10", "concurrently": "^7.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c87fff40..a6960314 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -55,7 +55,7 @@ dependencies: version: 1.5.1(@vanilla-extract/css@1.14.1) '@vanilla-extract/webpack-plugin': specifier: ^2.3.6 - version: 2.3.6(webpack@5.75.0) + version: 2.3.6(@types/node@18.11.12)(webpack@5.75.0) babel-loader: specifier: ^9.1.0 version: 9.1.0(@babel/core@7.23.3)(webpack@5.75.0) @@ -184,6 +184,9 @@ devDependencies: '@types/jest': specifier: ^29.2.4 version: 29.2.4 + '@types/node': + specifier: ^18.11.9 + version: 18.11.12 '@types/react-helmet': specifier: ^6.1.6 version: 6.1.11 @@ -207,7 +210,7 @@ devDependencies: version: 8.0.2 jest: specifier: ^29.3.1 - version: 29.3.1 + version: 29.3.1(@types/node@18.11.12) lint-staged: specifier: ^15.2.2 version: 15.2.2 @@ -3147,7 +3150,7 @@ packages: '@vanilla-extract/private': 1.0.6 dev: false - /@vanilla-extract/integration@7.1.0: + /@vanilla-extract/integration@7.1.0(@types/node@18.11.12): resolution: {integrity: sha512-kCFn2IfnCHf4PCP538zBs5g6JJvqybJ4lU+ww2CeV/B2roze8drF7jVu2hDQUTtfiXgNe0Q3WpUfXdX27KFLsw==} dependencies: '@babel/core': 7.23.3 @@ -3161,8 +3164,8 @@ packages: lodash: 4.17.21 mlly: 1.5.0 outdent: 0.8.0 - vite: 5.1.3 - vite-node: 1.3.0 + vite: 5.1.3(@types/node@18.11.12) + vite-node: 1.3.0(@types/node@18.11.12) transitivePeerDependencies: - '@types/node' - less @@ -3190,12 +3193,12 @@ packages: '@vanilla-extract/css': 1.14.1 dev: false - /@vanilla-extract/webpack-plugin@2.3.6(webpack@5.75.0): + /@vanilla-extract/webpack-plugin@2.3.6(@types/node@18.11.12)(webpack@5.75.0): resolution: {integrity: sha512-GnWdVzBFDfCzNRyBoYzuwPTEWFOKFtq3Td9gla6ng+dCeJFRGW+6jT5hXvqJojw8Rk2fWzc6XA2FHPrVa7W9wA==} peerDependencies: webpack: ^4.30.0 || ^5.20.2 dependencies: - '@vanilla-extract/integration': 7.1.0 + '@vanilla-extract/integration': 7.1.0(@types/node@18.11.12) chalk: 4.1.2 debug: 4.3.4(supports-color@8.1.1) loader-utils: 2.0.4 @@ -5227,7 +5230,7 @@ packages: '@typescript-eslint/eslint-plugin': 5.61.0(@typescript-eslint/parser@5.61.0)(eslint@8.57.0)(typescript@5.0.4) '@typescript-eslint/utils': 5.61.0(eslint@8.57.0)(typescript@5.0.4) eslint: 8.57.0 - jest: 29.3.1 + jest: 29.3.1(@types/node@18.11.12) transitivePeerDependencies: - supports-color - typescript @@ -6833,7 +6836,7 @@ packages: - supports-color dev: true - /jest-cli@29.3.1: + /jest-cli@29.3.1(@types/node@18.11.12): resolution: {integrity: sha512-TO/ewvwyvPOiBBuWZ0gm04z3WWP8TIK8acgPzE4IxgsLKQgb377NYGrQLc3Wl/7ndWzIH2CDNNsUjGxwLL43VQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -7196,7 +7199,7 @@ packages: supports-color: 8.1.1 dev: true - /jest@29.3.1: + /jest@29.3.1(@types/node@18.11.12): resolution: {integrity: sha512-6iWfL5DTT0Np6UYs/y5Niu7WIfNv/wRTtN5RSXt2DIEft3dx3zPuw/3WJQBCJfmEzvDiEKwoqMbGD9n49+qLSA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -7209,7 +7212,7 @@ packages: '@jest/core': 29.3.1 '@jest/types': 29.3.1 import-local: 3.1.0 - jest-cli: 29.3.1 + jest-cli: 29.3.1(@types/node@18.11.12) transitivePeerDependencies: - '@types/node' - supports-color @@ -10278,7 +10281,7 @@ packages: extsprintf: 1.3.0 dev: true - /vite-node@1.3.0: + /vite-node@1.3.0(@types/node@18.11.12): resolution: {integrity: sha512-D/oiDVBw75XMnjAXne/4feCkCEwcbr2SU1bjAhCcfI5Bq3VoOHji8/wCPAfUkDIeohJ5nSZ39fNxM3dNZ6OBOA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -10287,7 +10290,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.1.3 + vite: 5.1.3(@types/node@18.11.12) transitivePeerDependencies: - '@types/node' - less @@ -10299,7 +10302,7 @@ packages: - terser dev: false - /vite@5.1.3: + /vite@5.1.3(@types/node@18.11.12): resolution: {integrity: sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -10327,6 +10330,7 @@ packages: terser: optional: true dependencies: + '@types/node': 18.11.12 esbuild: 0.19.12 postcss: 8.4.35 rollup: 4.12.0 diff --git a/tsconfig.json b/tsconfig.json index 6f01e5bd..d410d141 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,6 @@ "lib": ["dom", "es2022"], "target": "es2022" }, - "include": ["src"], + "include": ["src", "lib"], "exclude": ["cypress", "node_modules"] }