Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
lint:fix
  • Loading branch information
legobeat committed Oct 13, 2023
commit c65368b641fdb906f7dfb776ba2fbdf080044d51
2 changes: 1 addition & 1 deletion src/command-line-arguments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
import yargs from 'yargs/yargs';

export type CommandLineArguments = {
projectDirectory: string;
Expand Down
1 change: 1 addition & 0 deletions src/editor.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { when } from 'jest-when';

import { determineEditor } from './editor';
import * as envModule from './env';
import * as miscUtils from './misc-utils';
Expand Down
2 changes: 2 additions & 0 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function determineEditor(): Promise<Editor | null> {
executablePath = await resolveExecutable(EDITOR);
} catch (error) {
debug(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Could not resolve executable ${EDITOR} (${error}), falling back to VSCode`,
);
}
Expand All @@ -43,6 +44,7 @@ export async function determineEditor(): Promise<Editor | null> {
executableArgs.push('--wait');
} catch (error) {
debug(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Could not resolve path to VSCode: ${error}, continuing regardless`,
);
}
Expand Down
7 changes: 4 additions & 3 deletions src/fs.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as actionUtils from '@metamask/action-utils';
import fs from 'fs';
import { when } from 'jest-when';
import path from 'path';
import { rimraf } from 'rimraf';
import { when } from 'jest-when';
import * as actionUtils from '@metamask/action-utils';
import { withSandbox } from '../tests/helpers';

import {
readFile,
writeFile,
Expand All @@ -13,6 +13,7 @@ import {
ensureDirectoryPathExists,
removeFile,
} from './fs';
import { withSandbox } from '../tests/helpers';

jest.mock('@metamask/action-utils');

Expand Down
3 changes: 2 additions & 1 deletion src/fs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from 'fs';
import {
readJsonObjectFile as underlyingReadJsonObjectFile,
writeJsonFile as underlyingWriteJsonFile,
} from '@metamask/action-utils';
import fs from 'fs';

import { wrapError, isErrorWithCode } from './misc-utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/functional.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withMonorepoProjectEnvironment } from '../tests/functional/helpers/with';
import { buildChangelog } from '../tests/functional/helpers/utils';
import { withMonorepoProjectEnvironment } from '../tests/functional/helpers/with';

jest.setTimeout(10_000);

Expand Down
11 changes: 6 additions & 5 deletions src/initial-parameters.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { when } from 'jest-when';
import os from 'os';
import path from 'path';
import { when } from 'jest-when';

import * as commandLineArgumentsModule from './command-line-arguments';
import * as envModule from './env';
import { determineInitialParameters } from './initial-parameters';
import * as projectModule from './project';
import {
buildMockProject,
buildMockPackage,
createNoopWriteStream,
} from '../tests/unit/helpers';
import { determineInitialParameters } from './initial-parameters';
import * as commandLineArgumentsModule from './command-line-arguments';
import * as envModule from './env';
import * as projectModule from './project';

jest.mock('./command-line-arguments');
jest.mock('./env');
Expand Down
6 changes: 4 additions & 2 deletions src/initial-parameters.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os from 'os';
import path from 'path';

import { readCommandLineArguments } from './command-line-arguments';
import { WriteStreamLike } from './fs';
import { readProject, Project } from './project';
import type { WriteStreamLike } from './fs';
import type { Project } from './project';
import { readProject } from './project';

/**
* The type of release being created as determined by the parent release.
Expand Down
5 changes: 3 additions & 2 deletions src/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from 'fs';
import { buildMockProject } from '../tests/unit/helpers';
import { main } from './main';

import * as initialParametersModule from './initial-parameters';
import { main } from './main';
import * as monorepoWorkflowOperations from './monorepo-workflow-operations';
import { buildMockProject } from '../tests/unit/helpers';

jest.mock('./initial-parameters');
jest.mock('./monorepo-workflow-operations');
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { WriteStream } from 'fs';

import { determineInitialParameters } from './initial-parameters';
import { followMonorepoWorkflow } from './monorepo-workflow-operations';

Expand Down
3 changes: 2 additions & 1 deletion src/misc-utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as whichModule from 'which';
import * as execaModule from 'execa';
import * as whichModule from 'which';

import {
isErrorWithCode,
isErrorWithMessage,
Expand Down
13 changes: 7 additions & 6 deletions src/misc-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import which from 'which';
import execa from 'execa';
import { isObject } from '@metamask/utils';
import createDebug from 'debug';
import execa from 'execa';
import { ErrorWithCause } from 'pony-cause';
import { isObject } from '@metamask/utils';
import which from 'which';

export { isTruthyString } from '@metamask/action-utils';
export { hasProperty, isNullOrUndefined } from '@metamask/utils';
Expand Down Expand Up @@ -91,6 +91,7 @@ export function wrapError(message: string, originalError: unknown) {
return error;
}

// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return new Error(`${message}: ${originalError}`);
}

Expand Down Expand Up @@ -130,7 +131,7 @@ export async function resolveExecutable(
export async function runCommand(
command: string,
args?: readonly string[] | undefined,
options?: execa.Options<string> | undefined,
options?: execa.Options | undefined,
): Promise<void> {
await execa(command, args, options);
}
Expand All @@ -149,7 +150,7 @@ export async function runCommand(
export async function getStdoutFromCommand(
command: string,
args?: readonly string[] | undefined,
options?: execa.Options<string> | undefined,
options?: execa.Options | undefined,
): Promise<string> {
return (await execa(command, args, options)).stdout.trim();
}
Expand All @@ -167,7 +168,7 @@ export async function getStdoutFromCommand(
export async function getLinesFromCommand(
command: string,
args?: readonly string[] | undefined,
options?: execa.Options<string> | undefined,
options?: execa.Options | undefined,
): Promise<string[]> {
const { stdout } = await execa(command, args, options);
return stdout.split('\n').filter((value) => value !== '');
Expand Down
17 changes: 10 additions & 7 deletions src/monorepo-workflow-operations.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import fs from 'fs';
import path from 'path';
import { when } from 'jest-when';
import path from 'path';
import { MockWritable } from 'stdio-mock';
import { withSandbox, Sandbox, isErrorWithCode } from '../tests/helpers';
import { buildMockProject, Require } from '../tests/unit/helpers';
import { followMonorepoWorkflow } from './monorepo-workflow-operations';

import * as editorModule from './editor';
import type { Editor } from './editor';
import { ReleaseType } from './initial-parameters';
import * as releaseSpecificationModule from './release-specification';
import type { ReleaseSpecification } from './release-specification';
import type { ReleaseType } from './initial-parameters';
import { followMonorepoWorkflow } from './monorepo-workflow-operations';
import * as releasePlanModule from './release-plan';
import type { ReleasePlan } from './release-plan';
import * as releaseSpecificationModule from './release-specification';
import type { ReleaseSpecification } from './release-specification';
import * as repoModule from './repo';
import { withSandbox, isErrorWithCode } from '../tests/helpers';
import type { Sandbox } from '../tests/helpers';
import { buildMockProject } from '../tests/unit/helpers';
import type { Require } from '../tests/unit/helpers';

jest.mock('./editor');
jest.mock('./release-plan');
Expand Down
9 changes: 5 additions & 4 deletions src/monorepo-workflow-operations.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import type { WriteStream } from 'fs';
import path from 'path';

import { determineEditor } from './editor';
import {
ensureDirectoryPathExists,
fileExists,
removeFile,
writeFile,
} from './fs';
import { determineEditor } from './editor';
import { ReleaseType } from './initial-parameters';
import { Project } from './project';
import type { ReleaseType } from './initial-parameters';
import type { Project } from './project';
import { planRelease, executeReleasePlan } from './release-plan';
import { captureChangesInReleaseBranch } from './repo';
import {
generateReleaseSpecificationTemplateForMonorepo,
waitForUserToEditReleaseSpecification,
validateReleaseSpecification,
} from './release-specification';
import { captureChangesInReleaseBranch } from './repo';

/**
* For a monorepo, the process works like this:
Expand Down
3 changes: 2 additions & 1 deletion src/package-manifest.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from 'fs';
import path from 'path';
import { SemVer } from 'semver';
import { withSandbox } from '../tests/helpers';

import { readPackageManifest } from './package-manifest';
import { withSandbox } from '../tests/helpers';

describe('package-manifest', () => {
describe('readPackageManifest', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/package-manifest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import path from 'path';
import {
ManifestFieldNames as PackageManifestFieldNames,
ManifestDependencyFieldNames as PackageManifestDependenciesFieldNames,
} from '@metamask/action-utils';
import { isPlainObject } from '@metamask/utils';
import path from 'path';

import { readJsonObjectFile } from './fs';
import { isTruthyString } from './misc-utils';
import { isValidSemver, SemVer } from './semver';
Expand Down
21 changes: 11 additions & 10 deletions src/package.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import * as autoChangelog from '@metamask/auto-changelog';
import fs from 'fs';
import path from 'path';
import { when } from 'jest-when';
import * as autoChangelog from '@metamask/auto-changelog';
import path from 'path';
import { SemVer } from 'semver';
import { MockWritable } from 'stdio-mock';
import { withSandbox } from '../tests/helpers';
import {
buildMockPackage,
buildMockProject,
buildMockManifest,
createNoopWriteStream,
} from '../tests/unit/helpers';

import * as fsModule from './fs';
import {
readMonorepoRootPackage,
readMonorepoWorkspacePackage,
updatePackage,
} from './package';
import * as fsModule from './fs';
import * as packageManifestModule from './package-manifest';
import * as repoModule from './repo';
import { withSandbox } from '../tests/helpers';
import {
buildMockPackage,
buildMockProject,
buildMockManifest,
createNoopWriteStream,
} from '../tests/unit/helpers';

jest.mock('@metamask/auto-changelog');
jest.mock('./package-manifest');
Expand Down
19 changes: 11 additions & 8 deletions src/package.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import fs, { WriteStream } from 'fs';
import { updateChangelog } from '@metamask/auto-changelog';
import type { WriteStream } from 'fs';
import fs from 'fs';
import path from 'path';
import { format } from 'util';
import { updateChangelog } from '@metamask/auto-changelog';
import { WriteStreamLike, readFile, writeFile, writeJsonFile } from './fs';

import type { WriteStreamLike } from './fs';
import { readFile, writeFile, writeJsonFile } from './fs';
import { isErrorWithCode } from './misc-utils';
import {
readPackageManifest,
import type {
UnvalidatedPackageManifest,
ValidatedPackageManifest,
} from './package-manifest';
import { Project } from './project';
import { PackageReleasePlan } from './release-plan';
import { readPackageManifest } from './package-manifest';
import type { Project } from './project';
import type { PackageReleasePlan } from './release-plan';
import { hasChangesInDirectorySinceGitTag } from './repo';
import { SemVer } from './semver';
import type { SemVer } from './semver';

const MANIFEST_FILE_NAME = 'package.json';
const CHANGELOG_FILE_NAME = 'CHANGELOG.md';
Expand Down
11 changes: 6 additions & 5 deletions src/project.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as actionUtils from '@metamask/action-utils';
import fs from 'fs';
import path from 'path';
import { when } from 'jest-when';
import path from 'path';
import { SemVer } from 'semver';
import * as actionUtils from '@metamask/action-utils';
import { withSandbox } from '../tests/helpers';
import { buildMockPackage, createNoopWriteStream } from '../tests/unit/helpers';
import { readProject } from './project';

import * as packageModule from './package';
import { readProject } from './project';
import * as repoModule from './repo';
import { withSandbox } from '../tests/helpers';
import { buildMockPackage, createNoopWriteStream } from '../tests/unit/helpers';

jest.mock('./package');
jest.mock('./repo');
Expand Down
15 changes: 8 additions & 7 deletions src/project.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { resolve } from 'path';
import { getWorkspaceLocations } from '@metamask/action-utils';
import { WriteStreamLike } from './fs';
import { resolve } from 'path';

import type { WriteStreamLike } from './fs';
import type { Package } from './package';
import {
Package,
readMonorepoRootPackage,
readMonorepoWorkspacePackage,
} from './package';
import { getRepositoryHttpsUrl, getTagNames } from './repo';
import { SemVer } from './semver';
import { PackageManifestFieldNames } from './package-manifest';
import { getRepositoryHttpsUrl, getTagNames } from './repo';
import type { SemVer } from './semver';

/**
* The release version of the root package of a monorepo extracted from its
Expand Down Expand Up @@ -110,9 +111,9 @@ export async function readProject(
});
}),
)
).reduce((obj, pkg) => {
).reduce<Record<string, Package>>((obj, pkg) => {
return { ...obj, [pkg.validatedManifest.name]: pkg };
}, {} as Record<string, Package>);
}, {});

const isMonorepo = Object.keys(workspacePackages).length > 0;

Expand Down
5 changes: 3 additions & 2 deletions src/release-plan.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import fs from 'fs';
import { SemVer } from 'semver';
import { buildMockProject, buildMockPackage } from '../tests/unit/helpers';

import * as packageUtils from './package';
import { planRelease, executeReleasePlan } from './release-plan';
import { IncrementableVersionParts } from './release-specification';
import * as packageUtils from './package';
import { buildMockProject, buildMockPackage } from '../tests/unit/helpers';

jest.mock('./package');

Expand Down
Loading