@trackunit/iris-app-e2e 1.1.4 → 1.1.6
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/index.cjs.js +151 -0
- package/index.esm.js +151 -0
- package/package.json +2 -2
- package/src/plugins/defaultPlugins.d.ts +1 -1
- package/src/utils/Codeowner.d.ts +70 -0
package/index.cjs.js
CHANGED
|
@@ -220,6 +220,133 @@ function createLogFile(nxRoot, logsPath, fileNameWithoutExtension, logs, logWrit
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Parses lines from a CODEOWNERS‐style file into a mapping of patterns → owners.
|
|
225
|
+
* Skips blank lines and comments (lines beginning with `#`).
|
|
226
|
+
*
|
|
227
|
+
* @param {string[]} lines - Each element is a line from your CODEOWNERS file.
|
|
228
|
+
* @returns {Record<string, string>} An object whose keys are normalized path patterns (no leading/trailing slashes)
|
|
229
|
+
* and whose values are the owner (e.g. a GitHub team handle).
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const lines = [
|
|
233
|
+
* "# Our CODEOWNERS",
|
|
234
|
+
* "/src @team/backend",
|
|
235
|
+
* "README.md @team/docs",
|
|
236
|
+
* "", // blank lines ignored
|
|
237
|
+
* "# end of file"
|
|
238
|
+
* ];
|
|
239
|
+
* const owners = parseCodeowners(lines);
|
|
240
|
+
* // → { "src": "@team/backend", "README.md": "@team/docs" }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
const parseCodeowners = (lines) => {
|
|
244
|
+
const patterns = {};
|
|
245
|
+
for (const line of lines) {
|
|
246
|
+
const trimmed = line.trim();
|
|
247
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const [pattern, owner] = trimmed.split(/\s+/, 2);
|
|
251
|
+
if (pattern && owner) {
|
|
252
|
+
const normalizedPattern = pattern.replace(/^\/+|\/+$/g, "");
|
|
253
|
+
patterns[normalizedPattern] = owner;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return patterns;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Converts a full team handle (potentially namespaced and with platform suffix)
|
|
260
|
+
* into its “short” team name.
|
|
261
|
+
*
|
|
262
|
+
* - Strips any leading `@org/` prefix
|
|
263
|
+
* - Removes `-be` or `-fe` suffix if present
|
|
264
|
+
*
|
|
265
|
+
* @param {string} teamName - e.g. `"@trackunit/backend-be"` or `"@trackunit/frontend-fe"`
|
|
266
|
+
* @returns {string} e.g. `"backend"` or `"frontend"`
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* toShortTeamName("@trackunit/backend-be"); // → "backend"
|
|
270
|
+
* toShortTeamName("@trackunit/frontend-fe"); // → "frontend"
|
|
271
|
+
* toShortTeamName("infra"); // → "infra"
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
const toShortTeamName = (teamName) => {
|
|
275
|
+
if (!teamName) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
let shortName = teamName;
|
|
279
|
+
if (teamName.startsWith("@")) {
|
|
280
|
+
shortName = shortName.slice(shortName.indexOf("/") + 1);
|
|
281
|
+
}
|
|
282
|
+
if (shortName.endsWith("-be") || shortName.endsWith("-fe")) {
|
|
283
|
+
shortName = shortName.slice(0, shortName.lastIndexOf("-"));
|
|
284
|
+
}
|
|
285
|
+
return shortName;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Recursively looks up the CODEOWNER for a given file or directory path
|
|
289
|
+
* by reading your workspace’s CODEOWNERS file.
|
|
290
|
+
*
|
|
291
|
+
* Walks up the directory tree until it finds a matching pattern. If no
|
|
292
|
+
* deeper match is found but there is a `"."` entry, returns that.
|
|
293
|
+
*
|
|
294
|
+
* @param {string} currentPath - Absolute path to the file/directory you’re querying.
|
|
295
|
+
* @param {string} workspaceRoot - Absolute path to your repo/workspace root.
|
|
296
|
+
* @param {string} [codeownersFileName="TEAM_CODEOWNERS"] - Filename to read at the root.
|
|
297
|
+
* @returns {string|undefined} The owner handle (e.g. `"@team/backend"`) or `undefined` if none found.
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* // Suppose your repo root has a TEAM_CODEOWNERS file containing:
|
|
301
|
+
* // src @team/backend
|
|
302
|
+
* // src/utils @team/utils
|
|
303
|
+
* // . @team/root
|
|
304
|
+
*
|
|
305
|
+
* const owner1 = getCodeowner(
|
|
306
|
+
* "/Users/alice/project/src/utils/helpers.ts",
|
|
307
|
+
* "/Users/alice/project"
|
|
308
|
+
* );
|
|
309
|
+
* // → "@team/utils"
|
|
310
|
+
*
|
|
311
|
+
* const owner2 = getCodeowner(
|
|
312
|
+
* "/Users/alice/project/other/file.txt",
|
|
313
|
+
* "/Users/alice/project"
|
|
314
|
+
* );
|
|
315
|
+
* // → "@team/root" (falls back to the "." entry)
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
const getCodeowner = (currentPath, workspaceRoot, codeownersFileName = "TEAM_CODEOWNERS") => {
|
|
319
|
+
if (!workspaceRoot) {
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
const codeownersPath = path.join(workspaceRoot, codeownersFileName);
|
|
323
|
+
if (!fs.existsSync(codeownersPath)) {
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
const codeownersLines = fs.readFileSync(codeownersPath, "utf8").split("\n");
|
|
327
|
+
const codeowners = parseCodeowners(codeownersLines);
|
|
328
|
+
let relPath = path
|
|
329
|
+
.relative(workspaceRoot, currentPath)
|
|
330
|
+
.replace(/\\/g, "/")
|
|
331
|
+
.replace(/^\/+|\/+$/g, "");
|
|
332
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
333
|
+
while (true) {
|
|
334
|
+
const codeowner = codeowners[relPath];
|
|
335
|
+
if (codeowner) {
|
|
336
|
+
return codeowner;
|
|
337
|
+
}
|
|
338
|
+
const parent = path.posix.dirname(relPath);
|
|
339
|
+
if ((parent === relPath || parent === ".") && codeowners["."]) {
|
|
340
|
+
return codeowners["."];
|
|
341
|
+
}
|
|
342
|
+
if (parent === relPath || parent === ".") {
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
relPath = parent;
|
|
346
|
+
}
|
|
347
|
+
return undefined;
|
|
348
|
+
};
|
|
349
|
+
|
|
223
350
|
/**
|
|
224
351
|
* Utility function to find NX workspace root by looking for nx.json or workspace.json.
|
|
225
352
|
* This is more reliable than hardcoded relative paths and works from any directory.
|
|
@@ -337,11 +464,16 @@ const setupPlugins = (on, config, logWriter, installHarGenerator) => {
|
|
|
337
464
|
},
|
|
338
465
|
});
|
|
339
466
|
/* ---- END: Task setup ---- */
|
|
467
|
+
/* ---- BEGIN: codeowner setup ---- */
|
|
468
|
+
const codeowner = toShortTeamName(getCodeowner(config.projectRoot, config.nxRoot));
|
|
469
|
+
config.env.codeowner = codeowner;
|
|
470
|
+
/* ---- END: codeowner setup ---- */
|
|
340
471
|
/* ---- BEGIN: HAR setup ---- */
|
|
341
472
|
// Installing the HAR geneartor should happen last according to the documentation
|
|
342
473
|
// https://github.com/NeuraLegion/cypress-har-generator?tab=readme-ov-file#setting-up-the-plugin
|
|
343
474
|
installHarGenerator(on);
|
|
344
475
|
/* ---- END: HAR setup ---- */
|
|
476
|
+
return config;
|
|
345
477
|
};
|
|
346
478
|
|
|
347
479
|
/* eslint-disable local-rules/no-typescript-assertion, @typescript-eslint/no-explicit-any */
|
|
@@ -385,6 +517,25 @@ function setupE2E() {
|
|
|
385
517
|
return false;
|
|
386
518
|
});
|
|
387
519
|
}
|
|
520
|
+
const originalDescribe = global.describe;
|
|
521
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
522
|
+
if (originalDescribe) {
|
|
523
|
+
const codeowner = Cypress.env("codeowner");
|
|
524
|
+
const addOwnerToTitle = (title) => {
|
|
525
|
+
return codeowner ? title + ` [${codeowner}]` : title;
|
|
526
|
+
};
|
|
527
|
+
function patchedDescribe(title, fn) {
|
|
528
|
+
return originalDescribe(addOwnerToTitle(title), fn);
|
|
529
|
+
}
|
|
530
|
+
patchedDescribe.only = (title, fn) => {
|
|
531
|
+
return originalDescribe.only(addOwnerToTitle(title), fn);
|
|
532
|
+
};
|
|
533
|
+
patchedDescribe.skip = (title, fn) => {
|
|
534
|
+
return originalDescribe.skip(addOwnerToTitle(title), fn);
|
|
535
|
+
};
|
|
536
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
537
|
+
global.describe = patchedDescribe;
|
|
538
|
+
}
|
|
388
539
|
|
|
389
540
|
exports.createLogFile = createLogFile;
|
|
390
541
|
exports.defaultCypressConfig = defaultCypressConfig;
|
package/index.esm.js
CHANGED
|
@@ -200,6 +200,133 @@ function createLogFile(nxRoot, logsPath, fileNameWithoutExtension, logs, logWrit
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Parses lines from a CODEOWNERS‐style file into a mapping of patterns → owners.
|
|
205
|
+
* Skips blank lines and comments (lines beginning with `#`).
|
|
206
|
+
*
|
|
207
|
+
* @param {string[]} lines - Each element is a line from your CODEOWNERS file.
|
|
208
|
+
* @returns {Record<string, string>} An object whose keys are normalized path patterns (no leading/trailing slashes)
|
|
209
|
+
* and whose values are the owner (e.g. a GitHub team handle).
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* const lines = [
|
|
213
|
+
* "# Our CODEOWNERS",
|
|
214
|
+
* "/src @team/backend",
|
|
215
|
+
* "README.md @team/docs",
|
|
216
|
+
* "", // blank lines ignored
|
|
217
|
+
* "# end of file"
|
|
218
|
+
* ];
|
|
219
|
+
* const owners = parseCodeowners(lines);
|
|
220
|
+
* // → { "src": "@team/backend", "README.md": "@team/docs" }
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
const parseCodeowners = (lines) => {
|
|
224
|
+
const patterns = {};
|
|
225
|
+
for (const line of lines) {
|
|
226
|
+
const trimmed = line.trim();
|
|
227
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
const [pattern, owner] = trimmed.split(/\s+/, 2);
|
|
231
|
+
if (pattern && owner) {
|
|
232
|
+
const normalizedPattern = pattern.replace(/^\/+|\/+$/g, "");
|
|
233
|
+
patterns[normalizedPattern] = owner;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return patterns;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Converts a full team handle (potentially namespaced and with platform suffix)
|
|
240
|
+
* into its “short” team name.
|
|
241
|
+
*
|
|
242
|
+
* - Strips any leading `@org/` prefix
|
|
243
|
+
* - Removes `-be` or `-fe` suffix if present
|
|
244
|
+
*
|
|
245
|
+
* @param {string} teamName - e.g. `"@trackunit/backend-be"` or `"@trackunit/frontend-fe"`
|
|
246
|
+
* @returns {string} e.g. `"backend"` or `"frontend"`
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* toShortTeamName("@trackunit/backend-be"); // → "backend"
|
|
250
|
+
* toShortTeamName("@trackunit/frontend-fe"); // → "frontend"
|
|
251
|
+
* toShortTeamName("infra"); // → "infra"
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
const toShortTeamName = (teamName) => {
|
|
255
|
+
if (!teamName) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
let shortName = teamName;
|
|
259
|
+
if (teamName.startsWith("@")) {
|
|
260
|
+
shortName = shortName.slice(shortName.indexOf("/") + 1);
|
|
261
|
+
}
|
|
262
|
+
if (shortName.endsWith("-be") || shortName.endsWith("-fe")) {
|
|
263
|
+
shortName = shortName.slice(0, shortName.lastIndexOf("-"));
|
|
264
|
+
}
|
|
265
|
+
return shortName;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Recursively looks up the CODEOWNER for a given file or directory path
|
|
269
|
+
* by reading your workspace’s CODEOWNERS file.
|
|
270
|
+
*
|
|
271
|
+
* Walks up the directory tree until it finds a matching pattern. If no
|
|
272
|
+
* deeper match is found but there is a `"."` entry, returns that.
|
|
273
|
+
*
|
|
274
|
+
* @param {string} currentPath - Absolute path to the file/directory you’re querying.
|
|
275
|
+
* @param {string} workspaceRoot - Absolute path to your repo/workspace root.
|
|
276
|
+
* @param {string} [codeownersFileName="TEAM_CODEOWNERS"] - Filename to read at the root.
|
|
277
|
+
* @returns {string|undefined} The owner handle (e.g. `"@team/backend"`) or `undefined` if none found.
|
|
278
|
+
* @example
|
|
279
|
+
* ```ts
|
|
280
|
+
* // Suppose your repo root has a TEAM_CODEOWNERS file containing:
|
|
281
|
+
* // src @team/backend
|
|
282
|
+
* // src/utils @team/utils
|
|
283
|
+
* // . @team/root
|
|
284
|
+
*
|
|
285
|
+
* const owner1 = getCodeowner(
|
|
286
|
+
* "/Users/alice/project/src/utils/helpers.ts",
|
|
287
|
+
* "/Users/alice/project"
|
|
288
|
+
* );
|
|
289
|
+
* // → "@team/utils"
|
|
290
|
+
*
|
|
291
|
+
* const owner2 = getCodeowner(
|
|
292
|
+
* "/Users/alice/project/other/file.txt",
|
|
293
|
+
* "/Users/alice/project"
|
|
294
|
+
* );
|
|
295
|
+
* // → "@team/root" (falls back to the "." entry)
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
const getCodeowner = (currentPath, workspaceRoot, codeownersFileName = "TEAM_CODEOWNERS") => {
|
|
299
|
+
if (!workspaceRoot) {
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
const codeownersPath = path__default.join(workspaceRoot, codeownersFileName);
|
|
303
|
+
if (!fs.existsSync(codeownersPath)) {
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
const codeownersLines = fs.readFileSync(codeownersPath, "utf8").split("\n");
|
|
307
|
+
const codeowners = parseCodeowners(codeownersLines);
|
|
308
|
+
let relPath = path__default
|
|
309
|
+
.relative(workspaceRoot, currentPath)
|
|
310
|
+
.replace(/\\/g, "/")
|
|
311
|
+
.replace(/^\/+|\/+$/g, "");
|
|
312
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
313
|
+
while (true) {
|
|
314
|
+
const codeowner = codeowners[relPath];
|
|
315
|
+
if (codeowner) {
|
|
316
|
+
return codeowner;
|
|
317
|
+
}
|
|
318
|
+
const parent = path__default.posix.dirname(relPath);
|
|
319
|
+
if ((parent === relPath || parent === ".") && codeowners["."]) {
|
|
320
|
+
return codeowners["."];
|
|
321
|
+
}
|
|
322
|
+
if (parent === relPath || parent === ".") {
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
relPath = parent;
|
|
326
|
+
}
|
|
327
|
+
return undefined;
|
|
328
|
+
};
|
|
329
|
+
|
|
203
330
|
/**
|
|
204
331
|
* Utility function to find NX workspace root by looking for nx.json or workspace.json.
|
|
205
332
|
* This is more reliable than hardcoded relative paths and works from any directory.
|
|
@@ -317,11 +444,16 @@ const setupPlugins = (on, config, logWriter, installHarGenerator) => {
|
|
|
317
444
|
},
|
|
318
445
|
});
|
|
319
446
|
/* ---- END: Task setup ---- */
|
|
447
|
+
/* ---- BEGIN: codeowner setup ---- */
|
|
448
|
+
const codeowner = toShortTeamName(getCodeowner(config.projectRoot, config.nxRoot));
|
|
449
|
+
config.env.codeowner = codeowner;
|
|
450
|
+
/* ---- END: codeowner setup ---- */
|
|
320
451
|
/* ---- BEGIN: HAR setup ---- */
|
|
321
452
|
// Installing the HAR geneartor should happen last according to the documentation
|
|
322
453
|
// https://github.com/NeuraLegion/cypress-har-generator?tab=readme-ov-file#setting-up-the-plugin
|
|
323
454
|
installHarGenerator(on);
|
|
324
455
|
/* ---- END: HAR setup ---- */
|
|
456
|
+
return config;
|
|
325
457
|
};
|
|
326
458
|
|
|
327
459
|
/* eslint-disable local-rules/no-typescript-assertion, @typescript-eslint/no-explicit-any */
|
|
@@ -365,5 +497,24 @@ function setupE2E() {
|
|
|
365
497
|
return false;
|
|
366
498
|
});
|
|
367
499
|
}
|
|
500
|
+
const originalDescribe = global.describe;
|
|
501
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
502
|
+
if (originalDescribe) {
|
|
503
|
+
const codeowner = Cypress.env("codeowner");
|
|
504
|
+
const addOwnerToTitle = (title) => {
|
|
505
|
+
return codeowner ? title + ` [${codeowner}]` : title;
|
|
506
|
+
};
|
|
507
|
+
function patchedDescribe(title, fn) {
|
|
508
|
+
return originalDescribe(addOwnerToTitle(title), fn);
|
|
509
|
+
}
|
|
510
|
+
patchedDescribe.only = (title, fn) => {
|
|
511
|
+
return originalDescribe.only(addOwnerToTitle(title), fn);
|
|
512
|
+
};
|
|
513
|
+
patchedDescribe.skip = (title, fn) => {
|
|
514
|
+
return originalDescribe.skip(addOwnerToTitle(title), fn);
|
|
515
|
+
};
|
|
516
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
517
|
+
global.describe = patchedDescribe;
|
|
518
|
+
}
|
|
368
519
|
|
|
369
520
|
export { createLogFile, defaultCypressConfig, setupDefaultCommands, setupE2E, setupHarRecording, setupPlugins, writeFileWithPrettier };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-e2e",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"cypress-terminal-report": "7.0.3",
|
|
15
15
|
"node-xlsx": "^0.23.0",
|
|
16
16
|
"prettier": "^3.4.2",
|
|
17
|
-
"@trackunit/react-test-setup": "1.1.
|
|
17
|
+
"@trackunit/react-test-setup": "1.1.6"
|
|
18
18
|
},
|
|
19
19
|
"module": "./index.esm.js",
|
|
20
20
|
"main": "./index.cjs.js",
|
|
@@ -45,4 +45,4 @@ export declare const defaultCypressConfig: (optionsOrDirname?: E2EConfigOptions
|
|
|
45
45
|
* Sets up Cypress plugins for logging, tasks, and HAR generation.
|
|
46
46
|
* Configures terminal reporting, XLSX parsing, and HTTP archive recording.
|
|
47
47
|
*/
|
|
48
|
-
export declare const setupPlugins: (on: Cypress.PluginEvents, config: CypressPluginConfig, logWriter: Formatter, installHarGenerator: (on: Cypress.PluginEvents) => void) =>
|
|
48
|
+
export declare const setupPlugins: (on: Cypress.PluginEvents, config: CypressPluginConfig, logWriter: Formatter, installHarGenerator: (on: Cypress.PluginEvents) => void) => CypressPluginConfig;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses lines from a CODEOWNERS‐style file into a mapping of patterns → owners.
|
|
3
|
+
* Skips blank lines and comments (lines beginning with `#`).
|
|
4
|
+
*
|
|
5
|
+
* @param {string[]} lines - Each element is a line from your CODEOWNERS file.
|
|
6
|
+
* @returns {Record<string, string>} An object whose keys are normalized path patterns (no leading/trailing slashes)
|
|
7
|
+
* and whose values are the owner (e.g. a GitHub team handle).
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const lines = [
|
|
11
|
+
* "# Our CODEOWNERS",
|
|
12
|
+
* "/src @team/backend",
|
|
13
|
+
* "README.md @team/docs",
|
|
14
|
+
* "", // blank lines ignored
|
|
15
|
+
* "# end of file"
|
|
16
|
+
* ];
|
|
17
|
+
* const owners = parseCodeowners(lines);
|
|
18
|
+
* // → { "src": "@team/backend", "README.md": "@team/docs" }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const parseCodeowners: (lines: Array<string>) => Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Converts a full team handle (potentially namespaced and with platform suffix)
|
|
24
|
+
* into its “short” team name.
|
|
25
|
+
*
|
|
26
|
+
* - Strips any leading `@org/` prefix
|
|
27
|
+
* - Removes `-be` or `-fe` suffix if present
|
|
28
|
+
*
|
|
29
|
+
* @param {string} teamName - e.g. `"@trackunit/backend-be"` or `"@trackunit/frontend-fe"`
|
|
30
|
+
* @returns {string} e.g. `"backend"` or `"frontend"`
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* toShortTeamName("@trackunit/backend-be"); // → "backend"
|
|
34
|
+
* toShortTeamName("@trackunit/frontend-fe"); // → "frontend"
|
|
35
|
+
* toShortTeamName("infra"); // → "infra"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const toShortTeamName: (teamName?: string) => string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Recursively looks up the CODEOWNER for a given file or directory path
|
|
41
|
+
* by reading your workspace’s CODEOWNERS file.
|
|
42
|
+
*
|
|
43
|
+
* Walks up the directory tree until it finds a matching pattern. If no
|
|
44
|
+
* deeper match is found but there is a `"."` entry, returns that.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} currentPath - Absolute path to the file/directory you’re querying.
|
|
47
|
+
* @param {string} workspaceRoot - Absolute path to your repo/workspace root.
|
|
48
|
+
* @param {string} [codeownersFileName="TEAM_CODEOWNERS"] - Filename to read at the root.
|
|
49
|
+
* @returns {string|undefined} The owner handle (e.g. `"@team/backend"`) or `undefined` if none found.
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // Suppose your repo root has a TEAM_CODEOWNERS file containing:
|
|
53
|
+
* // src @team/backend
|
|
54
|
+
* // src/utils @team/utils
|
|
55
|
+
* // . @team/root
|
|
56
|
+
*
|
|
57
|
+
* const owner1 = getCodeowner(
|
|
58
|
+
* "/Users/alice/project/src/utils/helpers.ts",
|
|
59
|
+
* "/Users/alice/project"
|
|
60
|
+
* );
|
|
61
|
+
* // → "@team/utils"
|
|
62
|
+
*
|
|
63
|
+
* const owner2 = getCodeowner(
|
|
64
|
+
* "/Users/alice/project/other/file.txt",
|
|
65
|
+
* "/Users/alice/project"
|
|
66
|
+
* );
|
|
67
|
+
* // → "@team/root" (falls back to the "." entry)
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare const getCodeowner: (currentPath: string, workspaceRoot: string, codeownersFileName?: string) => string | undefined;
|