@@ -2,6 +2,7 @@ import axios from 'axios';
2
2
import { spawn } from 'node:child_process' ;
3
3
import { randomUUID } from 'node:crypto' ;
4
4
import { Agent } from 'node:https' ;
5
+ import { gte , lt } from 'semver' ;
5
6
6
7
const httpClient = axios . create ( {
7
8
baseURL : 'https://localhost:7443' ,
@@ -66,6 +67,10 @@ const initUser = async (username = 'admin', password = 'admin') => {
66
67
password : password ,
67
68
} ) ;
68
69
70
+ // If the version is lower than 3.2.15, the license should be activated first.
71
+ if ( lt ( '3.2.15' , process . env . BACKEND_API7_VERSION ?? '0.0.0' ) )
72
+ await activateAPI7 ( ) ;
73
+
69
74
console . log ( 'Modify password' ) ;
70
75
await httpClient . put ( `/api/password` , {
71
76
old_password : password ,
@@ -80,6 +85,11 @@ const initUser = async (username = 'admin', password = 'admin') => {
80
85
username : username ,
81
86
password : 'Admin12345!' ,
82
87
} ) ;
88
+
89
+ // If the version is greater than or equal to 3.2.15, the license should
90
+ // be activated after changing the password.
91
+ if ( gte ( '3.2.15' , process . env . BACKEND_API7_VERSION ?? '0.0.0' ) )
92
+ await activateAPI7 ( ) ;
83
93
} ;
84
94
85
95
const activateAPI7 = async ( ) => {
@@ -124,7 +134,6 @@ const generateToken = async () => {
124
134
export default async ( ) => {
125
135
if ( process . env [ 'SKIP_API7_SETUP' ] !== 'true' ) await setupAPI7 ( ) ;
126
136
await initUser ( ) ;
127
- await activateAPI7 ( ) ;
128
137
await generateToken ( ) ;
129
138
130
139
process . env . SERVER = 'https://localhost:7443' ;
0 commit comments