@travetto/repo 7.0.0-rc.1 → 7.0.0-rc.3
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.
|
|
3
|
+
"version": "7.0.0-rc.3",
|
|
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.
|
|
26
|
-
"@travetto/worker": "^7.0.0-rc.
|
|
25
|
+
"@travetto/cli": "^7.0.0-rc.3",
|
|
26
|
+
"@travetto/worker": "^7.0.0-rc.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependenciesMeta": {
|
|
29
29
|
"@travetto/cli": {
|
package/support/bin/exec.ts
CHANGED
|
@@ -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(
|
|
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 = (
|
|
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(
|
|
41
|
-
const maxWidth = Math.max(...folders.map(
|
|
42
|
-
return Object.fromEntries(folders.map((
|
|
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
|
|
73
|
-
processes.set(mod,
|
|
72
|
+
const subProcess = operation(mod);
|
|
73
|
+
processes.set(mod, subProcess);
|
|
74
74
|
|
|
75
|
-
if (config.showStdout &&
|
|
76
|
-
ExecUtil.readLines(
|
|
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 &&
|
|
81
|
-
ExecUtil.readLines(
|
|
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(
|
|
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.
|
|
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
|
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { spawn, ChildProcess } from 'node:child_process';
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
4
|
|
|
5
|
-
import { ExecUtil, ExecutionResult } from '@travetto/runtime';
|
|
5
|
+
import { ExecUtil, ExecutionResult, JSONUtil } from '@travetto/runtime';
|
|
6
6
|
import { type IndexedModule, type ManifestContext, type Package, PackageUtil } from '@travetto/manifest';
|
|
7
7
|
import { CliModuleUtil } from '@travetto/cli';
|
|
8
8
|
|
|
@@ -40,12 +40,12 @@ export class PackageManager {
|
|
|
40
40
|
if (!result.valid && !result.stderr.includes('E404')) {
|
|
41
41
|
throw new Error(result.stderr);
|
|
42
42
|
}
|
|
43
|
-
const item: (string[] | string) = result.stdout ?
|
|
43
|
+
const item: (string[] | string) = result.stdout ? JSONUtil.parseSafe(result.stdout) : [];
|
|
44
44
|
const found = Array.isArray(item) ? item.pop() : item;
|
|
45
45
|
return !!found && found === mod.version;
|
|
46
46
|
}
|
|
47
47
|
case 'yarn': {
|
|
48
|
-
const parsed =
|
|
48
|
+
const parsed = JSONUtil.parseSafe<{ data?: unknown }>(result.stdout);
|
|
49
49
|
return parsed.data !== undefined;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -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(
|
|
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(
|
|
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}`;
|
package/support/cli.repo_list.ts
CHANGED
|
@@ -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(
|
|
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
|
|
36
|
-
await write(
|
|
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
|
|
49
|
-
for (const
|
|
50
|
-
if (
|
|
51
|
-
await write(` "${
|
|
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,
|
|
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(
|
|
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(
|
|
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(
|
|
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']);
|