mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-30 16:01:14 -04:00
refactor: remove invariant (#62275)
This commit is contained in:
committed by
GitHub
parent
56c34a3bd6
commit
c6498cf0b4
@@ -47,7 +47,6 @@
|
||||
"@vitest/ui": "^3.2.4",
|
||||
"chai": "4.4.1",
|
||||
"glob": "8.1.0",
|
||||
"invariant": "2.2.4",
|
||||
"joi": "17.12.2",
|
||||
"joi-objectid": "3.0.1",
|
||||
"js-yaml": "4.0.0",
|
||||
|
||||
@@ -38,14 +38,13 @@ WORKDIR /home/node/build
|
||||
COPY --chown=node:node pnpm*.yaml .
|
||||
COPY --chown=node:node package.json .
|
||||
COPY --chown=node:node api/ api/
|
||||
COPY --chown=node:node shared/ shared/
|
||||
RUN npm i -g pnpm@10
|
||||
|
||||
# Weirdly this config does not seem necessary for the new api (the same number
|
||||
# of deps are installed in both cases), but I'm including it just for
|
||||
# consistency.
|
||||
RUN pnpm config set dedupe-peer-dependents false
|
||||
RUN pnpm install --prod --ignore-scripts -F=shared -F=api --frozen-lockfile
|
||||
RUN pnpm install --prod --ignore-scripts -F=api --frozen-lockfile
|
||||
RUN cd api && npx prisma@$(jq -r '.devDependencies.prisma' < package.json) generate
|
||||
|
||||
FROM node:22-bookworm
|
||||
@@ -56,7 +55,6 @@ COPY --from=builder --chown=node:node /home/node/build/api/package.json api/
|
||||
COPY --from=builder --chown=node:node /home/node/build/shared/config/curriculum.json shared/config/
|
||||
|
||||
COPY --from=deps --chown=node:node /home/node/build/node_modules/ node_modules/
|
||||
COPY --from=deps --chown=node:node /home/node/build/shared/node_modules/ shared/node_modules/
|
||||
COPY --from=deps --chown=node:node /home/node/build/api/node_modules/ api/node_modules/
|
||||
|
||||
CMD ["node", "api/src/server.js"]
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
"@redux-saga/core" // Not referenced, something seems off related to peer dep and types
|
||||
]
|
||||
},
|
||||
"curriculum": {
|
||||
"ignoreDependencies": ["invariant"] // Used from another workspace: shared/utils/polyvinyl.js
|
||||
},
|
||||
"shared": {
|
||||
"ignore": ["{config,utils}/*.ts"] // Using the same dir for src + outDir files with tsc confuses Knip
|
||||
},
|
||||
|
||||
17
pnpm-lock.yaml
generated
17
pnpm-lock.yaml
generated
@@ -736,9 +736,6 @@ importers:
|
||||
glob:
|
||||
specifier: 8.1.0
|
||||
version: 8.1.0
|
||||
invariant:
|
||||
specifier: 2.2.4
|
||||
version: 2.2.4
|
||||
joi:
|
||||
specifier: 17.12.2
|
||||
version: 17.12.2
|
||||
@@ -782,14 +779,7 @@ importers:
|
||||
specifier: ^3.2.4
|
||||
version: 3.2.4(@types/node@20.12.8)(@vitest/ui@3.2.4)(jsdom@16.7.0)(msw@2.8.7(@types/node@20.12.8)(typescript@5.8.2))(terser@5.28.1)(tsx@4.19.1)(yaml@2.8.0)
|
||||
|
||||
shared:
|
||||
dependencies:
|
||||
'@types/invariant':
|
||||
specifier: ^2.2.37
|
||||
version: 2.2.37
|
||||
invariant:
|
||||
specifier: 2.2.4
|
||||
version: 2.2.4
|
||||
shared: {}
|
||||
|
||||
tools/challenge-editor/api:
|
||||
dependencies:
|
||||
@@ -4610,9 +4600,6 @@ packages:
|
||||
'@types/inquirer@8.2.11':
|
||||
resolution: {integrity: sha512-15UboTvxb9SOaPG7CcXZ9dkv8lNqfiAwuh/5WxJDLjmElBt9tbx1/FDsEnJddUBKvN4mlPKvr8FyO1rAmBanzg==}
|
||||
|
||||
'@types/invariant@2.2.37':
|
||||
resolution: {integrity: sha512-IwpIMieE55oGWiXkQPSBY1nw1nFs6bsKXTFskNY8sdS17K24vyEBRQZEwlRS7ZmXCWnJcQtbxWzly+cODWGs2A==}
|
||||
|
||||
'@types/istanbul-lib-coverage@2.0.4':
|
||||
resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==}
|
||||
|
||||
@@ -19615,8 +19602,6 @@ snapshots:
|
||||
'@types/through': 0.0.33
|
||||
rxjs: 7.8.1
|
||||
|
||||
'@types/invariant@2.2.37': {}
|
||||
|
||||
'@types/istanbul-lib-coverage@2.0.4': {}
|
||||
|
||||
'@types/istanbul-lib-report@3.0.1':
|
||||
|
||||
@@ -17,9 +17,5 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/freeCodeCamp/freeCodeCamp/issues"
|
||||
},
|
||||
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
|
||||
"dependencies": {
|
||||
"@types/invariant": "^2.2.37",
|
||||
"invariant": "2.2.4"
|
||||
}
|
||||
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// originally based off of https://github.com/gulpjs/vinyl
|
||||
import invariant from 'invariant';
|
||||
|
||||
const exts = ['js', 'html', 'css', 'jsx', 'ts', 'tsx', 'py'] as const;
|
||||
export type Ext = (typeof exts)[number];
|
||||
|
||||
@@ -48,15 +45,10 @@ export function createPoly<Rest>({
|
||||
history,
|
||||
...rest
|
||||
}: PolyProps & Rest): PolyProps & AddedProperties & Rest {
|
||||
invariant(typeof name === 'string', 'name must be a string but got %s', name);
|
||||
|
||||
invariant(typeof ext === 'string', 'ext must be a string, but was %s', ext);
|
||||
|
||||
invariant(
|
||||
typeof contents === 'string',
|
||||
'contents must be a string but got %s',
|
||||
contents
|
||||
);
|
||||
if (typeof name !== 'string') throw new TypeError('name must be a string');
|
||||
if (typeof ext !== 'string') throw new TypeError('ext must be a string');
|
||||
if (typeof contents !== 'string')
|
||||
throw new TypeError('contents must be a string');
|
||||
|
||||
return {
|
||||
...rest,
|
||||
@@ -98,11 +90,7 @@ export function isPoly(poly: unknown): poly is ChallengeFile {
|
||||
}
|
||||
|
||||
function checkPoly(poly: ChallengeFile) {
|
||||
invariant(
|
||||
isPoly(poly),
|
||||
'function should receive a PolyVinyl, but got %s',
|
||||
JSON.stringify(poly)
|
||||
);
|
||||
if (!isPoly(poly)) throw Error('Not a PolyVinyl: ' + JSON.stringify(poly));
|
||||
}
|
||||
|
||||
// setContent will lose source if not supplied
|
||||
|
||||
Reference in New Issue
Block a user