ultimate-jekyll-manager 0.0.184 → 0.0.186

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.
@@ -1,7 +1,7 @@
1
1
  // Libraries
2
2
  const Manager = new (require('../build.js'));
3
3
  const logger = Manager.logger('clean');
4
- const path = require('path');
4
+ const { execSync } = require('child_process');
5
5
  const jetpack = require('fs-jetpack');
6
6
 
7
7
  // Load package
@@ -32,8 +32,12 @@ module.exports = async function (options) {
32
32
  try {
33
33
  // Loop through dirs
34
34
  dirsToClean.forEach((dir) => {
35
- // Remove
36
- jetpack.remove(dir);
35
+ // Remove (use rm -rf on Unix for speed, fallback to jetpack on Windows)
36
+ if (process.platform !== 'win32') {
37
+ execSync(`rm -rf ${dir}`, { stdio: 'ignore' });
38
+ } else {
39
+ jetpack.remove(dir);
40
+ }
37
41
 
38
42
  // Create empty dir
39
43
  jetpack.dir(dir);
@@ -43,6 +43,7 @@ module.exports = async function (options) {
43
43
  options.publishGitHubToken = options.publishGitHubToken !== 'false';
44
44
  options.updateGitHubPages = options.updateGitHubPages !== 'false';
45
45
  options.deduplicatePosts = options.deduplicatePosts !== 'false';
46
+ options.migrate = options.migrate !== 'false';
46
47
 
47
48
  // Log
48
49
  logger.log(`Welcome to ${package.name} v${package.version}!`);
@@ -56,6 +57,11 @@ module.exports = async function (options) {
56
57
  // Log current working directory
57
58
  await logCWD();
58
59
 
60
+ // Run migrations
61
+ if (options.migrate) {
62
+ await migrate();
63
+ }
64
+
59
65
  // Detect GitHub repository early so it's available to all tasks/functions
60
66
  await detectGitHubRepository(logger);
61
67
 
@@ -780,3 +786,59 @@ async function deduplicatePosts() {
780
786
  logger.log('✅ No duplicate posts found');
781
787
  }
782
788
  }
789
+
790
+ // Run migrations based on installed version
791
+ async function migrate() {
792
+ const installedVersion = project.devDependencies[package.name] || '0.0.0';
793
+ console.log('---installedVersion', installedVersion);
794
+ console.log('****', version.is(installedVersion, '<=', '0.0.184'));
795
+
796
+ // Skip if using local version
797
+ if (installedVersion.startsWith('file:')) {
798
+ return;
799
+ }
800
+
801
+ // Migrate hooks to nested structure (for versions <= 0.0.184)
802
+ if (version.is(installedVersion, '<=', '0.0.184')) {
803
+ await migrateHooksToNestedStructure();
804
+ }
805
+ }
806
+
807
+ // Migrate old hook files to new nested structure
808
+ async function migrateHooksToNestedStructure() {
809
+ const hooksDir = path.join(rootPathProject, 'hooks');
810
+
811
+ // Map of old file names to new paths
812
+ const migrations = [
813
+ { old: 'build:post.js', new: 'build/post.js' },
814
+ { old: 'build:pre.js', new: 'build/pre.js' },
815
+ { old: 'middleware:request.js', new: 'middleware/request.js' },
816
+ ];
817
+
818
+ let migratedCount = 0;
819
+
820
+ for (const migration of migrations) {
821
+ const oldPath = path.join(hooksDir, migration.old);
822
+ const newPath = path.join(hooksDir, migration.new);
823
+
824
+ // Check if old file exists
825
+ if (!jetpack.exists(oldPath)) {
826
+ continue;
827
+ }
828
+
829
+ // Check if new file already exists
830
+ if (jetpack.exists(newPath)) {
831
+ logger.warn(`⚠️ Cannot migrate ${migration.old}: ${migration.new} already exists`);
832
+ continue;
833
+ }
834
+
835
+ // Move the file
836
+ jetpack.move(oldPath, newPath);
837
+ logger.log(`✅ Migrated hook: ${migration.old} → ${migration.new}`);
838
+ migratedCount++;
839
+ }
840
+
841
+ if (migratedCount > 0) {
842
+ logger.log(`✅ Migrated ${migratedCount} hook file(s) to new nested structure`);
843
+ }
844
+ }
@@ -185,4 +185,4 @@ steps:
185
185
  </div>
186
186
  </section>
187
187
 
188
- {{ content | uj_content_format }}
188
+ {{ content | uj_content_format }}
@@ -77,7 +77,7 @@ async function jekyll(complete) {
77
77
  }
78
78
 
79
79
  // Run buildpre hook
80
- await hook('build:pre', index);
80
+ await hook('build/pre', index);
81
81
 
82
82
  // Build Jekyll
83
83
  const command = [
@@ -97,6 +97,8 @@ async function jekyll(complete) {
97
97
  Manager.isBuildMode() ? '' : '.temp/_config_browsersync.yml',
98
98
  // Add development config IF BUILD_MODE is not true
99
99
  Manager.isBuildMode() ? '' : `./node_modules/${package.name}/dist/config/_config_development.yml`,
100
+ // Add project-level dev config IF it exists and BUILD_MODE is not true
101
+ (!Manager.isBuildMode() && jetpack.exists('dist/_config.dev.yml')) ? 'dist/_config.dev.yml' : '',
100
102
  ].join(','),
101
103
  '--incremental',
102
104
  (Manager.isBuildMode() || argv.profile) ? ' --profile' : '',
@@ -120,7 +122,7 @@ async function jekyll(complete) {
120
122
  await fixBlogIndex();
121
123
 
122
124
  // Run buildpost hook
123
- await hook('build:post', index);
125
+ await hook('build/post', index);
124
126
 
125
127
  // Create build JSON with runtime config
126
128
  await createBuildJSON();
@@ -100,9 +100,15 @@ function sass(complete) {
100
100
  // So we can use "@use 'ultimate-jekyll-manager' as *;"
101
101
  path.resolve(rootPathPackage, 'dist/assets/css'),
102
102
 
103
- // So we can use "@use 'themes/{theme}' as *;" in the project
103
+ // Project theme FIRST (higher priority) - allows consuming projects to define custom themes
104
+ path.resolve(rootPathProject, 'src/assets/themes', config.theme.id),
105
+
106
+ // UJM theme as fallback - for built-in themes like "classy", "bootstrap"
104
107
  path.resolve(rootPathPackage, 'dist/assets/themes', config.theme.id),
105
108
 
109
+ // UJM themes root - allows themes to reference sibling themes (e.g., ../bootstrap)
110
+ path.resolve(rootPathPackage, 'dist/assets/themes'),
111
+
106
112
  // So we can load _pages.scss from the project's dist
107
113
  path.resolve(rootPathProject, 'dist/assets/css'),
108
114
 
@@ -132,10 +138,14 @@ function sass(complete) {
132
138
  // Exclude test pages that include components we don't normally use (would prevent PurgeCSS from working)
133
139
  `!${rootPathPackage}/dist/defaults/**/pages/test/**/*.{html,liquid,md}`,
134
140
 
135
- // Include ONLY the active theme's files
141
+ // Include ONLY the active theme's files from UJM
136
142
  `${rootPathPackage}/dist/defaults/**/_includes/themes/${config.theme.id}/**/*.{html,liquid,md}`,
137
143
  `${rootPathPackage}/dist/defaults/**/_layouts/themes/${config.theme.id}/**/*.{html,liquid,md}`,
138
144
 
145
+ // Project theme layouts/includes (for project-defined themes)
146
+ `src/_layouts/themes/${config.theme.id}/**/*.{html,liquid,md}`,
147
+ `src/_includes/themes/${config.theme.id}/**/*.{html,liquid,md}`,
148
+
139
149
  // Project HTML
140
150
  'src/**/*.{html,liquid,md}',
141
151
  'dist/**/*.{html,liquid,md}',
@@ -144,7 +154,10 @@ function sass(complete) {
144
154
  `${rootPathPackage}/dist/assets/js/**/*.js`,
145
155
  `${rootPathPackage}/node_modules/web-manager/**/*.js`,
146
156
 
147
- // Theme JS
157
+ // Project theme JS (for project-defined themes)
158
+ `src/assets/themes/${config.theme.id}/**/*.js`,
159
+
160
+ // UJM theme JS
148
161
  `${rootPathPackage}/dist/assets/themes/${config.theme.id}/**/*.js`,
149
162
 
150
163
  // Project JS
@@ -277,7 +277,7 @@ async function processRequestMiddleware(req, res, next) {
277
277
  }
278
278
 
279
279
  // Run middleware:request hook to allow custom URL rewriting
280
- await hook('middleware:request', { req, res, pathname });
280
+ await hook('middleware/request', { req, res, pathname });
281
281
 
282
282
  // Process the post request
283
283
  if (pathname.match(/\/_process/)) {
@@ -140,8 +140,13 @@ function getSettings() {
140
140
  '__main_assets__': path.resolve(rootPathPackage, 'dist/assets'),
141
141
  '__project_assets__': path.resolve(process.cwd(), 'src/assets'),
142
142
 
143
- // For importing the theme
144
- '__theme__': path.resolve(rootPathPackage, 'dist/assets/themes', config.theme.id),
143
+ // For importing the theme - project theme takes priority over UJM theme
144
+ '__theme__': (() => {
145
+ const projectThemePath = path.resolve(rootPathProject, 'src/assets/themes', config.theme.id);
146
+ const ujmThemePath = path.resolve(rootPathPackage, 'dist/assets/themes', config.theme.id);
147
+ // Use project theme if it exists, otherwise fall back to UJM theme
148
+ return jetpack.exists(projectThemePath) ? projectThemePath : ujmThemePath;
149
+ })(),
145
150
  },
146
151
  // Add module resolution paths for local web-manager
147
152
  modules: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-jekyll-manager",
3
- "version": "0.0.184",
3
+ "version": "0.0.186",
4
4
  "description": "Ultimate Jekyll dependency manager",
5
5
  "main": "dist/index.js",
6
6
  "exports": {