Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Move from submodules to npm package #3

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [0, 'always'],
'footer-max-line-length': [0, 'always'],
},
};
42 changes: 42 additions & 0 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish to NPM

on:
workflow_dispatch:
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run prepublish

publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://registry.npmjs.org/

- name: Authenticate with NPM
run: echo "//registry.npmjs.org/:_authToken=\${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Publish to NPM
run: npm publish --access public
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# compiled output
/dist
/node_modules
/temp

# Logs
logs
!src/modules/logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Secrets
.env

# Stored files
public/*

old
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
# Typings
# @ae_utbm/core

Ce répertoire est conçu pour héberger les types TypeScript utilisés entre différents projets pour l'association des étudiants, tels que l'API et le Sith 4.
Repository that contains all typings & constants variables used across all projects of the AE UTBM.

## Installation

Pour installer ce projet, suivez les étapes suivantes :
Use the package manager [npm](https://www.npmjs.com/) to install @ae_utbm/core.

```bash
# Cloner le projet en tant que sous-module dans le dossier src/types
git submodule add https://github.com/ae-utbm/typings.git "src/types"
npm install @ae_utbm/core
```

Once installed, modify your `tsconfig.json` file to add the following lines:

```jsonc
{
"compilerOptions": {
// ...
"typeRoots": ["node_modules/@ae_utbm/core/types"]
// ...
},
"include": ["node_modules/@ae_utbm/core/types/**/*"]
}
```

As we are overriding the default `lib`s types of TypeScript, you should also add the following lines to your `package.json` file:

```jsonc
{
"dependencies": {
// ...
"@typescript/lib-dom": "npm:@ae_utbm/core",
"@typescript/lib-es2015": "npm:@ae_utbm/core",
"@typescript/lib-es5": "npm:@ae_utbm/core",
// ...
}
}
```
13 changes: 13 additions & 0 deletions clean.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable no-console */
import { existsSync, rmSync } from 'node:fs';

(() => {
const start = Date.now();
console.log('Cleaning generated files...');

['./coverage', './dist'].forEach((dir) => {
if (existsSync(dir)) rmSync(dir, { recursive: true });
});

console.log(`Cleaning done! (in ${Date.now() - start}ms)`);
})();
24 changes: 24 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { JestConfigWithTsJest } from 'ts-jest';

const config: JestConfigWithTsJest = {
coverageReporters: ['text', 'lcov'],
collectCoverage: true,
coverageDirectory: 'coverage',
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
detectOpenHandles: true,
maxConcurrency: 1,
modulePathIgnorePatterns: ['<rootDir>/dist', '<rootDir>/node_modules'],
preset: 'ts-jest',
testEnvironment: 'node',
testRegex: '.(spec|test).ts$',
verbose: true,
};

export default config;
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@ae_utbm/core",
"version": "1.0.1",
"description": "Typings & utilities for the AE UTBM API & sub-projects",
"license": "GPL v3",
"main": "src/index.ts",
"types": "types/@ae_utbm/core/index",
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@types/jest": "^29.5.10",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-extended": "^4.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"type-fest": "^4.6.0",
"typescript": "^5.3.2"
},
"scripts": {
"clean": "node clean.mjs",
"prepare": "husky install",
"prepublish": "pnpm clean && tsc",
"test": "jest --config jest.config.ts"
}
}
Loading