feat(package): adjust packages to workspaces

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-11-02 16:24:45 +01:00 committed by David Mehren
parent 046a173891
commit 2241a3faea
26 changed files with 5157 additions and 11075 deletions

View file

@ -52,6 +52,9 @@ module.exports = {
jest: true,
},
rules: {
"prettier/prettier": ["error",
require('./.prettierrc.json')
],
'local-rules/correct-logger-context': 'error',
'func-style': ['error', 'declaration'],
'@typescript-eslint/no-unused-vars': [

View file

@ -1,11 +0,0 @@
nodeLinker: node-modules
plugins:
- path: ../.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: ../.yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: ../.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: ../.yarn/releases/yarn-3.3.0.cjs

View file

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: CC0-1.0

View file

@ -16,60 +16,71 @@ FROM docker.io/node:19-alpine@sha256:80844b6643f239c87fceae51e6540eeb054fc7114d9
RUN apk add --no-cache tini
ENTRYPOINT ["tini"]
ENV YARN_CACHE_FOLDER /tmp/.yarn
USER node
WORKDIR /usr/src/app
COPY --chown=node .yarn ../.yarn
COPY --chown=node backend/package.json backend/yarn.lock backend/.yarnrc.yml ./
## Stage 1: Code with all dependencies
FROM base as code-with-deps
USER node
WORKDIR /usr/src/app
COPY --chown=node .yarn/plugins .yarn/plugins
COPY --chown=node .yarn/releases .yarn/releases
COPY --chown=node .yarnrc.yml .yarnrc.yml
COPY --chown=node package.json package.json
COPY --chown=node yarn.lock yarn.lock
COPY --chown=node backend/package.json backend/
COPY --chown=node frontend/package.json frontend/
# Install dependencies first to not invalidate the cache on every source change
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
YARN_CACHE_FOLDER=/tmp/.yarn yarn install --immutable
COPY --chown=node backend/nest-cli.json backend/tsconfig.json backend/tsconfig.build.json ./
COPY --chown=node backend/src src
yarn install --immutable && yarn workspaces focus @hedgedoc/backend
COPY --chown=node backend/nest-cli.json backend/tsconfig.json backend/tsconfig.build.json backend/
COPY --chown=node backend/src backend/src
## Stage 2a: Dev config files and tests
FROM code-with-deps as development
USER node
WORKDIR /usr/src/app
COPY --chown=node backend/.eslintrc.js backend/eslint-local-rules.js backend/.prettierrc backend/jest-e2e.json ./
COPY --chown=node backend/test test
COPY --chown=node eslint-local-rules.js eslint-local-rules.js
COPY --chown=node backend/.eslintrc.js backend/.prettierrc.json backend/jest-e2e.json backend/
COPY --chown=node backend/test backend/test
CMD ["node", "-r", "ts-node/register", "src/main.ts"]
## Stage 2b: Compile TypeScript
FROM code-with-deps as builder
USER node
WORKDIR /usr/src/app
WORKDIR /usr/src/app/backend
RUN yarn run build
## Stage 3a: Install only prod dependencies
FROM code-with-deps as prod-dependencies
USER node
WORKDIR /usr/src/app
## Stage 3: Final image, only production dependencies
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
yarn workspaces focus --production @hedgedoc/backend
## Stage 3a: Final image, only production dependencies
FROM base as prod
LABEL org.opencontainers.image.title='HedgeDoc production image'
LABEL org.opencontainers.image.url='https://hedgedoc.org'
LABEL org.opencontainers.image.source='https://github.com/hedgedoc/hedgedoc'
LABEL org.opencontainers.image.documentation='https://github.com/hedgedoc/hedgedoc/blob/develop/docker/README.md'
LABEL org.opencontainers.image.documentation='https://github.com/hedgedoc/hedgedoc/blob/develop/docs/docker/README.md'
LABEL org.opencontainers.image.licenses='AGPL-3.0'
USER node
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY --chown=node --from=builder /usr/src/app/dist ./dist
COPY --chown=node --from=builder /usr/src/app/backend/dist ./
COPY --chown=node backend/package.json package.json
COPY --chown=node --from=prod-dependencies /usr/src/app/node_modules ./node_modules
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
YARN_CACHE_FOLDER=/tmp/.yarn yarn workspaces focus --all --production
CMD ["node", "dist/main.js"]
CMD ["node", "main.js"]

View file

@ -1,58 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
'use strict';
const loggerFunctions = ['error', 'log', 'warn', 'debug', 'verbose'];
module.exports = {
'correct-logger-context': {
meta: {
fixable: 'code',
type: 'problem',
docs: {
recommended: true
},
schema: [],
},
create: function (context) {
return {
CallExpression: function (node) {
if (
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'MemberExpression' &&
node.callee.object.property.name === 'logger' &&
loggerFunctions.includes(node.callee.property.name) &&
!!node.arguments &&
node.arguments.length === 2
) {
const usedContext = node.arguments[1].value;
let correctContext = 'undefined';
const ancestors = context.getAncestors();
for (let index = ancestors.length - 1; index >= 0; index--) {
if (ancestors[index].type === 'MethodDefinition') {
correctContext = ancestors[index].key.name;
break;
}
}
if (usedContext !== correctContext) {
context.report({
node: node,
message: `Used wrong context in log statement`,
fix: function (fixer) {
return fixer.replaceText(
node.arguments[1],
`'${correctContext}'`,
);
},
});
}
}
},
};
},
},
};

View file

@ -1,6 +1,6 @@
{
"name": "hedgedoc",
"version": "2.0.0",
"name": "@hedgedoc/backend",
"version": "2.0.0-dev",
"description": "Realtime collaborative markdown notes on all platforms.",
"author": "",
"private": true,
@ -141,8 +141,5 @@
"github-actions"
]
},
"packageManager": "yarn@3.3.0",
"resolutions": {
"yjs": "13.5.43"
}
"packageManager": "yarn@3.3.0"
}

File diff suppressed because it is too large Load diff

View file

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: CC0-1.0