Skip to content

Commit f993049

Browse files
authored
[4] Build tools should preserve the original timestamps (#35310)
1 parent 8c96877 commit f993049

17 files changed

+45
-44
lines changed

build/build-modules-js/error-pages.es6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ module.exports.createErrorPages = async (options) => {
141141
}
142142

143143
if (!mediaExists) {
144-
await mkdir(dirname(`${RootPath}${options.settings.errorPages[name].destFile}`), { recursive: true });
144+
await mkdir(dirname(`${RootPath}${options.settings.errorPages[name].destFile}`), { recursive: true, mode: 0o755 });
145145
}
146146

147147
await writeFile(
148148
`${RootPath}${options.settings.errorPages[name].destFile}`,
149149
template,
150-
{ encoding: 'utf8' },
150+
{ encoding: 'utf8', mode: 0o644 },
151151
);
152152

153153
// eslint-disable-next-line no-console

build/build-modules-js/init/cleanup-media.es6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ module.exports.cleanVendors = async () => {
2424
// console.error('/media has been removed.');
2525

2626
// Recreate the media folder
27-
await mkdir(join(RootPath, 'media/vendor/debugbar'), { recursive: true });
27+
await mkdir(join(RootPath, 'media/vendor/debugbar'), { recursive: true, mode: 0o755 });
2828

2929
// Copy some assets from a PHP package
30-
await copy(join(RootPath, 'libraries/vendor/maximebf/debugbar/src/DebugBar/Resources'), join(RootPath, 'media/vendor/debugbar'));
30+
await copy(join(RootPath, 'libraries/vendor/maximebf/debugbar/src/DebugBar/Resources'), join(RootPath, 'media/vendor/debugbar'), { preserveTimestamps: true });
3131
await remove(join(RootPath, 'media/vendor/debugbar/vendor/font-awesome'));
3232
await remove(join(RootPath, 'media/vendor/debugbar/vendor/jquery'));
3333
} else {

build/build-modules-js/init/common/concat-files.es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ module.exports.concatFiles = async (files, output) => {
2222

2323
const res = await Promise.all(promises);
2424

25-
await writeFile(`${RootPath}/${output}`, res.join(' '));
25+
await writeFile(`${RootPath}/${output}`, res.join(' '), { encoding: 'utf8', mode: 0o644 });
2626
};

build/build-modules-js/init/common/copy-all-files.es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ const RootPath = process.cwd();
1515
module.exports.copyAllFiles = async (dirName, name, type) => {
1616
const folderName = dirName === '/' ? '/' : `/${dirName}`;
1717
await copy(join(RootPath, `node_modules/${name}/${folderName}`),
18-
join(RootPath, `media/vendor/${name.replace(/.+\//, '')}/${type}`));
18+
join(RootPath, `media/vendor/${name.replace(/.+\//, '')}/${type}`), { preserveTimestamps: true });
1919
};

build/build-modules-js/init/exemptions/codemirror.es6.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const xmlVersionStr = /(<version>)(.+)(<\/version>)/;
1515
module.exports.codeMirror = async (packageName, version) => {
1616
const itemvendorPath = join(RootPath, `media/vendor/${packageName}`);
1717
if (!await existsSync(itemvendorPath)) {
18-
await mkdir(itemvendorPath, { recursive: true });
19-
await mkdir(join(itemvendorPath, 'addon'));
20-
await mkdir(join(itemvendorPath, 'lib'));
21-
await mkdir(join(itemvendorPath, 'mode'));
22-
await mkdir(join(itemvendorPath, 'keymap'));
23-
await mkdir(join(itemvendorPath, 'theme'));
18+
await mkdir(itemvendorPath, { recursive: true, mode: 0o755 });
19+
await mkdir(join(itemvendorPath, 'addon'), { mode: 0o755 });
20+
await mkdir(join(itemvendorPath, 'lib'), { mode: 0o755 });
21+
await mkdir(join(itemvendorPath, 'mode'), { mode: 0o755 });
22+
await mkdir(join(itemvendorPath, 'keymap'), { mode: 0o755 });
23+
await mkdir(join(itemvendorPath, 'theme'), { mode: 0o755 });
2424
}
2525

2626
await copyAllFiles('addon', 'codemirror', 'addon');
@@ -65,5 +65,5 @@ module.exports.codeMirror = async (packageName, version) => {
6565
// Update the XML file for Codemirror
6666
let codemirrorXml = await readFile(`${RootPath}/plugins/editors/codemirror/codemirror.xml`, { encoding: 'utf8' });
6767
codemirrorXml = codemirrorXml.replace(xmlVersionStr, `$1${version}$3`);
68-
await writeFile(`${RootPath}/plugins/editors/codemirror/codemirror.xml`, codemirrorXml, { encoding: 'utf8' });
68+
await writeFile(`${RootPath}/plugins/editors/codemirror/codemirror.xml`, codemirrorXml, { encoding: 'utf8', mode: 0o644 });
6969
};

build/build-modules-js/init/exemptions/tinymce.es6.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const copyArrayFiles = async (dirName, files, name, type) => {
2525
const folderName = dirName === '/' ? '/' : `/${dirName}/`;
2626

2727
if (existsSync(`node_modules/${name}${folderName}${file}`)) {
28-
promises.push(copy(`node_modules/${name}${folderName}${file}`, `media/vendor/${name.replace(/.+\//, '')}${type ? `/${type}` : ''}/${file}`));
28+
promises.push(copy(`node_modules/${name}${folderName}${file}`, `media/vendor/${name.replace(/.+\//, '')}${type ? `/${type}` : ''}/${file}`, { preserveTimestamps: true }));
2929
}
3030
}
3131

@@ -39,13 +39,13 @@ module.exports.tinyMCE = async (packageName, version) => {
3939
const itemvendorPath = join(RootPath, `media/vendor/${packageName}`);
4040

4141
if (!await existsSync(itemvendorPath)) {
42-
await mkdir(itemvendorPath);
43-
await mkdir(join(itemvendorPath, 'icons'));
44-
await mkdir(join(itemvendorPath, 'plugins'));
45-
await mkdir(join(itemvendorPath, 'langs'));
46-
await mkdir(join(itemvendorPath, 'skins'));
47-
await mkdir(join(itemvendorPath, 'themes'));
48-
await mkdir(join(itemvendorPath, 'templates'));
42+
await mkdir(itemvendorPath, { mode: 0o755 });
43+
await mkdir(join(itemvendorPath, 'icons'), { mode: 0o755 });
44+
await mkdir(join(itemvendorPath, 'plugins'), { mode: 0o755 });
45+
await mkdir(join(itemvendorPath, 'langs'), { mode: 0o755 });
46+
await mkdir(join(itemvendorPath, 'skins'), { mode: 0o755 });
47+
await mkdir(join(itemvendorPath, 'themes'), { mode: 0o755 });
48+
await mkdir(join(itemvendorPath, 'templates'), { mode: 0o755 });
4949
}
5050

5151
await copyAllFiles('icons', 'tinymce', 'icons');
@@ -58,13 +58,13 @@ module.exports.tinyMCE = async (packageName, version) => {
5858
// Update the XML file for tinyMCE
5959
let tinyXml = await readFile(`${RootPath}/plugins/editors/tinymce/tinymce.xml`, { encoding: 'utf8' });
6060
tinyXml = tinyXml.replace(xmlVersionStr, `$1${version}$3`);
61-
await writeFile(`${RootPath}/plugins/editors/tinymce/tinymce.xml`, tinyXml, { encoding: 'utf8' });
61+
await writeFile(`${RootPath}/plugins/editors/tinymce/tinymce.xml`, tinyXml, { encoding: 'utf8', mode: 0o644 });
6262

6363
// Remove that sourcemap...
6464
let tinyWrongMap = await readFile(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, { encoding: 'utf8' });
6565
tinyWrongMap = tinyWrongMap.replace('/*# sourceMappingURL=skin.min.css.map */', '');
66-
await writeFile(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, tinyWrongMap, { encoding: 'utf8' });
66+
await writeFile(`${RootPath}/media/vendor/tinymce/skins/ui/oxide/skin.min.css`, tinyWrongMap, { encoding: 'utf8', mode: 0o644 });
6767

6868
// Restore our code on the vendor folders
69-
await copy(join(RootPath, 'build/media_source/vendor/tinymce/templates'), join(RootPath, 'media/vendor/tinymce/templates'));
69+
await copy(join(RootPath, 'build/media_source/vendor/tinymce/templates'), join(RootPath, 'media/vendor/tinymce/templates'), { preserveTimestamps: true });
7070
};

build/build-modules-js/init/localise-packages.es6.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const copyFilesTo = async (files, srcDir, destDir) => {
2020

2121
async function doTheCopy(source, dest) {
2222
await ensureDir(dirname(dest));
23-
await copy(source, dest);
23+
await copy(source, dest, { preserveTimestamps: true });
2424
}
2525

2626
// Copy each file
@@ -70,6 +70,7 @@ const resolvePackage = async (vendor, packageName, mediaVendorPath, options, reg
7070
await copy(
7171
`${join(RootPath, `node_modules/${packageName}`)}/${options.settings.vendors[packageName].licenseFilename}`,
7272
`${dest}/${options.settings.vendors[packageName].licenseFilename}`,
73+
{ preserveTimestamps: true },
7374
);
7475
}
7576

@@ -127,7 +128,7 @@ module.exports.localisePackages = async (options) => {
127128
const promises = [];
128129

129130
if (!await existsSync(mediaVendorPath)) {
130-
await mkdir(mediaVendorPath, { recursive: true });
131+
await mkdir(mediaVendorPath, { recursive: true, mode: 0o755 });
131132
}
132133

133134
// Loop to get some text for the package.json
@@ -144,6 +145,6 @@ module.exports.localisePackages = async (options) => {
144145
await writeFile(
145146
join(mediaVendorPath, 'joomla.asset.json'),
146147
JSON.stringify(registry, null, 2),
147-
{ encoding: 'utf8' },
148+
{ encoding: 'utf8', mode: 0o644 },
148149
);
149150
};

build/build-modules-js/init/minify-vendor.es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const minifyJS = async (file) => {
7575
await writeFile(
7676
newFile,
7777
minified,
78-
{ encoding: 'utf8' },
78+
{ encoding: 'utf8', mode: 0o644 },
7979
);
8080
};
8181

build/build-modules-js/init/patches.es6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ module.exports.patchPackages = async (options) => {
2121
ChosenJs = ChosenJs.replace('}).call(this);', ` document.AbstractChosen = AbstractChosen;
2222
document.Chosen = Chosen;
2323
}).call(this);`);
24-
await writeFile(chosenPath, ChosenJs, { encoding: 'utf8' });
24+
await writeFile(chosenPath, ChosenJs, { encoding: 'utf8', mode: 0o644 });
2525

2626
// Append initialising code to the end of the Short-and-Sweet javascript
2727
dest = join(mediaVendorPath, 'short-and-sweet');
2828
const shortandsweetPath = `${dest}/${options.settings.vendors['short-and-sweet'].js['dist/short-and-sweet.min.js']}`;
2929
let ShortandsweetJs = await readFile(shortandsweetPath, { encoding: 'utf8' });
3030
ShortandsweetJs = ShortandsweetJs.concat('shortAndSweet(\'textarea.charcount\', {counterClassName: \'small text-muted\'});');
31-
await writeFile(shortandsweetPath, ShortandsweetJs, { encoding: 'utf8' });
31+
await writeFile(shortandsweetPath, ShortandsweetJs, { encoding: 'utf8', mode: 0o644 });
3232
};

build/build-modules-js/init/recreate-media.es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ module.exports.recreateMediaFolder = async (options) => {
4848
return true;
4949
};
5050

51-
await copy(join(RootPath, 'build/media_source'), join(RootPath, 'media'), { filter: filterFunc });
51+
await copy(join(RootPath, 'build/media_source'), join(RootPath, 'media'), { filter: filterFunc, preserveTimestamps: true });
5252
};

0 commit comments

Comments
 (0)