From 460969208e265cb477e07f02d71f59702b0d14d0 Mon Sep 17 00:00:00 2001 From: Josh Stillman Date: Sat, 28 Sep 2024 15:39:04 -0400 Subject: [PATCH 1/2] switch to json for pinned versions list --- .../installDependencies.ts | 2 +- src/installDependencies/pinnedVersions.json | 19 ++++++++++++++++++ src/installDependencies/pinnedVersions.ts | 20 ------------------- 3 files changed, 20 insertions(+), 21 deletions(-) create mode 100644 src/installDependencies/pinnedVersions.json delete mode 100644 src/installDependencies/pinnedVersions.ts diff --git a/src/installDependencies/installDependencies.ts b/src/installDependencies/installDependencies.ts index af6e9af..5f1cf93 100644 --- a/src/installDependencies/installDependencies.ts +++ b/src/installDependencies/installDependencies.ts @@ -2,7 +2,7 @@ import execa from 'execa'; import ora from 'ora'; import chalk from 'chalk'; import { PROGRESS_MESSAGES } from '../progressMessages'; -import { PINNED_VERSIONS } from './pinnedVersions'; +import PINNED_VERSIONS from './pinnedVersions.json'; export const installDeps = async ({ useYarn, diff --git a/src/installDependencies/pinnedVersions.json b/src/installDependencies/pinnedVersions.json new file mode 100644 index 0000000..c829afa --- /dev/null +++ b/src/installDependencies/pinnedVersions.json @@ -0,0 +1,19 @@ +{ + "_UPDATED_AT": "9/28/2024", + "@eslint/js": "9.11.1", + "@types/eslint__js": "8.42.3", + "eslint": "9.11.1", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.2.1", + "eslint-plugin-n": "17.10.3", + "eslint-plugin-react": "7.36.1", + "globals": "15.9.0", + "lint-staged": "15.2.10", + "prettier": "3.3.3", + "simple-git-hooks": "2.11.1", + "stylelint": "16.9.0", + "stylelint-config-sass-guidelines": "12.1.0", + "stylelint-config-standard": "36.0.1", + "stylelint-prettier": "5.0.2", + "typescript-eslint": "8.7.0" +} diff --git a/src/installDependencies/pinnedVersions.ts b/src/installDependencies/pinnedVersions.ts deleted file mode 100644 index 39d57ba..0000000 --- a/src/installDependencies/pinnedVersions.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const PINNED_VERSIONS = { - '@eslint/js': '9.11.1', - '@types/eslint__js': '8.42.3', - eslint: '9.11.1', - 'eslint-config-prettier': '9.1.0', - 'eslint-plugin-prettier': '5.2.1', - 'eslint-plugin-n': '17.10.3', - 'eslint-plugin-react': '7.36.1', - globals: '15.9.0', - 'lint-staged': '15.2.10', - prettier: '3.3.3', - 'simple-git-hooks': '2.11.1', - stylelint: '16.9.0', - 'stylelint-config-sass-guidelines': '12.1.0', - 'stylelint-config-standard': '36.0.1', - 'stylelint-prettier': '5.0.2', - 'typescript-eslint': '8.7.0', -}; - -// Updated 09/26/2024 From 0528709c11a154b4091a6a0392d049b85d62231c Mon Sep 17 00:00:00 2001 From: Josh Stillman Date: Sat, 28 Sep 2024 16:08:08 -0400 Subject: [PATCH 2/2] use remote pinned versions json --- .../installDependencies.ts | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/installDependencies/installDependencies.ts b/src/installDependencies/installDependencies.ts index 5f1cf93..92d4bfc 100644 --- a/src/installDependencies/installDependencies.ts +++ b/src/installDependencies/installDependencies.ts @@ -27,7 +27,7 @@ export const installDeps = async ({ const installProcess = execa(useYarn ? 'yarn' : 'npm', [ useYarn ? 'add' : 'install', - ...getDepList({ node, react, styleLint, sass, lintStaged, pinned }), + ...(await getDepList({ node, react, styleLint, sass, lintStaged, pinned })), '-E', '-D', ]); @@ -48,9 +48,8 @@ export const installDeps = async ({ // } }; -export const getDepList = ({ +export const getDepList = async ({ react, - node, styleLint, sass, @@ -64,6 +63,27 @@ export const getDepList = ({ lintStaged: boolean; pinned: boolean; }) => { + let pinnedJson = PINNED_VERSIONS; + + if (pinned) { + // fetch updated list of pinned versions, falling back to version from published package + try { + const remotePinned = await fetch( + 'https://raw.githubusercontent.com/josh-stillman/lintier/refs/heads/main/src/installDependencies/pinnedVersions.json' + ); + + const json = (await remotePinned.json()) as typeof PINNED_VERSIONS; + + pinnedJson = json; + + console.log(`Using pinned versions from ${pinnedJson['_UPDATED_AT']}`); + } catch (error) { + console.error( + `Error fetching remote list of pinned versions, falling back to list from ${PINNED_VERSIONS['_UPDATED_AT']}\n\n${error}` + ); + } + } + return [ 'eslint', 'prettier', @@ -88,20 +108,22 @@ export const getDepList = ({ ...(lintStaged ? ['simple-git-hooks', 'lint-staged'] : []), ].map( packageName => - `${packageName}@${getVersion({ packageName, usePinned: pinned })}` + `${packageName}@${getVersion({ packageName, usePinned: pinned, pinnedJson })}` ); }; export const getVersion = ({ packageName, usePinned, + pinnedJson, }: { packageName: string; usePinned: boolean; + pinnedJson: typeof PINNED_VERSIONS; }) => !usePinned ? 'latest' - : PINNED_VERSIONS[packageName as keyof typeof PINNED_VERSIONS] || 'latest'; + : pinnedJson[packageName as keyof typeof PINNED_VERSIONS] || 'latest'; // const installAirBnb = async ({ // useYarn,