Skip to content

Commit

Permalink
chore(app): migrate to yarn 4 (#61)
Browse files Browse the repository at this point in the history
* chore(app): migrate to yarn 4

* chore: upgrade dependencies

* chore: upgrade node version in the ci

* chore: upgrade github actions version
  • Loading branch information
tericcabrel committed Mar 24, 2024
1 parent 578eb8c commit 811625e
Show file tree
Hide file tree
Showing 73 changed files with 19,236 additions and 20,362 deletions.
10 changes: 7 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:typescript-sort-keys/recommended"
"plugin:typescript-sort-keys/recommended",
"plugin:jest/recommended"
],
"plugins": [
"sort-destructure-keys",
"sort-keys-fix",
"typescript-sort-keys",
"import"
"import",
"jest"
],
"env": {
"es6": true,
Expand Down Expand Up @@ -139,6 +141,8 @@
"next": "case",
"prev": ["case", "default"]
}
]
],
"jest/prefer-expect-resolves": "error",
"jest/prefer-hooks-in-order": "error"
}
}
23 changes: 18 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,27 @@ jobs:
CONVERTKIT_API_KEY: api_key
CONVERTKIT_FORM_ID: form_id
steps:
- uses: actions/checkout@v3
- name: Set up Node 18
uses: actions/setup-node@v3
- uses: actions/checkout@v4

- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/*.yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-

- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'

- name: Install Yarn 4
run: |
corepack enable
yarn set version berry
- name: Install projects dependencies
uses: bahmutov/npm-install@v1
run: yarn install

- name: Lint the projects
run: yarn lint
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy-code-embed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v3
- name: Set up Node 18
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'

- name: Install projects dependencies
uses: bahmutov/npm-install@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Copy the core Dockerfile in the root repository
run: cp apps/core/Dockerfile .
Expand All @@ -40,7 +40,7 @@ jobs:
needs:
- package
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Deploy the application
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-embed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Install projects dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/sentry-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node 18
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'

- name: Install projects dependencies
uses: bahmutov/npm-install@v1
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ dist/**
eslintcache
key.txt
.eslintcache

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=$NPM_TOKEN
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.17.1
20.11.1
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
45 changes: 19 additions & 26 deletions apps/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,26 @@
"gql:gen:types": "yarn graphql-codegen"
},
"dependencies": {
"@graphql-tools/schema": "^8.5.0",
"@snipcode/database": "*",
"@snipcode/domain": "*",
"@snipcode/embed": "*",
"@snipcode/logger": "*",
"@snipcode/utils": "*",
"apollo-server-core": "^3.9.0",
"apollo-server-express": "^3.9.0",
"axios": "^0.27.2",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"graphql": "^16.5.0"
"@graphql-tools/schema": "10.0.3",
"@snipcode/database": "workspace:*",
"@snipcode/domain": "workspace:*",
"@snipcode/embed": "workspace:*",
"@snipcode/logger": "workspace:*",
"@snipcode/utils": "workspace:*",
"apollo-server-core": "3.13.0",
"apollo-server-express": "3.13.0",
"axios": "1.6.8",
"cors": "2.8.5",
"express": "4.19.1",
"graphql": "16.8.1"
},
"devDependencies": {
"@graphql-codegen/cli": "^2.7.0",
"@graphql-codegen/typescript": "^2.6.0",
"@graphql-codegen/typescript-resolvers": "^2.6.7",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/jest": "^28.1.4",
"@types/node": "^18.0.1",
"esbuild": "^0.14.48",
"jest": "^28.1.2",
"nodemon": "^2.0.18",
"ts-jest": "^28.0.5",
"ts-node": "^10.8.2",
"typescript": "4.8.4"
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/typescript": "4.0.6",
"@graphql-codegen/typescript-resolvers": "4.0.6",
"@types/cors": "2.8.17",
"@types/express": "4.17.21",
"esbuild": "0.20.2",
"nodemon": "3.1.0"
}
}
2 changes: 1 addition & 1 deletion apps/core/src/resources/resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Resolvers } from '../types/graphql';
import { createFolder } from './folders/mutations/create-folder';
import { deleteFolders } from './folders/mutations/delete-folders';
import { updateFolder } from './folders/mutations/update-folder';
Expand All @@ -18,6 +17,7 @@ import { loginUser } from './users/mutations/login-user';
import { logoutUser } from './users/mutations/logout-user';
import { signupUser } from './users/mutations/signup-user';
import { authenticatedUser } from './users/queries/authenticated-user';
import { Resolvers } from '../types/graphql';

const resolvers: Resolvers = {
Date: dateScalar,
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/server/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
import { ApolloServer } from 'apollo-server-express';
import { Application } from 'express';

import { buildGraphQLContext } from './config/build-context';
import { env } from '../configs/env';
import resolvers from '../resources/resolvers';
import schemas from '../resources/schemas';
import { AppContext } from '../types/common';
import { CORS_APOLLO_STUDIO_URL } from '../utils/constants';
import { buildGraphQLContext } from './config/build-context';

const explorerPlugin: PluginDefinition[] = env.IS_PROD
? []
Expand Down
4 changes: 2 additions & 2 deletions apps/core/src/server/rest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import express, { Application, Request, Response } from 'express';

import { authenticationRoute } from '../resources/authentication/routes';
import { snippetRoute } from '../resources/snippets/routes';
import { errorHandlerMiddleware } from './middleware/error-middleware';
import { notFoundMiddleware } from './middleware/not-found-middleware';
import { authenticationRoute } from '../resources/authentication/routes';
import { snippetRoute } from '../resources/snippets/routes';

export const setupRestEndpoints = (app: Application) => {
const router = express.Router();
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('Test Suites', () => {
test('Test case', () => {
test('default tests', () => {
expect(true).toEqual(true);
});
});
14 changes: 14 additions & 0 deletions apps/functions/code-embed/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type EnvironmentVariables = {
EMBED_JS_URL: string;
EMBED_STYLE_URL: string;
WEB_APP_URL: string;
WEB_APP_SNIPPET_VIEW_URL: string;
};

declare global {
namespace NodeJS {
type ProcessEnv = EnvironmentVariables;
}
}

export {};
26 changes: 12 additions & 14 deletions apps/functions/code-embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@
"node": ">=16.14.0"
},
"dependencies": {
"@snipcode/database": "*",
"@snipcode/embed": "*",
"@snipcode/database": "workspace:*",
"@snipcode/embed": "workspace:*",
"shiki": "^0.11.1"
},
"devDependencies": {
"@serverless/typescript": "^3.21.0",
"@types/aws-lambda": "^8.10.102",
"@types/node": "^17.0.45",
"esbuild": "^0.15.5",
"serverless": "^3.22.0",
"serverless-certificate-creator": "^1.6.0",
"serverless-domain-manager": "^6.1.0",
"serverless-esbuild": "^1.32.8",
"serverless-offline": "^9.2.6",
"ts-node": "^10.4.0",
"tsconfig-paths": "^4.1.0",
"typescript": "4.8.4"
"@serverless/typescript": "3.21.0",
"@types/aws-lambda": "8.10.136",
"esbuild": "0.20.2",
"serverless": "3.22.0",
"serverless-certificate-creator": "1.6.0",
"serverless-domain-manager": "6.4.4",
"serverless-esbuild": "1.52.1",
"serverless-offline": "13.3.3",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0"
}
}
16 changes: 12 additions & 4 deletions apps/functions/code-embed/src/functions/renderer/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ import { APIGatewayProxyEvent, APIGatewayProxyResult, Handler } from 'aws-lambda
// eslint-disable-next-line @typescript-eslint/no-var-requires
const shiki = require('shiki');

export const main: Handler<APIGatewayProxyEvent, APIGatewayProxyResult> = async (event) => {
const snippetId = event.pathParameters['id'];
const findSnippet = async (id?: string | null) => {
if (!id) {
return null;
}

const snippet = await dbClient.snippet.findFirst({
return dbClient.snippet.findFirst({
where: {
id: snippetId,
id,
visibility: 'public',
},
});
};

export const main: Handler<APIGatewayProxyEvent, APIGatewayProxyResult> = async (event) => {
const snippetId = event.pathParameters ? event.pathParameters['id'] : null;

const snippet = await findSnippet(snippetId);

const content = await renderSnippetToHtml({
options: {
Expand Down
6 changes: 1 addition & 5 deletions apps/functions/code-embed/src/functions/renderer/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { AWS } from '@serverless/typescript';

import { handlerPath } from '@/libs/handler-resolver';

type LambdaEventHandler = Pick<AWS['functions'][number], 'events' | 'handler' | 'layers'>;

export default {
events: [
{
Expand All @@ -29,4 +25,4 @@ export default {
Ref: 'ShikiLambdaLayer',
},
],
} as LambdaEventHandler;
};
5 changes: 3 additions & 2 deletions apps/functions/code-embed/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"sourceMap": true,
"target": "ES2020",
"outDir": "lib",
"skipLibCheck": true
"skipLibCheck": true,
"strictNullChecks": true
},
"include": ["src/**/*.ts", "serverless.ts"],
"include": ["src/**/*.ts", "serverless.ts", "env.d.ts"],
"exclude": [
"node_modules/**/*",
".serverless/**/*",
Expand Down
13 changes: 6 additions & 7 deletions apps/web/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"plugins": ["prettier"],
"extends": ["next", "next/core-web-vitals", "prettier"],
"plugins": [],
"extends": ["next", "next/core-web-vitals"],
"settings": {
"next": {
"rootDir": "."
Expand All @@ -12,7 +12,6 @@
"project": "tsconfig.json"
},
"rules": {
"prettier/prettier": "error",
"camelcase": "off",
"import/prefer-default-export": "off",
"react/jsx-filename-extension": "off",
Expand All @@ -35,8 +34,8 @@
{
"files": "**/*.+(ts|tsx)",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint/eslint-plugin", "testing-library", "jest-dom"],
"extends": ["plugin:@typescript-eslint/recommended", "prettier", "plugin:jest-dom/recommended"],
"plugins": ["testing-library", "jest-dom"],
"extends": ["prettier", "plugin:jest-dom/recommended"],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
Expand All @@ -60,14 +59,14 @@
"ignoreStrings": true,
"ignoreComments": true
}],
"sort-keys": "warn",
"sort-keys": "error",
"react/destructuring-assignment": "warn",
"react/display-name": "warn",
"react/prop-types": "warn",
"react/sort-prop-types": "warn",
"react/no-unescaped-entities": "off",
"react/jsx-sort-props": [
1,
2,
{
"callbacksLast": true,
"ignoreCase": false,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/__tests__/setup/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import '@testing-library/jest-dom/extend-expect';
import '@testing-library/jest-dom';
Loading

0 comments on commit 811625e

Please sign in to comment.