@quenty/nevermore-cli 4.49.0 → 4.50.1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/commands/tools-command/ci-post-test-results.d.ts.map +1 -1
  3. package/dist/commands/tools-command/ci-post-test-results.js +7 -3
  4. package/dist/commands/tools-command/ci-post-test-results.js.map +1 -1
  5. package/dist/utils/batch/changed-packages-utils.d.ts +8 -0
  6. package/dist/utils/batch/changed-packages-utils.d.ts.map +1 -1
  7. package/dist/utils/batch/changed-packages-utils.js +9 -11
  8. package/dist/utils/batch/changed-packages-utils.js.map +1 -1
  9. package/dist/utils/testing/batch-run.e2e.test.js +2 -2
  10. package/dist/utils/testing/batch-run.e2e.test.js.map +1 -1
  11. package/dist/utils/testing/parsers/annotation-workspace.d.ts +17 -0
  12. package/dist/utils/testing/parsers/annotation-workspace.d.ts.map +1 -0
  13. package/dist/utils/testing/parsers/annotation-workspace.js +47 -0
  14. package/dist/utils/testing/parsers/annotation-workspace.js.map +1 -0
  15. package/dist/utils/testing/parsers/index.d.ts +0 -1
  16. package/dist/utils/testing/parsers/index.d.ts.map +1 -1
  17. package/dist/utils/testing/parsers/index.js +0 -1
  18. package/dist/utils/testing/parsers/index.js.map +1 -1
  19. package/dist/utils/testing/parsers/jest-lua-parser.d.ts +14 -29
  20. package/dist/utils/testing/parsers/jest-lua-parser.d.ts.map +1 -1
  21. package/dist/utils/testing/parsers/jest-lua-parser.js +85 -100
  22. package/dist/utils/testing/parsers/jest-lua-parser.js.map +1 -1
  23. package/dist/utils/testing/parsers/jest-lua-parser.test.js +359 -56
  24. package/dist/utils/testing/parsers/jest-lua-parser.test.js.map +1 -1
  25. package/dist/utils/testing/parsers/roblox-path-resolver.d.ts +23 -17
  26. package/dist/utils/testing/parsers/roblox-path-resolver.d.ts.map +1 -1
  27. package/dist/utils/testing/parsers/roblox-path-resolver.js +89 -54
  28. package/dist/utils/testing/parsers/roblox-path-resolver.js.map +1 -1
  29. package/dist/utils/testing/parsers/roblox-path-resolver.test.js +76 -36
  30. package/dist/utils/testing/parsers/roblox-path-resolver.test.js.map +1 -1
  31. package/dist/utils/testing/runner/combined-project-generator.d.ts.map +1 -1
  32. package/dist/utils/testing/runner/combined-project-generator.js +5 -6
  33. package/dist/utils/testing/runner/combined-project-generator.js.map +1 -1
  34. package/dist/utils/testing/runner/test-project-slug.d.ts +11 -0
  35. package/dist/utils/testing/runner/test-project-slug.d.ts.map +1 -0
  36. package/dist/utils/testing/runner/test-project-slug.js +11 -0
  37. package/dist/utils/testing/runner/test-project-slug.js.map +1 -0
  38. package/package.json +6 -6
  39. package/src/commands/tools-command/ci-post-test-results.ts +7 -2
  40. package/src/utils/batch/changed-packages-utils.ts +21 -12
  41. package/src/utils/testing/batch-run.e2e.test.ts +6 -2
  42. package/src/utils/testing/parsers/annotation-workspace.ts +74 -0
  43. package/src/utils/testing/parsers/index.ts +0 -1
  44. package/src/utils/testing/parsers/jest-lua-parser.test.ts +433 -65
  45. package/src/utils/testing/parsers/jest-lua-parser.ts +131 -109
  46. package/src/utils/testing/parsers/roblox-path-resolver.test.ts +144 -61
  47. package/src/utils/testing/parsers/roblox-path-resolver.ts +117 -56
  48. package/src/utils/testing/runner/combined-project-generator.ts +9 -13
  49. package/src/utils/testing/runner/test-project-slug.ts +18 -0
  50. package/tsconfig.tsbuildinfo +1 -1
@@ -10,6 +10,11 @@ import {
10
10
  toManifestPlaceInfo,
11
11
  } from '@quenty/nevermore-deploy';
12
12
 
13
+ export interface WorkspacePackageInfo {
14
+ name: string;
15
+ path: string;
16
+ }
17
+
13
18
  export interface TargetPackage {
14
19
  name: string;
15
20
  path: string;
@@ -50,16 +55,19 @@ export interface BatchTarget {
50
55
  export async function discoverAllTargetPackagesAsync(
51
56
  targetName: string
52
57
  ): Promise<TargetPackage[]> {
53
- const { stdout } = await execa('pnpm', [
54
- 'ls',
55
- '--json',
56
- '-r',
57
- '--depth',
58
- '-1',
59
- ]);
58
+ return filterByTargetAsync(await listWorkspacePackagesAsync(), targetName);
59
+ }
60
60
 
61
- const packages = JSON.parse(stdout) as Array<{ name: string; path: string }>;
62
- return _filterByTargetAsync(packages, targetName);
61
+ /** Every package in the pnpm workspace, with absolute paths. */
62
+ export async function listWorkspacePackagesAsync(
63
+ cwd?: string
64
+ ): Promise<WorkspacePackageInfo[]> {
65
+ const { stdout } = await execa(
66
+ 'pnpm',
67
+ ['ls', '--json', '-r', '--depth', '-1'],
68
+ { cwd }
69
+ );
70
+ return JSON.parse(stdout) as WorkspacePackageInfo[];
63
71
  }
64
72
 
65
73
  /**
@@ -92,7 +100,7 @@ export async function discoverChangedTargetPackagesAsync(
92
100
  return [];
93
101
  }
94
102
 
95
- return _filterByTargetAsync(packages, targetName);
103
+ return filterByTargetAsync(packages, targetName);
96
104
  }
97
105
 
98
106
  /**
@@ -181,8 +189,9 @@ function _requireScriptTemplate(targets: BatchTarget[]): BatchTarget[] {
181
189
  return withTemplate;
182
190
  }
183
191
 
184
- async function _filterByTargetAsync(
185
- packages: Array<{ name: string; path: string }>,
192
+ /** Keep the packages whose deploy config has `targetName`, with its places. */
193
+ export async function filterByTargetAsync(
194
+ packages: WorkspacePackageInfo[],
186
195
  targetName: string
187
196
  ): Promise<TargetPackage[]> {
188
197
  const results: TargetPackage[] = [];
@@ -485,8 +485,12 @@ describe('an aggregated batch run, end to end', () => {
485
485
  '/tmp/batch-2.rbxl',
486
486
  ]);
487
487
  expect(transport.runCount).toBe(2);
488
- expect(transport.scriptContents[0]).toContain('["alpha"]');
489
- expect(transport.scriptContents[1]).toContain('["beta"]');
488
+ // The places run in parallel, so their scripts arrive in either order
489
+ expect(
490
+ transport.scriptContents.map((script) =>
491
+ script.includes('["alpha"]') ? 'alpha' : 'beta'
492
+ )
493
+ ).toEqual(expect.arrayContaining(['alpha', 'beta']));
490
494
 
491
495
  expect(alpha.success).toBe(true);
492
496
  expect(alpha.testResults).toMatchObject({ passed: 68, total: 68 });
@@ -0,0 +1,74 @@
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'path';
3
+ import {
4
+ filterByTargetAsync,
5
+ listWorkspacePackagesAsync,
6
+ } from '../../batch/changed-packages-utils.js';
7
+ import {
8
+ type TestRojoProject,
9
+ findTestProjectSlug,
10
+ } from '../runner/test-project-slug.js';
11
+
12
+ export interface AnnotationWorkspacePackage {
13
+ /** Repo-relative POSIX directory, e.g. `src/player-mock` */
14
+ dir: string;
15
+ /** Rojo project name, which the sourcemap uses */
16
+ projectName?: string;
17
+ /** Instance names the package gets in its test places */
18
+ testSlugs: string[];
19
+ }
20
+
21
+ export interface AnnotationWorkspace {
22
+ packagesByName: Map<string, AnnotationWorkspacePackage>;
23
+ }
24
+
25
+ /**
26
+ * Index the pnpm workspace for mapping test output back to files. Returns
27
+ * `undefined` when the workspace can't be listed.
28
+ */
29
+ export async function tryLoadAnnotationWorkspaceAsync(
30
+ repoRoot: string
31
+ ): Promise<AnnotationWorkspace | undefined> {
32
+ let packages;
33
+ try {
34
+ packages = await listWorkspacePackagesAsync(repoRoot);
35
+ } catch {
36
+ return undefined;
37
+ }
38
+
39
+ const packagesByName = new Map<string, AnnotationWorkspacePackage>();
40
+ await Promise.all(
41
+ packages.map(async (pkg) => {
42
+ const project = await _tryReadJsonAsync<{ name?: string }>(
43
+ path.join(pkg.path, 'default.project.json')
44
+ );
45
+ packagesByName.set(pkg.name, {
46
+ dir: path.relative(repoRoot, pkg.path).replace(/\\/g, '/'),
47
+ projectName: project?.name,
48
+ testSlugs: [],
49
+ });
50
+ })
51
+ );
52
+
53
+ for (const testPackage of await filterByTargetAsync(packages, 'test')) {
54
+ const entry = packagesByName.get(testPackage.name);
55
+ if (!entry) continue;
56
+ for (const target of testPackage.activeTargets) {
57
+ const project = await _tryReadJsonAsync<TestRojoProject>(
58
+ path.resolve(testPackage.path, target.project)
59
+ );
60
+ const slug = project && findTestProjectSlug(project);
61
+ if (slug && !entry.testSlugs.includes(slug)) entry.testSlugs.push(slug);
62
+ }
63
+ }
64
+
65
+ return { packagesByName };
66
+ }
67
+
68
+ async function _tryReadJsonAsync<T>(filePath: string): Promise<T | undefined> {
69
+ try {
70
+ return JSON.parse(await fs.readFile(filePath, 'utf-8')) as T;
71
+ } catch {
72
+ return undefined;
73
+ }
74
+ }
@@ -1,2 +1 @@
1
- export { resolveRobloxTestPath } from './roblox-path-resolver.js';
2
1
  export { parseJestLuaOutput } from './jest-lua-parser.js';