Import extensions - add .js to all the import specifiers! (#472)

* adding import extensions and enforced in linter

* Change files

* fixing import extensions

* Change files

* fixing according to ts-jest esm-support
This commit is contained in:
Kenneth Chau 2022-11-01 15:18:33 -07:00 коммит произвёл GitHub
Родитель 8295ceaf9c
Коммит 1664f38eca
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
98 изменённых файлов: 303 добавлений и 198 удалений

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/cache",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/cache-github-actions",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/cli",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/find-npm-client",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/format-hrtime",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/logger",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/reporters",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/scheduler",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/scheduler-types",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/target-graph",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "adds import extensions of .js to prepare of esmodule switchover",
"packageName": "@lage-run/worker-threads-pool",
"email": "kchau@microsoft.com",
"dependentChangeType": "patch"
}

Просмотреть файл

@ -1 +1 @@
export { cacheProvider as default } from "./cacheProvider"; export { cacheProvider as default } from "./cacheProvider.js";

4
packages/cache/src/TargetHasher.ts поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
import { createBackfillLogger } from "./backfillWrapper"; import { createBackfillLogger } from "./backfillWrapper.js";
import { Hasher as BackfillHasher } from "backfill-hasher"; import { Hasher as BackfillHasher } from "backfill-hasher";
import { salt } from "./salt"; import { salt } from "./salt.js";
import type { Logger as BackfillLogger } from "backfill-logger"; import type { Logger as BackfillLogger } from "backfill-logger";
import type { Target } from "@lage-run/target-graph"; import type { Target } from "@lage-run/target-graph";

2
packages/cache/src/backfillWrapper.ts поставляемый
Просмотреть файл

@ -6,7 +6,7 @@ import * as os from "os";
import { createDefaultConfig, getEnvConfig } from "backfill-config"; import { createDefaultConfig, getEnvConfig } from "backfill-config";
import { makeLogger } from "backfill-logger"; import { makeLogger } from "backfill-logger";
import type { Logger as BackfillLogger } from "backfill-logger"; import type { Logger as BackfillLogger } from "backfill-logger";
import type { CacheOptions } from "./types/CacheOptions"; import type { CacheOptions } from "./types/CacheOptions.js";
export function createBackfillLogger() { export function createBackfillLogger() {
const stdout = process.stdout; const stdout = process.stdout;

10
packages/cache/src/index.ts поставляемый
Просмотреть файл

@ -1,5 +1,5 @@
export { BackfillCacheProvider } from "./providers/BackfillCacheProvider"; export { BackfillCacheProvider } from "./providers/BackfillCacheProvider.js";
export { RemoteFallbackCacheProvider } from "./providers/RemoteFallbackCacheProvider"; export { RemoteFallbackCacheProvider } from "./providers/RemoteFallbackCacheProvider.js";
export { TargetHasher } from "./TargetHasher"; export { TargetHasher } from "./TargetHasher.js";
export type { CacheOptions } from "./types/CacheOptions"; export type { CacheOptions } from "./types/CacheOptions.js";
export type { CacheProvider } from "./types/CacheProvider"; export type { CacheProvider } from "./types/CacheProvider.js";

Просмотреть файл

@ -1,10 +1,10 @@
import { createBackfillCacheConfig, createBackfillLogger } from "../backfillWrapper"; import { createBackfillCacheConfig, createBackfillLogger } from "../backfillWrapper.js";
import { getCacheStorageProvider } from "backfill-cache"; import { getCacheStorageProvider } from "backfill-cache";
import { getPackageInfos } from "workspace-tools"; import { getPackageInfos } from "workspace-tools";
import { promisify } from "util"; import { promisify } from "util";
import * as fs from "fs"; import * as fs from "fs";
import * as path from "path"; import * as path from "path";
import type { CacheProvider, CacheProviderOptions } from "../types/CacheProvider"; import type { CacheProvider, CacheProviderOptions } from "../types/CacheProvider.js";
import type { Logger as BackfillLogger } from "backfill-logger"; import type { Logger as BackfillLogger } from "backfill-logger";
import type { PackageInfo } from "workspace-tools"; import type { PackageInfo } from "workspace-tools";
import type { Target } from "@lage-run/target-graph"; import type { Target } from "@lage-run/target-graph";

Просмотреть файл

@ -1,4 +1,4 @@
import type { CacheProvider } from "../types/CacheProvider"; import type { CacheProvider } from "../types/CacheProvider.js";
import type { Logger } from "@lage-run/logger"; import type { Logger } from "@lage-run/logger";
import type { Target } from "@lage-run/target-graph"; import type { Target } from "@lage-run/target-graph";

2
packages/cache/src/types/CacheOptions.ts поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
import type { CacheProviderOptions } from "./CacheProvider"; import type { CacheProviderOptions } from "./CacheProvider.js";
export interface CacheOptions extends CacheProviderOptions { export interface CacheOptions extends CacheProviderOptions {
/** /**

Просмотреть файл

@ -14,7 +14,8 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"start": "tsc -w --preserveWatchOutput", "start": "tsc -w --preserveWatchOutput",
"test": "jest" "test": "jest",
"lint": "monorepo-scripts lint"
}, },
"dependencies": { "dependencies": {
"@lage-run/find-npm-client": "^0.1.3", "@lage-run/find-npm-client": "^0.1.3",

Просмотреть файл

@ -12,6 +12,7 @@ async function main() {
} }
main().catch((err) => { main().catch((err) => {
// eslint-disable-next-line no-console
console.error(err); console.error(err);
process.exitCode = 1; process.exitCode = 1;
}); });

Просмотреть файл

@ -1,4 +1,5 @@
import { Command, Option } from "commander"; import type { Command } from "commander";
import { Option } from "commander";
export function addLoggerOptions(program: Command) { export function addLoggerOptions(program: Command) {
return program return program

8
packages/cli/src/commands/cache/action.ts поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
import { clearCache } from "./clearCache"; import { clearCache } from "./clearCache.js";
import { Command } from "commander"; import type { Command } from "commander";
import { getConfig } from "../../config/getConfig"; import { getConfig } from "../../config/getConfig.js";
import { pruneCache } from "./pruneCache"; import { pruneCache } from "./pruneCache.js";
import createLogger from "@lage-run/logger"; import createLogger from "@lage-run/logger";
import { initializeReporters } from "@lage-run/reporters"; import { initializeReporters } from "@lage-run/reporters";
import type { ReporterInitOptions } from "@lage-run/reporters"; import type { ReporterInitOptions } from "@lage-run/reporters";

2
packages/cli/src/commands/cache/cacheDir.ts поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
import fs from "fs"; import type fs from "fs";
import path from "path"; import path from "path";
import { rm, unlink } from "fs/promises"; import { rm, unlink } from "fs/promises";

Просмотреть файл

@ -1,6 +1,6 @@
import { getCacheDir, removeCacheEntry } from "./cacheDir"; import { getCacheDir, removeCacheEntry } from "./cacheDir.js";
import { getWorkspaceRoot, getWorkspaces } from "workspace-tools"; import { getWorkspaceRoot, getWorkspaces } from "workspace-tools";
import { Logger } from "@lage-run/logger"; import type { Logger } from "@lage-run/logger";
import { stat } from "fs/promises"; import { stat } from "fs/promises";
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";

4
packages/cli/src/commands/cache/index.ts поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
import { Command, Option } from "commander"; import { Command, Option } from "commander";
import { addLoggerOptions } from "../addLoggerOptions"; import { addLoggerOptions } from "../addLoggerOptions.js";
import { cacheAction } from "./action"; import { cacheAction } from "./action.js";
const cacheCommand = new Command("cache"); const cacheCommand = new Command("cache");

Просмотреть файл

@ -1,8 +1,8 @@
import { Logger } from "@lage-run/logger"; import type { Logger } from "@lage-run/logger";
import { stat } from "fs/promises"; import { stat } from "fs/promises";
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import { getCacheDir, removeCacheEntry } from "./cacheDir"; import { getCacheDir, removeCacheEntry } from "./cacheDir.js";
import { getWorkspaces } from "workspace-tools"; import { getWorkspaces } from "workspace-tools";
const MS_IN_A_DAY = 1000 * 60 * 60 * 24; const MS_IN_A_DAY = 1000 * 60 * 60 * 24;

Просмотреть файл

@ -1,6 +1,6 @@
import { Command } from "commander"; import type { Command } from "commander";
import { runAction } from "./runAction"; import { runAction } from "./runAction.js";
import { watchAction } from "./watchAction"; import { watchAction } from "./watchAction.js";
import type { ReporterInitOptions } from "@lage-run/reporters"; import type { ReporterInitOptions } from "@lage-run/reporters";
interface RunOptions extends ReporterInitOptions { interface RunOptions extends ReporterInitOptions {

Просмотреть файл

@ -1,6 +1,7 @@
import { BackfillCacheProvider, CacheOptions, RemoteFallbackCacheProvider, TargetHasher } from "@lage-run/cache"; import type { CacheOptions } from "@lage-run/cache";
import { Logger } from "@lage-run/logger"; import { BackfillCacheProvider, RemoteFallbackCacheProvider, TargetHasher } from "@lage-run/cache";
import { isRunningFromCI } from "../isRunningFromCI"; import type { Logger } from "@lage-run/logger";
import { isRunningFromCI } from "../isRunningFromCI.js";
interface CreateCacheOptions { interface CreateCacheOptions {
cacheOptions?: CacheOptions; cacheOptions?: CacheOptions;

Просмотреть файл

@ -1,9 +1,8 @@
import { Logger } from "@lage-run/logger"; import type { Logger } from "@lage-run/logger";
import { TargetGraphBuilder } from "@lage-run/target-graph"; import { TargetGraphBuilder } from "@lage-run/target-graph";
import { getPackageInfos, PackageInfos } from "workspace-tools"; import type { PackageInfos } from "workspace-tools";
import { getFilteredPackages } from "../../filter/getFilteredPackages"; import { getFilteredPackages } from "../../filter/getFilteredPackages.js";
import type { PipelineDefinition } from "../../types/PipelineDefinition"; import type { PipelineDefinition } from "../../types/PipelineDefinition.js";
import { filterArgsForTasks } from "./filterArgsForTasks";
interface CreateTargetGraphOptions { interface CreateTargetGraphOptions {
logger: Logger; logger: Logger;

Просмотреть файл

@ -1,5 +1,5 @@
import type { Target } from "@lage-run/target-graph"; import type { Target } from "@lage-run/target-graph";
import type { PipelineDefinition } from "../../types/PipelineDefinition"; import type { PipelineDefinition } from "../../types/PipelineDefinition.js";
export function filterPipelineDefinitions(targets: IterableIterator<Target>, pipeline: PipelineDefinition) { export function filterPipelineDefinitions(targets: IterableIterator<Target>, pipeline: PipelineDefinition) {
const tasksSet = new Set<string>(); const tasksSet = new Set<string>();

Просмотреть файл

@ -1,8 +1,8 @@
import { Command, Option } from "commander"; import { Command } from "commander";
import os from "os"; import os from "os";
import { action } from "./action"; import { action } from "./action.js";
import { addLoggerOptions } from "../addLoggerOptions"; import { addLoggerOptions } from "../addLoggerOptions.js";
import { isRunningFromCI } from "../isRunningFromCI"; import { isRunningFromCI } from "../isRunningFromCI.js";
const runCommand = new Command("run"); const runCommand = new Command("run");

Просмотреть файл

@ -1,17 +1,18 @@
import { Command } from "commander"; import type { Command } from "commander";
import { createCache } from "./createCacheProvider"; import { createCache } from "./createCacheProvider.js";
import { createProfileReporter } from "./createProfileReporter"; import { createProfileReporter } from "./createProfileReporter.js";
import { createTargetGraph } from "./createTargetGraph"; import { createTargetGraph } from "./createTargetGraph.js";
import { filterArgsForTasks } from "./filterArgsForTasks"; import { filterArgsForTasks } from "./filterArgsForTasks.js";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions"; import { filterPipelineDefinitions } from "./filterPipelineDefinitions.js";
import { findNpmClient } from "@lage-run/find-npm-client"; import { findNpmClient } from "@lage-run/find-npm-client";
import { getConfig } from "../../config/getConfig"; import { getConfig } from "../../config/getConfig.js";
import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask"; import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask.js";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools"; import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { initializeReporters } from "@lage-run/reporters"; import { initializeReporters } from "@lage-run/reporters";
import { SimpleScheduler } from "@lage-run/scheduler"; import { SimpleScheduler } from "@lage-run/scheduler";
import createLogger, { Reporter } from "@lage-run/logger"; import type { Reporter } from "@lage-run/logger";
import createLogger from "@lage-run/logger";
import type { ReporterInitOptions } from "@lage-run/reporters"; import type { ReporterInitOptions } from "@lage-run/reporters";
import type { SchedulerRunSummary } from "@lage-run/scheduler-types"; import type { SchedulerRunSummary } from "@lage-run/scheduler-types";

Просмотреть файл

@ -1,17 +1,18 @@
import { Command } from "commander"; import type { Command } from "commander";
import { createCache } from "./createCacheProvider"; import { createCache } from "./createCacheProvider.js";
import { createTargetGraph } from "./createTargetGraph"; import { createTargetGraph } from "./createTargetGraph.js";
import { filterArgsForTasks } from "./filterArgsForTasks"; import { filterArgsForTasks } from "./filterArgsForTasks.js";
import { findNpmClient } from "@lage-run/find-npm-client"; import { findNpmClient } from "@lage-run/find-npm-client";
import { getConfig } from "../../config/getConfig"; import { getConfig } from "../../config/getConfig.js";
import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask"; import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask.js";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools"; import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions"; import { filterPipelineDefinitions } from "./filterPipelineDefinitions.js";
import { LogReporter } from "@lage-run/reporters"; import { LogReporter } from "@lage-run/reporters";
import { SimpleScheduler } from "@lage-run/scheduler"; import { SimpleScheduler } from "@lage-run/scheduler";
import { watch } from "./watcher"; import { watch } from "./watcher.js";
import createLogger, { LogLevel, Reporter } from "@lage-run/logger"; import type { Reporter } from "@lage-run/logger";
import createLogger, { LogLevel } from "@lage-run/logger";
import type { ReporterInitOptions } from "@lage-run/reporters"; import type { ReporterInitOptions } from "@lage-run/reporters";
import type { SchedulerRunSummary } from "@lage-run/scheduler-types"; import type { SchedulerRunSummary } from "@lage-run/scheduler-types";

Просмотреть файл

@ -2,7 +2,7 @@ import chokidar from "chokidar";
import path from "path"; import path from "path";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools"; import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import type { PackageInfo, PackageInfos } from "workspace-tools"; import type { PackageInfos } from "workspace-tools";
import EventEmitter from "events"; import EventEmitter from "events";
interface PathIndexItem { interface PathIndexItem {
@ -77,6 +77,7 @@ function findPackageByPath(filePath: string, index: PathIndex) {
for (const pathPart of pathParts) { for (const pathPart of pathParts) {
if (!pointer[pathPart]) { if (!pointer[pathPart]) {
// eslint-disable-next-line no-console
console.log(pathPart, filePath); console.log(pathPart, filePath);
break; break;
} }

Просмотреть файл

@ -1,7 +1,7 @@
import os from "os"; import os from "os";
import { cosmiconfig } from "cosmiconfig"; import { cosmiconfig } from "cosmiconfig";
import { getWorkspaceRoot } from "workspace-tools"; import { getWorkspaceRoot } from "workspace-tools";
import type { ConfigOptions } from "../types/ConfigOptions"; import type { ConfigOptions } from "../types/ConfigOptions.js";
export async function getConfig(cwd: string): Promise<ConfigOptions> { export async function getConfig(cwd: string): Promise<ConfigOptions> {
// Verify presence of git // Verify presence of git

Просмотреть файл

@ -1,4 +1,4 @@
import type { ConfigOptions } from "../types/ConfigOptions"; import type { ConfigOptions } from "../types/ConfigOptions.js";
export function getMaxWorkersPerTask(pipelineConfig: ConfigOptions["pipeline"], concurrency: number) { export function getMaxWorkersPerTask(pipelineConfig: ConfigOptions["pipeline"], concurrency: number) {
const maxWorkersPerTask = new Map<string, number>(); const maxWorkersPerTask = new Map<string, number>();
@ -18,7 +18,7 @@ export function getMaxWorkersPerTask(pipelineConfig: ConfigOptions["pipeline"],
continue; continue;
} }
let maxWorkers: number = 0; let maxWorkers = 0;
if (typeof maxWorkerOption !== "number") { if (typeof maxWorkerOption !== "number") {
throw new Error(`Invalid maxWorkers value: ${maxWorkerOption}`); throw new Error(`Invalid maxWorkers value: ${maxWorkerOption}`);

Просмотреть файл

@ -1,13 +1,13 @@
import type { PackageInfos } from "workspace-tools";
import { import {
getScopedPackages, getScopedPackages,
getChangedPackages, getChangedPackages,
getBranchChanges, getBranchChanges,
PackageInfos,
getTransitiveDependents, getTransitiveDependents,
getTransitiveDependencies, getTransitiveDependencies,
} from "workspace-tools"; } from "workspace-tools";
import * as fg from "fast-glob"; import * as fg from "fast-glob";
import { Logger } from "@lage-run/logger"; import type { Logger } from "@lage-run/logger";
export function getFilteredPackages(options: { export function getFilteredPackages(options: {
root: string; root: string;

Просмотреть файл

@ -1 +1 @@
export type { ConfigOptions } from "./types/ConfigOptions"; export type { ConfigOptions } from "./types/ConfigOptions.js";

Просмотреть файл

@ -1,3 +1,5 @@
/* eslint-disable no-console */
export function showHelp(msg: string) { export function showHelp(msg: string) {
console.error(msg); console.error(msg);

Просмотреть файл

@ -1,4 +1,4 @@
import { Config as BackfillCacheOptions } from "backfill-config"; import type { Config as BackfillCacheOptions } from "backfill-config";
export type CacheOptions = BackfillCacheOptions & { export type CacheOptions = BackfillCacheOptions & {
environmentGlob: string[]; environmentGlob: string[];

Просмотреть файл

@ -1,8 +1,8 @@
import { CacheOptions } from "./CacheOptions"; import type { CacheOptions } from "./CacheOptions.js";
import { Priority } from "./Priority"; import type { Priority } from "./Priority.js";
import { PipelineDefinition } from "./PipelineDefinition"; import type { PipelineDefinition } from "./PipelineDefinition.js";
import { LoggerOptions } from "./LoggerOptions"; import type { LoggerOptions } from "./LoggerOptions.js";
import { TargetRunnerPickerOptions } from "@lage-run/scheduler/lib/runners/TargetRunnerPicker"; import type { TargetRunnerPickerOptions } from "@lage-run/scheduler/lib/runners/TargetRunnerPicker.js";
export type NpmClient = "npm" | "yarn" | "pnpm"; export type NpmClient = "npm" | "yarn" | "pnpm";

Просмотреть файл

@ -1,4 +1,4 @@
import { LogLevel } from "@lage-run/logger"; import type { LogLevel } from "@lage-run/logger";
export interface LoggerOptions { export interface LoggerOptions {
disp?: { disp?: {

Просмотреть файл

@ -1,5 +1,5 @@
import { TargetConfig } from "@lage-run/target-graph"; import type { TargetConfig } from "@lage-run/target-graph";
import { ConfigOptions } from "./ConfigOptions"; import type { ConfigOptions } from "./ConfigOptions.js";
export interface FactoryArgs { export interface FactoryArgs {
cwd: string; cwd: string;

Просмотреть файл

@ -15,7 +15,8 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"start": "tsc -w --preserveWatchOutput", "start": "tsc -w --preserveWatchOutput",
"test": "jest" "test": "jest",
"lint": "monorepo-scripts lint"
}, },
"dependencies": { "dependencies": {
"monorepo-scripts": "*", "monorepo-scripts": "*",

Просмотреть файл

@ -1,5 +1,5 @@
import { Monorepo } from "./mock/monorepo"; import { Monorepo } from "./mock/monorepo.js";
import { filterEntry, parseNdJson } from "./parseNdJson"; import { filterEntry, parseNdJson } from "./parseNdJson.js";
describe("basics", () => { describe("basics", () => {
it("basic test case", () => { it("basic test case", () => {

Просмотреть файл

@ -1,5 +1,5 @@
import { Monorepo } from "./mock/monorepo"; import { Monorepo } from "./mock/monorepo.js";
import { filterEntry, parseNdJson } from "./parseNdJson"; import { filterEntry, parseNdJson } from "./parseNdJson.js";
describe("basic failure case where a dependent target has failed", () => { describe("basic failure case where a dependent target has failed", () => {
it("when a failure happens, halts all other targets", () => { it("when a failure happens, halts all other targets", () => {
@ -62,8 +62,6 @@ describe("basic failure case where a dependent target has failed", () => {
jsonOutput = parseNdJson(output); jsonOutput = parseNdJson(output);
console.log(repo.root);
expect(jsonOutput.find((entry) => filterEntry(entry.data, "b", "build", "failed"))).toBeTruthy(); expect(jsonOutput.find((entry) => filterEntry(entry.data, "b", "build", "failed"))).toBeTruthy();
expect(jsonOutput.find((entry) => filterEntry(entry.data, "b", "test", "success"))).toBeFalsy(); expect(jsonOutput.find((entry) => filterEntry(entry.data, "b", "test", "success"))).toBeFalsy();
expect(jsonOutput.find((entry) => filterEntry(entry.data, "a", "build", "success"))).toBeFalsy(); expect(jsonOutput.find((entry) => filterEntry(entry.data, "a", "build", "success"))).toBeFalsy();

Просмотреть файл

@ -1,6 +1,6 @@
import { Monorepo } from "./mock/monorepo"; import { Monorepo } from "./mock/monorepo.js";
import { getTargetId } from "@lage-run/target-graph"; import { getTargetId } from "@lage-run/target-graph";
import { filterEntry, parseNdJson } from "./parseNdJson"; import { filterEntry, parseNdJson } from "./parseNdJson.js";
describe("bigapp test", () => { describe("bigapp test", () => {
// This test follows the model as documented here: // This test follows the model as documented here:

Просмотреть файл

@ -1,7 +1,7 @@
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import { Monorepo } from "./mock/monorepo"; import { Monorepo } from "./mock/monorepo.js";
const defaultCacheLocation = "node_modules/.cache/backfill"; const defaultCacheLocation = "node_modules/.cache/backfill";
const cacheLocation = ".cache/backfill"; const cacheLocation = ".cache/backfill";

Просмотреть файл

@ -1,9 +1,9 @@
import { Monorepo } from "./mock/monorepo"; import { Monorepo } from "./mock/monorepo.js";
describe("info test", () => { describe("info test", () => {
it("with json reporter", () => { it("with json reporter", () => {
const result = testInfoWithReporter("json"); const result = testInfoWithReporter("json");
var resultObj = JSON.parse(result); const resultObj = JSON.parse(result);
// make deterministic // make deterministic
resultObj.timestamp = 0; resultObj.timestamp = 0;
expect(JSON.stringify(resultObj)).toMatchSnapshot(); expect(JSON.stringify(resultObj)).toMatchSnapshot();

Просмотреть файл

@ -138,7 +138,7 @@ export class Monorepo {
return execa.sync("git", ["push", origin, branch], { cwd: this.root }); return execa.sync("git", ["push", origin, branch], { cwd: this.root });
} }
commitFiles(files: { [name: string]: string | Object }, options: { executable?: boolean } = {}) { commitFiles(files: { [name: string]: string | Record<string, unknown> }, options: { executable?: boolean } = {}) {
for (const [file, contents] of Object.entries(files)) { for (const [file, contents] of Object.entries(files)) {
let out = ""; let out = "";
if (typeof contents !== "string") { if (typeof contents !== "string") {

Просмотреть файл

@ -1,5 +1,5 @@
import { Monorepo } from "./mock/monorepo"; import { Monorepo } from "./mock/monorepo.js";
import { parseNdJson } from "./parseNdJson"; import { parseNdJson } from "./parseNdJson.js";
describe("RemoteFallbackCacheProvider", () => { describe("RemoteFallbackCacheProvider", () => {
it("should skip local cache population if --skip-local-cache is enabled", () => { it("should skip local cache population if --skip-local-cache is enabled", () => {

Просмотреть файл

@ -1,6 +1,6 @@
import { Monorepo } from "./mock/monorepo"; import { Monorepo } from "./mock/monorepo.js";
import { getTargetId } from "@lage-run/target-graph"; import { getTargetId } from "@lage-run/target-graph";
import { filterEntry, parseNdJson } from "./parseNdJson"; import { filterEntry, parseNdJson } from "./parseNdJson.js";
describe("transitive task deps test", () => { describe("transitive task deps test", () => {
// This test follows the model as documented here: // This test follows the model as documented here:

Просмотреть файл

@ -10,7 +10,8 @@
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"start": "tsc -w --preserveWatchOutput" "start": "tsc -w --preserveWatchOutput",
"lint": "monorepo-scripts lint"
}, },
"devDependencies": { "devDependencies": {
"monorepo-scripts": "*" "monorepo-scripts": "*"

Просмотреть файл

@ -1 +1 @@
export { findNpmClient } from "./findNpmClient"; export { findNpmClient } from "./findNpmClient.js";

Просмотреть файл

@ -11,7 +11,8 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"start": "tsc -w --preserveWatchOutput", "start": "tsc -w --preserveWatchOutput",
"test": "jest" "test": "jest",
"lint": "monorepo-scripts lint"
}, },
"devDependencies": {}, "devDependencies": {},
"publishConfig": { "publishConfig": {

Просмотреть файл

@ -1 +1 @@
export { formatDuration, hrToSeconds, hrtimeDiff } from "./formatDuration"; export { formatDuration, hrToSeconds, hrtimeDiff } from "./formatDuration.js";

Просмотреть файл

@ -11,7 +11,8 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"start": "tsc -w --preserveWatchOutput", "start": "tsc -w --preserveWatchOutput",
"test": "jest" "test": "jest",
"lint": "monorepo-scripts lint"
}, },
"devDependencies": {}, "devDependencies": {},
"publishConfig": { "publishConfig": {

Просмотреть файл

@ -1,6 +1,6 @@
import type { LogStructuredData } from "./interfaces/LogStructuredData"; import type { LogStructuredData } from "./interfaces/LogStructuredData.js";
import type { Reporter } from "./interfaces/Reporter"; import type { Reporter } from "./interfaces/Reporter.js";
import { LogLevel } from "./interfaces/LogLevel"; import { LogLevel } from "./interfaces/LogLevel.js";
import { createInterface } from "readline"; import { createInterface } from "readline";
export class Logger<TLogStructuredData extends LogStructuredData = LogStructuredData> { export class Logger<TLogStructuredData extends LogStructuredData = LogStructuredData> {

Просмотреть файл

@ -1,14 +1,14 @@
import { LogStructuredData } from "./interfaces/LogStructuredData"; import type { LogStructuredData } from "./interfaces/LogStructuredData.js";
import { Logger } from "./Logger"; import { Logger } from "./Logger.js";
export default function createLogger<TLogStructuredData extends LogStructuredData = LogStructuredData>() { export default function createLogger<TLogStructuredData extends LogStructuredData = LogStructuredData>() {
return new Logger<TLogStructuredData>(); return new Logger<TLogStructuredData>();
} }
export type { LogEntry } from "./interfaces/LogEntry"; export type { LogEntry } from "./interfaces/LogEntry.js";
export type { Reporter } from "./interfaces/Reporter"; export type { Reporter } from "./interfaces/Reporter.js";
export type { LogStructuredData }; export type { LogStructuredData };
/** Logger, can be extended to have specific TLogStructuredData generic param */ /** Logger, can be extended to have specific TLogStructuredData generic param */
export { Logger }; export { Logger };
export { LogLevel } from "./interfaces/LogLevel"; export { LogLevel } from "./interfaces/LogLevel.js";

Просмотреть файл

@ -1,5 +1,5 @@
import type { LogLevel } from "./LogLevel"; import type { LogLevel } from "./LogLevel.js";
import { LogStructuredData } from "./LogStructuredData"; import type { LogStructuredData } from "./LogStructuredData.js";
export interface LogEntry<TLogStructuredData extends LogStructuredData = LogStructuredData> { export interface LogEntry<TLogStructuredData extends LogStructuredData = LogStructuredData> {
/** a timestamp of when the log event occurred */ /** a timestamp of when the log event occurred */

Просмотреть файл

@ -1,6 +1,6 @@
import type { LogLevel } from "./LogLevel"; import type { LogLevel } from "./LogLevel.js";
import type { LogEntry } from "./LogEntry"; import type { LogEntry } from "./LogEntry.js";
import { LogStructuredData } from "./LogStructuredData"; import type { LogStructuredData } from "./LogStructuredData.js";
export interface Reporter<TLogStructuredData extends LogStructuredData = LogStructuredData> { export interface Reporter<TLogStructuredData extends LogStructuredData = LogStructuredData> {
/** log level, use the LogLevel object */ /** log level, use the LogLevel object */

Просмотреть файл

@ -1 +1 @@
export * from "./monorepo"; export * from "./monorepo.js";

Просмотреть файл

@ -1,11 +1,11 @@
import { formatDuration, hrToSeconds } from "@lage-run/format-hrtime"; import { formatDuration, hrToSeconds } from "@lage-run/format-hrtime";
import { getPackageAndTask } from "@lage-run/target-graph"; import { getPackageAndTask } from "@lage-run/target-graph";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry"; import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry.js";
import { LogLevel } from "@lage-run/logger"; import { LogLevel } from "@lage-run/logger";
import chalk from "chalk"; import chalk from "chalk";
import type { Reporter, LogEntry } from "@lage-run/logger"; import type { Reporter, LogEntry } from "@lage-run/logger";
import type { SchedulerRunSummary, TargetStatus } from "@lage-run/scheduler-types"; import type { SchedulerRunSummary, TargetStatus } from "@lage-run/scheduler-types";
import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry"; import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry.js";
import type { Writable } from "stream"; import type { Writable } from "stream";
const colors = { const colors = {

Просмотреть файл

@ -1,11 +1,11 @@
import { getStartTargetId } from "@lage-run/target-graph"; import { getStartTargetId } from "@lage-run/target-graph";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry"; import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry.js";
import chalk from "chalk"; import chalk from "chalk";
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import type { LogEntry, Reporter } from "@lage-run/logger"; import type { LogEntry, Reporter } from "@lage-run/logger";
import type { SchedulerRunSummary, TargetRun } from "@lage-run/scheduler-types"; import type { SchedulerRunSummary, TargetRun } from "@lage-run/scheduler-types";
import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry"; import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry.js";
import type { Writable } from "stream"; import type { Writable } from "stream";
interface TraceEventsObject { interface TraceEventsObject {

Просмотреть файл

@ -3,7 +3,7 @@
import { hrToSeconds } from "@lage-run/format-hrtime"; import { hrToSeconds } from "@lage-run/format-hrtime";
import type { SchedulerRunSummary } from "@lage-run/scheduler-types"; import type { SchedulerRunSummary } from "@lage-run/scheduler-types";
import type { LogEntry, LogLevel, Reporter } from "@lage-run/logger"; import type { LogEntry, LogLevel, Reporter } from "@lage-run/logger";
import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry"; import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry.js";
export class JsonReporter implements Reporter { export class JsonReporter implements Reporter {
constructor(private options: { logLevel: LogLevel }) {} constructor(private options: { logLevel: LogLevel }) {}

Просмотреть файл

@ -1,6 +1,6 @@
import { formatDuration, hrtimeDiff, hrToSeconds } from "@lage-run/format-hrtime"; import { formatDuration, hrtimeDiff, hrToSeconds } from "@lage-run/format-hrtime";
import { getPackageAndTask } from "@lage-run/target-graph"; import { getPackageAndTask } from "@lage-run/target-graph";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry"; import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry.js";
import { LogLevel } from "@lage-run/logger"; import { LogLevel } from "@lage-run/logger";
import ansiRegex from "ansi-regex"; import ansiRegex from "ansi-regex";
import chalk from "chalk"; import chalk from "chalk";
@ -8,10 +8,10 @@ import type { Chalk } from "chalk";
import gradient from "gradient-string"; import gradient from "gradient-string";
import type { Reporter, LogEntry } from "@lage-run/logger"; import type { Reporter, LogEntry } from "@lage-run/logger";
import type { SchedulerRunSummary, TargetStatus } from "@lage-run/scheduler-types"; import type { SchedulerRunSummary, TargetStatus } from "@lage-run/scheduler-types";
import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry"; import type { TargetMessageEntry, TargetStatusEntry } from "./types/TargetLogEntry.js";
import type { Writable } from "stream"; import type { Writable } from "stream";
import crypto from "crypto"; import crypto from "crypto";
import { formatBytes } from "./formatBytes"; import { formatBytes } from "./formatBytes.js";
const colors = { const colors = {
[LogLevel.info]: chalk.white, [LogLevel.info]: chalk.white,

Просмотреть файл

@ -1,7 +1,7 @@
import { LogLevel } from "@lage-run/logger"; import { LogLevel } from "@lage-run/logger";
import { JsonReporter } from "./JsonReporter"; import { JsonReporter } from "./JsonReporter.js";
import { AdoReporter } from "./AdoReporter"; import { AdoReporter } from "./AdoReporter.js";
import { LogReporter } from "./LogReporter"; import { LogReporter } from "./LogReporter.js";
export function createReporter({ export function createReporter({
reporter = "npmLog", reporter = "npmLog",

Просмотреть файл

@ -1,10 +1,10 @@
export { AdoReporter } from "./AdoReporter"; export { AdoReporter } from "./AdoReporter.js";
export { JsonReporter } from "./JsonReporter"; export { JsonReporter } from "./JsonReporter.js";
export { LogReporter } from "./LogReporter"; export { LogReporter } from "./LogReporter.js";
export { ChromeTraceEventsReporter } from "./ChromeTraceEventsReporter"; export { ChromeTraceEventsReporter } from "./ChromeTraceEventsReporter.js";
export { initializeReporters } from "./initialize"; export { initializeReporters } from "./initialize.js";
export { createReporter } from "./createReporter"; export { createReporter } from "./createReporter.js";
export type { TargetStatusEntry, TargetMessageEntry } from "./types/TargetLogEntry"; export type { TargetStatusEntry, TargetMessageEntry } from "./types/TargetLogEntry.js";
export type { ReporterInitOptions } from "./initialize"; export type { ReporterInitOptions } from "./initialize.js";

Просмотреть файл

@ -1,5 +1,5 @@
import { LogLevel } from "@lage-run/logger"; import { LogLevel } from "@lage-run/logger";
import { createReporter } from "./createReporter"; import { createReporter } from "./createReporter.js";
import type { Logger } from "@lage-run/logger"; import type { Logger } from "@lage-run/logger";
export interface ReporterInitOptions { export interface ReporterInitOptions {

Просмотреть файл

@ -1,5 +1,5 @@
import type { LogStructuredData } from "@lage-run/logger"; import type { LogStructuredData } from "@lage-run/logger";
import type { TargetStatusEntry } from "./types/TargetLogEntry"; import type { TargetStatusEntry } from "./types/TargetLogEntry.js";
export function isTargetStatusLogEntry(data?: LogStructuredData): data is TargetStatusEntry { export function isTargetStatusLogEntry(data?: LogStructuredData): data is TargetStatusEntry {
return data !== undefined && data.target && data.status !== undefined; return data !== undefined && data.target && data.status !== undefined;

Просмотреть файл

@ -1,5 +1,5 @@
export type { TargetRunSummary, SchedulerRunSummary, SchedulerRunResults } from "./types/SchedulerRunSummary"; export type { TargetRunSummary, SchedulerRunSummary, SchedulerRunResults } from "./types/SchedulerRunSummary.js";
export type { TargetRun } from "./types/TargetRun"; export type { TargetRun } from "./types/TargetRun.js";
export type { TargetRunner, TargetRunnerOptions } from "./types/TargetRunner"; export type { TargetRunner, TargetRunnerOptions } from "./types/TargetRunner.js";
export type { TargetScheduler } from "./types/TargetScheduler"; export type { TargetScheduler } from "./types/TargetScheduler.js";
export type { TargetStatus } from "./types/TargetStatus"; export type { TargetStatus } from "./types/TargetStatus.js";

Просмотреть файл

@ -1,5 +1,5 @@
import type { TargetRun } from "./TargetRun"; import type { TargetRun } from "./TargetRun.js";
import type { TargetStatus } from "./TargetStatus"; import type { TargetStatus } from "./TargetStatus.js";
// the "-?" syntax is TypeScript's way of making Mapped Types index signatures to always include a key // the "-?" syntax is TypeScript's way of making Mapped Types index signatures to always include a key
// https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers // https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers

Просмотреть файл

@ -1,5 +1,5 @@
import type { Target } from "@lage-run/target-graph"; import type { Target } from "@lage-run/target-graph";
import type { TargetStatus } from "./TargetStatus"; import type { TargetStatus } from "./TargetStatus.js";
export interface TargetRun { export interface TargetRun {
queueTime: [number, number]; queueTime: [number, number];

Просмотреть файл

@ -1,5 +1,5 @@
import type { TargetGraph } from "@lage-run/target-graph"; import type { TargetGraph } from "@lage-run/target-graph";
import type { SchedulerRunSummary } from "./SchedulerRunSummary"; import type { SchedulerRunSummary } from "./SchedulerRunSummary.js";
export interface TargetScheduler { export interface TargetScheduler {
abort(): void; abort(): void;

Просмотреть файл

@ -1,7 +1,7 @@
import { AbortController } from "abort-controller"; import { AbortController } from "abort-controller";
import { categorizeTargetRuns } from "./categorizeTargetRuns"; import { categorizeTargetRuns } from "./categorizeTargetRuns.js";
import { getStartTargetId, sortTargetsByPriority } from "@lage-run/target-graph"; import { getStartTargetId, sortTargetsByPriority } from "@lage-run/target-graph";
import { WrappedTarget } from "./WrappedTarget"; import { WrappedTarget } from "./WrappedTarget.js";
import type { AbortSignal } from "abort-controller"; import type { AbortSignal } from "abort-controller";
import type { CacheProvider, TargetHasher } from "@lage-run/cache"; import type { CacheProvider, TargetHasher } from "@lage-run/cache";
@ -9,9 +9,9 @@ import type { Logger } from "@lage-run/logger";
import type { TargetGraph, Target } from "@lage-run/target-graph"; import type { TargetGraph, Target } from "@lage-run/target-graph";
import type { TargetScheduler, SchedulerRunResults, SchedulerRunSummary, TargetRunSummary } from "@lage-run/scheduler-types"; import type { TargetScheduler, SchedulerRunResults, SchedulerRunSummary, TargetRunSummary } from "@lage-run/scheduler-types";
import type { Pool } from "@lage-run/worker-threads-pool"; import type { Pool } from "@lage-run/worker-threads-pool";
import type { TargetRunnerPickerOptions } from "./runners/TargetRunnerPicker"; import type { TargetRunnerPickerOptions } from "./runners/TargetRunnerPicker.js";
import { AggregatedPool } from "@lage-run/worker-threads-pool"; import { AggregatedPool } from "@lage-run/worker-threads-pool";
import { formatBytes } from "./formatBytes"; import { formatBytes } from "./formatBytes.js";
export interface SimpleSchedulerOptions { export interface SimpleSchedulerOptions {
logger: Logger; logger: Logger;

Просмотреть файл

@ -1,5 +1,5 @@
import { bufferTransform } from "./bufferTransform"; import { bufferTransform } from "./bufferTransform.js";
import { getLageOutputCacheLocation } from "./getLageOutputCacheLocation"; import { getLageOutputCacheLocation } from "./getLageOutputCacheLocation.js";
import { LogLevel } from "@lage-run/logger"; import { LogLevel } from "@lage-run/logger";
import fs from "fs"; import fs from "fs";

Просмотреть файл

@ -1,4 +1,4 @@
export { NpmScriptRunner } from "./runners/NpmScriptRunner"; export { NpmScriptRunner } from "./runners/NpmScriptRunner.js";
export { SimpleScheduler } from "./SimpleScheduler"; export { SimpleScheduler } from "./SimpleScheduler.js";
export { TargetRunnerPicker } from "./runners/TargetRunnerPicker"; export { TargetRunnerPicker } from "./runners/TargetRunnerPicker.js";
export { WorkerRunner } from "./runners/WorkerRunner"; export { WorkerRunner } from "./runners/WorkerRunner.js";

Просмотреть файл

@ -1,6 +1,6 @@
import path from "path"; import path from "path";
import { getStartTargetId } from "@lage-run/target-graph"; import { getStartTargetId } from "@lage-run/target-graph";
import { NoOpRunner } from "./NoOpRunner"; import { NoOpRunner } from "./NoOpRunner.js";
import type { Target } from "@lage-run/target-graph"; import type { Target } from "@lage-run/target-graph";
import type { TargetRunner } from "@lage-run/scheduler-types"; import type { TargetRunner } from "@lage-run/scheduler-types";

Просмотреть файл

@ -1,8 +1,8 @@
import { registerWorker } from "@lage-run/worker-threads-pool"; import { registerWorker } from "@lage-run/worker-threads-pool";
import { TargetRunnerPicker } from "../runners/TargetRunnerPicker"; import { TargetRunnerPicker } from "../runners/TargetRunnerPicker.js";
import { workerData } from "worker_threads"; import { workerData } from "worker_threads";
import type { AbortSignal } from "abort-controller"; import type { AbortSignal } from "abort-controller";
import type { TargetRunnerPickerOptions } from "../runners/TargetRunnerPicker"; import type { TargetRunnerPickerOptions } from "../runners/TargetRunnerPicker.js";
interface TargetWorkerDataOptions { interface TargetWorkerDataOptions {
runners: TargetRunnerPickerOptions; runners: TargetRunnerPickerOptions;

Просмотреть файл

@ -1,16 +1,16 @@
import { createDependencyMap } from "workspace-tools/lib/graph/createDependencyMap"; import { createDependencyMap } from "workspace-tools/lib/graph/createDependencyMap.js";
import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId"; import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId.js";
import { prioritize } from "./prioritize"; import { prioritize } from "./prioritize.js";
import { expandDepSpecs } from "./expandDepSpecs"; import { expandDepSpecs } from "./expandDepSpecs.js";
import path from "path"; import path from "path";
import type { DependencyMap } from "workspace-tools/lib/graph/createDependencyMap"; import type { DependencyMap } from "workspace-tools/lib/graph/createDependencyMap.js";
import type { PackageInfos } from "workspace-tools"; import type { PackageInfos } from "workspace-tools";
import type { Target } from "./types/Target"; import type { Target } from "./types/Target.js";
import type { TargetConfig } from "./types/TargetConfig"; import type { TargetConfig } from "./types/TargetConfig.js";
import { detectCycles } from "./detectCycles"; import { detectCycles } from "./detectCycles.js";
import { getWeight } from "./getWeight"; import { getWeight } from "./getWeight.js";
/** /**
* TargetGraphBuilder class provides a builder API for registering target configs. It exposes a method called `generateTargetGraph` to * TargetGraphBuilder class provides a builder API for registering target configs. It exposes a method called `generateTargetGraph` to

Просмотреть файл

@ -1,4 +1,4 @@
import type { Target } from "./types/Target"; import type { Target } from "./types/Target.js";
/** /**
* Checks for any cycles in the dependency graph, returning `{ hasCycle: false }` if no cycles were detected. * Checks for any cycles in the dependency graph, returning `{ hasCycle: false }` if no cycles were detected.

Просмотреть файл

@ -1,6 +1,6 @@
import type { Target } from "./types/Target"; import type { Target } from "./types/Target.js";
import type { DependencyMap } from "workspace-tools/lib/graph/createDependencyMap"; import type { DependencyMap } from "workspace-tools/lib/graph/createDependencyMap.js";
import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId"; import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId.js";
/** /**
* Expands the dependency graph by adding all transitive dependencies of the given targets. * Expands the dependency graph by adding all transitive dependencies of the given targets.

Просмотреть файл

@ -1,4 +1,4 @@
import type { Target } from "./types/Target"; import type { Target } from "./types/Target.js";
export function getWeight( export function getWeight(
target: Target, target: Target,

Просмотреть файл

@ -1,8 +1,8 @@
export type { Target } from "./types/Target"; export type { Target } from "./types/Target.js";
export type { TargetGraph } from "./types/TargetGraph"; export type { TargetGraph } from "./types/TargetGraph.js";
export type { TargetConfig } from "./types/TargetConfig"; export type { TargetConfig } from "./types/TargetConfig.js";
export { sortTargetsByPriority } from "./sortTargetsByPriority"; export { sortTargetsByPriority } from "./sortTargetsByPriority.js";
export { getPackageAndTask, getTargetId, getStartTargetId } from "./targetId"; export { getPackageAndTask, getTargetId, getStartTargetId } from "./targetId.js";
export { detectCycles } from "./detectCycles"; export { detectCycles } from "./detectCycles.js";
export { TargetGraphBuilder } from "./TargetGraphBuilder"; export { TargetGraphBuilder } from "./TargetGraphBuilder.js";

Просмотреть файл

@ -1,4 +1,4 @@
import type { Target } from "./types/Target"; import type { Target } from "./types/Target.js";
function getNodesWithNoDependencies(targets: Map<string, Target>) { function getNodesWithNoDependencies(targets: Map<string, Target>) {
const nodesWithNoDependencies: string[] = []; const nodesWithNoDependencies: string[] = [];

Просмотреть файл

@ -1,4 +1,4 @@
import type { Target } from "./types/Target"; import type { Target } from "./types/Target.js";
export function sortTargetsByPriority(targets: Target[]) { export function sortTargetsByPriority(targets: Target[]) {
return targets.sort((a, b) => { return targets.sort((a, b) => {

Просмотреть файл

@ -1,4 +1,4 @@
import type { Target } from "./Target"; import type { Target } from "./Target.js";
/** /**
* Target configuration - to be used inside `lage.config.js` options.pipeline configurations * Target configuration - to be used inside `lage.config.js` options.pipeline configurations

Просмотреть файл

@ -1,4 +1,4 @@
import type { Target } from "../types/Target"; import type { Target } from "../types/Target.js";
export interface TargetGraph { export interface TargetGraph {
targets: Map<string, Target>; targets: Map<string, Target>;

Просмотреть файл

@ -1,10 +1,10 @@
import type { AbortSignal } from "abort-controller"; import type { AbortSignal } from "abort-controller";
import type { Readable } from "stream"; import type { Readable } from "stream";
import type { Worker, WorkerOptions } from "worker_threads"; import type { Worker, WorkerOptions } from "worker_threads";
import type { Pool } from "./types/Pool"; import type { Pool } from "./types/Pool.js";
import type { Logger } from "@lage-run/logger"; import type { Logger } from "@lage-run/logger";
import { WorkerPool } from "./WorkerPool"; import { WorkerPool } from "./WorkerPool.js";
interface AggregatedPoolOptions { interface AggregatedPoolOptions {
groupBy: (data: any) => string; groupBy: (data: any) => string;

Просмотреть файл

@ -4,18 +4,18 @@
*/ */
import { AsyncResource } from "async_hooks"; import { AsyncResource } from "async_hooks";
import { createFilteredStreamTransform } from "./createFilteredStreamTransform"; import { createFilteredStreamTransform } from "./createFilteredStreamTransform.js";
import { createInterface } from "readline"; import { createInterface } from "readline";
import { endMarker, startMarker } from "./stdioStreamMarkers"; import { endMarker, startMarker } from "./stdioStreamMarkers.js";
import { EventEmitter } from "events"; import { EventEmitter } from "events";
import { Worker } from "worker_threads"; import { Worker } from "worker_threads";
import crypto from "crypto"; import crypto from "crypto";
import os from "os"; import os from "os";
import type { Pool } from "./types/Pool"; import type { Pool } from "./types/Pool.js";
import type { Readable } from "stream"; import type { Readable } from "stream";
import type { AbortSignal } from "abort-controller"; import type { AbortSignal } from "abort-controller";
import type { WorkerPoolOptions } from "./types/WorkerPoolOptions"; import type { WorkerPoolOptions } from "./types/WorkerPoolOptions.js";
const kTaskInfo = Symbol("kTaskInfo"); const kTaskInfo = Symbol("kTaskInfo");
const kWorkerFreedEvent = Symbol("kWorkerFreedEvent"); const kWorkerFreedEvent = Symbol("kWorkerFreedEvent");

Просмотреть файл

@ -1,5 +1,5 @@
import { Transform } from "stream"; import { Transform } from "stream";
import { END_MARKER_PREFIX, START_MARKER_PREFIX } from "./stdioStreamMarkers"; import { END_MARKER_PREFIX, START_MARKER_PREFIX } from "./stdioStreamMarkers.js";
export function createFilteredStreamTransform(): Transform { export function createFilteredStreamTransform(): Transform {
const transform = new Transform({ const transform = new Transform({

Просмотреть файл

@ -1,4 +1,4 @@
export { registerWorker } from "./registerWorker"; export { registerWorker } from "./registerWorker.js";
export { WorkerPool } from "./WorkerPool"; export { WorkerPool } from "./WorkerPool.js";
export { AggregatedPool } from "./AggregatedPool"; export { AggregatedPool } from "./AggregatedPool.js";
export type { Pool } from "./types/Pool"; export type { Pool } from "./types/Pool.js";

Просмотреть файл

@ -1,6 +1,6 @@
import { parentPort } from "worker_threads"; import { parentPort } from "worker_threads";
import { AbortController } from "abort-controller"; import { AbortController } from "abort-controller";
import { endMarker, startMarker } from "./stdioStreamMarkers"; import { endMarker, startMarker } from "./stdioStreamMarkers.js";
import type { AbortSignal } from "abort-controller"; import type { AbortSignal } from "abort-controller";
import type { MessagePort } from "worker_threads"; import type { MessagePort } from "worker_threads";

Просмотреть файл

@ -1,13 +1,14 @@
module.exports = { module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser", parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"], plugins: ["@typescript-eslint", "file-extension-in-import-ts"],
rules: { rules: {
"@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error", "@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"no-console": "error" "no-console": "error",
"file-extension-in-import-ts/file-extension-in-import-ts": "error"
}, },
parserOptions: { parserOptions: {
project: "./tsconfig.json", project: "./tsconfig.json",

Просмотреть файл

@ -11,6 +11,8 @@ const moduleNameMapper = Object.values(packages).reduce((acc, { packageJsonPath,
return acc; return acc;
}, {}); }, {});
moduleNameMapper["^(\\.{1,2}/.*)\\.js$"] = "$1";
/** @type {import("ts-jest").JestConfigWithTsJest} */ /** @type {import("ts-jest").JestConfigWithTsJest} */
module.exports = { module.exports = {
clearMocks: true, clearMocks: true,
@ -18,10 +20,11 @@ module.exports = {
collectCoverageFrom: ["src/**/*.ts", "!src/types/*.ts", "!**/node_modules/**"], collectCoverageFrom: ["src/**/*.ts", "!src/types/*.ts", "!**/node_modules/**"],
coverageDirectory: "coverage", coverageDirectory: "coverage",
coverageProvider: "v8", coverageProvider: "v8",
extensionsToTreatAsEsm: [".ts"],
testMatch: ["**/?(*.)+(spec|test).ts?(x)"], testMatch: ["**/?(*.)+(spec|test).ts?(x)"],
testPathIgnorePatterns: ["/node_modules/"], testPathIgnorePatterns: ["/node_modules/"],
transform: { transform: {
"^.+\\.tsx?$": ["ts-jest", { tsconfig: { isolatedModules: true } }], "^.+\\.tsx?$": ["ts-jest", { tsconfig: { isolatedModules: true }, useESM: true }],
}, },
transformIgnorePatterns: ["/node_modules/", "\\.pnp\\.[^\\/]+$"], transformIgnorePatterns: ["/node_modules/", "\\.pnp\\.[^\\/]+$"],
watchPathIgnorePatterns: ["/node_modules/"], watchPathIgnorePatterns: ["/node_modules/"],

Просмотреть файл

@ -11,6 +11,7 @@
"ts-jest": "^29.0.0", "ts-jest": "^29.0.0",
"typescript": "^4.4.4", "typescript": "^4.4.4",
"eslint": "^8.20.0", "eslint": "^8.20.0",
"eslint-plugin-file-extension-in-import-ts": "^1.0.1",
"workspace-tools": "^0.29.0", "workspace-tools": "^0.29.0",
"@typescript-eslint/eslint-plugin": "^5.30.7", "@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7" "@typescript-eslint/parser": "^5.30.7"

Просмотреть файл

@ -6,7 +6,7 @@ const { readFile } = require("fs/promises");
const path = require("path"); const path = require("path");
module.exports = async function run(data) { module.exports = async function run(data) {
const { target } = data; const { target, taskArgs } = data;
const packageJson = JSON.parse(await readFile(path.join(target.cwd, "package.json"), "utf8")); const packageJson = JSON.parse(await readFile(path.join(target.cwd, "package.json"), "utf8"));
if (!packageJson.scripts?.[target.task]) { if (!packageJson.scripts?.[target.task]) {
@ -18,19 +18,24 @@ module.exports = async function run(data) {
const baseConfig = require(path.join(PROJECT_ROOT, "scripts/config/eslintrc.js")); const baseConfig = require(path.join(PROJECT_ROOT, "scripts/config/eslintrc.js"));
baseConfig.parserOptions.project = path.join(target.cwd, "tsconfig.json"); baseConfig.parserOptions.project = path.join(target.cwd, "tsconfig.json");
const shouldFix = taskArgs?.includes("--fix");
const eslint = new ESLint({ const eslint = new ESLint({
reportUnusedDisableDirectives: "error", reportUnusedDisableDirectives: "error",
baseConfig, baseConfig,
fix: false, fix: shouldFix,
cache: false, cache: false,
cwd: target.cwd, cwd: target.cwd,
}); });
const files = "src/**/*.ts"; const files = ["src/**/*.ts", "src/*.ts"];
const results = await eslint.lintFiles(files); const results = await eslint.lintFiles(files);
const formatter = await eslint.loadFormatter("stylish"); const formatter = await eslint.loadFormatter("stylish");
const resultText = await formatter.format(results); const resultText = await formatter.format(results);
// 3. Modify the files with the fixed code.
await ESLint.outputFixes(results);
// 4. Output it. // 4. Output it.
if (resultText) { if (resultText) {
process.stdout.write(resultText + "\n"); process.stdout.write(resultText + "\n");

Просмотреть файл

@ -5844,6 +5844,14 @@ escape-string-regexp@^4.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
eslint-plugin-file-extension-in-import-ts@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-file-extension-in-import-ts/-/eslint-plugin-file-extension-in-import-ts-1.0.1.tgz#aa1cf3e9771e1395ad2284c9186f00a597e80f42"
integrity sha512-3Z24WhVyhA0vxj0xfS1ws+1z49LKivdeb9Bp7SdY36x6UJtJYnyi9L6GNJAjVgFTj8ux8M5wz06h/quSyhTYUg==
dependencies:
is-core-module "^2.9.0"
resolve "^1.22.1"
eslint-scope@5.1.1, eslint-scope@^5.1.1: eslint-scope@5.1.1, eslint-scope@^5.1.1:
version "5.1.1" version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"