@travetto/cli 3.2.2 → 3.2.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 +1 -1
- package/src/module.ts +3 -5
- package/src/scm.ts +25 -8
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -20,9 +20,7 @@ export class CliModuleUtil {
|
|
|
20
20
|
* @returns
|
|
21
21
|
*/
|
|
22
22
|
static async findChangedModulesRecursive(hash?: string, transitive = true): Promise<IndexedModule[]> {
|
|
23
|
-
|
|
24
|
-
hash = await CliScmUtil.findLastRelease();
|
|
25
|
-
}
|
|
23
|
+
hash ??= await CliScmUtil.findLastRelease();
|
|
26
24
|
|
|
27
25
|
if (!hash) {
|
|
28
26
|
return RootIndex.getLocalModules();
|
|
@@ -48,9 +46,9 @@ export class CliModuleUtil {
|
|
|
48
46
|
* @param transitive
|
|
49
47
|
* @returns
|
|
50
48
|
*/
|
|
51
|
-
static async findModules(mode: 'all' | 'changed'): Promise<IndexedModule[]> {
|
|
49
|
+
static async findModules(mode: 'all' | 'changed', sinceHash?: string): Promise<IndexedModule[]> {
|
|
52
50
|
return (mode === 'changed' ?
|
|
53
|
-
await this.findChangedModulesRecursive() :
|
|
51
|
+
await this.findChangedModulesRecursive(sinceHash) :
|
|
54
52
|
[...RootIndex.getModuleList('all')].map(x => RootIndex.getModule(x)!)
|
|
55
53
|
).filter(x => x.sourcePath !== RootIndex.manifest.workspacePath);
|
|
56
54
|
}
|
package/src/scm.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
|
|
3
3
|
import { Env, ExecUtil } from '@travetto/base';
|
|
4
|
-
import { IndexedModule, RootIndex, path } from '@travetto/manifest';
|
|
4
|
+
import { IndexedFile, IndexedModule, RootIndex, path } from '@travetto/manifest';
|
|
5
5
|
|
|
6
6
|
export class CliScmUtil {
|
|
7
7
|
/**
|
|
@@ -41,21 +41,38 @@ export class CliScmUtil {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Find all
|
|
44
|
+
* Find all source files that changed since hash
|
|
45
45
|
* @param hash
|
|
46
46
|
* @returns
|
|
47
47
|
*/
|
|
48
|
-
static async
|
|
48
|
+
static async findChangedFilesSince(hash: string): Promise<string[]> {
|
|
49
49
|
const ws = RootIndex.manifest.workspacePath;
|
|
50
50
|
const res = await ExecUtil.spawn('git', ['diff', '--name-only', `HEAD..${hash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }).result;
|
|
51
|
-
const out = new Set<
|
|
51
|
+
const out = new Set<string>();
|
|
52
52
|
for (const line of res.stdout.split(/\n/g)) {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
out.add(
|
|
53
|
+
const entry = RootIndex.getEntry(path.resolve(ws, line));
|
|
54
|
+
if (entry) {
|
|
55
|
+
out.add(entry.sourceFile);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
return [...out].sort((a, b) => a.
|
|
58
|
+
return [...out].sort((a, b) => a.localeCompare(b));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Find all modules that changed since hash
|
|
63
|
+
* @param hash
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
static async findChangedModulesSince(hash: string): Promise<IndexedModule[]> {
|
|
67
|
+
const files = await this.findChangedFilesSince(hash);
|
|
68
|
+
const mods = files
|
|
69
|
+
.map(x => RootIndex.getFromSource(x))
|
|
70
|
+
.filter((x): x is IndexedFile => !!x)
|
|
71
|
+
.map(x => RootIndex.getModule(x.module))
|
|
72
|
+
.filter((x): x is IndexedModule => !!x);
|
|
73
|
+
|
|
74
|
+
return [...new Set(mods)]
|
|
75
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
/**
|