neozip-cli 0.70.0-alpha
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/CHANGELOG.md +72 -0
- package/DOCUMENTATION.md +194 -0
- package/LICENSE +22 -0
- package/README.md +504 -0
- package/WHY_NEOZIP.md +212 -0
- package/bin/neolist +16 -0
- package/bin/neounzip +16 -0
- package/bin/neozip +15 -0
- package/dist/neozipkit-bundles/blockchain.js +13091 -0
- package/dist/neozipkit-bundles/browser.js +5733 -0
- package/dist/neozipkit-bundles/core.js +3766 -0
- package/dist/neozipkit-bundles/server.js +14996 -0
- package/dist/neozipkit-wrappers/blockchain/core/contracts.js +16 -0
- package/dist/neozipkit-wrappers/blockchain/index.js +2 -0
- package/dist/neozipkit-wrappers/core/ZipDecompress.js +2 -0
- package/dist/neozipkit-wrappers/core/components/HashCalculator.js +2 -0
- package/dist/neozipkit-wrappers/core/components/Logger.js +2 -0
- package/dist/neozipkit-wrappers/core/constants/Errors.js +2 -0
- package/dist/neozipkit-wrappers/core/constants/Headers.js +2 -0
- package/dist/neozipkit-wrappers/core/encryption/ZipCrypto.js +7 -0
- package/dist/neozipkit-wrappers/core/index.js +3 -0
- package/dist/neozipkit-wrappers/index.js +13 -0
- package/dist/neozipkit-wrappers/server/index.js +2 -0
- package/dist/src/config/ConfigSetup.js +455 -0
- package/dist/src/config/ConfigStore.js +373 -0
- package/dist/src/config/ConfigWizard.js +453 -0
- package/dist/src/config/WalletConfig.js +372 -0
- package/dist/src/exit-codes.js +210 -0
- package/dist/src/index.js +141 -0
- package/dist/src/neolist.js +1194 -0
- package/dist/src/neounzip.js +2177 -0
- package/dist/src/neozip/CommentManager.js +240 -0
- package/dist/src/neozip/blockchain.js +383 -0
- package/dist/src/neozip/createZip.js +2273 -0
- package/dist/src/neozip/file-operations.js +920 -0
- package/dist/src/neozip/types.js +6 -0
- package/dist/src/neozip/user-interaction.js +256 -0
- package/dist/src/neozip/utils.js +96 -0
- package/dist/src/neozip.js +785 -0
- package/dist/src/server/CommentManager.js +240 -0
- package/dist/src/version.js +59 -0
- package/env.example +101 -0
- package/package.json +175 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* User interaction functions for NeoZip CLI
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.readFilenamesFromStdin = readFilenamesFromStdin;
|
|
40
|
+
exports.promptUser = promptUser;
|
|
41
|
+
exports.promptPassword = promptPassword;
|
|
42
|
+
exports.getUserTokenChoice = getUserTokenChoice;
|
|
43
|
+
const readline = __importStar(require("readline"));
|
|
44
|
+
/**
|
|
45
|
+
* Read filenames from stdin (one per line)
|
|
46
|
+
*/
|
|
47
|
+
async function readFilenamesFromStdin() {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const filenames = [];
|
|
50
|
+
const rl = readline.createInterface({
|
|
51
|
+
input: process.stdin,
|
|
52
|
+
output: process.stdout,
|
|
53
|
+
terminal: false
|
|
54
|
+
});
|
|
55
|
+
rl.on('line', (line) => {
|
|
56
|
+
const filename = line.trim();
|
|
57
|
+
if (filename) {
|
|
58
|
+
filenames.push(filename);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
rl.on('close', () => {
|
|
62
|
+
resolve(filenames);
|
|
63
|
+
});
|
|
64
|
+
rl.on('error', (error) => {
|
|
65
|
+
reject(error);
|
|
66
|
+
});
|
|
67
|
+
// Handle case where stdin is empty or closed immediately
|
|
68
|
+
process.stdin.on('end', () => {
|
|
69
|
+
rl.close();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Generic user prompt function
|
|
75
|
+
*/
|
|
76
|
+
async function promptUser(question) {
|
|
77
|
+
const rl = readline.createInterface({
|
|
78
|
+
input: process.stdin,
|
|
79
|
+
output: process.stdout
|
|
80
|
+
});
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
rl.question(question, (answer) => {
|
|
83
|
+
rl.close();
|
|
84
|
+
resolve(answer.trim());
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Prompt for password with masking
|
|
90
|
+
*/
|
|
91
|
+
async function promptPassword(question) {
|
|
92
|
+
const rl = readline.createInterface({
|
|
93
|
+
input: process.stdin,
|
|
94
|
+
output: process.stdout
|
|
95
|
+
});
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
let password = '';
|
|
98
|
+
// Check if setRawMode is available (not available in some environments)
|
|
99
|
+
if (process.stdin.setRawMode) {
|
|
100
|
+
process.stdout.write(question);
|
|
101
|
+
process.stdin.setRawMode(true);
|
|
102
|
+
process.stdin.resume();
|
|
103
|
+
process.stdin.setEncoding('utf8');
|
|
104
|
+
process.stdin.on('data', (char) => {
|
|
105
|
+
const charStr = char.toString();
|
|
106
|
+
if (charStr === '\r' || charStr === '\n') {
|
|
107
|
+
process.stdin.setRawMode(false);
|
|
108
|
+
process.stdin.pause();
|
|
109
|
+
process.stdout.write('\n');
|
|
110
|
+
rl.close();
|
|
111
|
+
resolve(password);
|
|
112
|
+
}
|
|
113
|
+
else if (charStr === '\u0003') { // Ctrl+C
|
|
114
|
+
process.exit(0);
|
|
115
|
+
}
|
|
116
|
+
else if (charStr === '\u007f') { // Backspace
|
|
117
|
+
if (password.length > 0) {
|
|
118
|
+
password = password.slice(0, -1);
|
|
119
|
+
process.stdout.write('\b \b');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
password += charStr;
|
|
124
|
+
process.stdout.write('*');
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// Fallback to regular readline if setRawMode is not available
|
|
130
|
+
rl.question(question, (answer) => {
|
|
131
|
+
rl.close();
|
|
132
|
+
resolve(answer.trim());
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get user's token choice from available options
|
|
139
|
+
*/
|
|
140
|
+
async function getUserTokenChoice(duplicateCheck) {
|
|
141
|
+
// Display owned tokens
|
|
142
|
+
if (duplicateCheck.userOwnedTokens.length > 0) {
|
|
143
|
+
console.log('\nYour tokens:');
|
|
144
|
+
duplicateCheck.userOwnedTokens.forEach((token, index) => {
|
|
145
|
+
console.log(` ${index + 1}. Token ID ${token.tokenId}`);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Display tokens owned by others
|
|
149
|
+
if (duplicateCheck.othersTokens.length > 0) {
|
|
150
|
+
console.log('\nTokens owned by others:');
|
|
151
|
+
duplicateCheck.othersTokens.forEach((token, index) => {
|
|
152
|
+
const shortOwner = `${token.owner.substring(0, 6)}...${token.owner.substring(38)}`;
|
|
153
|
+
console.log(` ${duplicateCheck.userOwnedTokens.length + index + 1}. Token ID ${token.tokenId} (owned by ${shortOwner})`);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
console.log('\nChoose an option:');
|
|
157
|
+
let optionNumber = 1;
|
|
158
|
+
const options = {};
|
|
159
|
+
// Option 1: Use earliest owned token (default if user owns exactly one)
|
|
160
|
+
if (duplicateCheck.userOwnedTokens.length === 1) {
|
|
161
|
+
console.log(` ${optionNumber}. Use your token (ID ${duplicateCheck.userOwnedTokens[0].tokenId}) [DEFAULT]`);
|
|
162
|
+
options[optionNumber.toString()] = async () => {
|
|
163
|
+
return {
|
|
164
|
+
action: 'use-existing',
|
|
165
|
+
selectedToken: duplicateCheck.userOwnedTokens[0]
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
optionNumber++;
|
|
169
|
+
}
|
|
170
|
+
else if (duplicateCheck.userOwnedTokens.length > 1) {
|
|
171
|
+
console.log(` ${optionNumber}. Use your earliest token (ID ${duplicateCheck.userOwnedTokens[0].tokenId}) [DEFAULT]`);
|
|
172
|
+
options[optionNumber.toString()] = async () => {
|
|
173
|
+
return {
|
|
174
|
+
action: 'use-existing',
|
|
175
|
+
selectedToken: duplicateCheck.userOwnedTokens[0]
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
optionNumber++;
|
|
179
|
+
}
|
|
180
|
+
// Option 2: Choose from all owned tokens (if more than one)
|
|
181
|
+
if (duplicateCheck.userOwnedTokens.length > 1) {
|
|
182
|
+
console.log(` ${optionNumber}. Choose from your tokens`);
|
|
183
|
+
options[optionNumber.toString()] = async () => {
|
|
184
|
+
console.log('\nYour tokens:');
|
|
185
|
+
duplicateCheck.userOwnedTokens.forEach((token, index) => {
|
|
186
|
+
console.log(` ${index + 1}. Token ID ${token.tokenId}`);
|
|
187
|
+
});
|
|
188
|
+
const tokenChoice = await promptUser('Enter token number: ');
|
|
189
|
+
const tokenIndex = parseInt(tokenChoice) - 1;
|
|
190
|
+
if (tokenIndex >= 0 && tokenIndex < duplicateCheck.userOwnedTokens.length) {
|
|
191
|
+
return {
|
|
192
|
+
action: 'use-existing',
|
|
193
|
+
selectedToken: duplicateCheck.userOwnedTokens[tokenIndex]
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
console.log('❌ Invalid selection');
|
|
198
|
+
return { action: 'cancel' };
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
optionNumber++;
|
|
202
|
+
}
|
|
203
|
+
// Option 3: Choose from tokens owned by others (with warning)
|
|
204
|
+
if (duplicateCheck.othersTokens.length > 0) {
|
|
205
|
+
console.log(` ${optionNumber}. Choose from tokens owned by others (⚠️ WARNING: You don't own these)`);
|
|
206
|
+
options[optionNumber.toString()] = async () => {
|
|
207
|
+
console.log('\n⚠️ WARNING: These tokens are owned by other users!');
|
|
208
|
+
console.log('Using someone else\'s token may have legal or ownership implications.');
|
|
209
|
+
console.log('\nAvailable tokens owned by others:');
|
|
210
|
+
duplicateCheck.othersTokens.forEach((token, index) => {
|
|
211
|
+
const shortOwner = `${token.owner.substring(0, 6)}...${token.owner.substring(38)}`;
|
|
212
|
+
console.log(` ${index + 1}. Token ID ${token.tokenId} (owned by ${shortOwner})`);
|
|
213
|
+
});
|
|
214
|
+
const tokenChoice = await promptUser('Enter token number: ');
|
|
215
|
+
const tokenIndex = parseInt(tokenChoice) - 1;
|
|
216
|
+
if (tokenIndex >= 0 && tokenIndex < duplicateCheck.othersTokens.length) {
|
|
217
|
+
return {
|
|
218
|
+
action: 'use-existing',
|
|
219
|
+
selectedToken: duplicateCheck.othersTokens[tokenIndex]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
console.log('❌ Invalid selection');
|
|
224
|
+
return { action: 'cancel' };
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
optionNumber++;
|
|
228
|
+
}
|
|
229
|
+
// Option: Mint new token
|
|
230
|
+
console.log(` ${optionNumber}. Mint a new token`);
|
|
231
|
+
options[optionNumber.toString()] = async () => {
|
|
232
|
+
return { action: 'mint-new' };
|
|
233
|
+
};
|
|
234
|
+
optionNumber++;
|
|
235
|
+
// Option: Skip tokenization
|
|
236
|
+
console.log(` ${optionNumber}. Skip tokenization (create ZIP without token metadata)`);
|
|
237
|
+
options[optionNumber.toString()] = async () => {
|
|
238
|
+
return { action: 'skip-tokenization' };
|
|
239
|
+
};
|
|
240
|
+
optionNumber++;
|
|
241
|
+
// Option: Cancel
|
|
242
|
+
console.log(` ${optionNumber}. Cancel`);
|
|
243
|
+
options[optionNumber.toString()] = async () => {
|
|
244
|
+
return { action: 'cancel' };
|
|
245
|
+
};
|
|
246
|
+
const choice = await promptUser('Enter your choice: ');
|
|
247
|
+
const selectedOption = options[choice];
|
|
248
|
+
if (selectedOption) {
|
|
249
|
+
return await selectedOption();
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
console.log('❌ Invalid choice');
|
|
253
|
+
return { action: 'cancel' };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=user-interaction.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions for NeoZip CLI
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatBytes = formatBytes;
|
|
7
|
+
exports.log = log;
|
|
8
|
+
exports.logError = logError;
|
|
9
|
+
exports.logDebug = logDebug;
|
|
10
|
+
exports.convertLineEndings = convertLineEndings;
|
|
11
|
+
exports.isTextFile = isTextFile;
|
|
12
|
+
exports.getTempDir = getTempDir;
|
|
13
|
+
/**
|
|
14
|
+
* Format bytes into human readable string
|
|
15
|
+
*/
|
|
16
|
+
function formatBytes(bytes) {
|
|
17
|
+
const units = ['B', 'KB', 'MB', 'GB'];
|
|
18
|
+
let i = 0;
|
|
19
|
+
let v = bytes;
|
|
20
|
+
while (v >= 1024 && i < units.length - 1) {
|
|
21
|
+
v /= 1024;
|
|
22
|
+
i++;
|
|
23
|
+
}
|
|
24
|
+
return `${v.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Logging function that respects quiet mode
|
|
28
|
+
*/
|
|
29
|
+
function log(message, options = { verbose: false, quiet: false }) {
|
|
30
|
+
if (!options.quiet) {
|
|
31
|
+
console.log(message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Error logging function (always shows errors)
|
|
36
|
+
*/
|
|
37
|
+
function logError(message) {
|
|
38
|
+
console.error(message);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Debug logging function (only shows in debug mode)
|
|
42
|
+
*/
|
|
43
|
+
function logDebug(message, options = { verbose: false, quiet: false }) {
|
|
44
|
+
if (options.debug && !options.quiet) {
|
|
45
|
+
console.log(`🐛 DEBUG: ${message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Convert line endings in text content
|
|
50
|
+
*/
|
|
51
|
+
function convertLineEndings(content, options) {
|
|
52
|
+
if (!options.toCrlf && !options.fromCrlf) {
|
|
53
|
+
return content;
|
|
54
|
+
}
|
|
55
|
+
// Convert to string for line ending processing
|
|
56
|
+
let text = content.toString('utf8');
|
|
57
|
+
if (options.toCrlf) {
|
|
58
|
+
// Convert LF to CRLF (Unix to Windows)
|
|
59
|
+
text = text.replace(/\r?\n/g, '\r\n');
|
|
60
|
+
}
|
|
61
|
+
else if (options.fromCrlf) {
|
|
62
|
+
// Convert CRLF to LF (Windows to Unix)
|
|
63
|
+
text = text.replace(/\r\n/g, '\n');
|
|
64
|
+
}
|
|
65
|
+
return Buffer.from(text, 'utf8');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check if a file is likely a text file based on extension
|
|
69
|
+
*/
|
|
70
|
+
function isTextFile(filename) {
|
|
71
|
+
const textExtensions = [
|
|
72
|
+
'.txt', '.md', '.json', '.js', '.ts', '.jsx', '.tsx', '.css', '.scss', '.sass', '.less',
|
|
73
|
+
'.html', '.htm', '.xml', '.yaml', '.yml', '.ini', '.cfg', '.conf', '.config',
|
|
74
|
+
'.py', '.rb', '.php', '.java', '.c', '.cpp', '.h', '.hpp', '.cs', '.go', '.rs',
|
|
75
|
+
'.sh', '.bash', '.zsh', '.fish', '.ps1', '.bat', '.cmd',
|
|
76
|
+
'.sql', '.r', '.m', '.pl', '.pm', '.t', '.pod',
|
|
77
|
+
'.log', '.diff', '.patch', '.gitignore', '.dockerignore',
|
|
78
|
+
'.env', '.properties', '.gradle', '.maven', '.pom',
|
|
79
|
+
'.dockerfile', '.makefile', '.cmake', '.ninja',
|
|
80
|
+
'.tex', '.rst', '.adoc', '.org', '.wiki'
|
|
81
|
+
];
|
|
82
|
+
const ext = filename.toLowerCase().substring(filename.lastIndexOf('.'));
|
|
83
|
+
return textExtensions.includes(ext);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get temporary directory for operations
|
|
87
|
+
*/
|
|
88
|
+
function getTempDir(options) {
|
|
89
|
+
if (options.tempPath) {
|
|
90
|
+
return options.tempPath;
|
|
91
|
+
}
|
|
92
|
+
// Use system temp directory
|
|
93
|
+
const os = require('os');
|
|
94
|
+
return os.tmpdir();
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=utils.js.map
|