Skip to content

Commit

Permalink
chore: wip -- cleanup "packages" remnant
Browse files Browse the repository at this point in the history
  • Loading branch information
kasir-barati committed May 16, 2024
1 parent fce124a commit 3196b41
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-e2e-tests.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
is-backend:
- 'apps/backend/**'
- 'apps/backend-e2e/**'
- 'packages/backend/auth/**'
- 'libs/backend/auth/**'
- '.github/workflows/backend-e2e-tests.workflow.yml'
- if: ${{ steps.changed-paths.outputs.is-backend == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/frontend-e2e-tests.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- 'apps/backend/**'
- 'apps/frontend/**'
- 'apps/frontend-e2e/**'
- 'packages/backend/auth/**'
- 'libs/backend/auth/**'
- '.github/workflows/frontend-e2e-tests.workflow.yml'
- if: ${{ steps.changed-paths.outputs.is-backend-or-frontend == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion apps/backend-e2e/src/auth/auth-business.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Auth -- business', () => {
const loginRedirectUrl = response.request.res.responseUrl;

expect(response.status).toBe(200);
// README: a more exhaustive test to check generate URL had been written here: packages/backend/auth/src/lib/services/auth.service.spec.ts
// README: a more exhaustive test to check generate URL had been written here: libs/backend/auth/src/lib/services/auth.service.spec.ts
expect(loginRedirectUrl).toEqual(expect.any(String));
});
});
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ COPY package*.json ./
RUN npm ci --include="dev" --ignore-scripts
COPY apps/backend/healthcheck.js .
COPY apps/backend ./apps/backend
COPY packages ./packages
COPY libs ./libs
RUN npx nx build backend

FROM docker.io/node:20.10.0-alpine
Expand All @@ -21,7 +21,7 @@ COPY --chown=backend:backend --from=build_stage /build/healthcheck.js ./
COPY --chown=backend:backend --from=build_stage /build/package*.json ./
# RUN npm prune --omit=dev
COPY --chown=backend:backend --from=build_stage /build/dist/apps/backend ./dist/apps/backend
COPY --chown=backend:backend --from=build_stage /build/dist/packages ./dist/packages
COPY --chown=backend:backend --from=build_stage /build/dist/libs ./dist/libs

EXPOSE 3001

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"docker compose down -v",
"docker compose -f fusionauth.docker-compose.yml down -v",
"rm -rf ./dist/apps/backend",
"rm -rf ./dist/packages",
"rm -rf ./dist/libs",
"rm -rf deployment/terraform.tfstate* deployment/.terraform*",
"docker system prune -f"
]
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY tsconfig.base.json jest.preset.js nx.json ./
COPY package*.json ./
# README: Why --ignore-scripts? https://github.com/typicode/husky/issues/920#issuecomment-809851650
RUN npm ci --include="dev" --ignore-scripts
COPY packages/shared ./packages/shared
COPY libs/shared ./libs/shared
COPY apps/frontend ./apps/frontend
RUN npx nx build frontend

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace NodeJS {
NEXT_PUBLIC_FRONTEND_URL: string;
NEXT_PUBLIC_FUSIONAUTH_APPLICATION_ID: string;
NEXT_PUBLIC_FUSIONAUTH_OAUTH_SCOPES: string;
NEXT_PUBLIC_NODE_ENV: import('../../packages/shared/src/index').NodeEnv;
NEXT_PUBLIC_NODE_ENV: import('@shared').NodeEnv;
}
}
1 change: 1 addition & 0 deletions apps/frontend/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
12 changes: 6 additions & 6 deletions libs/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Rules and regulations

1. Do not import anything from other packages inside the shared package.
2. Do not import anything from apps in packages.
1. Do not import anything from other libs inside the shared package.
2. Do not import anything from apps in libs.
3. Do not include anything outside of the package in the package's `tsconfig.json` since it causes issues with the build process.
4. Backend packages can be a normal Nx package or a dynamic module.
4. Backend libs can be a normal Nx package or a dynamic module.
5. We are calling each reuseable and shareable part a `package` instead of `library` but in practice I do not see any difference between them. So keep that in mind.

# Add new package

Run `nx g @nx/js:lib packages/backend/libName`
Or run `nx g @nx/js:lib packages/frontend/libName`
Run `nx g @nx/js:lib libs/backend/libName`
Or run `nx g @nx/js:lib libs/frontend/libName`

> [!NOTE]
>
> If your package is not a publishable package, then to prevent your linter from failing because of this error: [`The "packageName" project uses the following packages, but they are missing from "dependencies":`](https://github.com/nrwl/nx/issues/19307), make sure to turn off the `@nx/dependency-checks` in the respective `.eslintrc.json` file.
> If your package is not a publishable package, then to prevent your linter from failing because of this error: [`The "packageName" project uses the following libs, but they are missing from "dependencies":`](https://github.com/nrwl/nx/issues/19307), make sure to turn off the `@nx/dependency-checks` in the respective `.eslintrc.json` file.
# Build

Expand Down
2 changes: 1 addition & 1 deletion libs/backend/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### Please note that all the packages that we have created here for our backend are not NestJS dynamic modules but they are also normal Nx packages
#### Please note that all the libs that we have created here for our backend are not NestJS dynamic modules but they are also normal Nx libs

# What are the NestJS modules

Expand Down
2 changes: 1 addition & 1 deletion libs/backend/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Auth package, created and will serve our backend application to communicate and work with FusionAuth API. Task such as registering new users etc will be managed and handled by this package.

#### Super important: This package comes with its own RESTful API, so be aware of it. It is defined under `/auth` and you can find them in `packages/backend/auth/src/lib/auth.controller.ts`
#### Super important: This package comes with its own RESTful API, so be aware of it. It is defined under `/auth` and you can find them in `libs/backend/auth/src/lib/auth.controller.ts`

## Building

Expand Down
2 changes: 1 addition & 1 deletion libs/shared/src/lib/types/node-env.type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck

/**
* @readme Since here we needed to define NODE_ENV type and NextJS is also defining it I decided to disable tsc compile checks (look at the first line) for this file since it is a simple type declaration and an enum. We also ignored this file from being linted in the packages/shared/.eslintrc.json.
* @readme Since here we needed to define NODE_ENV type and NextJS is also defining it I decided to disable tsc compile checks (look at the first line) for this file since it is a simple type declaration and an enum. We also ignored this file from being linted in the libs/shared/.eslintrc.json.
*
* @therefore DO NOT add extra or more logics here.
*/
Expand Down

0 comments on commit 3196b41

Please sign in to comment.