mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: Fix generating tray icons and downloading binaries on windows
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
30f794d66d
commit
289d62caaa
@ -23,17 +23,32 @@ const options = arg({
|
|||||||
"--base-dir": String,
|
"--base-dir": String,
|
||||||
});
|
});
|
||||||
|
|
||||||
const pathToPackage = options["--package"];
|
type Options = typeof options;
|
||||||
const pathToBaseDir = options["--base-dir"];
|
|
||||||
|
|
||||||
if (typeof pathToPackage !== "string") {
|
const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[Key]> => {
|
||||||
throw new Error("--package is required");
|
const raw = options[key];
|
||||||
|
|
||||||
|
if (raw === undefined) {
|
||||||
|
console.error(`missing ${key} option`);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof pathToBaseDir !== "string") {
|
return raw;
|
||||||
throw new Error("--base-dir is required");
|
};
|
||||||
|
|
||||||
|
const joinWithInitCwd = (relativePath: string): string => {
|
||||||
|
const { INIT_CWD } = process.env;
|
||||||
|
|
||||||
|
if (!INIT_CWD) {
|
||||||
|
return relativePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return path.join(INIT_CWD, relativePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
const pathToPackage = joinWithInitCwd(assertOption("--package"));
|
||||||
|
const pathToBaseDir = joinWithInitCwd(assertOption("--base-dir"));
|
||||||
|
|
||||||
function setTimeoutFor(controller: AbortController, timeout: number): void {
|
function setTimeoutFor(controller: AbortController, timeout: number): void {
|
||||||
const handle = setTimeout(() => controller.abort(), timeout);
|
const handle = setTimeout(() => controller.abort(), timeout);
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ type Options = typeof options;
|
|||||||
const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[Key]> => {
|
const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[Key]> => {
|
||||||
const raw = options[key];
|
const raw = options[key];
|
||||||
|
|
||||||
if (!raw) {
|
if (raw === undefined) {
|
||||||
console.error(`missing ${key} option`);
|
console.error(`missing ${key} option`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@ -31,11 +31,21 @@ const assertOption = <Key extends keyof Options>(key: Key): NonNullable<Options[
|
|||||||
return raw;
|
return raw;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const joinWithInitCwd = (relativePath: string): string => {
|
||||||
|
const { INIT_CWD } = process.env;
|
||||||
|
|
||||||
|
if (!INIT_CWD) {
|
||||||
|
return relativePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.join(INIT_CWD, relativePath);
|
||||||
|
};
|
||||||
|
|
||||||
const size = options["--output-size"] ?? 16;
|
const size = options["--output-size"] ?? 16;
|
||||||
const inputFile = assertOption("--input");
|
const inputFile = joinWithInitCwd(assertOption("--input"));
|
||||||
const outputFolder = assertOption("--output");
|
const outputFolder = joinWithInitCwd(assertOption("--output"));
|
||||||
const noticeFile = assertOption("--notice-icon");
|
const noticeFile = joinWithInitCwd(assertOption("--notice-icon"));
|
||||||
const spinnerFile = assertOption("--spinner-icon");
|
const spinnerFile = joinWithInitCwd(assertOption("--spinner-icon"));
|
||||||
|
|
||||||
const getSvgStyling = (colouring: "dark" | "light") => (
|
const getSvgStyling = (colouring: "dark" | "light") => (
|
||||||
`
|
`
|
||||||
|
|||||||
@ -33,8 +33,8 @@
|
|||||||
"dev:main": "cross-env NODE_ENV=development webpack --config webpack/main.ts --progress --watch",
|
"dev:main": "cross-env NODE_ENV=development webpack --config webpack/main.ts --progress --watch",
|
||||||
"dev:renderer": "cross-env NODE_ENV=development ts-node ./webpack/dev-server.ts",
|
"dev:renderer": "cross-env NODE_ENV=development ts-node ./webpack/dev-server.ts",
|
||||||
"test:integration": "jest -xyz --runInBand --modulePaths=[\"<rootDir>/integration/\"];",
|
"test:integration": "jest -xyz --runInBand --modulePaths=[\"<rootDir>/integration/\"];",
|
||||||
"build:tray-icons": "npm run --workspace @k8slens/generate-tray-icons generate -- --output $INIT_CWD/static/build/tray --input $INIT_CWD/../core/src/renderer/components/icon/logo-lens.svg --notice-icon $INIT_CWD/../core/src/renderer/components/icon/notice.svg --spinner-icon $INIT_CWD/../core/src/renderer/components/icon/arrow-spinner.svg",
|
"build:tray-icons": "npm run --workspace @k8slens/generate-tray-icons generate -- --output static/build/tray --input ../core/src/renderer/components/icon/logo-lens.svg --notice-icon ../core/src/renderer/components/icon/notice.svg --spinner-icon ../core/src/renderer/components/icon/arrow-spinner.svg",
|
||||||
"download:binaries": "npm run --workspace @k8slens/ensure-binaries ensure -- --package $INIT_CWD/package.json --base-dir $INIT_CWD/binaries/client",
|
"download:binaries": "npm run --workspace @k8slens/ensure-binaries ensure -- --package package.json --base-dir binaries/client",
|
||||||
"postinstall": "electron-rebuild"
|
"postinstall": "electron-rebuild"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user