create-gasket-app 7.0.0-next.21 → 7.0.0-next.23
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/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/scaffold/actions/setup-pkg.js +0 -1
- package/lib/utils/index.js +0 -1
- package/package.json +6 -7
- package/lib/utils/warn-if-outdated.js +0 -78
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GasketConfigDefinition, MaybeAsync, Plugin, GasketEngine } from '@gasket/
|
|
1
|
+
import type { GasketConfigDefinition, MaybeAsync, Plugin, GasketEngine } from '@gasket/core';
|
|
2
2
|
import type { PackageManager } from '@gasket/utils';
|
|
3
3
|
|
|
4
4
|
export interface Dependencies {
|
|
@@ -239,7 +239,7 @@ export interface ActionWrapperParams {
|
|
|
239
239
|
spinner?: any;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
declare module '@gasket/
|
|
242
|
+
declare module '@gasket/core' {
|
|
243
243
|
export interface HookExecTypes {
|
|
244
244
|
presetPrompt(context: CreateContext): Promise<void>;
|
|
245
245
|
presetConfig(context: CreateContext): Promise<CreateContext['presetConfig']>;
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
4
|
import { createCommand } from './commands/create.js';
|
|
5
|
-
import { processCommand, logo
|
|
5
|
+
import { processCommand, logo } from './utils/index.js';
|
|
6
|
+
import { warnIfOutdated } from '@gasket/utils';
|
|
6
7
|
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
8
9
|
const pkg = require('../package.json');
|
package/lib/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-gasket-app",
|
|
3
|
-
"version": "7.0.0-next.
|
|
3
|
+
"version": "7.0.0-next.23",
|
|
4
4
|
"description": "starter pack for creating a gasket app",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"bin": {
|
|
@@ -32,11 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/create-gasket-app",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gasket/core": "^7.0.0-next.
|
|
36
|
-
"@gasket/
|
|
37
|
-
"@gasket/plugin-
|
|
38
|
-
"@gasket/
|
|
39
|
-
"@gasket/utils": "^7.0.0-next.21",
|
|
35
|
+
"@gasket/core": "^7.0.0-next.23",
|
|
36
|
+
"@gasket/plugin-git": "^7.0.0-next.23",
|
|
37
|
+
"@gasket/plugin-logger": "^7.0.0-next.23",
|
|
38
|
+
"@gasket/utils": "^7.0.0-next.23",
|
|
40
39
|
"commander": "^12.0.0",
|
|
41
40
|
"deepmerge": "^4.3.1",
|
|
42
41
|
"glob": "^8.1.0",
|
|
@@ -79,5 +78,5 @@
|
|
|
79
78
|
"jest": {
|
|
80
79
|
"transform": {}
|
|
81
80
|
},
|
|
82
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "0ba753c8764138e300be1c464065280bcc801239"
|
|
83
82
|
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { default as gasketUtils } from '@gasket/utils';
|
|
2
|
-
import semver from 'semver';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { readFile, writeFile } from 'fs/promises';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
const __dirname = fileURLToPath(import.meta.url);
|
|
8
|
-
|
|
9
|
-
const cachePath = path.join(__dirname, '..', '..', '..', '.cache'); // Place at root of gasket-cli
|
|
10
|
-
const LATEST_VERSION = 'latestVersion';
|
|
11
|
-
const LATEST_VERSION_UPDATE_TIME = 'latestVersionUpdateTime';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Checks if the latest version update time is older than seven days
|
|
15
|
-
* @param {number} currentTime - current time in milliseconds
|
|
16
|
-
* @param {number} latestVersionUpdateTime - latest version update time in milliseconds
|
|
17
|
-
* @returns {boolean} - true if latestVersionUpdateTime is older than seven days
|
|
18
|
-
*/
|
|
19
|
-
function isOlderThanSevenDays(currentTime, latestVersionUpdateTime) {
|
|
20
|
-
const sevenDaysInMillis = 7 * 24 * 60 * 60 * 1000; // Seven days in milliseconds
|
|
21
|
-
const timeDifference = Math.abs(currentTime - latestVersionUpdateTime);
|
|
22
|
-
return timeDifference > sevenDaysInMillis;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Fetches the latest version of a package from npm
|
|
27
|
-
* @param {string} pkgName - package name
|
|
28
|
-
* @param {number} currentTime - current time in milliseconds
|
|
29
|
-
* @param {object} cache - cache object
|
|
30
|
-
* @returns {string} - latest version of the package
|
|
31
|
-
*/
|
|
32
|
-
async function getLatestVersion(pkgName, currentTime, cache) {
|
|
33
|
-
if (
|
|
34
|
-
!cache[LATEST_VERSION_UPDATE_TIME] ||
|
|
35
|
-
!cache[LATEST_VERSION] ||
|
|
36
|
-
isOlderThanSevenDays(currentTime, cache[LATEST_VERSION_UPDATE_TIME])
|
|
37
|
-
) {
|
|
38
|
-
try {
|
|
39
|
-
const cmdResult = await gasketUtils.runShellCommand('npm', ['view', pkgName, 'version'], {});
|
|
40
|
-
if (cmdResult?.stdout) {
|
|
41
|
-
const latestVersion = cmdResult.stdout.trim();
|
|
42
|
-
cache[LATEST_VERSION_UPDATE_TIME] = currentTime;
|
|
43
|
-
cache[LATEST_VERSION] = latestVersion;
|
|
44
|
-
await writeFile(cachePath, JSON.stringify(cache));
|
|
45
|
-
return latestVersion;
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error('Error fetching latest version:', error);
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
return cache[LATEST_VERSION];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Warns if the package is outdated
|
|
57
|
-
* @param {string} pkgName - package name
|
|
58
|
-
* @param {string} currentVersion - current version of the package
|
|
59
|
-
*/
|
|
60
|
-
export async function warnIfOutdated(pkgName, currentVersion) {
|
|
61
|
-
const currentTime = new Date().getTime();
|
|
62
|
-
let cache = {};
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
const file = await readFile(cachePath, 'utf8');
|
|
66
|
-
cache = JSON.parse(file);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
// console.error('Error reading cache file:', error);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const latestVersion = await getLatestVersion(pkgName, currentTime, cache);
|
|
72
|
-
|
|
73
|
-
if (typeof latestVersion === 'string' && semver.gt(latestVersion, currentVersion)) {
|
|
74
|
-
console.warn(
|
|
75
|
-
` ${chalk.yellow('›')} Warning: ${pkgName} update available from ${chalk.green(latestVersion)} to ${chalk.green(currentVersion)}`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|