Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumps workspace-tools and use the new async API for getPackageInfos to speed things up #626

Merged
merged 3 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bumps workspace-tools and use async packageinfos",
"packageName": "@lage-run/cache-github-actions",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bumps workspace-tools and use async packageinfos",
"packageName": "@lage-run/cli",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bumps workspace-tools and use async packageinfos",
"packageName": "@lage-run/config",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bumps workspace-tools and use async packageinfos",
"packageName": "@lage-run/target-graph",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}
7 changes: 7 additions & 0 deletions change/lage-077e0c75-0904-49bd-8bc6-01a86a997af7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bumps workspace-tools and use async packageinfos",
"packageName": "lage",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"syncpack": "8.5.14"
},
"resolutions": {
"workspace-tools": "^0.30.0",
"workspace-tools": "^0.32.0",
"typescript": "^5.0.3"
},
"lint-staged": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cache-github-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"backfill-config": "^6.3.0",
"backfill-logger": "^5.1.3",
"workspace-tools": "^0.30.0",
"workspace-tools": "^0.32.0",
"@actions/cache": "^3.0.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@lage-run/cache": "^0.5.1",
"@lage-run/reporters": "^1.1.0",
"commander": "^9.4.0",
"workspace-tools": "^0.30.0",
"workspace-tools": "^0.32.0",
"chokidar": "3.5.3",
"fast-glob": "^3.2.11"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/affected/action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createLogger from "@lage-run/logger";
import { getPackageInfos, getWorkspaceRoot, type PackageInfos } from "workspace-tools";
import { getPackageInfosAsync, getWorkspaceRoot, type PackageInfos } from "workspace-tools";
import { getConfig } from "@lage-run/config";
import { getFilteredPackages } from "../../filter/getFilteredPackages.js";
import type { FilterOptions } from "../../types/FilterOptions.js";
Expand All @@ -16,7 +16,7 @@ export async function affectedAction(options: AffectedOptions) {
const logger = createLogger();

const root = getWorkspaceRoot(cwd)!;
const packageInfos = getPackageInfos(root);
const packageInfos = await getPackageInfosAsync(root);

const packages = getFilteredPackages({
root,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/run/infoAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Command } from "commander";
import { createTargetGraph } from "./createTargetGraph.js";
import { filterArgsForTasks } from "./filterArgsForTasks.js";
import { getConfig } from "@lage-run/config";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { getPackageInfosAsync, getWorkspaceRoot } from "workspace-tools";
import createLogger from "@lage-run/logger";

import type { ReporterInitOptions } from "../../types/ReporterInitOptions.js";
Expand All @@ -27,7 +27,7 @@ export async function infoAction(options: RunOptions, command: Command) {

// Build Target Graph
const root = getWorkspaceRoot(process.cwd())!;
const packageInfos = getPackageInfos(root);
const packageInfos = await getPackageInfosAsync(root);

const { tasks } = filterArgsForTasks(command.args);

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/run/runAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { filterArgsForTasks } from "./filterArgsForTasks.js";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions.js";
import { findNpmClient } from "@lage-run/find-npm-client";
import { getConfig, getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions, getConcurrency } from "@lage-run/config";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { getPackageInfosAsync, getWorkspaceRoot } from "workspace-tools";
import { initializeReporters } from "../initializeReporters.js";
import { SimpleScheduler } from "@lage-run/scheduler";

Expand Down Expand Up @@ -44,7 +44,7 @@ export async function runAction(options: RunOptions, command: Command) {

// Build Target Graph
const root = getWorkspaceRoot(process.cwd())!;
const packageInfos = getPackageInfos(root);
const packageInfos = await getPackageInfosAsync(root);

const { tasks, taskArgs } = filterArgsForTasks(command.args);

Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/run/watchAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createTargetGraph } from "./createTargetGraph.js";
import { filterArgsForTasks } from "./filterArgsForTasks.js";
import { findNpmClient } from "@lage-run/find-npm-client";
import { getConfig, getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions, getConcurrency } from "@lage-run/config";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { getPackageInfosAsync, getWorkspaceRoot } from "workspace-tools";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions.js";
import { LogReporter } from "@lage-run/reporters";
import { SimpleScheduler } from "@lage-run/scheduler";
Expand Down Expand Up @@ -43,7 +43,7 @@ export async function watchAction(options: RunOptions, command: Command) {

// Build Target Graph
const root = getWorkspaceRoot(process.cwd())!;
const packageInfos = getPackageInfos(root);
const packageInfos = await getPackageInfosAsync(root);

const { tasks, taskArgs } = filterArgsForTasks(command.args);

Expand Down Expand Up @@ -119,7 +119,7 @@ export async function watchAction(options: RunOptions, command: Command) {
}

// When initial run is done, disable fetching of caches on all targets, keep writing to the cache
const watcher = watch(root);
const watcher = await watch(root, packageInfos);
watcher.on("change", async (packageName) => {
reporter.resetLogEntries();
const targets = new Map<string, Target>();
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/src/commands/run/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chokidar from "chokidar";

import path from "path";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { getWorkspaceRoot } from "workspace-tools";
import type { PackageInfos } from "workspace-tools";
import EventEmitter from "events";

Expand All @@ -13,10 +13,9 @@ interface PathIndex {
[pathPart: string]: PathIndexItem;
}

export function watch(cwd: string): EventEmitter {
export function watch(cwd: string, packageInfos: PackageInfos): EventEmitter {
const events = new EventEmitter();
const root = getWorkspaceRoot(cwd);
const packageInfos = getPackageInfos(cwd);

// generate a tree index of all the packages
const packageIndex = createPackageIndex(root!, packageInfos);
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/tests/getFilteredPackages.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import createLogger from "@lage-run/logger";
import { Monorepo } from "@lage-run/monorepo-fixture";
import { getPackageInfos } from "workspace-tools";
import { getPackageInfosAsync } from "workspace-tools";
import { getFilteredPackages } from "../src/filter/getFilteredPackages";

describe("getFilteredPackages", () => {
Expand All @@ -24,7 +24,7 @@ describe("getFilteredPackages", () => {

const filteredPackages = getFilteredPackages({
root: monorepo.root,
packageInfos: getPackageInfos(monorepo.root),
packageInfos: await getPackageInfosAsync(monorepo.root),
includeDependents: false,
includeDependencies: false,
since: "HEAD~1",
Expand Down Expand Up @@ -59,7 +59,7 @@ describe("getFilteredPackages", () => {

const filteredPackages = getFilteredPackages({
root: monorepo.root,
packageInfos: getPackageInfos(monorepo.root),
packageInfos: await getPackageInfosAsync(monorepo.root),
includeDependents: false,
includeDependencies: false,
since: "HEAD~1",
Expand Down Expand Up @@ -96,7 +96,7 @@ describe("getFilteredPackages", () => {

const filteredPackages = getFilteredPackages({
root: monorepo.root,
packageInfos: getPackageInfos(monorepo.root),
packageInfos: await getPackageInfosAsync(monorepo.root),
includeDependents: false,
includeDependencies: false,
since: "HEAD~1",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@lage-run/logger": "^1.2.2",
"@lage-run/scheduler-types": "^0.3.5",
"@lage-run/target-graph": "^0.8.1",
"workspace-tools": "^0.30.0",
"workspace-tools": "^0.32.0",
"cosmiconfig": "^7.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"rollup-plugin-terser": "7.0.2",
"backfill-config": "^6.3.0",
"dts-bundle-generator": "7.2.0",
"workspace-tools": "^0.30.0"
"workspace-tools": "^0.32.0"
},
"files": [
"dist/*.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/target-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint": "monorepo-scripts lint"
},
"dependencies": {
"workspace-tools": "^0.30.0"
"workspace-tools": "^0.32.0"
},
"devDependencies": {
"monorepo-scripts": "*"
Expand Down
2 changes: 1 addition & 1 deletion scripts/config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { getWorkspaceRoot, getPackageInfos } = require("workspace-tools");
const path = require("path");

const root = getWorkspaceRoot(process.cwd());
const root = getWorkspaceRoot(process.cwd()) ?? process.cwd();
const packages = getPackageInfos(root);
const moduleNameMapper = Object.values(packages).reduce((acc, { packageJsonPath, name }) => {
const packagePath = path.dirname(packageJsonPath);
Expand Down
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"typescript": "^5.0.3",
"eslint": "^8.20.0",
"eslint-plugin-file-extension-in-import-ts": "^1.0.1",
"workspace-tools": "^0.30.0",
"workspace-tools": "^0.32.0",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7"
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4836,10 +4836,10 @@ word-wrap@^1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==

workspace-tools@0.30.0, workspace-tools@^0.30.0:
version "0.30.0"
resolved "https://registry.yarnpkg.com/workspace-tools/-/workspace-tools-0.30.0.tgz#93103df09a66d5a4260bf65005b8f9924e439cf1"
integrity sha512-vQrzjAFvQYI2Zg9kFAo43aIgQNX5VSTtWLvOxCKhgjKnPdyLMXcPNxPTCKu3v+tjDW+YJNXUAigVv+pykrwOsQ==
workspace-tools@0.30.0, workspace-tools@^0.30.0, workspace-tools@^0.32.0:
version "0.32.0"
resolved "https://registry.yarnpkg.com/workspace-tools/-/workspace-tools-0.32.0.tgz#ffc07ae42377aad774b294168afad1b69d7db379"
integrity sha512-A61/L7jpHLAvGVgjtT5tJypOP7FVuI3iLwJYlyxJSrZpY5NQ/lCzW1fQZiXi7gNJDnJXuXjQM5cSLvIANH3X4Q==
dependencies:
"@yarnpkg/lockfile" "^1.1.0"
git-url-parse "^13.0.0"
Expand Down