From 0ac5f75f28bd971e3a4ff429a4ab94ec3a1d468a Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 16 Jan 2025 11:07:41 -0800 Subject: [PATCH 01/14] Add "open" mode for open source devs --- config/open.json | 6 ++++++ package.json | 1 + src/main.ts | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 config/open.json diff --git a/config/open.json b/config/open.json new file mode 100644 index 00000000..27d7fb97 --- /dev/null +++ b/config/open.json @@ -0,0 +1,6 @@ +{ + "mode": "open", + "apiURL": "", + "dashURL": "", + "plausibleDomain": "open-plausible-app.cyd.social" +} \ No newline at end of file diff --git a/package.json b/package.json index cff31b0a..bf531702 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "open-cypress": "cd src/renderer && cypress open", "lint": "eslint ./src", "lint-fix": "eslint ./src --fix", + "config-open": "./archive-static-sites/build.sh && cp ./config/open.json ./build/config.json", "config-local": "./archive-static-sites/build.sh && cp ./config/local.json ./build/config.json", "config-dev": "./archive-static-sites/build.sh && cp ./config/dev.json ./build/config.json", "config-prod": "./archive-static-sites/build.sh && cp ./config/prod.json ./build/config.json" diff --git a/src/main.ts b/src/main.ts index 73a5489b..c9acf8d9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -87,16 +87,26 @@ async function initializeApp() { message: `You're running Cyd ${app.getVersion()}. It uses the dev server and it might contain bugs.`, type: 'info', }); - } else if (config.mode == "local") { + } + // Display message in local mode + else if (config.mode == "local") { dialog.showMessageBoxSync({ title: `Cyd Local ${app.getVersion()}`, message: `You're running Cyd ${app.getVersion()} in local mode.`, type: 'info', }); } + // Display message in open mode + else if (config.mode == "open") { + dialog.showMessageBoxSync({ + title: `Cyd ${app.getVersion()}`, + message: `You're running Cyd ${app.getVersion()} in open mode.\n\nThis is intended for use by open source developers. If you're not contributing to Cyd, please support the project by paying for a Premium plan.`, + type: 'info', + }); + } // Set the log level - if (config.mode == "dev" || config.mode == "local") { + if (config.mode == "open" || config.mode == "dev" || config.mode == "local") { log.transports.console.level = "debug"; } else { log.transports.console.level = "info"; From c924bfa0171c16f44a7cd7b669b624d8ada196a5 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 16 Jan 2025 11:13:24 -0800 Subject: [PATCH 02/14] Add DEVELOPMENT.md with instructions for open source contributors --- DEVELOPMENT.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 00000000..41b36b4b --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,55 @@ +# Developing Cyd + +Cyd is a desktop app for Windows, Mac, and Linux written in Node.js. To run Cyd locally, all you need is [Node.JS LTS](https://nodejs.org/en) for your operating systems. + +Install dependencies. + +```sh +npm install +``` + +Configure your Cyd environment to use "open" mode. This disables the server, which allows outside contributors to build features. + +```sh +npm run config-open +``` + +Run Cyd: + +```sh +npm run start +``` + +To make it so devtools automatically opens, and so each embedded webview has a separate devtools window open, set the environment variables `CYD_DEV` to `1`: + +```sh +CYD_DEV=1 +npm run start +``` + +Run the tests: + +```sh +# Node.js tests +npm run test + +# Vue.js component tests +npm run test:components +``` + +## Other server modes + +If you're an outside contributor you'll want to use "open" mode, as described above. + +If you're part of Lockdown Systems and you need to test functionality that uses the server, you need "local", "dev", or "prod" mode: + +```sh +# local mode: use a locally-hosted server at localhost:5000 +npm run config-local + +# dev mode: use the dev server at dev-api.cyd.social +npm run config-dev + +# prod mode: use the prod server at prod-api.cyd.social +npm run config-prod +``` \ No newline at end of file From 12c5497a7527e099b6c16c32a7928ef8ff705f47 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Fri, 17 Jan 2025 17:37:43 -0800 Subject: [PATCH 03/14] Prevent signing in with SignInModal in open mode --- src/renderer/src/modals/SignInModal.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/modals/SignInModal.vue b/src/renderer/src/modals/SignInModal.vue index a77eb025..ff570d18 100644 --- a/src/renderer/src/modals/SignInModal.vue +++ b/src/renderer/src/modals/SignInModal.vue @@ -24,6 +24,8 @@ const apiClient = inject('apiClient') as Ref; const deviceInfo = inject('deviceInfo') as Ref; const refreshDeviceInfo = inject('refreshDeviceInfo') as () => Promise; +const mode = ref(''); + const userSubscribe = ref(true); const verificationCode = ref(''); @@ -165,6 +167,8 @@ async function goBack() { } onMounted(async () => { + mode.value = await window.electron.getMode() + const modalElement = signInModal.value; if (modalElement) { modalInstance = new Modal(modalElement); @@ -196,7 +200,15 @@ onUnmounted(() => {