agrs-sequelize-sdk 1.0.2 → 1.0.4

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 (6) hide show
  1. package/index.js +0 -18
  2. package/jq.exe +0 -0
  3. package/package.json +1 -19
  4. package/run.bat +105 -0
  5. package/run.ps1 +98 -0
  6. package/run.sh +74 -0
package/index.js CHANGED
@@ -72,22 +72,4 @@ class DBModels {
72
72
  }
73
73
  }
74
74
 
75
- const config = {
76
- username: 'avnadmin',
77
- password: 'AVNS_nRgOZOZ4v1We_KncNYr',
78
- database: 'defaultdb',
79
- host: 'pg-7f50792-dev-7212.l.aivencloud.com',
80
- port: 28333, // Replace with the appropriate port for your database
81
- dialect: 'postgres', // Replace with your dialect (e.g., 'postgres', 'mysql')
82
- };
83
-
84
- (async () => {
85
- // Initialize Sequelize models and apply any pending migrations (if included in your SDK)
86
- const Db = new DBModels(config);
87
- const db = Db.db;
88
- // Example usage of the models
89
- console.log(db);
90
-
91
- })();
92
-
93
75
  module.exports = DBModels;
package/jq.exe ADDED
Binary file
package/package.json CHANGED
@@ -1,19 +1 @@
1
- {
2
- "name": "agrs-sequelize-sdk",
3
- "version": "1.0.2",
4
- "main": "index.js",
5
- "scripts": {
6
- "start": "node index.js",
7
- "sync": "node services/sequelizeService.js",
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "keywords": [],
11
- "author": "",
12
- "license": "ISC",
13
- "description": "",
14
- "dependencies": {
15
- "pg": "^8.13.0",
16
- "pg-hstore": "^2.3.4",
17
- "sequelize": "^6.37.4"
18
- }
19
- }
1
+ {"name":"agrs-sequelize-sdk","version":"1.0.4","main":"index.js","scripts":{"start":"node index.js","sync":"node services/sequelizeService.js","test":"echo \"Error: no test specified\" \u0026\u0026 exit 1"},"keywords":[],"author":"","license":"ISC","description":"","dependencies":{"pg":"^8.13.0","pg-hstore":"^2.3.4","sequelize":"^6.37.4"}}
package/run.bat ADDED
@@ -0,0 +1,105 @@
1
+ @echo off
2
+ setlocal
3
+
4
+ :: Check if running as administrator
5
+ net session >nul 2>&1
6
+ if %ERRORLEVEL% neq 0 (
7
+ echo This script must be run as an administrator.
8
+ echo Please right-click on the script and select 'Run as Administrator'.
9
+ pause
10
+ exit /b 1
11
+ )
12
+
13
+ :: Check if jq is installed
14
+ where jq >nul 2>nul
15
+ if %ERRORLEVEL% neq 0 (
16
+ echo jq not found. Downloading jq manually...
17
+ powershell -Command "Invoke-WebRequest -Uri https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe -OutFile %TEMP%\jq.exe"
18
+ if exist %TEMP%\jq.exe (
19
+ move /y %TEMP%\jq.exe %SystemRoot%\System32\jq.exe >nul
20
+ if %ERRORLEVEL% neq 0 (
21
+ echo Failed to move jq to System32. Please run this script as administrator.
22
+ exit /b 1
23
+ )
24
+ echo jq installed manually.
25
+ ) else (
26
+ echo Failed to download jq. Please install it manually.
27
+ exit /b 1
28
+ )
29
+ )
30
+
31
+ :: Step 1: Check if already logged in to NPM
32
+ npm whoami >nul 2>nul
33
+ if %ERRORLEVEL% neq 0 (
34
+ echo Not logged in. Logging in to NPM...
35
+ npm login
36
+ if %ERRORLEVEL% neq 0 (
37
+ echo NPM login failed. Exiting...
38
+ exit /b 1
39
+ )
40
+ ) else (
41
+ for /f %%i in ('npm whoami') do set USERNAME=%%i
42
+ echo Already logged in to NPM as %USERNAME%
43
+ )
44
+
45
+ :: Step 2: Increment version in package.json
46
+ for /f "tokens=*" %%i in ('jq -r ".version" package.json') do set current_version=%%i
47
+
48
+ if "%current_version%"=="" (
49
+ echo Could not find version in package.json
50
+ exit /b 1
51
+ )
52
+
53
+ :: Split version into major, minor, patch
54
+ for /f "tokens=1-3 delims=." %%a in ("%current_version%") do (
55
+ set major=%%a
56
+ set minor=%%b
57
+ set patch=%%c
58
+ )
59
+
60
+ :: Increment version numbers with three-digit logic
61
+ if "%patch%"=="99" (
62
+ set patch=0
63
+ if "%minor%"=="99" (
64
+ set minor=0
65
+ set /a major+=1
66
+ ) else (
67
+ set /a minor+=1
68
+ )
69
+ ) else (
70
+ set /a patch+=1
71
+ )
72
+
73
+ set new_version=%major%.%minor%.%patch%
74
+
75
+ :: Update the version in package.json using jq
76
+ jq --arg new_version "%new_version%" ".version = $new_version" package.json > temp.json && move /y temp.json package.json
77
+
78
+ if %ERRORLEVEL% neq 0 (
79
+ echo Failed to update package.json. Exiting...
80
+ exit /b 1
81
+ )
82
+
83
+ echo Version updated from %current_version% to %new_version%
84
+
85
+ :: Step 3: Publish the package to NPM
86
+ npm publish
87
+ if %ERRORLEVEL% neq 0 (
88
+ echo NPM publish failed. Exiting...
89
+ exit /b 1
90
+ )
91
+
92
+ :: Step 4: Commit the changes and push to GitHub
93
+ git add .
94
+ git commit -m "Bump version to %new_version%"
95
+ git push origin %cd:~2,100%
96
+
97
+ if %ERRORLEVEL% neq 0 (
98
+ echo Failed to push changes to GitHub. Exiting...
99
+ exit /b 1
100
+ )
101
+
102
+ echo Version %new_version% published and changes pushed to GitHub successfully!
103
+
104
+ endlocal
105
+ exit /b 0
package/run.ps1 ADDED
@@ -0,0 +1,98 @@
1
+ # Ensure the script is run as an Administrator
2
+ #If (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
3
+ # Write-Host "This script must be run as an administrator." -ForegroundColor Red
4
+ # Write-Host "Right-click on the script and select 'Run as Administrator'."
5
+ # Exit 1
6
+ #}
7
+
8
+ # Check if jq is installed
9
+ $jqPath = Get-Command jq -ErrorAction SilentlyContinue
10
+
11
+ if (-not $jqPath) {
12
+ Write-Host "jq not found. Downloading jq manually..."
13
+ $jqUrl = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe"
14
+ $jqDestination = "$env:TEMP\jq.exe"
15
+
16
+ try {
17
+ Invoke-WebRequest -Uri $jqUrl -OutFile $jqDestination
18
+ Move-Item -Path $jqDestination -Destination "$env:SystemRoot\System32\jq.exe" -Force
19
+ Write-Host "jq installed manually."
20
+ } catch {
21
+ Write-Host "Failed to download or move jq. Please ensure you have the necessary permissions."
22
+ Exit 1
23
+ }
24
+ }
25
+
26
+ # Step 1: Check if logged in to NPM
27
+ try {
28
+ $npmUsername = npm whoami 2>&1
29
+ if ($npmUsername -match "ERR") {
30
+ Write-Host "Not logged in. Please log in to NPM."
31
+ npm login
32
+ if ($LASTEXITCODE -ne 0) {
33
+ Write-Host "NPM login failed. Exiting..."
34
+ Exit 1
35
+ }
36
+ } else {
37
+ Write-Host "Already logged in to NPM as $npmUsername"
38
+ }
39
+ } catch {
40
+ Write-Host "Error while checking NPM login status."
41
+ Exit 1
42
+ }
43
+
44
+ # Step 2: Increment version in package.json
45
+ $packageJson = Get-Content -Raw -Path "package.json" | ConvertFrom-Json
46
+ $currentVersion = $packageJson.version
47
+
48
+ if (-not $currentVersion) {
49
+ Write-Host "Could not find version in package.json"
50
+ Exit 1
51
+ }
52
+
53
+ # Split version into major, minor, patch
54
+ $versionParts = $currentVersion -split '\.'
55
+
56
+ $major = [int]$versionParts[0]
57
+ $minor = [int]$versionParts[1]
58
+ $patch = [int]$versionParts[2]
59
+
60
+ # Increment version numbers with three-digit logic
61
+ if ($patch -eq 99) {
62
+ $patch = 0
63
+ if ($minor -eq 99) {
64
+ $minor = 0
65
+ $major++
66
+ } else {
67
+ $minor++
68
+ }
69
+ } else {
70
+ $patch++
71
+ }
72
+
73
+ $newVersion = "$major.$minor.$patch"
74
+
75
+ # Update the version in package.json
76
+ $packageJson.version = $newVersion
77
+ $packageJson | ConvertTo-Json -Compress | Set-Content -Path "package.json"
78
+
79
+ Write-Host "Version updated from $currentVersion to $newVersion"
80
+
81
+ # Step 3: Publish the package to NPM
82
+ npm publish
83
+ if ($LASTEXITCODE -ne 0) {
84
+ Write-Host "NPM publish failed. Exiting..."
85
+ Exit 1
86
+ }
87
+
88
+ # Step 4: Commit the changes and push to GitHub
89
+ git add .
90
+ git commit -m "Bump version to $newVersion"
91
+ git push origin master
92
+
93
+ if ($LASTEXITCODE -ne 0) {
94
+ Write-Host "Failed to push changes to GitHub. Exiting..."
95
+ Exit 1
96
+ }
97
+
98
+ Write-Host "Version $newVersion published and changes pushed to GitHub successfully!"
package/run.sh ADDED
@@ -0,0 +1,74 @@
1
+ #!/bin/bash
2
+
3
+
4
+ if ! command -v jq &> /dev/null
5
+ then
6
+ echo "jq not found. Installing jq..."
7
+ sudo apt-get update && sudo apt-get install -y jq
8
+ fi
9
+
10
+
11
+ # Step 1: Check if already logged in to NPM
12
+ if npm whoami &> /dev/null; then
13
+ echo "Already logged in to NPM as $(npm whoami)"
14
+ else
15
+ echo "Not logged in. Logging in to NPM..."
16
+ npm login
17
+ if [ $? -ne 0 ]; then
18
+ echo "NPM login failed. Exiting..."
19
+ exit 1
20
+ fi
21
+ fi
22
+
23
+ # Step 2: Increment version in package.json
24
+ echo "Updating version in package.json..."
25
+
26
+ # Extract the current version
27
+ current_version=$(jq -r '.version' package.json)
28
+ if [[ -z "$current_version" ]]; then
29
+ echo "Could not find version in package.json"
30
+ exit 1
31
+ fi
32
+
33
+ # Split the version into its components
34
+ IFS='.' read -r -a version_parts <<< "$current_version"
35
+ major="${version_parts[0]}"
36
+ minor="${version_parts[1]}"
37
+ patch="${version_parts[2]}"
38
+
39
+ # Increment version numbers with three-digit logic
40
+ if [[ $patch -eq 99 ]]; then
41
+ patch=0
42
+ if [[ $minor -eq 99 ]]; then
43
+ minor=0
44
+ major=$((major + 1))
45
+ else
46
+ minor=$((minor + 1))
47
+ fi
48
+ else
49
+ patch=$((patch + 1))
50
+ fi
51
+
52
+ new_version="$major.$minor.$patch"
53
+
54
+ # Update the version in package.json using jq
55
+ jq --arg new_version "$new_version" '.version = $new_version' package.json > temp.json && mv temp.json package.json
56
+
57
+ echo "Version updated from $current_version to $new_version"
58
+
59
+ # Step 3: Publish the package to NPM
60
+ echo "Publishing the package to NPM..."
61
+ npm publish
62
+ if [ $? -ne 0 ]; then
63
+ echo "NPM publish failed. Exiting..."
64
+ exit 1
65
+ fi
66
+
67
+ # Step 4: Commit the changes and push to GitHub
68
+ echo "Committing and pushing changes to GitHub..."
69
+
70
+ git add .
71
+ git commit -m "Bump version to $new_version"
72
+ git push origin $(git rev-parse --abbrev-ref HEAD)
73
+
74
+ echo "Version $new_version published and changes pushed to GitHub successfully!"