apify-test-tools 0.8.5 → 0.8.6-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
1
  {
2
- "name": "apify-test-tools",
3
- "version": "0.8.5",
4
- "type": "module",
5
- "description": "TBD",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/apify/apify-test-tools.git"
9
- },
10
- "engines": {
11
- "node": ">=18.0.0"
12
- },
13
- "bin": {
14
- "apify-test-tools": "dist/bin/main.js"
15
- },
16
- "types": "./dist/index.d.ts",
17
- "main": "./dist/lib/lib.js",
18
- "dependencies": {
19
- "@apify/consts": "^2.43.0",
20
- "@slack/web-api": "^7.9.2",
21
- "apify-client": "^2.22.2",
22
- "yargs": "^18.0.0"
23
- },
24
- "devDependencies": {
25
- "@apify/eslint-config": "^1.0.0",
26
- "@apify/tsconfig": "^0.1.1",
27
- "@types/node": "^24.0.0",
28
- "@types/yargs": "^17.0.33",
29
- "eslint": "^9.29.0",
30
- "eslint-config-prettier": "^10.1.5",
31
- "globals": "^17.0.0",
32
- "prettier": "^3.5.3",
33
- "tsx": "^4.20.3",
34
- "typescript": "^5.9.3",
35
- "typescript-eslint": "^8.34.1",
36
- "vitest": "^3.2.4",
37
- "knip": "^5.65.0",
38
- "husky": "^9.0.11",
39
- "lint-staged": "^15.2.2"
40
- },
41
- "peerDependencies": {
42
- "vitest": ">=3.2.4"
43
- },
44
- "scripts": {
45
- "start": "npm run dist/bin/main.js",
46
- "start:dev": "GITHUB_WORKSPACE=local-clone tsx bin/main.ts",
47
- "build": "tsc && chmod +x ./dist/bin/main.js",
48
- "lint": "eslint",
49
- "lint:fix": "eslint --fix",
50
- "format": "prettier --write .",
51
- "format:check": "prettier --check .",
52
- "type-check": "tsc --noEmit",
53
- "test": "vitest run",
54
- "check-unused": "npx knip",
55
- "prepare": "husky .husky || true"
56
- },
57
- "lint-staged": {
58
- "*.js": "eslint",
59
- "*.ts": "eslint"
60
- },
61
- "author": "oklinov",
62
- "license": "ISC"
2
+ "name": "apify-test-tools",
3
+ "version": "0.8.6-beta.0",
4
+ "type": "module",
5
+ "description": "TBD",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/apify/apify-test-tools.git"
9
+ },
10
+ "engines": {
11
+ "node": ">=18.0.0"
12
+ },
13
+ "bin": {
14
+ "apify-test-tools": "dist/bin/main.js"
15
+ },
16
+ "types": "./dist/index.d.ts",
17
+ "main": "./dist/lib/lib.js",
18
+ "dependencies": {
19
+ "@apify/consts": "^2.43.0",
20
+ "@slack/web-api": "^7.9.2",
21
+ "apify-client": "^2.22.2",
22
+ "yargs": "^18.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@apify/eslint-config": "^1.0.0",
26
+ "@apify/tsconfig": "^0.1.1",
27
+ "@types/node": "^24.0.0",
28
+ "@types/yargs": "^17.0.33",
29
+ "eslint": "^9.29.0",
30
+ "eslint-config-prettier": "^10.1.5",
31
+ "globals": "^17.0.0",
32
+ "prettier": "^3.5.3",
33
+ "tsx": "^4.20.3",
34
+ "typescript": "^5.9.3",
35
+ "typescript-eslint": "^8.34.1",
36
+ "vitest": "^3.2.4",
37
+ "knip": "^5.65.0",
38
+ "husky": "^9.0.11",
39
+ "lint-staged": "^15.2.2"
40
+ },
41
+ "peerDependencies": {
42
+ "vitest": ">=3.2.4"
43
+ },
44
+ "scripts": {
45
+ "start": "npm run dist/bin/main.js",
46
+ "start:dev": "GITHUB_WORKSPACE=local-clone tsx bin/main.ts",
47
+ "build": "tsc && chmod +x ./dist/bin/main.js",
48
+ "lint": "eslint",
49
+ "lint:fix": "eslint --fix",
50
+ "format": "prettier --write .",
51
+ "format:check": "prettier --check .",
52
+ "type-check": "tsc --noEmit",
53
+ "test": "vitest run",
54
+ "check-unused": "npx knip",
55
+ "prepare": "husky .husky || true"
56
+ },
57
+ "lint-staged": {
58
+ "*.js": "eslint",
59
+ "*.ts": "eslint"
60
+ },
61
+ "author": "oklinov",
62
+ "license": "ISC"
63
63
  }
@@ -6,13 +6,13 @@ import path from 'node:path';
6
6
 
7
7
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
8
8
 
9
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
- // @ts-ignore: editor-only TS6059 — test/tsconfig.json's rootDir doesn't span bin/, but the root
11
- // tsconfig (used for the real build and for eslint's type-aware linting) has no such restriction.
12
9
  import {
13
10
  collectNonIgnoredFiles,
14
11
  flattenMonorepoContext,
15
12
  rewriteActorJsonPaths,
13
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
+ // @ts-ignore: editor-only TS6059 — test/tsconfig.json's rootDir doesn't span bin/, but the root
15
+ // tsconfig (used for the real build and for eslint's type-aware linting) has no such restriction.
16
16
  } from '../../../bin/build-from-local.js';
17
17
  import * as Utils from '../../../bin/utils.js';
18
18
 
@@ -182,6 +182,83 @@ describe('build-from-local helpers', () => {
182
182
  });
183
183
  });
184
184
 
185
+ describe('getDockerignoredPaths', () => {
186
+ const tempDirs: string[] = [];
187
+
188
+ afterEach(async () => {
189
+ vi.mocked(spawnSync).mockClear();
190
+ await Promise.all(tempDirs.splice(0).map(async (dir) => fs.rm(dir, { recursive: true, force: true })));
191
+ });
192
+
193
+ it('returns an empty set without calling git when given no paths', () => {
194
+ const result = Utils.getDockerignoredPaths('/does/not/matter', []);
195
+
196
+ expect(result).toStrictEqual(new Set());
197
+ expect(spawnSync).not.toHaveBeenCalled();
198
+ });
199
+
200
+ it('returns an empty set when rootDir has no .dockerignore', async () => {
201
+ const rootDir = await mkTempDir('apify-test-tools-dockerignore-');
202
+ tempDirs.push(rootDir);
203
+ initGitRepo(rootDir);
204
+
205
+ expect(Utils.getDockerignoredPaths(rootDir, ['main.js'])).toStrictEqual(new Set());
206
+ });
207
+
208
+ it('returns the paths that match .dockerignore patterns rooted at rootDir', async () => {
209
+ const rootDir = await mkTempDir('apify-test-tools-dockerignore-');
210
+ tempDirs.push(rootDir);
211
+ initGitRepo(rootDir);
212
+
213
+ await fs.writeFile(path.join(rootDir, '.dockerignore'), 'test/\n*.log\n');
214
+
215
+ const result = Utils.getDockerignoredPaths(rootDir, ['main.js', 'test/fixture.json', 'debug.log']);
216
+
217
+ expect(result).toStrictEqual(new Set(['test/fixture.json', 'debug.log']));
218
+ });
219
+
220
+ it('matches "./"-prefixed patterns, which Docker treats as a no-op but git treats as literal text', async () => {
221
+ const rootDir = await mkTempDir('apify-test-tools-dockerignore-');
222
+ tempDirs.push(rootDir);
223
+ initGitRepo(rootDir);
224
+
225
+ // The common real-world .dockerignore style: every pattern prefixed with "./",
226
+ // including a negation re-including one of the otherwise-matched files.
227
+ await fs.writeFile(path.join(rootDir, '.dockerignore'), './node_modules\n./*.log\n!./keep.log\n');
228
+
229
+ const result = Utils.getDockerignoredPaths(rootDir, [
230
+ 'node_modules/foo.js',
231
+ 'debug.log',
232
+ 'keep.log',
233
+ 'main.js',
234
+ ]);
235
+
236
+ expect(result).toStrictEqual(new Set(['node_modules/foo.js', 'debug.log']));
237
+ });
238
+
239
+ it('matches already-tracked files too, since Docker excludes them regardless of git tracking', async () => {
240
+ const rootDir = await mkTempDir('apify-test-tools-dockerignore-');
241
+ tempDirs.push(rootDir);
242
+ initGitRepo(rootDir);
243
+ spawnSync('git', ['config', 'user.email', 'test@example.com'], { cwd: rootDir });
244
+ spawnSync('git', ['config', 'user.name', 'Test'], { cwd: rootDir });
245
+
246
+ // Husky hooks are committed to the repo, so this path is tracked by git — by default
247
+ // `git check-ignore` never reports a tracked file as ignored, which would otherwise mask
248
+ // this exact pattern from matching, unlike a real Docker build which excludes it anyway.
249
+ await fs.mkdir(path.join(rootDir, '.husky'));
250
+ await fs.writeFile(path.join(rootDir, '.husky', 'pre-commit'), '#!/bin/sh\n');
251
+ spawnSync('git', ['add', '.husky/pre-commit'], { cwd: rootDir });
252
+ spawnSync('git', ['commit', '-q', '-m', 'add husky hook'], { cwd: rootDir });
253
+
254
+ await fs.writeFile(path.join(rootDir, '.dockerignore'), './.husky\n');
255
+
256
+ const result = Utils.getDockerignoredPaths(rootDir, ['.husky/pre-commit', 'main.js']);
257
+
258
+ expect(result).toStrictEqual(new Set(['.husky/pre-commit']));
259
+ });
260
+ });
261
+
185
262
  describe('getGitignoredPaths', () => {
186
263
  beforeEach(() => {
187
264
  vi.mocked(spawnSync).mockReset();