apify-test-tools 0.10.2-beta.12 → 0.10.2-beta.13
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/.prettierignore +1 -1
- package/CHANGELOG.md +1 -0
- package/dist/test/unit/bin/compiled-cli.d.ts +1 -1
- package/dist/test/unit/bin/compiled-cli.d.ts.map +1 -1
- package/dist/test/unit/bin/compiled-cli.js +12 -5
- package/dist/test/unit/bin/compiled-cli.js.map +1 -1
- package/dist/test/unit/bin/logging.test.js +5 -11
- package/dist/test/unit/bin/logging.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +1 -1
- package/package.json +1 -1
- package/test/unit/bin/compiled-cli.ts +11 -5
- package/test/unit/bin/logging.test.ts +6 -10
package/eslint.config.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import tsEslint from 'typescript-eslint';
|
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line import/no-default-export
|
|
8
8
|
export default [
|
|
9
|
-
{ ignores: ['**/dist', 'eslint.config.mjs', 'vitest.config.ts', '.github'] },
|
|
9
|
+
{ ignores: ['**/dist', 'eslint.config.mjs', 'vitest.config.ts', '.github', '.cli-test-*'] },
|
|
10
10
|
...apify,
|
|
11
11
|
prettier,
|
|
12
12
|
{
|
package/package.json
CHANGED
|
@@ -7,11 +7,17 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
const projectRoot = fileURLToPath(new URL('../../../', import.meta.url));
|
|
8
8
|
const compilerPath = fileURLToPath(new URL('../../../node_modules/typescript/bin/tsc', import.meta.url));
|
|
9
9
|
|
|
10
|
-
/** Compiles the CLI from the sources into a temporary directory, so tests run it the way users do. */
|
|
10
|
+
/** Compiles the CLI from the sources into a temporary directory, so tests run it the way npm users do. */
|
|
11
11
|
export const compileCli = async () => {
|
|
12
12
|
const buildDir = await mkdtemp(path.join(projectRoot, '.cli-test-'));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const cleanup = async () => rm(buildDir, { recursive: true, force: true });
|
|
14
|
+
try {
|
|
15
|
+
execFileSync(process.execPath, [compilerPath, '--outDir', buildDir], { cwd: projectRoot });
|
|
16
|
+
const cliPath = path.join(buildDir, 'bin/main.js');
|
|
17
|
+
await chmod(cliPath, 0o755);
|
|
18
|
+
return { cliPath, cleanup };
|
|
19
|
+
} catch (error) {
|
|
20
|
+
await cleanup();
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
17
23
|
};
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { chmod, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import process from 'node:process';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
6
|
|
|
8
7
|
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import { compileCli } from './compiled-cli.js';
|
|
10
|
+
|
|
12
11
|
let cliPath: string;
|
|
13
|
-
let
|
|
12
|
+
let cleanup: (() => Promise<void>) | undefined;
|
|
14
13
|
let gitStubDir: string | undefined;
|
|
15
14
|
const sha = '1'.repeat(40);
|
|
16
15
|
|
|
17
16
|
describe('CLI logging', () => {
|
|
18
17
|
beforeAll(async () => {
|
|
19
|
-
|
|
20
|
-
execFileSync(process.execPath, [compilerPath, '--outDir', buildDir], { cwd: projectRoot });
|
|
21
|
-
cliPath = path.join(buildDir, 'bin/main.js');
|
|
22
|
-
await chmod(cliPath, 0o755);
|
|
18
|
+
({ cliPath, cleanup } = await compileCli());
|
|
23
19
|
gitStubDir = await mkdtemp(path.join(os.tmpdir(), 'apify-cli-logging-'));
|
|
24
20
|
const gitStub = path.join(gitStubDir, 'git');
|
|
25
21
|
await writeFile(
|
|
@@ -30,7 +26,7 @@ describe('CLI logging', () => {
|
|
|
30
26
|
});
|
|
31
27
|
|
|
32
28
|
afterAll(async () => {
|
|
33
|
-
|
|
29
|
+
await cleanup?.();
|
|
34
30
|
if (gitStubDir) await rm(gitStubDir, { recursive: true, force: true });
|
|
35
31
|
});
|
|
36
32
|
|