Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable git extension in desktop app by default #2053

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions gulpfile.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ function cleanAll() {
]);
}

function cleanUnwantedFilesInDist() {
return del([
'dist/nls/*/expertTranslations.json',
'dist/nls/*/lastTranslated.json',
'dist/nls/*/lastTranslatedLocale.json',
'dist/nls/*/*.js.map'
]);
}

/**
* TODO: Release scripts to merge and min src js/css/html resources into dist.
* Links that might help:
Expand Down Expand Up @@ -380,11 +389,25 @@ const ALLOWED_EXTENSIONS_TO_CACHE = ["js", "html", "htm", "xml", "xhtml", "mjs",
const DISALLOWED_EXTENSIONS_TO_CACHE = ["map", "nuspec", "partial", "pre", "post",
"webmanifest", "rb", "ts"];

const EXCLUDE_PATTERNS_FROM_CACHE = [
/src\/nls\/.*expertTranslations\.json$/,
/src\/nls\/.*lastTranslated\.json$/,
/src\/nls\/.*lastTranslatedLocale\.json$/,
/extensions\/registry\/registry\.json$/
];

function _isCacheableFile(path) {
if(path.indexOf(".") === -1){
// no extension. dont cache
return false;
}
for (const pattern of EXCLUDE_PATTERNS_FROM_CACHE) {
if (pattern.test(path)) {
// If the path matches any excluded pattern, do not cache
return false;
}
}

let ext = path.split(".");
ext = ext[ext.length - 1];
if(ALLOWED_EXTENSIONS_TO_CACHE.includes(ext.toLocaleString())){
Expand Down Expand Up @@ -422,11 +445,23 @@ function _getFileDetails(path) {

function _computeCacheManifest(baseDir, filePaths) {
let manifest = {}, fileDetails, totalSize = 0;
let fileSizes = [];
for(let filePath of filePaths){
fileDetails = _getFileDetails(baseDir + "/" + filePath);
manifest[filePath] = fileDetails.hash;
totalSize += fileDetails.sizeBytes;
fileSizes.push({ path: filePath, sizeBytes: fileDetails.sizeBytes });
}

// Sort files by size in descending order
fileSizes.sort((a, b) => b.sizeBytes - a.sizeBytes);

// Log file sizes in descending order. uncomment to debug large cache size
// console.log("Files sorted by size (in bytes):");
// for (let file of fileSizes) {
// console.log(`${file.path}: ${file.sizeBytes} bytes`);
// }

totalSize = Math.round(totalSize/1024); // KB
console.log("Total size of cache in KB: ", totalSize);
if(totalSize > 75000){
Expand Down Expand Up @@ -717,14 +752,14 @@ exports.clean = series(cleanDist);
exports.reset = series(cleanAll);

exports.releaseDev = series(cleanDist, exports.buildDebug, makeBracketsConcatJS, _compileLessSrc,
makeDistAll, releaseDev,
makeDistAll, cleanUnwantedFilesInDist, releaseDev,
createDistCacheManifest, createDistTest, _cleanReleaseBuildArtefactsInSrc);
exports.releaseStaging = series(cleanDist, exports.build, makeBracketsConcatJS, _compileLessSrc,
makeDistNonJS, makeJSDist, makeJSPrettierDist, makeNonMinifyDist,
makeDistNonJS, makeJSDist, makeJSPrettierDist, makeNonMinifyDist, cleanUnwantedFilesInDist,
_renameBracketsConcatAsBracketsJSInDist, _patchMinifiedCSSInDistIndex, releaseStaging,
createDistCacheManifest, createDistTest, _cleanReleaseBuildArtefactsInSrc);
exports.releaseProd = series(cleanDist, exports.build, makeBracketsConcatJS, _compileLessSrc,
makeDistNonJS, makeJSDist, makeJSPrettierDist, makeNonMinifyDist,
makeDistNonJS, makeJSDist, makeJSPrettierDist, makeNonMinifyDist, cleanUnwantedFilesInDist,
_renameBracketsConcatAsBracketsJSInDist, _patchMinifiedCSSInDistIndex, releaseProd,
createDistCacheManifest, createDistTest, _cleanReleaseBuildArtefactsInSrc);
exports.releaseWebCache = series(makeDistWebCache);
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/default/DefaultExtensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"UrlCodeHints",
"HealthData"
],
"desktopOnly": [
"Git"
],
"warnExtensionStoreExtensions": {
"description": "list extension ids here that you want to show this warning in extension store: 'You may not need this extension. Phoenix comes built in with this feature.'",
"note": "This is only to for legacy extensions that havent been updated for a long time, remove flag unconditionally if instructed by the extension author, but inform of the issues in extension.",
Expand Down
18 changes: 16 additions & 2 deletions src/utils/ExtensionLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,22 @@ define(function (require, exports, module) {
UrlParams = require("utils/UrlParams").UrlParams,
NodeUtils = require("utils/NodeUtils"),
PathUtils = require("thirdparty/path-utils/path-utils"),
DefaultExtensionsList = JSON.parse(require("text!extensions/default/DefaultExtensions.json"))
.defaultExtensionsList;
DefaultExtensions = JSON.parse(require("text!extensions/default/DefaultExtensions.json"));

const desktopOnlyExtensions = DefaultExtensions.desktopOnly;
const DefaultExtensionsList = Phoenix.isNativeApp ?
[...DefaultExtensions.defaultExtensionsList, ...desktopOnlyExtensions]:
DefaultExtensions.defaultExtensionsList;

if(Phoenix.isTestWindow) {
// we dont load the heavy weight git extension by default for tests as huge number
// of tests written before git integration and too hard to fix those failing tests for now.
// we will just have new tests from git specific workflows.
const index = DefaultExtensionsList.indexOf("Git");
if(index !== -1) {
DefaultExtensionsList.splice(index, 1);
}
}

const customExtensionLoadPaths = {};

Expand Down
Loading