diff --git a/js/{{ cookiecutter.project_name }}/.github/workflows/commitlint.yml b/js/{{ cookiecutter.project_name }}/.github/workflows/commitlint.yml index 266d1d6..834e8c3 100644 --- a/js/{{ cookiecutter.project_name }}/.github/workflows/commitlint.yml +++ b/js/{{ cookiecutter.project_name }}/.github/workflows/commitlint.yml @@ -18,4 +18,9 @@ jobs: with: fetch-depth: 0 # fetch-depth is required + {%- if cookiecutter.type == "svelte" %} + # This needs a generated dependency - doesn't add anything to this test + - run: rm tsconfig.json + {%- endif %} + - uses: wagoid/commitlint-github-action@v5 diff --git a/js/{{ cookiecutter.project_name }}/.github/workflows/pre-commit.yml b/js/{{ cookiecutter.project_name }}/.github/workflows/pre-commit.yml index b2379de..eb91440 100644 --- a/js/{{ cookiecutter.project_name }}/.github/workflows/pre-commit.yml +++ b/js/{{ cookiecutter.project_name }}/.github/workflows/pre-commit.yml @@ -22,4 +22,15 @@ jobs: with: go-version: '>=1.20.0' + {%- if cookiecutter.type == "svelte" %} + - name: Set up JS + uses: actions/setup-node@v3 + with: + node-version: lts/* + cache: "npm" + + - name: Install dependencies + run: npm ci + {%- endif %} + - uses: pre-commit/action@v3.0.0 diff --git a/js/{{ cookiecutter.project_name }}/nestjs/.github/workflows/build.yml b/js/{{ cookiecutter.project_name }}/nestjs/.github/workflows/build.yml index 8b1c015..71a95f0 100644 --- a/js/{{ cookiecutter.project_name }}/nestjs/.github/workflows/build.yml +++ b/js/{{ cookiecutter.project_name }}/nestjs/.github/workflows/build.yml @@ -48,8 +48,6 @@ jobs: - test steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Required for goreleaser changelog to work correctly - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -116,19 +114,3 @@ jobs: platforms: {{ '${{ steps.docker.outputs.platforms }}' }} push: {{ '${{ github.ref == \'refs/heads/main\' }}' }} tags: {{ '${{ steps.docker.outputs.image_name }},${{ steps.docker.outputs.container_tagged_image }}' }} - - - name: Set up Go - if: steps.branch-name.outputs.is_tag == 'true' - uses: actions/setup-go@v3 - with: - go-version: '>=1.20.0' - - - name: Run GoReleaser - if: steps.branch-name.outputs.is_tag == 'true' - uses: goreleaser/goreleaser-action@v4 - with: - version: latest - args: release --clean - env: - GIT_REPO: {{ '${{ steps.docker.outputs.gitRepo }}' }} - GITHUB_TOKEN: {{ '${{ secrets.GITHUB_TOKEN }}' }} diff --git a/js/{{ cookiecutter.project_name }}/nestjs/test/app.e2e-spec.ts b/js/{{ cookiecutter.project_name }}/nestjs/test/app.e2e-spec.ts deleted file mode 100644 index f3b8d30..0000000 --- a/js/{{ cookiecutter.project_name }}/nestjs/test/app.e2e-spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { AppModule } from './../src/app.module'; -import { INestApplication } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; -import * as request from 'supertest'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); - }); -}); diff --git a/js/{{ cookiecutter.project_name }}/nestjs/test/health.e2e-spec.ts b/js/{{ cookiecutter.project_name }}/nestjs/test/health.e2e-spec.ts new file mode 100644 index 0000000..f7ba1c8 --- /dev/null +++ b/js/{{ cookiecutter.project_name }}/nestjs/test/health.e2e-spec.ts @@ -0,0 +1,16 @@ +import * as supertest from 'supertest'; +import { request } from './setup'; + +describe('HealthController (e2e)', () => { + let app: supertest.Test; + + describe('/', () => { + describe('GET', () => { + beforeEach(async () => { + app = (await request())().get('/health'); + }); + + it('should return a healthy state', () => app.expect(200)); + }); + }); +}); diff --git a/js/{{ cookiecutter.project_name }}/nestjs/test/setup.ts b/js/{{ cookiecutter.project_name }}/nestjs/test/setup.ts new file mode 100644 index 0000000..6ef7edc --- /dev/null +++ b/js/{{ cookiecutter.project_name }}/nestjs/test/setup.ts @@ -0,0 +1,35 @@ +process.env.LOG_LEVEL = 'silent'; + +import { INestApplication } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; +import * as supertest from 'supertest'; +import { AppModule } from '../src/app.module'; + +let app: INestApplication; + +export const destroyApp = async () => { + if (app) { + await app.close(); + + /* Remove definition to prevent being run again */ + app = undefined; + } +}; + +export const request = async (): Promise< + () => supertest.SuperTest +> => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [AppModule], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + + return () => supertest(app.getHttpServer()); +}; + +export { supertest }; + +// Ensure that the test app is correctly destroyed after use +afterEach(() => destroyApp()); diff --git a/js/{{ cookiecutter.project_name }}/svelte/package.json b/js/{{ cookiecutter.project_name }}/svelte/package.json index 4845ad9..3210ced 100644 --- a/js/{{ cookiecutter.project_name }}/svelte/package.json +++ b/js/{{ cookiecutter.project_name }}/svelte/package.json @@ -26,8 +26,8 @@ "eslint": "^8.28.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-svelte": "^2.30.0", - "prettier": "^2.8.0", - "prettier-plugin-svelte": "^2.10.1", + "prettier": "^3.0.0", + "prettier-plugin-svelte": "^3.0.0", "svelte": "^4.0.5", "svelte-check": "^3.4.3", "tslib": "^2.4.1", diff --git a/js/{{ cookiecutter.project_name }}/svelte/tsconfig.json b/js/{{ cookiecutter.project_name }}/svelte/tsconfig.json index 6ae0c8c..5c56cee 100644 --- a/js/{{ cookiecutter.project_name }}/svelte/tsconfig.json +++ b/js/{{ cookiecutter.project_name }}/svelte/tsconfig.json @@ -1,17 +1,13 @@ { - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true - } - // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true + } }