Skip to content

Commit

Permalink
Fix: Webpack fallback release config (#3232)
Browse files Browse the repository at this point in the history
* Don't pass a variable to require, it makes webpack mad

* remove get-config.js because only webpack can use fs

* update electron-updater due to security vulnerability

* keep target set as default

* add release notes assuming this is going to constitute a new 2.22.1 version
  • Loading branch information
codebykat authored Jul 17, 2024
1 parent cf502a8 commit 02efedb
Show file tree
Hide file tree
Showing 13 changed files with 493 additions and 166 deletions.
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [v2.22.1]

### Fixes

- The final release build of v2.22.0 was not correctly packaged, causing a crash on startup. Affected users will need to manually download this version, which properly includes a necessary configuration file during the build process [#3232](https://github.com/Automattic/simplenote-electron/pull/3232)

## [v2.22.0]

### Fixes
Expand Down
27 changes: 0 additions & 27 deletions get-config.js

This file was deleted.

3 changes: 0 additions & 3 deletions lib/auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component, Fragment } from 'react';
import classNames from 'classnames';
import cryptoRandomString from '../utils/crypto-random-string';
import { get } from 'lodash';
import getConfig from '../../get-config';
import MailIcon from '../icons/mail';
import SimplenoteLogo from '../icons/simplenote';
import Spinner from '../components/spinner';
Expand Down Expand Up @@ -48,7 +47,6 @@ export class Auth extends Component<Props> {

render() {
// Don't render this component when running on the web
const config = getConfig();
if (config.is_app_engine) {
return null;
}
Expand Down Expand Up @@ -423,7 +421,6 @@ export class Auth extends Component<Props> {
};

onWPLogin = () => {
const config = getConfig();
const redirectUrl = encodeURIComponent(config.wpcc_redirect_url);
this.authState = `app-${cryptoRandomString(20)}`;
const authUrl = `https://public-api.wordpress.com/oauth2/authorize?client_id=${config.wpcc_client_id}&redirect_uri=${redirectUrl}&response_type=code&scope=global&state=${this.authState}`;
Expand Down
3 changes: 0 additions & 3 deletions lib/boot-with-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React from 'react';
import App from './app';
import { ErrorBoundaryWithAnalytics } from './error-boundary';
import Modal from 'react-modal';
import getConfig from '../get-config';
import { makeStore } from './state';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
Expand All @@ -16,8 +15,6 @@ import '../scss/style.scss';

import isDevConfig from './utils/is-dev-config';

const config = getConfig();

export const bootWithToken = (
logout: () => any,
token: string,
Expand Down
3 changes: 0 additions & 3 deletions lib/boot-without-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import classNames from 'classnames';
import AboutDialog from './dialogs/about';
import ErrorBoundary from './error-boundary';

import getConfig from '../get-config';

import '../scss/style.scss';

type Props = {
Expand All @@ -36,7 +34,6 @@ type User = {
access_token?: string;
};

const config = getConfig();
const auth = new SimperiumAuth(config.app_id, config.app_key);

class AppWithoutAuth extends Component<Props, State> {
Expand Down
3 changes: 0 additions & 3 deletions lib/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ import 'setimmediate';

import { parse } from 'cookie';

import getConfig from '../get-config';
import { boot as bootWithoutAuth } from './boot-without-auth';
import { boot as bootLoggingOut } from './logging-out';
import { isElectron } from './utils/platform';

const config = getConfig();

const clearStorage = (): Promise<void> =>
new Promise((resolveStorage) => {
localStorage.removeItem('access_token');
Expand Down
10 changes: 10 additions & 0 deletions lib/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import * as S from './state';

declare global {
const __TEST__: boolean;
const config: {
app_engine_url: string;
app_id: string;
app_key: string;
development: boolean;
is_app_engine: string;
version: string;
wpcc_client_id: string;
wpcc_redirect_url: string;
};

interface Window {
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;
Expand Down
3 changes: 0 additions & 3 deletions lib/state/analytics/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { debounce } from 'lodash';

import analytics from '../../analytics';
import getConfig from '../../../get-config';
import isDevConfig from '../../utils/is-dev-config';

const config = getConfig();

import type * as A from '../action-types';
import type * as S from '../';
import type * as T from '../../types';
Expand Down
5 changes: 2 additions & 3 deletions lib/state/simperium/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { default as createClient } from 'simperium';

import debugFactory from 'debug';
import actions from '../actions';
import getConfig from '../../../get-config';
import { BucketQueue } from './functions/bucket-queue';
import { InMemoryBucket } from './functions/in-memory-bucket';
import { InMemoryGhost } from './functions/in-memory-ghost';
Expand Down Expand Up @@ -37,7 +36,7 @@ export const initSimperium =
(store) => {
const { dispatch, getState } = store;

const client = createClient<Buckets>(getConfig().app_id, token, {
const client = createClient<Buckets>(config.app_id, token, {
objectStoreProvider: (bucket) => {
switch (bucket.name) {
case 'account':
Expand Down Expand Up @@ -465,7 +464,7 @@ export const initSimperium =
return result;
}

case 'REALLY_LOGOUT':
case 'REALLY_LOG_OUT':
stopSyncing();
localStorage.setItem('simplenote_logout', Math.random().toString());
client.end();
Expand Down
Loading

0 comments on commit 02efedb

Please sign in to comment.