@corva/create-app 0.48.0-5 → 0.48.0-6

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.
@@ -2,9 +2,11 @@ import NpmApi from 'npm-api';
2
2
  import chalk from 'chalk';
3
3
  import semver from 'semver';
4
4
  import inquirer from 'inquirer';
5
+ import { join } from 'path';
6
+ import * as url from 'url';
5
7
 
6
- import packageJson from '../../../package.json' assert { type: 'json' };
7
8
  import { logger } from '../../helpers/logger.js';
9
+ import fs from 'fs-extra';
8
10
 
9
11
  const npm = new NpmApi();
10
12
 
@@ -13,12 +15,13 @@ const warning = chalk.hex('#FFA500'); // Orange
13
15
  const code = chalk.cyan;
14
16
  const asterisks = '****************************************************************';
15
17
 
16
- const getCurrentVersion = () => packageJson.version;
18
+ const getCurrentVersion = async () =>
19
+ (await fs.readJSON(join(url.fileURLToPath(new URL('.', import.meta.url)), '../../../package.json'))).version;
17
20
  const getLatestVersion = async () => npm.repo('@corva/create-app').prop('version');
18
21
 
19
22
  // NOTE: Stop process and show error if version is outdated
20
23
  export async function ensureLatestVersion() {
21
- const currentVersion = getCurrentVersion();
24
+ const currentVersion = await getCurrentVersion();
22
25
  const latestVersion = await getLatestVersion();
23
26
 
24
27
  const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
@@ -42,7 +45,7 @@ export async function ensureLatestVersion() {
42
45
  export async function warnIfOutdated() {
43
46
  logger.write('Checking for updates...\n');
44
47
 
45
- const currentVersion = getCurrentVersion();
48
+ const currentVersion = await getCurrentVersion();
46
49
  const latestVersion = await getLatestVersion();
47
50
 
48
51
  const isCurrentVersionOutdated = semver.gt(latestVersion, currentVersion);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.48.0-5",
3
+ "version": "0.48.0-6",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [