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 { salt } from "./salt";
import { salt } from "./salt.js";
import type { Logger as BackfillLogger } from "backfill-logger";
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 { makeLogger } 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() {
const stdout = process.stdout;

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

@ -1,5 +1,5 @@
export { BackfillCacheProvider } from "./providers/BackfillCacheProvider";
export { RemoteFallbackCacheProvider } from "./providers/RemoteFallbackCacheProvider";
export { TargetHasher } from "./TargetHasher";
export type { CacheOptions } from "./types/CacheOptions";
export type { CacheProvider } from "./types/CacheProvider";
export { BackfillCacheProvider } from "./providers/BackfillCacheProvider.js";
export { RemoteFallbackCacheProvider } from "./providers/RemoteFallbackCacheProvider.js";
export { TargetHasher } from "./TargetHasher.js";
export type { CacheOptions } from "./types/CacheOptions.js";
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 { getPackageInfos } from "workspace-tools";
import { promisify } from "util";
import * as fs from "fs";
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 { PackageInfo } from "workspace-tools";
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 { 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 {
/**

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

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

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

@ -12,6 +12,7 @@ async function main() {
}
main().catch((err) => {
// eslint-disable-next-line no-console
console.error(err);
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) {
return program

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

@ -1,7 +1,7 @@
import { clearCache } from "./clearCache";
import { Command } from "commander";
import { getConfig } from "../../config/getConfig";
import { pruneCache } from "./pruneCache";
import { clearCache } from "./clearCache.js";
import type { Command } from "commander";
import { getConfig } from "../../config/getConfig.js";
import { pruneCache } from "./pruneCache.js";
import createLogger from "@lage-run/logger";
import { initializeReporters } 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 { 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 { Logger } from "@lage-run/logger";
import type { Logger } from "@lage-run/logger";
import { stat } from "fs/promises";
import fs from "fs";
import path from "path";

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

@ -1,6 +1,6 @@
import { Command, Option } from "commander";
import { addLoggerOptions } from "../addLoggerOptions";
import { cacheAction } from "./action";
import { addLoggerOptions } from "../addLoggerOptions.js";
import { cacheAction } from "./action.js";
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 fs from "fs";
import path from "path";
import { getCacheDir, removeCacheEntry } from "./cacheDir";
import { getCacheDir, removeCacheEntry } from "./cacheDir.js";
import { getWorkspaces } from "workspace-tools";
const MS_IN_A_DAY = 1000 * 60 * 60 * 24;

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

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

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

@ -1,6 +1,7 @@
import { BackfillCacheProvider, CacheOptions, RemoteFallbackCacheProvider, TargetHasher } from "@lage-run/cache";
import { Logger } from "@lage-run/logger";
import { isRunningFromCI } from "../isRunningFromCI";
import type { CacheOptions } from "@lage-run/cache";
import { BackfillCacheProvider, RemoteFallbackCacheProvider, TargetHasher } from "@lage-run/cache";
import type { Logger } from "@lage-run/logger";
import { isRunningFromCI } from "../isRunningFromCI.js";
interface CreateCacheOptions {
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 { getPackageInfos, PackageInfos } from "workspace-tools";
import { getFilteredPackages } from "../../filter/getFilteredPackages";
import type { PipelineDefinition } from "../../types/PipelineDefinition";
import { filterArgsForTasks } from "./filterArgsForTasks";
import type { PackageInfos } from "workspace-tools";
import { getFilteredPackages } from "../../filter/getFilteredPackages.js";
import type { PipelineDefinition } from "../../types/PipelineDefinition.js";
interface CreateTargetGraphOptions {
logger: Logger;

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

@ -1,5 +1,5 @@
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) {
const tasksSet = new Set<string>();

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

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

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

@ -1,17 +1,18 @@
import { Command } from "commander";
import { createCache } from "./createCacheProvider";
import { createProfileReporter } from "./createProfileReporter";
import { createTargetGraph } from "./createTargetGraph";
import { filterArgsForTasks } from "./filterArgsForTasks";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions";
import type { Command } from "commander";
import { createCache } from "./createCacheProvider.js";
import { createProfileReporter } from "./createProfileReporter.js";
import { createTargetGraph } from "./createTargetGraph.js";
import { filterArgsForTasks } from "./filterArgsForTasks.js";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions.js";
import { findNpmClient } from "@lage-run/find-npm-client";
import { getConfig } from "../../config/getConfig";
import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask";
import { getConfig } from "../../config/getConfig.js";
import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask.js";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { initializeReporters } from "@lage-run/reporters";
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 { SchedulerRunSummary } from "@lage-run/scheduler-types";

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

@ -1,17 +1,18 @@
import { Command } from "commander";
import { createCache } from "./createCacheProvider";
import { createTargetGraph } from "./createTargetGraph";
import { filterArgsForTasks } from "./filterArgsForTasks";
import type { Command } from "commander";
import { createCache } from "./createCacheProvider.js";
import { createTargetGraph } from "./createTargetGraph.js";
import { filterArgsForTasks } from "./filterArgsForTasks.js";
import { findNpmClient } from "@lage-run/find-npm-client";
import { getConfig } from "../../config/getConfig";
import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask";
import { getConfig } from "../../config/getConfig.js";
import { getMaxWorkersPerTask, getMaxWorkersPerTaskFromOptions } from "../../config/getMaxWorkersPerTask.js";
import { getPackageInfos, getWorkspaceRoot } from "workspace-tools";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions";
import { filterPipelineDefinitions } from "./filterPipelineDefinitions.js";
import { LogReporter } from "@lage-run/reporters";
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 { SchedulerRunSummary } from "@lage-run/scheduler-types";

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

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

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

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

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

@ -1,13 +1,13 @@
import type { PackageInfos } from "workspace-tools";
import {
getScopedPackages,
getChangedPackages,
getBranchChanges,
PackageInfos,
getTransitiveDependents,
getTransitiveDependencies,
} from "workspace-tools";
import * as fg from "fast-glob";
import { Logger } from "@lage-run/logger";
import type { Logger } from "@lage-run/logger";
export function getFilteredPackages(options: {
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) {
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 & {
environmentGlob: string[];

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

@ -1,8 +1,8 @@
import { CacheOptions } from "./CacheOptions";
import { Priority } from "./Priority";
import { PipelineDefinition } from "./PipelineDefinition";
import { LoggerOptions } from "./LoggerOptions";
import { TargetRunnerPickerOptions } from "@lage-run/scheduler/lib/runners/TargetRunnerPicker";
import type { CacheOptions } from "./CacheOptions.js";
import type { Priority } from "./Priority.js";
import type { PipelineDefinition } from "./PipelineDefinition.js";
import type { LoggerOptions } from "./LoggerOptions.js";
import type { TargetRunnerPickerOptions } from "@lage-run/scheduler/lib/runners/TargetRunnerPicker.js";
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 {
disp?: {

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

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

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

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

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

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

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

@ -1,5 +1,5 @@
import { Monorepo } from "./mock/monorepo";
import { filterEntry, parseNdJson } from "./parseNdJson";
import { Monorepo } from "./mock/monorepo.js";
import { filterEntry, parseNdJson } from "./parseNdJson.js";
describe("basic failure case where a dependent target has failed", () => {
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);
console.log(repo.root);
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, "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 { filterEntry, parseNdJson } from "./parseNdJson";
import { filterEntry, parseNdJson } from "./parseNdJson.js";
describe("bigapp test", () => {
// This test follows the model as documented here:

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

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

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

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

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

@ -138,7 +138,7 @@ export class Monorepo {
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)) {
let out = "";
if (typeof contents !== "string") {

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

@ -1,5 +1,5 @@
import { Monorepo } from "./mock/monorepo";
import { parseNdJson } from "./parseNdJson";
import { Monorepo } from "./mock/monorepo.js";
import { parseNdJson } from "./parseNdJson.js";
describe("RemoteFallbackCacheProvider", () => {
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 { filterEntry, parseNdJson } from "./parseNdJson";
import { filterEntry, parseNdJson } from "./parseNdJson.js";
describe("transitive task deps test", () => {
// This test follows the model as documented here:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,6 +1,6 @@
import type { LogLevel } from "./LogLevel";
import type { LogEntry } from "./LogEntry";
import { LogStructuredData } from "./LogStructuredData";
import type { LogLevel } from "./LogLevel.js";
import type { LogEntry } from "./LogEntry.js";
import type { LogStructuredData } from "./LogStructuredData.js";
export interface Reporter<TLogStructuredData extends LogStructuredData = LogStructuredData> {
/** 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 { getPackageAndTask } from "@lage-run/target-graph";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry.js";
import { LogLevel } from "@lage-run/logger";
import chalk from "chalk";
import type { Reporter, LogEntry } from "@lage-run/logger";
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";
const colors = {

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

@ -1,11 +1,11 @@
import { getStartTargetId } from "@lage-run/target-graph";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry.js";
import chalk from "chalk";
import fs from "fs";
import path from "path";
import type { LogEntry, Reporter } from "@lage-run/logger";
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";
interface TraceEventsObject {

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

@ -3,7 +3,7 @@
import { hrToSeconds } from "@lage-run/format-hrtime";
import type { SchedulerRunSummary } from "@lage-run/scheduler-types";
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 {
constructor(private options: { logLevel: LogLevel }) {}

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

@ -1,6 +1,6 @@
import { formatDuration, hrtimeDiff, hrToSeconds } from "@lage-run/format-hrtime";
import { getPackageAndTask } from "@lage-run/target-graph";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry";
import { isTargetStatusLogEntry } from "./isTargetStatusLogEntry.js";
import { LogLevel } from "@lage-run/logger";
import ansiRegex from "ansi-regex";
import chalk from "chalk";
@ -8,10 +8,10 @@ import type { Chalk } from "chalk";
import gradient from "gradient-string";
import type { Reporter, LogEntry } from "@lage-run/logger";
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 crypto from "crypto";
import { formatBytes } from "./formatBytes";
import { formatBytes } from "./formatBytes.js";
const colors = {
[LogLevel.info]: chalk.white,

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

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

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

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

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

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

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

@ -1,5 +1,5 @@
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 {
return data !== undefined && data.target && data.status !== undefined;

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

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

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

@ -1,5 +1,5 @@
import type { TargetRun } from "./TargetRun";
import type { TargetStatus } from "./TargetStatus";
import type { TargetRun } from "./TargetRun.js";
import type { TargetStatus } from "./TargetStatus.js";
// 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

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

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

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

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

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

@ -1,7 +1,7 @@
import { AbortController } from "abort-controller";
import { categorizeTargetRuns } from "./categorizeTargetRuns";
import { categorizeTargetRuns } from "./categorizeTargetRuns.js";
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 { 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 { TargetScheduler, SchedulerRunResults, SchedulerRunSummary, TargetRunSummary } from "@lage-run/scheduler-types";
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 { formatBytes } from "./formatBytes";
import { formatBytes } from "./formatBytes.js";
export interface SimpleSchedulerOptions {
logger: Logger;

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

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

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

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

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

@ -1,6 +1,6 @@
import path from "path";
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 { TargetRunner } from "@lage-run/scheduler-types";

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

@ -1,8 +1,8 @@
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 type { AbortSignal } from "abort-controller";
import type { TargetRunnerPickerOptions } from "../runners/TargetRunnerPicker";
import type { TargetRunnerPickerOptions } from "../runners/TargetRunnerPicker.js";
interface TargetWorkerDataOptions {
runners: TargetRunnerPickerOptions;

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

@ -1,16 +1,16 @@
import { createDependencyMap } from "workspace-tools/lib/graph/createDependencyMap";
import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId";
import { prioritize } from "./prioritize";
import { expandDepSpecs } from "./expandDepSpecs";
import { createDependencyMap } from "workspace-tools/lib/graph/createDependencyMap.js";
import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId.js";
import { prioritize } from "./prioritize.js";
import { expandDepSpecs } from "./expandDepSpecs.js";
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 { Target } from "./types/Target";
import type { TargetConfig } from "./types/TargetConfig";
import { detectCycles } from "./detectCycles";
import { getWeight } from "./getWeight";
import type { Target } from "./types/Target.js";
import type { TargetConfig } from "./types/TargetConfig.js";
import { detectCycles } from "./detectCycles.js";
import { getWeight } from "./getWeight.js";
/**
* 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.

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

@ -1,6 +1,6 @@
import type { Target } from "./types/Target";
import type { DependencyMap } from "workspace-tools/lib/graph/createDependencyMap";
import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId";
import type { Target } from "./types/Target.js";
import type { DependencyMap } from "workspace-tools/lib/graph/createDependencyMap.js";
import { getPackageAndTask, getStartTargetId, getTargetId } from "./targetId.js";
/**
* 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(
target: Target,

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

@ -1,8 +1,8 @@
export type { Target } from "./types/Target";
export type { TargetGraph } from "./types/TargetGraph";
export type { TargetConfig } from "./types/TargetConfig";
export type { Target } from "./types/Target.js";
export type { TargetGraph } from "./types/TargetGraph.js";
export type { TargetConfig } from "./types/TargetConfig.js";
export { sortTargetsByPriority } from "./sortTargetsByPriority";
export { getPackageAndTask, getTargetId, getStartTargetId } from "./targetId";
export { detectCycles } from "./detectCycles";
export { TargetGraphBuilder } from "./TargetGraphBuilder";
export { sortTargetsByPriority } from "./sortTargetsByPriority.js";
export { getPackageAndTask, getTargetId, getStartTargetId } from "./targetId.js";
export { detectCycles } from "./detectCycles.js";
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>) {
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[]) {
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

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

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

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

@ -1,10 +1,10 @@
import type { AbortSignal } from "abort-controller";
import type { Readable } from "stream";
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 { WorkerPool } from "./WorkerPool";
import { WorkerPool } from "./WorkerPool.js";
interface AggregatedPoolOptions {
groupBy: (data: any) => string;

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

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

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

@ -1,5 +1,5 @@
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 {
const transform = new Transform({

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

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

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

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

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

@ -1,13 +1,14 @@
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
plugins: ["@typescript-eslint", "file-extension-in-import-ts"],
rules: {
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/no-non-null-assertion": "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: {
project: "./tsconfig.json",

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

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

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

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

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

@ -6,7 +6,7 @@ const { readFile } = require("fs/promises");
const path = require("path");
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"));
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"));
baseConfig.parserOptions.project = path.join(target.cwd, "tsconfig.json");
const shouldFix = taskArgs?.includes("--fix");
const eslint = new ESLint({
reportUnusedDisableDirectives: "error",
baseConfig,
fix: false,
fix: shouldFix,
cache: false,
cwd: target.cwd,
});
const files = "src/**/*.ts";
const files = ["src/**/*.ts", "src/*.ts"];
const results = await eslint.lintFiles(files);
const formatter = await eslint.loadFormatter("stylish");
const resultText = await formatter.format(results);
// 3. Modify the files with the fixed code.
await ESLint.outputFixes(results);
// 4. Output it.
if (resultText) {
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"
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:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"