Skip to content
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
4 changes: 2 additions & 2 deletions code/+matbox/+codespell/+internal/addToIgnore.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function addToIgnore(word, ignoreFilePath)

[~, ~, fileExt] = fileparts(ignoreFilePath);

if strcmp(fileExt, '.codespell_ignore')
Expand All @@ -9,7 +9,7 @@ function addToIgnore(word, ignoreFilePath)
else
fileContent = '';
end

elseif strcmp(fileExt, '.codespellrc')
if isfile(ignoreFilePath)
fileContent = fileread(ignoreFilePath);
Expand Down
2 changes: 1 addition & 1 deletion code/+matbox/+py/getPackageInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
% Postprocess Requires, Required_by
packageInfo.Requires = split(packageInfo.Requires, ', ');
packageInfo.Required_by = split(packageInfo.Required_by, ', ');

if ~ismissing( options.Field )
packageInfo = packageInfo.(options.Field);
end
Expand Down
4 changes: 2 additions & 2 deletions code/+matbox/+py/getPythonExecutable.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

% Todo: What if MATLAB release is older than R2019b when pyenv was
% introduced?

pythonInfo = pyenv;

if pythonInfo.Version == ""
error("MatBox:PythonNotInstalled", "Python not installed.")
end
Expand Down
2 changes: 1 addition & 1 deletion code/+matbox/+py/pipInstall.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function pipInstall(packageName, options)

arguments
packageName (1,1) string
options.Update (1,1) logical = false
options.Update (1,1) logical = false
end

pythonExecutable = matbox.py.getPythonExecutable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
numAddons = numel(fexURI);

fieldNames = ["Name", "Identifier", "EarliestVersion", "LatestVersion", "DownloadURL"];

S = cell2struct( repmat({""}, 1, numel(fieldNames)), cellstr(fieldNames), 2 );
S = repmat(S, 1, numAddons);

for iAddon = 1:numAddons
[addonUuid, version] = matbox.setup.internal.fex.parseFileExchangeURI(fexURI(iAddon));

addonMetadata = matbox.setup.internal.fex.getAddonMetadata(addonUuid);

S(iAddon).Name = addonMetadata.name;
Expand Down
4 changes: 2 additions & 2 deletions code/+matbox/+setup/+internal/+fex/isToolboxInstalled.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function [tf, versionString, toolboxFolder] = isToolboxInstalled(toolboxIdentifier, versionString)

arguments
toolboxIdentifier (1,1) string
versionString (1,1) string = missing
end

import matlab.internal.addons.util.retrieveInstallationFolderForAddOn

tf = false;
Expand Down
12 changes: 6 additions & 6 deletions code/+matbox/+setup/+internal/+fex/parseFileExchangeURI.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
%
% NB: This function relies on an undocumented api, and might break in the
% future.

arguments
uri (1,:) string
end

FEX_API_URL = "https://addons.mathworks.com/registry/v1/";

packageUuid = repmat("", 1, numel(uri));
version = repmat("latest", 1, numel(uri)); % Initialize default value

for i = 1:numel(uri)

splitUri = strsplit(uri(i), '/');

packageNumber = regexp(splitUri{2}, '\d*(?=-)', 'match', 'once');
try
packageInfo = webread(FEX_API_URL + num2str(packageNumber));
Expand All @@ -29,7 +29,7 @@
rethrow(ME)
end
end

if numel(splitUri) == 3
version = string( splitUri{3} );
assert( any(strcmp(packageInfo.versions, version) ), ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

API_BASE_URL = sprintf("https://api.github.com/repos/%s/%s", ...
options.Owner, repositoryName);

apiURL = strjoin( [API_BASE_URL, "commits", options.BranchName], '/');

% Get info about latest commit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

% Build the API URL
apiUrl = sprintf('https://api.github.com/repos/%s/%s', owner, repoName);

requestOpts = matbox.setup.internal.github.api.getGithubWebOptions();
requestOpts.Timeout = 10;
requestOpts.ContentType = 'json';
Expand Down
10 changes: 5 additions & 5 deletions code/+matbox/+setup/+internal/+github/+api/getGithubWebOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
%
% Outputs:
% options - weboptions object with authentication headers if token is available

arguments
customHeaders = {}
end

% Get GITHUB_TOKEN from environment variables
token = getenv('GITHUB_TOKEN');

% Initialize options
options = weboptions('UserAgent', 'MATLAB WebClient');

% Add custom headers if provided
if ~isempty(customHeaders)
options.HeaderFields = customHeaders;
end

% Add authentication header if token is available
if ~isempty(token)
if isempty(options.HeaderFields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
repositoryOwner (1,1) string
end
apiUrl = sprintf("https://api.github.com/repos/%s/%s/license", repositoryOwner, repositoryName);

% Get web options with GitHub authentication if available
options = matbox.setup.internal.github.api.getGithubWebOptions();

try
data = webread(apiUrl, options);
htmlUrl = data.download_url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
%
% Outputs:
% reposStruct - A struct array with fields 'name' and 'visibility'.

arguments
organizationName (1,1) string
end

% Get GITHUB_TOKEN from environment variables
token = getenv('GITHUB_TOKEN');

if isempty(token)
warning('GITHUB_TOKEN environment variable is not set. Retrieving public repositories');
end

organizationName = char(organizationName);

% GitHub API endpoint for organization repositories
url = ['https://api.github.com/orgs/' organizationName '/repos'];

% Get web options with GitHub authentication if available
options = matbox.setup.internal.github.api.getGithubWebOptions();
options.Timeout = 15;
options.ContentType = 'json';

% Fetch repositories information from GitHub
data = webread(url, options);

% Initialize an empty struct
reposStruct = struct('name', {}, 'visibility', {});

% Parse the data
for i = 1:numel(data)
reposStruct(i).name = data(i).name; % Repository name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
% - Platform Platform to download the additional software package for, specified as "win64", "maci64", or "glnxa64"
% - DownloadURL URL to download the additional software package, specified as a string scalar or character vector
% - LicenseURL URL for the software package license file, specified as a string scalar or character vector

arguments
githubRepo (1,:) string
end
Expand Down
6 changes: 3 additions & 3 deletions code/+matbox/+setup/+internal/+github/parseRepositoryURL.m
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
function [owner, repositoryName, branchName] = parseRepositoryURL(repoUrl)
% parseRepositoryURL - Extract owner, repository name and branch name from URL

arguments
repoUrl (1,1) matlab.net.URI
end

if repoUrl.Host ~= "github.com"
error("MATBOX:GitHub:InvalidRepositoryURL", ...
"Please make sure the repository URL's host name is 'github.com'")
end

pathNames = repoUrl.Path;
pathNames( cellfun('isempty', pathNames) ) = [];

Expand Down
6 changes: 3 additions & 3 deletions code/+matbox/+setup/+internal/+github/readCommitHash.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
% readCommitHash - Reads the commit hash from a specified repository folder
%
% Syntax:
% commitHash = readCommitHash(repositoryFolderPath)
% This function reads the commit hash from a file named '.commit_hash'
% commitHash = readCommitHash(repositoryFolderPath)
% This function reads the commit hash from a file named '.commit_hash'
% located in the specified repository folder.
%
% Input Arguments:
% repositoryFolderPath - A string specifying the path to the repository
% repositoryFolderPath - A string specifying the path to the repository
% folder from which the commit hash will be read.
%
% Output Arguments:
Expand Down
4 changes: 2 additions & 2 deletions code/+matbox/+setup/+internal/+github/writeCommitHash.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function writeCommitHash(repositoryFolderPath, repositoryName, owner, branchName)
% writeCommitHash - Writes the current commit hash of a repository to file.
% writeCommitHash - Writes the current commit hash of a repository to file.
%
% Syntax:
% writeCommitHash(repositoryFolderPath, repositoryName, owner, branchName)
Expand All @@ -12,7 +12,7 @@ function writeCommitHash(repositoryFolderPath, repositoryName, owner, branchName
%
% See also:
% matbox.setup.internal.github.api.getCurrentCommitID
% matbox.setup.internal.github.readCommitHash
% matbox.setup.internal.github.readCommitHash

arguments
repositoryFolderPath (1,1) string
Expand Down
8 changes: 4 additions & 4 deletions code/+matbox/+setup/+internal/+pathtool/lookForRepository.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function [exists, repositoryPath] = lookForRepository(repositoryName, branchName)

exists = false;
repositoryPath = "";

% Get the full MATLAB search path:
pathList = strsplit(path, pathsep);

Expand Down Expand Up @@ -48,7 +48,7 @@
end
end
repositoryPath = string(repositoryPath);

% Make sure folder exists
if ~isempty(char(repositoryPath)) && ~isfolder(repositoryPath)
warning("Repository was found on MATLAB's search path, but folder does not exist")
Expand All @@ -57,7 +57,7 @@
end

if repositoryPath == ""; return; end

% Check if folder contains expected files...
L = dir( repositoryPath );
assert(contains('README.md', {L.name}, 'IgnoreCase', true) && ...
Expand Down
6 changes: 3 additions & 3 deletions code/+matbox/+setup/+internal/+utility/filewrite.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function filewrite(filePath, textStr)

folderPath = fileparts(filePath);

if ~exist(folderPath, 'dir')
mkdir(folderPath)
end

fid = fopen(filePath, 'w');
fwrite(fid, textStr);
fclose(fid);
Expand Down
8 changes: 4 additions & 4 deletions code/+matbox/+setup/+internal/addDependenciesToPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function addDependenciesToPath(toolboxFolder, options)
toolboxFolder (1,1) string {mustBeFolder}
options.InstallationLocation (1,1) string = matbox.setup.internal.getDefaultAddonFolder()
end

reqs = matbox.setup.internal.getRequirements(toolboxFolder);

for i = 1:numel(reqs)
Expand All @@ -13,7 +13,7 @@ function addDependenciesToPath(toolboxFolder, options)
% Todo.
% [repoUrl, branchName] = parseGitHubUrl(reqs(i).URI);
% matbox.setup.internal.installGithubRepository( repoUrl, branchName )

case 'FileExchange'
[packageUuid, version] = matbox.setup.internal.fex.parseFileExchangeURI( reqs(i).URI );
[isInstalled, version] = matbox.setup.internal.fex.isToolboxInstalled(packageUuid, version);
Expand All @@ -24,7 +24,7 @@ function addDependenciesToPath(toolboxFolder, options)
continue
end
end

% Add all addons in the package's addon folder to path
addonLocation = options.InstallationLocation;
addonListing = dir(addonLocation);
Expand All @@ -39,7 +39,7 @@ function addDependenciesToPath(toolboxFolder, options)

folderPath = fullfile(addonListing(i).folder, addonListing(i).name);
startupFile = matbox.setup.internal.findStartupFile(folderPath);

if ~isempty(startupFile)
run( startupFile )
else
Expand Down
12 changes: 6 additions & 6 deletions code/+matbox/+setup/+internal/downloadZippedGithubRepo.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
if isa(updateFlag, 'char') && strcmp(updateFlag, 'update')
updateFlag = true;
end

% Create a temporary path for storing the downloaded file.
[~, ~, fileType] = fileparts(githubUrl);
tempFilepath = [tempname, fileType];

% Get web options with GitHub authentication if available
options = matbox.setup.internal.github.api.getGithubWebOptions();

% Download the file containing the addon toolbox
try
tempFilepath = websave(tempFilepath, githubUrl, options);
Expand All @@ -32,12 +32,12 @@
if endsWith(unzippedFolder, filesep)
unzippedFolder = unzippedFolder(1:end-1);
end

[~, repoFolderName] = fileparts(unzippedFolder);
targetFolder = fullfile(targetFolder, repoFolderName);

if updateFlag && isfolder(targetFolder)

% Delete current version
if isfolder(targetFolder)
if contains(path, fullfile(targetFolder, filesep))
Expand All @@ -56,7 +56,7 @@
end

movefile(unzippedFolder, targetFolder);

% Delete the temp zip file
clear fileCleanupObj

Expand Down
Loading
Loading