@bazilio-san/glm-cc 1.0.1
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/LICENSE +21 -0
- package/README.md +47 -0
- package/_tmp/glm.ps1 +12 -0
- package/bin/glm.js +152 -0
- package/package-2.json +61 -0
- package/package.json +39 -0
- package/scripts/pre-commit +58 -0
- package/scripts/publish.js +86 -0
- package/scripts/remove-nul.js +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Michael Makarov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @bazilio-san/glm-cc
|
|
2
|
+
|
|
3
|
+
CLI tool for running Claude with custom GLM model configuration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @bazilio-san/glm-cc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Start claude with your configuration
|
|
14
|
+
```bash
|
|
15
|
+
glm
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Interactive configuration
|
|
19
|
+
```bash
|
|
20
|
+
glm -c
|
|
21
|
+
# or
|
|
22
|
+
glm --config
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Show help and current settings
|
|
26
|
+
```bash
|
|
27
|
+
glm -h
|
|
28
|
+
# or
|
|
29
|
+
glm --help
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
The tool stores configuration in `~/.glm-claude-code.json`.
|
|
35
|
+
|
|
36
|
+
Supported settings:
|
|
37
|
+
- `ANTHROPIC_BASE_URL` — API endpoint (default: `https://api.z.ai/api/anthropic`)
|
|
38
|
+
- `ANTHROPIC_AUTH_TOKEN` — primary auth token
|
|
39
|
+
- `ANTHROPIC_DEFAULT_HAIKU_MODEL` — default Haiku model (default: `glm-4.5-air`)
|
|
40
|
+
- `ANTHROPIC_DEFAULT_SONNET_MODEL` — default Sonnet model (default: `glm-5.1`)
|
|
41
|
+
- `ANTHROPIC_DEFAULT_OPUS_MODEL` — default Opus model (default: `glm-5.1`)
|
|
42
|
+
|
|
43
|
+
If any setting is missing, the tool will automatically prompt for it on first run.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
package/_tmp/glm.ps1
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Set environment variables for current PowerShell session
|
|
2
|
+
$env:ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic"
|
|
3
|
+
# Макаров
|
|
4
|
+
$env:ANTHROPIC_AUTH_TOKEN = "76e74fbef042406eb6cdc9134f7e817a.NsdiQkKuihWd2yfp"
|
|
5
|
+
# Уклеин
|
|
6
|
+
$env:ANTHROPIC_AUTH_TOKEN_ = "9dbf5f5f27f44505920c03c8aafd88d1.riY7D9a3pMbQXmkn"
|
|
7
|
+
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "glm-4.5-air"
|
|
8
|
+
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "glm-4.6"
|
|
9
|
+
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "glm-4.6"
|
|
10
|
+
|
|
11
|
+
# Launch claude program (if installed and available in PATH)
|
|
12
|
+
claude
|
package/bin/glm.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const readline = require('readline');
|
|
9
|
+
const { spawn } = require('child_process');
|
|
10
|
+
|
|
11
|
+
const CONFIG_FILE = path.join(os.homedir(), '.glm-claude-code.json');
|
|
12
|
+
|
|
13
|
+
const CONFIG_FIELDS = [
|
|
14
|
+
{
|
|
15
|
+
key: 'ANTHROPIC_BASE_URL',
|
|
16
|
+
label: 'Anthropic Base URL',
|
|
17
|
+
defaultValue: 'https://api.z.ai/api/anthropic',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: 'ANTHROPIC_AUTH_TOKEN',
|
|
21
|
+
label: 'Anthropic Auth Token (primary)',
|
|
22
|
+
defaultValue: '',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
key: 'ANTHROPIC_DEFAULT_HAIKU_MODEL',
|
|
26
|
+
label: 'Default Haiku model',
|
|
27
|
+
defaultValue: 'glm-4.5-air',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: 'ANTHROPIC_DEFAULT_SONNET_MODEL',
|
|
31
|
+
label: 'Default Sonnet model',
|
|
32
|
+
defaultValue: 'glm-5.1',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: 'ANTHROPIC_DEFAULT_OPUS_MODEL',
|
|
36
|
+
label: 'Default Opus model',
|
|
37
|
+
defaultValue: 'glm-5.1',
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
function loadConfig() {
|
|
42
|
+
if (!fs.existsSync(CONFIG_FILE)) return {};
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
45
|
+
} catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function saveConfig(config) {
|
|
51
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf8');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function ask(rl, question) {
|
|
55
|
+
return new Promise(resolve => rl.question(question, resolve));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function runConfig(fields) {
|
|
59
|
+
const config = loadConfig();
|
|
60
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
61
|
+
|
|
62
|
+
console.log('\nConfiguration (press Enter to keep current value):\n');
|
|
63
|
+
|
|
64
|
+
for (const field of fields) {
|
|
65
|
+
const current = config[field.key] !== undefined && config[field.key] !== ''
|
|
66
|
+
? config[field.key]
|
|
67
|
+
: field.defaultValue;
|
|
68
|
+
const hint = current ? ` [${current}]` : '';
|
|
69
|
+
const answer = await ask(rl, `${field.label}${hint}: `);
|
|
70
|
+
config[field.key] = answer.trim() !== '' ? answer.trim() : current;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
rl.close();
|
|
74
|
+
saveConfig(config);
|
|
75
|
+
console.log(`\nConfig saved: ${CONFIG_FILE}\n`);
|
|
76
|
+
return config;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function showHelp(config) {
|
|
80
|
+
const lines = [
|
|
81
|
+
'',
|
|
82
|
+
'Usage: glm [options]',
|
|
83
|
+
'',
|
|
84
|
+
'Options:',
|
|
85
|
+
' -c, --config Interactive configuration',
|
|
86
|
+
' -h, --help Show this help',
|
|
87
|
+
'',
|
|
88
|
+
'Without options: applies config to environment and launches claude.',
|
|
89
|
+
'',
|
|
90
|
+
`Config file: ${CONFIG_FILE}`,
|
|
91
|
+
'',
|
|
92
|
+
'Current settings:',
|
|
93
|
+
];
|
|
94
|
+
for (const field of CONFIG_FIELDS) {
|
|
95
|
+
const val = config[field.key] !== undefined && config[field.key] !== ''
|
|
96
|
+
? config[field.key]
|
|
97
|
+
: '(not set)';
|
|
98
|
+
lines.push(` ${field.key} = ${val}`);
|
|
99
|
+
}
|
|
100
|
+
lines.push('');
|
|
101
|
+
console.log(lines.join('\n'));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function launchClaude(config) {
|
|
105
|
+
const env = { ...process.env };
|
|
106
|
+
for (const field of CONFIG_FIELDS) {
|
|
107
|
+
if (config[field.key]) {
|
|
108
|
+
env[field.key] = config[field.key];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const proc = spawn('claude', [], {
|
|
112
|
+
env,
|
|
113
|
+
stdio: 'inherit',
|
|
114
|
+
shell: process.platform === 'win32',
|
|
115
|
+
});
|
|
116
|
+
proc.on('exit', code => process.exit(code ?? 0));
|
|
117
|
+
proc.on('error', err => {
|
|
118
|
+
console.error(`Failed to launch claude: ${err.message}`);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function main() {
|
|
124
|
+
const args = process.argv.slice(2);
|
|
125
|
+
|
|
126
|
+
if (args.includes('-h') || args.includes('--help')) {
|
|
127
|
+
showHelp(loadConfig());
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (args.includes('-c') || args.includes('--config')) {
|
|
132
|
+
await runConfig(CONFIG_FIELDS);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let config = loadConfig();
|
|
137
|
+
|
|
138
|
+
const missingFields = CONFIG_FIELDS.filter(f => !config[f.key]);
|
|
139
|
+
|
|
140
|
+
if (missingFields.length > 0) {
|
|
141
|
+
console.log('Some settings are missing. Please fill them in:\n');
|
|
142
|
+
config = await runConfig(missingFields);
|
|
143
|
+
config = loadConfig();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
launchClaude(config);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
main().catch(err => {
|
|
150
|
+
console.error(err.message);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
});
|
package/package-2.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-notification-plugin",
|
|
3
|
+
"productName": "claude-notification-plugin",
|
|
4
|
+
"version": "1.1.76",
|
|
5
|
+
"description": "Claude Code task-completion notifications: Telegram, desktop notifications (Windows/macOS/Linux), sound, and voice",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18.0.0"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
".claude-plugin/",
|
|
12
|
+
"bin/",
|
|
13
|
+
"claude_img/claude.png",
|
|
14
|
+
"hooks/",
|
|
15
|
+
"listener/",
|
|
16
|
+
"notifier/",
|
|
17
|
+
"commit-sha",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"bin": {
|
|
22
|
+
"claude-notify": "bin/cli.js"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"prepack": "git rev-parse HEAD > commit-sha",
|
|
26
|
+
"postinstall": "node bin/install.js",
|
|
27
|
+
"lint": "eslint .",
|
|
28
|
+
"lint:fix": "eslint --fix ."
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"claude",
|
|
32
|
+
"claude-code",
|
|
33
|
+
"notifications",
|
|
34
|
+
"telegram",
|
|
35
|
+
"hooks",
|
|
36
|
+
"macos",
|
|
37
|
+
"linux",
|
|
38
|
+
"cross-platform"
|
|
39
|
+
],
|
|
40
|
+
"author": {
|
|
41
|
+
"name": "Viacheslav Makarov",
|
|
42
|
+
"email": "npmjs@bazilio.ru"
|
|
43
|
+
},
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/Bazilio-san/claude-notification-plugin.git"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/Bazilio-san/claude-notification-plugin#readme",
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"node-notifier": "^10.0.1",
|
|
55
|
+
"node-pty": "^1.1.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"eslint-plugin-import": "^2.31.0",
|
|
59
|
+
"eslint-plugin-unused-imports": "^4.4.1"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bazilio-san/glm-cc",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "CLI tool for running claude with custom GLM configuration",
|
|
5
|
+
"main": "bin/glm.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"glm": "./bin/glm.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"claude",
|
|
14
|
+
"cli",
|
|
15
|
+
"anthropic",
|
|
16
|
+
"glm"
|
|
17
|
+
],
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Viacheslav Makarov",
|
|
20
|
+
"email": "npmjs@bazilio.ru"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/Bazilio-san/glm-cc.git"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/Bazilio-san/glm-cc#readme",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
|
+
},
|
|
34
|
+
"os": [
|
|
35
|
+
"win32",
|
|
36
|
+
"darwin",
|
|
37
|
+
"linux"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
#=============== Version update before commit: minor + 1 ==========================
|
|
4
|
+
|
|
5
|
+
#File: .git/hooks/pre-commit
|
|
6
|
+
# Version 2020-08-22
|
|
7
|
+
|
|
8
|
+
c='\033[0;35m'
|
|
9
|
+
y='\033[0;33m'
|
|
10
|
+
c0='\033[0;0m'
|
|
11
|
+
g='\033[0;32m'
|
|
12
|
+
set -e
|
|
13
|
+
echo -e "$c**** [pre-commit hook] ****$c0"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
update_version(){
|
|
17
|
+
old_version=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
|
|
18
|
+
echo -e "$c**** Old version is $g$old_version$c ****$c0"
|
|
19
|
+
version_split=( ${old_version//./ } )
|
|
20
|
+
major=${version_split[0]:-0}
|
|
21
|
+
minor=${version_split[1]:-0}
|
|
22
|
+
patch=${version_split[2]:-0}
|
|
23
|
+
let "patch=patch+1"
|
|
24
|
+
new_version="${major}.${minor}.${patch}"
|
|
25
|
+
|
|
26
|
+
repo=`cat package.json | grep name | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
|
|
27
|
+
echo -e "$c**** Bumping version of $g$repo$c: $y$old_version$c -> $g$new_version$c ****$c0"
|
|
28
|
+
sed -i -e "0,/$old_version/s/$old_version/$new_version/" package.json
|
|
29
|
+
echo -e "$g"
|
|
30
|
+
npm version 2>&1 | head -2 | tail -1
|
|
31
|
+
echo -e "$c0"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
branch_name=$(git symbolic-ref --short HEAD)
|
|
35
|
+
retcode=$?
|
|
36
|
+
|
|
37
|
+
if [[ $retcode -ne 0 ]] ; then
|
|
38
|
+
echo -e "$y**** Version will not be bumped since retcode is not equals 0 ****$c0"
|
|
39
|
+
exit 0
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
if [[ $branch_name == *"_nap" ]] ; then
|
|
43
|
+
echo -e "$y**** Version will not be bumped since branch name ends with '_nap'. ****$c0"
|
|
44
|
+
exit 0
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
if [[ $branch_name == *"_local" ]] ; then
|
|
48
|
+
echo -e "$y**** Version will not be bumped since branch name ends with '_local'. ****$c0"
|
|
49
|
+
exit 0
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
if [[ "$DONT_BUMP_VERSION" -eq "1" ]] ; then
|
|
53
|
+
echo -e "$y**** Version will not be bumped since variable DONT_BUMP_VERSION is set. ****$c0"
|
|
54
|
+
exit 0
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
update_version
|
|
58
|
+
git add package.json
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const projectRoot = resolve(__dirname, '..');
|
|
10
|
+
|
|
11
|
+
const c = '\x1b[35m';
|
|
12
|
+
const y = '\x1b[33m';
|
|
13
|
+
const r = '\x1b[31m';
|
|
14
|
+
const g = '\x1b[32m';
|
|
15
|
+
const c0 = '\x1b[0m';
|
|
16
|
+
|
|
17
|
+
function log(color, msg) {
|
|
18
|
+
process.stdout.write(`${color}${msg}${c0}\n`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function run(cmd, opts = {}) {
|
|
22
|
+
try {
|
|
23
|
+
const result = execSync(cmd, { encoding: 'utf-8', stdio: opts.stdio || 'pipe', cwd: opts.cwd || projectRoot });
|
|
24
|
+
return result ? result.trim() : '';
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (opts.ignoreError) return '';
|
|
27
|
+
log(r, `**** ERROR running: ${cmd} ****`);
|
|
28
|
+
log(r, e.stderr || e.message);
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function fail(msg) {
|
|
34
|
+
log(r, msg);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function readJson(filePath) {
|
|
39
|
+
return JSON.parse(readFileSync(filePath, 'utf-8'));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function bumpPatch(version) {
|
|
43
|
+
const [major, minor, patch] = version.split('.').map(Number);
|
|
44
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function setJsonVersion(filePath, newVer) {
|
|
48
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
49
|
+
writeFileSync(filePath, content.replace(/("version"\s*:\s*")[\d.]+(")/, `$1${newVer}$2`), 'utf-8');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ── Main ──
|
|
53
|
+
|
|
54
|
+
const expectedBranch = 'master';
|
|
55
|
+
|
|
56
|
+
const branch = run('git symbolic-ref --short HEAD');
|
|
57
|
+
if (branch !== expectedBranch) {
|
|
58
|
+
fail(`**** git branch should be ${expectedBranch}, current: ${branch} ****`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 1. Bump version
|
|
62
|
+
const pkgPath = join(projectRoot, 'package.json');
|
|
63
|
+
const pkg = readJson(pkgPath);
|
|
64
|
+
const oldVersion = pkg.version;
|
|
65
|
+
const newVersion = bumpPatch(oldVersion);
|
|
66
|
+
const repoName = pkg.name;
|
|
67
|
+
|
|
68
|
+
log(c, `**** Bumping ${repoName}: ${oldVersion} -> ${newVersion} ****`);
|
|
69
|
+
setJsonVersion(pkgPath, newVersion);
|
|
70
|
+
|
|
71
|
+
// 2. Commit & push
|
|
72
|
+
run('git add -A');
|
|
73
|
+
run(`git commit --no-verify -m "${newVersion}"`);
|
|
74
|
+
run(`git push origin refs/heads/${expectedBranch}:${expectedBranch}`);
|
|
75
|
+
log(g, '**** Pushed commit ****');
|
|
76
|
+
|
|
77
|
+
// 3. Tag & push tag
|
|
78
|
+
run(`git tag "v${newVersion}"`);
|
|
79
|
+
run(`git push origin "v${newVersion}"`);
|
|
80
|
+
log(g, `**** Tagged v${newVersion} ****`);
|
|
81
|
+
|
|
82
|
+
// 4. npm publish
|
|
83
|
+
log(c, '**** Publishing to npm ****');
|
|
84
|
+
run('npm publish', { stdio: 'inherit' });
|
|
85
|
+
|
|
86
|
+
log(g, `\n**** Done: ${repoName}@${newVersion} ****`);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Script to remove 'nul' file that accidentally gets created on Windows
|
|
5
|
+
* This file is created when using 2>nul redirection in Windows commands
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
import { dirname } from 'path';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
|
|
16
|
+
// Get project root (parent of scripts directory)
|
|
17
|
+
const projectRoot = path.resolve(__dirname, '..');
|
|
18
|
+
|
|
19
|
+
// File to remove
|
|
20
|
+
const nulFile = path.join(projectRoot, 'nul');
|
|
21
|
+
|
|
22
|
+
// Check if file exists and remove it
|
|
23
|
+
if (fs.existsSync(nulFile)) {
|
|
24
|
+
try {
|
|
25
|
+
fs.unlinkSync(nulFile);
|
|
26
|
+
console.log('✅ Removed "nul" file from project root');
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error('❌ Error removing "nul" file:', error.message);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
console.log('ℹ️ No "nul" file found in project root');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Also check for other common accidental files on Windows
|
|
36
|
+
const accidentalFiles = ['nul', 'NUL', 'con', 'CON', 'aux', 'AUX', 'prn', 'PRN'];
|
|
37
|
+
|
|
38
|
+
accidentalFiles.forEach(fileName => {
|
|
39
|
+
const filePath = path.join(projectRoot, fileName);
|
|
40
|
+
if (fs.existsSync(filePath)) {
|
|
41
|
+
try {
|
|
42
|
+
const stats = fs.statSync(filePath);
|
|
43
|
+
if (stats.isFile()) {
|
|
44
|
+
fs.unlinkSync(filePath);
|
|
45
|
+
console.log(`✅ Removed "${fileName}" file from project root`);
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(`⚠️ Could not remove "${fileName}":`, error.message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
console.log('🎯 Cleanup completed');
|