ultimate-jekyll-manager 0.0.217 → 0.0.219
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.
|
@@ -10,6 +10,7 @@ const GitHubCache = require('./utils/github-cache');
|
|
|
10
10
|
|
|
11
11
|
// Load package
|
|
12
12
|
const rootPathProject = Manager.getRootPath('project');
|
|
13
|
+
const ujmConfig = Manager.getUJMConfig();
|
|
13
14
|
|
|
14
15
|
// Settings
|
|
15
16
|
const CACHE_DIR = '.temp/cache/imagemin';
|
|
@@ -52,6 +53,18 @@ async function imagemin(complete) {
|
|
|
52
53
|
logger.log('Starting...');
|
|
53
54
|
Manager.logMemory(logger, 'Start');
|
|
54
55
|
|
|
56
|
+
// Skip in dev mode - only run during builds
|
|
57
|
+
if (!Manager.isBuildMode()) {
|
|
58
|
+
logger.log('⏭️ Skipping imagemin in dev mode');
|
|
59
|
+
return complete();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Skip if disabled in config
|
|
63
|
+
if (ujmConfig?.imagemin?.enabled === false) {
|
|
64
|
+
logger.log('⏭️ Skipping imagemin - disabled in ultimate-jekyll-manager.json');
|
|
65
|
+
return complete();
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
// Track timing
|
|
56
69
|
const startTime = Date.now();
|
|
57
70
|
|
|
@@ -164,13 +164,12 @@ class GitHubCache {
|
|
|
164
164
|
if (options.validFiles) {
|
|
165
165
|
const orphanCheck = await this.checkForOrphans(options.validFiles);
|
|
166
166
|
if (orphanCheck.hasOrphans) {
|
|
167
|
-
this.logger.log(`🗑️ Found ${orphanCheck.orphanedCount} orphaned files in cache
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (jetpack.exists(metaPath) && !files.includes(metaPath)) {
|
|
172
|
-
files.push(metaPath);
|
|
167
|
+
this.logger.log(`🗑️ Found ${orphanCheck.orphanedCount} orphaned files in cache, removing...`);
|
|
168
|
+
// Delete orphaned files locally — git add -A will pick up the deletions
|
|
169
|
+
for (const orphan of orphanCheck.orphanedFiles) {
|
|
170
|
+
jetpack.remove(path.join(this.cacheDir, orphan));
|
|
173
171
|
}
|
|
172
|
+
this.logger.log(`✅ Removed ${orphanCheck.orphanedCount} orphaned files`);
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
|
|
@@ -415,25 +414,21 @@ class GitHubCache {
|
|
|
415
414
|
execSync(`git remote add origin https://${process.env.GH_TOKEN}@github.com/${this.owner}/${this.repo}.git`, { cwd: this.cacheDir, stdio: 'ignore' });
|
|
416
415
|
execSync(`git checkout -b ${this.branchName}`, { cwd: this.cacheDir, stdio: 'ignore' });
|
|
417
416
|
} else if (!jetpack.exists(gitDir)) {
|
|
418
|
-
//
|
|
417
|
+
// No .git dir — init locally and fetch the branch ref so we can push incrementally
|
|
418
|
+
// (files are already here from the ZIP fetch, no need to clone)
|
|
419
419
|
this.logger.log(`📥 Initializing git in cache directory...`);
|
|
420
|
+
execSync('git init', { cwd: this.cacheDir, stdio: 'ignore' });
|
|
421
|
+
execSync(`git remote add origin https://${process.env.GH_TOKEN}@github.com/${this.owner}/${this.repo}.git`, { cwd: this.cacheDir, stdio: 'ignore' });
|
|
420
422
|
|
|
421
|
-
//
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
`git
|
|
430
|
-
{ stdio: 'ignore' }
|
|
431
|
-
);
|
|
432
|
-
|
|
433
|
-
// Restore backed up files (overwriting cloned files)
|
|
434
|
-
if (jetpack.exists(tempBackup)) {
|
|
435
|
-
jetpack.copy(tempBackup, this.cacheDir, { overwrite: true });
|
|
436
|
-
jetpack.remove(tempBackup);
|
|
423
|
+
// Fetch just the branch ref so git knows the remote history
|
|
424
|
+
try {
|
|
425
|
+
execSync(`git fetch --depth 1 origin ${this.branchName}`, { cwd: this.cacheDir, stdio: 'ignore' });
|
|
426
|
+
execSync(`git checkout -b ${this.branchName}`, { cwd: this.cacheDir, stdio: 'ignore' });
|
|
427
|
+
// Reset to the fetched ref to establish history, then overlay our files
|
|
428
|
+
execSync(`git reset origin/${this.branchName}`, { cwd: this.cacheDir, stdio: 'ignore' });
|
|
429
|
+
} catch (e) {
|
|
430
|
+
// Branch might not exist yet remotely — just create it locally
|
|
431
|
+
execSync(`git checkout -b ${this.branchName}`, { cwd: this.cacheDir, stdio: 'ignore' });
|
|
437
432
|
}
|
|
438
433
|
} else {
|
|
439
434
|
// Git dir exists, just pull latest
|
|
@@ -519,7 +514,7 @@ class GitHubCache {
|
|
|
519
514
|
async checkForOrphans(validFiles) {
|
|
520
515
|
const validSet = new Set(validFiles);
|
|
521
516
|
const cacheFiles = jetpack.find(this.cacheDir, {
|
|
522
|
-
matching: '**/*',
|
|
517
|
+
matching: ['**/*', '!.git/**'],
|
|
523
518
|
files: true,
|
|
524
519
|
directories: false
|
|
525
520
|
});
|
|
@@ -529,7 +524,7 @@ class GitHubCache {
|
|
|
529
524
|
|
|
530
525
|
cacheFiles.forEach(file => {
|
|
531
526
|
const relativePath = path.relative(this.cacheDir, file);
|
|
532
|
-
if (validSet.has(relativePath) || relativePath === 'meta.json') {
|
|
527
|
+
if (validSet.has(relativePath) || relativePath === 'meta.json' || relativePath === 'README.md') {
|
|
533
528
|
validCacheFiles.push(file);
|
|
534
529
|
} else {
|
|
535
530
|
orphanedFiles.push(relativePath);
|