create-gasket-app 7.0.0-next.21 → 7.0.0-next.25
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 +22 -19
- 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 +9 -9
- 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 {
|
|
@@ -9,17 +9,18 @@ export interface Dependencies {
|
|
|
9
9
|
|
|
10
10
|
export interface PackageJson extends Dependencies {
|
|
11
11
|
name: string;
|
|
12
|
-
version
|
|
12
|
+
version?: string;
|
|
13
13
|
description?: string;
|
|
14
14
|
license?: string;
|
|
15
15
|
repository?:
|
|
16
16
|
| string
|
|
17
17
|
| {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
type: 'git';
|
|
19
|
+
url: string;
|
|
20
|
+
};
|
|
21
21
|
scripts?: Record<string, string>;
|
|
22
22
|
optionalDependencies?: Record<string, string>;
|
|
23
|
+
homepage?: string;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface ModuleInfo {
|
|
@@ -30,11 +31,9 @@ export interface ModuleInfo {
|
|
|
30
31
|
version?: string;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export interface PresetInfo extends ModuleInfo {
|
|
34
|
-
}
|
|
34
|
+
export interface PresetInfo extends ModuleInfo {}
|
|
35
35
|
|
|
36
|
-
export interface PluginInfo extends ModuleInfo {
|
|
37
|
-
}
|
|
36
|
+
export interface PluginInfo extends ModuleInfo {}
|
|
38
37
|
|
|
39
38
|
export interface ConfigBuilder<Config> {
|
|
40
39
|
/**
|
|
@@ -132,16 +131,16 @@ export interface ConfigBuilder<Config> {
|
|
|
132
131
|
|
|
133
132
|
export interface PackageJsonBuilder extends ConfigBuilder<PackageJson> {
|
|
134
133
|
/**
|
|
135
|
-
* Checks if a
|
|
136
|
-
* @param key -
|
|
137
|
-
* @param value -
|
|
138
|
-
* @returns True if the
|
|
134
|
+
* Checks if a property exists on the package.json fields.
|
|
135
|
+
* @param key - Field to search
|
|
136
|
+
* @param value - Value to search for
|
|
137
|
+
* @returns True if the property exists and matches the value
|
|
139
138
|
*/
|
|
140
|
-
has(key: keyof
|
|
139
|
+
has(key: keyof PackageJson, value: string): boolean;
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
export interface Files {
|
|
144
|
-
add(...args: string[]): void
|
|
143
|
+
add(...args: string[]): void;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
export interface CreateContext {
|
|
@@ -239,14 +238,17 @@ export interface ActionWrapperParams {
|
|
|
239
238
|
spinner?: any;
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
declare module '@gasket/
|
|
241
|
+
declare module '@gasket/core' {
|
|
243
242
|
export interface HookExecTypes {
|
|
244
243
|
presetPrompt(context: CreateContext): Promise<void>;
|
|
245
244
|
presetConfig(context: CreateContext): Promise<CreateContext['presetConfig']>;
|
|
246
245
|
prompt(
|
|
247
246
|
context: CreateContext,
|
|
248
247
|
utils: {
|
|
249
|
-
prompt: (
|
|
248
|
+
prompt: (
|
|
249
|
+
prompts: Array<Record<string, any>>
|
|
250
|
+
) => Promise<Record<string, any>>;
|
|
251
|
+
addPlugins: (plugins: Array<string>) => Promise<void>;
|
|
250
252
|
}
|
|
251
253
|
): MaybeAsync<CreateContext>;
|
|
252
254
|
|
|
@@ -255,7 +257,8 @@ declare module '@gasket/engine' {
|
|
|
255
257
|
postCreate(
|
|
256
258
|
context: CreateContext,
|
|
257
259
|
utils: {
|
|
258
|
-
runScript: (script: string) => Promise<void
|
|
259
|
-
}
|
|
260
|
+
runScript: (script: string) => Promise<void>;
|
|
261
|
+
}
|
|
262
|
+
): MaybeAsync<void>;
|
|
260
263
|
}
|
|
261
264
|
}
|
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,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-gasket-app",
|
|
3
|
-
"version": "7.0.0-next.
|
|
3
|
+
"version": "7.0.0-next.25",
|
|
4
4
|
"description": "starter pack for creating a gasket app",
|
|
5
|
-
"main": "lib",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
6
7
|
"bin": {
|
|
7
8
|
"create-gasket-app": "./lib/index.js"
|
|
8
9
|
},
|
|
@@ -32,11 +33,10 @@
|
|
|
32
33
|
},
|
|
33
34
|
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/create-gasket-app",
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@gasket/core": "^7.0.0-next.
|
|
36
|
-
"@gasket/
|
|
37
|
-
"@gasket/plugin-
|
|
38
|
-
"@gasket/
|
|
39
|
-
"@gasket/utils": "^7.0.0-next.21",
|
|
36
|
+
"@gasket/core": "^7.0.0-next.25",
|
|
37
|
+
"@gasket/plugin-git": "^7.0.0-next.25",
|
|
38
|
+
"@gasket/plugin-logger": "^7.0.0-next.25",
|
|
39
|
+
"@gasket/utils": "^7.0.0-next.25",
|
|
40
40
|
"commander": "^12.0.0",
|
|
41
41
|
"deepmerge": "^4.3.1",
|
|
42
42
|
"glob": "^8.1.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"diagnostics": "^2.0.2",
|
|
56
56
|
"dotenv": "^16.4.5",
|
|
57
57
|
"eslint": "^8.56.0",
|
|
58
|
-
"eslint-config-godaddy": "^7.0
|
|
58
|
+
"eslint-config-godaddy": "^7.1.0",
|
|
59
59
|
"eslint-plugin-jest": "^27.6.3",
|
|
60
60
|
"eslint-plugin-json": "^3.1.0",
|
|
61
61
|
"eslint-plugin-unicorn": "^44.0.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"jest": {
|
|
80
80
|
"transform": {}
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "0782b4f4d07d18fb6bd44ecaab3e6bdafd6d4c9d"
|
|
83
83
|
}
|
|
@@ -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
|
-
}
|