@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/cli",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "CLI infrastructure for Travetto framework",
5
5
  "keywords": [
6
6
  "cli",
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 hash
14
+ * @param fromHash
15
+ * @param toHash
15
16
  * @param transitive
16
17
  * @returns
17
18
  */
18
- static async findChangedModulesRecursive(hash?: string, transitive = true): Promise<IndexedModule[]> {
19
- hash ??= await CliScmUtil.findLastRelease();
19
+ static async findChangedModulesRecursive(fromHash?: string, toHash?: string, transitive = true): Promise<IndexedModule[]> {
20
+ fromHash ??= await CliScmUtil.findLastRelease();
20
21
 
21
- if (!hash) {
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.findChangedModulesSince(hash)) {
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', sinceHash?: string): Promise<IndexedModule[]> {
46
+ static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string): Promise<IndexedModule[]> {
46
47
  return (mode === 'changed' ?
47
- await this.findChangedModulesRecursive(sinceHash) :
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 since hash
45
- * @param hash
44
+ * Find all source files that changed between from and to hashes
45
+ * @param fromHash
46
46
  * @returns
47
47
  */
48
- static async findChangedFilesSince(hash: string): Promise<string[]> {
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', `HEAD..${hash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }).result;
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 since hash
63
- * @param hash
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 findChangedModulesSince(hash: string): Promise<IndexedModule[]> {
67
- const files = await this.findChangedFilesSince(hash);
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)