@travetto/cli 4.1.1 → 4.1.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": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "description": "CLI infrastructure for Travetto framework",
5
5
  "keywords": [
6
6
  "cli",
package/src/module.ts CHANGED
@@ -43,9 +43,9 @@ export class CliModuleUtil {
43
43
  * @param transitive
44
44
  * @returns
45
45
  */
46
- static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string): Promise<IndexedModule[]> {
46
+ static async findModules(mode: 'all' | 'changed', fromHash?: string, toHash?: string, emptyOnFail = false): Promise<IndexedModule[]> {
47
47
  return (mode === 'changed' ?
48
- await this.findChangedModulesRecursive(fromHash, toHash) :
48
+ await this.findChangedModulesRecursive(fromHash, toHash, emptyOnFail) :
49
49
  [...RuntimeIndex.getModuleList('all')].map(x => RuntimeIndex.getModule(x)!)
50
50
  ).filter(x => x.sourcePath !== RuntimeContext.workspace.path);
51
51
  }
package/src/parse.ts CHANGED
@@ -210,7 +210,7 @@ export class CliParseUtil {
210
210
  inputs,
211
211
  all: out,
212
212
  unknown: out.filter(x => x.type === 'unknown').map(x => x.input),
213
- flags: out.filter((x): x is ParsedInput & { type: 'flag' } => x.type === 'flag')
213
+ flags: out.filter(x => x.type === 'flag')
214
214
  };
215
215
  }
216
216
  }
package/src/scm.ts CHANGED
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
2
2
  import fs from 'node:fs/promises';
3
3
 
4
4
  import { ExecUtil } from '@travetto/base';
5
- import { IndexedFile, IndexedModule, RuntimeIndex, RuntimeContext, path } from '@travetto/manifest';
5
+ import { IndexedModule, RuntimeIndex, RuntimeContext, path } from '@travetto/manifest';
6
6
 
7
7
  export class CliScmUtil {
8
8
  /**
@@ -45,9 +45,13 @@ export class CliScmUtil {
45
45
  * @param fromHash
46
46
  * @returns
47
47
  */
48
- static async findChangedFiles(fromHash: string, toHash: string = 'HEAD'): Promise<string[]> {
48
+ static async findChangedFiles(fromHash: string, toHash: string = 'HEAD', emptyOnFail = false): Promise<string[]> {
49
49
  const ws = RuntimeContext.workspace.path;
50
- const res = await ExecUtil.getResult(spawn('git', ['diff', '--name-only', `${fromHash}..${toHash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }));
50
+ const res = await ExecUtil.getResult(spawn('git', ['diff', '--name-only', `${fromHash}..${toHash}`, ':!**/DOC.*', ':!**/README.*'], { cwd: ws }), { catch: true });
51
+ if (!res.valid && emptyOnFail) {
52
+ console.warn('Unable to detect changes between', fromHash, toHash, 'with', (res.stderr || res.stdout));
53
+ return [];
54
+ }
51
55
  const out = new Set<string>();
52
56
  for (const line of res.stdout.split(/\n/g)) {
53
57
  const entry = RuntimeIndex.getEntry(path.resolve(ws, line));
@@ -68,9 +72,9 @@ export class CliScmUtil {
68
72
  const files = await this.findChangedFiles(fromHash, toHash);
69
73
  const mods = files
70
74
  .map(x => RuntimeIndex.getFromSource(x))
71
- .filter((x): x is IndexedFile => !!x)
75
+ .filter(x => !!x)
72
76
  .map(x => RuntimeIndex.getModule(x.module))
73
- .filter((x): x is IndexedModule => !!x);
77
+ .filter(x => !!x);
74
78
 
75
79
  return [...new Set(mods)]
76
80
  .sort((a, b) => a.name.localeCompare(b.name));