Skip to content

Commit

Permalink
Dependency updates (#1609)
Browse files Browse the repository at this point in the history
* Dependency updates

* Use Node 23

* Remove extra canary

* Lets go
  • Loading branch information
ardatan authored Dec 16, 2024
1 parent f66a50e commit a864517
Show file tree
Hide file tree
Showing 112 changed files with 127,319 additions and 1,325 deletions.
4 changes: 3 additions & 1 deletion .changeset/sofa-api-1596-dependencies.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
'sofa-api': patch
---

dependencies updates:
- Updated dependency [`@whatwg-node/fetch@^0.10.0` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.10.0) (from `^0.9.14`, in `dependencies`)

- Updated dependency [`@whatwg-node/fetch@^0.10.0` ↗︎](https://www.npmjs.com/package/@whatwg-node/fetch/v/0.10.0) (from `^0.9.14`, in `dependencies`)
14 changes: 1 addition & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [18, 20, 21]
node_version: [18, 20, 22, 23]
steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ matrix.node_version }}
Expand All @@ -25,15 +25,3 @@ jobs:
run: yarn build
- name: Test
run: yarn test
- name: Publish Canary
env: # Or as an environment variable
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: |
echo "Fork PR: ${{github.repository}}"
if [ "${{github.repository}}" == "Urigo/SOFA" ] && [ "${{ secrets.NODE_AUTH_TOKEN }}" != "" ]
then
echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" > .npmrc
npm run release
else
echo "Skipping canary publish due to a fork/PR..."
fi
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
npmTag: alpha
buildScript: build
nodeVersion: 16
nodeVersion: 23
secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: the-guild-org/shared-config/.github/workflows/release-stable.yml@main
with:
releaseScript: release
nodeVersion: 16
nodeVersion: 23
secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
npmToken: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: the-guild-org/shared-config/setup@main
name: setup env
with:
nodeVersion: 18 # change if needed
nodeVersion: 23 # change if needed
packageManager: yarn # change if needed

- uses: the-guild-org/shared-config/website-cf@main
Expand Down
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
dist/
.bob
.bob
.next
out
node_modules
16 changes: 8 additions & 8 deletions example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const app = useSofa({
title: 'Example API',
description: 'Example API Description',
version: '3.0.0',
}
}
})
},
},
});

app.route({
path: '/collect-book',
Expand All @@ -38,8 +38,8 @@ app.route({
status: 200,
statusText: 'OK',
});
}
})
},
});

const yoga = createYoga({
schema,
Expand All @@ -48,7 +48,7 @@ const yoga = createYoga({
app.route({
path: yoga.graphqlEndpoint,
handler: yoga as any,
})
});

const port = 4000;

Expand All @@ -74,7 +74,7 @@ server.listen(port, () => {
${chalk.bold('Mutations:')}
addBook: ${printUrl('/add-book')} ${chalk.italic.gray(
'POST: {title}'
)}
'POST: {title}'
)}
`);
});
2 changes: 1 addition & 1 deletion example/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const typeDefs = /* GraphQL */ `
THIN
THICK
}
type Pizza {
dough: Dough!
toppings: [String!]
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
"prebuild": "yarn clean",
"build": "bob build --single",
"test": "jest --no-watchman",
"release": "yarn build && changeset publish",
"postinstall": "husky install"
"release": "yarn build && changeset publish"
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
Expand Down Expand Up @@ -95,7 +94,7 @@
"swagger-ui-dist": "5.18.2",
"ts-jest": "29.2.5",
"tsup": "8.3.5",
"typescript": "5.5.4"
"typescript": "5.7.2"
},
"husky": {
"hooks": {
Expand All @@ -110,5 +109,6 @@
"publishConfig": {
"directory": "dist",
"access": "public"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ import { createSofa } from './sofa.js';
export { OpenAPI } from './open-api/index.js';

export function useSofa(config: SofaConfig) {
return createRouter(
createSofa(config)
);
return createRouter(createSofa(config));
}
2 changes: 1 addition & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const toLevel = (string: void | string) =>

const currentLevel: Level = globalThis.process?.env?.SOFA_DEBUG
? 'debug'
: toLevel(globalThis.process?.env?.SOFA_LOGGER_LEVEL) ?? 'info';
: (toLevel(globalThis.process?.env?.SOFA_LOGGER_LEVEL) ?? 'info');

const log = (level: Level, color: any, args: any[]) => {
if (levels.indexOf(level) <= levels.indexOf(currentLevel)) {
Expand Down
23 changes: 11 additions & 12 deletions src/open-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,24 @@ export function OpenAPI({
}
) {
const basePath = config?.basePath || '';
const path =
basePath +
normalizePathParamForOpenAPI(info.path);
const path = basePath + normalizePathParamForOpenAPI(info.path);

if (!swagger.paths[path]) {
swagger.paths[path] = {};
}

const pathsObj = swagger.paths[path] as OpenAPIV3.PathItemObject;

pathsObj[info.method.toLowerCase() as OpenAPIV3.HttpMethods] = buildPathFromOperation({
url: path,
operation: info.document,
schema,
useRequestBody: ['POST', 'PUT', 'PATCH'].includes(info.method),
tags: info.tags || [],
description: info.description || '',
customScalars,
});
pathsObj[info.method.toLowerCase() as OpenAPIV3.HttpMethods] =
buildPathFromOperation({
url: path,
operation: info.document,
schema,
useRequestBody: ['POST', 'PUT', 'PATCH'].includes(info.method),
tags: info.tags || [],
description: info.description || '',
customScalars,
});
},
get() {
return swagger;
Expand Down
13 changes: 5 additions & 8 deletions src/open-api/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ export function buildPathFromOperation({
requestBody: {
content: {
'application/json': {
schema: resolveRequestBody(
bodyParams,
schema,
info.operation,
{ customScalars, enumTypes }
),
schema: resolveRequestBody(bodyParams, schema, info.operation, {
customScalars,
enumTypes,
}),
},
},
},
Expand Down Expand Up @@ -101,8 +99,7 @@ export function buildPathFromOperation({
}

function resolveEnumTypes(schema: GraphQLSchema): Record<string, any> {
const enumTypes = Object.values(schema.getTypeMap())
.filter(isEnumType)
const enumTypes = Object.values(schema.getTypeMap()).filter(isEnumType);
return Object.fromEntries(
enumTypes.map((type) => [
type.name,
Expand Down
2 changes: 1 addition & 1 deletion src/open-api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ export function normalizePathParamForOpenAPI(path: string) {
return part;
});
return normalizedPathParts.join('/');
}
}
2 changes: 1 addition & 1 deletion src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function resolveVariable({
if (isScalarType(namedType)) {
// GraphQLBoolean.serialize expects a boolean or a number only
if (isEqualType(GraphQLBoolean, namedType)) {
value = (value === 'true' || value === true);
value = value === 'true' || value === true;
}

return namedType.serialize(value);
Expand Down
Loading

0 comments on commit a864517

Please sign in to comment.