Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

BREAKING CHANGE: substantial dep mgmt effort - drop support for EOL Node versions #613

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ module.exports = {
sourceType: 'module',
},
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/require-await': 'off',
'no-useless-escape': 'off',
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-argument': 0,
'@typescript-eslint/no-this-alias': 0,
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/restrict-template-expressions': 0,
'@typescript-eslint/unbound-method': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/require-await': 0,
'no-useless-escape': 0,
},
plugins: ['@typescript-eslint', 'import', 'prefer-arrow'],
settings: {
Expand All @@ -40,7 +42,7 @@ module.exports = {
{
files: ['*.ts', '*.tsx'],
parserOptions: {
project: ['tsconfig.eslint.json'],
project: ['tsconfig.cjs.json'],
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['12', '14', '16']
node: ['18', '20']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 18
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
72 changes: 39 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nerdwallet/shepherd",
"version": "1.16.0",
"version": "2.0.0",
"description": "A utility for applying code changes across many repositories",
"keywords": [
"codemod",
Expand All @@ -17,11 +17,12 @@
},
"license": "Apache-2.0",
"author": "Nathan Walters",
"main": "./lib/cli.js",
"bin": {
"shepherd": "./lib/cli.js"
},
"scripts": {
"build": "tsc",
"build": "tsc -p tsconfig.cjs.json",
"build:watch": "yarn build --watch",
"fix-lint": "eslint src/**/*.ts --fix && prettier --write .",
"lint": "eslint src/**/*.ts && prettier --check .",
Expand All @@ -39,51 +40,56 @@
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"transform": {
"^.+\\.tsx?$": "ts-jest"
"^.+\\.tsx?$": [
"ts-jest",
{
"tsconfig": "tsconfig.cjs.json"
}
]
}
},
"files": [
"lib"
],
"dependencies": {
"@octokit/plugin-retry": "^3.0.9",
"@octokit/plugin-throttling": "^3.5.2",
"@octokit/rest": "^18.12.0",
"@types/js-yaml": "^3.12.6",
"chalk": "^4.1.0",
"@octokit/core": "^5.0.0",
"@octokit/plugin-retry": "^6.0.0",
"@octokit/plugin-throttling": "^7.0.0",
"@octokit/rest": "^20.0.1",
"@types/js-yaml": "^4.0.5",
"chalk": "^4.1.2",
"child-process-promise": "^2.2.1",
"commander": "^6.2.1",
"fs-extra": "^9.1.0",
"joi": "^17.4.0",
"js-yaml": "^3.14.1",
"lodash": "^4.17.19",
"log-symbols": "^4.0.0",
"fs-extra": "^11.1.1",
"joi": "^17.10.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"log-symbols": "^4.1.0",
"netrc": "^0.1.4",
"ora": "^5.3.0",
"ora": "^5.4.1",
"preferences": "^2.0.2",
"simple-git": "^2.36.1"
"simple-git": "^3.19.1"
},
"devDependencies": {
"@octokit/plugin-rest-endpoint-methods": "^5.0.0",
"@octokit/types": "^6.8.3",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@types/fs-extra": "^9.0.6",
"@types/jest": "^27.0.0",
"@types/lodash": "^4.14.167",
"@types/log-symbols": "^2.0.0",
"@types/node": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"eslint": "^7.19.0",
"@octokit/plugin-rest-endpoint-methods": "^9.0.0",
"@octokit/types": "^11.1.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/fs-extra": "^11.0.1",
"@types/jest": "^29.5.4",
"@types/lodash": "^4.14.198",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^27.0.0",
"prettier": "2.5.1",
"semantic-release": "^17.3.8",
"ts-jest": "^27.0.0",
"typescript": "^3.9.9"
"jest": "^29.6.4",
"prettier": "^3.0.3",
"semantic-release": "^21.1.1",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/git.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable class-methods-use-this */
import fs from 'fs-extra';
import simpleGit, { SimpleGit } from 'simple-git/promise';
import { simpleGit } from 'simple-git';

import { IMigrationContext } from '../migration-context';
import IRepoAdapter, { IEnvironmentVariables, IRepo, RetryMethod } from './base';
Expand Down Expand Up @@ -90,7 +90,7 @@ abstract class GitAdapter implements IRepoAdapter {

protected abstract getRepositoryUrl(repo: IRepo): string;

protected git(repo: IRepo): SimpleGit {
protected git(repo: IRepo): any {
return simpleGit(this.getRepoDir(repo));
}

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mockMigrationContext = () =>
title: 'Test migration',
},
},
} as IMigrationContext);
}) as IMigrationContext;

describe('GithubAdapter', () => {
describe('reposEqual', () => {
Expand Down
6 changes: 4 additions & 2 deletions src/adapters/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class GithubAdapter extends GitAdapter {
branch: this.branchName,
});
status.push('No PR exists');
} catch (e) {
} catch (e: any) {
if (e.code === 404) {
status.push('No branch or PR exists');
} else {
Expand Down Expand Up @@ -323,7 +323,9 @@ class GithubAdapter extends GitAdapter {
// master.
const upstreamBranch = `remotes/origin/${this.branchName}`;
const commits = await this.git(repo).log([`HEAD..${upstreamBranch}`]);
const allShepherd = commits.all.every(({ message }) => this.isShepherdCommitMessage(message));
const allShepherd = commits.all.every(({ message }: any) =>
this.isShepherdCommitMessage(message)
);
if (!allShepherd) {
// RIP.
return SafetyStatus.NonShepherdCommits;
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const handleCommand =
migrationContext.migration.repos = await loadRepoList(migrationContext);

await handler(migrationContext, options);
} catch (e) {
} catch (e: any) {
logger.error(e);
process.exit(1);
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async (context: IMigrationContext, options: any): Promise<void> =
try {
await adapter.resetChangedFiles(repo);
resetSpinner.succeed('Successfully reset repo');
} catch (e) {
} catch (e: any) {
logger.error(e);
resetSpinner.fail('Failed to remove changes; not applying migration');
return;
Expand All @@ -23,7 +23,7 @@ export default async (context: IMigrationContext, options: any): Promise<void> =
try {
await adapter.resetRepoBeforeApply(repo, options.forceResetBranch);
resetBranchSpinner.succeed('Successfully reset branch');
} catch (e) {
} catch (e: any) {
logger.error(e);
resetBranchSpinner.fail('Failed to reset branch; not applying migration');
return;
Expand All @@ -45,7 +45,7 @@ export default async (context: IMigrationContext, options: any): Promise<void> =
try {
await adapter.resetChangedFiles(repo);
spinner.succeed('Successfully reset repo');
} catch (e) {
} catch (e: any) {
logger.error(e);
spinner.fail('Failed to reset repo');
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default async (context: IMigrationContext) => {
try {
await adapter.checkoutRepo(repo);
spinner.succeed('Checked out repo');
} catch (e) {
} catch (e: any) {
logger.error(e);
spinner.fail('Failed to check out repo; skipping');
return;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async (context: IMigrationContext) => {
try {
await adapter.commitRepo(repo);
spinner.succeed('Changes committed');
} catch (e) {
} catch (e: any) {
logger.error(e);
spinner.fail('Failed to commit changes');
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/pr-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async (context: IMigrationContext) => {
const status = await adapter.getPullRequestStatus(repo);
spinner.destroy();
status.forEach((s) => logger.info(s));
} catch (e) {
} catch (e: any) {
logger.error(e);
spinner.fail('Failed to determine PR status');
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async (context: IMigrationContext) => {
try {
await context.adapter.createPullRequest(repo, message);
prSpinner.succeed('Pull request created');
} catch (e) {
} catch (e: any) {
logger.error(e);
prSpinner.fail('Failed to create pull request');
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async (context: IMigrationContext, options: any) => {
try {
await adapter.pushRepo(repo, options.force);
spinner.succeed('Changes pushed');
} catch (e) {
} catch (e: any) {
logger.error(e);
spinner.fail('Failed to push changes');
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async (context: IMigrationContext) => {
await adapter.resetChangedFiles(repo);
spinner.succeed('Reset changes');
} catch (e) {
logger.error(e);
logger.error(e as string);
spinner.fail('Failed to reset changes');
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/services/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Octokit } from '@octokit/rest';
import { IMigrationContext } from '../migration-context';
import GithubService from './github';

const mockMigrationContext = () => ({} as IMigrationContext);
const mockMigrationContext = () => ({}) as IMigrationContext;

describe('GithubService', () => {
describe('getDefaultBranchForRepo', () => {
Expand Down
6 changes: 1 addition & 5 deletions src/services/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ export default class GithubService {
this.octokit = new RetryableThrottledOctokit({
auth: token,
throttle: {
enabled: false,
onRateLimit: (retryAfter: number, options: any) => {
context.logger.warn(`Hit rate limit for ${options.method} ${options.url}`);
context.logger.warn(`Retrying in ${retryAfter} second(s)`);
return options.request.retryCount < 5;
},
onAbuseLimit: (retryAfter: number, options: any) => {
context.logger.warn(`Hit abuse limit for ${options.method} ${options.url}`);
context.logger.warn(`Retrying in ${retryAfter} second(s)`);
return options.request.retryCount < 5;
},
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/execute-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default async (
stdout: childProcessResult.stdout,
stderr: childProcessResult.stderr,
});
} catch (e) {
} catch (e: any) {
// This could either be an error from the process itself (which will have an exit code)
// or an error from JavaScript world (e.g. the script wasn't executable)
if (e.code !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions src/util/migration-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Joi from 'joi';
import fs from 'fs';
import yaml from 'js-yaml';
import * as yaml from 'js-yaml';
import { cloneDeep, mapValues } from 'lodash';
import path from 'path';

Expand All @@ -26,7 +26,7 @@ export interface IMigrationSpec {

export function loadSpec(directory: string): IMigrationSpec {
const docPath = path.join(directory, 'shepherd.yml');
const spec = yaml.safeLoad(fs.readFileSync(docPath, 'utf8'));
const spec = yaml.load(fs.readFileSync(docPath, 'utf8'));
const normalizedSpec = normalizeSpec(spec);
const validationResult = validateSpec(normalizedSpec);
if (validationResult.error) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/persisted-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const makeContext = (workingDirectory: string) =>
adapter: {
reposEqual: (r1: IRepo, r2: IRepo) => isEqual(r1, r2),
},
} as IMigrationContext);
}) as IMigrationContext;

describe('persisted-data', () => {
it('loads repo list from a file', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/util/persisted-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const jsonStringify = (data: any) => JSON.stringify(data, undefined, 2);
const migrateToJsonIfNeeded = async (migrationContext: IMigrationContext) => {
const legacyFile = getLegacyRepoListFile(migrationContext);
if (await fs.pathExists(legacyFile)) {
const data = yaml.safeLoad(await fs.readFile(legacyFile, 'utf8'));
const data = yaml.load(await fs.readFile(legacyFile, 'utf8'));
await fs.outputFile(getRepoListFile(migrationContext), jsonStringify(data));
await fs.remove(legacyFile);
}
Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json → tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"compilerOptions": {
"target": "ES2016",
"module": "commonjs",
"target": "ES2018",
"module": "CommonJS",
"allowJs": false,
"declaration": true,
"sourceMap": true,
"outDir": "lib",
"outDir": "./lib",
"rootDir": "./src",
"removeComments": false,
"resolveJsonModule": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
Expand Down
Loading
Loading