@travetto/repo 8.0.0-alpha.23 → 8.0.0-alpha.24

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/README.md CHANGED
@@ -13,14 +13,14 @@ npm install @travetto/repo
13
13
  yarn add @travetto/repo
14
14
  ```
15
15
 
16
- The repo module aims to provide concise monorepo based tools. The monorepo support within the [Travetto](https://travetto.dev) framework, is backed by the built in functionality of [Npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)/[Yarn](https://yarnpkg.com). This module is not a requirement for monorepo support, but provides some quality of life improvements for:
16
+ The repo module aims to provide concise monorepo based tools. The monorepo support within the [Travetto](https://travetto.dev) framework, is backed by the built in functionality of [Npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)/[Yarn](https://yarnpkg.com). This module is not a requirement for monorepo support, but provides some quality of life improvements for:
17
17
  * Versioning releases
18
18
  * Publishing releases
19
19
  * Listing local modules
20
20
  * Running commands on all workspace modules
21
21
 
22
22
  ## CLI - repo:version
23
- The versioning operation will find all the changed modules (and the modules that depend on the changed), and will update the versions in accordance with the user preferences. The versioning logic is backed by [Npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)/[Yarn](https://yarnpkg.com)'s versioning functionality and so it is identical to using the tool manually. The determination of what has or hasn't changed is relative to the last versioning commit.
23
+ The versioning operation will find all the changed modules (and the modules that depend on the changed), and will update the versions in accordance with the user preferences. The versioning logic is backed by [Npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)/[Yarn](https://yarnpkg.com)'s versioning functionality and so it is identical to using the tool manually. The determination of what has or hasn't changed is relative to the last versioning commit.
24
24
 
25
25
  **Terminal: Help for repo:version**
26
26
  ```bash
@@ -43,7 +43,7 @@ Options:
43
43
  --help display help for command
44
44
  ```
45
45
 
46
- Level is a standard semver level of: major, minor, patch or prerelease. The prefix argument only applies to the prerelease and allows for determining the prerelease level. For example:
46
+ Level is a standard semver level of: major, minor, patch or prerelease. The prefix argument only applies to the prerelease and allows for determining the prerelease level. For example:
47
47
 
48
48
  **Terminal: Cutting a release candidate**
49
49
  ```bash
@@ -63,7 +63,7 @@ Date: Thu Feb 23 17:51:37 2023 -0500
63
63
  ```
64
64
 
65
65
  ## CLI - repo:publish
66
- The publish functionality is relatively naive, but consistent. The code will look at all modules in the mono-repo and check the listed version against what is available in the npm registry. If the local version is newer, it is a candidate for publishing.
66
+ The publish functionality is relatively naive, but consistent. The code will look at all modules in the mono-repo and check the listed version against what is available in the npm registry. If the local version is newer, it is a candidate for publishing.
67
67
 
68
68
  **Terminal: Help for repo:publish**
69
69
  ```bash
@@ -145,8 +145,8 @@ module/email
145
145
  module/email-compiler
146
146
  module/email-inky
147
147
  module/email-nodemailer
148
- module/eslint
149
148
  module/image
149
+ module/lint
150
150
  module/llm-support
151
151
  module/log
152
152
  module/manifest
@@ -237,8 +237,8 @@ global-test/model_auth-session <workspace-root>/global-test/model_auth-session
237
237
  module/email-compiler <workspace-root>/module/email-compiler
238
238
  module/email-inky <workspace-root>/module/email-inky
239
239
  module/email-nodemailer <workspace-root>/module/email-nodemailer
240
- module/eslint <workspace-root>/module/eslint
241
240
  module/image <workspace-root>/module/image
241
+ module/lint <workspace-root>/module/lint
242
242
  module/llm-support <workspace-root>/module/llm-support
243
243
  module/log <workspace-root>/module/log
244
244
  module/manifest <workspace-root>/module/manifest
package/__index__.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from './support/bin/exec.ts';
2
- export * from './support/bin/package-manager.ts';
2
+ export * from './support/bin/package-manager.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/repo",
3
- "version": "8.0.0-alpha.23",
3
+ "version": "8.0.0-alpha.24",
4
4
  "type": "module",
5
5
  "description": "Monorepo utilities",
6
6
  "keywords": [
@@ -23,10 +23,10 @@
23
23
  "directory": "module/repo"
24
24
  },
25
25
  "dependencies": {
26
- "@travetto/worker": "^8.0.0-alpha.19"
26
+ "@travetto/worker": "^8.0.0-alpha.20"
27
27
  },
28
28
  "peerDependencies": {
29
- "@travetto/cli": "^8.0.0-alpha.26"
29
+ "@travetto/cli": "^8.0.0-alpha.28"
30
30
  },
31
31
  "peerDependenciesMeta": {
32
32
  "@travetto/cli": {
@@ -1,17 +1,67 @@
1
1
  import type { ChildProcess } from 'node:child_process';
2
2
 
3
- import { type ExecutionResult, Env, Util, ExecUtil, CodecUtil, Runtime, RuntimeIndex, AsyncQueue } from '@travetto/runtime';
4
3
  import { CliModuleUtil } from '@travetto/cli';
5
4
  import type { IndexedModule } from '@travetto/manifest';
6
- import { StyleUtil, Terminal, TerminalUtil, type ProgressEvent } from '@travetto/terminal';
5
+ import { AsyncQueue, CodecUtil, Env, ExecUtil, type ExecutionResult, Runtime, RuntimeIndex, Util } from '@travetto/runtime';
6
+ import { type ProgressEvent, StyleUtil, Terminal, TerminalUtil } from '@travetto/terminal';
7
7
  import { WorkPool } from '@travetto/worker';
8
8
 
9
- const COLORS = ([...[
10
- '#8787ff', '#87afff', '#87d7ff', '#87ff87', '#87ffaf', '#87ffd7', '#87ffff', '#af87ff', '#afafd7', '#afafff', '#afd7af', '#afd7d7', '#afd7ff', '#afff87', '#afffaf',
11
- '#afffd7', '#afffff', '#d787ff', '#d7afaf', '#d7afd7', '#d7afff', '#d7d7af', '#d7d7d7', '#d7d7ff', '#d7ff87', '#d7ffaf', '#d7ffd7', '#d7ffff', '#ff8787', '#ff87af',
12
- '#ff87d7', '#ff87ff', '#ffaf87', '#ffafaf', '#ffafd7', '#ffafff', '#ffd787', '#ffd7af', '#ffd7d7', '#ffd7ff', '#ffff87', '#ffffaf', '#ffffd7', '#ffffff', '#bcbcbc',
13
- '#c6c6c6', '#d0d0d0', '#dadada', '#e4e4e4', '#eeeeee'
14
- ] as const]).toSorted(() => Math.random() < .5 ? -1 : 1).map(color => StyleUtil.getStyle(color));
9
+ const COLORS = [
10
+ ...([
11
+ '#8787ff',
12
+ '#87afff',
13
+ '#87d7ff',
14
+ '#87ff87',
15
+ '#87ffaf',
16
+ '#87ffd7',
17
+ '#87ffff',
18
+ '#af87ff',
19
+ '#afafd7',
20
+ '#afafff',
21
+ '#afd7af',
22
+ '#afd7d7',
23
+ '#afd7ff',
24
+ '#afff87',
25
+ '#afffaf',
26
+ '#afffd7',
27
+ '#afffff',
28
+ '#d787ff',
29
+ '#d7afaf',
30
+ '#d7afd7',
31
+ '#d7afff',
32
+ '#d7d7af',
33
+ '#d7d7d7',
34
+ '#d7d7ff',
35
+ '#d7ff87',
36
+ '#d7ffaf',
37
+ '#d7ffd7',
38
+ '#d7ffff',
39
+ '#ff8787',
40
+ '#ff87af',
41
+ '#ff87d7',
42
+ '#ff87ff',
43
+ '#ffaf87',
44
+ '#ffafaf',
45
+ '#ffafd7',
46
+ '#ffafff',
47
+ '#ffd787',
48
+ '#ffd7af',
49
+ '#ffd7d7',
50
+ '#ffd7ff',
51
+ '#ffff87',
52
+ '#ffffaf',
53
+ '#ffffd7',
54
+ '#ffffff',
55
+ '#bcbcbc',
56
+ '#c6c6c6',
57
+ '#d0d0d0',
58
+ '#dadada',
59
+ '#e4e4e4',
60
+ '#eeeeee'
61
+ ] as const)
62
+ ]
63
+ .toSorted(() => (Math.random() < 0.5 ? -1 : 1))
64
+ .map(color => StyleUtil.getStyle(color));
15
65
 
16
66
  type ModuleRunConfig = {
17
67
  progressMessage?: (module: IndexedModule | undefined) => string;
@@ -33,7 +83,6 @@ const colorize = (value: string, idx: number): string => COLORS[idx % COLORS.len
33
83
  * Tools for running commands across all modules of the monorepo
34
84
  */
35
85
  export class RepoExecUtil {
36
-
37
86
  /**
38
87
  * Build equal sized prefix labels for outputting
39
88
  * @param modules
@@ -53,7 +102,6 @@ export class RepoExecUtil {
53
102
  operation: (module: IndexedModule) => ChildProcess,
54
103
  config: ModuleRunConfig = {}
55
104
  ): Promise<Map<IndexedModule, ExecutionResult>> {
56
-
57
105
  config.showStdout = config.showStdout ?? (Env.DEBUG.isSet && !Env.DEBUG.isFalse);
58
106
  config.showStderr = config.showStderr ?? true;
59
107
 
@@ -72,58 +120,61 @@ export class RepoExecUtil {
72
120
  }
73
121
 
74
122
  const active = new Set<string>();
75
- const activeItems = new AsyncQueue<{ idx: number, text: string }>();
123
+ const activeItems = new AsyncQueue<{ idx: number; text: string }>();
76
124
  const listHeader = ['', 'Modules in progress', '-------------------'];
77
125
 
78
126
  if (stdoutTerm.interactive && config.showProgressList) {
79
127
  stdoutTerm.writer.writeLines(listHeader).commit();
80
128
  }
81
129
 
82
- const modulesToRun = (config.filter ? await Promise.all(
83
- modules.map(async module => (await config.filter!(module)) ? module : undefined)
84
- ) : modules)
85
- .filter((module): module is IndexedModule => !!module);
86
-
87
- const work = WorkPool.runStream<IndexedModule, ExecutionResult>(async (module) => {
88
- try {
89
- const prefix = prefixes[module.sourceFolder] ?? '';
90
- const listKey = config.progressListKey?.(module) ?? ` * ${module.name}`;
91
- active.add(listKey);
92
- [...active].sort().forEach((text, idx) => activeItems.add({ idx, text }));
93
-
94
- const subProcess = operation(module);
95
- processes.set(module, subProcess);
96
-
97
- if (config.showStdout && subProcess.stdout) {
98
- CodecUtil.readLines(subProcess.stdout, line =>
99
- stdoutTerm.writer.writeLine(`${prefix}${line.trimEnd()}`).commit()
100
- );
130
+ const modulesToRun = (
131
+ config.filter ? await Promise.all(modules.map(async module => ((await config.filter!(module)) ? module : undefined))) : modules
132
+ ).filter((module): module is IndexedModule => !!module);
133
+
134
+ const work = WorkPool.runStream<IndexedModule, ExecutionResult>(
135
+ async module => {
136
+ try {
137
+ const prefix = prefixes[module.sourceFolder] ?? '';
138
+ const listKey = config.progressListKey?.(module) ?? ` * ${module.name}`;
139
+ active.add(listKey);
140
+ [...active].sort().forEach((text, idx) => {
141
+ activeItems.add({ idx, text });
142
+ });
143
+
144
+ const subProcess = operation(module);
145
+ processes.set(module, subProcess);
146
+
147
+ if (config.showStdout && subProcess.stdout) {
148
+ CodecUtil.readLines(subProcess.stdout, line => stdoutTerm.writer.writeLine(`${prefix}${line.trimEnd()}`).commit());
149
+ }
150
+ if (config.showStderr && subProcess.stderr) {
151
+ CodecUtil.readLines(subProcess.stderr, line => stderrTerm.writer.writeLine(`${prefix}${line.trimEnd()}`).commit());
152
+ }
153
+
154
+ const result = await ExecUtil.getResult(subProcess, { catch: true });
155
+
156
+ active.delete(listKey);
157
+ [...active].sort().forEach((text, idx) => {
158
+ activeItems.add({ idx, text });
159
+ });
160
+ for (let j = active.size; j < workerCount; j++) {
161
+ activeItems.add({ idx: j, text: '' }); // Force update to remove item if needed
162
+ }
163
+
164
+ results.set(module, result);
165
+ return result;
166
+ } finally {
167
+ processes.get(module!)?.kill();
101
168
  }
102
- if (config.showStderr && subProcess.stderr) {
103
- CodecUtil.readLines(subProcess.stderr, line =>
104
- stderrTerm.writer.writeLine(`${prefix}${line.trimEnd()}`).commit()
105
- );
106
- }
107
-
108
- const result = await ExecUtil.getResult(subProcess, { catch: true });
109
-
110
- active.delete(listKey);
111
- [...active].sort().forEach((text, idx) => activeItems.add({ idx, text }));
112
- for (let j = active.size; j < workerCount; j++) {
113
- activeItems.add({ idx: j, text: '' }); // Force update to remove item if needed
114
- }
115
-
116
- results.set(module, result);
117
- return result;
118
- } finally {
119
- processes.get(module!)?.kill();
169
+ },
170
+ modulesToRun,
171
+ {
172
+ max: workerCount,
173
+ min: workerCount,
174
+ total: modules.length,
175
+ isSuccess: config.isSuccess ?? ((result: ExecutionResult): boolean => result.valid)
120
176
  }
121
- }, modulesToRun, {
122
- max: workerCount,
123
- min: workerCount,
124
- total: modules.length,
125
- isSuccess: config.isSuccess ?? ((result: ExecutionResult): boolean => result.valid),
126
- });
177
+ );
127
178
 
128
179
  if (config.progressMessage && stdoutTerm.interactive) {
129
180
  if (config.showProgressList) {
@@ -132,14 +183,21 @@ export class RepoExecUtil {
132
183
  await stdoutTerm.streamToBottom(
133
184
  Util.mapAsyncIterable(
134
185
  Util.mapAsyncIterable(work, (event): ProgressEvent<string> => {
135
- const message = config.progressMessage?.(modulesToRun[event.progress.completed]) ?? 'Completed %completed/%total (%failed failed)';
186
+ const message =
187
+ config.progressMessage?.(modulesToRun[event.progress.completed]) ?? 'Completed %completed/%total (%failed failed)';
136
188
  return { ...event.progress, value: message };
137
189
  }),
138
- TerminalUtil.progressBarUpdater(stdoutTerm, { withWaiting: true }))
190
+ TerminalUtil.progressBarUpdater(stdoutTerm, { withWaiting: true })
191
+ )
139
192
  );
140
193
 
141
194
  if (stdoutTerm.interactive && config.showProgressList) {
142
- stdoutTerm.writer.changePosition({ y: -listHeader.length, x: 0 }).storePosition().writeLines(Array(listHeader.length).fill('')).restoreOnCommit().commit();
195
+ stdoutTerm.writer
196
+ .changePosition({ y: -listHeader.length, x: 0 })
197
+ .storePosition()
198
+ .writeLines(Array(listHeader.length).fill(''))
199
+ .restoreOnCommit()
200
+ .commit();
143
201
  }
144
202
  } else {
145
203
  for await (const _ of work) {
@@ -149,4 +207,4 @@ export class RepoExecUtil {
149
207
 
150
208
  return results;
151
209
  }
152
- }
210
+ }
@@ -1,10 +1,10 @@
1
- import path from 'node:path';
2
- import { spawn, type ChildProcess } from 'node:child_process';
1
+ import { type ChildProcess, spawn } from 'node:child_process';
3
2
  import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
4
 
5
- import { JSONUtil, type ExecutionResult, Runtime, ExecUtil } from '@travetto/runtime';
6
- import { type IndexedModule, type Package, PackageUtil } from '@travetto/manifest';
7
5
  import { CliModuleUtil } from '@travetto/cli';
6
+ import { type IndexedModule, type Package, PackageUtil } from '@travetto/manifest';
7
+ import { ExecUtil, type ExecutionResult, JSONUtil, Runtime } from '@travetto/runtime';
8
8
  import { TerminalUtil } from '@travetto/terminal';
9
9
 
10
10
  export type SemverLevel = 'minor' | 'patch' | 'major' | 'prerelease' | 'premajor' | 'preminor' | 'prepatch';
@@ -13,7 +13,6 @@ export type SemverLevel = 'minor' | 'patch' | 'major' | 'prerelease' | 'premajor
13
13
  * Utilities for working with package managers
14
14
  */
15
15
  export class PackageManager {
16
-
17
16
  /**
18
17
  * Check if npm login is needed
19
18
  */
@@ -43,10 +42,12 @@ export class PackageManager {
43
42
  */
44
43
  static async requestOtp(): Promise<string | undefined> {
45
44
  if (TerminalUtil.isInteractive()) {
46
- console.log([
47
- 'OTP token is required for publishing. Please provide an OTP token to proceed with publishing.',
48
- 'This value will not be stored, and is only used for the current publish operation.'
49
- ].join(' '));
45
+ console.log(
46
+ [
47
+ 'OTP token is required for publishing. Please provide an OTP token to proceed with publishing.',
48
+ 'This value will not be stored, and is only used for the current publish operation.'
49
+ ].join(' ')
50
+ );
50
51
  return await TerminalUtil.prompt('Enter OTP token: ');
51
52
  }
52
53
  }
@@ -81,7 +82,9 @@ export class PackageManager {
81
82
  switch (Runtime.workspace.manager) {
82
83
  case 'npm':
83
84
  case 'yarn':
84
- case 'pnpm': args = ['info', `${module.name}@${module.version}`, '--json']; break;
85
+ case 'pnpm':
86
+ args = ['info', `${module.name}@${module.version}`, '--json'];
87
+ break;
85
88
  }
86
89
  return spawn(Runtime.workspace.manager, args, { cwd: module.sourceFolder });
87
90
  }
@@ -98,7 +101,8 @@ export class PackageManager {
98
101
  const stdout = ExecUtil.toString(result, 'stdout');
99
102
  type PackageInfo = { dist?: { integrity?: string } };
100
103
  let parsed = JSONUtil.fromUTF8<PackageInfo | { data: PackageInfo }>(stdout || '{}');
101
- if ('data' in parsed) { // Yarn support
104
+ if ('data' in parsed) {
105
+ // Yarn support
102
106
  parsed = parsed.data;
103
107
  }
104
108
  return parsed.dist?.integrity !== undefined;
@@ -113,7 +117,9 @@ export class PackageManager {
113
117
  switch (Runtime.workspace.manager) {
114
118
  case 'npm':
115
119
  case 'yarn':
116
- case 'pnpm': args = ['version', '--no-workspaces-update', level, ...(preid ? ['--preid', preid] : [])]; break;
120
+ case 'pnpm':
121
+ args = ['version', '--no-workspaces-update', level, ...(preid ? ['--preid', preid] : [])];
122
+ break;
117
123
  }
118
124
  return spawn(Runtime.workspace.manager, [...args, ...moduleArgs], { cwd: Runtime.workspace.path, stdio: 'inherit' });
119
125
  }
@@ -126,7 +132,9 @@ export class PackageManager {
126
132
  switch (Runtime.workspace.manager) {
127
133
  case 'npm':
128
134
  case 'yarn':
129
- case 'pnpm': args = ['pack', '--dry-run']; break;
135
+ case 'pnpm':
136
+ args = ['pack', '--dry-run'];
137
+ break;
130
138
  }
131
139
  return spawn(Runtime.workspace.manager, args, { cwd: module.sourcePath });
132
140
  }
@@ -144,7 +152,9 @@ export class PackageManager {
144
152
  switch (Runtime.workspace.manager) {
145
153
  case 'npm':
146
154
  case 'yarn':
147
- case 'pnpm': args = ['publish', '--tag', versionTag, '--access', 'public', ...(otp ? ['--otp', otp] : [])]; break;
155
+ case 'pnpm':
156
+ args = ['publish', '--tag', versionTag, '--access', 'public', ...(otp ? ['--otp', otp] : [])];
157
+ break;
148
158
  }
149
159
  return spawn(Runtime.workspace.manager, args, { cwd: module.sourcePath });
150
160
  }
@@ -174,12 +184,7 @@ export class PackageManager {
174
184
  });
175
185
 
176
186
  for (const { pkg } of packages) {
177
- for (const group of [
178
- pkg.dependencies ?? {},
179
- pkg.devDependencies ?? {},
180
- pkg.optionalDependencies ?? {},
181
- pkg.peerDependencies ?? {}
182
- ]) {
187
+ for (const group of [pkg.dependencies ?? {}, pkg.devDependencies ?? {}, pkg.optionalDependencies ?? {}, pkg.peerDependencies ?? {}]) {
183
188
  for (const [module, ver] of Object.entries(versions)) {
184
189
  if (module in group && !/^[*]|(file:.*)$/.test(group[module])) {
185
190
  group[module] = ver;
@@ -194,4 +199,4 @@ export class PackageManager {
194
199
 
195
200
  return versions;
196
201
  }
197
- }
202
+ }
@@ -1,9 +1,9 @@
1
1
  import { spawn } from 'node:child_process';
2
2
 
3
- import { CliCommand, CliParseUtil, type CliCommandShape } from '@travetto/cli';
4
- import { WorkPool } from '@travetto/worker';
3
+ import { CliCommand, type CliCommandShape, CliParseUtil } from '@travetto/cli';
5
4
  import { Env } from '@travetto/runtime';
6
5
  import { Max, Min } from '@travetto/schema';
6
+ import { WorkPool } from '@travetto/worker';
7
7
 
8
8
  import { RepoExecUtil } from './bin/exec.ts';
9
9
 
@@ -15,12 +15,12 @@ import { RepoExecUtil } from './bin/exec.ts';
15
15
  */
16
16
  @CliCommand()
17
17
  export class RepoExecCommand implements CliCommandShape {
18
-
19
18
  /** Only changed modules */
20
19
  changed = false;
21
20
 
22
21
  /** Number of concurrent workers */
23
- @Min(1) @Max(WorkPool.MAX_SIZE)
22
+ @Min(1)
23
+ @Max(WorkPool.MAX_SIZE)
24
24
  workers = WorkPool.DEFAULT_SIZE;
25
25
 
26
26
  /** Prefix output by folder */
@@ -35,23 +35,24 @@ export class RepoExecCommand implements CliCommandShape {
35
35
 
36
36
  async main(cmd: string, args: string[] = []): Promise<void> {
37
37
  const parsed = CliParseUtil.getState(this);
38
- const finalArgs = [...args, ...parsed?.unknown ?? []];
38
+ const finalArgs = [...args, ...(parsed?.unknown ?? [])];
39
39
 
40
40
  await RepoExecUtil.execOnModules(
41
41
  this.changed ? 'changed' : 'workspace',
42
- module => spawn(cmd, finalArgs, {
43
- cwd: module.sourceFolder,
44
- env: {
45
- ...process.env,
46
- ...Env.TRV_MODULE.export(module.name),
47
- ...Env.TRV_MANIFEST.export(undefined)
48
- }
49
- }),
42
+ module =>
43
+ spawn(cmd, finalArgs, {
44
+ cwd: module.sourceFolder,
45
+ env: {
46
+ ...process.env,
47
+ ...Env.TRV_MODULE.export(module.name),
48
+ ...Env.TRV_MANIFEST.export(undefined)
49
+ }
50
+ }),
50
51
  {
51
52
  progressMessage: module => `Running '${cmd} ${finalArgs.join(' ')}' [%completed/%total] ${module?.sourceFolder ?? ''}`,
52
53
  showStdout: this.showStdout,
53
54
  prefixOutput: this.prefixOutput,
54
- workerCount: this.workers,
55
+ workerCount: this.workers
55
56
  }
56
57
  );
57
58
  }
@@ -1,4 +1,4 @@
1
- import { type CliCommandShape, CliCommand, CliModuleUtil } from '@travetto/cli';
1
+ import { CliCommand, type CliCommandShape, CliModuleUtil } from '@travetto/cli';
2
2
  import { JSONUtil, Runtime, RuntimeIndex } from '@travetto/runtime';
3
3
 
4
4
  const write = (line: string): Promise<void> => new Promise(resolve => process.stdout.write(`${line}\n`, () => resolve()));
@@ -11,7 +11,6 @@ const write = (line: string): Promise<void> => new Promise(resolve => process.st
11
11
  */
12
12
  @CliCommand()
13
13
  export class ListModuleCommand implements CliCommandShape {
14
-
15
14
  /** Only show changed modules */
16
15
  changed = false;
17
16
 
@@ -31,7 +30,6 @@ export class ListModuleCommand implements CliCommandShape {
31
30
  toHash?: string;
32
31
 
33
32
  async main(): Promise<void> {
34
-
35
33
  const modules = await CliModuleUtil.findModules(this.changed ? 'changed' : 'workspace', this.fromHash, this.toHash);
36
34
  switch (this.format) {
37
35
  case 'list': {
@@ -42,11 +40,12 @@ export class ListModuleCommand implements CliCommandShape {
42
40
  }
43
41
  case 'json': {
44
42
  const outputMap = CliModuleUtil.getDependencyGraph(modules);
45
- await write(JSONUtil.toUTF8(
46
- Object.entries(outputMap)
47
- .map(([name, children]) => ({ name, children, workspace: RuntimeIndex.getModule(name)?.workspace })),
48
- { indent: 2 }
49
- ));
43
+ await write(
44
+ JSONUtil.toUTF8(
45
+ Object.entries(outputMap).map(([name, children]) => ({ name, children, workspace: RuntimeIndex.getModule(name)?.workspace })),
46
+ { indent: 2 }
47
+ )
48
+ );
50
49
  break;
51
50
  }
52
51
  case 'graph': {
@@ -63,4 +62,4 @@ export class ListModuleCommand implements CliCommandShape {
63
62
  }
64
63
  }
65
64
  }
66
- }
65
+ }
@@ -1,8 +1,8 @@
1
- import { type CliCommandShape, CliCommand, cliTpl } from '@travetto/cli';
1
+ import { CliCommand, type CliCommandShape, cliTpl } from '@travetto/cli';
2
2
  import { RuntimeError } from '@travetto/runtime';
3
3
 
4
- import { PackageManager } from './bin/package-manager.ts';
5
4
  import { RepoExecUtil } from './bin/exec.ts';
5
+ import { PackageManager } from './bin/package-manager.ts';
6
6
 
7
7
  /**
8
8
  * Publish unpublished workspace modules to the package registry.
@@ -12,7 +12,6 @@ import { RepoExecUtil } from './bin/exec.ts';
12
12
  */
13
13
  @CliCommand()
14
14
  export class RepoPublishCommand implements CliCommandShape {
15
-
16
15
  /** Dry Run? */
17
16
  dryRun = true;
18
17
 
@@ -22,7 +21,7 @@ export class RepoPublishCommand implements CliCommandShape {
22
21
  async main(): Promise<void> {
23
22
  const published = await RepoExecUtil.execOnModules('workspace', module => PackageManager.isPublished(module), {
24
23
  filter: module => !!module.workspace && !module.internal,
25
- progressMessage: (module) => `Checking published [%completed/%total] -- ${module?.name ?? ''}`,
24
+ progressMessage: module => `Checking published [%completed/%total] -- ${module?.name ?? ''}`,
26
25
  showStderr: false,
27
26
  showProgressList: true,
28
27
  isSuccess: () => true
@@ -33,7 +32,10 @@ export class RepoPublishCommand implements CliCommandShape {
33
32
  .map(([module]) => module);
34
33
 
35
34
  if (this.dryRun) {
36
- console.log('Unpublished modules', unpublished.map(module => module.sourceFolder));
35
+ console.log(
36
+ 'Unpublished modules',
37
+ unpublished.map(module => module.sourceFolder)
38
+ );
37
39
  }
38
40
 
39
41
  let otp = this.otp;
@@ -41,7 +43,7 @@ export class RepoPublishCommand implements CliCommandShape {
41
43
  if (await PackageManager.needsLogin()) {
42
44
  throw new RuntimeError('NPM login is required to publish. Please run "npm login" to authenticate.');
43
45
  }
44
- if (!otp && await PackageManager.needsOtp()) {
46
+ if (!otp && (await PackageManager.needsOtp())) {
45
47
  otp = await PackageManager.requestOtp();
46
48
  }
47
49
  if (!otp) {
@@ -51,17 +53,13 @@ export class RepoPublishCommand implements CliCommandShape {
51
53
 
52
54
  const unpublishedSet = new Set(unpublished);
53
55
 
54
- const results = await RepoExecUtil.execOnModules(
55
- 'workspace',
56
- module => PackageManager.publish(module, this.dryRun, otp),
57
- {
58
- progressMessage: (module) => `Publishing [%completed/%total] -- ${module?.name ?? ''} (Failed %failed)`,
59
- showStdout: false,
60
- showStderr: false,
61
- showProgressList: true,
62
- filter: module => unpublishedSet.has(module)
63
- }
64
- );
56
+ const results = await RepoExecUtil.execOnModules('workspace', module => PackageManager.publish(module, this.dryRun, otp), {
57
+ progressMessage: module => `Publishing [%completed/%total] -- ${module?.name ?? ''} (Failed %failed)`,
58
+ showStdout: false,
59
+ showStderr: false,
60
+ showProgressList: true,
61
+ filter: module => unpublishedSet.has(module)
62
+ });
65
63
 
66
64
  const failures = [...results.entries()].filter(([, result]) => !result.valid);
67
65
  if (failures.length > 0) {
@@ -69,9 +67,11 @@ export class RepoPublishCommand implements CliCommandShape {
69
67
  console.error(cliTpl`${'-'.repeat(50)}`);
70
68
  const nameWidth = Math.max(...failures.map(([module]) => module.name.length));
71
69
  for (const [module, result] of failures) {
72
- console.error(cliTpl`${{ identifier: module.name.padStart(nameWidth, ' ') }}: ${{ description: PackageManager.classifyPublishError(result) }}`);
70
+ console.error(
71
+ cliTpl`${{ identifier: module.name.padStart(nameWidth, ' ') }}: ${{ description: PackageManager.classifyPublishError(result) }}`
72
+ );
73
73
  }
74
74
  process.exitCode = 1;
75
75
  }
76
76
  }
77
- }
77
+ }
@@ -1,4 +1,5 @@
1
- import { type CliCommandShape, CliCommand } from '@travetto/cli';
1
+ import { CliCommand, type CliCommandShape } from '@travetto/cli';
2
+
2
3
  import { PackageManager } from './bin/package-manager.ts';
3
4
 
4
5
  /**
@@ -12,4 +13,4 @@ export class VersionSyncCommand implements CliCommandShape {
12
13
  async main(): Promise<void> {
13
14
  await PackageManager.synchronizeVersions();
14
15
  }
15
- }
16
+ }
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
 
3
- import { CliModuleUtil, type CliCommandShape, CliCommand, CliScmUtil } from '@travetto/cli';
3
+ import { CliCommand, type CliCommandShape, CliModuleUtil, CliScmUtil } from '@travetto/cli';
4
4
  import { ExecUtil, Runtime, RuntimeError } from '@travetto/runtime';
5
5
  import { Validator } from '@travetto/schema';
6
6
 
@@ -15,8 +15,8 @@ const CHANGE_LEVELS = new Set<SemverLevel>(['prerelease', 'patch', 'prepatch']);
15
15
  * versions after the version bump operation completes.
16
16
  */
17
17
  @CliCommand()
18
- @Validator(async (cmd) => {
19
- if (!cmd.force && await CliScmUtil.isWorkspaceDirty()) {
18
+ @Validator(async cmd => {
19
+ if (!cmd.force && (await CliScmUtil.isWorkspaceDirty())) {
20
20
  return { message: 'Cannot update versions with uncommitted changes', path: 'custom', kind: 'invalid' };
21
21
  }
22
22
  })
@@ -38,7 +38,7 @@ export class RepoVersionCommand implements CliCommandShape {
38
38
  async main(level: SemverLevel, prefix?: string): Promise<void> {
39
39
  const mode = this.mode ?? (CHANGE_LEVELS.has(level) ? 'changed' : 'workspace');
40
40
 
41
- this.tag ??= (level === 'minor' || level === 'major');
41
+ this.tag ??= level === 'minor' || level === 'major';
42
42
 
43
43
  const allModules = await CliModuleUtil.findModules(mode === 'direct' ? 'all' : mode);
44
44
 
@@ -63,4 +63,4 @@ export class RepoVersionCommand implements CliCommandShape {
63
63
  await fs.utimes(Runtime.workspaceRelative('package.json'), new Date(), new Date());
64
64
  }
65
65
  }
66
- }
66
+ }