@travetto/cli 3.4.1 → 3.4.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 +1 -1
- package/src/module.ts +8 -7
- package/src/scm.ts +9 -8
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -11,19 +11,20 @@ export class CliModuleUtil {
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Find modules that changed, and the dependent modules
|
|
14
|
-
* @param
|
|
14
|
+
* @param fromHash
|
|
15
|
+
* @param toHash
|
|
15
16
|
* @param transitive
|
|
16
17
|
* @returns
|
|
17
18
|
*/
|
|
18
|
-
static async findChangedModulesRecursive(
|
|
19
|
-
|
|
19
|
+
static async findChangedModulesRecursive(fromHash?: string, toHash?: string, transitive = true): Promise<IndexedModule[]> {
|
|
20
|
+
fromHash ??= await CliScmUtil.findLastRelease();
|
|
20
21
|
|
|
21
|
-
if (!
|
|
22
|
+
if (!fromHash) {
|
|
22
23
|
return RootIndex.getLocalModules();
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const out = new Map<string, IndexedModule>();
|
|
26
|
-
for (const mod of await CliScmUtil.
|
|
27
|
+
for (const mod of await CliScmUtil.findChangedModules(fromHash, toHash)) {
|
|
27
28
|
out.set(mod.name, mod);
|
|
28
29
|
if (transitive) {
|
|
29
30
|
for (const sub of await RootIndex.getDependentModules(mod)) {
|
|
@@ -42,9 +43,9 @@ export class CliModuleUtil {
|
|
|
42
43
|
* @param transitive
|
|
43
44
|
* @returns
|
|
44
45
|
*/
|
|
45
|
-
static async findModules(mode: 'all' | 'changed',
|
|
46
|
+
static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string): Promise<IndexedModule[]> {
|
|
46
47
|
return (mode === 'changed' ?
|
|
47
|
-
await this.findChangedModulesRecursive(
|
|
48
|
+
await this.findChangedModulesRecursive(fromHash, toHash) :
|
|
48
49
|
[...RootIndex.getModuleList('all')].map(x => RootIndex.getModule(x)!)
|
|
49
50
|
).filter(x => x.sourcePath !== RootIndex.manifest.workspacePath);
|
|
50
51
|
}
|
package/src/scm.ts
CHANGED
|
@@ -41,13 +41,13 @@ export class CliScmUtil {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Find all source files that changed
|
|
45
|
-
* @param
|
|
44
|
+
* Find all source files that changed between from and to hashes
|
|
45
|
+
* @param fromHash
|
|
46
46
|
* @returns
|
|
47
47
|
*/
|
|
48
|
-
static async
|
|
48
|
+
static async findChangedFiles(fromHash: string, toHash: string = 'HEAD'): Promise<string[]> {
|
|
49
49
|
const ws = RootIndex.manifest.workspacePath;
|
|
50
|
-
const res = await ExecUtil.spawn('git', ['diff', '--name-only',
|
|
50
|
+
const res = await ExecUtil.spawn('git', ['diff', '--name-only', `${fromHash}..${toHash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }).result;
|
|
51
51
|
const out = new Set<string>();
|
|
52
52
|
for (const line of res.stdout.split(/\n/g)) {
|
|
53
53
|
const entry = RootIndex.getEntry(path.resolve(ws, line));
|
|
@@ -59,12 +59,13 @@ export class CliScmUtil {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Find all modules that changed
|
|
63
|
-
* @param
|
|
62
|
+
* Find all modules that changed between from and to hashes
|
|
63
|
+
* @param fromHash
|
|
64
|
+
* @param toHash
|
|
64
65
|
* @returns
|
|
65
66
|
*/
|
|
66
|
-
static async
|
|
67
|
-
const files = await this.
|
|
67
|
+
static async findChangedModules(fromHash: string, toHash?: string): Promise<IndexedModule[]> {
|
|
68
|
+
const files = await this.findChangedFiles(fromHash, toHash);
|
|
68
69
|
const mods = files
|
|
69
70
|
.map(x => RootIndex.getFromSource(x))
|
|
70
71
|
.filter((x): x is IndexedFile => !!x)
|