Skip to content

Commit

Permalink
Merge branch 'main' into fix-release-process
Browse files Browse the repository at this point in the history
  • Loading branch information
micahflee committed Dec 12, 2024
2 parents 07c8246 + df4ba8d commit 1e1052f
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 26 deletions.
31 changes: 21 additions & 10 deletions forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ function removeCodeSignatures(dir: string) {

const config: ForgeConfig = {
packagerConfig: {
name: 'Cyd',
executableName: os.platform() == 'linux' ? 'cyd' : 'Cyd',
appBundleId: 'systems.lockdown.cyd',
name: process.env.CYD_ENV == 'prod' ? 'Cyd' : 'Cyd Dev',
executableName: os.platform() == 'linux' ? (process.env.CYD_ENV == 'prod' ? 'cyd' : 'cyd-dev') : (process.env.CYD_ENV == 'prod' ? 'Cyd' : 'Cyd Dev'),
appBundleId: process.env.CYD_ENV == 'prod' ? 'systems.lockdown.cyd' : 'systems.lockdown.cyd-dev',
appCopyright: `Copyright ${new Date().getFullYear()} Lockdown Systems LLC`,
asar: true,
icon: path.join(assetsPath, 'icon'),
Expand All @@ -121,7 +121,7 @@ const config: ForgeConfig = {
// Windows
new MakerSquirrel({
iconUrl: "https://releases.lockdown.systems/cyd/icon.ico",
name: "Cyd",
name: process.env.CYD_ENV == 'prod' ? "Cyd" : "CydDev",
setupIcon: path.join(assetsPath, "installer-icon.ico"),
loadingGif: path.join(assetsPath, "installer-loading.gif"),
windowsSign: process.env.WINDOWS_RELEASE === 'true' ? {
Expand All @@ -133,13 +133,13 @@ const config: ForgeConfig = {
}),
// macOS DMG
new MakerDMG({
name: `Cyd ${version}`,
name: process.env.CYD_ENV == 'prod' ? `Cyd ${version}` : `Cyd Dev ${version}`,
background: path.join(assetsPath, 'dmg-background.png'),
icon: path.join(assetsPath, 'installer-icon.icns'),
iconSize: 110,
overwrite: true,
contents: [
{ "x": 270, "y": 142, "type": "file", "path": `${process.cwd()}/out/Cyd-darwin-universal/Cyd.app` },
{ "x": 270, "y": 142, "type": "file", "path": process.env.CYD_ENV == 'prod' ? `${process.cwd()}/out/Cyd-darwin-universal/Cyd.app` : `${process.cwd()}/out/Cyd Dev-darwin-universal/Cyd Dev.app` },
{ "x": 428, "y": 142, "type": "link", "path": "/Applications" }
],
additionalDMGOptions: {
Expand All @@ -156,7 +156,16 @@ const config: ForgeConfig = {
macUpdateManifestBaseUrl: `https://releases.lockdown.systems/cyd/${process.env.CYD_ENV}/macos/universal`
}),
// Linux RPM
new MakerRpm({}),
new MakerRpm({
// @ts-expect-error I think the typescript definitions are wrong, but this should work
icon: path.join(assetsPath, 'icon.png'),
homepage: 'https://cyd.social',
categories: ['Utility', 'Network'],
description: 'Claw back your data from Big Tech',
productName: process.env.CYD_ENV == 'prod' ? "Cyd" : "Cyd Dev",
bin: process.env.CYD_ENV == 'prod' ? "cyd" : "cyd-dev",
name: process.env.CYD_ENV == 'prod' ? "cyd" : "cyd-dev",
}),
// Linux Debian
new MakerDeb({
options: {
Expand All @@ -165,7 +174,9 @@ const config: ForgeConfig = {
homepage: 'https://cyd.social',
categories: ['Utility', 'Network'],
description: 'Claw back your data from Big Tech',
productName: "Cyd",
productName: process.env.CYD_ENV == 'prod' ? "Cyd" : "Cyd Dev",
bin: process.env.CYD_ENV == 'prod' ? "cyd" : "cyd-dev",
name: process.env.CYD_ENV == 'prod' ? "cyd" : "cyd-dev",
}
})
],
Expand Down Expand Up @@ -210,8 +221,8 @@ const config: ForgeConfig = {

console.log('🍎 Preparing to codesign macOS app bundle');

const universalBuildPath = path.join(__dirname, 'out', 'Cyd-darwin-universal');
const appPath = path.join(universalBuildPath, "Cyd.app");
const universalBuildPath = path.join(__dirname, 'out', process.env.CYD_ENV == 'prod' ? 'Cyd-darwin-universal' : 'Cyd Dev-darwin-universal');
const appPath = path.join(universalBuildPath, process.env.CYD_ENV == 'prod' ? "Cyd.app" : "Cyd Dev.app");
const identity = "Developer ID Application: Lockdown Systems LLC (G762K6CH36)";
const entitlementDefault = path.join(assetsPath, 'entitlements', 'default.plist');
const entitlementGpu = path.join(assetsPath, 'entitlements', 'gpu.plist');
Expand Down
2 changes: 1 addition & 1 deletion scripts/make-dev-linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=dev
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge make
2 changes: 1 addition & 1 deletion scripts/make-dev-macos.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=dev
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge make --arch universal
2 changes: 1 addition & 1 deletion scripts/make-dev-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env pwsh
$env:CYD_ENV = "dev"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*,electron-installer*"
$env:WINDOWS_RELEASE = "false"

# https://github.com/Squirrel/Squirrel.Windows/issues/1838#issuecomment-1514089628
Expand Down
2 changes: 1 addition & 1 deletion scripts/make-local-linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=local
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge make
2 changes: 1 addition & 1 deletion scripts/make-local-macos.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=local
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge make --arch universal
2 changes: 1 addition & 1 deletion scripts/make-prod-linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=prod
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge make
2 changes: 1 addition & 1 deletion scripts/make-prod-macos.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=prod
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge make --arch universal
2 changes: 1 addition & 1 deletion scripts/make-prod-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env pwsh
$env:CYD_ENV = "prod"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*,electron-installer*"
$env:WINDOWS_RELEASE = "false"

# https://github.com/Squirrel/Squirrel.Windows/issues/1838#issuecomment-1514089628
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish-dev-macos.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=dev
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge publish --arch universal
2 changes: 1 addition & 1 deletion scripts/publish-dev-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env pwsh
$env:CYD_ENV = "dev"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*,electron-installer*"
$env:WINDOWS_RELEASE = "true"

# https://github.com/Squirrel/Squirrel.Windows/issues/1838#issuecomment-1514089628
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish-prod-macos.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
export CYD_ENV=prod
export DEBUG=electron-packager,electron-universal,electron-forge*
export DEBUG=electron-packager,electron-universal,electron-forge*,electron-installer*

./scripts/clean.sh
electron-forge publish --arch universal
2 changes: 1 addition & 1 deletion scripts/publish-prod-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env pwsh
$env:CYD_ENV = "prod"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*"
$env:DEBUG = "electron-packager,electron-universal,electron-forge*,electron-installer*"
$env:WINDOWS_RELEASE = "true"

# https://github.com/Squirrel/Squirrel.Windows/issues/1838#issuecomment-1514089628
Expand Down
25 changes: 22 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ if (!fs.existsSync(configPath)) {
}
const config: Config = JSON.parse(fs.readFileSync(configPath, 'utf8'));

// Attach the mode to the process environment
process.env.CYD_MODE = config.mode;

// Set the app name
if (config.mode == "prod") {
// cyd with a lowercase c, for backwards compatibility
app.setName('cyd');
} else {
app.setName('Cyd Dev');
}

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
Expand All @@ -71,13 +82,13 @@ async function initializeApp() {
// Display message in dev mode
if (config.mode == "dev") {
dialog.showMessageBoxSync({
title: `Cyd ${app.getVersion()}`,
title: `Cyd Dev ${app.getVersion()}`,
message: `You're running Cyd ${app.getVersion()}. It uses the dev server and it might contain bugs.`,
type: 'info',
});
} else if (config.mode == "local") {
dialog.showMessageBoxSync({
title: `Cyd ${app.getVersion()}`,
title: `Cyd Local ${app.getVersion()}`,
message: `You're running Cyd ${app.getVersion()} in local mode.`,
type: 'info',
});
Expand Down Expand Up @@ -154,7 +165,7 @@ async function createWindow() {
webviewTag: true,
preload: path.join(__dirname, './preload.js')
},
icon: icon
icon: icon,
});

// Handle power monitor events
Expand Down Expand Up @@ -249,6 +260,14 @@ async function createWindow() {
}
});

ipcMain.handle('getMode', async () => {
try {
return config.mode;
} catch (error) {
throw new Error(packageExceptionForReport(error as Error));
}
});

ipcMain.handle('getPlatform', async () => {
try {
return os.platform();
Expand Down
3 changes: 3 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ contextBridge.exposeInMainWorld('electron', {
getVersion: (): Promise<string> => {
return ipcRenderer.invoke('getVersion')
},
getMode: (): Promise<string> => {
return ipcRenderer.invoke('getMode')
},
getPlatform: (): Promise<string> => {
return ipcRenderer.invoke('getPlatform')
},
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ onMounted(async () => {
}
isReady.value = true;
// Change the app title
const mode = await window.electron.getMode();
if (mode === 'prod') {
document.title = 'Cyd';
} else {
document.title = `Cyd (${mode})`;
}
});
</script>

Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ declare global {
electron: {
checkForUpdates: () => void;
getVersion: () => Promise<string>;
getMode: () => Promise<string>;
getPlatform: () => Promise<string>;
getAPIURL: () => Promise<string>;
getDashURL: () => Promise<string>;
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/src/test_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const stubElectron = () => {
return {
checkForUpdates: cy.stub(),
getVersion: cy.stub(),
getMode: cy.stub(),
getPlatform: cy.stub(),
getAPIURL: cy.stub(),
getDashURL: cy.stub(),
Expand All @@ -20,6 +21,12 @@ export const stubElectron = () => {
database: {
getConfig: cy.stub(),
setConfig: cy.stub(),
getErrorReport: cy.stub(),
getNewErrorReports: cy.stub(),
createErrorReport: cy.stub(),
updateErrorReportSubmitted: cy.stub(),
dismissNewErrorReports: cy.stub(),
getAccount: cy.stub(),
getAccounts: cy.stub(),
createAccount: cy.stub(),
selectAccountType: cy.stub(),
Expand All @@ -37,10 +44,12 @@ export const stubElectron = () => {
updateJob: cy.stub(),
indexStart: cy.stub(),
indexStop: cy.stub(),
indexParseAllJSON: cy.stub(),
indexParseTweets: cy.stub(),
indexParseLikes: cy.stub(),
indexParseConversations: cy.stub(),
indexIsThereMore: cy.stub(),
resetThereIsMore: cy.stub(),
indexMessagesStart: cy.stub(),
indexParseMessages: cy.stub(),
indexTweetsFinished: cy.stub(),
Expand All @@ -65,11 +74,14 @@ export const stubElectron = () => {
saveProfileImage: cy.stub(),
getLatestResponseData: cy.stub(),
deleteTweetsStart: cy.stub(),
deleteTweetsCountNotArchived: cy.stub(),
deleteRetweetsStart: cy.stub(),
deleteLikesStart: cy.stub(),
deleteTweet: cy.stub(),
deleteDMsMarkAllDeleted: cy.stub(),
deleteDMsScrollToBottom: cy.stub(),
verifyXArchive: cy.stub(),
importXArchive: cy.stub(),
getConfig: cy.stub(),
setConfig: cy.stub(),
},
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/src/views/AboutView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ref, onMounted } from "vue";
const currentYear = new Date().getFullYear();
const appVersion = ref("");
const mode = ref("prod");
defineProps<{
shouldShow: boolean;
Expand All @@ -18,6 +19,7 @@ const termsClicked = async () => {
onMounted(async () => {
appVersion.value = await window.electron.getVersion();
mode.value = await window.electron.getMode();
});
</script>

Expand All @@ -36,6 +38,7 @@ onMounted(async () => {
</p>
<p class="text-muted">
<img src="/assets/wordmark.svg" class="cyd-wordmark mr-2" alt="Cyd">
{{ mode != 'prod' ? 'Dev' : '' }}
version {{ appVersion }}
</p>
<p class="text-muted">
Expand Down
6 changes: 5 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ export const getDataPath = () => {
// Get dataPath from config
let dataPath = getConfig('dataPath');
if (!dataPath) {
dataPath = path.join(app.getPath('documents'), 'Cyd');
if (process.env.CYD_MODE === 'prod') {
dataPath = path.join(app.getPath('documents'), 'Cyd');
} else {
dataPath = path.join(app.getPath('documents'), 'Cyd Dev');
}
setConfig('dataPath', dataPath);
}

Expand Down

0 comments on commit 1e1052f

Please sign in to comment.