Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected] #169

Merged
merged 8 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn build
yarn lint-staged --no-stash
yarn test
yarn build
28 changes: 28 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"env": {
"targets": {
"node": "12.0"
}
},
"module": {
"type": "commonjs"
},
"jsc": {
"parser": {
"syntax": "typescript"
},
"baseUrl": "./",
"paths": {
"@/server": ["./src/server"],
"@/core/database": ["./src/core/database"],
"@/core/rest": ["./src/core/rest"],
"@/core/graphql": ["./src/core/graphql"],
"@/core/middlewares": ["./src/core/middlewares"],
"@/utils/helpers": ["./src/utils/helpers"],
"@/utils/helpers/tests": ["./src/utils/helpers/tests"],
"@/utils/types": ["./src/utils/types"],
"@/utils/constants": ["./src/utils/constants"]
}
}
}
14 changes: 0 additions & 14 deletions babel.config.json

This file was deleted.

3 changes: 2 additions & 1 deletion bin/helpers/createTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs';
import path from 'node:path';

import { APP_PATH, DEFAULT } from '@/utils/constants';

Expand All @@ -12,7 +13,7 @@ interface CreateTemplateOptions {

export const createTemplate = (options: CreateTemplateOptions) => {
const language = options.withTypescript ? 'ts' : 'js';
const templatePath = `dist/bin/templates/${language}/${options.apiType}`;
const templatePath = path.join(__dirname, '..', `templates/${language}/${options.apiType}`);

fs.cpSync(`${templatePath}/mock-requests`, `${APP_PATH}/mock-requests`, {
recursive: true,
Expand Down
13 changes: 8 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const { jest } = require('@siberiacancode/jest');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig.dev.json');
const fs = require('fs');

const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8'));

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...jest,
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' })
transform: {
// ✅ important:
// 'swcrc: false' disable reading .swcrc config and override 'exclude' property https://github.com/swc-project/jest/issues/62
'^.+\\.ts$': ['@swc/jest', { ...config, exclude: [], swcrc: false }]
}
};
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"node": ">=12"
},
"scripts": {
"prepublishOnly": "git diff --exit-code",
"prepare": "husky install && yarn build",
"build:types": "tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json",
"build:babel": "babel --delete-dir-on-start bin --out-dir dist/bin --extensions .ts && shx cp -r bin/templates dist/bin/templates && babel --delete-dir-on-start src --out-dir dist/src --extensions .ts --copy-files --no-copy-ignored && babel ./index.ts --out-dir dist --extensions .ts",
"build": "yarn build:babel && yarn build:types",
"build:swc": "swc bin src index.ts -d dist --extensions .ts --copy-files --ignore **/*.test.ts --ignore bin/templates",
"build:copy-templates": "shx mkdir -p dist/bin/templates/ts && shx cp -r bin/templates/ts dist/bin/templates && shx mkdir -p dist/bin/templates/js && shx cp -r bin/templates/js dist/bin/templates",
"build": "shx rm -rf dist && yarn build:types && yarn build:swc && yarn build:copy-templates",
"start": "yarn build && node ./dist/bin/bin.js",
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
"test": "jest",
"type": "tsc --noEmit",
"lint": "eslint . --ext .ts --no-error-on-unmatched-pattern --fix",
"stylelint": "stylelint \"src/static/**/*.css\" --fix",
"format": "prettier --write \"**/*.(ts|js)\"",
Expand Down Expand Up @@ -87,14 +88,13 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@babel/preset-typescript": "^7.23.3",
"@siberiacancode/eslint": "^1.0.3",
"@siberiacancode/jest": "^1.0.2",
"@siberiacancode/prettier": "^1.0.1",
"@siberiacancode/stylelint": "^1.0.2",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.4.12",
"@swc/jest": "^0.2.36",
"@types/jest": "^29.5.11",
"@types/supertest": "^6.0.2",
"husky": "^8.0.3",
Expand All @@ -103,7 +103,6 @@
"shx": "^0.3.4",
"style-loader": "^3.3.4",
"supertest": "^6.3.4",
"ts-jest": "^29.1.1",
"tsc-alias": "^1.8.8",
"typescript": "^5.3.3"
},
Expand Down
Loading