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

Implement single Command per multiple packages for latestVersion #168

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion components/AppExport/AdvancedConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const AdvancedConfig = ({ refreshConfig, activeTab }) => {
"--override": false,
"-l": "",
"--force": false,
"--ignore-unavailable": false
"--ignore-unavailable": false,
"--singleCommand": true
});

const [ hiddenOptions, setHiddenOptions ] = useState([]);
Expand Down Expand Up @@ -76,6 +77,15 @@ const AdvancedConfig = ({ refreshConfig, activeTab }) => {
hiddenOptions={hiddenOptions}
labelText="Installation scope"
/>

<RadioConfig
id="--singleCommand"
defaultChecked={config["--singleCommand"]}
options={[{ id: "singleCmd", label: "Single Command for multiple pkgs" }, { id: "multiCmd", label: "One cmd per package" }]}
updateConfig={updateConfig}
labelText="Single Command"
hiddenOptions={[]}
/>

<CheckboxConfig id="-i" defaultChecked={config["-i"]} updateConfig={updateConfig} hiddenOptions={hiddenOptions} labelText="Request interactive installation; user input may be needed"/>
<CheckboxConfig id="-h" defaultChecked={config["-h"]} updateConfig={updateConfig} hiddenOptions={hiddenOptions} labelText="Request silent installation"/>
Expand Down
16 changes: 14 additions & 2 deletions components/AppExport/ExportApps.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const ExportApps = ({ apps, title, subtitle }) => {
if(!apps) return;

let installs = [];
let appsIndividualCommands = apps;

let advancedFilters = "";

Expand All @@ -54,14 +55,25 @@ const ExportApps = ({ apps, title, subtitle }) => {
if(filters["--scope"]) advancedFilters += ` --scope "${filters["--scope"]}"`;
}

apps.map((app) => {
const showSingleCmd = (filters["--singleCommand"] ?? 'singleCmd') == 'singleCmd'
if (showSingleCmd) {
let apps_ids = apps
.filter((app) => app.selectedVersion === app.latestVersion)
.map((app) => app._id)
installs.push(`winget install ${apps_ids.join(' ')} -e ${advancedFilters}`)
appsIndividualCommands = apps.filter((app) => app.selectedVersion !== app.latestVersion)
}

appsIndividualCommands.map((app) => {
installs.push(
`winget install --id=${app._id}${app.selectedVersion !== app.latestVersion ? ` -v "${app.selectedVersion}"` : ""} -e ${advancedFilters}`
);

return app;
});


// Concat command with no version specified (latsest by default), eventually in a single command
// with apps with version specified, each on its own command
let newBatchScript = installs.join(" && ");
let newPSScript = installs.join(" ; ");

Expand Down
3 changes: 2 additions & 1 deletion components/ListSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const ListSort = ({apps, defaultSort, onSort}) => {
);
}

function applySort(apps, sortChoice) {
function applySort(apps_, sortChoice) {
const apps = apps_.pageProps.data;
if (sortChoice === "name-asc") {
apps.sort((a, b) => a.name.localeCompare(b.name));
} else if (sortChoice === "name-desc") {
Expand Down
1 change: 1 addition & 0 deletions pages/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function Store({ data, error }) {
applySort(data, sortOrder);
setSort(sortOrder);
setApps(data);
// setApps(data.pageProps.data);

let handlePagination = (e) => {
if (e.keyCode === 39) {
Expand Down
2 changes: 1 addition & 1 deletion pages/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Generate() {
<h1>Your apps are ready to be installed.</h1>
<h3>Make sure you have Windows Package Manager installed :)</h3>

<ExportApps apps={apps} />
<ExportApps apps={selectedApps} />
</div>
<div className="art">
<img src="/assets/dl.svg" draggable={false} alt="download icon" />
Expand Down