mcp-perforce-server 1.0.0
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/MCP_CONFIG_EXAMPLES.md +205 -0
- package/README.md +224 -0
- package/dist/p4/config.d.ts +67 -0
- package/dist/p4/config.d.ts.map +1 -0
- package/dist/p4/config.js +259 -0
- package/dist/p4/config.js.map +1 -0
- package/dist/p4/parse.d.ts +39 -0
- package/dist/p4/parse.d.ts.map +1 -0
- package/dist/p4/parse.js +286 -0
- package/dist/p4/parse.js.map +1 -0
- package/dist/p4/runner.d.ts +45 -0
- package/dist/p4/runner.d.ts.map +1 -0
- package/dist/p4/runner.js +303 -0
- package/dist/p4/runner.js.map +1 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +562 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/basic.d.ts +79 -0
- package/dist/tools/basic.d.ts.map +1 -0
- package/dist/tools/basic.js +401 -0
- package/dist/tools/basic.js.map +1 -0
- package/dist/tools/changelist.d.ts +50 -0
- package/dist/tools/changelist.d.ts.map +1 -0
- package/dist/tools/changelist.js +469 -0
- package/dist/tools/changelist.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +28 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/utils.d.ts +32 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +164 -0
- package/dist/tools/utils.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.P4Config = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
class P4Config {
|
|
40
|
+
/**
|
|
41
|
+
* Find .p4config file by searching upward from the given directory
|
|
42
|
+
*/
|
|
43
|
+
async findConfig(startPath = process.cwd()) {
|
|
44
|
+
const configName = process.env.P4CONFIG || P4Config.DEFAULT_CONFIG_NAME;
|
|
45
|
+
try {
|
|
46
|
+
const { configPath, projectRoot } = await this.searchUpward(startPath, configName);
|
|
47
|
+
if (!configPath || !projectRoot) {
|
|
48
|
+
return {
|
|
49
|
+
found: false,
|
|
50
|
+
config: {},
|
|
51
|
+
environment: { P4CONFIG: configName },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const config = await this.parseConfigFile(configPath);
|
|
55
|
+
const environment = this.buildEnvironment(config, configName);
|
|
56
|
+
return {
|
|
57
|
+
found: true,
|
|
58
|
+
configPath,
|
|
59
|
+
projectRoot,
|
|
60
|
+
config,
|
|
61
|
+
environment,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
found: false,
|
|
67
|
+
config: {},
|
|
68
|
+
environment: { P4CONFIG: configName },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Search upward through parent directories for config file
|
|
74
|
+
*/
|
|
75
|
+
async searchUpward(startPath, configName) {
|
|
76
|
+
let currentPath = path.resolve(startPath);
|
|
77
|
+
const root = path.parse(currentPath).root;
|
|
78
|
+
while (currentPath !== root) {
|
|
79
|
+
const configPath = path.join(currentPath, configName);
|
|
80
|
+
try {
|
|
81
|
+
await fs.promises.access(configPath, fs.constants.F_OK);
|
|
82
|
+
return { configPath, projectRoot: currentPath };
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// File doesn't exist, continue searching
|
|
86
|
+
}
|
|
87
|
+
currentPath = path.dirname(currentPath);
|
|
88
|
+
}
|
|
89
|
+
// Check root directory as well
|
|
90
|
+
const rootConfigPath = path.join(root, configName);
|
|
91
|
+
try {
|
|
92
|
+
await fs.promises.access(rootConfigPath, fs.constants.F_OK);
|
|
93
|
+
return { configPath: rootConfigPath, projectRoot: root };
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Config not found
|
|
97
|
+
}
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Parse .p4config file content
|
|
102
|
+
*/
|
|
103
|
+
async parseConfigFile(configPath) {
|
|
104
|
+
const content = await fs.promises.readFile(configPath, 'utf-8');
|
|
105
|
+
const config = {};
|
|
106
|
+
const lines = content.split('\n');
|
|
107
|
+
for (const line of lines) {
|
|
108
|
+
const trimmed = line.trim();
|
|
109
|
+
// Skip empty lines and comments
|
|
110
|
+
if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith(';')) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
// Parse key=value pairs
|
|
114
|
+
const equalIndex = trimmed.indexOf('=');
|
|
115
|
+
if (equalIndex > 0) {
|
|
116
|
+
const key = trimmed.substring(0, equalIndex).trim();
|
|
117
|
+
const value = trimmed.substring(equalIndex + 1).trim();
|
|
118
|
+
// Remove quotes if present
|
|
119
|
+
const cleanValue = value.replace(/^(['"])(.*)\1$/, '$2');
|
|
120
|
+
config[key] = cleanValue;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return config;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Build environment variables from config
|
|
127
|
+
*/
|
|
128
|
+
buildEnvironment(config, configName) {
|
|
129
|
+
const env = {
|
|
130
|
+
P4CONFIG: configName,
|
|
131
|
+
};
|
|
132
|
+
// Map common config keys to environment variables
|
|
133
|
+
const keyMapping = {
|
|
134
|
+
P4PORT: 'P4PORT',
|
|
135
|
+
P4USER: 'P4USER',
|
|
136
|
+
P4CLIENT: 'P4CLIENT',
|
|
137
|
+
P4CHARSET: 'P4CHARSET',
|
|
138
|
+
P4PASSWD: 'P4PASSWD',
|
|
139
|
+
P4COMMANDCHARSET: 'P4COMMANDCHARSET',
|
|
140
|
+
P4LANGUAGE: 'P4LANGUAGE',
|
|
141
|
+
P4DIFF: 'P4DIFF',
|
|
142
|
+
P4MERGE: 'P4MERGE',
|
|
143
|
+
P4EDITOR: 'P4EDITOR',
|
|
144
|
+
};
|
|
145
|
+
for (const [configKey, envKey] of Object.entries(keyMapping)) {
|
|
146
|
+
if (config[configKey]) {
|
|
147
|
+
env[envKey] = config[configKey];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return env;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get project root directory from workspace path
|
|
154
|
+
*/
|
|
155
|
+
async getProjectRoot(workspacePath) {
|
|
156
|
+
if (!workspacePath) {
|
|
157
|
+
return process.cwd();
|
|
158
|
+
}
|
|
159
|
+
const resolved = path.resolve(workspacePath);
|
|
160
|
+
const configResult = await this.findConfig(resolved);
|
|
161
|
+
return configResult.projectRoot || resolved;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Setup environment and working directory for p4 command
|
|
165
|
+
*/
|
|
166
|
+
async setupForCommand(workspacePath) {
|
|
167
|
+
const startPath = workspacePath || process.cwd();
|
|
168
|
+
const configResult = await this.findConfig(startPath);
|
|
169
|
+
// Use project root as working directory if config found, otherwise use provided path
|
|
170
|
+
const cwd = configResult.projectRoot || startPath;
|
|
171
|
+
// Merge .p4config environment with MCP-provided environment variables
|
|
172
|
+
const env = {
|
|
173
|
+
...configResult.environment,
|
|
174
|
+
...this.getMcpEnvironment(), // MCP environment takes precedence
|
|
175
|
+
};
|
|
176
|
+
return { cwd, env, configResult };
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Validate that Perforce environment is properly configured
|
|
180
|
+
*/
|
|
181
|
+
validateEnvironment(configResult) {
|
|
182
|
+
const errors = [];
|
|
183
|
+
// Get combined environment (MCP + .p4config)
|
|
184
|
+
const mcpEnv = this.getMcpEnvironment();
|
|
185
|
+
const hasAnyConfig = configResult.found || Object.keys(mcpEnv).length > 0;
|
|
186
|
+
if (!hasAnyConfig) {
|
|
187
|
+
errors.push('No .p4config file found and no MCP environment variables provided');
|
|
188
|
+
}
|
|
189
|
+
const requiredKeys = ['P4PORT', 'P4USER', 'P4CLIENT'];
|
|
190
|
+
for (const key of requiredKeys) {
|
|
191
|
+
const hasInConfig = configResult.config[key];
|
|
192
|
+
const hasInMcp = mcpEnv[key];
|
|
193
|
+
const hasInProcessEnv = process.env[key];
|
|
194
|
+
if (!hasInConfig && !hasInMcp && !hasInProcessEnv) {
|
|
195
|
+
errors.push(`Required configuration missing: ${key}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
valid: errors.length === 0,
|
|
200
|
+
errors,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get server configuration from environment variables
|
|
205
|
+
*/
|
|
206
|
+
getServerConfig() {
|
|
207
|
+
return {
|
|
208
|
+
readOnlyMode: process.env.P4_READONLY_MODE !== 'false', // Default: true
|
|
209
|
+
disableDelete: process.env.P4_DISABLE_DELETE !== 'false', // Default: true
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Extract MCP-provided Perforce environment variables
|
|
214
|
+
*/
|
|
215
|
+
getMcpEnvironment() {
|
|
216
|
+
const mcpEnv = {};
|
|
217
|
+
// Standard Perforce environment variables that can be provided via MCP config
|
|
218
|
+
const p4Keys = [
|
|
219
|
+
'P4PORT', 'P4USER', 'P4CLIENT', 'P4CHARSET', 'P4PASSWD',
|
|
220
|
+
'P4COMMANDCHARSET', 'P4LANGUAGE', 'P4DIFF', 'P4MERGE', 'P4EDITOR'
|
|
221
|
+
];
|
|
222
|
+
for (const key of p4Keys) {
|
|
223
|
+
if (process.env[key]) {
|
|
224
|
+
mcpEnv[key] = process.env[key];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return mcpEnv;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Create a minimal .p4config file template
|
|
231
|
+
*/
|
|
232
|
+
static createTemplate(options = {}) {
|
|
233
|
+
const template = `# Perforce Configuration
|
|
234
|
+
# This file should be placed in your project root directory
|
|
235
|
+
|
|
236
|
+
# Server connection
|
|
237
|
+
P4PORT=${options.port || 'your-perforce-server:1666'}
|
|
238
|
+
|
|
239
|
+
# User credentials
|
|
240
|
+
P4USER=${options.user || 'your-username'}
|
|
241
|
+
|
|
242
|
+
# Client/workspace name
|
|
243
|
+
P4CLIENT=${options.client || 'your-client-name'}
|
|
244
|
+
|
|
245
|
+
# Character set (optional)
|
|
246
|
+
${options.charset ? `P4CHARSET=${options.charset}` : '# P4CHARSET=utf8'}
|
|
247
|
+
|
|
248
|
+
# Optional: Editor for change descriptions
|
|
249
|
+
# P4EDITOR=notepad
|
|
250
|
+
|
|
251
|
+
# Optional: Diff tool
|
|
252
|
+
# P4DIFF=diff
|
|
253
|
+
`;
|
|
254
|
+
return template;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.P4Config = P4Config;
|
|
258
|
+
P4Config.DEFAULT_CONFIG_NAME = '.p4config';
|
|
259
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/p4/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAe7B,MAAa,QAAQ;IAGnB;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,YAAoB,OAAO,CAAC,GAAG,EAAE;QAChD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,QAAQ,CAAC,mBAAmB,CAAC;QAExE,IAAI,CAAC;YACH,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAEnF,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW,EAAE,CAAC;gBAChC,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,EAAE;oBACV,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;iBACtC,CAAC;YACJ,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe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AAY,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,OAAO,EAAE,gBAAgB;YACxE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO,EAAE,gBAAgB;SAC3E,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,iBAAiB;QACvB,MAAM,MAAM,GAA2B,EAAE,CAAC;QAE1C,8EAA8E;QAC9E,MAAM,MAAM,GAAG;YACb,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU;YACvD,kBAAkB,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU;SAClE,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,UAKlB,EAAE;QACJ,MAAM,QAAQ,GAAG;;;;SAIZ,OAAO,CAAC,IAAI,IAAI,2BAA2B;;;SAG3C,OAAO,CAAC,IAAI,IAAI,eAAe;;;WAG7B,OAAO,CAAC,MAAM,IAAI,kBAAkB;;;EAG7C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,kBAAkB;;;;;;;CAOtE,CAAC;QAEE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AA9QH,4BA+QC;AA9QyB,4BAAmB,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse utilities for different p4 output formats
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedRecord {
|
|
5
|
+
[key: string]: string | number | boolean | undefined | ParsedRecord[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parse p4 -ztag output into structured data
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseZtagOutput(output: string): ParsedRecord[];
|
|
11
|
+
/**
|
|
12
|
+
* Parse p4 info output into key-value pairs
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseInfoOutput(output: string): ParsedRecord;
|
|
15
|
+
/**
|
|
16
|
+
* Parse p4 opened output into file records
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseOpenedOutput(output: string): ParsedRecord[];
|
|
19
|
+
/**
|
|
20
|
+
* Parse p4 changes output into changelist records
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseChangesOutput(output: string): ParsedRecord[];
|
|
23
|
+
/**
|
|
24
|
+
* Parse p4 filelog output into file history records
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseFilelogOutput(output: string): ParsedRecord[];
|
|
27
|
+
/**
|
|
28
|
+
* Parse p4 clients output into client records
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseClientsOutput(output: string): ParsedRecord[];
|
|
31
|
+
/**
|
|
32
|
+
* Parse p4 diff output into structured diff information
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseDiffOutput(output: string): ParsedRecord;
|
|
35
|
+
/**
|
|
36
|
+
* Parse p4 sync output into sync records
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseSyncOutput(output: string): ParsedRecord[];
|
|
39
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/p4/parse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,EAAE,CAAC;CACvE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CA+B9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAoB5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CA+BhE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAoBjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAgDjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAmBjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAyD5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAqB9D"}
|
package/dist/p4/parse.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Parse utilities for different p4 output formats
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseZtagOutput = parseZtagOutput;
|
|
7
|
+
exports.parseInfoOutput = parseInfoOutput;
|
|
8
|
+
exports.parseOpenedOutput = parseOpenedOutput;
|
|
9
|
+
exports.parseChangesOutput = parseChangesOutput;
|
|
10
|
+
exports.parseFilelogOutput = parseFilelogOutput;
|
|
11
|
+
exports.parseClientsOutput = parseClientsOutput;
|
|
12
|
+
exports.parseDiffOutput = parseDiffOutput;
|
|
13
|
+
exports.parseSyncOutput = parseSyncOutput;
|
|
14
|
+
/**
|
|
15
|
+
* Parse p4 -ztag output into structured data
|
|
16
|
+
*/
|
|
17
|
+
function parseZtagOutput(output) {
|
|
18
|
+
const results = [];
|
|
19
|
+
const lines = output.split('\n');
|
|
20
|
+
let currentRecord = {};
|
|
21
|
+
for (const line of lines) {
|
|
22
|
+
const trimmedLine = line.trim();
|
|
23
|
+
// Empty line indicates end of record
|
|
24
|
+
if (!trimmedLine) {
|
|
25
|
+
if (Object.keys(currentRecord).length > 0) {
|
|
26
|
+
results.push(currentRecord);
|
|
27
|
+
currentRecord = {};
|
|
28
|
+
}
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
// Parse ztag format: "... key value"
|
|
32
|
+
const match = trimmedLine.match(/^\.\.\. (\w+)\s*(.*)$/);
|
|
33
|
+
if (match) {
|
|
34
|
+
const [, key, value] = match;
|
|
35
|
+
currentRecord[key] = parseValue(value.trim());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Don't forget the last record
|
|
39
|
+
if (Object.keys(currentRecord).length > 0) {
|
|
40
|
+
results.push(currentRecord);
|
|
41
|
+
}
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse p4 info output into key-value pairs
|
|
46
|
+
*/
|
|
47
|
+
function parseInfoOutput(output) {
|
|
48
|
+
const result = {};
|
|
49
|
+
const lines = output.split('\n');
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
const trimmedLine = line.trim();
|
|
52
|
+
if (!trimmedLine)
|
|
53
|
+
continue;
|
|
54
|
+
const colonIndex = trimmedLine.indexOf(': ');
|
|
55
|
+
if (colonIndex > 0) {
|
|
56
|
+
const key = trimmedLine.substring(0, colonIndex).trim();
|
|
57
|
+
const value = trimmedLine.substring(colonIndex + 2).trim();
|
|
58
|
+
// Convert key to camelCase for consistency
|
|
59
|
+
const camelKey = key.replace(/\s+(.)/g, (_, char) => char.toUpperCase());
|
|
60
|
+
result[camelKey] = parseValue(value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parse p4 opened output into file records
|
|
67
|
+
*/
|
|
68
|
+
function parseOpenedOutput(output) {
|
|
69
|
+
const results = [];
|
|
70
|
+
const lines = output.split('\n').filter(line => line.trim());
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
// Format: "//depot/path#revision - action by user@client (change) type"
|
|
73
|
+
const match = line.match(/^(.+?)#(\d+)\s+-\s+(\w+)\s+by\s+(.+?)@(.+?)\s+\((.+?)\)(?:\s+(.+))?/);
|
|
74
|
+
if (match) {
|
|
75
|
+
const [, depotFile, revision, action, user, client, changeInfo, fileType] = match;
|
|
76
|
+
let changeList = 'default';
|
|
77
|
+
if (changeInfo !== 'default change') {
|
|
78
|
+
const changeMatch = changeInfo.match(/change (\d+)/);
|
|
79
|
+
if (changeMatch) {
|
|
80
|
+
changeList = changeMatch[1];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
results.push({
|
|
84
|
+
depotFile: depotFile.trim(),
|
|
85
|
+
revision: parseInt(revision, 10),
|
|
86
|
+
action,
|
|
87
|
+
user,
|
|
88
|
+
client,
|
|
89
|
+
change: changeList,
|
|
90
|
+
type: fileType || 'text',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parse p4 changes output into changelist records
|
|
98
|
+
*/
|
|
99
|
+
function parseChangesOutput(output) {
|
|
100
|
+
const results = [];
|
|
101
|
+
const lines = output.split('\n').filter(line => line.trim());
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
// Format: "Change 12345 on 2023/01/01 by user@client 'Description...'"
|
|
104
|
+
const match = line.match(/^Change\s+(\d+)\s+on\s+(\S+)\s+by\s+(.+?)@(.+?)\s+'(.*)'/);
|
|
105
|
+
if (match) {
|
|
106
|
+
const [, change, date, user, client, description] = match;
|
|
107
|
+
results.push({
|
|
108
|
+
change: parseInt(change, 10),
|
|
109
|
+
date,
|
|
110
|
+
user,
|
|
111
|
+
client,
|
|
112
|
+
description: description.replace(/'/g, ''), // Remove surrounding quotes
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return results;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Parse p4 filelog output into file history records
|
|
120
|
+
*/
|
|
121
|
+
function parseFilelogOutput(output) {
|
|
122
|
+
const results = [];
|
|
123
|
+
const lines = output.split('\n');
|
|
124
|
+
let currentFile = null;
|
|
125
|
+
let currentRevision = null;
|
|
126
|
+
for (const line of lines) {
|
|
127
|
+
const trimmedLine = line.trim();
|
|
128
|
+
if (!trimmedLine)
|
|
129
|
+
continue;
|
|
130
|
+
// File header: "//depot/path"
|
|
131
|
+
if (trimmedLine.startsWith('//') && !trimmedLine.includes('#')) {
|
|
132
|
+
if (currentFile && currentFile.revisions) {
|
|
133
|
+
results.push(currentFile);
|
|
134
|
+
}
|
|
135
|
+
currentFile = {
|
|
136
|
+
depotFile: trimmedLine,
|
|
137
|
+
revisions: [],
|
|
138
|
+
};
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
// Revision line: "... #1 change 123 edit on 2023/01/01 by user@client (text)"
|
|
142
|
+
const revisionMatch = trimmedLine.match(/^\.\.\. #(\d+) change (\d+) (\w+) on (\S+) by (.+?)@(.+?) \((.+?)\)/);
|
|
143
|
+
if (revisionMatch && currentFile) {
|
|
144
|
+
const [, revision, change, action, date, user, client, type] = revisionMatch;
|
|
145
|
+
currentRevision = {
|
|
146
|
+
revision: parseInt(revision, 10),
|
|
147
|
+
change: parseInt(change, 10),
|
|
148
|
+
action,
|
|
149
|
+
date,
|
|
150
|
+
user,
|
|
151
|
+
client,
|
|
152
|
+
type,
|
|
153
|
+
};
|
|
154
|
+
currentFile.revisions.push(currentRevision);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
// Integration records and other details can be added here
|
|
158
|
+
}
|
|
159
|
+
// Don't forget the last file
|
|
160
|
+
if (currentFile) {
|
|
161
|
+
results.push(currentFile);
|
|
162
|
+
}
|
|
163
|
+
return results;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Parse p4 clients output into client records
|
|
167
|
+
*/
|
|
168
|
+
function parseClientsOutput(output) {
|
|
169
|
+
const results = [];
|
|
170
|
+
const lines = output.split('\n').filter(line => line.trim());
|
|
171
|
+
for (const line of lines) {
|
|
172
|
+
// Format: "Client clientname 2023/01/01 root /path/to/root 'Description...'"
|
|
173
|
+
const match = line.match(/^Client\s+(\S+)\s+(\S+)\s+root\s+(.+?)\s+'(.*)'/);
|
|
174
|
+
if (match) {
|
|
175
|
+
const [, client, date, root, description] = match;
|
|
176
|
+
results.push({
|
|
177
|
+
client,
|
|
178
|
+
date,
|
|
179
|
+
root: root.trim(),
|
|
180
|
+
description: description.replace(/'/g, ''),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return results;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Parse p4 diff output into structured diff information
|
|
188
|
+
*/
|
|
189
|
+
function parseDiffOutput(output) {
|
|
190
|
+
const lines = output.split('\n');
|
|
191
|
+
const files = [];
|
|
192
|
+
let currentFile = null;
|
|
193
|
+
let diffLines = [];
|
|
194
|
+
let addedLines = 0;
|
|
195
|
+
let removedLines = 0;
|
|
196
|
+
for (const line of lines) {
|
|
197
|
+
// File header: "==== //depot/path#revision - /local/path ===="
|
|
198
|
+
const fileMatch = line.match(/^==== (.+?)#(\d+) - (.+?) ====/);
|
|
199
|
+
if (fileMatch) {
|
|
200
|
+
// Save previous file if exists
|
|
201
|
+
if (currentFile) {
|
|
202
|
+
currentFile.addedLines = addedLines;
|
|
203
|
+
currentFile.removedLines = removedLines;
|
|
204
|
+
currentFile.diff = diffLines.join('\n');
|
|
205
|
+
files.push(currentFile);
|
|
206
|
+
}
|
|
207
|
+
// Start new file
|
|
208
|
+
const [, depotFile, revision, localFile] = fileMatch;
|
|
209
|
+
currentFile = {
|
|
210
|
+
depotFile,
|
|
211
|
+
revision: parseInt(revision, 10),
|
|
212
|
+
localFile,
|
|
213
|
+
};
|
|
214
|
+
diffLines = [];
|
|
215
|
+
addedLines = 0;
|
|
216
|
+
removedLines = 0;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
// Count added/removed lines
|
|
220
|
+
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
221
|
+
addedLines++;
|
|
222
|
+
}
|
|
223
|
+
else if (line.startsWith('-') && !line.startsWith('---')) {
|
|
224
|
+
removedLines++;
|
|
225
|
+
}
|
|
226
|
+
diffLines.push(line);
|
|
227
|
+
}
|
|
228
|
+
// Don't forget the last file
|
|
229
|
+
if (currentFile) {
|
|
230
|
+
currentFile.addedLines = addedLines;
|
|
231
|
+
currentFile.removedLines = removedLines;
|
|
232
|
+
currentFile.diff = diffLines.join('\n');
|
|
233
|
+
files.push(currentFile);
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
files: files,
|
|
237
|
+
totalFiles: files.length,
|
|
238
|
+
totalAddedLines: files.reduce((sum, file) => sum + (file.addedLines || 0), 0),
|
|
239
|
+
totalRemovedLines: files.reduce((sum, file) => sum + (file.removedLines || 0), 0),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Parse p4 sync output into sync records
|
|
244
|
+
*/
|
|
245
|
+
function parseSyncOutput(output) {
|
|
246
|
+
const results = [];
|
|
247
|
+
const lines = output.split('\n').filter(line => line.trim());
|
|
248
|
+
for (const line of lines) {
|
|
249
|
+
// Format: "//depot/path#revision - updating /local/path"
|
|
250
|
+
// Format: "//depot/path#revision - added as /local/path"
|
|
251
|
+
// Format: "//depot/path#revision - deleted as /local/path"
|
|
252
|
+
const match = line.match(/^(.+?)#(\d+)\s+-\s+(\w+)(?:\s+as)?\s+(.+)/);
|
|
253
|
+
if (match) {
|
|
254
|
+
const [, depotFile, revision, action, localFile] = match;
|
|
255
|
+
results.push({
|
|
256
|
+
depotFile,
|
|
257
|
+
revision: parseInt(revision, 10),
|
|
258
|
+
action,
|
|
259
|
+
localFile,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return results;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Parse individual values with type conversion
|
|
267
|
+
*/
|
|
268
|
+
function parseValue(value) {
|
|
269
|
+
if (!value)
|
|
270
|
+
return '';
|
|
271
|
+
// Try to parse as number
|
|
272
|
+
const numValue = parseFloat(value);
|
|
273
|
+
if (!isNaN(numValue) && isFinite(numValue) && value.match(/^\d+(\.\d+)?$/)) {
|
|
274
|
+
return numValue;
|
|
275
|
+
}
|
|
276
|
+
// Try to parse as boolean
|
|
277
|
+
const lowerValue = value.toLowerCase();
|
|
278
|
+
if (lowerValue === 'true' || lowerValue === 'yes' || lowerValue === 'on') {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
if (lowerValue === 'false' || lowerValue === 'no' || lowerValue === 'off') {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
return value;
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/p4/parse.ts"],"names":[],"mappings":";AAAA;;GAEG;;AASH,0CA+BC;AAKD,0CAoBC;AAKD,8CA+BC;AAKD,gDAoBC;AAKD,gDAgDC;AAKD,gDAmBC;AAKD,0CAyDC;AAKD,0CAqBC;AA7RD;;GAEG;AACH,SAAgB,eAAe,CAAC,MAAc;IAC5C,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,aAAa,GAAiB,EAAE,CAAC;IAErC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAEhC,qCAAqC;QACrC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,IAAI,MAAM,CAAC,IAAI,C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B;IAC1B,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QAC1E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface P4RunResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
command: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
cwd: string;
|
|
6
|
+
configUsed: {
|
|
7
|
+
p4configPath?: string;
|
|
8
|
+
P4PORT?: string;
|
|
9
|
+
P4USER?: string;
|
|
10
|
+
P4CLIENT?: string;
|
|
11
|
+
P4CHARSET?: string;
|
|
12
|
+
[key: string]: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
result?: any;
|
|
15
|
+
warnings?: string[];
|
|
16
|
+
error?: {
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
details?: any;
|
|
20
|
+
stderr?: string;
|
|
21
|
+
exitCode?: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface P4RunOptions {
|
|
25
|
+
timeout?: number;
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
parseOutput?: boolean;
|
|
28
|
+
useZtag?: boolean;
|
|
29
|
+
useMarshalled?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare class P4Runner {
|
|
32
|
+
private static readonly DEFAULT_TIMEOUT;
|
|
33
|
+
private readonly p4Path;
|
|
34
|
+
constructor();
|
|
35
|
+
run(command: string, args?: string[], cwd?: string, options?: P4RunOptions): Promise<P4RunResult>;
|
|
36
|
+
private spawnP4Process;
|
|
37
|
+
private parseOutput;
|
|
38
|
+
private parseZtagOutput;
|
|
39
|
+
private parseMarshaled;
|
|
40
|
+
private parseTextOutput;
|
|
41
|
+
private supportsMarshalled;
|
|
42
|
+
private extractConfigFromEnv;
|
|
43
|
+
private mapError;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/p4/runner.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE;QACV,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;KACnC,CAAC;IACF,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,O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