@within-7/jetr 0.0.1 → 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.
Files changed (2) hide show
  1. package/package.json +3 -1
  2. package/src/index.js +26 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@within-7/jetr",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "CLI tool for deploying static websites instantly",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -12,6 +12,8 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "test": "node bin/jetr.js --help",
15
+ "link": "npm link --force",
16
+ "unlink": "npm unlink -g @within-7/jetr",
15
17
  "publish:release": "node scripts/publish.cjs"
16
18
  },
17
19
  "repository": {
package/src/index.js CHANGED
@@ -12,7 +12,8 @@ import ora from 'ora';
12
12
  const __filename = fileURLToPath(import.meta.url);
13
13
  const __dirname = path.dirname(__filename);
14
14
 
15
- const API_URL = 'https://api-statics.within-7.com/api/deploy';
15
+ // const API_URL = 'https://api-statics.within-7.com/api/deploy';
16
+ const API_URL = 'https://api-statics.within-7.com/api/deploy/s3';
16
17
  const CONFIG_FILE = '.jetrrc';
17
18
 
18
19
  const DEFAULT_JETRIGNORE = `# Dependencies
@@ -116,6 +117,10 @@ ${chalk.bold('.jetrignore:')}
116
117
  Create a .jetrignore file in your project root to exclude files.
117
118
  Uses the same syntax as .gitignore.
118
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.
119
124
  `);
120
125
  }
121
126
 
@@ -243,6 +248,18 @@ async function promptNewName() {
243
248
  });
244
249
  }
245
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
+
246
263
  function loadIgnoreRules(targetDir) {
247
264
  const ig = ignore();
248
265
  const ignoreFile = path.join(targetDir, '.jetrignore');
@@ -255,7 +272,7 @@ function loadIgnoreRules(targetDir) {
255
272
  return ig;
256
273
  }
257
274
 
258
- async function createZip(targetDir, ig, singleFile = null) {
275
+ async function createZip(targetDir, ig, keep, singleFile = null) {
259
276
  const tmpFile = path.join(targetDir, `.jetr-upload-${Date.now()}.zip`);
260
277
 
261
278
  return new Promise((resolve, reject) => {
@@ -305,13 +322,15 @@ async function createZip(targetDir, ig, singleFile = null) {
305
322
  if (entry.name.startsWith('.jetr-upload-') && entry.name.endsWith('.zip')) {
306
323
  continue;
307
324
  }
308
- if (entry.name === '.jetrignore' || entry.name === '.jetrrc') {
325
+ if (entry.name === '.jetrignore' || entry.name === '.jetrkeep' || entry.name === '.jetrrc') {
309
326
  continue;
310
327
  }
311
328
 
312
- // Skip ignored files/directories
329
+ // Skip ignored files/directories (unless kept by .jetrkeep)
313
330
  if (ig.ignores(relativePath) || ig.ignores(relativePath + '/')) {
314
- continue;
331
+ if (!keep || !keep.ignores(relativePath)) {
332
+ continue;
333
+ }
315
334
  }
316
335
 
317
336
  // Skip symbolic links to avoid potential loops
@@ -484,13 +503,14 @@ export async function run() {
484
503
  }
485
504
 
486
505
  const ig = loadIgnoreRules(targetDir);
506
+ const keep = loadKeepRules(targetDir);
487
507
 
488
508
  const spinner = ora('Packing files...').start();
489
509
  let zipPath;
490
510
  let fileCount;
491
511
 
492
512
  try {
493
- const result = await createZip(targetDir, ig, singleFile);
513
+ const result = await createZip(targetDir, ig, keep, singleFile);
494
514
  zipPath = result.zipPath;
495
515
  fileCount = result.fileCount;
496
516
  const stats = fs.statSync(zipPath);