claude-switch-profile 1.4.3 → 1.4.4
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.
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/scripts/release.js
CHANGED
|
@@ -14,9 +14,41 @@ import { fileURLToPath } from 'node:url';
|
|
|
14
14
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
15
|
const ROOT = join(__dirname, '..');
|
|
16
16
|
const PKG_PATH = join(ROOT, 'package.json');
|
|
17
|
+
const TEST_SUMMARY_PATTERN = /^# (tests|suites|pass|fail|cancelled|skipped|todo|duration_ms)\b/;
|
|
18
|
+
|
|
19
|
+
const run = (cmd, options = {}) => {
|
|
20
|
+
return execSync(cmd, {
|
|
21
|
+
cwd: ROOT,
|
|
22
|
+
encoding: 'utf-8',
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
...options,
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const runQuiet = (cmd) => run(cmd, { stdio: 'pipe' }).trim();
|
|
29
|
+
|
|
30
|
+
const fail = (message, details = '') => {
|
|
31
|
+
console.error(`✗ ${message}`);
|
|
32
|
+
if (details) console.error(details);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
};
|
|
17
35
|
|
|
18
|
-
const
|
|
19
|
-
const
|
|
36
|
+
const formatCommandOutput = (error) => {
|
|
37
|
+
const stdout = error?.stdout?.toString?.() || '';
|
|
38
|
+
const stderr = error?.stderr?.toString?.() || '';
|
|
39
|
+
return [stdout.trim(), stderr.trim()].filter(Boolean).join('\n');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const printTestSummary = (output) => {
|
|
43
|
+
const summary = output
|
|
44
|
+
.split(/\r?\n/)
|
|
45
|
+
.map((line) => line.trim())
|
|
46
|
+
.filter((line) => TEST_SUMMARY_PATTERN.test(line))
|
|
47
|
+
.map((line) => line.replace(/^#\s*/, ''))
|
|
48
|
+
.join('\n');
|
|
49
|
+
|
|
50
|
+
if (summary) console.log(summary);
|
|
51
|
+
};
|
|
20
52
|
|
|
21
53
|
// --- Helpers ---
|
|
22
54
|
|
|
@@ -33,17 +65,14 @@ const bumpVersion = (current, type) => {
|
|
|
33
65
|
const checkCleanWorkingTree = () => {
|
|
34
66
|
const status = runQuiet('git status --porcelain');
|
|
35
67
|
if (status) {
|
|
36
|
-
|
|
37
|
-
console.error(status);
|
|
38
|
-
process.exit(1);
|
|
68
|
+
fail('Working tree is not clean. Commit or stash changes first.', status);
|
|
39
69
|
}
|
|
40
70
|
};
|
|
41
71
|
|
|
42
72
|
const checkOnMainBranch = () => {
|
|
43
73
|
const branch = runQuiet('git branch --show-current');
|
|
44
74
|
if (branch !== 'main' && branch !== 'master') {
|
|
45
|
-
|
|
46
|
-
process.exit(1);
|
|
75
|
+
fail(`Must be on main/master branch. Current: ${branch}`);
|
|
47
76
|
}
|
|
48
77
|
};
|
|
49
78
|
|
|
@@ -51,8 +80,20 @@ const checkNpmAuth = () => {
|
|
|
51
80
|
try {
|
|
52
81
|
runQuiet('npm whoami');
|
|
53
82
|
} catch {
|
|
54
|
-
|
|
55
|
-
|
|
83
|
+
fail('Not logged in to npm. Run "npm login" first.');
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const runTests = () => {
|
|
88
|
+
console.log('Running tests...');
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const output = run('npm test', { stdio: 'pipe' });
|
|
92
|
+
printTestSummary(output);
|
|
93
|
+
console.log('✓ Tests passed\n');
|
|
94
|
+
} catch (error) {
|
|
95
|
+
const output = formatCommandOutput(error);
|
|
96
|
+
fail('Tests failed. Release aborted.', output);
|
|
56
97
|
}
|
|
57
98
|
};
|
|
58
99
|
|
|
@@ -61,50 +102,45 @@ const checkNpmAuth = () => {
|
|
|
61
102
|
const main = () => {
|
|
62
103
|
const type = process.argv[2] || 'patch';
|
|
63
104
|
if (!['patch', 'minor', 'major'].includes(type)) {
|
|
64
|
-
|
|
65
|
-
process.exit(1);
|
|
105
|
+
fail(`Invalid bump type: "${type}". Use patch, minor, or major.`);
|
|
66
106
|
}
|
|
67
107
|
|
|
68
|
-
// Pre-flight checks
|
|
69
108
|
console.log('Pre-flight checks...');
|
|
70
109
|
checkCleanWorkingTree();
|
|
71
110
|
checkOnMainBranch();
|
|
72
111
|
checkNpmAuth();
|
|
73
112
|
console.log('✓ All checks passed\n');
|
|
74
113
|
|
|
75
|
-
// Read current version
|
|
76
114
|
const pkg = JSON.parse(readFileSync(PKG_PATH, 'utf-8'));
|
|
77
115
|
const oldVersion = pkg.version;
|
|
78
116
|
const newVersion = bumpVersion(oldVersion, type);
|
|
79
117
|
|
|
80
118
|
console.log(`Bumping version: ${oldVersion} → ${newVersion} (${type})\n`);
|
|
81
119
|
|
|
82
|
-
|
|
83
|
-
console.log('Running tests...');
|
|
84
|
-
run('npm test');
|
|
85
|
-
console.log('✓ Tests passed\n');
|
|
120
|
+
runTests();
|
|
86
121
|
|
|
87
|
-
// Update package.json version
|
|
88
122
|
pkg.version = newVersion;
|
|
89
123
|
writeFileSync(PKG_PATH, JSON.stringify(pkg, null, 2) + '\n');
|
|
90
124
|
console.log(`✓ Updated package.json to ${newVersion}`);
|
|
91
125
|
|
|
92
|
-
// Git commit + tag
|
|
93
126
|
run('git add package.json');
|
|
94
127
|
run(`git commit -m "chore(release): v${newVersion}"`);
|
|
95
128
|
run(`git tag -a v${newVersion} -m "v${newVersion}"`);
|
|
96
129
|
console.log(`✓ Created tag v${newVersion}`);
|
|
97
130
|
|
|
98
|
-
// Publish to npm
|
|
99
131
|
console.log('\nPublishing to npm...');
|
|
100
132
|
run('npm publish');
|
|
101
133
|
console.log(`✓ Published claude-switch-profile@${newVersion}`);
|
|
102
134
|
|
|
103
|
-
|
|
104
|
-
run('git push
|
|
105
|
-
console.log(
|
|
135
|
+
run('git push');
|
|
136
|
+
run('git push --tags');
|
|
137
|
+
console.log('✓ Pushed to remote with tags\n');
|
|
106
138
|
|
|
107
139
|
console.log(`🎉 Released v${newVersion} successfully!`);
|
|
108
140
|
};
|
|
109
141
|
|
|
110
|
-
|
|
142
|
+
try {
|
|
143
|
+
main();
|
|
144
|
+
} catch (error) {
|
|
145
|
+
fail('Release failed.', formatCommandOutput(error));
|
|
146
|
+
}
|