@togatherlabs/shared-utils 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/commitlint.config.d.ts +3 -0
- package/dist/commitlint.config.js +91 -0
- package/dist/src/constants/index.d.ts +1 -0
- package/dist/src/constants/index.js +1 -0
- package/dist/src/constants/sample.d.ts +3 -0
- package/dist/src/constants/sample.js +3 -0
- package/dist/src/helpers/formatDate.d.ts +1 -0
- package/dist/src/helpers/formatDate.js +10 -0
- package/dist/src/helpers/index.d.ts +1 -0
- package/dist/src/helpers/index.js +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/user.d.ts +5 -0
- package/dist/src/types/user.js +1 -0
- package/dist/tests/unit/constants/sample.test.d.ts +1 -0
- package/dist/tests/unit/constants/sample.test.js +7 -0
- package/dist/tests/unit/helpers/formatDate.test.d.ts +1 -0
- package/dist/tests/unit/helpers/formatDate.test.js +18 -0
- package/dist/tests/unit/index.test.d.ts +1 -0
- package/dist/tests/unit/index.test.js +8 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +17 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# togather-shared-utils
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// This config follows the project guidelines
|
|
2
|
+
// (https://docs.google.com/document/d/1psbMtN-PIF4oBbNc_pW_mtDPPAa_yPdV_apf-wq5spM/edit?tab=t.0)
|
|
3
|
+
const config = {
|
|
4
|
+
extends: ['@commitlint/config-conventional'],
|
|
5
|
+
rules: {
|
|
6
|
+
'scope-empty': [2, 'never'],
|
|
7
|
+
'scope-max-length': [2, 'always', 20],
|
|
8
|
+
// Subject rules
|
|
9
|
+
'subject-max-length': [2, 'always', 50],
|
|
10
|
+
'subject-case': [2, 'always', 'sentence-case'],
|
|
11
|
+
'subject-full-stop': [2, 'never', '.'],
|
|
12
|
+
// Body rules
|
|
13
|
+
'body-empty': [0],
|
|
14
|
+
'body-max-line-length': [2, 'always', 72],
|
|
15
|
+
// Footer (optional)
|
|
16
|
+
'footer-max-line-length': [2, 'always', 72],
|
|
17
|
+
},
|
|
18
|
+
prompt: {
|
|
19
|
+
settings: {
|
|
20
|
+
enableMultipleScopes: false,
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
skip: ':skip (press enter to skip)',
|
|
24
|
+
max: 'Max %d characters',
|
|
25
|
+
min: 'Min %d characters',
|
|
26
|
+
emptyWarning: 'This field cannot be empty',
|
|
27
|
+
upperLimitWarning: 'Character limit exceeded',
|
|
28
|
+
lowerLimitWarning: 'Too few characters',
|
|
29
|
+
},
|
|
30
|
+
questions: {
|
|
31
|
+
type: {
|
|
32
|
+
description: "Select the type of change you're committing:",
|
|
33
|
+
enum: {
|
|
34
|
+
feat: {
|
|
35
|
+
description: '✨ A new feature',
|
|
36
|
+
title: 'Feature',
|
|
37
|
+
emoji: '✨',
|
|
38
|
+
},
|
|
39
|
+
fix: {
|
|
40
|
+
description: '🐛 A bug fix',
|
|
41
|
+
title: 'Bug Fix',
|
|
42
|
+
emoji: '🐛',
|
|
43
|
+
},
|
|
44
|
+
docs: {
|
|
45
|
+
description: '📚 Documentation only changes',
|
|
46
|
+
title: 'Documentation',
|
|
47
|
+
emoji: '📚',
|
|
48
|
+
},
|
|
49
|
+
style: {
|
|
50
|
+
description: '💅 Changes that do not affect code meaning (formatting, etc.)',
|
|
51
|
+
title: 'Style',
|
|
52
|
+
emoji: '💅',
|
|
53
|
+
},
|
|
54
|
+
refactor: {
|
|
55
|
+
description: '🔧 Code change that neither fixes a bug nor adds a feature',
|
|
56
|
+
title: 'Refactor',
|
|
57
|
+
emoji: '🔧',
|
|
58
|
+
},
|
|
59
|
+
test: {
|
|
60
|
+
description: '✅ Adding or updating tests',
|
|
61
|
+
title: 'Test',
|
|
62
|
+
emoji: '✅',
|
|
63
|
+
},
|
|
64
|
+
chore: {
|
|
65
|
+
description: '🛠 Maintenance tasks (e.g., tooling, dependencies)',
|
|
66
|
+
title: 'Chore',
|
|
67
|
+
emoji: '🛠',
|
|
68
|
+
},
|
|
69
|
+
perf: { description: '⚡ Performance improvement', title: 'Performance', emoji: '⚡' },
|
|
70
|
+
build: {
|
|
71
|
+
description: '🏗 Build system or dependency changes',
|
|
72
|
+
title: 'Build',
|
|
73
|
+
emoji: '🏗',
|
|
74
|
+
},
|
|
75
|
+
ci: { description: '🔁 CI/CD configuration', title: 'CI', emoji: '🔁' },
|
|
76
|
+
revert: { description: '⏪ Reverts a previous commit', title: 'Revert', emoji: '⏪' },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
scope: {
|
|
80
|
+
description: 'Scope of this change (e.g., auth, ui, api)',
|
|
81
|
+
},
|
|
82
|
+
subject: {
|
|
83
|
+
description: 'Write a short, imperative description (max 50 chars, e.g., Add login validation)',
|
|
84
|
+
},
|
|
85
|
+
body: {
|
|
86
|
+
description: 'Provide a detailed description of what changed, why, and how (optional)',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sample';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sample';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatDate(date: Date, locale?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './formatDate';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './formatDate';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './user';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './user';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { formatDate } from '../../../src/helpers/formatDate';
|
|
3
|
+
describe('formatDate helper', () => {
|
|
4
|
+
it('should format a valid date correctly', () => {
|
|
5
|
+
const date = new Date('2025-10-14T00:00:00Z');
|
|
6
|
+
const formatted = formatDate(date);
|
|
7
|
+
expect(formatted).toBe('14 Oct 2025');
|
|
8
|
+
});
|
|
9
|
+
it('should format date in custom locale', () => {
|
|
10
|
+
const date = new Date('2025-10-14T00:00:00Z');
|
|
11
|
+
const formatted = formatDate(date, 'en-US');
|
|
12
|
+
expect(formatted).toMatch(/Oct/);
|
|
13
|
+
});
|
|
14
|
+
it('should throw an error for invalid date', () => {
|
|
15
|
+
// @ts-expect-error testing invalid date
|
|
16
|
+
expect(() => formatDate('not-a-date')).toThrowError('Invalid Date');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import * as utils from '../../src';
|
|
3
|
+
describe('index.ts', () => {
|
|
4
|
+
it('should export all modules correctly', () => {
|
|
5
|
+
expect(utils).toBeDefined();
|
|
6
|
+
expect(utils.formatDate).toBeInstanceOf(Function); // Example for a helper
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
export default defineConfig({
|
|
3
|
+
test: {
|
|
4
|
+
globals: true,
|
|
5
|
+
environment: "node",
|
|
6
|
+
coverage: {
|
|
7
|
+
provider: "v8",
|
|
8
|
+
reporter: ["text", "json", "html"],
|
|
9
|
+
exclude: [
|
|
10
|
+
"**/node_modules/**",
|
|
11
|
+
"**/dist/**",
|
|
12
|
+
"**/*.config.*",
|
|
13
|
+
"**/commitlint.*", // Exclude config files
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@togatherlabs/shared-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared utility functions, constants, and types for ToGather microservices",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"shared",
|
|
13
|
+
"utils",
|
|
14
|
+
"togather",
|
|
15
|
+
"microservices"
|
|
16
|
+
],
|
|
17
|
+
"author": "toGather team",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@biomejs/biome": "^2.2.6",
|
|
21
|
+
"@commitlint/cli": "^20.1.0",
|
|
22
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
23
|
+
"@commitlint/cz-commitlint": "^20.1.0",
|
|
24
|
+
"@commitlint/types": "^20.0.0",
|
|
25
|
+
"@types/node": "^24.7.2",
|
|
26
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
27
|
+
"@vitest/ui": "^3.2.4",
|
|
28
|
+
"commitizen": "^4.3.1",
|
|
29
|
+
"husky": "^9.1.7",
|
|
30
|
+
"inquirer": "^9.3.8",
|
|
31
|
+
"ts-node": "^10.9.2",
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"vitest": "^3.2.4"
|
|
34
|
+
},
|
|
35
|
+
"config": {
|
|
36
|
+
"commitizen": {
|
|
37
|
+
"path": "@commitlint/cz-commitlint"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"lint": "biome lint .",
|
|
46
|
+
"lint:fix": "biome lint --write .",
|
|
47
|
+
"format": "biome format .",
|
|
48
|
+
"format:fix": "biome format --write .",
|
|
49
|
+
"check": "biome check .",
|
|
50
|
+
"check:fix": "biome check --write .",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:watch": "vitest",
|
|
54
|
+
"test:coverage": "vitest run --coverage",
|
|
55
|
+
"test:ui": "vitest --ui",
|
|
56
|
+
"commit": "git-cz",
|
|
57
|
+
"package:patch": "pnpm version patch",
|
|
58
|
+
"package:publish": "pnpm publish --access public",
|
|
59
|
+
"release": "pnpm build && git add . && pnpm commit && pnpm package:patch && git push --follow-tags && pnpm package:publish"
|
|
60
|
+
}
|
|
61
|
+
}
|