@within-7/jetr 0.0.2 → 0.0.3
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/package.json +1 -1
- package/src/index.js +24 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -117,6 +117,10 @@ ${chalk.bold('.jetrignore:')}
|
|
|
117
117
|
Create a .jetrignore file in your project root to exclude files.
|
|
118
118
|
Uses the same syntax as .gitignore.
|
|
119
119
|
Run "jetr init" to generate one with common defaults.
|
|
120
|
+
|
|
121
|
+
${chalk.bold('.jetrkeep:')}
|
|
122
|
+
Create a .jetrkeep file to force-include files that match .jetrignore patterns.
|
|
123
|
+
Uses the same syntax as .gitignore. Patterns in .jetrkeep override .jetrignore.
|
|
120
124
|
`);
|
|
121
125
|
}
|
|
122
126
|
|
|
@@ -244,6 +248,18 @@ async function promptNewName() {
|
|
|
244
248
|
});
|
|
245
249
|
}
|
|
246
250
|
|
|
251
|
+
function loadKeepRules(targetDir) {
|
|
252
|
+
const keepFile = path.join(targetDir, '.jetrkeep');
|
|
253
|
+
if (!fs.existsSync(keepFile)) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const ig = ignore();
|
|
258
|
+
const content = fs.readFileSync(keepFile, 'utf-8');
|
|
259
|
+
ig.add(content);
|
|
260
|
+
return ig;
|
|
261
|
+
}
|
|
262
|
+
|
|
247
263
|
function loadIgnoreRules(targetDir) {
|
|
248
264
|
const ig = ignore();
|
|
249
265
|
const ignoreFile = path.join(targetDir, '.jetrignore');
|
|
@@ -256,7 +272,7 @@ function loadIgnoreRules(targetDir) {
|
|
|
256
272
|
return ig;
|
|
257
273
|
}
|
|
258
274
|
|
|
259
|
-
async function createZip(targetDir, ig, singleFile = null) {
|
|
275
|
+
async function createZip(targetDir, ig, keep, singleFile = null) {
|
|
260
276
|
const tmpFile = path.join(targetDir, `.jetr-upload-${Date.now()}.zip`);
|
|
261
277
|
|
|
262
278
|
return new Promise((resolve, reject) => {
|
|
@@ -306,13 +322,15 @@ async function createZip(targetDir, ig, singleFile = null) {
|
|
|
306
322
|
if (entry.name.startsWith('.jetr-upload-') && entry.name.endsWith('.zip')) {
|
|
307
323
|
continue;
|
|
308
324
|
}
|
|
309
|
-
if (entry.name === '.jetrignore' || entry.name === '.jetrrc') {
|
|
325
|
+
if (entry.name === '.jetrignore' || entry.name === '.jetrkeep' || entry.name === '.jetrrc') {
|
|
310
326
|
continue;
|
|
311
327
|
}
|
|
312
328
|
|
|
313
|
-
// Skip ignored files/directories
|
|
329
|
+
// Skip ignored files/directories (unless kept by .jetrkeep)
|
|
314
330
|
if (ig.ignores(relativePath) || ig.ignores(relativePath + '/')) {
|
|
315
|
-
|
|
331
|
+
if (!keep || !keep.ignores(relativePath)) {
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
316
334
|
}
|
|
317
335
|
|
|
318
336
|
// Skip symbolic links to avoid potential loops
|
|
@@ -485,13 +503,14 @@ export async function run() {
|
|
|
485
503
|
}
|
|
486
504
|
|
|
487
505
|
const ig = loadIgnoreRules(targetDir);
|
|
506
|
+
const keep = loadKeepRules(targetDir);
|
|
488
507
|
|
|
489
508
|
const spinner = ora('Packing files...').start();
|
|
490
509
|
let zipPath;
|
|
491
510
|
let fileCount;
|
|
492
511
|
|
|
493
512
|
try {
|
|
494
|
-
const result = await createZip(targetDir, ig, singleFile);
|
|
513
|
+
const result = await createZip(targetDir, ig, keep, singleFile);
|
|
495
514
|
zipPath = result.zipPath;
|
|
496
515
|
fileCount = result.fileCount;
|
|
497
516
|
const stats = fs.statSync(zipPath);
|