@meltstudio/meltctl 1.6.0 → 2.0.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/README.md CHANGED
@@ -5,7 +5,7 @@ CLI tool for Melt's AI-assisted development workflow. Initialize projects with C
5
5
  ## 🚀 Quick Start
6
6
 
7
7
  ```bash
8
- # Install globally
8
+ # Install globally via npm
9
9
  npm install -g @meltstudio/meltctl
10
10
 
11
11
  # Initialize your project
@@ -58,13 +58,17 @@ This command:
58
58
  - Supports both shell (sh/bash/zsh) and PowerShell environments
59
59
  - Uses fs-extra for robust file operations and template copying
60
60
 
61
- ### Update Project (Coming Soon)
61
+ ### Update Project
62
62
 
63
63
  ```bash
64
64
  meltctl project update
65
65
  ```
66
66
 
67
- Updates your project templates to the latest version.
67
+ Updates your project templates to the latest version. This command:
68
+ - Checks for CLI package updates and prompts to update if available
69
+ - Updates .cursor/commands/ with the latest command templates
70
+ - Verifies .melt/ workspace migration status
71
+ - Handles version compatibility automatically
68
72
 
69
73
  ## 🛠️ Requirements
70
74
 
@@ -1,15 +1,151 @@
1
- import { intro, outro } from '@clack/prompts';
1
+ import { intro, outro, spinner, confirm } from '@clack/prompts';
2
2
  import chalk from 'chalk';
3
+ import { execSync } from 'child_process';
4
+ import fs from 'fs-extra';
5
+ import path from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ async function getCurrentCliVersion() {
9
+ const packagePath = path.join(__dirname, '../../../package.json');
10
+ const packageJson = await fs.readJson(packagePath);
11
+ return packageJson.version;
12
+ }
13
+ async function getLatestCliVersion() {
14
+ try {
15
+ const result = execSync('npm view @meltstudio/meltctl version --json', {
16
+ encoding: 'utf-8',
17
+ stdio: 'pipe',
18
+ });
19
+ return JSON.parse(result.trim());
20
+ }
21
+ catch (error) {
22
+ console.error(chalk.red('Failed to check latest version from npm registry'));
23
+ throw error;
24
+ }
25
+ }
26
+ function compareVersions(current, latest) {
27
+ // Parse semver strings, handling pre-release tags
28
+ const parseVersion = (version) => {
29
+ const [base, prerelease] = version.split('-');
30
+ const parts = (base || '').split('.').map(Number);
31
+ return {
32
+ major: parts[0] || 0,
33
+ minor: parts[1] || 0,
34
+ patch: parts[2] || 0,
35
+ prerelease: prerelease || null,
36
+ };
37
+ };
38
+ const currentVer = parseVersion(current);
39
+ const latestVer = parseVersion(latest);
40
+ // Compare major.minor.patch first
41
+ if (latestVer.major !== currentVer.major) {
42
+ return latestVer.major > currentVer.major;
43
+ }
44
+ if (latestVer.minor !== currentVer.minor) {
45
+ return latestVer.minor > currentVer.minor;
46
+ }
47
+ if (latestVer.patch !== currentVer.patch) {
48
+ return latestVer.patch > currentVer.patch;
49
+ }
50
+ // If base versions are equal, handle pre-release comparison
51
+ // No pre-release (stable) > pre-release
52
+ if (!latestVer.prerelease && currentVer.prerelease)
53
+ return true;
54
+ if (latestVer.prerelease && !currentVer.prerelease)
55
+ return false;
56
+ // Both have pre-release or both are stable
57
+ if (latestVer.prerelease && currentVer.prerelease) {
58
+ return latestVer.prerelease > currentVer.prerelease;
59
+ }
60
+ return false; // Versions are equal
61
+ }
62
+ async function updateCliPackage() {
63
+ const s = spinner();
64
+ s.start('Updating @meltstudio/meltctl package...');
65
+ try {
66
+ execSync('npm install -g @meltstudio/meltctl@latest', {
67
+ stdio: 'pipe',
68
+ });
69
+ s.stop('CLI package updated successfully!');
70
+ }
71
+ catch (error) {
72
+ s.stop('Failed to update CLI package');
73
+ throw error;
74
+ }
75
+ }
76
+ async function updateCursorCommands() {
77
+ const s = spinner();
78
+ s.start('Updating .cursor/commands/ with latest prompts...');
79
+ try {
80
+ const templatesDir = path.join(__dirname, '../../../templates/cursor-commands');
81
+ const targetDir = path.join(process.cwd(), '.cursor', 'commands');
82
+ if (await fs.pathExists(templatesDir)) {
83
+ await fs.ensureDir(targetDir);
84
+ await fs.copy(templatesDir, targetDir, { overwrite: true });
85
+ s.stop('Cursor commands updated successfully!');
86
+ }
87
+ else {
88
+ s.stop('No cursor templates found to update');
89
+ }
90
+ }
91
+ catch (error) {
92
+ s.stop('Failed to update cursor commands');
93
+ throw error;
94
+ }
95
+ }
96
+ async function migrateMeltWorkspace() {
97
+ const s = spinner();
98
+ s.start('Checking .melt/ workspace migration...');
99
+ try {
100
+ const meltDir = path.join(process.cwd(), '.melt');
101
+ if (await fs.pathExists(meltDir)) {
102
+ s.stop('Melt workspace found - no migration needed');
103
+ }
104
+ else {
105
+ s.stop('No melt workspace found - consider running meltctl project init');
106
+ }
107
+ }
108
+ catch (error) {
109
+ s.stop('Failed to check melt workspace');
110
+ throw error;
111
+ }
112
+ }
3
113
  export async function updateCommand() {
4
114
  intro(chalk.blue('🔄 Melt Project - Update'));
5
- console.log(chalk.yellow('⏳ Coming soon!'));
6
- console.log();
7
- console.log('This command will:');
8
- console.log('• Check for CLI package updates');
9
- console.log('• Update .cursor/commands/ with latest prompts');
10
- console.log('• Migrate .melt/ workspace if needed');
11
- console.log('• Handle version compatibility');
12
- console.log();
13
- console.log(chalk.gray('Usage: meltctl project update'));
14
- outro(chalk.green('Stay tuned for the full implementation!'));
115
+ try {
116
+ const currentVersion = await getCurrentCliVersion();
117
+ const latestVersion = await getLatestCliVersion();
118
+ console.log(chalk.gray(`Current CLI version: ${currentVersion}`));
119
+ console.log(chalk.gray(`Latest CLI version: ${latestVersion}`));
120
+ console.log();
121
+ if (compareVersions(currentVersion, latestVersion)) {
122
+ console.log(chalk.yellow(`📦 New version available: ${latestVersion}`));
123
+ const shouldUpdate = await confirm({
124
+ message: 'Would you like to update the CLI package?',
125
+ });
126
+ if (shouldUpdate) {
127
+ await updateCliPackage();
128
+ console.log();
129
+ }
130
+ }
131
+ else {
132
+ console.log(chalk.green('✅ CLI package is up to date'));
133
+ console.log();
134
+ }
135
+ const shouldUpdateCommands = await confirm({
136
+ message: 'Would you like to update .cursor/commands/ with latest prompts?',
137
+ });
138
+ if (shouldUpdateCommands) {
139
+ await updateCursorCommands();
140
+ console.log();
141
+ }
142
+ await migrateMeltWorkspace();
143
+ outro(chalk.green('✅ Update process completed!'));
144
+ }
145
+ catch (error) {
146
+ console.error();
147
+ console.error(chalk.red('❌ Update failed:'), error instanceof Error ? error.message : String(error));
148
+ outro(chalk.red('Update process failed'));
149
+ process.exit(1);
150
+ }
15
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltstudio/meltctl",
3
- "version": "1.6.0",
3
+ "version": "2.0.2",
4
4
  "description": "CLI tool for Melt development process automation - initialize and update project configurations",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -17,6 +17,11 @@
17
17
  "registry": "https://registry.npmjs.org/",
18
18
  "access": "public"
19
19
  },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/MeltStudio/melt-development-prompts.git",
23
+ "directory": "packages/cli"
24
+ },
20
25
  "scripts": {
21
26
  "build": "tsc",
22
27
  "dev": "tsx src/index.ts",