adminforth 2.4.0-next.26 → 2.4.0-next.27
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/commands/cli.js +8 -2
- package/commands/createApp/utils.js +19 -7
- package/package.json +1 -1
package/commands/cli.js
CHANGED
|
@@ -25,19 +25,25 @@ function showHelp() {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function currentFileDir(importMetaUrl) {
|
|
28
|
+
export function currentFileDir(importMetaUrl) {
|
|
29
29
|
const filePath = importMetaUrl.replace("file://", "");
|
|
30
30
|
const fileDir = path.dirname(filePath);
|
|
31
31
|
return fileDir;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
export function getVersion() {
|
|
35
35
|
const ADMIN_FORTH_ABSOLUTE_PATH = path.join(currentFileDir(import.meta.url), '..');
|
|
36
36
|
|
|
37
37
|
const package_json = JSON.parse(fs.readFileSync(path.join(ADMIN_FORTH_ABSOLUTE_PATH, 'package.json'), 'utf8'));
|
|
38
38
|
|
|
39
39
|
const ADMINFORTH_VERSION = package_json.version;
|
|
40
40
|
|
|
41
|
+
return ADMINFORTH_VERSION;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function showVersion() {
|
|
45
|
+
const ADMINFORTH_VERSION = getVersion();
|
|
46
|
+
|
|
41
47
|
console.log(
|
|
42
48
|
chalk.white('AdminForth CLI version: ') +
|
|
43
49
|
chalk.cyan.bold(ADMINFORTH_VERSION)
|
|
@@ -11,17 +11,30 @@ import { exec } from 'child_process';
|
|
|
11
11
|
|
|
12
12
|
import Handlebars from 'handlebars';
|
|
13
13
|
import { promisify } from 'util';
|
|
14
|
+
import { getVersion } from '../cli.js';
|
|
14
15
|
|
|
15
16
|
const execAsync = promisify(exec);
|
|
16
17
|
|
|
17
18
|
function detectAdminforthVersion() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
try {
|
|
20
|
+
const version = getVersion();
|
|
21
|
+
|
|
22
|
+
if (typeof version !== 'string') {
|
|
23
|
+
throw new Error('Invalid version format');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (version.includes('next')) {
|
|
27
|
+
return 'next';
|
|
28
|
+
}
|
|
29
|
+
return 'latest';
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.warn('⚠️ Could not detect AdminForth version, defaulting to "latest".');
|
|
32
|
+
return 'latest';
|
|
33
|
+
}
|
|
23
34
|
}
|
|
24
35
|
|
|
36
|
+
const adminforthVersion = detectAdminforthVersion();
|
|
37
|
+
|
|
25
38
|
|
|
26
39
|
export function parseArgumentsIntoOptions(rawArgs) {
|
|
27
40
|
const args = arg(
|
|
@@ -67,7 +80,6 @@ export async function promptForMissingOptions(options) {
|
|
|
67
80
|
...options,
|
|
68
81
|
appName: options.appName || answers.appName,
|
|
69
82
|
db: options.db || answers.db,
|
|
70
|
-
adminforthVersion: detectAdminforthVersion(),
|
|
71
83
|
};
|
|
72
84
|
}
|
|
73
85
|
|
|
@@ -215,7 +227,7 @@ async function writeTemplateFiles(dirname, cwd, options) {
|
|
|
215
227
|
dest: 'package.json',
|
|
216
228
|
data: {
|
|
217
229
|
appName,
|
|
218
|
-
adminforthVersion:
|
|
230
|
+
adminforthVersion: adminforthVersion,
|
|
219
231
|
},
|
|
220
232
|
},
|
|
221
233
|
{
|