nitor 0.0.1

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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": ["@commitlint/config-angular"],
3
+ "rules": {
4
+ "subject-case": [
5
+ 2,
6
+ "always",
7
+ ["sentence-case", "start-case", "pascal-case", "upper-case", "lower-case"]
8
+ ]
9
+ }
10
+ }
package/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+
14
+ [*.md]
15
+ max_line_length = off
16
+ trim_trailing_whitespace = false
package/.eslintrc.js ADDED
@@ -0,0 +1,29 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ node: true,
5
+ commonjs: true,
6
+ },
7
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
8
+ overrides: [
9
+ {
10
+ env: {
11
+ node: true,
12
+ },
13
+ files: ['.eslintrc.{js,cjs}'],
14
+ parserOptions: {
15
+ sourceType: 'script',
16
+ },
17
+ },
18
+ ],
19
+ parser: '@typescript-eslint/parser',
20
+ parserOptions: {
21
+ ecmaVersion: 'latest',
22
+ sourceType: 'module',
23
+ },
24
+ plugins: ['@typescript-eslint'],
25
+ rules: {
26
+ '@typescript-eslint/no-unsafe-optional-chain': 'off',
27
+ '@typescript-eslint/no-var-requires': 'off',
28
+ },
29
+ };
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ package-lock.json -diff -merge
2
+ package-lock.json linguist-generated=true
package/.prettierrc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "printWidth": 100
5
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "branches": ["master"],
3
+ "plugins": [
4
+ [
5
+ "@semantic-release/commit-analyzer",
6
+ {
7
+ "preset": "angular",
8
+ "releaseRules": [
9
+ { "type": "feat", "release": "minor" },
10
+ { "type": "fix", "release": "patch" },
11
+ { "type": "docs", "release": false },
12
+ { "type": "style", "release": false },
13
+ { "type": "refactor", "release": "patch" },
14
+ { "type": "perf", "release": "patch" },
15
+ { "type": "breaking", "release": "major" }
16
+ ],
17
+ "parserOpts": {
18
+ "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
19
+ }
20
+ }
21
+ ],
22
+ "@semantic-release/release-notes-generator",
23
+ "@semantic-release/changelog",
24
+ "@semantic-release/npm",
25
+ "@semantic-release/github",
26
+ [
27
+ "@semantic-release/git",
28
+ {
29
+ "assets": ["CHANGELOG.md", "package.json"],
30
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
31
+ }
32
+ ]
33
+ ]
34
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,72 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0] - 2025-07-12
4
+
5
+ ### Initial Release
6
+
7
+ We are pleased to announce the first official release of **Nithin Utils**.
8
+
9
+ #### Features
10
+
11
+ - Command-line interface for building, deploying, and managing 4medica projects (portal, gateway, phr).
12
+ - Environment-based configuration via `.env.nu` for secure token and URL management.
13
+ - Automated build and deployment workflows for both client and backend components.
14
+ - Status checks and reporting for CI/CD operations.
15
+ - Utility functions for parameter parsing and object cleanup.
16
+ - Scriptable and extensible for automation and integration into larger workflows.
17
+
18
+ For a complete list of changes and discussion, see [Issue #1](https://github.com/codebynithin/nithin-utils/issues/1).
19
+
20
+ ## [1.0.2] - 2025-07-12
21
+
22
+ ### Bug Fixes
23
+
24
+ - Website liveness checks are now bypassed when executing the `nu help` or `nu version` commands, ensuring faster and uninterrupted access to help and version information.
25
+
26
+ For a complete list of changes and discussion, see [Issue #2](https://github.com/codebynithin/nithin-utils/issues/2).
27
+
28
+ ## [1.1.0] - 2025-08-14
29
+
30
+ ### Features
31
+
32
+ - Added support for creating git branches, see [Issue #3](https://github.com/codebynithin/nithin-utils/issues/3).
33
+
34
+ ## [1.2.0] - 2025-08-15
35
+
36
+ ### Features
37
+
38
+ - Added support for automating AI Review, see [Issue #4](https://github.com/codebynithin/nithin-utils/issues/4).
39
+
40
+ ## [1.2.1] - 2025-08-25
41
+
42
+ ### Bug Fixes
43
+
44
+ - Fixed Review review url, see [Issue #6](https://github.com/codebynithin/nithin-utils/issues/6).
45
+
46
+ ## [1.2.2] - 2025-09-15
47
+
48
+ ### Features
49
+
50
+ - Added support for automating build, see [Issue #7](https://github.com/codebynithin/nithin-utils/issues/7).
51
+
52
+ ### Bug Fixes
53
+
54
+ - Fixed build branch, see [Issue #8](https://github.com/codebynithin/nithin-utils/issues/8).
55
+
56
+ ## [1.3.0] - 2025-09-21
57
+
58
+ ### Features
59
+
60
+ - Added support for automating build, see [Issue #9](https://github.com/codebynithin/nithin-utils/issues/9).
61
+
62
+ ## [1.4.0] - 2025-10-10
63
+
64
+ ### Features
65
+
66
+ - Added support for automating backup, see [Issue #12](https://github.com/codebynithin/nithin-utils/issues/12).
67
+
68
+ ## [1.5.0] - 2025-10-22
69
+
70
+ ### Features
71
+
72
+ - Added support for automating merge, see [Issue #14](https://github.com/codebynithin/nithin-utils/issues/14).
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # @codebynithin/nithin-utils
2
+
3
+ <a name="readme-top"></a>
4
+
5
+ <!-- PROJECT LOGO -->
6
+ <br />
7
+ <div align="center">
8
+ <a href="https://github.com/codebynithin/time-entry">
9
+ <img src="./favicon.png" alt="Logo" width="80" height="80">
10
+ </a>
11
+ </div>
12
+
13
+ A CLI utility toolkit for automating and managing build, deploy, and status operations for projects, AI code review, AI text refactor and related components.
14
+
15
+ ## Features
16
+
17
+ - Build and deploy Gitlab project
18
+ - Check build and deployment status
19
+ - Utility functions for parameter parsing and object cleaning
20
+ - Extensible and scriptable for automation
21
+ - Create git branch
22
+ - AI Review merge request
23
+ - AI text refactoring
24
+ - Backup and restore MongoDB
25
+ - Merge git branches
26
+
27
+ ## Requirements
28
+
29
+ - Node.js >= 14.x
30
+ - npm >= 6.x
31
+ - A properly configured `.env.nu` file in your `~/Desktop` directory with required tokens and URLs:
32
+ - `CSRF_TOKEN`
33
+ - `COOKIE`
34
+ - `ORIGIN`
35
+ - `GITLAB_TOKEN`
36
+ - `MR_PROMPT`
37
+ - `MR_LANG`
38
+ - `AI_API_KEY`
39
+ - `AI_MODEL`
40
+ - `BACKUP_CONFIG`
41
+ - `RESTORE_CONFIG`
42
+
43
+ ## Usage
44
+
45
+ You can use the CLI via the `nu` command:
46
+
47
+ ```bash
48
+ nu <command> [options]
49
+ ```
50
+
51
+ ### Example Commands
52
+
53
+ - **Build:**
54
+ ```bash
55
+ nu build -project <project name> -components <component name> -instance <instance name>
56
+ ```
57
+ - **Deploy:**
58
+ ```bash
59
+ nu deploy -project <project name> -components <component name> -instance <instance name>
60
+ ```
61
+ - **Build & Deploy:**
62
+ ```bash
63
+ nu build-deploy -project <project name> -components <component name> -instance <instance name>
64
+ ```
65
+ - **Create branch:**
66
+ ```bash
67
+ nu create-branch -task <task number> -type <feat|fix> -description <description> -repository <repository name>
68
+ ```
69
+ - **Review:**
70
+ ```bash
71
+ nu review -project <project short name> -mergeId <merge id> -repository <repository name>
72
+ ```
73
+ - **Refactor Text:**
74
+ ```bash
75
+ nu refactor <text>
76
+ ```
77
+ - **Backup:**
78
+ ```bash
79
+ nu backup <text>
80
+ ```
81
+ - **Restore:**
82
+ ```bash
83
+ nu restore <text>
84
+ ```
85
+ - **Merge:**
86
+ ```bash
87
+ nu merge -source <source branch> -target <target branch>
88
+ ```
89
+
90
+ ### Command Reference
91
+
92
+ - `build` : Build specified components
93
+ - `deploy` : Deploy specified components
94
+ - `build-deploy` : Build and then deploy
95
+ - `version` : Show version info
96
+ - `help` : Show help
97
+ - `init` : Initialize configuration
98
+ - `create-branch` : Create git branch
99
+ - `review` : AI review specified merge request
100
+ - `refactor` : AI refactor specified text
101
+ - `backup` : Backup specified projects
102
+ - `restore` : Restore specified projects
103
+ - `merge` : Merge source branch into target branch
104
+
105
+ ### Options
106
+
107
+ - `-project` or `-p` : Project name (`portal`, `gateway`, `phr`)
108
+ - `-components` or `-c` : Components (`client`, `backend`, etc.)
109
+ - `-instance` or `-i` : Instance/environment (`dev`, `qa`, `pilot`)
110
+ - `-branch` or `-b` : Git branch (optional)
111
+ - `-task` or `-t` : Task number
112
+ - `-type` or `-ty` : Type (`feat`, `fix`)
113
+ - `-description` or `-d` : Description
114
+ - `-repository` or `-r` : Repository name
115
+ - `-mergeId` or `-mId` : Merge ID
116
+ - `-source` or `-so` : Source branch name
117
+ - `-target` or `-ta` : Target branch name
118
+
119
+ ## License
120
+
121
+ ISC
122
+
123
+ ## Author
124
+
125
+ Nithin V (<mails2nithin@gmail.com>)
package/favicon.png ADDED
Binary file
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ const { processArgs } = require('./services/process-commands.js');
3
+ const initNpm = async () => {
4
+ let [type, ...value] = (process.argv || []).splice(2);
5
+
6
+ if (!type) {
7
+ type = 'help';
8
+ }
9
+
10
+ processArgs(type, value?.join(' '));
11
+ };
12
+
13
+ initNpm();
14
+
15
+ module.exports = initNpm;
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "nitor",
3
+ "version": "0.0.1",
4
+ "description": "Nithin command line interface",
5
+ "main": "index.js",
6
+ "author": "Nithin V <mails2nithin@gmail.com>",
7
+ "bin": "index.js",
8
+ "scripts": {
9
+ "start": "node index",
10
+ "start:dev": "nodemon index",
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "lint": "eslint \"services/*.js\" --fix",
13
+ "prettier": "prettier \"services/*.js\" --write",
14
+ "release": "semantic-release"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/codebynithin/nitor.git"
19
+ },
20
+ "keywords": [
21
+ "nitor",
22
+ "nithin",
23
+ "utils",
24
+ "nithin-utils",
25
+ "nithin-cli",
26
+ "cli",
27
+ "merge",
28
+ "review",
29
+ "build",
30
+ "deploy"
31
+ ],
32
+ "license": "ISC",
33
+ "bugs": {
34
+ "url": "https://github.com/codebynithin/nitor/issues"
35
+ },
36
+ "homepage": "https://github.com/codebynithin/nitor#readme",
37
+ "dependencies": {
38
+ "@google/generative-ai": "~0.24.1",
39
+ "axios": "~1.12.2",
40
+ "chalk": "~4.1.2",
41
+ "cheerio": "~1.0.0-rc.12",
42
+ "commander": "~14.0.1",
43
+ "compression": "~1.8.1",
44
+ "date-fns": "~2.30.0",
45
+ "date-fns-tz": "~2.0.1",
46
+ "dotenv": "~16.4.5",
47
+ "form-data": "~4.0.0"
48
+ },
49
+ "devDependencies": {
50
+ "@commitlint/cli": "~19.8.1",
51
+ "@commitlint/config-angular": "~19.8.1",
52
+ "@semantic-release/changelog": "6.0.3",
53
+ "@semantic-release/git": "10.0.1",
54
+ "@semantic-release/npm": "12.0.1",
55
+ "@typescript-eslint/eslint-plugin": "~7.3.1",
56
+ "eslint": "~8.57.0",
57
+ "eslint-config-semistandard": "~17.0.0",
58
+ "eslint-config-standard": "~17.1.0",
59
+ "eslint-plugin-import": "~2.29.1",
60
+ "eslint-plugin-n": "~15.7.0",
61
+ "eslint-plugin-promise": "~6.1.1",
62
+ "husky": "~4.3.6",
63
+ "lint-staged": "~15.2.2",
64
+ "prettier": "~3.2.5",
65
+ "semantic-release": "24.2.0"
66
+ },
67
+ "lint-staged": {
68
+ "**/*.(js)": [
69
+ "eslint --fix",
70
+ "prettier --write"
71
+ ]
72
+ },
73
+ "husky": {
74
+ "hooks": {
75
+ "pre-commit": "lint-staged",
76
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
77
+ }
78
+ },
79
+ "type": "commonjs"
80
+ }
@@ -0,0 +1,55 @@
1
+ const axios = require('axios');
2
+ const { generateBuildConfigs, generateBuildStatusConfigs, wait } = require('./utils');
3
+
4
+ const build = async (values) => {
5
+ const { configs } = generateBuildConfigs(values);
6
+
7
+ if (!(configs.client?.config || configs.backend?.config)) {
8
+ return;
9
+ }
10
+
11
+ for (const [key, { config }] of Object.entries(configs)) {
12
+ await axios
13
+ .request(config)
14
+ .then((response) => {
15
+ configs[key].buildId = response?.data?.id;
16
+ })
17
+ .catch((error) => {
18
+ console.log(error);
19
+ });
20
+ }
21
+
22
+ console.log('Built: ', { buildIds: Object.values(configs).map((c) => c.buildId) });
23
+
24
+ return configs;
25
+ };
26
+ const buildStatus = async (values, configs) => {
27
+ configs = generateBuildStatusConfigs(values, configs);
28
+
29
+ for (const [key, { statusConfig }] of Object.entries(configs)) {
30
+ let status = await checkStatus(statusConfig);
31
+
32
+ while (status !== 'passed' && status !== 'failed') {
33
+ await wait(30000);
34
+
35
+ status = await checkStatus(statusConfig);
36
+ }
37
+
38
+ configs[key].status = status;
39
+ }
40
+
41
+ return configs;
42
+ };
43
+ const checkStatus = async (config) => {
44
+ return await axios
45
+ .request(config)
46
+ .then((response) => {
47
+ return response?.data?.details?.status?.label;
48
+ })
49
+ .catch((error) => {
50
+ console.log(error);
51
+ return null;
52
+ });
53
+ };
54
+
55
+ module.exports = { build, buildStatus };
@@ -0,0 +1,29 @@
1
+ const { execSync } = require('child_process');
2
+
3
+ const createBranch = async (values) => {
4
+ if (!values.task || !values.type || !values.description) {
5
+ console.log('Invalid branch parameters');
6
+
7
+ return;
8
+ }
9
+
10
+ if (isNaN(values.task)) {
11
+ console.log('Invalid task number');
12
+
13
+ return;
14
+ }
15
+
16
+ if (!values.project) {
17
+ values.project = 'portal';
18
+ }
19
+
20
+ const branchName = `${values.project}-${values.task}-${values.type}-${values.description.toLowerCase().replace(/\s/g, '-')}`;
21
+
22
+ try {
23
+ execSync(`git checkout -b ${branchName}`, { stdio: 'inherit' });
24
+ } catch (error) {
25
+ console.error('Error creating branch:', error.message);
26
+ }
27
+ };
28
+
29
+ module.exports = { createBranch };
@@ -0,0 +1,21 @@
1
+ const axios = require('axios');
2
+ const { generateDeployConfigs } = require('./utils');
3
+ const deploy = async (values) => {
4
+ const { configs } = generateDeployConfigs(values);
5
+ const buildIds = [];
6
+
7
+ await axios
8
+ .request(configs)
9
+ .then((response) => {
10
+ buildIds.push(response?.data?.id);
11
+ })
12
+ .catch((error) => {
13
+ console.log(error);
14
+ });
15
+
16
+ console.log('Deployed: ', { buildIds });
17
+
18
+ return buildIds;
19
+ };
20
+
21
+ module.exports = { deploy };
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ ACTIONS: {
3
+ BUILD: 'build',
4
+ DEPLOY: 'deploy',
5
+ BUILD_DEPLOY: 'build-deploy',
6
+ VERSION: 'version',
7
+ HELP: 'help',
8
+ CREATE_BRANCH: 'create-branch',
9
+ REVIEW: 'review',
10
+ REFACTOR: 'refactor',
11
+ BACKUP: 'backup',
12
+ MERGE: 'merge',
13
+ },
14
+ };
@@ -0,0 +1,34 @@
1
+ const { execSync } = require('child_process');
2
+
3
+ const merge = async (values) => {
4
+ const { source, target } = values;
5
+
6
+ if (!source || !target) {
7
+ console.error('Error: Both -source and -target branch parameters are required');
8
+ console.log('Usage: nu merge -source <source branch> -target <target branch>');
9
+ return;
10
+ }
11
+
12
+ try {
13
+ console.log('Starting merge process...\n');
14
+
15
+ execSync('git checkout master', { stdio: 'inherit' });
16
+ execSync('git pull', { stdio: 'inherit' });
17
+ execSync(`git checkout ${source}`, { stdio: 'inherit' });
18
+ execSync('git pull', { stdio: 'inherit' });
19
+
20
+ for (const branch of target.split(' ')) {
21
+ execSync(`git checkout ${branch}`, { stdio: 'inherit' });
22
+ execSync('git pull', { stdio: 'inherit' });
23
+ execSync(`git merge ${source} --no-edit`, { stdio: 'inherit' });
24
+ execSync('git push', { stdio: 'inherit' });
25
+ }
26
+
27
+ console.log('\n✓ Merge completed successfully!');
28
+ } catch (error) {
29
+ console.error('\n✗ Merge failed:', error.message);
30
+ process.exit(1);
31
+ }
32
+ };
33
+
34
+ module.exports = { merge };