movehat 0.1.1 → 0.1.2
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/dist/commands/compile.d.ts +13 -0
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +31 -11
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/fork/create.d.ts +20 -1
- package/dist/commands/fork/create.d.ts.map +1 -1
- package/dist/commands/fork/create.js +54 -20
- package/dist/commands/fork/create.js.map +1 -1
- package/dist/commands/fork/list.d.ts +12 -1
- package/dist/commands/fork/list.d.ts.map +1 -1
- package/dist/commands/fork/list.js +50 -22
- package/dist/commands/fork/list.js.map +1 -1
- package/dist/commands/init.d.ts +19 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +64 -29
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/update.d.ts +11 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +44 -18
- package/dist/commands/update.js.map +1 -1
- package/dist/helpers/banner.d.ts +17 -0
- package/dist/helpers/banner.d.ts.map +1 -1
- package/dist/helpers/banner.js +38 -23
- package/dist/helpers/banner.js.map +1 -1
- package/dist/helpers/version-check.d.ts +12 -1
- package/dist/helpers/version-check.d.ts.map +1 -1
- package/dist/helpers/version-check.js +17 -7
- package/dist/helpers/version-check.js.map +1 -1
- package/dist/ui/colors.d.ts +77 -0
- package/dist/ui/colors.d.ts.map +1 -0
- package/dist/ui/colors.js +121 -0
- package/dist/ui/colors.js.map +1 -0
- package/dist/ui/formatters.d.ts +171 -0
- package/dist/ui/formatters.d.ts.map +1 -0
- package/dist/ui/formatters.js +186 -0
- package/dist/ui/formatters.js.map +1 -0
- package/dist/ui/index.d.ts +58 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +60 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/logger.d.ts +160 -0
- package/dist/ui/logger.d.ts.map +1 -0
- package/dist/ui/logger.js +206 -0
- package/dist/ui/logger.js.map +1 -0
- package/dist/ui/spinner.d.ts +106 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/spinner.js +120 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/symbols.d.ts +50 -0
- package/dist/ui/symbols.d.ts.map +1 -0
- package/dist/ui/symbols.js +64 -0
- package/dist/ui/symbols.js.map +1 -0
- package/dist/ui/table.d.ts +67 -0
- package/dist/ui/table.d.ts.map +1 -0
- package/dist/ui/table.js +143 -0
- package/dist/ui/table.js.map +1 -0
- package/package.json +8 -1
- package/src/commands/compile.ts +32 -11
- package/src/commands/fork/create.ts +59 -20
- package/src/commands/fork/list.ts +52 -22
- package/src/commands/init.ts +111 -74
- package/src/commands/update.ts +52 -19
- package/src/helpers/banner.ts +45 -29
- package/src/helpers/version-check.ts +20 -8
- package/src/ui/colors.ts +141 -0
- package/src/ui/formatters.ts +246 -0
- package/src/ui/index.ts +62 -0
- package/src/ui/logger.ts +226 -0
- package/src/ui/spinner.ts +171 -0
- package/src/ui/symbols.ts +74 -0
- package/src/ui/table.ts +191 -0
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Update
|
|
2
|
+
* Update Movehat CLI to the latest version from npm
|
|
3
|
+
*
|
|
4
|
+
* This command:
|
|
5
|
+
* - Fetches the latest version from npm registry
|
|
6
|
+
* - Compares with currently installed version
|
|
7
|
+
* - Auto-detects package manager (npm/yarn/pnpm)
|
|
8
|
+
* - Installs the update if a newer version is available
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Update to latest version
|
|
12
|
+
* await updateCommand();
|
|
3
13
|
*/
|
|
4
14
|
export default function updateCommand(): Promise<void>;
|
|
5
15
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AA+DA;;;;;;;;;;;;GAYG;AACH,wBAA8B,aAAa,kBAwG1C"}
|
package/dist/commands/update.js
CHANGED
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from "url";
|
|
|
5
5
|
import { homedir } from "os";
|
|
6
6
|
import { isNewerVersion } from "../helpers/semver-utils.js";
|
|
7
7
|
import { fetchLatestVersion } from "../helpers/npm-registry.js";
|
|
8
|
+
import { logger, withSpinner, box, colors } from "../ui/index.js";
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = dirname(__filename);
|
|
10
11
|
/**
|
|
@@ -46,33 +47,50 @@ function detectPackageManager() {
|
|
|
46
47
|
return "npm";
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
|
-
* Update
|
|
50
|
+
* Update Movehat CLI to the latest version from npm
|
|
51
|
+
*
|
|
52
|
+
* This command:
|
|
53
|
+
* - Fetches the latest version from npm registry
|
|
54
|
+
* - Compares with currently installed version
|
|
55
|
+
* - Auto-detects package manager (npm/yarn/pnpm)
|
|
56
|
+
* - Installs the update if a newer version is available
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Update to latest version
|
|
60
|
+
* await updateCommand();
|
|
50
61
|
*/
|
|
51
62
|
export default async function updateCommand() {
|
|
52
63
|
try {
|
|
53
|
-
console.log("Checking for updates...\n");
|
|
54
64
|
// Read current version from package.json
|
|
55
65
|
const packageJsonPath = join(__dirname, "../../package.json");
|
|
56
66
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
57
67
|
const currentVersion = packageJson.version;
|
|
58
68
|
const packageName = packageJson.name;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
69
|
+
logger.newline();
|
|
70
|
+
logger.info(`Current version: ${currentVersion}`);
|
|
71
|
+
// Fetch latest version from npm with spinner
|
|
72
|
+
const latestVersion = await withSpinner('Checking for updates...', async () => await fetchLatestVersion(packageName, { throwOnError: true }), 'Update check complete');
|
|
64
73
|
if (!latestVersion) {
|
|
65
|
-
|
|
74
|
+
logger.error("Failed to fetch latest version from npm registry");
|
|
75
|
+
logger.newline();
|
|
66
76
|
process.exit(1);
|
|
67
77
|
}
|
|
68
|
-
|
|
78
|
+
logger.info(`Latest version: ${latestVersion}`);
|
|
79
|
+
logger.newline();
|
|
69
80
|
// Compare versions
|
|
70
81
|
if (!isNewerVersion(currentVersion, latestVersion)) {
|
|
71
|
-
|
|
82
|
+
logger.success('You are already using the latest version!');
|
|
83
|
+
logger.newline();
|
|
72
84
|
return;
|
|
73
85
|
}
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
// Show update available box
|
|
87
|
+
const updateBox = box(`${colors.brandBright('Update Available!')}\n\n` +
|
|
88
|
+
`Current: ${currentVersion}\n` +
|
|
89
|
+
`Latest: ${colors.success(latestVersion)}`, { borderColor: 'warning', padding: 1 });
|
|
90
|
+
console.log(updateBox);
|
|
91
|
+
logger.newline();
|
|
92
|
+
logger.info('Updating movehat...');
|
|
93
|
+
logger.newline();
|
|
76
94
|
// Detect package manager
|
|
77
95
|
const packageManager = detectPackageManager();
|
|
78
96
|
// Build update command based on package manager
|
|
@@ -97,24 +115,32 @@ export default async function updateCommand() {
|
|
|
97
115
|
});
|
|
98
116
|
child.on("exit", (code) => {
|
|
99
117
|
if (code === 0) {
|
|
100
|
-
|
|
118
|
+
logger.newline();
|
|
119
|
+
logger.success(`Successfully updated to version ${latestVersion}!`);
|
|
120
|
+
logger.newline();
|
|
101
121
|
process.exit(0);
|
|
102
122
|
}
|
|
103
123
|
else {
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
logger.newline();
|
|
125
|
+
logger.error('Update failed');
|
|
126
|
+
logger.plain(` Try manually: ${packageManager} ${updateArgs.join(" ")}`);
|
|
127
|
+
logger.newline();
|
|
106
128
|
process.exit(1);
|
|
107
129
|
}
|
|
108
130
|
});
|
|
109
131
|
child.on("error", (error) => {
|
|
110
|
-
|
|
111
|
-
|
|
132
|
+
logger.newline();
|
|
133
|
+
logger.error(`Failed to update: ${error.message}`);
|
|
134
|
+
logger.plain(` Try manually: ${packageManager} ${updateArgs.join(" ")}`);
|
|
135
|
+
logger.newline();
|
|
112
136
|
process.exit(1);
|
|
113
137
|
});
|
|
114
138
|
}
|
|
115
139
|
catch (error) {
|
|
116
140
|
const message = error instanceof Error ? error.message : String(error);
|
|
117
|
-
|
|
141
|
+
logger.newline();
|
|
142
|
+
logger.error(`Error: ${message}`);
|
|
143
|
+
logger.newline();
|
|
118
144
|
process.exit(1);
|
|
119
145
|
}
|
|
120
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAA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,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,KAAK,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;QAClC,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/helpers/banner.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render the Movehat banner with gradient colors
|
|
3
|
+
* Uses the UI module's gradient system for consistency
|
|
4
|
+
*
|
|
5
|
+
* @returns Formatted banner string ready for console output
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const banner = renderMovehatBanner();
|
|
9
|
+
* console.log(banner);
|
|
10
|
+
*/
|
|
1
11
|
export declare const renderMovehatBanner: () => string;
|
|
12
|
+
/**
|
|
13
|
+
* Print the Movehat banner to console
|
|
14
|
+
* Convenience function that renders and logs the banner
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* printMovehatBanner();
|
|
18
|
+
*/
|
|
2
19
|
export declare const printMovehatBanner: () => void;
|
|
3
20
|
//# sourceMappingURL=banner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/helpers/banner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../src/helpers/banner.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,QAAO,MAiBtC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAO,IAErC,CAAC"}
|
package/dist/helpers/banner.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[255, 207, 64],
|
|
6
|
-
[255, 181, 45],
|
|
7
|
-
[255, 160, 30],
|
|
8
|
-
];
|
|
1
|
+
import { applyGradient, gradients, shouldUseColor, colors } from '../ui/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* MOVEHAT ASCII art banner lines
|
|
4
|
+
*/
|
|
9
5
|
const bannerLines = [
|
|
10
6
|
" ███╗ ███╗ ██████╗ ██╗ ██╗███████╗██╗ ██╗ █████╗ ████████╗",
|
|
11
7
|
" ████╗ ████║██╔═══██╗██║ ██║██╔════╝██║ ██║██╔══██╗╚══██╔══╝",
|
|
@@ -14,24 +10,43 @@ const bannerLines = [
|
|
|
14
10
|
" ██║ ╚═╝ ██║╚██████╔╝ ╚████╔╝ ███████╗██║ ██║██║ ██║ ██║ ",
|
|
15
11
|
" ╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ",
|
|
16
12
|
];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Divider line below the banner
|
|
15
|
+
*/
|
|
16
|
+
const dividerLine = "━".repeat(68);
|
|
17
|
+
/**
|
|
18
|
+
* Tagline describing Movehat
|
|
19
|
+
*/
|
|
20
|
+
const tagline = " A powerful testing framework for Move smart contracts";
|
|
21
|
+
/**
|
|
22
|
+
* Render the Movehat banner with gradient colors
|
|
23
|
+
* Uses the UI module's gradient system for consistency
|
|
24
|
+
*
|
|
25
|
+
* @returns Formatted banner string ready for console output
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const banner = renderMovehatBanner();
|
|
29
|
+
* console.log(banner);
|
|
30
|
+
*/
|
|
28
31
|
export const renderMovehatBanner = () => {
|
|
29
|
-
if (!
|
|
30
|
-
return bannerLines.join("\n")
|
|
32
|
+
if (!shouldUseColor()) {
|
|
33
|
+
return `${bannerLines.join("\n")}\n${dividerLine}\n${tagline}`;
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
// Apply Movehat brand gradient to each line with varying offsets
|
|
36
|
+
const coloredLines = bannerLines.map((line, idx) => applyGradient(line, gradients.movehat, idx * 2));
|
|
37
|
+
// Apply gradient to divider line
|
|
38
|
+
const coloredDivider = applyGradient(dividerLine, gradients.movehat, 0);
|
|
39
|
+
// Dim the tagline for subtle appearance
|
|
40
|
+
const coloredTagline = colors.dim(tagline);
|
|
41
|
+
return `${coloredLines.join("\n")}\n${coloredDivider}\n${coloredTagline}`;
|
|
34
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Print the Movehat banner to console
|
|
45
|
+
* Convenience function that renders and logs the banner
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* printMovehatBanner();
|
|
49
|
+
*/
|
|
35
50
|
export const printMovehatBanner = () => {
|
|
36
51
|
console.log(renderMovehatBanner());
|
|
37
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/helpers/banner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../src/helpers/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,iEAAiE;IACjE,iEAAiE;IACjE,iEAAiE;IACjE,iEAAiE;IACjE,iEAAiE;IACjE,iEAAiE;CAClE,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,OAAO,GAAG,yDAAyD,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAW,EAAE;IAC9C,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;QACtB,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,WAAW,KAAK,OAAO,EAAE,CAAC;IACjE,CAAC;IAED,iEAAiE;IACjE,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CACjD,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,CAChD,CAAC;IAEF,iCAAiC;IACjC,MAAM,cAAc,GAAG,aAAa,CAAC,WAAW,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAExE,wCAAwC;IACxC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAE3C,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,cAAc,KAAK,cAAc,EAAE,CAAC;AAC5E,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAS,EAAE;IAC3C,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Check if a newer version is available and notify the user
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* This function:
|
|
5
|
+
* - Runs synchronously using cached version data
|
|
6
|
+
* - Displays update notification immediately if cache indicates newer version
|
|
7
|
+
* - Asynchronously updates cache in background (non-blocking)
|
|
8
|
+
* - Respects 24-hour cache duration to avoid excessive network requests
|
|
9
|
+
*
|
|
10
|
+
* @param currentVersion - Currently installed version (e.g., '1.0.0')
|
|
11
|
+
* @param packageName - npm package name to check (e.g., 'movehat')
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* checkForUpdates('1.0.0', 'movehat');
|
|
4
15
|
*/
|
|
5
16
|
export declare function checkForUpdates(currentVersion: string, packageName: string): void;
|
|
6
17
|
//# sourceMappingURL=version-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-check.d.ts","sourceRoot":"","sources":["../../src/helpers/version-check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version-check.d.ts","sourceRoot":"","sources":["../../src/helpers/version-check.ts"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAyCjF"}
|
|
@@ -3,6 +3,7 @@ import { join } from "path";
|
|
|
3
3
|
import { homedir } from "os";
|
|
4
4
|
import { isNewerVersion } from "./semver-utils.js";
|
|
5
5
|
import { fetchLatestVersion } from "./npm-registry.js";
|
|
6
|
+
import { box, colors, formatCommand } from "../ui/index.js";
|
|
6
7
|
const CACHE_DURATION = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
|
|
7
8
|
const CACHE_DIR = join(homedir(), ".movehat");
|
|
8
9
|
const CACHE_FILE = join(CACHE_DIR, "version-cache.json");
|
|
@@ -41,7 +42,18 @@ function writeCache(latestVersion) {
|
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Check if a newer version is available and notify the user
|
|
44
|
-
*
|
|
45
|
+
*
|
|
46
|
+
* This function:
|
|
47
|
+
* - Runs synchronously using cached version data
|
|
48
|
+
* - Displays update notification immediately if cache indicates newer version
|
|
49
|
+
* - Asynchronously updates cache in background (non-blocking)
|
|
50
|
+
* - Respects 24-hour cache duration to avoid excessive network requests
|
|
51
|
+
*
|
|
52
|
+
* @param currentVersion - Currently installed version (e.g., '1.0.0')
|
|
53
|
+
* @param packageName - npm package name to check (e.g., 'movehat')
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* checkForUpdates('1.0.0', 'movehat');
|
|
45
57
|
*/
|
|
46
58
|
export function checkForUpdates(currentVersion, packageName) {
|
|
47
59
|
try {
|
|
@@ -53,12 +65,10 @@ export function checkForUpdates(currentVersion, packageName) {
|
|
|
53
65
|
}
|
|
54
66
|
// Display notification immediately if cache says there's an update
|
|
55
67
|
if (shouldNotify && cache) {
|
|
56
|
-
const updateMessage =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"└" + "─".repeat(60) + "┘\n";
|
|
61
|
-
console.error(updateMessage);
|
|
68
|
+
const updateMessage = box(`${colors.brandBright('Update Available!')}\n\n` +
|
|
69
|
+
`${currentVersion} ${colors.dim('→')} ${colors.success(cache.latestVersion)}\n\n` +
|
|
70
|
+
`${formatCommand('movehat update')}`, { borderColor: 'warning', padding: 1 });
|
|
71
|
+
console.error('\n' + updateMessage + '\n');
|
|
62
72
|
}
|
|
63
73
|
// Update cache in background if needed (doesn't block)
|
|
64
74
|
if (!cache || Date.now() - cache.lastChecked > CACHE_DURATION) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-check.js","sourceRoot":"","sources":["../../src/helpers/version-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"version-check.js","sourceRoot":"","sources":["../../src/helpers/version-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,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gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,kDAAkD;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RGB type for gradient functions
|
|
3
|
+
*/
|
|
4
|
+
export type Rgb = [number, number, number];
|
|
5
|
+
/**
|
|
6
|
+
* Detect if colors should be used
|
|
7
|
+
* Respects NO_COLOR env var and TTY detection
|
|
8
|
+
*/
|
|
9
|
+
export declare const shouldUseColor: () => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Semantic color palette
|
|
12
|
+
* Maps intent to colors consistently across the CLI
|
|
13
|
+
*/
|
|
14
|
+
export declare const colors: {
|
|
15
|
+
success: (str: string) => string;
|
|
16
|
+
error: (str: string) => string;
|
|
17
|
+
warning: (str: string) => string;
|
|
18
|
+
info: (str: string) => string;
|
|
19
|
+
primary: (str: string) => string;
|
|
20
|
+
secondary: (str: string) => string;
|
|
21
|
+
muted: (str: string) => string;
|
|
22
|
+
dim: (str: string) => string;
|
|
23
|
+
bold: (str: string) => string;
|
|
24
|
+
brand: (str: string) => string;
|
|
25
|
+
brandBright: (str: string) => string;
|
|
26
|
+
raw: import("picocolors/types.js").Colors & {
|
|
27
|
+
createColors: (enabled?: boolean) => import("picocolors/types.js").Colors;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Convert RGB to ANSI 24-bit color code
|
|
32
|
+
*
|
|
33
|
+
* @param r - Red value (0-255)
|
|
34
|
+
* @param g - Green value (0-255)
|
|
35
|
+
* @param b - Blue value (0-255)
|
|
36
|
+
* @returns ANSI escape code for RGB color
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const red = rgbToAnsi(255, 0, 0);
|
|
40
|
+
* console.log(`${red}This is red text\x1b[0m`);
|
|
41
|
+
*/
|
|
42
|
+
export declare const rgbToAnsi: (r: number, g: number, b: number) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Apply gradient to text using RGB palette
|
|
45
|
+
* Migrated from banner.ts for reuse across the application
|
|
46
|
+
*
|
|
47
|
+
* @param text - Text to colorize with gradient
|
|
48
|
+
* @param palette - Array of RGB color values
|
|
49
|
+
* @param offset - Starting offset in palette (useful for animation)
|
|
50
|
+
* @returns Colored text with gradient applied
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const gradient = applyGradient('MOVEHAT', gradients.movehat);
|
|
54
|
+
* console.log(gradient);
|
|
55
|
+
*/
|
|
56
|
+
export declare const applyGradient: (text: string, palette: Rgb[], offset?: number) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Preset gradient palettes for consistent branding
|
|
59
|
+
*/
|
|
60
|
+
export declare const gradients: {
|
|
61
|
+
/**
|
|
62
|
+
* Movehat brand gradient (warm yellow/amber)
|
|
63
|
+
* Used for the banner and brand-related UI elements
|
|
64
|
+
*/
|
|
65
|
+
movehat: Rgb[];
|
|
66
|
+
/**
|
|
67
|
+
* Success gradient (green tones)
|
|
68
|
+
* For positive feedback and success states
|
|
69
|
+
*/
|
|
70
|
+
success: Rgb[];
|
|
71
|
+
/**
|
|
72
|
+
* Error gradient (red tones)
|
|
73
|
+
* For errors and warnings
|
|
74
|
+
*/
|
|
75
|
+
error: Rgb[];
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/ui/colors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAO,OAEjC,CAAC;AAUF;;;GAGG;AACH,eAAO,MAAM,MAAM;mBARM,MAAM,KAAK,MAAM;iBAAjB,MAAM,KAAK,MAAM;mBAAjB,MAAM,KAAK,MAAM;gBAAjB,MAAM,KAAK,MAAM;mBAAjB,MAAM,KAAK,MAAM;qBAAjB,MAAM,KAAK,MAAM;iBAAjB,MAAM,KAAK,MAAM;eAAjB,MAAM,KAAK,MAAM;gBAAjB,MAAM,KAAK,MAAM;iBAAjB,MAAM,KAAK,MAAM;uBAAjB,MAAM,KAAK,MAAM;;8BAdtB,CAAC;;CA0CpB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAE3D,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,SAAS,GAAG,EAAE,EACd,SAAQ,MAAU,KACjB,MAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;;OAGG;aAOE,GAAG,EAAE;IAEV;;;OAGG;aAKE,GAAG,EAAE;IAEV;;;OAGG;WAKE,GAAG,EAAE;CACX,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
/**
|
|
3
|
+
* Detect if colors should be used
|
|
4
|
+
* Respects NO_COLOR env var and TTY detection
|
|
5
|
+
*/
|
|
6
|
+
export const shouldUseColor = () => {
|
|
7
|
+
return process.env.NO_COLOR === undefined && Boolean(process.stdout.isTTY);
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Conditional color wrapper
|
|
11
|
+
* Returns identity function if colors disabled
|
|
12
|
+
*/
|
|
13
|
+
const color = (fn) => {
|
|
14
|
+
return shouldUseColor() ? fn : (str) => str;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Semantic color palette
|
|
18
|
+
* Maps intent to colors consistently across the CLI
|
|
19
|
+
*/
|
|
20
|
+
export const colors = {
|
|
21
|
+
// Status colors
|
|
22
|
+
success: color(pc.green),
|
|
23
|
+
error: color(pc.red),
|
|
24
|
+
warning: color(pc.yellow),
|
|
25
|
+
info: color(pc.cyan),
|
|
26
|
+
// UI element colors
|
|
27
|
+
primary: color(pc.magenta),
|
|
28
|
+
secondary: color(pc.blue),
|
|
29
|
+
muted: color(pc.gray),
|
|
30
|
+
dim: color(pc.dim),
|
|
31
|
+
bold: color(pc.bold),
|
|
32
|
+
// Movehat brand colors (amber/yellow gradient)
|
|
33
|
+
brand: color(pc.yellow),
|
|
34
|
+
brandBright: color((str) => pc.yellow(pc.bold(str))),
|
|
35
|
+
// Direct access for advanced use
|
|
36
|
+
raw: shouldUseColor() ? pc : createNoopColors(),
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Convert RGB to ANSI 24-bit color code
|
|
40
|
+
*
|
|
41
|
+
* @param r - Red value (0-255)
|
|
42
|
+
* @param g - Green value (0-255)
|
|
43
|
+
* @param b - Blue value (0-255)
|
|
44
|
+
* @returns ANSI escape code for RGB color
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const red = rgbToAnsi(255, 0, 0);
|
|
48
|
+
* console.log(`${red}This is red text\x1b[0m`);
|
|
49
|
+
*/
|
|
50
|
+
export const rgbToAnsi = (r, g, b) => {
|
|
51
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Apply gradient to text using RGB palette
|
|
55
|
+
* Migrated from banner.ts for reuse across the application
|
|
56
|
+
*
|
|
57
|
+
* @param text - Text to colorize with gradient
|
|
58
|
+
* @param palette - Array of RGB color values
|
|
59
|
+
* @param offset - Starting offset in palette (useful for animation)
|
|
60
|
+
* @returns Colored text with gradient applied
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const gradient = applyGradient('MOVEHAT', gradients.movehat);
|
|
64
|
+
* console.log(gradient);
|
|
65
|
+
*/
|
|
66
|
+
export const applyGradient = (text, palette, offset = 0) => {
|
|
67
|
+
if (!shouldUseColor())
|
|
68
|
+
return text;
|
|
69
|
+
let result = '';
|
|
70
|
+
for (let i = 0; i < text.length; i++) {
|
|
71
|
+
const colorIndex = (i + offset) % palette.length;
|
|
72
|
+
const [r, g, b] = palette[colorIndex];
|
|
73
|
+
result += `${rgbToAnsi(r, g, b)}${text[i]}`;
|
|
74
|
+
}
|
|
75
|
+
return result + '\x1b[0m';
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Preset gradient palettes for consistent branding
|
|
79
|
+
*/
|
|
80
|
+
export const gradients = {
|
|
81
|
+
/**
|
|
82
|
+
* Movehat brand gradient (warm yellow/amber)
|
|
83
|
+
* Used for the banner and brand-related UI elements
|
|
84
|
+
*/
|
|
85
|
+
movehat: [
|
|
86
|
+
[255, 239, 150],
|
|
87
|
+
[255, 223, 88],
|
|
88
|
+
[255, 207, 64],
|
|
89
|
+
[255, 181, 45],
|
|
90
|
+
[255, 160, 30],
|
|
91
|
+
],
|
|
92
|
+
/**
|
|
93
|
+
* Success gradient (green tones)
|
|
94
|
+
* For positive feedback and success states
|
|
95
|
+
*/
|
|
96
|
+
success: [
|
|
97
|
+
[144, 238, 144],
|
|
98
|
+
[60, 179, 113],
|
|
99
|
+
[46, 139, 87],
|
|
100
|
+
],
|
|
101
|
+
/**
|
|
102
|
+
* Error gradient (red tones)
|
|
103
|
+
* For errors and warnings
|
|
104
|
+
*/
|
|
105
|
+
error: [
|
|
106
|
+
[255, 182, 193],
|
|
107
|
+
[220, 20, 60],
|
|
108
|
+
[178, 34, 34],
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* No-op color functions for when colors are disabled
|
|
113
|
+
* Uses a Proxy to return identity function for any property access
|
|
114
|
+
*/
|
|
115
|
+
function createNoopColors() {
|
|
116
|
+
const noop = (str) => str;
|
|
117
|
+
return new Proxy({}, {
|
|
118
|
+
get: () => noop,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
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