xcally-nest-library 0.0.35 → 0.0.37-XM3778-bae91

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.
Files changed (85) hide show
  1. package/.jest/jestEnv.js +3 -0
  2. package/.nvmrc +1 -1
  3. package/.prettierrc +18 -1
  4. package/dist/index.d.ts +9 -0
  5. package/dist/index.js +9 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/jest.config.d.ts +3 -0
  8. package/dist/jest.config.js +61 -0
  9. package/dist/jest.config.js.map +1 -0
  10. package/dist/src/core/application/__tests__/cached-base.service.spec.d.ts +1 -0
  11. package/dist/src/core/application/__tests__/cached-base.service.spec.js +224 -0
  12. package/dist/src/core/application/__tests__/cached-base.service.spec.js.map +1 -0
  13. package/dist/src/core/application/__tests__/mock-types.d.ts +66 -0
  14. package/dist/src/core/application/__tests__/mock-types.js +9 -0
  15. package/dist/src/core/application/__tests__/mock-types.js.map +1 -0
  16. package/dist/src/core/application/__tests__/mocks/paginated-query.mock.d.ts +2 -0
  17. package/dist/src/core/application/__tests__/mocks/paginated-query.mock.js +12 -0
  18. package/dist/src/core/application/__tests__/mocks/paginated-query.mock.js.map +1 -0
  19. package/dist/src/core/application/__tests__/mocks/paginated-result.mock.d.ts +31 -0
  20. package/dist/src/core/application/__tests__/mocks/paginated-result.mock.js +169 -0
  21. package/dist/src/core/application/__tests__/mocks/paginated-result.mock.js.map +1 -0
  22. package/dist/src/core/application/base.interface.d.ts +4 -4
  23. package/dist/src/core/application/base.mongo.interface.d.ts +16 -0
  24. package/dist/src/core/application/base.mongo.interface.js +3 -0
  25. package/dist/src/core/application/base.mongo.interface.js.map +1 -0
  26. package/dist/src/core/application/base.mongo.service.d.ts +23 -0
  27. package/dist/src/core/application/base.mongo.service.js +91 -0
  28. package/dist/src/core/application/base.mongo.service.js.map +1 -0
  29. package/dist/src/core/application/base.service.d.ts +2 -2
  30. package/dist/src/core/application/cached-base.service.d.ts +26 -0
  31. package/dist/src/core/application/cached-base.service.js +52 -0
  32. package/dist/src/core/application/cached-base.service.js.map +1 -0
  33. package/dist/src/core/application/cached.service.d.ts +13 -0
  34. package/dist/src/core/application/cached.service.js +55 -0
  35. package/dist/src/core/application/cached.service.js.map +1 -0
  36. package/dist/src/core/domain/interfaces/base.mongo.repository.interface.d.ts +12 -0
  37. package/dist/src/core/domain/interfaces/base.mongo.repository.interface.js +3 -0
  38. package/dist/src/core/domain/interfaces/base.mongo.repository.interface.js.map +1 -0
  39. package/dist/src/core/domain/interfaces/cache-configuration.interface.d.ts +8 -0
  40. package/dist/src/core/domain/interfaces/cache-configuration.interface.js +11 -0
  41. package/dist/src/core/domain/interfaces/cache-configuration.interface.js.map +1 -0
  42. package/dist/src/core/infrastracture/databases/base.mongo.entity.d.ts +14 -0
  43. package/dist/src/core/infrastracture/databases/base.mongo.entity.interface.d.ts +10 -0
  44. package/dist/src/core/infrastracture/databases/base.mongo.entity.interface.js +3 -0
  45. package/dist/src/core/infrastracture/databases/base.mongo.entity.interface.js.map +1 -0
  46. package/dist/src/core/infrastracture/databases/base.mongo.entity.js +66 -0
  47. package/dist/src/core/infrastracture/databases/base.mongo.entity.js.map +1 -0
  48. package/dist/src/core/infrastracture/databases/base.mongo.repository.d.ts +20 -0
  49. package/dist/src/core/infrastracture/databases/base.mongo.repository.js +275 -0
  50. package/dist/src/core/infrastracture/databases/base.mongo.repository.js.map +1 -0
  51. package/dist/src/core/infrastracture/databases/base.repository.d.ts +1 -1
  52. package/dist/src/modules/logger/pino/logger.module.js +1 -1
  53. package/dist/src/modules/logger/pino/logger.module.js.map +1 -1
  54. package/dist/src/modules/logger/pino/logger.service.js +1 -1
  55. package/dist/src/modules/logger/pino/logger.service.js.map +1 -1
  56. package/dist/tsconfig.json +38 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/eslint.config.mjs +49 -0
  59. package/index.ts +9 -0
  60. package/jest.config.ts +219 -0
  61. package/package.json +34 -21
  62. package/scripts/publish-feat.sh +67 -0
  63. package/src/core/application/__tests__/cached-base.service.spec.ts +367 -0
  64. package/src/core/application/__tests__/mock-types.ts +73 -0
  65. package/src/core/application/__tests__/mocks/paginated-query.mock.ts +10 -0
  66. package/src/core/application/__tests__/mocks/paginated-result.mock.ts +166 -0
  67. package/src/core/application/base.interface.ts +4 -5
  68. package/src/core/application/base.mongo.interface.ts +15 -0
  69. package/src/core/application/base.mongo.service.ts +170 -0
  70. package/src/core/application/base.service.ts +2 -2
  71. package/src/core/application/cached-base.service.ts +119 -0
  72. package/src/core/application/cached.service.ts +96 -0
  73. package/src/core/domain/interfaces/base.mongo.repository.interface.ts +14 -0
  74. package/src/core/domain/interfaces/base.repository.interface.ts +1 -0
  75. package/src/core/domain/interfaces/cache-configuration.interface.ts +10 -0
  76. package/src/core/infrastracture/databases/base.mongo.entity.interface.ts +12 -0
  77. package/src/core/infrastracture/databases/base.mongo.entity.ts +65 -0
  78. package/src/core/infrastracture/databases/base.mongo.repository.ts +371 -0
  79. package/src/core/infrastracture/databases/base.repository.ts +1 -1
  80. package/src/modules/logger/pino/logger.module.ts +1 -1
  81. package/src/modules/logger/pino/logger.service.ts +1 -1
  82. package/tsconfig.json +1 -0
  83. package/dist/src/modules/db-hooks-subscriber/db-hooks-subscriber.module.d.ts +0 -2
  84. package/dist/src/modules/db-hooks-subscriber/db-hooks-subscriber.module.js +0 -22
  85. package/dist/src/modules/db-hooks-subscriber/db-hooks-subscriber.module.js.map +0 -1
@@ -0,0 +1,49 @@
1
+ // @ts-check
2
+ import eslint from '@eslint/js';
3
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
4
+ import globals from 'globals';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default tseslint.config(
8
+ {
9
+ ignores: ['eslint.config.mjs', '**/*.mjs'],
10
+ },
11
+ eslint.configs.recommended,
12
+ ...tseslint.configs.recommendedTypeChecked,
13
+ eslintPluginPrettierRecommended,
14
+ {
15
+ languageOptions: {
16
+ globals: {
17
+ ...globals.node,
18
+ ...globals.jest,
19
+ },
20
+ ecmaVersion: 5,
21
+ sourceType: 'module',
22
+ parserOptions: {
23
+ projectService: true,
24
+ tsconfigRootDir: import.meta.dirname,
25
+ },
26
+ },
27
+ },
28
+ {
29
+ rules: {
30
+ '@typescript-eslint/no-explicit-any': 'off',
31
+ '@typescript-eslint/no-floating-promises': 'warn',
32
+ '@typescript-eslint/no-unsafe-argument': 'warn',
33
+ '@typescript-eslint/no-unsafe-assignment': 'warn',
34
+ '@typescript-eslint/no-unsafe-member-access': 'warn',
35
+ '@typescript-eslint/no-unsafe-call': 'warn',
36
+ '@typescript-eslint/no-unsafe-return': 'warn',
37
+ '@typescript-eslint/no-empty-object-type': 'warn',
38
+ '@typescript-eslint/no-unused-vars': [
39
+ 'warn',
40
+ {
41
+ vars: 'all',
42
+ varsIgnorePattern: '^_',
43
+ args: 'after-used',
44
+ argsIgnorePattern: '^_',
45
+ },
46
+ ],
47
+ },
48
+ },
49
+ );
package/index.ts CHANGED
@@ -3,7 +3,16 @@ export * from './src/modules/logger/pino/logger.module';
3
3
  export * from './src/modules/logger/pino/logger.default';
4
4
  export * from './src/core/application/base.interface';
5
5
  export * from './src/core/application/base.service';
6
+ export * from './src/core/application/cached-base.service';
7
+ export * from './src/core/application/base.mongo.interface';
8
+ export * from './src/core/application/base.mongo.service';
9
+ export * from './src/core/application/cached-base.service';
6
10
  export * from './src/core/domain/interfaces/base.repository.interface';
11
+ export * from './src/core/domain/interfaces/cache-configuration.interface';
7
12
  export * from './src/core/infrastracture/databases/base.entity';
8
13
  export * from './src/core/infrastracture/databases/base.entity.interface';
9
14
  export * from './src/core/infrastracture/databases/base.repository';
15
+ export * from './src/core/infrastracture/databases/base.mongo.entity';
16
+ export * from './src/core/infrastracture/databases/base.mongo.entity.interface';
17
+ export * from './src/core/infrastracture/databases/base.mongo.repository';
18
+ export * from './src/core/domain/interfaces/base.mongo.repository.interface';
package/jest.config.ts ADDED
@@ -0,0 +1,219 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ // For a detailed explanation regarding each configuration property, visit:
3
+ import { pathsToModuleNameMapper, JestConfigWithTsJest } from 'ts-jest';
4
+ import { compilerOptions } from './tsconfig.json';
5
+ const BUILD_ID = process.env.BUILD_ID || '';
6
+ const UNIT_TEST_REPORT_NAME = `${BUILD_ID}_unit_report.html`;
7
+
8
+ const jestConfig: JestConfigWithTsJest = {
9
+ // All imported modules in your tests should be mocked automatically
10
+ // automock: false,
11
+
12
+ // Stop running tests after `n` failures
13
+ bail: 1,
14
+
15
+ // The directory where Jest should store its cached dependency information
16
+ // cacheDirectory: "/private/var/folders/xv/43k0vp7n00jgq5zq55g1v6t40000gr/T/jest_e0",
17
+
18
+ // Automatically clear mock calls and instances between every test
19
+ // clearMocks: false,
20
+
21
+ // Indicates whether the coverage information should be collected while executing the test
22
+ collectCoverage: true,
23
+
24
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
25
+ // collectCoverageFrom: ['**/src/**/*.ts', '!**/node_modules/**'],
26
+
27
+ // The directory where Jest should output its coverage files
28
+ coverageDirectory: 'coverage/unit',
29
+
30
+ // An array of regexp pattern strings used to skip coverage collection
31
+ coveragePathIgnorePatterns: ['/node_modules/', 'coverage', 'integration-tests'],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ // coverageProvider: "v8",
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ // coverageReporters: [
38
+ // "json",
39
+ // "text",
40
+ // "lcov",
41
+ // "clover"
42
+ // ],
43
+
44
+ // An object that configures minimum threshold enforcement for coverage results
45
+ coverageThreshold: {
46
+ global: {
47
+ branches: 80,
48
+ functions: 80,
49
+ lines: 80,
50
+ statements: 80,
51
+ },
52
+ },
53
+
54
+ // A path to a custom dependency extractor
55
+ // dependencyExtractor: undefined,
56
+
57
+ // Make calling deprecated APIs throw helpful error messages
58
+ // errorOnDeprecated: false,
59
+
60
+ // Force coverage collection from ignored files using an array of glob patterns
61
+ // forceCoverageMatch: [],
62
+
63
+ // A path to a module which exports an async function that is triggered once before all test suites
64
+ // globalSetup: undefined,
65
+
66
+ // A path to a module which exports an async function that is triggered once after all test suites
67
+ // globalTeardown: undefined,
68
+
69
+ // A set of global variables that need to be available in all test environments
70
+ // globals: {
71
+ // 'ts-jest': {
72
+ // // ts-jest configuration goes here
73
+ // },
74
+ // },
75
+
76
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
77
+ // maxWorkers: "50%",
78
+
79
+ // An array of directory names to be searched recursively up from the requiring module's location
80
+ moduleDirectories: ['node_modules', '<rootDir>'],
81
+
82
+ // An array of file extensions your modules use
83
+ moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
84
+
85
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
86
+ moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
87
+
88
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
89
+ // modulePathIgnorePatterns: [],
90
+
91
+ // Activates notifications for test results
92
+ // notify: false,
93
+
94
+ // An enum that specifies notification mode. Requires { notify: true }
95
+ // notifyMode: "failure-change",
96
+
97
+ // A preset that is used as a base for Jest's configuration
98
+ preset: 'ts-jest',
99
+
100
+ // Run tests from one or more projects
101
+ // projects: undefined,
102
+
103
+ // Use this configuration option to add custom reporters to Jest
104
+ reporters: [
105
+ 'default',
106
+ [
107
+ 'jest-html-reporters',
108
+ {
109
+ publicPath: './test-reports/unit-jest-html',
110
+ filename: `${UNIT_TEST_REPORT_NAME}`,
111
+ expand: false,
112
+ openReport: false,
113
+ includeFailureMsg: true,
114
+ },
115
+ ],
116
+ [
117
+ 'jest-junit',
118
+ {
119
+ suiteName: 'jest tests',
120
+ outputDirectory: './test-reports/unit-junit',
121
+ outputName: `${BUILD_ID}_junit.xml`,
122
+ },
123
+ ],
124
+ ],
125
+
126
+ // Automatically reset mock state between every test
127
+ // resetMocks: false,
128
+
129
+ // Reset the module registry before running each individual test
130
+ // resetModules: false,
131
+
132
+ // A path to a custom resolver
133
+ // resolver: undefined,
134
+
135
+ // Automatically restore mock state between every test
136
+ // restoreMocks: false,
137
+
138
+ // The root directory that Jest should scan for tests and modules within
139
+ // rootDir: undefined,
140
+
141
+ // A list of paths to directories that Jest should use to search for files in
142
+ // roots: [
143
+ // "<rootDir>"
144
+ // ],
145
+
146
+ // Allows you to use a custom runner instead of Jest's default test runner
147
+ // runner: "jest-runner",
148
+
149
+ // The paths to modules that run some code to configure or set up the testing environment before each test
150
+ setupFiles: ['<rootDir>/.jest/jestEnv.js'],
151
+
152
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
153
+ // setupFilesAfterEnv: [],
154
+
155
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
156
+ // slowTestThreshold: 5,
157
+
158
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
159
+ // snapshotSerializers: [],
160
+
161
+ // The test environment that will be used for testing
162
+ // testEnvironment: "node",
163
+
164
+ // Options that will be passed to the testEnvironment
165
+ // testEnvironmentOptions: {},
166
+
167
+ // Adds a location field to test results
168
+ // testLocationInResults: false,
169
+
170
+ // The glob patterns Jest uses to detect test files
171
+ testMatch: ['**/__tests__/**/*.spec.ts', '**/?(*.)+(spec).ts'],
172
+
173
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
174
+ testPathIgnorePatterns: [
175
+ '/node_modules/',
176
+ 'coverage',
177
+ 'integration-tests',
178
+ '/src/integration-tests/variable/utils.ts',
179
+ ],
180
+
181
+ // The regexp pattern or array of patterns that Jest uses to detect test files
182
+ // testRegex: "^(.+)\/__test__\/.+.spec\\.(tsx|ts)$",
183
+ // This option allows the use of a custom results processor
184
+ // testResultsProcessor: undefined,
185
+
186
+ // This option allows use of a custom test runner
187
+ // testRunner: "jasmine2",
188
+
189
+ // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
190
+ // testURL: "http://localhost",
191
+
192
+ // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
193
+ // timers: "real",
194
+
195
+ // A map from regular expressions to paths to transformers
196
+ transform: {
197
+ '^.+\\.ts?$': 'ts-jest',
198
+ },
199
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
200
+ // transformIgnorePatterns: [
201
+ // "/node_modules/",
202
+ // "\\.pnp\\.[^\\/]+$"
203
+ // ],
204
+
205
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
206
+ // unmockedModulePathPatterns: undefined,
207
+
208
+ // Indicates whether each individual test should be reported during the run
209
+ verbose: true,
210
+
211
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
212
+ // watchPathIgnorePatterns: [],
213
+
214
+ // Whether to use watchman for file crawling
215
+ // watchman: true,
216
+ rootDir: '.',
217
+ roots: ['<rootDir>/src/'],
218
+ };
219
+ export default jestConfig;
package/package.json CHANGED
@@ -1,20 +1,42 @@
1
1
  {
2
2
  "name": "xcally-nest-library",
3
- "version": "0.0.35",
3
+ "version": "0.0.37-XM3778-bae91",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "",
8
8
  "license": "UNLICENSED",
9
+ "scripts": {
10
+ "bump:patch": "npm version patch -m \"Bump version to %s\"",
11
+ "prepublishOnly": "npm run build",
12
+ "build": "tsc",
13
+ "build:watch": "rimraf dist && tsc-watch -b -v",
14
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
15
+ "prettier:check": "prettier --check ./**/*.{ts,js,json,*rc}",
16
+ "prettier:write": "prettier --write ./**/*.{ts,js,json,*rc}",
17
+ "start": "nest start",
18
+ "start:dev": "nest start --watch",
19
+ "start:debug": "nest start --debug --watch",
20
+ "start:prod": "node dist/main",
21
+ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
22
+ "lib:link": "pnpm link --global",
23
+ "lib:unlink": "pnpm unlink xcally-nest-libs --global",
24
+ "publish:feat": "bash ./scripts/publish-feat.sh",
25
+ "test": "TZ=UTC jest"
26
+ },
9
27
  "dependencies": {
28
+ "@nestjs/cache-manager": "^3.0.1",
10
29
  "@nestjs/config": "^4.0.0",
30
+ "cache-manager": "^7.2.4",
11
31
  "class-transformer": "^0.5.1",
32
+ "ioredis": "^5.4.2",
33
+ "mongodb": "6.20.0",
34
+ "nestjs-cls": "^6.0.1",
12
35
  "nestjs-grpc-exceptions": "^0.2.2",
13
- "nestjs-paginate": "^11.0.0",
36
+ "nestjs-paginate": "^11.1.1",
14
37
  "nestjs-pino": "^4.3.0",
15
38
  "pino": "^9.6.0",
16
- "pino-pretty": "^13.0.0",
17
- "typeorm": "^0.3.20"
39
+ "pino-pretty": "^13.0.0"
18
40
  },
19
41
  "devDependencies": {
20
42
  "@nestjs/cli": "^11.0.2",
@@ -22,13 +44,18 @@
22
44
  "@nestjs/core": "^11.0.9",
23
45
  "@nestjs/microservices": "^11.0.9",
24
46
  "@nestjs/schematics": "^11.0.0",
47
+ "@nestjs/testing": "^11.1.7",
48
+ "@types/jest": "^29.5.14",
25
49
  "@typescript-eslint/eslint-plugin": "^8.23.0",
26
50
  "@typescript-eslint/parser": "^8.23.0",
27
51
  "eslint": "^9.19.0",
28
52
  "eslint-config-prettier": "^10.0.1",
29
53
  "eslint-plugin-prettier": "^5.2.3",
54
+ "jest": "^29.7.0",
55
+ "jest-mock-extended": "4.0.0-beta1",
30
56
  "prettier": "^3.4.2",
31
57
  "rimraf": "^6.0.1",
58
+ "ts-jest": "^29.4.5",
32
59
  "ts-node": "^10.9.2",
33
60
  "tsc-watch": "^6.2.1",
34
61
  "typescript": "^5.7.3"
@@ -36,21 +63,7 @@
36
63
  "peerDependencies": {
37
64
  "@nestjs/common": "^10.0.0 || ^11.0.0",
38
65
  "@nestjs/core": "^10.0.0 || ^11.0.0",
39
- "@nestjs/microservices": "^10.0.0 || ^11.0.0"
40
- },
41
- "scripts": {
42
- "bump:patch": "npm version patch -m \"Bump version to %s\"",
43
- "build": "tsc",
44
- "build:watch": "rimraf dist && tsc-watch -b -v",
45
- "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
46
- "prettier:check": "prettier --check ./**/*.{ts,js,json,*rc}",
47
- "prettier:write": "prettier --write ./**/*.{ts,js,json,*rc}",
48
- "start": "nest start",
49
- "start:dev": "nest start --watch",
50
- "start:debug": "nest start --debug --watch",
51
- "start:prod": "node dist/main",
52
- "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
53
- "lib:link": "pnpm link --global",
54
- "lib:unlink": "pnpm unlink xcally-nest-libs --global"
66
+ "@nestjs/microservices": "^10.0.0 || ^11.0.0",
67
+ "typeorm": "^0.3.20"
55
68
  }
56
- }
69
+ }
@@ -0,0 +1,67 @@
1
+ #!/bin/bash
2
+
3
+ # Check the number of parameters
4
+ if [ "$#" -ne 1 ]; then
5
+ echo "Error: You must specify exactly one parameter."
6
+ echo "Specify task name without dash as parameter (e.g., XM1234 or XM12345)."
7
+ exit 1
8
+ fi
9
+
10
+ # Parameter validation
11
+ REGEX="^XM[0-9]{4,5}$"
12
+
13
+ if [[ ! "$1" =~ $REGEX ]]; then
14
+ echo "Error: The parameter '$1' is not valid."
15
+ echo "It must start with 'XM' followed by 4 or 5 digits (e.g., XM1234 or XM12345)."
16
+ exit 1
17
+ fi
18
+
19
+ task_name=$1
20
+
21
+ # Abort if pending changes are present in the working area
22
+ git_status=$(git status --porcelain)
23
+ if [[ -n "$git_status" ]]; then
24
+ echo "There are pending changes in the working directory."
25
+ echo "Script execution will be aborted."
26
+ exit 1
27
+ fi
28
+
29
+ # Get the version of the package
30
+ package_version=$(cat package.json \
31
+ | grep version \
32
+ | head -1 \
33
+ | awk -F: '{ print $2 }' \
34
+ | sed 's/[",]//g' \
35
+ | tr -d '[[:space:]]')
36
+
37
+ # Get SemVer from package version
38
+ sem_ver=$(echo "$package_version" | grep -o '^[^-]*')
39
+
40
+ # Get commit hash
41
+ full_commit=$(git rev-parse HEAD)
42
+ commit=${full_commit:0:5}
43
+
44
+ # Update the version of the package
45
+ npm version $sem_ver-$task_name-$commit --no-git-tag-version
46
+
47
+ # Install dependencies
48
+ pnpm i
49
+
50
+ # Publish the package
51
+ npm publish --tag $task_name
52
+ PUBLISH_EXIT_CODE=$?
53
+
54
+ # Clean changes to package.json
55
+ git checkout package.json
56
+
57
+ # Check if publish failed
58
+ if [ $PUBLISH_EXIT_CODE -ne 0 ]; then
59
+ echo ""
60
+ echo "Error: npm publish failed with code $PUBLISH_EXIT_CODE"
61
+ exit $PUBLISH_EXIT_CODE
62
+ fi
63
+
64
+ # # Print the installation command of the published packaged
65
+ printf "\nPackage successfully published."
66
+ printf "\nInstall it using the following command:"
67
+ printf "\npnpm i --save-exact xcally-nest-library@$sem_ver-$task_name-$commit\n\n"