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