@btc-vision/cli 1.0.5 → 1.0.7

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.
Files changed (51) hide show
  1. package/build/index.js +3 -4
  2. package/build/lib/config.js +1 -6
  3. package/build/lib/ipfs.d.ts +0 -2
  4. package/build/lib/ipfs.js +29 -32
  5. package/build/lib/wallet.js +1 -1
  6. package/package.json +4 -1
  7. package/.gitattributes +0 -2
  8. package/.github/dependabot.yml +0 -9
  9. package/.github/workflows/ci.yml +0 -48
  10. package/.prettierrc.json +0 -12
  11. package/CONTRIBUTING.md +0 -56
  12. package/NOTICE +0 -17
  13. package/SECURITY.md +0 -35
  14. package/eslint.config.js +0 -41
  15. package/gulpfile.js +0 -41
  16. package/src/commands/AcceptCommand.ts +0 -224
  17. package/src/commands/BaseCommand.ts +0 -59
  18. package/src/commands/CompileCommand.ts +0 -195
  19. package/src/commands/ConfigCommand.ts +0 -117
  20. package/src/commands/DeprecateCommand.ts +0 -193
  21. package/src/commands/InfoCommand.ts +0 -293
  22. package/src/commands/InitCommand.ts +0 -541
  23. package/src/commands/InstallCommand.ts +0 -179
  24. package/src/commands/KeygenCommand.ts +0 -157
  25. package/src/commands/ListCommand.ts +0 -169
  26. package/src/commands/LoginCommand.ts +0 -197
  27. package/src/commands/LogoutCommand.ts +0 -76
  28. package/src/commands/PublishCommand.ts +0 -340
  29. package/src/commands/ScopeRegisterCommand.ts +0 -164
  30. package/src/commands/SearchCommand.ts +0 -140
  31. package/src/commands/SignCommand.ts +0 -110
  32. package/src/commands/TransferCommand.ts +0 -363
  33. package/src/commands/UndeprecateCommand.ts +0 -167
  34. package/src/commands/UpdateCommand.ts +0 -200
  35. package/src/commands/VerifyCommand.ts +0 -228
  36. package/src/commands/WhoamiCommand.ts +0 -113
  37. package/src/index.ts +0 -88
  38. package/src/lib/PackageRegistry.abi.json +0 -765
  39. package/src/lib/PackageRegistry.abi.ts +0 -365
  40. package/src/lib/binary.ts +0 -338
  41. package/src/lib/config.ts +0 -265
  42. package/src/lib/credentials.ts +0 -176
  43. package/src/lib/ipfs.ts +0 -382
  44. package/src/lib/manifest.ts +0 -195
  45. package/src/lib/provider.ts +0 -121
  46. package/src/lib/registry.ts +0 -467
  47. package/src/lib/transaction.ts +0 -205
  48. package/src/lib/wallet.ts +0 -262
  49. package/src/types/PackageRegistry.ts +0 -344
  50. package/src/types/index.ts +0 -147
  51. package/tsconfig.json +0 -25
@@ -1,293 +0,0 @@
1
- /**
2
- * Info command - Display plugin or .opnet file information
3
- *
4
- * @module commands/InfoCommand
5
- */
6
-
7
- import * as fs from 'fs';
8
- import * as path from 'path';
9
- import * as crypto from 'crypto';
10
- import { IPluginPermissions } from '@btc-vision/plugin-sdk';
11
- import { BaseCommand } from './BaseCommand.js';
12
- import { formatFileSize, getParsedMldsaLevel, parseOpnetBinary } from '../lib/binary.js';
13
- import { getManifestPath, loadManifest } from '../lib/manifest.js';
14
-
15
- interface InfoOptions {
16
- json?: boolean;
17
- }
18
-
19
- export class InfoCommand extends BaseCommand {
20
- constructor() {
21
- super('info', 'Display information about a plugin or .opnet file');
22
- }
23
-
24
- protected configure(): void {
25
- this.command
26
- .argument(
27
- '[path]',
28
- 'Path to plugin directory or .opnet file (default: current directory)',
29
- )
30
- .option('--json', 'Output as JSON')
31
- .action((inputPath?: string, options?: InfoOptions) =>
32
- this.execute(inputPath, options),
33
- );
34
- }
35
-
36
- private execute(inputPath?: string, options?: InfoOptions): void {
37
- try {
38
- const targetPath = inputPath ? path.resolve(inputPath) : process.cwd();
39
-
40
- if (!fs.existsSync(targetPath)) {
41
- this.exitWithError(`Path not found: ${targetPath}`);
42
- }
43
-
44
- const stat = fs.statSync(targetPath);
45
-
46
- if (stat.isFile() && targetPath.endsWith('.opnet')) {
47
- this.displayBinaryInfo(targetPath, options?.json);
48
- } else if (stat.isDirectory()) {
49
- this.displayProjectInfo(targetPath, options?.json);
50
- } else if (stat.isFile() && targetPath.endsWith('plugin.json')) {
51
- this.displayProjectInfo(path.dirname(targetPath), options?.json);
52
- } else {
53
- this.exitWithError('Invalid path. Provide a plugin directory or .opnet file.');
54
- }
55
- } catch (error) {
56
- this.exitWithError(this.formatError(error));
57
- }
58
- }
59
-
60
- private displayBinaryInfo(filePath: string, json?: boolean): void {
61
- const data = fs.readFileSync(filePath);
62
- const parsed = parseOpnetBinary(data);
63
- const mldsaLevel = getParsedMldsaLevel(parsed);
64
-
65
- const isUnsigned = parsed.publicKey.every((b) => b === 0);
66
- const publicKeyHash = crypto.createHash('sha256').update(parsed.publicKey).digest('hex');
67
-
68
- if (json) {
69
- const output = {
70
- type: 'binary',
71
- file: filePath,
72
- fileSize: data.length,
73
- formatVersion: parsed.formatVersion,
74
- mldsaLevel,
75
- signed: !isUnsigned,
76
- publicKeyHash: isUnsigned ? null : publicKeyHash,
77
- metadata: parsed.metadata,
78
- sizes: {
79
- metadata: parsed.rawMetadata.length,
80
- bytecode: parsed.bytecode.length,
81
- proto: parsed.proto?.length ?? 0,
82
- publicKey: parsed.publicKey.length,
83
- signature: parsed.signature.length,
84
- },
85
- };
86
- this.logger.log(JSON.stringify(output, null, 2));
87
- return;
88
- }
89
-
90
- const meta = parsed.metadata;
91
-
92
- this.logger.info('\nOPNet Binary Information\n');
93
- this.logger.log('─'.repeat(60));
94
-
95
- this.logger.log(`File: ${filePath}`);
96
- this.logger.log(`Size: ${formatFileSize(data.length)}`);
97
- this.logger.log(`Format: v${parsed.formatVersion}`);
98
- this.logger.log('');
99
-
100
- this.logger.log('Plugin:');
101
- this.logger.log(` Name: ${meta.name}`);
102
- this.logger.log(` Version: ${meta.version}`);
103
- this.logger.log(` Type: ${meta.pluginType}`);
104
- this.logger.log(` OPNet: ${meta.opnetVersion}`);
105
- if (meta.description) {
106
- this.logger.log(` Description: ${meta.description}`);
107
- }
108
- this.logger.log('');
109
-
110
- this.logger.log('Author:');
111
- this.logger.log(` Name: ${meta.author.name}`);
112
- if (meta.author.email) {
113
- this.logger.log(` Email: ${meta.author.email}`);
114
- }
115
- this.logger.log('');
116
-
117
- this.logger.log('Cryptography:');
118
- this.logger.log(` MLDSA Level: MLDSA-${mldsaLevel}`);
119
- this.logger.log(` Signed: ${isUnsigned ? 'No' : 'Yes'}`);
120
- if (!isUnsigned) {
121
- this.logger.log(` Publisher: ${publicKeyHash.substring(0, 32)}...`);
122
- }
123
- this.logger.log('');
124
-
125
- this.logger.log('Sizes:');
126
- this.logger.log(` Bytecode: ${formatFileSize(parsed.bytecode.length)}`);
127
- this.logger.log(` Metadata: ${formatFileSize(parsed.rawMetadata.length)}`);
128
- this.logger.log(` Proto: ${formatFileSize(parsed.proto?.length ?? 0)}`);
129
- this.logger.log('');
130
-
131
- this.logger.log('Permissions:');
132
- this.displayPermissions(meta.permissions);
133
- this.logger.log('');
134
-
135
- if (Object.keys(meta.dependencies || {}).length > 0) {
136
- this.logger.log('Dependencies:');
137
- for (const [name, version] of Object.entries(meta.dependencies || {})) {
138
- this.logger.log(` ${name}: ${version}`);
139
- }
140
- this.logger.log('');
141
- }
142
- }
143
-
144
- private displayProjectInfo(projectDir: string, json?: boolean): void {
145
- const manifestPath = getManifestPath(projectDir);
146
-
147
- if (!fs.existsSync(manifestPath)) {
148
- this.logger.fail('No plugin.json found in this directory.');
149
- this.logger.info('Run `opnet init` to create a new plugin project.');
150
- process.exit(1);
151
- }
152
-
153
- const manifest = loadManifest(manifestPath);
154
-
155
- // Check for compiled binary
156
- const binaryPath = path.join(
157
- projectDir,
158
- 'build',
159
- `${manifest.name.replace(/^@/, '').replace(/\//g, '-')}.opnet`,
160
- );
161
- const hasBinary = fs.existsSync(binaryPath);
162
- let binarySize: number | null = null;
163
- if (hasBinary) {
164
- binarySize = fs.statSync(binaryPath).size;
165
- }
166
-
167
- // Check for source files
168
- const srcDir = path.join(projectDir, 'src');
169
- const hasSrc = fs.existsSync(srcDir);
170
-
171
- // Check for node_modules
172
- const hasNodeModules = fs.existsSync(path.join(projectDir, 'node_modules'));
173
-
174
- if (json) {
175
- const output = {
176
- type: 'project',
177
- directory: projectDir,
178
- manifest,
179
- compiled: hasBinary,
180
- binaryPath: hasBinary ? binaryPath : null,
181
- binarySize,
182
- hasSource: hasSrc,
183
- hasNodeModules,
184
- };
185
- this.logger.log(JSON.stringify(output, null, 2));
186
- return;
187
- }
188
-
189
- this.logger.info('\nOPNet Plugin Project\n');
190
- this.logger.log('─'.repeat(60));
191
-
192
- this.logger.log(`Directory: ${projectDir}`);
193
- this.logger.log('');
194
-
195
- this.logger.log('Plugin:');
196
- this.logger.log(` Name: ${manifest.name}`);
197
- this.logger.log(` Version: ${manifest.version}`);
198
- this.logger.log(` Type: ${manifest.pluginType}`);
199
- this.logger.log(` OPNet: ${manifest.opnetVersion}`);
200
- if (manifest.description) {
201
- this.logger.log(` Description: ${manifest.description}`);
202
- }
203
- this.logger.log('');
204
-
205
- this.logger.log('Author:');
206
- this.logger.log(` Name: ${manifest.author.name}`);
207
- if (manifest.author.email) {
208
- this.logger.log(` Email: ${manifest.author.email}`);
209
- }
210
- this.logger.log('');
211
-
212
- this.logger.log('Status:');
213
- this.logger.log(` Source: ${hasSrc ? 'Found' : 'Missing'}`);
214
- this.logger.log(` Dependencies: ${hasNodeModules ? 'Installed' : 'Not installed'}`);
215
- this.logger.log(
216
- ` Compiled: ${hasBinary && binarySize !== null ? `Yes (${formatFileSize(binarySize)})` : 'No'}`,
217
- );
218
- this.logger.log('');
219
-
220
- this.logger.log('Permissions:');
221
- this.displayPermissions(manifest.permissions);
222
- this.logger.log('');
223
-
224
- if (manifest.resources) {
225
- this.logger.log('Resources:');
226
- if (manifest.resources.memory) {
227
- this.logger.log(
228
- ` Max Heap: ${manifest.resources.memory.maxHeapMB ?? 'N/A'} MB`,
229
- );
230
- }
231
- if (manifest.resources.cpu) {
232
- this.logger.log(` Max Threads: ${manifest.resources.cpu.maxThreads ?? 'N/A'}`);
233
- this.logger.log(` Priority: ${manifest.resources.cpu.priority ?? 'normal'}`);
234
- }
235
- if (manifest.resources.timeout) {
236
- this.logger.log(
237
- ` Init Timeout: ${manifest.resources.timeout.initMs ?? 'N/A'} ms`,
238
- );
239
- this.logger.log(
240
- ` Hook Timeout: ${manifest.resources.timeout.hookMs ?? 'N/A'} ms`,
241
- );
242
- }
243
- this.logger.log('');
244
- }
245
-
246
- if (Object.keys(manifest.dependencies || {}).length > 0) {
247
- this.logger.log('Plugin Dependencies:');
248
- for (const [name, version] of Object.entries(manifest.dependencies || {})) {
249
- this.logger.log(` ${name}: ${version}`);
250
- }
251
- this.logger.log('');
252
- }
253
-
254
- if (manifest.lifecycle) {
255
- this.logger.log('Lifecycle:');
256
- this.logger.log(` Load Priority: ${manifest.lifecycle.loadPriority ?? 100}`);
257
- this.logger.log(
258
- ` Enabled: ${manifest.lifecycle.enabledByDefault !== false ? 'Yes' : 'No'}`,
259
- );
260
- this.logger.log(
261
- ` Requires Restart: ${manifest.lifecycle.requiresRestart ? 'Yes' : 'No'}`,
262
- );
263
- this.logger.log('');
264
- }
265
- }
266
-
267
- private displayPermissions(permissions?: IPluginPermissions): void {
268
- if (!permissions) {
269
- this.logger.log(' (none configured)');
270
- return;
271
- }
272
- const db = permissions.database?.enabled ?? false;
273
- const blocks =
274
- permissions.blocks?.preProcess ||
275
- permissions.blocks?.postProcess ||
276
- permissions.blocks?.onChange ||
277
- false;
278
- const epochs = permissions.epochs?.onChange || permissions.epochs?.onFinalized || false;
279
- const mempool = permissions.mempool?.txFeed ?? false;
280
- const api = permissions.api?.addEndpoints || permissions.api?.addWebsocket || false;
281
- const fsPerms =
282
- permissions.filesystem?.configDir || permissions.filesystem?.tempDir || false;
283
-
284
- this.logger.log(` Database: ${db ? 'Yes' : 'No'}`);
285
- this.logger.log(` Block Hooks: ${blocks ? 'Yes' : 'No'}`);
286
- this.logger.log(` Epoch Hooks: ${epochs ? 'Yes' : 'No'}`);
287
- this.logger.log(` Mempool Feed: ${mempool ? 'Yes' : 'No'}`);
288
- this.logger.log(` API Endpoints: ${api ? 'Yes' : 'No'}`);
289
- this.logger.log(` Filesystem: ${fsPerms ? 'Yes' : 'No'}`);
290
- }
291
- }
292
-
293
- export const infoCommand = new InfoCommand().getCommand();