@lage-run/cli 0.8.6 → 0.9.0

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/CHANGELOG.json CHANGED
@@ -2,7 +2,34 @@
2
2
  "name": "@lage-run/cli",
3
3
  "entries": [
4
4
  {
5
- "date": "Sat, 18 Feb 2023 00:43:24 GMT",
5
+ "date": "Tue, 21 Feb 2023 21:30:26 GMT",
6
+ "tag": "@lage-run/cli_v0.9.0",
7
+ "version": "0.9.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "kchau@microsoft.com",
12
+ "package": "@lage-run/cli",
13
+ "commit": "d7a8a3fa2bcf434c59bea26d5964dd7235998ad2",
14
+ "comment": "cache directory to be centralized"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@lage-run/cli",
19
+ "comment": "Bump @lage-run/scheduler to v0.9.0",
20
+ "commit": "d7a8a3fa2bcf434c59bea26d5964dd7235998ad2"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@lage-run/cli",
25
+ "comment": "Bump @lage-run/cache to v0.3.0",
26
+ "commit": "d7a8a3fa2bcf434c59bea26d5964dd7235998ad2"
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "date": "Sat, 18 Feb 2023 00:43:33 GMT",
6
33
  "tag": "@lage-run/cli_v0.8.6",
7
34
  "version": "0.8.6",
8
35
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # Change Log - @lage-run/cli
2
2
 
3
- This log was last generated on Sat, 18 Feb 2023 00:43:24 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 21 Feb 2023 21:30:26 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.9.0
8
+
9
+ Tue, 21 Feb 2023 21:30:26 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - cache directory to be centralized (kchau@microsoft.com)
14
+ - Bump @lage-run/scheduler to v0.9.0
15
+ - Bump @lage-run/cache to v0.3.0
16
+
7
17
  ## 0.8.6
8
18
 
9
- Sat, 18 Feb 2023 00:43:24 GMT
19
+ Sat, 18 Feb 2023 00:43:33 GMT
10
20
 
11
21
  ### Patches
12
22
 
@@ -10,7 +10,6 @@ const _clearCacheJs = require("./clearCache.js");
10
10
  const _getConfigJs = require("../../config/getConfig.js");
11
11
  const _pruneCacheJs = require("./pruneCache.js");
12
12
  const _logger = /*#__PURE__*/ _interopRequireDefault(require("@lage-run/logger"));
13
- const _initializeReportersJs = require("../initializeReporters.js");
14
13
  function _interopRequireDefault(obj) {
15
14
  return obj && obj.__esModule ? obj : {
16
15
  default: obj
@@ -20,7 +19,6 @@ async function cacheAction(options, command) {
20
19
  const cwd = process.cwd();
21
20
  const config = await (0, _getConfigJs.getConfig)(cwd);
22
21
  const logger = (0, _logger.default)();
23
- (0, _initializeReportersJs.initializeReporters)(logger, options);
24
22
  if (options.clear) {
25
23
  return await (0, _clearCacheJs.clearCache)({
26
24
  cwd: process.cwd(),
@@ -6,68 +6,26 @@ Object.defineProperty(exports, "clearCache", {
6
6
  enumerable: true,
7
7
  get: ()=>clearCache
8
8
  });
9
- const _cacheDirJs = require("./cacheDir.js");
10
9
  const _getConfigJs = require("../../config/getConfig.js");
11
10
  const _workspaceTools = require("workspace-tools");
12
- const _scheduler = require("@lage-run/scheduler");
13
- const _targetGraph = require("@lage-run/target-graph");
14
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
15
11
  const _getConcurrencyJs = require("../../config/getConcurrency.js");
16
- function _interopRequireDefault(obj) {
17
- return obj && obj.__esModule ? obj : {
18
- default: obj
19
- };
20
- }
12
+ const _cache = require("@lage-run/cache");
21
13
  async function clearCache(options) {
22
- const { logger , cwd , internalCacheFolder } = options;
14
+ const { logger , cwd } = options;
23
15
  const config = await (0, _getConfigJs.getConfig)(cwd);
24
16
  const workspaceRoot = (0, _workspaceTools.getWorkspaceRoot)(cwd);
25
17
  const concurrency = (0, _getConcurrencyJs.getConcurrency)(options.concurrency, config.concurrency);
26
18
  if (!workspaceRoot) {
27
19
  return;
28
20
  }
29
- const graphBuilder = new _targetGraph.TargetGraphBuilder();
30
- const workspaces = (0, _workspaceTools.getWorkspaces)(workspaceRoot);
31
- for (const workspace of workspaces){
32
- const cachePath = (0, _cacheDirJs.getCacheDir)(workspace.path, internalCacheFolder);
33
- const logOutputCachePath = _path.default.join(workspace.path, "node_modules/.cache/lage/output/");
34
- graphBuilder.addTarget({
35
- packageName: workspace.name,
36
- cwd: workspace.path,
37
- dependencies: [],
38
- dependents: [],
39
- id: `${workspace.name}#clearCache`,
40
- label: `Clearing Cache for ${workspace.name}`,
41
- task: "clearCache",
42
- type: "worker",
43
- depSpecs: [],
44
- options: {
45
- clearPaths: [
46
- cachePath,
47
- logOutputCachePath
48
- ]
49
- }
50
- });
51
- }
52
- const graph = graphBuilder.build();
53
- const scheduler = new _scheduler.SimpleScheduler({
54
- logger,
55
- concurrency,
56
- continueOnError: true,
57
- shouldCache: false,
58
- shouldResetCache: false,
59
- maxWorkersPerTask: new Map(),
60
- runners: {
61
- worker: {
62
- script: require.resolve("./runners/ClearCacheRunner.js"),
63
- options: {}
64
- }
65
- },
66
- workerIdleMemoryLimit: config.workerIdleMemoryLimit
67
- });
68
- const summary = await scheduler.run(workspaceRoot, graph);
69
- await scheduler.cleanup();
70
- logger.reporters.forEach((reporter)=>{
71
- reporter.summarize(summary);
21
+ const cacheProvider = new _cache.BackfillCacheProvider({
22
+ root: cwd,
23
+ cacheOptions: config.cacheOptions,
24
+ logger
72
25
  });
26
+ // eslint-disable-next-line no-console
27
+ console.log("Clearing Cache");
28
+ cacheProvider.clear(concurrency);
29
+ // eslint-disable-next-line no-console
30
+ console.log("Cache Cleared");
73
31
  }
@@ -6,72 +6,27 @@ Object.defineProperty(exports, "pruneCache", {
6
6
  enumerable: true,
7
7
  get: ()=>pruneCache
8
8
  });
9
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
10
- const _cacheDirJs = require("./cacheDir.js");
11
9
  const _workspaceTools = require("workspace-tools");
12
10
  const _getConfigJs = require("../../config/getConfig.js");
13
11
  const _getConcurrencyJs = require("../../config/getConcurrency.js");
14
- const _targetGraph = require("@lage-run/target-graph");
15
- const _scheduler = require("@lage-run/scheduler");
16
- function _interopRequireDefault(obj) {
17
- return obj && obj.__esModule ? obj : {
18
- default: obj
19
- };
20
- }
12
+ const _cache = require("@lage-run/cache");
21
13
  async function pruneCache(options) {
22
- const { logger , cwd , pruneDays , internalCacheFolder } = options;
14
+ const { logger , cwd , pruneDays } = options;
23
15
  const config = await (0, _getConfigJs.getConfig)(cwd);
24
16
  const workspaceRoot = (0, _workspaceTools.getWorkspaceRoot)(cwd);
25
17
  const concurrency = (0, _getConcurrencyJs.getConcurrency)(options.concurrency, config.concurrency);
26
18
  if (!workspaceRoot) {
27
19
  return;
28
20
  }
29
- const graphBuilder = new _targetGraph.TargetGraphBuilder();
30
- const workspaces = (0, _workspaceTools.getWorkspaces)(workspaceRoot);
31
21
  const prunePeriod = pruneDays || 30;
32
- const now = new Date().getTime();
33
- for (const workspace of workspaces){
34
- const cachePath = (0, _cacheDirJs.getCacheDir)(workspace.path, internalCacheFolder);
35
- const logOutputCachePath = _path.default.join(workspace.path, "node_modules/.cache/lage/output/");
36
- graphBuilder.addTarget({
37
- packageName: workspace.name,
38
- cwd: workspace.path,
39
- dependencies: [],
40
- dependents: [],
41
- id: `${workspace.name}#pruneCache`,
42
- label: `Pruning Cache for ${workspace.name}`,
43
- task: "pruneCache",
44
- type: "worker",
45
- depSpecs: [],
46
- options: {
47
- clearPaths: [
48
- cachePath,
49
- logOutputCachePath
50
- ],
51
- now,
52
- prunePeriod
53
- }
54
- });
55
- }
56
- const graph = graphBuilder.build();
57
- const scheduler = new _scheduler.SimpleScheduler({
58
- logger,
59
- concurrency,
60
- continueOnError: true,
61
- shouldCache: false,
62
- shouldResetCache: false,
63
- maxWorkersPerTask: new Map(),
64
- runners: {
65
- worker: {
66
- script: require.resolve("./runners/PruneCacheRunner.js"),
67
- options: {}
68
- }
69
- },
70
- workerIdleMemoryLimit: config.workerIdleMemoryLimit
71
- });
72
- const summary = await scheduler.run(workspaceRoot, graph);
73
- await scheduler.cleanup();
74
- logger.reporters.forEach((reporter)=>{
75
- reporter.summarize(summary);
22
+ const cacheProvider = new _cache.BackfillCacheProvider({
23
+ root: cwd,
24
+ cacheOptions: config.cacheOptions,
25
+ logger
76
26
  });
27
+ // eslint-disable-next-line no-console
28
+ console.log("Clearing Cache");
29
+ cacheProvider.purge(prunePeriod, concurrency);
30
+ // eslint-disable-next-line no-console
31
+ console.log("Cache Cleared");
77
32
  }
@@ -1,3 +1,3 @@
1
1
  import { JsonReporter, AdoReporter, LogReporter, ProgressReporter, ChromeTraceEventsReporter } from "@lage-run/reporters";
2
2
  import type { ReporterInitOptions } from "../types/ReporterInitOptions.js";
3
- export declare function createReporter(reporter: string, options: ReporterInitOptions): ChromeTraceEventsReporter | JsonReporter | AdoReporter | ProgressReporter | LogReporter;
3
+ export declare function createReporter(reporter: string, options: ReporterInitOptions): ChromeTraceEventsReporter | JsonReporter | AdoReporter | LogReporter | ProgressReporter;
@@ -27,8 +27,14 @@ function createReporter(reporter, options) {
27
27
  grouped,
28
28
  logLevel: verbose ? _logger.LogLevel.verbose : logLevel
29
29
  });
30
+ case "npmLog":
31
+ case "old":
32
+ return new _reporters.LogReporter({
33
+ grouped,
34
+ logLevel: verbose ? _logger.LogLevel.verbose : logLevel
35
+ });
30
36
  default:
31
- if (progress && !(verbose || grouped)) {
37
+ if (progress && !(logLevel >= _logger.LogLevel.verbose || verbose || grouped)) {
32
38
  return new _reporters.ProgressReporter({
33
39
  concurrency
34
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/cli",
3
- "version": "0.8.6",
3
+ "version": "0.9.0",
4
4
  "description": "Command Line Interface for Lage",
5
5
  "repository": {
6
6
  "url": "https://github.com/microsoft/lage"
@@ -20,10 +20,10 @@
20
20
  "dependencies": {
21
21
  "@lage-run/find-npm-client": "^0.1.4",
22
22
  "@lage-run/logger": "^1.2.2",
23
- "@lage-run/scheduler": "^0.8.5",
23
+ "@lage-run/scheduler": "^0.9.0",
24
24
  "@lage-run/scheduler-types": "^0.3.1",
25
25
  "@lage-run/target-graph": "^0.6.2",
26
- "@lage-run/cache": "^0.2.5",
26
+ "@lage-run/cache": "^0.3.0",
27
27
  "@lage-run/reporters": "^1.0.3",
28
28
  "commander": "^9.4.0",
29
29
  "workspace-tools": "^0.30.0",
@@ -1 +0,0 @@
1
- export declare function getCacheDir(workspace: string, internalCacheFolder: string): string;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getCacheDir", {
6
- enumerable: true,
7
- get: ()=>getCacheDir
8
- });
9
- const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
10
- function _interopRequireDefault(obj) {
11
- return obj && obj.__esModule ? obj : {
12
- default: obj
13
- };
14
- }
15
- function getCacheDir(workspace, internalCacheFolder) {
16
- const cacheFolder = !internalCacheFolder ? undefined : internalCacheFolder;
17
- return _path.default.join(workspace, cacheFolder ?? "node_modules/.cache/backfill");
18
- }