Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(root): improve build config #231

Merged
merged 6 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ updates:
directory: /
schedule:
interval: weekly
day: sunday
time: '00:00'
timezone: America/Sao_Paulo
commit-message:
prefix: chore
target-branch: canary
Expand Down Expand Up @@ -38,6 +41,9 @@ updates:
directory: /
schedule:
interval: weekly
day: sunday
time: '00:00'
timezone: America/Sao_Paulo
commit-message:
prefix: chore
target-branch: canary
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
node-version:
- 18
- 20
- 22
- '22.2'

env:
NODE_VERSION: ${{ matrix.node-version }}
Expand Down Expand Up @@ -104,6 +104,18 @@ jobs:
--continue \
--concurrency 1 \
${{ steps.zimic-setup.outputs.install-filters }}
env:
PLAYWRIGHT_WORKERS: 100%

- name: Upload test reports
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: test-reports-node-${{ matrix.node-version }}
path: |
./examples/*/tests/reports
./examples/*/tests/outputs
retention-days: 7

ci-typescript:
name: CI TypeScript
Expand Down
2 changes: 1 addition & 1 deletion apps/zimic-test-client/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},

"lint:turbo": {
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json", ".eslintrc.js", "../../.prettierrc.json"]
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json", ".eslintrc.js"]
},

"types:check": {
Expand Down
3 changes: 1 addition & 2 deletions examples/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"with-*/{src,tests}/**/*.{ts,json}",
"with-*/{package,tsconfig}.json",
"{package,tsconfig}.json",
".eslintrc.js",
"../.prettierrc.json"
".eslintrc.js"
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion examples/with-jest-jsdom/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
3 changes: 2 additions & 1 deletion examples/with-jest-node/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
3 changes: 2 additions & 1 deletion examples/with-next-js-app/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ export default defineConfig({
testMatch: '**/__tests__/**/*.e2e.test.ts',
fullyParallel: true,
retries: 1,
workers: process.env.PLAYWRIGHT_WORKERS,
reporter: [['html', { outputFolder: './tests/reports' }]],
outputDir: './tests/outputs',
timeout: 60 * 1000,

expect: {
timeout: 10 * 1000,
Expand All @@ -16,7 +18,6 @@ export default defineConfig({
baseURL: 'http://localhost:3004',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'on-first-retry',
actionTimeout: 10 * 1000,
navigationTimeout: 30 * 1000,
},
Expand Down
4 changes: 3 additions & 1 deletion examples/with-next-js-app/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"tasks": {
"test:turbo": {
"dependsOn": ["^build", "zimic#build"],
"passThroughEnv": ["PLAYWRIGHT_WORKERS"],
"inputs": [
"{src,tests}/**/*.{ts,tsx,json}",
"{package,tsconfig}.json",
Expand All @@ -12,7 +13,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
3 changes: 2 additions & 1 deletion examples/with-next-js-pages/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ export default defineConfig({
testMatch: '**/__tests__/**/*.e2e.test.ts',
fullyParallel: true,
retries: 1,
workers: process.env.PLAYWRIGHT_WORKERS,
reporter: [['html', { outputFolder: './tests/reports' }]],
outputDir: './tests/outputs',
timeout: 60 * 1000,

expect: {
timeout: 10 * 1000,
Expand All @@ -16,7 +18,6 @@ export default defineConfig({
baseURL: 'http://localhost:3006',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'on-first-retry',
actionTimeout: 10 * 1000,
navigationTimeout: 30 * 1000,
},
Expand Down
4 changes: 3 additions & 1 deletion examples/with-next-js-pages/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"tasks": {
"test:turbo": {
"dependsOn": ["^build", "zimic#build"],
"passThroughEnv": ["PLAYWRIGHT_WORKERS"],
"inputs": [
"{src,tests}/**/*.{ts,tsx,json}",
"{package,tsconfig}.json",
Expand All @@ -12,7 +13,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
2 changes: 1 addition & 1 deletion examples/with-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default defineConfig({
testMatch: '**/__tests__/**/*.e2e.test.ts',
fullyParallel: true,
retries: 1,
workers: process.env.PLAYWRIGHT_WORKERS,
reporter: [['html', { outputFolder: './tests/reports' }]],
outputDir: './tests/outputs',
timeout: 60 * 1000,
Expand All @@ -17,7 +18,6 @@ export default defineConfig({
baseURL: 'http://localhost:3002',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'on-first-retry',
actionTimeout: 10 * 1000,
navigationTimeout: 30 * 1000,
},
Expand Down
4 changes: 3 additions & 1 deletion examples/with-playwright/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"tasks": {
"test:turbo": {
"dependsOn": ["^build", "zimic#build"],
"passThroughEnv": ["PLAYWRIGHT_WORKERS"],
"inputs": [
"{src,tests}/**/*.{ts,tsx,json}",
"{package,tsconfig}.json",
Expand All @@ -12,7 +13,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
3 changes: 2 additions & 1 deletion examples/with-vitest-browser/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
3 changes: 2 additions & 1 deletion examples/with-vitest-jsdom/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
3 changes: 2 additions & 1 deletion examples/with-vitest-node/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},

"types:check": {
"dependsOn": ["^build", "zimic#build"]
"dependsOn": ["^build", "zimic#build"],
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json"]
}
}
}
1 change: 0 additions & 1 deletion packages/release/cli.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/release/index.d.ts

This file was deleted.

6 changes: 1 addition & 5 deletions packages/release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
"index.d.ts",
"cli.d.ts"
],
"exports": {
".": "./dist/index.js"
},
"bin": {
"release": "./dist/cli.js"
},
"scripts": {
"dev": "pnpm build --watch",
"dev:cli": "tsx src/cli/index.ts",
"cli": "node ./dist/cli.js",
"build": "tsup",
"lint": "eslint --ext 'ts,tsx' --cache --no-error-on-unmatched-pattern --fix",
"lint:turbo": "pnpm lint . --max-warnings 0",
Expand All @@ -40,7 +37,6 @@
"@zimic/tsconfig": "workspace:*",
"dotenv-cli": "^7.4.2",
"tsup": "^8.1.0",
"tsx": "^4.15.6",
"typescript": "^5.4.5",
"vitest": "1.6.0"
}
Expand Down
3 changes: 0 additions & 3 deletions packages/release/src/index.ts

This file was deleted.

31 changes: 11 additions & 20 deletions packages/release/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Options, defineConfig } from 'tsup';

const sharedConfig: Options = {
format: ['cjs', 'esm'],
dts: true,
bundle: true,
sourcemap: true,
Expand All @@ -10,23 +9,15 @@ const sharedConfig: Options = {
clean: true,
};

export default defineConfig([
{
...sharedConfig,
name: 'node',
platform: 'node',
entry: {
index: 'src/index.ts',
},
const cliConfig = (['cjs'] as const).map<Options>((format) => ({
...sharedConfig,
name: 'cli',
platform: 'node',
format: [format],
dts: false,
entry: {
cli: 'src/cli/entry.ts',
},
{
...sharedConfig,
name: 'cli',
platform: 'node',
format: ['cjs'],
dts: false,
entry: {
cli: 'src/cli/entry.ts',
},
},
]);
}));

export default defineConfig([...cliConfig]);
2 changes: 1 addition & 1 deletion packages/release/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},

"lint:turbo": {
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json", ".eslintrc.js", "../../.prettierrc.json"]
"inputs": ["{src,tests}/**/*.{ts,json}", "{package,tsconfig}.json", ".eslintrc.js"]
},

"types:check": {
Expand Down
12 changes: 5 additions & 7 deletions packages/zimic/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import InvalidFormDataError from './http/errors/InvalidFormDataError';
import InvalidJSONError from './http/errors/InvalidJSONError';
import HttpFormData from './http/formData/HttpFormData';
import HttpHeaders from './http/headers/HttpHeaders';
import HttpSearchParams from './http/searchParams/HttpSearchParams';
export { default as InvalidFormDataError } from './http/errors/InvalidFormDataError';
export { default as InvalidJSONError } from './http/errors/InvalidJSONError';
export { default as HttpFormData } from './http/formData/HttpFormData';
export { default as HttpHeaders } from './http/headers/HttpHeaders';
export { default as HttpSearchParams } from './http/searchParams/HttpSearchParams';

export type { JSONValue, JSONSerialized } from '@/types/json';

Expand Down Expand Up @@ -41,5 +41,3 @@ export type {
HttpServiceSchemaPath,
PathParamsSchemaFromPath,
} from './http/types/schema';

export { HttpSearchParams, HttpHeaders, HttpFormData, InvalidJSONError, InvalidFormDataError };
19 changes: 6 additions & 13 deletions packages/zimic/src/interceptor/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import NotStartedHttpInterceptorError from './http/interceptor/errors/NotStartedHttpInterceptorError';
import UnknownHttpInterceptorPlatformError from './http/interceptor/errors/UnknownHttpInterceptorPlatformError';
import UnknownHttpInterceptorTypeError from './http/interceptor/errors/UnknownHttpInterceptorTypeError';
import UnregisteredBrowserServiceWorkerError from './http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError';
import HttpInterceptorNamespace from './http/namespace/HttpInterceptorNamespace';
import DisabledRequestSavingError from './http/requestHandler/errors/DisabledRequestSavingError';

export {
UnknownHttpInterceptorPlatformError,
UnknownHttpInterceptorTypeError,
NotStartedHttpInterceptorError,
UnregisteredBrowserServiceWorkerError,
DisabledRequestSavingError,
};
export { default as NotStartedHttpInterceptorError } from './http/interceptor/errors/NotStartedHttpInterceptorError';
export { default as UnknownHttpInterceptorPlatformError } from './http/interceptor/errors/UnknownHttpInterceptorPlatformError';
export { default as UnknownHttpInterceptorTypeError } from './http/interceptor/errors/UnknownHttpInterceptorTypeError';
export { default as UnregisteredBrowserServiceWorkerError } from './http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError';
export { default as HttpInterceptorNamespace } from './http/namespace/HttpInterceptorNamespace';
export { default as DisabledRequestSavingError } from './http/requestHandler/errors/DisabledRequestSavingError';

export type {
HttpRequestHandlerResponseDeclaration,
Expand Down Expand Up @@ -48,7 +42,6 @@ export type { ExtractHttpInterceptorSchema } from './http/interceptor/types/sche
export type { LocalHttpInterceptor, RemoteHttpInterceptor, HttpInterceptor } from './http/interceptor/types/public';

export type { HttpInterceptorNamespaceDefault } from './http/namespace/HttpInterceptorNamespace';
export type { HttpInterceptorNamespace };

/**
* A set of interceptor resources for mocking HTTP requests.
Expand Down
6 changes: 4 additions & 2 deletions packages/zimic/tests/utils/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export async function usingIgnoredConsole<Method extends keyof Console>(
ignoredMethods: Method[],
callback: (spyByMethod: SpyByConsoleMethod<Method>) => PossiblePromise<void>,
) {
const spyByMethod = ignoredMethods.reduce<SpyByConsoleMethod<Method>>((groupedSpies, method) => {
const initialSpyByMethod = {} as SpyByConsoleMethod<Method>;

const spyByMethod = ignoredMethods.reduce((groupedSpies, method) => {
const spy = vi.spyOn(console, method).mockImplementation(vi.fn());
groupedSpies[method] = spy;
return groupedSpies;
}, {} as SpyByConsoleMethod<Method>); // eslint-disable-line @typescript-eslint/prefer-reduce-type-parameter
}, initialSpyByMethod);

try {
await callback(spyByMethod);
Expand Down
Loading
Loading