@travetto/repo 7.0.0-rc.1 → 7.0.0-rc.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/repo",
3
- "version": "7.0.0-rc.1",
3
+ "version": "7.0.0-rc.2",
4
4
  "description": "Monorepo utilities",
5
5
  "keywords": [
6
6
  "travetto",
@@ -22,8 +22,8 @@
22
22
  "directory": "module/repo"
23
23
  },
24
24
  "dependencies": {
25
- "@travetto/cli": "^7.0.0-rc.1",
26
- "@travetto/worker": "^7.0.0-rc.1"
25
+ "@travetto/cli": "^7.0.0-rc.2",
26
+ "@travetto/worker": "^7.0.0-rc.2"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "@travetto/cli": {
@@ -11,7 +11,7 @@ const COLORS = ([...[
11
11
  '#afffd7', '#afffff', '#d787ff', '#d7afaf', '#d7afd7', '#d7afff', '#d7d7af', '#d7d7d7', '#d7d7ff', '#d7ff87', '#d7ffaf', '#d7ffd7', '#d7ffff', '#ff8787', '#ff87af',
12
12
  '#ff87d7', '#ff87ff', '#ffaf87', '#ffafaf', '#ffafd7', '#ffafff', '#ffd787', '#ffd7af', '#ffd7d7', '#ffd7ff', '#ffff87', '#ffffaf', '#ffffd7', '#ffffff', '#bcbcbc',
13
13
  '#c6c6c6', '#d0d0d0', '#dadada', '#e4e4e4', '#eeeeee'
14
- ] as const]).toSorted(() => Math.random() < .5 ? -1 : 1).map(x => StyleUtil.getStyle(x));
14
+ ] as const]).toSorted(() => Math.random() < .5 ? -1 : 1).map(color => StyleUtil.getStyle(color));
15
15
 
16
16
  type ModuleRunConfig<T = ExecutionResult<string>> = {
17
17
  progressMessage?: (mod: IndexedModule | undefined) => string;
@@ -24,7 +24,7 @@ type ModuleRunConfig<T = ExecutionResult<string>> = {
24
24
  stableOutput?: boolean;
25
25
  };
26
26
 
27
- const colorize = (val: string, idx: number): string => COLORS[idx % COLORS.length](val);
27
+ const colorize = (value: string, idx: number): string => COLORS[idx % COLORS.length](value);
28
28
 
29
29
  /**
30
30
  * Tools for running commands across all modules of the monorepo
@@ -37,9 +37,9 @@ export class RepoExecUtil {
37
37
  * @returns
38
38
  */
39
39
  static #buildPrefixes(mods: IndexedModule[]): Record<string, string> {
40
- const folders = mods.map(x => x.sourceFolder);
41
- const maxWidth = Math.max(...folders.map(x => x.length));
42
- return Object.fromEntries(folders.map((x, i) => [x, colorize(x.padStart(maxWidth, ' ').padEnd(maxWidth + 1), i)]));
40
+ const folders = mods.map(mod => mod.sourceFolder);
41
+ const maxWidth = Math.max(...folders.map(folder => folder.length));
42
+ return Object.fromEntries(folders.map((folder, i) => [folder, colorize(folder.padStart(maxWidth, ' ').padEnd(maxWidth + 1), i)]));
43
43
  }
44
44
 
45
45
  /**
@@ -69,21 +69,21 @@ export class RepoExecUtil {
69
69
  try {
70
70
  if (!(await config.filter?.(mod) === false)) {
71
71
  const prefix = prefixes[mod.sourceFolder] ?? '';
72
- const proc = operation(mod);
73
- processes.set(mod, proc);
72
+ const subProcess = operation(mod);
73
+ processes.set(mod, subProcess);
74
74
 
75
- if (config.showStdout && proc.stdout) {
76
- ExecUtil.readLines(proc.stdout, line =>
75
+ if (config.showStdout && subProcess.stdout) {
76
+ ExecUtil.readLines(subProcess.stdout, line =>
77
77
  stdoutTerm.writer.writeLine(`${prefix}${line.trimEnd()}`).commit()
78
78
  );
79
79
  }
80
- if (config.showStderr && proc.stderr) {
81
- ExecUtil.readLines(proc.stderr, line =>
80
+ if (config.showStderr && subProcess.stderr) {
81
+ ExecUtil.readLines(subProcess.stderr, line =>
82
82
  stderrTerm.writer.writeLine(`${prefix}${line.trimEnd()}`).commit()
83
83
  );
84
84
  }
85
85
 
86
- const result = await ExecUtil.getResult(proc, { catch: true });
86
+ const result = await ExecUtil.getResult(subProcess, { catch: true });
87
87
  const output = transform(mod, result);
88
88
  results.set(mod, output);
89
89
  }
@@ -94,7 +94,7 @@ export class RepoExecUtil {
94
94
  }, mods, mods.length, { max: workerCount, min: workerCount });
95
95
 
96
96
  if (config.progressMessage && stdoutTerm.interactive) {
97
- await stdoutTerm.streamToBottom(Util.mapAsyncItr(work, TerminalUtil.progressBarUpdater(stdoutTerm, { withWaiting: true })));
97
+ await stdoutTerm.streamToBottom(Util.mapAsyncIterable(work, TerminalUtil.progressBarUpdater(stdoutTerm, { withWaiting: true })));
98
98
  } else {
99
99
  for await (const _ of work) {
100
100
  // Ensure its all consumed
@@ -55,7 +55,7 @@ export class PackageManager {
55
55
  * Setting the version
56
56
  */
57
57
  static async version(ctx: Ctx, modules: IndexedModule[], level: SemverLevel, preid?: string): Promise<void> {
58
- const mods = modules.flatMap(m => ['-w', m.sourceFolder]);
58
+ const mods = modules.flatMap(mod => ['-w', mod.sourceFolder]);
59
59
  let args: string[];
60
60
  switch (ctx.workspace.manager) {
61
61
  case 'npm':
@@ -116,7 +116,7 @@ export class PackageManager {
116
116
  */
117
117
  static async synchronizeVersions(): Promise<Record<string, string>> {
118
118
  const versions: Record<string, string> = {};
119
- const folders = (await CliModuleUtil.findModules('workspace')).map(x => x.sourcePath);
119
+ const folders = (await CliModuleUtil.findModules('workspace')).map(mod => mod.sourcePath);
120
120
  const packages = folders.map(folder => {
121
121
  const pkg = PackageUtil.readPackage(folder, true);
122
122
  versions[pkg.name] = `^${pkg.version}`;
@@ -1,7 +1,7 @@
1
1
  import { CliCommandShape, CliCommand, CliModuleUtil } from '@travetto/cli';
2
2
  import { Runtime, RuntimeIndex } from '@travetto/runtime';
3
3
 
4
- const write = (line: string): Promise<void> => new Promise(r => process.stdout.write(`${line}\n`, () => r()));
4
+ const write = (line: string): Promise<void> => new Promise(resolve => process.stdout.write(`${line}\n`, () => resolve()));
5
5
 
6
6
  /**
7
7
  * Allows for listing of modules
@@ -32,8 +32,8 @@ export class ListModuleCommand implements CliCommandShape {
32
32
  const mods = await CliModuleUtil.findModules(this.changed ? 'changed' : 'workspace', this.fromHash, this.toHash);
33
33
  switch (this.format) {
34
34
  case 'list': {
35
- for (const mod of mods.map(x => x.sourceFolder).toSorted()) {
36
- await write(mod);
35
+ for (const folder of mods.map(mod => mod.sourceFolder).toSorted()) {
36
+ await write(folder);
37
37
  }
38
38
  break;
39
39
  }
@@ -45,10 +45,10 @@ export class ListModuleCommand implements CliCommandShape {
45
45
  }
46
46
  case 'graph': {
47
47
  await write('digraph g {');
48
- for (const el of mods) {
49
- for (const dep of el.parents) {
50
- if (dep !== Runtime.main.name) {
51
- await write(` "${dep}" -> "${el.name}";`);
48
+ for (const mod of mods) {
49
+ for (const parent of mod.parents) {
50
+ if (parent !== Runtime.main.name) {
51
+ await write(` "${parent}" -> "${mod.name}";`);
52
52
  }
53
53
  }
54
54
  }
@@ -18,11 +18,11 @@ export class RepoPublishCommand implements CliCommandShape {
18
18
  filter: mod => !!mod.workspace && !mod.internal,
19
19
  progressMessage: (mod) => `Checking published [%idx/%total] -- ${mod?.name}`,
20
20
  showStderr: false,
21
- transformResult: (mod, res) => PackageManager.validatePublishedResult(Runtime, mod, res),
21
+ transformResult: (mod, result) => PackageManager.validatePublishedResult(Runtime, mod, result),
22
22
  });
23
23
 
24
24
  if (this.dryRun) {
25
- console.log('Unpublished modules', [...published.entries()].filter(x => !x[1]).map(([mod]) => mod.sourceFolder));
25
+ console.log('Unpublished modules', [...published.entries()].filter(entry => !entry[1]).map(([mod]) => mod.sourceFolder));
26
26
  }
27
27
 
28
28
  await RepoExecUtil.execOnModules(
@@ -39,7 +39,7 @@ export class RepoVersionCommand implements CliCommandShape {
39
39
 
40
40
  const allModules = await CliModuleUtil.findModules(mode);
41
41
 
42
- const modules = allModules.filter(x => !x.internal && (this.mode !== 'direct' || this.modules?.includes(x.name)));
42
+ const modules = allModules.filter(mod => !mod.internal && (this.mode !== 'direct' || this.modules?.includes(mod.name)));
43
43
 
44
44
  // Do we have valid changes?
45
45
  if (!modules.length) {
@@ -50,7 +50,7 @@ export class RepoVersionCommand implements CliCommandShape {
50
50
 
51
51
  const versions = await PackageManager.synchronizeVersions();
52
52
  if (this.commit) {
53
- const commitMessage = `Publish ${modules.map(x => `${x.name}#${versions[x.name]?.replace('^', '') ?? x.version}`).join(',')}`;
53
+ const commitMessage = `Publish ${modules.map(mod => `${mod.name}#${versions[mod.name]?.replace('^', '') ?? mod.version}`).join(',')}`;
54
54
  console.log!(await CliScmUtil.createCommit(commitMessage));
55
55
  if (this.tag) {
56
56
  await CliScmUtil.createTag(versions['@travetto/manifest']);