adminforth 2.4.0-next.26 → 2.4.0-next.28

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 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 showVersion() {
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
- const userAgent = process.env.npm_config_user_agent || '';
19
- if (userAgent.includes('adminforth@next')) {
20
- return 'next'
21
- };
22
- return 'main';
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: options.adminforthVersion || 'latest'
230
+ adminforthVersion: adminforthVersion,
219
231
  },
220
232
  },
221
233
  {
@@ -199,11 +199,11 @@
199
199
  <!-- pagination
200
200
  totalRows in v-if is used to not hide page input during loading when user puts cursor into it and edit directly (rows gets null there during edit)
201
201
  -->
202
- <div class="flex flex-row items-center mt-4 xs:flex-row xs:justify-between xs:items-center gap-3"
203
- v-if="(rows || totalRows) && totalRows >= pageSize && totalRows > 0"
204
- >
202
+ <div class="flex flex-row items-center mt-4 xs:flex-row xs:justify-between xs:items-center gap-3">
205
203
 
206
- <div class="inline-flex ">
204
+ <div class="inline-flex "
205
+ v-if="(rows || totalRows) && totalRows >= pageSize && totalRows > 0"
206
+ >
207
207
  <!-- Buttons -->
208
208
  <button
209
209
  class="flex items-center py-1 px-3 gap-1 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 rounded-s border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
@@ -216,11 +216,11 @@
216
216
  <!-- pagination
217
217
  totalRows in v-if is used to not hide page input during loading when user puts cursor into it and edit directly (rows gets null there during edit)
218
218
  -->
219
- <div class="flex flex-row items-center mt-4 xs:flex-row xs:justify-between xs:items-center gap-3"
220
- v-if="(rows || totalRows) && totalRows >= pageSize && totalRows > 0"
221
- >
219
+ <div class="flex flex-row items-center mt-4 xs:flex-row xs:justify-between xs:items-center gap-3">
222
220
 
223
- <div class="inline-flex ">
221
+ <div class="inline-flex "
222
+ v-if="(rows || totalRows) && totalRows >= pageSize && totalRows > 0"
223
+ >
224
224
  <!-- Buttons -->
225
225
  <button
226
226
  class="flex items-center py-1 px-3 gap-1 text-sm font-medium text-gray-900 focus:outline-none bg-white border-r-0 rounded-s border border-gray-300 hover:bg-gray-100 hover:text-lightPrimary focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 disabled:opacity-50"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.4.0-next.26",
3
+ "version": "2.4.0-next.28",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",