1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Merge branch 'stop-updating' into jbirlingmair/add-no-update-channel

# Conflicts:
#	README.md
#	package.json
#	src/common/user-store/preferences-helpers.ts
#	src/common/user-store/user-store.ts
#	src/main/app-updater.ts
#	yarn.lock
This commit is contained in:
JoelTrain 2022-09-01 09:57:56 -05:00
commit a5d192af16
No known key found for this signature in database
GPG Key ID: E7720A2908E42F0A
23 changed files with 252 additions and 26 deletions

106
.github/workflows/build-for-windows.yml vendored Normal file
View File

@ -0,0 +1,106 @@
# This is a basic workflow to help you get started with Actions
name: Build For Windows
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: ["stop-updating"]
pull_request:
branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/setup-node@v3
with:
node-version: 14
- name: Check node/npm version
run: |
echo "NodeJs version: "
node --version
echo "npm version: "
npm --version
# use npm to set up yarn
- name: Set up yarn cli
run: |
npm install --global yarn
echo "Yarn version: "
yarn --version
- name: Set MSVC version
run: npm config set msvs_version 2022
# This might be helpful for issues building node-gyp modules on Windows.
# - name: Set up npm Windows build tools
# run: yarn install -g windows-build-tools
- name: Update node-gyp
run: |
$WhereNode = Get-Command node | Select-Object -ExpandProperty Definition
$NodeDirPath = Split-Path $WhereNode -Parent
$NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\npm-lifecycle"
cd $NodeModulesPath
npm install node-gyp@latest
- name: Force to latest node-gyp
run: |
npm install --global node-gyp@latest
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
# install GNU make
- name: Install gnu make using choclatey
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install make
- uses: actions/checkout@v3
# Sets up the node_modules folder with the Windows version of the dependencies
- name: Yarn install
run: yarn install --frozen-lockfile --network-timeout=100000 --no-optional
# Downloads kubernetes dependencies
- name: Download client binaries
run: yarn download:binaries
# Fix the version of the build
- name: Fix Build version
run: yarn run npm:fix-build-version
# Compile
- name: Compile
run: yarn run compile
# clear our pem folder before publish
# https://github.com/ukoloff/win-ca#clear-pem-folder-on-publish
# - name: Clear CA trust
# run: rm -Recursive node_modules/win-ca/pem
- name: add path to msbuild
run: $env:Path += ";/c/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/"
- name: Electron Builder
run: yarn run electron-builder --publish onTag --win --dir
# - name: Make
# run: make build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: built-artifacts
path: ./dist

View File

@ -1,30 +1,10 @@
# Lens Open Source Project (OpenLens)
# A place to build Open Lens for Windows
[![Build Status](https://github.com/lensapp/lens/actions/workflows/test.yml/badge.svg)](https://github.com/lensapp/lens/actions/workflows/test.yml)
[![Chat on Slack](https://img.shields.io/badge/chat-on%20slack-blue.svg?logo=slack&longCache=true&style=flat)](https://join.slack.com/t/k8slens/shared_invite/zt-198iepl92-EPJsCckkJ~f887vWqJcgGA)
[![Build For Windows](https://github.com/JoelBirlingmairBeastCode/lens-without-lens-ID/actions/workflows/build-for-windows.yml/badge.svg?branch=stop-updating)](https://github.com/JoelBirlingmairBeastCode/lens-without-lens-ID/actions/workflows/build-for-windows.yml)
## The Repository
This repository ("OpenLens") is where Team Lens develops the [Lens IDE](https://k8slens.dev) product together with the community. It is backed by a number of Kubernetes and cloud native ecosystem pioneers. This source code is available to everyone under the [MIT license](./LICENSE).
This is a forked repository of the "OpenLens" repo.
## Lens - The Kubernetes IDE
Lens - The Kubernetes IDE ("Lens IDE") is a distribution of the OpenLens repository with Team Lens specific customizations released under a traditional [EULA](https://k8slens.dev/licenses/eula).
Lens IDE provides the full situational awareness for everything that runs in Kubernetes. It's lowering the barrier of entry for people just getting started and radically improving productivity for people with more experience.
Lens IDE a standalone application for MacOS, Windows and Linux operating systems. You can download it free of charge for Windows, MacOS, and Linux from [Lens IDE website](https://k8slens.dev).
[![Screenshot](.github/screenshot.png)](https://www.youtube.com/watch?v=eeDwdVXattc)
## Installation
See [Getting Started](https://docs.k8slens.dev/main/getting-started/install-lens/) page.
## Development
See [Development](https://docs.k8slens.dev/latest/contributing/development/) page.
## Contributing
See [Contributing](https://docs.k8slens.dev/latest/contributing/) page.
Observe the github actions on this repo.
The file [./.github/workflows/build-for-windows.yml](./.github/workflows/build-for-windows.yml) shows how to build the basic Lens app without any of the proprietary extensions like the Lens ID log in screen.

View File

@ -401,7 +401,7 @@
"make-plural": "^6.2.2",
"mini-css-extract-plugin": "^2.6.1",
"mock-http": "^1.1.0",
"node-gyp": "^8.3.0",
"node-gyp": "^9.1.0",
"node-loader": "^2.0.0",
"nodemon": "^2.0.19",
"playwright": "^1.25.1",

View File

@ -293,6 +293,11 @@ const terminalConfig: PreferenceDescription<TerminalConfig, TerminalConfig> = {
},
};
["none", {
label: "Do Not Update",
}],
// export const defaultUpdateChannel = new SemVer(getAppVersion()).prerelease[0]?.toString() || "latest";
export const defaultUpdateChannel = "none";
export type ExtensionRegistryLocation = "default" | "npmrc" | "custom";
export type ExtensionRegistry = {

View File

@ -106,6 +106,7 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
return this.shell || process.env.SHELL || process.env.PTYSHELL;
}
return true;
startMainReactions() {
// open at system start-up
reaction(() => this.openAtLogin, openAtLogin => {

134
src/main/app-updater.ts Normal file
View File

@ -0,0 +1,134 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { UpdateInfo } from "electron-updater";
import { autoUpdater } from "electron-updater";
import logger from "./logger";
import { isTestEnv } from "../common/vars";
import { delay } from "../common/utils";
import type { UpdateAvailableToBackchannel } from "../common/ipc";
import { areArgsUpdateAvailableToBackchannel, AutoUpdateChecking, AutoUpdateLogPrefix, AutoUpdateNoUpdateAvailable, broadcastMessage, onceCorrect, UpdateAvailableChannel } from "../common/ipc";
import { once } from "lodash";
import { ipcMain } from "electron";
import { nextUpdateChannel } from "./utils/update-channel";
import { UserStore } from "../common/user-store";
let installVersion: undefined | string;
export function isAutoUpdateEnabled() {
//return autoUpdater.isUpdaterActive() && isPublishConfigured;
return false;
}
function handleAutoUpdateBackChannel(event: Electron.IpcMainEvent, ...[arg]: UpdateAvailableToBackchannel) {
if (arg.doUpdate) {
if (arg.now) {
logger.info(`${AutoUpdateLogPrefix}: User chose to update now`);
autoUpdater.quitAndInstall(true, true);
} else {
logger.info(`${AutoUpdateLogPrefix}: User chose to update on quit`);
}
} else {
logger.info(`${AutoUpdateLogPrefix}: User chose not to update, will update on quit anyway`);
}
}
autoUpdater.logger = {
info: message => logger.info(`[AUTO-UPDATE]: electron-updater: %s`, message),
warn: message => logger.warn(`[AUTO-UPDATE]: electron-updater: %s`, message),
error: message => logger.error(`[AUTO-UPDATE]: electron-updater: %s`, message),
debug: message => logger.debug(`[AUTO-UPDATE]: electron-updater: %s`, message),
};
interface Dependencies {
isAutoUpdateEnabled: () => boolean;
}
/**
* starts the automatic update checking
* @param interval milliseconds between interval to check on, defaults to 2h
*/
export const startUpdateChecking = ({ isAutoUpdateEnabled }: Dependencies) => once(function (interval = 1000 * 60 * 60 * 2): void {
if (!isAutoUpdateEnabled() || isTestEnv) {
return;
}
const userStore = UserStore.getInstance();
autoUpdater.autoDownload = false;
autoUpdater.autoInstallOnAppQuit = true;
autoUpdater.channel = userStore.updateChannel;
autoUpdater.allowDowngrade = userStore.isAllowedToDowngrade;
autoUpdater
.on("update-available", (info: UpdateInfo) => {
if (installVersion === info.version) {
// same version, don't broadcast
return;
}
installVersion = info.version;
autoUpdater.downloadUpdate()
.catch(error => logger.error(`${AutoUpdateLogPrefix}: failed to download update`, { error: String(error) }));
})
.on("update-downloaded", (info: UpdateInfo) => {
try {
const backchannel = `auto-update:${info.version}`;
ipcMain.removeAllListeners(backchannel); // only one handler should be present
// make sure that the handler is in place before broadcasting (prevent race-condition)
onceCorrect({
source: ipcMain,
channel: backchannel,
listener: handleAutoUpdateBackChannel,
verifier: areArgsUpdateAvailableToBackchannel,
});
logger.info(`${AutoUpdateLogPrefix}: broadcasting update available`, { backchannel, version: info.version });
broadcastMessage(UpdateAvailableChannel, backchannel, info);
} catch (error) {
logger.error(`${AutoUpdateLogPrefix}: broadcasting failed`, { error });
installVersion = undefined;
}
})
.on("update-not-available", () => {
const nextChannel = nextUpdateChannel(userStore.updateChannel, autoUpdater.channel);
logger.info(`${AutoUpdateLogPrefix}: update not available from ${autoUpdater.channel}, will check ${nextChannel} channel next`);
if (nextChannel !== autoUpdater.channel) {
autoUpdater.channel = nextChannel;
autoUpdater.checkForUpdates()
.catch(error => logger.error(`${AutoUpdateLogPrefix}: failed with an error`, error));
} else {
broadcastMessage(AutoUpdateNoUpdateAvailable);
}
});
async function helper() {
while (true) {
await checkForUpdates();
await delay(interval);
}
}
helper();
});
export async function checkForUpdates(): Promise<void> {
const userStore = UserStore.getInstance();
try {
logger.info(`📡 Checking for app updates`);
autoUpdater.channel = userStore.updateChannel;
autoUpdater.allowDowngrade = userStore.isAllowedToDowngrade;
broadcastMessage(AutoUpdateChecking);
await autoUpdater.checkForUpdates();
} catch (error) {
logger.error(`${AutoUpdateLogPrefix}: failed with an error`, error);
}
}