Skip to content

Commit

Permalink
Revert "Revert "Revert "BREAKING CHANGE: substantial dep mgmt effort …
Browse files Browse the repository at this point in the history
…- drop support for Node v12, 14, 16" (NerdWalletOSS#608)" (NerdWalletOSS#611)"

This reverts commit 22a9a43.
  • Loading branch information
aorinevo committed Oct 2, 2023
1 parent 71c5c55 commit 0f3947b
Show file tree
Hide file tree
Showing 25 changed files with 3,832 additions and 4,100 deletions.
26 changes: 12 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ module.exports = {
sourceType: 'module',
},
rules: {
'@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,
'@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',
},
plugins: ['@typescript-eslint', 'import', 'prefer-arrow'],
settings: {
Expand All @@ -42,7 +40,7 @@ module.exports = {
{
files: ['*.ts', '*.tsx'],
parserOptions: {
project: ['tsconfig.cjs.json'],
project: ['tsconfig.eslint.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: ['18', '20']
node: ['12', '14', '16']
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: 18
node-version: 12
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

## [1.16.1](https://github.com/NerdWalletOSS/shepherd/compare/v1.16.0...v1.16.1) (2023-09-25)


### Reverts

- Revert "BREAKING CHANGE: substantial dep mgmt effort - drop support for Node v12, 14, 16" (#608) ([58b9b1c](https://github.com/NerdWalletOSS/shepherd/commit/58b9b1c2a4a936c6b67409a1981201704fb4d5ae)), closes [#608](https://github.com/NerdWalletOSS/shepherd/issues/608)
* Revert "BREAKING CHANGE: substantial dep mgmt effort - drop support for Node v12, 14, 16" (#608) ([58b9b1c](https://github.com/NerdWalletOSS/shepherd/commit/58b9b1c2a4a936c6b67409a1981201704fb4d5ae)), closes [#608](https://github.com/NerdWalletOSS/shepherd/issues/608)

# [1.16.0](https://github.com/NerdWalletOSS/shepherd/compare/v1.15.5...v1.16.0) (2021-12-03)

Expand Down
70 changes: 32 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
},
"license": "Apache-2.0",
"author": "Nathan Walters",
"main": "./lib/cli.js",
"bin": {
"shepherd": "./lib/cli.js"
},
"scripts": {
"build": "tsc -p tsconfig.cjs.json",
"build": "tsc",
"build:watch": "yarn build --watch",
"fix-lint": "eslint src/**/*.ts --fix && prettier --write .",
"lint": "eslint src/**/*.ts && prettier --check .",
Expand All @@ -40,56 +39,51 @@
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"transform": {
"^.+\\.tsx?$": [
"ts-jest",
{
"tsconfig": "tsconfig.cjs.json"
}
]
"^.+\\.tsx?$": "ts-jest"
}
},
"files": [
"lib"
],
"dependencies": {
"@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",
"@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",
"child-process-promise": "^2.2.1",
"commander": "^6.2.1",
"fs-extra": "^11.1.1",
"joi": "^17.10.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"log-symbols": "^4.1.0",
"fs-extra": "^9.1.0",
"joi": "^17.4.0",
"js-yaml": "^3.14.1",
"lodash": "^4.17.19",
"log-symbols": "^4.0.0",
"netrc": "^0.1.4",
"ora": "^5.4.1",
"ora": "^5.3.0",
"preferences": "^2.0.2",
"simple-git": "^3.19.1"
"simple-git": "^2.36.1"
},
"devDependencies": {
"@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",
"@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",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^29.6.4",
"prettier": "^3.0.3",
"semantic-release": "^21.1.1",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
"jest": "^27.0.0",
"prettier": "2.5.1",
"semantic-release": "^17.3.8",
"ts-jest": "^27.0.0",
"typescript": "^3.9.9"
},
"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 } from 'simple-git';
import simpleGit, { SimpleGit } from 'simple-git/promise';

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): any {
protected git(repo: IRepo): SimpleGit {
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: 2 additions & 4 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: any) {
} catch (e) {
if (e.code === 404) {
status.push('No branch or PR exists');
} else {
Expand Down Expand Up @@ -323,9 +323,7 @@ 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 }: any) =>
this.isShepherdCommitMessage(message)
);
const allShepherd = commits.all.every(({ message }) => 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: any) {
} catch (e) {
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: any) {
} catch (e) {
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: any) {
} catch (e) {
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: any) {
} catch (e) {
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: any) {
} catch (e) {
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: any) {
} catch (e) {
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: any) {
} catch (e) {
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: any) {
} catch (e) {
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: any) {
} catch (e) {
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 as string);
logger.error(e);
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: 5 additions & 1 deletion src/services/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ 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: any) {
} catch (e) {
// 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 * as yaml from 'js-yaml';
import 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.load(fs.readFileSync(docPath, 'utf8'));
const spec = yaml.safeLoad(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.load(await fs.readFile(legacyFile, 'utf8'));
const data = yaml.safeLoad(await fs.readFile(legacyFile, 'utf8'));
await fs.outputFile(getRepoListFile(migrationContext), jsonStringify(data));
await fs.remove(legacyFile);
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// extend your base config to share compilerOptions, etc
"extends": "./tsconfig.cjs.json",
"extends": "./tsconfig.json",
"compilerOptions": {
// ensure that nobody can accidentally use this config for a build
"noEmit": true
Expand Down
Loading

0 comments on commit 0f3947b

Please sign in to comment.