stigmergy 1.1.6 → 1.2.6
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 +18 -18
- package/README.md +28 -223
- package/STIGMERGY.md +61 -61
- package/docs/PROJECT_CONSTITUTION.md +433 -433
- package/docs/PROJECT_STRUCTURE_CURRENT.md +80 -80
- package/examples/calculator-example.js +72 -72
- package/examples/cline_usage_examples.md +364 -364
- package/examples/encryption-example.js +67 -67
- package/examples/json-parser-example.js +120 -120
- package/examples/json-validation-example.js +64 -64
- package/examples/rest-client-example.js +52 -52
- package/examples/rest_client_example.js +54 -54
- package/package.json +15 -7
- package/scripts/build.js +74 -74
- package/scripts/post-deployment-config.js +296 -296
- package/scripts/preinstall-check.js +173 -111
- package/scripts/publish.js +58 -268
- package/scripts/run-layered-tests.js +247 -0
- package/scripts/safe-install.js +139 -139
- package/scripts/simple-publish.js +57 -59
- package/src/adapters/claude/install_claude_integration.js +292 -0
- package/src/adapters/codebuddy/install_codebuddy_integration.js +349 -0
- package/src/adapters/codex/install_codex_integration.js +395 -0
- package/src/adapters/copilot/install_copilot_integration.js +716 -0
- package/src/adapters/gemini/install_gemini_integration.js +304 -0
- package/src/adapters/iflow/install_iflow_integration.js +304 -0
- package/src/adapters/qoder/install_qoder_integration.js +1090 -0
- package/src/adapters/qwen/install_qwen_integration.js +285 -0
- package/src/auth.js +173 -173
- package/src/auth_command.js +208 -208
- package/src/calculator.js +313 -313
- package/src/cli/router.js +792 -67
- package/src/core/cache_cleaner.js +767 -0
- package/src/core/cli_help_analyzer.js +680 -674
- package/src/core/cli_parameter_handler.js +132 -127
- package/src/core/cli_tools.js +89 -89
- package/src/core/coordination/index.js +16 -16
- package/src/core/coordination/nodejs/AdapterManager.js +102 -89
- package/src/core/coordination/nodejs/CLCommunication.js +132 -124
- package/src/core/coordination/nodejs/CLIIntegrationManager.js +272 -236
- package/src/core/coordination/nodejs/HealthChecker.js +76 -77
- package/src/core/coordination/nodejs/HookDeploymentManager.js +263 -190
- package/src/core/coordination/nodejs/StatisticsCollector.js +71 -71
- package/src/core/coordination/nodejs/index.js +90 -72
- package/src/core/coordination/nodejs/utils/Logger.js +29 -29
- package/src/core/enhanced_installer.js +479 -0
- package/src/core/enhanced_uninstaller.js +638 -0
- package/src/core/error_handler.js +406 -406
- package/src/core/installer.js +816 -294
- package/src/core/memory_manager.js +83 -83
- package/src/core/rest_client.js +160 -160
- package/src/core/smart_router.js +249 -146
- package/src/core/upgrade_manager.js +420 -0
- package/src/data_encryption.js +143 -143
- package/src/data_structures.js +440 -440
- package/src/deploy.js +55 -55
- package/src/index.js +30 -30
- package/src/test/cli-availability-checker.js +194 -0
- package/src/test/test-environment.js +289 -0
- package/src/utils/helpers.js +35 -35
- package/src/utils.js +921 -915
- package/src/weatherProcessor.js +228 -228
- package/test/calculator.test.js +0 -215
- package/test/collision-test.js +0 -26
- package/test/comprehensive-execution-test.js +0 -428
- package/test/conflict-prevention-test.js +0 -95
- package/test/cross-cli-detection-test.js +0 -33
- package/test/csv-processing-test.js +0 -36
- package/test/deploy-hooks-test.js +0 -250
- package/test/e2e/claude-cli-test.js +0 -128
- package/test/e2e/collaboration-test.js +0 -75
- package/test/e2e/comprehensive-test.js +0 -431
- package/test/e2e/error-handling-test.js +0 -90
- package/test/e2e/individual-tool-test.js +0 -143
- package/test/e2e/other-cli-test.js +0 -130
- package/test/e2e/qoder-cli-test.js +0 -128
- package/test/e2e/run-e2e-tests.js +0 -73
- package/test/e2e/test-data.js +0 -88
- package/test/e2e/test-utils.js +0 -222
- package/test/encryption-simple-test.js +0 -110
- package/test/encryption.test.js +0 -129
- package/test/enhanced-main-alignment.test.js +0 -298
- package/test/error-handling-test.js +0 -341
- package/test/fibonacci.test.js +0 -178
- package/test/final-deploy-test.js +0 -221
- package/test/final-install-test.js +0 -226
- package/test/hash-table-demo.js +0 -33
- package/test/hash-table-test.js +0 -26
- package/test/hash_table_test.js +0 -114
- package/test/hook-system-integration-test.js +0 -307
- package/test/iflow-integration-test.js +0 -292
- package/test/improved-install-test.js +0 -362
- package/test/install-command-test.js +0 -370
- package/test/json-parser-test.js +0 -161
- package/test/json-validation-test.js +0 -164
- package/test/natural-language-skills-test.js +0 -320
- package/test/nl-integration-test.js +0 -179
- package/test/parameter-parsing-test.js +0 -143
- package/test/plugin-deployment-test.js +0 -316
- package/test/postinstall-test.js +0 -269
- package/test/python-plugins-test.js +0 -259
- package/test/real-test.js +0 -435
- package/test/remaining-adapters-test.js +0 -256
- package/test/rest-client-test.js +0 -56
- package/test/rest_client.test.js +0 -85
- package/test/simple-iflow-hook-test.js +0 -137
- package/test/system-compatibility-test.js +0 -467
- package/test/tdd-deploy-fix-test.js +0 -324
- package/test/tdd-fixes-test.js +0 -211
- package/test/third-party-skills-test.js +0 -321
- package/test/tool-selection-integration-test.js +0 -158
- package/test/unit/calculator-full.test.js +0 -191
- package/test/unit/calculator-simple.test.js +0 -96
- package/test/unit/calculator.test.js +0 -97
- package/test/unit/cli-scanner.test.js +0 -291
- package/test/unit/cli_parameter_handler.test.js +0 -116
- package/test/unit/cross-cli-executor.test.js +0 -399
- package/test/weather-processor.test.js +0 -104
|
@@ -1,111 +1,173 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Stigmergy Pre-installation
|
|
5
|
-
* This script prevents installation conflicts
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const { spawnSync } = require('child_process');
|
|
11
|
-
|
|
12
|
-
console.log('[PRE-INSTALL] Running
|
|
13
|
-
|
|
14
|
-
// Check 1: Verify no conflicting "node" package is already installed
|
|
15
|
-
function checkConflictingNodePackage() {
|
|
16
|
-
console.log('[CHECK] Looking for conflicting node packages...');
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
const result = spawnSync('npm', ['list', '-g', 'node'], {
|
|
20
|
-
encoding: 'utf8',
|
|
21
|
-
timeout: 5000
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (result.stdout && result.stdout.includes('node@')) {
|
|
25
|
-
console.error('[ERROR] Conflicting "node" package detected!');
|
|
26
|
-
console.error('[ERROR] This will interfere with CLI tools. Please run:');
|
|
27
|
-
console.error('[ERROR] npm uninstall -g node');
|
|
28
|
-
console.error('[ERROR] Then try installing stigmergy again.');
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// If npm command fails, continue anyway
|
|
33
|
-
console.log('[INFO] Could not verify node package status, continuing...');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
console.log('[OK] No conflicting node package found.');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Check 2: Verify system Node.js installation
|
|
40
|
-
function checkSystemNode() {
|
|
41
|
-
console.log('[CHECK] Verifying system Node.js installation...');
|
|
42
|
-
|
|
43
|
-
const nodeVersion = process.version;
|
|
44
|
-
const majorVersion = parseInt(nodeVersion.match(/^v(\d+)/)[1]);
|
|
45
|
-
|
|
46
|
-
if (majorVersion < 16) {
|
|
47
|
-
console.error('[ERROR] Node.js version 16 or higher is required.');
|
|
48
|
-
console.error(`[ERROR] Current version: ${nodeVersion}`);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
console.log(`[OK] Node.js ${nodeVersion} detected.`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Check 3: Verify npm installation
|
|
56
|
-
function checkNpm() {
|
|
57
|
-
console.log('[CHECK] Verifying npm installation...');
|
|
58
|
-
|
|
59
|
-
// On Windows, npm might not be directly executable
|
|
60
|
-
if (process.platform === 'win32') {
|
|
61
|
-
console.log('[INFO] Skipping npm verification on Windows (may not be directly executable)');
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
const result = spawnSync('npm', ['--version'], {
|
|
67
|
-
encoding: 'utf8',
|
|
68
|
-
timeout: 5000
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (result.status !== 0) {
|
|
72
|
-
console.error('[ERROR] npm is not properly installed or accessible.');
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
console.log(`[OK] npm ${result.stdout.trim()} detected.`);
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error('[ERROR] Failed to verify npm installation.');
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Check 4: Check for existing stigmergy installation conflicts
|
|
84
|
-
function checkExistingInstallation() {
|
|
85
|
-
console.log('[CHECK] Looking for existing Stigmergy installations...');
|
|
86
|
-
|
|
87
|
-
const npmBinDir = path.join(process.env.APPDATA || process.env.HOME, 'npm');
|
|
88
|
-
const stigmergyBin = path.join(npmBinDir, 'stigmergy');
|
|
89
|
-
|
|
90
|
-
if (fs.existsSync(stigmergyBin)) {
|
|
91
|
-
console.log('[WARNING] Existing Stigmergy installation detected.');
|
|
92
|
-
console.log('[WARNING] This may cause conflicts. Consider uninstalling first:');
|
|
93
|
-
console.log('[WARNING] npm uninstall -g stigmergy');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
console.log('[OK] No conflicting Stigmergy installation found.');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Enhanced Stigmergy Pre-installation Check
|
|
5
|
+
* This script prevents installation conflicts and cleans historical caches
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { spawnSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
console.log('[PRE-INSTALL] Running enhanced installation preparation...');
|
|
13
|
+
|
|
14
|
+
// Check 1: Verify no conflicting "node" package is already installed
|
|
15
|
+
function checkConflictingNodePackage() {
|
|
16
|
+
console.log('[CHECK] Looking for conflicting node packages...');
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const result = spawnSync('npm', ['list', '-g', 'node'], {
|
|
20
|
+
encoding: 'utf8',
|
|
21
|
+
timeout: 5000
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (result.stdout && result.stdout.includes('node@')) {
|
|
25
|
+
console.error('[ERROR] Conflicting "node" package detected!');
|
|
26
|
+
console.error('[ERROR] This will interfere with CLI tools. Please run:');
|
|
27
|
+
console.error('[ERROR] npm uninstall -g node');
|
|
28
|
+
console.error('[ERROR] Then try installing stigmergy again.');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
// If npm command fails, continue anyway
|
|
33
|
+
console.log('[INFO] Could not verify node package status, continuing...');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log('[OK] No conflicting node package found.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Check 2: Verify system Node.js installation
|
|
40
|
+
function checkSystemNode() {
|
|
41
|
+
console.log('[CHECK] Verifying system Node.js installation...');
|
|
42
|
+
|
|
43
|
+
const nodeVersion = process.version;
|
|
44
|
+
const majorVersion = parseInt(nodeVersion.match(/^v(\d+)/)[1]);
|
|
45
|
+
|
|
46
|
+
if (majorVersion < 16) {
|
|
47
|
+
console.error('[ERROR] Node.js version 16 or higher is required.');
|
|
48
|
+
console.error(`[ERROR] Current version: ${nodeVersion}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log(`[OK] Node.js ${nodeVersion} detected.`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Check 3: Verify npm installation
|
|
56
|
+
function checkNpm() {
|
|
57
|
+
console.log('[CHECK] Verifying npm installation...');
|
|
58
|
+
|
|
59
|
+
// On Windows, npm might not be directly executable
|
|
60
|
+
if (process.platform === 'win32') {
|
|
61
|
+
console.log('[INFO] Skipping npm verification on Windows (may not be directly executable)');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const result = spawnSync('npm', ['--version'], {
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
timeout: 5000
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (result.status !== 0) {
|
|
72
|
+
console.error('[ERROR] npm is not properly installed or accessible.');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
console.log(`[OK] npm ${result.stdout.trim()} detected.`);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('[ERROR] Failed to verify npm installation.');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Check 4: Check for existing stigmergy installation conflicts
|
|
84
|
+
function checkExistingInstallation() {
|
|
85
|
+
console.log('[CHECK] Looking for existing Stigmergy installations...');
|
|
86
|
+
|
|
87
|
+
const npmBinDir = path.join(process.env.APPDATA || process.env.HOME, 'npm');
|
|
88
|
+
const stigmergyBin = path.join(npmBinDir, 'stigmergy');
|
|
89
|
+
|
|
90
|
+
if (fs.existsSync(stigmergyBin)) {
|
|
91
|
+
console.log('[WARNING] Existing Stigmergy installation detected.');
|
|
92
|
+
console.log('[WARNING] This may cause conflicts. Consider uninstalling first:');
|
|
93
|
+
console.log('[WARNING] npm uninstall -g stigmergy');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
console.log('[OK] No conflicting Stigmergy installation found.');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Check 5: Clean historical caches (NEW FUNCTION)
|
|
100
|
+
function cleanHistoricalCaches() {
|
|
101
|
+
console.log('[CLEAN] Cleaning historical caches to prevent conflicts...');
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
// Import and use our enhanced cache cleaner
|
|
105
|
+
const CacheCleaner = require('../src/core/cache_cleaner');
|
|
106
|
+
const cleaner = new CacheCleaner({
|
|
107
|
+
dryRun: false,
|
|
108
|
+
force: true,
|
|
109
|
+
verbose: false,
|
|
110
|
+
preserveRecent: 60 * 60 * 1000 // Preserve files from last hour
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Clean only safe items before installation
|
|
114
|
+
cleaner.cleanAllCaches({
|
|
115
|
+
cleanStigmergy: false, // Don't clean main config during install
|
|
116
|
+
cleanNPX: true, // Clean NPX cache (safe)
|
|
117
|
+
cleanNPM: false, // Don't clean NPM cache during install
|
|
118
|
+
cleanCLI: false, // Don't clean CLI configs during install
|
|
119
|
+
cleanTemp: true // Clean temporary files (safe)
|
|
120
|
+
}).then(results => {
|
|
121
|
+
if (results.filesRemoved > 0) {
|
|
122
|
+
console.log(`[CLEAN] Removed ${results.filesRemoved} cache files`);
|
|
123
|
+
console.log(`[CLEAN] Freed ${formatBytes(results.bytesFreed)} space`);
|
|
124
|
+
} else {
|
|
125
|
+
console.log('[CLEAN] No cache files needed cleaning');
|
|
126
|
+
}
|
|
127
|
+
}).catch(error => {
|
|
128
|
+
console.log(`[WARN] Cache cleaning failed: ${error.message}`);
|
|
129
|
+
console.log('[INFO] Continuing with installation...');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.log(`[WARN] Could not initialize cache cleaner: ${error.message}`);
|
|
134
|
+
console.log('[INFO] Continuing with installation...');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Helper function to format bytes
|
|
139
|
+
function formatBytes(bytes) {
|
|
140
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
141
|
+
if (bytes === 0) return '0 Bytes';
|
|
142
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
143
|
+
return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Run all checks and preparation
|
|
147
|
+
async function runInstallationPreparation() {
|
|
148
|
+
try {
|
|
149
|
+
// System requirements first
|
|
150
|
+
checkSystemNode();
|
|
151
|
+
checkNpm();
|
|
152
|
+
checkConflictingNodePackage();
|
|
153
|
+
checkExistingInstallation();
|
|
154
|
+
|
|
155
|
+
// Clean caches (async, but don't wait for completion to avoid blocking npm install)
|
|
156
|
+
cleanHistoricalCaches();
|
|
157
|
+
|
|
158
|
+
console.log('[SUCCESS] Enhanced installation preparation completed.');
|
|
159
|
+
console.log('[INFO] Proceeding with package installation...');
|
|
160
|
+
|
|
161
|
+
// Give cache cleaning a moment to start
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
process.exit(0);
|
|
164
|
+
}, 1000);
|
|
165
|
+
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('[FATAL] Installation preparation failed:', error.message);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Run the enhanced preparation
|
|
173
|
+
runInstallationPreparation();
|
package/scripts/publish.js
CHANGED
|
@@ -1,268 +1,58 @@
|
|
|
1
|
-
#!/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
throw new Error(`版本格式不正确: ${pkg.version}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 检查仓库URL
|
|
63
|
-
if (!pkg.repository?.url) {
|
|
64
|
-
throw new Error('缺少repository.url');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.log('所有检查通过', 'success');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async buildProject() {
|
|
71
|
-
this.log('构建项目...', 'info');
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
// 清理之前的构建
|
|
75
|
-
execSync('rm -rf dist', { cwd: this.rootDir });
|
|
76
|
-
|
|
77
|
-
// 创建dist目录
|
|
78
|
-
execSync('mkdir -p dist', { cwd: this.rootDir });
|
|
79
|
-
|
|
80
|
-
// 复制必要文件
|
|
81
|
-
const filesToCopy = [
|
|
82
|
-
'src/index.js',
|
|
83
|
-
'src/adapters/',
|
|
84
|
-
'src/templates/',
|
|
85
|
-
'package.json',
|
|
86
|
-
'README.md',
|
|
87
|
-
'LICENSE'
|
|
88
|
-
];
|
|
89
|
-
|
|
90
|
-
for (const file of filesToCopy) {
|
|
91
|
-
if (file.endsWith('/')) {
|
|
92
|
-
execSync(`cp -r ${file} dist/`, { cwd: this.rootDir });
|
|
93
|
-
} else {
|
|
94
|
-
execSync(`cp ${file} dist/`, { cwd: this.rootDir });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// 复制bin文件
|
|
99
|
-
execSync('mkdir -p dist/bin', { cwd: this.rootDir });
|
|
100
|
-
execSync('cp bin/* dist/bin/', { cwd: this.rootDir });
|
|
101
|
-
|
|
102
|
-
// 生成package.json用于发布
|
|
103
|
-
const publishPackage = await this.readPackage();
|
|
104
|
-
const publishConfig = {
|
|
105
|
-
...publishPackage,
|
|
106
|
-
files: [
|
|
107
|
-
'src/index.js',
|
|
108
|
-
'src/adapters/**',
|
|
109
|
-
'src/templates/**',
|
|
110
|
-
'bin/**',
|
|
111
|
-
'README.md',
|
|
112
|
-
'LICENSE'
|
|
113
|
-
],
|
|
114
|
-
main: 'src/index.js',
|
|
115
|
-
bin: {
|
|
116
|
-
'stigmergy-cli': 'src/index.js'
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
await writeFile(
|
|
121
|
-
join(this.rootDir, 'dist/package.json'),
|
|
122
|
-
JSON.stringify(publishConfig, null, 2),
|
|
123
|
-
'utf8'
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
this.log('构建完成', 'success');
|
|
127
|
-
} catch (error) {
|
|
128
|
-
this.log(`构建失败: ${error.message}`, 'error');
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async runTests() {
|
|
134
|
-
this.log('运行测试...', 'info');
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
execSync('npm test', { cwd: this.rootDir, stdio: 'inherit' });
|
|
138
|
-
this.log('测试通过', 'success');
|
|
139
|
-
} catch (error) {
|
|
140
|
-
this.log(`测试失败: ${error.message}`, 'error');
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async publishToNPM(dryRun = false) {
|
|
146
|
-
this.log('准备发布到npm...', 'info');
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
// 检查是否已登录npm
|
|
150
|
-
try {
|
|
151
|
-
execSync('npm whoami', { stdio: 'pipe' });
|
|
152
|
-
this.log('npm登录状态: 已登录', 'success');
|
|
153
|
-
} catch {
|
|
154
|
-
this.log('请先登录npm: npm login', 'warning');
|
|
155
|
-
throw new Error('需要先登录npm');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// 检查包名是否可用
|
|
159
|
-
const pkg = await this.readPackage();
|
|
160
|
-
try {
|
|
161
|
-
execSync(`npm view ${pkg.name}`, { stdio: 'pipe' });
|
|
162
|
-
this.log(`包名 ${pkg.name} 已存在,将覆盖发布`, 'warning');
|
|
163
|
-
} catch {
|
|
164
|
-
this.log(`包名 ${pkg.name} 可用`, 'success');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// 发布命令
|
|
168
|
-
const publishCmd = dryRun ? 'npm publish --dry-run' : 'npm publish --access public';
|
|
169
|
-
|
|
170
|
-
if (dryRun) {
|
|
171
|
-
this.log('模拟发布中...', 'info');
|
|
172
|
-
execSync(publishCmd, { cwd: join(this.rootDir, 'dist'), stdio: 'inherit' });
|
|
173
|
-
this.log('模拟发布完成', 'success');
|
|
174
|
-
} else {
|
|
175
|
-
this.log('发布到npm...', 'info');
|
|
176
|
-
execSync(publishCmd, { cwd: join(this.rootDir, 'dist'), stdio: 'inherit' });
|
|
177
|
-
this.log('发布成功!', 'success');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
} catch (error) {
|
|
181
|
-
this.log(`发布失败: ${error.message}`, 'error');
|
|
182
|
-
throw error;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async versionUpdate(type = 'patch') {
|
|
187
|
-
this.log(`更新版本 (${type})...`, 'info');
|
|
188
|
-
|
|
189
|
-
try {
|
|
190
|
-
execSync(`npm version ${type}`, { cwd: this.rootDir, stdio: 'inherit' });
|
|
191
|
-
this.log('版本更新完成', 'success');
|
|
192
|
-
} catch (error) {
|
|
193
|
-
this.log(`版本更新失败: ${error.message}`, 'error');
|
|
194
|
-
throw error;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
async showHelp() {
|
|
199
|
-
console.log(`
|
|
200
|
-
🚀 Stigmergy CLI 发布工具
|
|
201
|
-
|
|
202
|
-
用法: node scripts/publish.js [选项]
|
|
203
|
-
|
|
204
|
-
选项:
|
|
205
|
-
--dry-run 模拟发布,不实际上传到npm
|
|
206
|
-
--patch 更新补丁版本 (默认)
|
|
207
|
-
--minor 更新次版本
|
|
208
|
-
--major 更新主版本
|
|
209
|
-
--help, -h 显示帮助信息
|
|
210
|
-
|
|
211
|
-
示例:
|
|
212
|
-
node scripts/publish.js # 发布到npm
|
|
213
|
-
node scripts/publish.js --dry-run # 模拟发布
|
|
214
|
-
node scripts/publish.js --minor # 更新次版本并发布
|
|
215
|
-
node scripts/publish.js --help # 显示帮助
|
|
216
|
-
|
|
217
|
-
工作流程:
|
|
218
|
-
1. 检查发布要求
|
|
219
|
-
2. 运行测试
|
|
220
|
-
3. 构建项目
|
|
221
|
-
4. 更新版本 (可选)
|
|
222
|
-
5. 发布到npm
|
|
223
|
-
`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
async function main() {
|
|
228
|
-
const publisher = new NPMPublisher();
|
|
229
|
-
const args = process.argv.slice(2);
|
|
230
|
-
|
|
231
|
-
// 显示帮助
|
|
232
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
233
|
-
publisher.showHelp();
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
try {
|
|
238
|
-
// 检查发布要求
|
|
239
|
-
await publisher.checkRequirements();
|
|
240
|
-
|
|
241
|
-
// 运行测试
|
|
242
|
-
await publisher.runTests();
|
|
243
|
-
|
|
244
|
-
// 构建项目
|
|
245
|
-
await publisher.buildProject();
|
|
246
|
-
|
|
247
|
-
// 处理版本更新
|
|
248
|
-
let versionType = 'patch';
|
|
249
|
-
if (args.includes('--minor')) versionType = 'minor';
|
|
250
|
-
if (args.includes('--major')) versionType = 'major';
|
|
251
|
-
|
|
252
|
-
if (versionType !== 'patch') {
|
|
253
|
-
await publisher.versionUpdate(versionType);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// 发布到npm
|
|
257
|
-
const dryRun = args.includes('--dry-run');
|
|
258
|
-
await publisher.publishToNPM(dryRun);
|
|
259
|
-
|
|
260
|
-
} catch (error) {
|
|
261
|
-
console.error('发布失败:', error.message);
|
|
262
|
-
process.exit(1);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
267
|
-
main();
|
|
268
|
-
}
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Release script for Stigmergy CLI v1.2.1
|
|
3
|
+
|
|
4
|
+
echo "=========================================="
|
|
5
|
+
echo "Stigmergy CLI v1.2.1 Release Preparation"
|
|
6
|
+
echo "=========================================="
|
|
7
|
+
|
|
8
|
+
echo ""
|
|
9
|
+
echo "Changes in v1.2.1:"
|
|
10
|
+
echo "- Added 'call' command implementation to modular architecture"
|
|
11
|
+
echo "- Moved old main.js and main_english.js implementations to archive directory"
|
|
12
|
+
echo "- Fixed missing call command functionality in new system"
|
|
13
|
+
echo "- Updated version from 1.2.0 to 1.2.1"
|
|
14
|
+
echo ""
|
|
15
|
+
|
|
16
|
+
# Verify package
|
|
17
|
+
echo "Verifying package..."
|
|
18
|
+
npm pack
|
|
19
|
+
echo "Package stigmergy-1.2.1.tgz created successfully"
|
|
20
|
+
|
|
21
|
+
# Show important files for verification
|
|
22
|
+
echo ""
|
|
23
|
+
echo "Important files to verify before publishing:"
|
|
24
|
+
echo "- package.json: version updated to 1.2.1"
|
|
25
|
+
echo "- CHANGELOG.md: updated with v1.2.1 changes"
|
|
26
|
+
echo "- src/cli/router.js: contains call command implementation"
|
|
27
|
+
echo "- archive/main.js.backup: old implementation preserved"
|
|
28
|
+
|
|
29
|
+
# Instructions for publishing
|
|
30
|
+
echo ""
|
|
31
|
+
echo "=========================================="
|
|
32
|
+
echo "Publishing Instructions (for maintainers):"
|
|
33
|
+
echo "=========================================="
|
|
34
|
+
echo ""
|
|
35
|
+
echo "Before publishing, ensure you have:"
|
|
36
|
+
echo "1. npm login credentials"
|
|
37
|
+
echo "2. Two-factor authentication set up (if required)"
|
|
38
|
+
echo "3. Permissions to publish to 'stigmergy' package"
|
|
39
|
+
echo ""
|
|
40
|
+
echo "To publish the package, run:"
|
|
41
|
+
echo " npm publish"
|
|
42
|
+
echo ""
|
|
43
|
+
echo "To publish a specific tag (e.g., beta):"
|
|
44
|
+
echo " npm publish --tag beta"
|
|
45
|
+
echo ""
|
|
46
|
+
echo "After publishing, verify the release:"
|
|
47
|
+
echo " npm view stigmergy@1.2.1"
|
|
48
|
+
echo ""
|
|
49
|
+
echo "=========================================="
|
|
50
|
+
echo "Git Tagging Commands:"
|
|
51
|
+
echo "=========================================="
|
|
52
|
+
echo "After successful npm publish, tag the release:"
|
|
53
|
+
echo " git add ."
|
|
54
|
+
echo " git commit -m \"Release v1.2.1 - Add call command to modular architecture\""
|
|
55
|
+
echo " git tag -a v1.2.1 -m \"Release v1.2.1\""
|
|
56
|
+
echo " git push origin main"
|
|
57
|
+
echo " git push origin v1.2.1"
|
|
58
|
+
echo "=========================================="
|