@lage-run/cli 0.24.3 → 0.24.5

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.
Files changed (36) hide show
  1. package/CHANGELOG.json +91 -1
  2. package/CHANGELOG.md +28 -2
  3. package/lib/commands/exec/action.d.ts +1 -0
  4. package/lib/commands/exec/action.js +3 -0
  5. package/lib/commands/exec/action.js.map +1 -1
  6. package/lib/commands/exec/executeRemotely.d.ts +3 -1
  7. package/lib/commands/exec/executeRemotely.js +12 -55
  8. package/lib/commands/exec/executeRemotely.js.map +1 -1
  9. package/lib/commands/exec/index.js +2 -1
  10. package/lib/commands/exec/index.js.map +1 -1
  11. package/lib/commands/info/action.js +8 -21
  12. package/lib/commands/info/action.js.map +1 -1
  13. package/lib/commands/launchServerInBackground.d.ts +11 -0
  14. package/lib/commands/launchServerInBackground.js +98 -0
  15. package/lib/commands/launchServerInBackground.js.map +1 -0
  16. package/lib/commands/run/createTargetGraph.js +26 -2
  17. package/lib/commands/run/createTargetGraph.js.map +1 -1
  18. package/lib/commands/run/runAction.js +9 -1
  19. package/lib/commands/run/runAction.js.map +1 -1
  20. package/lib/commands/server/action.d.ts +1 -0
  21. package/lib/commands/server/action.js +3 -2
  22. package/lib/commands/server/action.js.map +1 -1
  23. package/lib/commands/server/index.js +3 -8
  24. package/lib/commands/server/index.js.map +1 -1
  25. package/lib/commands/server/lageService.d.ts +5 -3
  26. package/lib/commands/server/lageService.js +49 -30
  27. package/lib/commands/server/lageService.js.map +1 -1
  28. package/lib/filter/getFilteredPackages.js +2 -65
  29. package/lib/filter/getFilteredPackages.js.map +1 -1
  30. package/lib/filter/hasRepoChanged.d.ts +2 -0
  31. package/lib/filter/hasRepoChanged.js +75 -0
  32. package/lib/filter/hasRepoChanged.js.map +1 -0
  33. package/lib/optimizeTargetGraph.d.ts +3 -0
  34. package/lib/optimizeTargetGraph.js +49 -0
  35. package/lib/optimizeTargetGraph.js.map +1 -0
  36. package/package.json +11 -10
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "hasRepoChanged", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return hasRepoChanged;
9
+ }
10
+ });
11
+ const _workspacetools = require("workspace-tools");
12
+ const _fastglob = /*#__PURE__*/ _interop_require_wildcard(require("fast-glob"));
13
+ function _getRequireWildcardCache(nodeInterop) {
14
+ if (typeof WeakMap !== "function") return null;
15
+ var cacheBabelInterop = new WeakMap();
16
+ var cacheNodeInterop = new WeakMap();
17
+ return (_getRequireWildcardCache = function(nodeInterop) {
18
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
+ })(nodeInterop);
20
+ }
21
+ function _interop_require_wildcard(obj, nodeInterop) {
22
+ if (!nodeInterop && obj && obj.__esModule) {
23
+ return obj;
24
+ }
25
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
+ return {
27
+ default: obj
28
+ };
29
+ }
30
+ var cache = _getRequireWildcardCache(nodeInterop);
31
+ if (cache && cache.has(obj)) {
32
+ return cache.get(obj);
33
+ }
34
+ var newObj = {
35
+ __proto__: null
36
+ };
37
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
38
+ for(var key in obj){
39
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
40
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
41
+ if (desc && (desc.get || desc.set)) {
42
+ Object.defineProperty(newObj, key, desc);
43
+ } else {
44
+ newObj[key] = obj[key];
45
+ }
46
+ }
47
+ }
48
+ newObj.default = obj;
49
+ if (cache) {
50
+ cache.set(obj, newObj);
51
+ }
52
+ return newObj;
53
+ }
54
+ function hasRepoChanged(since, root, environmentGlob, logger) {
55
+ try {
56
+ const changedFiles = (0, _workspacetools.getBranchChanges)(since, root);
57
+ const envFiles = _fastglob.sync(environmentGlob, {
58
+ cwd: root
59
+ });
60
+ let repoWideChanged = false;
61
+ if (changedFiles) {
62
+ for (const change of changedFiles){
63
+ if (envFiles.includes(change)) {
64
+ repoWideChanged = true;
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ return repoWideChanged;
70
+ } catch (e) {
71
+ // if this fails, let's assume repo has changed
72
+ logger.warn(`An error in the git command has caused this to consider the repo has changed\n${e}`);
73
+ return true;
74
+ }
75
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/filter/hasRepoChanged.ts"],"sourcesContent":["import { getBranchChanges } from \"workspace-tools\";\nimport * as fg from \"fast-glob\";\nimport type { Logger } from \"@lage-run/logger\";\n\nexport function hasRepoChanged(since: string, root: string, environmentGlob: string[], logger: Logger) {\n try {\n const changedFiles = getBranchChanges(since, root);\n const envFiles = fg.sync(environmentGlob, { cwd: root });\n let repoWideChanged = false;\n\n if (changedFiles) {\n for (const change of changedFiles) {\n if (envFiles.includes(change)) {\n repoWideChanged = true;\n break;\n }\n }\n }\n\n return repoWideChanged;\n } catch (e) {\n // if this fails, let's assume repo has changed\n logger.warn(`An error in the git command has caused this to consider the repo has changed\\n${e}`);\n return true;\n }\n}\n"],"names":["hasRepoChanged","since","root","environmentGlob","logger","changedFiles","getBranchChanges","envFiles","fg","sync","cwd","repoWideChanged","change","includes","e","warn"],"mappings":";;;;+BAIgBA;;;eAAAA;;;gCAJiB;kEACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGb,SAASA,eAAeC,KAAa,EAAEC,IAAY,EAAEC,eAAyB,EAAEC,MAAc;IACnG,IAAI;QACF,MAAMC,eAAeC,IAAAA,gCAAgB,EAACL,OAAOC;QAC7C,MAAMK,WAAWC,UAAGC,IAAI,CAACN,iBAAiB;YAAEO,KAAKR;QAAK;QACtD,IAAIS,kBAAkB;QAEtB,IAAIN,cAAc;YAChB,KAAK,MAAMO,UAAUP,aAAc;gBACjC,IAAIE,SAASM,QAAQ,CAACD,SAAS;oBAC7BD,kBAAkB;oBAClB;gBACF;YACF;QACF;QAEA,OAAOA;IACT,EAAE,OAAOG,GAAG;QACV,+CAA+C;QAC/CV,OAAOW,IAAI,CAAC,CAAC,8EAA8E,EAAED,GAAG;QAChG,OAAO;IACT;AACF"}
@@ -0,0 +1,3 @@
1
+ import type { TargetRunnerPicker } from "@lage-run/runners";
2
+ import { type TargetGraph } from "@lage-run/target-graph";
3
+ export declare function optimizeTargetGraph(graph: TargetGraph, runnerPicker: TargetRunnerPicker): Promise<import("@lage-run/target-graph").Target[]>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "optimizeTargetGraph", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return optimizeTargetGraph;
9
+ }
10
+ });
11
+ const _targetgraph = require("@lage-run/target-graph");
12
+ async function optimizeTargetGraph(graph, runnerPicker) {
13
+ const targetMinimizedNodes = await (0, _targetgraph.removeNodes)([
14
+ ...graph.targets.values()
15
+ ], async (target)=>{
16
+ if (target.type === "noop") {
17
+ return true;
18
+ }
19
+ if (target.id === (0, _targetgraph.getStartTargetId)()) {
20
+ return false;
21
+ }
22
+ const runner = await runnerPicker.pick(target);
23
+ if (await runner.shouldRun(target)) {
24
+ return false;
25
+ }
26
+ return true;
27
+ });
28
+ const reduced = (0, _targetgraph.transitiveReduction)(targetMinimizedNodes);
29
+ // Update the dependents of nodes based on the new set of dependencies
30
+ // first build up a dependency map for quick lookup
31
+ const dependencyMap = new Map();
32
+ for (const node of reduced){
33
+ for (const depId of node.dependencies){
34
+ if (!dependencyMap.has(depId)) {
35
+ dependencyMap.set(depId, new Set());
36
+ }
37
+ dependencyMap.get(depId).add(node.id);
38
+ }
39
+ }
40
+ // update the dependents of each node
41
+ for (const node of reduced){
42
+ const dependents = new Set();
43
+ if (dependencyMap.has(node.id)) {
44
+ dependencyMap.get(node.id).forEach((dependentId)=>dependents.add(dependentId));
45
+ }
46
+ node.dependents = Array.from(dependents);
47
+ }
48
+ return reduced;
49
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/optimizeTargetGraph.ts"],"sourcesContent":["import type { TargetRunnerPicker } from \"@lage-run/runners\";\nimport { type TargetGraph, removeNodes, transitiveReduction, getStartTargetId } from \"@lage-run/target-graph\";\n\nexport async function optimizeTargetGraph(graph: TargetGraph, runnerPicker: TargetRunnerPicker) {\n const targetMinimizedNodes = await removeNodes([...graph.targets.values()], async (target) => {\n if (target.type === \"noop\") {\n return true;\n }\n\n if (target.id === getStartTargetId()) {\n return false;\n }\n\n const runner = await runnerPicker.pick(target);\n if (await runner.shouldRun(target)) {\n return false;\n }\n\n return true;\n });\n\n const reduced = transitiveReduction(targetMinimizedNodes);\n\n // Update the dependents of nodes based on the new set of dependencies\n // first build up a dependency map for quick lookup\n const dependencyMap = new Map<string, Set<string>>();\n for (const node of reduced) {\n for (const depId of node.dependencies) {\n if (!dependencyMap.has(depId)) {\n dependencyMap.set(depId, new Set<string>());\n }\n dependencyMap.get(depId)!.add(node.id);\n }\n }\n\n // update the dependents of each node\n for (const node of reduced) {\n const dependents = new Set<string>();\n if (dependencyMap.has(node.id)) {\n dependencyMap.get(node.id)!.forEach((dependentId) => dependents.add(dependentId));\n }\n\n node.dependents = Array.from(dependents);\n }\n\n return reduced;\n}\n"],"names":["optimizeTargetGraph","graph","runnerPicker","targetMinimizedNodes","removeNodes","targets","values","target","type","id","getStartTargetId","runner","pick","shouldRun","reduced","transitiveReduction","dependencyMap","Map","node","depId","dependencies","has","set","Set","get","add","dependents","forEach","dependentId","Array","from"],"mappings":";;;;+BAGsBA;;;eAAAA;;;6BAF+D;AAE9E,eAAeA,oBAAoBC,KAAkB,EAAEC,YAAgC;IAC5F,MAAMC,uBAAuB,MAAMC,IAAAA,wBAAW,EAAC;WAAIH,MAAMI,OAAO,CAACC,MAAM;KAAG,EAAE,OAAOC;QACjF,IAAIA,OAAOC,IAAI,KAAK,QAAQ;YAC1B,OAAO;QACT;QAEA,IAAID,OAAOE,EAAE,KAAKC,IAAAA,6BAAgB,KAAI;YACpC,OAAO;QACT;QAEA,MAAMC,SAAS,MAAMT,aAAaU,IAAI,CAACL;QACvC,IAAI,MAAMI,OAAOE,SAAS,CAACN,SAAS;YAClC,OAAO;QACT;QAEA,OAAO;IACT;IAEA,MAAMO,UAAUC,IAAAA,gCAAmB,EAACZ;IAEpC,sEAAsE;IACtE,mDAAmD;IACnD,MAAMa,gBAAgB,IAAIC;IAC1B,KAAK,MAAMC,QAAQJ,QAAS;QAC1B,KAAK,MAAMK,SAASD,KAAKE,YAAY,CAAE;YACrC,IAAI,CAACJ,cAAcK,GAAG,CAACF,QAAQ;gBAC7BH,cAAcM,GAAG,CAACH,OAAO,IAAII;YAC/B;YACAP,cAAcQ,GAAG,CAACL,OAAQM,GAAG,CAACP,KAAKT,EAAE;QACvC;IACF;IAEA,qCAAqC;IACrC,KAAK,MAAMS,QAAQJ,QAAS;QAC1B,MAAMY,aAAa,IAAIH;QACvB,IAAIP,cAAcK,GAAG,CAACH,KAAKT,EAAE,GAAG;YAC9BO,cAAcQ,GAAG,CAACN,KAAKT,EAAE,EAAGkB,OAAO,CAAC,CAACC,cAAgBF,WAAWD,GAAG,CAACG;QACtE;QAEAV,KAAKQ,UAAU,GAAGG,MAAMC,IAAI,CAACJ;IAC/B;IAEA,OAAOZ;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
- "version": "0.24.3",
3
+ "version": "0.24.5",
4
4
  "description": "Command Line Interface for Lage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,18 +21,19 @@
21
21
  "lint": "monorepo-scripts lint"
22
22
  },
23
23
  "dependencies": {
24
- "@lage-run/cache": "^1.3.9",
25
- "@lage-run/config": "^0.4.10",
24
+ "@lage-run/cache": "^1.3.10",
25
+ "@lage-run/config": "^0.4.11",
26
+ "@lage-run/format-hrtime": "^0.1.6",
26
27
  "@lage-run/globby": "^14.2.0",
27
- "@lage-run/hasher": "^1.6.6",
28
+ "@lage-run/hasher": "^1.6.7",
28
29
  "@lage-run/logger": "^1.3.1",
29
- "@lage-run/reporters": "^1.2.17",
30
+ "@lage-run/reporters": "^1.2.18",
30
31
  "@lage-run/rpc": "^1.2.3",
31
- "@lage-run/runners": "^1.1.2",
32
- "@lage-run/scheduler": "^1.3.12",
33
- "@lage-run/scheduler-types": "^0.3.21",
34
- "@lage-run/target-graph": "^0.10.1",
35
- "@lage-run/worker-threads-pool": "^0.8.4",
32
+ "@lage-run/runners": "^1.2.0",
33
+ "@lage-run/scheduler": "^1.4.1",
34
+ "@lage-run/scheduler-types": "^0.3.22",
35
+ "@lage-run/target-graph": "^0.11.0",
36
+ "@lage-run/worker-threads-pool": "^0.8.5",
36
37
  "chokidar": "3.5.3",
37
38
  "commander": "9.5.0",
38
39
  "execa": "5.1.1",