@epublishing/grunt-epublishing 1.2.6 → 1.2.8
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/epublishing-grunt-epublishing-1.2.8.tgz +0 -0
- package/lib/cli.js +28 -1
- package/lib/webpack.config.js +18 -0
- package/package.json +1 -1
|
Binary file
|
package/lib/cli.js
CHANGED
|
@@ -60,10 +60,12 @@ function printOptions(options) {
|
|
|
60
60
|
/**
|
|
61
61
|
* Run npm install in jade and jade child gem directories.
|
|
62
62
|
* Installs packages from each gem's package.json (excluding site).
|
|
63
|
+
* Skips if package-lock.json hasn't changed since the last install.
|
|
63
64
|
* @param {Object} config - Build configuration with paths
|
|
64
65
|
* @param {Object} options - Build options
|
|
65
66
|
*/
|
|
66
67
|
async function runNpmInstall(config, options) {
|
|
68
|
+
const crypto = require('crypto');
|
|
67
69
|
const Resolver = require('@epublishing/jade-resolver');
|
|
68
70
|
const paths = config.paths || {};
|
|
69
71
|
// Build paths object with ONLY jade and jade child gem directories (absolute paths)
|
|
@@ -89,10 +91,25 @@ async function runNpmInstall(config, options) {
|
|
|
89
91
|
|
|
90
92
|
for (const dir of dirs) {
|
|
91
93
|
const basename = path.basename(dir);
|
|
94
|
+
const lockFile = path.join(dir, 'package-lock.json');
|
|
95
|
+
const hasLock = fs.existsSync(lockFile);
|
|
96
|
+
const stampFile = path.join(dir, 'node_modules', '.package-lock.installed');
|
|
97
|
+
|
|
98
|
+
// Skip reinstall if package-lock.json hasn't changed since last npm ci
|
|
99
|
+
if (hasLock && fs.existsSync(stampFile)) {
|
|
100
|
+
const currentHash = crypto.createHash('sha1').update(fs.readFileSync(lockFile)).digest('hex');
|
|
101
|
+
const stampHash = fs.readFileSync(stampFile, 'utf8').trim();
|
|
102
|
+
if (currentHash === stampHash) {
|
|
103
|
+
if (options.verbose) {
|
|
104
|
+
console.log(chalk.gray(` Skipping npm install in ${basename} (package-lock.json unchanged)`));
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
92
110
|
const spinner = ora(`Installing npm modules in ${basename}...`).start();
|
|
93
111
|
|
|
94
112
|
try {
|
|
95
|
-
const hasLock = fs.existsSync(path.join(dir, 'package-lock.json'));
|
|
96
113
|
const cmd = hasLock ? 'ci' : 'install';
|
|
97
114
|
await new Promise((resolve, reject) => {
|
|
98
115
|
const proc = spawn('npm', [cmd], {
|
|
@@ -114,6 +131,16 @@ async function runNpmInstall(config, options) {
|
|
|
114
131
|
reject(err);
|
|
115
132
|
});
|
|
116
133
|
});
|
|
134
|
+
|
|
135
|
+
// Write stamp so we can skip next time if package-lock.json is unchanged
|
|
136
|
+
if (hasLock) {
|
|
137
|
+
try {
|
|
138
|
+
const hash = crypto.createHash('sha1').update(fs.readFileSync(lockFile)).digest('hex');
|
|
139
|
+
fs.writeFileSync(stampFile, hash + '\n');
|
|
140
|
+
} catch {
|
|
141
|
+
// Stamp write failure is non-fatal — we'll just reinstall next time
|
|
142
|
+
}
|
|
143
|
+
}
|
|
117
144
|
} catch (err) {
|
|
118
145
|
throw err;
|
|
119
146
|
}
|
package/lib/webpack.config.js
CHANGED
|
@@ -102,12 +102,30 @@ function createWebpackConfig(config, options = {}) {
|
|
|
102
102
|
resolveAlias['jade-engine'] = path.resolve(paths.jade, paths.js_src || 'app/js', 'jade-engine.js');
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// Read jade gem version from lib/jade/version.rb (Ruby is the source of truth)
|
|
106
|
+
let jadeVersion = 'unknown';
|
|
107
|
+
if (paths.jade && typeof paths.jade === 'string') {
|
|
108
|
+
try {
|
|
109
|
+
const versionRb = fs.readFileSync(
|
|
110
|
+
path.join(paths.jade, 'lib/jade/version.rb'),
|
|
111
|
+
'utf8',
|
|
112
|
+
);
|
|
113
|
+
const major = versionRb.match(/MAJOR\s*=\s*['"]?(\d+)['"]?/)?.[1];
|
|
114
|
+
const minor = versionRb.match(/MINOR\s*=\s*['"]?([\w.]+)['"]?/)?.[1];
|
|
115
|
+
const build = versionRb.match(/BUILD\s*=\s*['"]?([\w.]+)['"]?/)?.[1];
|
|
116
|
+
if (major && minor && build) jadeVersion = `${major}.${minor}.${build}`;
|
|
117
|
+
} catch {
|
|
118
|
+
// Fall through to 'unknown' — never fail the build over a version banner
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
105
122
|
// Build plugins array
|
|
106
123
|
const plugins = [
|
|
107
124
|
// Environment variables
|
|
108
125
|
new webpack.DefinePlugin({
|
|
109
126
|
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
|
|
110
127
|
'process.env.DEBUG': JSON.stringify(process.env.DEBUG || false),
|
|
128
|
+
__JADE_VERSION__: JSON.stringify(jadeVersion),
|
|
111
129
|
}),
|
|
112
130
|
|
|
113
131
|
// Limit moment.js locales to en
|
package/package.json
CHANGED