@ducky7go/ducky-cli 0.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 +661 -0
- package/README.md +241 -0
- package/bin/ducky +25 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +19 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/nuget/index.d.ts +3 -0
- package/dist/commands/nuget/index.d.ts.map +1 -0
- package/dist/commands/nuget/index.js +23 -0
- package/dist/commands/nuget/index.js.map +1 -0
- package/dist/commands/nuget/pack.d.ts +7 -0
- package/dist/commands/nuget/pack.d.ts.map +1 -0
- package/dist/commands/nuget/pack.js +78 -0
- package/dist/commands/nuget/pack.js.map +1 -0
- package/dist/commands/nuget/push.d.ts +7 -0
- package/dist/commands/nuget/push.d.ts.map +1 -0
- package/dist/commands/nuget/push.js +110 -0
- package/dist/commands/nuget/push.js.map +1 -0
- package/dist/commands/nuget/validate.d.ts +7 -0
- package/dist/commands/nuget/validate.d.ts.map +1 -0
- package/dist/commands/nuget/validate.js +78 -0
- package/dist/commands/nuget/validate.js.map +1 -0
- package/dist/formats/index.d.ts +2 -0
- package/dist/formats/index.d.ts.map +1 -0
- package/dist/formats/index.js +6 -0
- package/dist/formats/index.js.map +1 -0
- package/dist/formats/nuget/client.d.ts +59 -0
- package/dist/formats/nuget/client.d.ts.map +1 -0
- package/dist/formats/nuget/client.js +202 -0
- package/dist/formats/nuget/client.js.map +1 -0
- package/dist/formats/nuget/collector.d.ts +36 -0
- package/dist/formats/nuget/collector.d.ts.map +1 -0
- package/dist/formats/nuget/collector.js +72 -0
- package/dist/formats/nuget/collector.js.map +1 -0
- package/dist/formats/nuget/index.d.ts +6 -0
- package/dist/formats/nuget/index.d.ts.map +1 -0
- package/dist/formats/nuget/index.js +11 -0
- package/dist/formats/nuget/index.js.map +1 -0
- package/dist/formats/nuget/nuspec.d.ts +10 -0
- package/dist/formats/nuget/nuspec.d.ts.map +1 -0
- package/dist/formats/nuget/nuspec.js +59 -0
- package/dist/formats/nuget/nuspec.js.map +1 -0
- package/dist/formats/nuget/parser.d.ts +31 -0
- package/dist/formats/nuget/parser.d.ts.map +1 -0
- package/dist/formats/nuget/parser.js +140 -0
- package/dist/formats/nuget/parser.js.map +1 -0
- package/dist/formats/nuget/validator.d.ts +19 -0
- package/dist/formats/nuget/validator.d.ts.map +1 -0
- package/dist/formats/nuget/validator.js +104 -0
- package/dist/formats/nuget/validator.js.map +1 -0
- package/dist/utils/config.d.ts +31 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +86 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/errors.d.ts +43 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +73 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/fs.d.ts +42 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +125 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +71 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +119 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formats/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formats/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,cAAc,kBAAkB,CAAC;AAEjC,kBAAkB;AAClB,kCAAkC;AAClC,kCAAkC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NuGet CLI configuration
|
|
3
|
+
*/
|
|
4
|
+
interface NugetConfig {
|
|
5
|
+
/** Path to NuGet executable */
|
|
6
|
+
exePath?: string;
|
|
7
|
+
/** Whether to use embedded/managed NuGet */
|
|
8
|
+
useManaged?: boolean;
|
|
9
|
+
/** Custom NuGet version */
|
|
10
|
+
version?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* NuGet CLI manager
|
|
14
|
+
* Handles detection, download, and execution of NuGet CLI
|
|
15
|
+
*/
|
|
16
|
+
export declare class NuGetCliManager {
|
|
17
|
+
private cacheDir;
|
|
18
|
+
private version;
|
|
19
|
+
private platform;
|
|
20
|
+
constructor(config?: NugetConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Get the path to the NuGet executable
|
|
23
|
+
* Downloads NuGet if not found in PATH or cache
|
|
24
|
+
*/
|
|
25
|
+
getExePath(): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Find NuGet in system PATH
|
|
28
|
+
*/
|
|
29
|
+
private findInPath;
|
|
30
|
+
/**
|
|
31
|
+
* Get the path to cached NuGet executable
|
|
32
|
+
*/
|
|
33
|
+
private getCachedExePath;
|
|
34
|
+
/**
|
|
35
|
+
* Download NuGet CLI to cache directory
|
|
36
|
+
*/
|
|
37
|
+
private downloadNuGet;
|
|
38
|
+
/**
|
|
39
|
+
* Execute a NuGet command
|
|
40
|
+
*/
|
|
41
|
+
execute(args: string[], cwd?: string): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* T14: Pack a .nuspec file into a .nupkg package
|
|
44
|
+
* @param nuspecPath - Path to .nuspec file
|
|
45
|
+
* @param outputPath - Directory for output .nupkg file
|
|
46
|
+
* @returns Path to created .nupkg file
|
|
47
|
+
*/
|
|
48
|
+
pack(nuspecPath: string, outputPath: string): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* T15: Push a .nupkg package to a NuGet server
|
|
51
|
+
* @param nupkgPath - Path to .nupkg file
|
|
52
|
+
* @param server - NuGet server URL
|
|
53
|
+
* @param apiKey - API key for authentication
|
|
54
|
+
* @returns Success message
|
|
55
|
+
*/
|
|
56
|
+
push(nupkgPath: string, server: string, apiKey: string): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/formats/nuget/client.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,UAAU,WAAW;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2BAA2B;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAkB;gBAEtB,MAAM,GAAE,WAAgB;IAMpC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAoBnC;;OAEG;YACW,UAAU;IAcxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;YACW,aAAa;IA8C3B;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqC5D;;;;;OAKG;IACG,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCnE;;;;;;OAMG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAyB7E"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { spawn, exec } from 'child_process';
|
|
2
|
+
import { join, dirname, resolve } from 'path';
|
|
3
|
+
import { mkdir, chmod } from 'fs/promises';
|
|
4
|
+
import { existsSync } from 'fs';
|
|
5
|
+
import { homedir, platform } from 'os';
|
|
6
|
+
import { createLogger } from '../../utils/logger.js';
|
|
7
|
+
import { NuGetError } from '../../utils/errors.js';
|
|
8
|
+
const logger = createLogger();
|
|
9
|
+
/**
|
|
10
|
+
* NuGet CLI manager
|
|
11
|
+
* Handles detection, download, and execution of NuGet CLI
|
|
12
|
+
*/
|
|
13
|
+
export class NuGetCliManager {
|
|
14
|
+
cacheDir;
|
|
15
|
+
version;
|
|
16
|
+
platform;
|
|
17
|
+
constructor(config = {}) {
|
|
18
|
+
this.cacheDir = join(homedir(), '.ducky', 'nuget');
|
|
19
|
+
this.version = config.version || '6.11.0';
|
|
20
|
+
this.platform = platform();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the path to the NuGet executable
|
|
24
|
+
* Downloads NuGet if not found in PATH or cache
|
|
25
|
+
*/
|
|
26
|
+
async getExePath() {
|
|
27
|
+
// First, check if NuGet is in PATH
|
|
28
|
+
const pathExe = await this.findInPath();
|
|
29
|
+
if (pathExe) {
|
|
30
|
+
logger.debug(`Using NuGet from PATH: ${pathExe}`);
|
|
31
|
+
return pathExe;
|
|
32
|
+
}
|
|
33
|
+
// Check cache
|
|
34
|
+
const cachedExe = this.getCachedExePath();
|
|
35
|
+
if (existsSync(cachedExe)) {
|
|
36
|
+
logger.debug(`Using cached NuGet: ${cachedExe}`);
|
|
37
|
+
return cachedExe;
|
|
38
|
+
}
|
|
39
|
+
// Download to cache
|
|
40
|
+
logger.info(`NuGet not found in PATH or cache. Downloading v${this.version}...`);
|
|
41
|
+
return await this.downloadNuGet();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Find NuGet in system PATH
|
|
45
|
+
*/
|
|
46
|
+
async findInPath() {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
const command = this.platform === 'win32' ? 'where nuget.exe' : 'which nuget';
|
|
49
|
+
exec(command, (error, stdout) => {
|
|
50
|
+
if (error) {
|
|
51
|
+
resolve(null);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const path = stdout.trim().split('\n')[0];
|
|
55
|
+
resolve(path || null);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the path to cached NuGet executable
|
|
62
|
+
*/
|
|
63
|
+
getCachedExePath() {
|
|
64
|
+
const exeName = this.platform === 'win32' ? 'nuget.exe' : 'nuget.exe';
|
|
65
|
+
return join(this.cacheDir, exeName);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Download NuGet CLI to cache directory
|
|
69
|
+
*/
|
|
70
|
+
async downloadNuGet() {
|
|
71
|
+
const exePath = this.getCachedExePath();
|
|
72
|
+
// Ensure cache directory exists
|
|
73
|
+
await mkdir(dirname(exePath), { recursive: true });
|
|
74
|
+
// For now, we'll use a shell script approach for downloading
|
|
75
|
+
// In production, you'd want to verify checksums and handle HTTPS properly
|
|
76
|
+
const nugetUrl = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe';
|
|
77
|
+
logger.info(`Downloading NuGet from ${nugetUrl}...`);
|
|
78
|
+
// Download using curl or wget (available on most systems)
|
|
79
|
+
const downloadCmd = this.platform === 'win32' ? 'powershell' : 'curl';
|
|
80
|
+
const downloadArgs = this.platform === 'win32'
|
|
81
|
+
? [
|
|
82
|
+
'-Command',
|
|
83
|
+
`Invoke-WebRequest -Uri "${nugetUrl}" -OutFile "${exePath}"`,
|
|
84
|
+
]
|
|
85
|
+
: ['-L', nugetUrl, '-o', exePath];
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const child = spawn(downloadCmd, downloadArgs, { stdio: 'inherit' });
|
|
88
|
+
child.on('close', async (code) => {
|
|
89
|
+
if (code === 0) {
|
|
90
|
+
logger.success(`NuGet downloaded to ${exePath}`);
|
|
91
|
+
// Make executable on Unix-like systems
|
|
92
|
+
if (this.platform !== 'win32') {
|
|
93
|
+
await chmod(exePath, 0o755);
|
|
94
|
+
}
|
|
95
|
+
resolve(exePath);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
reject(new Error(`Failed to download NuGet (exit code ${code}). Please install manually from https://learn.microsoft.com/en-us/nuget/install-nuget-client-tools`));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Execute a NuGet command
|
|
105
|
+
*/
|
|
106
|
+
async execute(args, cwd) {
|
|
107
|
+
const exePath = await this.getExePath();
|
|
108
|
+
logger.debug(`Executing: ${exePath} ${args.join(' ')}`);
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const child = spawn(exePath, args, {
|
|
111
|
+
cwd,
|
|
112
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
113
|
+
shell: true,
|
|
114
|
+
});
|
|
115
|
+
let stdout = '';
|
|
116
|
+
let stderr = '';
|
|
117
|
+
child.stdout?.on('data', (data) => {
|
|
118
|
+
stdout += data.toString();
|
|
119
|
+
});
|
|
120
|
+
child.stderr?.on('data', (data) => {
|
|
121
|
+
stderr += data.toString();
|
|
122
|
+
});
|
|
123
|
+
child.on('close', (code) => {
|
|
124
|
+
if (code === 0) {
|
|
125
|
+
resolve(stdout);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
reject(new Error(`NuGet command failed (exit code ${code}): ${stderr}`));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
child.on('error', (error) => {
|
|
132
|
+
reject(new Error(`Failed to execute NuGet: ${error.message}`));
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* T14: Pack a .nuspec file into a .nupkg package
|
|
138
|
+
* @param nuspecPath - Path to .nuspec file
|
|
139
|
+
* @param outputPath - Directory for output .nupkg file
|
|
140
|
+
* @returns Path to created .nupkg file
|
|
141
|
+
*/
|
|
142
|
+
async pack(nuspecPath, outputPath) {
|
|
143
|
+
logger.info(`Creating NuGet package from ${nuspecPath}...`);
|
|
144
|
+
const outputDir = resolve(outputPath);
|
|
145
|
+
const args = ['pack', nuspecPath, '-OutputDirectory', outputDir, '-NoDefaultExcludes'];
|
|
146
|
+
try {
|
|
147
|
+
const stdout = await this.execute(args);
|
|
148
|
+
// Extract .nupkg path from output
|
|
149
|
+
const match = stdout.match(/[^/\\]+\.nupkg/g);
|
|
150
|
+
if (match && match.length > 0) {
|
|
151
|
+
const nupkgName = match[0];
|
|
152
|
+
const nupkgPath = join(outputDir, nupkgName);
|
|
153
|
+
logger.success(`Created package: ${nupkgPath}`);
|
|
154
|
+
return nupkgPath;
|
|
155
|
+
}
|
|
156
|
+
// Fallback: construct expected path
|
|
157
|
+
throw new NuGetError('Failed to determine .nupkg file path from NuGet output');
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (error instanceof Error) {
|
|
161
|
+
throw new NuGetError(`Failed to create NuGet package: ${error.message}`, [
|
|
162
|
+
'Check that the .nuspec file is valid',
|
|
163
|
+
'Ensure all referenced files exist',
|
|
164
|
+
'Run with --verbose for more details',
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* T15: Push a .nupkg package to a NuGet server
|
|
172
|
+
* @param nupkgPath - Path to .nupkg file
|
|
173
|
+
* @param server - NuGet server URL
|
|
174
|
+
* @param apiKey - API key for authentication
|
|
175
|
+
* @returns Success message
|
|
176
|
+
*/
|
|
177
|
+
async push(nupkgPath, server, apiKey) {
|
|
178
|
+
logger.info(`Pushing ${nupkgPath} to ${server}...`);
|
|
179
|
+
const args = ['push', nupkgPath, '-Source', server, '-ApiKey', apiKey];
|
|
180
|
+
try {
|
|
181
|
+
const stdout = await this.execute(args);
|
|
182
|
+
if (stdout.includes('Your package was pushed')) {
|
|
183
|
+
logger.success('Package pushed successfully!');
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
logger.info('Package push completed');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
if (error instanceof Error) {
|
|
191
|
+
throw new NuGetError(`Failed to push package: ${error.message}`, [
|
|
192
|
+
'Check your API key is correct',
|
|
193
|
+
'Ensure the server URL is correct',
|
|
194
|
+
'Verify the package version does not already exist on the server',
|
|
195
|
+
'Run with --verbose for more details',
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/formats/nuget/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAa,KAAK,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAU,MAAM,IAAI,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;AAc9B;;;GAGG;AACH,MAAM,OAAO,eAAe;IAClB,QAAQ,CAAS;IACjB,OAAO,CAAS;IAChB,QAAQ,CAAkB;IAElC,YAAY,SAAsB,EAAE;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,I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AAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File collection options
|
|
3
|
+
*/
|
|
4
|
+
export interface CollectOptions {
|
|
5
|
+
/** Include all files recursively (default: true) */
|
|
6
|
+
recursive?: boolean;
|
|
7
|
+
/** Pattern to match file names (default: all files) */
|
|
8
|
+
pattern?: RegExp;
|
|
9
|
+
/** Path to mod directory */
|
|
10
|
+
modPath: string;
|
|
11
|
+
/** Path to output directory */
|
|
12
|
+
outputPath: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Collected file information
|
|
16
|
+
*/
|
|
17
|
+
export interface CollectedFile {
|
|
18
|
+
/** Source path (absolute) */
|
|
19
|
+
source: string;
|
|
20
|
+
/** Target path (relative to package root) */
|
|
21
|
+
target: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Collect files for packaging
|
|
25
|
+
* Collects DLL files, preview.png (as icon.png), and all other mod files
|
|
26
|
+
*
|
|
27
|
+
* @param options - Collection options
|
|
28
|
+
* @returns Array of collected files
|
|
29
|
+
* @throws {ValidationError} If mod directory is invalid
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectFilesForPackage(options: CollectOptions): Promise<CollectedFile[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Calculate relative file size for display
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatFileSize(bytes: number): string;
|
|
36
|
+
//# sourceMappingURL=collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../src/formats/nuget/collector.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,EAAE,CAAC,CA2D1B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWpD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { join, relative } from 'path';
|
|
2
|
+
import { collectFiles, fileExists, directoryExists } from '../../utils/fs.js';
|
|
3
|
+
import { ValidationError } from '../../utils/errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Collect files for packaging
|
|
6
|
+
* Collects DLL files, preview.png (as icon.png), and all other mod files
|
|
7
|
+
*
|
|
8
|
+
* @param options - Collection options
|
|
9
|
+
* @returns Array of collected files
|
|
10
|
+
* @throws {ValidationError} If mod directory is invalid
|
|
11
|
+
*/
|
|
12
|
+
export async function collectFilesForPackage(options) {
|
|
13
|
+
const { modPath, outputPath } = options;
|
|
14
|
+
// Validate mod directory exists
|
|
15
|
+
if (!(await directoryExists(modPath))) {
|
|
16
|
+
throw new ValidationError(`Mod directory does not exist: ${modPath}`, ['Check that the path is correct', 'Ensure the directory exists']);
|
|
17
|
+
}
|
|
18
|
+
const files = [];
|
|
19
|
+
// Collect DLL files
|
|
20
|
+
const dllFiles = await collectFiles(modPath, /\.dll$/i);
|
|
21
|
+
for (const file of dllFiles) {
|
|
22
|
+
const target = relative(modPath, file);
|
|
23
|
+
files.push({ source: file, target });
|
|
24
|
+
}
|
|
25
|
+
// Check for preview.png to copy as icon.png
|
|
26
|
+
const previewPath = join(modPath, 'preview.png');
|
|
27
|
+
if (await fileExists(previewPath)) {
|
|
28
|
+
const iconPath = join(modPath, 'icon.png');
|
|
29
|
+
// The icon will be copied to the package, not renamed in source
|
|
30
|
+
files.push({ source: previewPath, target: 'icon.png' });
|
|
31
|
+
}
|
|
32
|
+
// Collect all other files (excluding info.ini and already collected files)
|
|
33
|
+
const allFiles = await collectFiles(modPath);
|
|
34
|
+
const excludedPatterns = [
|
|
35
|
+
/^info\.ini$/i,
|
|
36
|
+
/\.nupkg$/i,
|
|
37
|
+
/\.nuspec$/i,
|
|
38
|
+
/^preview\.png$/i,
|
|
39
|
+
/^icon\.png$/i,
|
|
40
|
+
];
|
|
41
|
+
for (const file of allFiles) {
|
|
42
|
+
const target = relative(modPath, file);
|
|
43
|
+
// Skip if already collected (DLLs)
|
|
44
|
+
if (target.endsWith('.dll')) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// Skip if excluded
|
|
48
|
+
const fileName = target.split('/').pop() || target;
|
|
49
|
+
if (excludedPatterns.some((pattern) => pattern.test(fileName))) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// Check if already added
|
|
53
|
+
if (!files.some((f) => f.target === target)) {
|
|
54
|
+
files.push({ source: file, target });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return files;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Calculate relative file size for display
|
|
61
|
+
*/
|
|
62
|
+
export function formatFileSize(bytes) {
|
|
63
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
64
|
+
let size = bytes;
|
|
65
|
+
let unitIndex = 0;
|
|
66
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
67
|
+
size /= 1024;
|
|
68
|
+
unitIndex++;
|
|
69
|
+
}
|
|
70
|
+
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../../src/formats/nuget/collector.ts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SAAS,EAAE,CAAC;IACd,CAAC;IAED,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formats/nuget/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAG5B,cAAc,aAAa,CAAC;AAG5B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Parser
|
|
2
|
+
export * from './parser.js';
|
|
3
|
+
// Nuspec generator
|
|
4
|
+
export * from './nuspec.js';
|
|
5
|
+
// File collector
|
|
6
|
+
export * from './collector.js';
|
|
7
|
+
// Validator
|
|
8
|
+
export * from './validator.js';
|
|
9
|
+
// Client (will be added in T13-T15)
|
|
10
|
+
export * from './client.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formats/nuget/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,aAAa,CAAC;AAE5B,mBAAmB;AACnB,cAAc,aAAa,CAAC;AAE5B,iBAAiB;AACjB,cAAc,gBAAgB,CAAC;AAE/B,YAAY;AACZ,cAAc,gBAAgB,CAAC;AAE/B,oCAAoC;AACpC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModMetadata } from './parser.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate .nuspec XML content from mod metadata
|
|
4
|
+
* Based on NuGet Mod Packaging Specification v1.0
|
|
5
|
+
*
|
|
6
|
+
* @param metadata - Parsed mod metadata
|
|
7
|
+
* @returns .nuspec XML content
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateNuspec(metadata: ModMetadata): string;
|
|
10
|
+
//# sourceMappingURL=nuspec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuspec.d.ts","sourceRoot":"","sources":["../../../src/formats/nuget/nuspec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAoB5D"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate .nuspec XML content from mod metadata
|
|
3
|
+
* Based on NuGet Mod Packaging Specification v1.0
|
|
4
|
+
*
|
|
5
|
+
* @param metadata - Parsed mod metadata
|
|
6
|
+
* @returns .nuspec XML content
|
|
7
|
+
*/
|
|
8
|
+
export function generateNuspec(metadata) {
|
|
9
|
+
const tags = metadata.tags?.join(' ') || '';
|
|
10
|
+
const dependencies = formatDependencies(metadata.dependencies);
|
|
11
|
+
const icon = metadata.icon ? `<icon>${escapeXml(metadata.icon)}</icon>` : '';
|
|
12
|
+
return `<?xml version="1.0" encoding="utf-8"?>
|
|
13
|
+
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
|
14
|
+
<metadata>
|
|
15
|
+
<id>${escapeXml(metadata.name)}</id>
|
|
16
|
+
<version>${escapeXml(metadata.version)}</version>
|
|
17
|
+
${metadata.description ? `<description>${escapeXml(metadata.description)}</description>` : ''}
|
|
18
|
+
${metadata.author ? `<authors>${escapeXml(metadata.author)}</authors>` : ''}
|
|
19
|
+
${metadata.projectUrl ? `<projectUrl>${escapeXml(metadata.projectUrl)}</projectUrl>` : ''}
|
|
20
|
+
${metadata.license ? `<license type="expression">${escapeXml(metadata.license)}</license>` : ''}
|
|
21
|
+
${metadata.copyright ? `<copyright>${escapeXml(metadata.copyright)}</copyright>` : ''}
|
|
22
|
+
${tags ? `<tags>${escapeXml(tags)}</tags>` : ''}
|
|
23
|
+
${icon}
|
|
24
|
+
${dependencies}
|
|
25
|
+
</metadata>
|
|
26
|
+
</package>`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Format dependencies as NuGet dependency groups
|
|
30
|
+
*/
|
|
31
|
+
function formatDependencies(dependencies) {
|
|
32
|
+
if (!dependencies || dependencies.length === 0) {
|
|
33
|
+
return '<dependencies />';
|
|
34
|
+
}
|
|
35
|
+
const dependencyItems = dependencies
|
|
36
|
+
.map((dep) => {
|
|
37
|
+
const [id, version] = dep.split(':');
|
|
38
|
+
if (version) {
|
|
39
|
+
return `<dependency id="${escapeXml(id)}" version="${escapeXml(version)}" />`;
|
|
40
|
+
}
|
|
41
|
+
return `<dependency id="${escapeXml(dep)}" />`;
|
|
42
|
+
})
|
|
43
|
+
.join('\n ');
|
|
44
|
+
return `<dependencies>
|
|
45
|
+
${dependencyItems}
|
|
46
|
+
</dependencies>`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Escape special XML characters
|
|
50
|
+
*/
|
|
51
|
+
function escapeXml(str) {
|
|
52
|
+
return str
|
|
53
|
+
.replace(/&/g, '&')
|
|
54
|
+
.replace(/</g, '<')
|
|
55
|
+
.replace(/>/g, '>')
|
|
56
|
+
.replace(/"/g, '"')
|
|
57
|
+
.replace(/'/g, ''');
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=nuspec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuspec.js","sourceRoot":"","sources":["../../../src/formats/nuget/nuspec.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,QAAqB;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC5C,MAAM,YAAY,GAAG,kBAAkB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC/D,MAAM,IAAI,GAAG,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G,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,mBAAmB,SAAS,CAAC,EAAE,CAAC,cAAc,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;QAChF,CAAC;QACD,OAAO,mBAAmB,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC;IACjD,CAAC,CAAC;SACD,IAAI,CAAC,QAAQ,CAAC,CAAC;IAElB,OAAO;QACD,eAAe;oBACH,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata structure parsed from info.ini
|
|
3
|
+
*/
|
|
4
|
+
export interface ModMetadata {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
author?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
dependencies?: string[];
|
|
12
|
+
projectUrl?: string;
|
|
13
|
+
license?: string;
|
|
14
|
+
copyright?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse info.ini file from a mod directory
|
|
18
|
+
* @param modPath - Path to the mod directory
|
|
19
|
+
* @returns Parsed metadata
|
|
20
|
+
* @throws {FileSystemError} If info.ini is not found
|
|
21
|
+
* @throws {ValidationError} If required fields are missing
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseInfoIni(modPath: string): Promise<ModMetadata>;
|
|
24
|
+
/**
|
|
25
|
+
* Parse info.ini content
|
|
26
|
+
* @param content - Raw INI content
|
|
27
|
+
* @returns Parsed metadata
|
|
28
|
+
* @throws {ValidationError} If required fields are missing or invalid
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseInfoIniContent(content: string): ModMetadata;
|
|
31
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/formats/nuget/parser.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAkBxE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CA8DhE"}
|