Skip to content

Commit 97ea66e

Browse files
committed
2.0
- upgraded to react 18 - replaced webpack with vite - upgraded to antd 5.0 - replaced jest with vitest - upgraded eslint
1 parent dc72e06 commit 97ea66e

32 files changed

+11915
-15372
lines changed

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ dev_alias=
22
scratch_alias=bass-scratch
33
prod_alias=
44

5-
devPort=8080
5+
dev_port=8080

.travis.yml

-3
This file was deleted.

.vscode/settings.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
},
1212
"terminal.integrated.env.windows": {
1313
"SFDX_SET_CLIENT_IDS": "sfdx-vscode"
14-
},
15-
"eslint.nodePath": "/Users/jonas/.vscode/extensions/salesforce.salesforcedx-vscode-lwc-45.5.0/node_modules"
14+
}
1615
}

LICENSE

-21
This file was deleted.

README.md

+14-39
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- [typescript](https://www.typescriptlang.org/): business in the front, party in the back
1010
- [antd](https://ant.design/docs/react/introduce): the best thing to come out of China since [the fork](https://en.wikipedia.org/wiki/Fork)
1111
- [ts-force](https://www.npmjs.com/package/ts-force): generates massive files so you don't have toooo
12-
- [webpack](https://webpack.github.io/): Does a lot of stuff won't ever fully don't understand
12+
- [vite](https://vitejs.dev/): Does a lot of stuff won't ever fully don't understand, slightly better than webpack
1313
- [sfdx-cli](https://developer.salesforce.com/tools/sfdxcli): #nosoftware
1414

1515
## FEATURES
@@ -19,7 +19,7 @@
1919
- 1 step build & deploy to orgs
2020
- supports developer, sandbox, scratch and production orgs
2121
- type safety and code completion when working with SF objects
22-
- jest test framework
22+
- testing with vitest
2323
- setup for debugging in [vscode chrome debugger](https://github.com/Microsoft/vscode-chrome-debug)
2424

2525
## GETTING STARTED
@@ -103,9 +103,7 @@ [email protected]
103103

104104
### How it works
105105

106-
`webpack-dev-server` compiles and makes your app available @ `https//localhost:PORT`. It incrementally compiles your app as you make changes & [react-hot-loader](https://github.com/gaearon/react-hot-loader) allows modules to be hot reloaded without refreshing the page.
107-
108-
Updates will only show for you and not impact any other users in that environment (until you deploy).
106+
`vite` compiles and makes your app available @ `https//localhost:PORT`. It incrementally compiles your app as you make changes allows modules to be hot reloaded without refreshing the page.
109107

110108
You can see how this is configured by looking at [`force-app/main/default/pages/App.page`](https://github.com/ChuckJonas/bad-ass-salesforce-stack/blob/e7b7366ca2ad1e13bc9b3a1986ad6148097c2fa2/force-app/main/default/pages/App.page#L17). Basically, we just have two output panels that render conditionally based on the url param `local == 1`.
111109

@@ -138,10 +136,6 @@ _Note: You can have multiple VF pages_
138136

139137
**NOTE: If you include other static resources in the `force-app/main/default/staticresources` folder they will get nuked by default. To prevent this, update the `copy-bundle` script **
140138

141-
### antd theme
142-
143-
You can change the antd theme less variables by editing `/styles/ant-theme-vars.less`. Unfortunately, changes here require a webpack restart to show up :(
144-
145139
### ts-force configuration
146140

147141
This project comes equipped with `ts-force` to allow you typed access to Salesforce Rest API. To use `ts-force`, you must first generate classes for the SObjects you want to work with.
@@ -173,7 +167,7 @@ It is possible to debug right from vscode. To do so:
173167

174168
Overtime, this project has gotten both simpler AND objectively better.
175169

176-
Unfortunately upgrades are currently a very manual process. Over the many different enhancements:
170+
Unfortunately upgrades are currently a very manual process. Overtime:
177171

178172
- configuration files have been changed & moved around
179173
- Low Value / High Complexity: features have been removed
@@ -183,35 +177,16 @@ Unfortunately upgrades are currently a very manual process. Over the many differ
183177

184178
I admit, I haven't done a very good job of documenting these changes very well. My goal of keeping this everything as flexible as possible has also made it impossible to move parts of the configuration to upgradable packages.
185179

186-
I've tried to go back and tag `Release` to give a sense of breaking changes, but it's very incomplete.
187-
188-
### Things to consider when upgrading
189-
190-
- Most changes have happened in the following areas:
191-
- `package.json` (particularly the `scripts` & `config` sections)
192-
- `webpack.config.ts`
193-
- `tsconfig.json`
194-
195-
For these files, it's best to first identify any customization of your own and then try to merge them into the latest version from `B.A.S.S.`.
196-
197-
- Lots of files have been moved around. In particular:
198-
199-
- many files have been moved to `config` folder.
200-
- `src` has been renamed to `app`
201-
202-
- Features & dependencies have been removed. Examples:
180+
### Upgrading to 2.0.0
203181

204-
- there is no longer an `local` mode as it no longer has any advantages over using `Localhost assets on salesforce`
205-
- Redux was removed from the core of this project
206-
- Replaced `awesome-typescript-loader` with babel
207-
- self-signed cert generation script has been removed (manual instructions are in `config/cert`)
182+
Version 2.0.0 is a major upgrade to the project. It includes the following changes:
208183

209-
- Runtime dependencies have been upgraded to the latest and greatest. Which likely means breaking changes in these libraries:
210-
- react
211-
- antd
212-
- ts-force
184+
- Upgrade to React18
185+
- Replace Webpack with Vite
186+
- Replacing Jest/Enzyme with Vitest/React Testing Library
187+
- Upgrade to antd v5 (changes to theming, removes LESS support by default)
213188

214-
In most cases you should just be able to continue using your runtime library versions with the latest version of `B.A.S.S.`.
189+
The easiest way to upgrade is to start a new project and copy over your files.
215190

216191
## OTHER USEFUL STUFF
217192

@@ -221,18 +196,18 @@ Highly recommend using vscode (typescript code completion, in editor terminal, e
221196

222197
plugins:
223198

224-
\*
225199

226200
- [Editor Config](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig): auto-set formatting options for everyone
227201
- [TSlint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint): green squigglies everywhere!
228202
- [Salesforce Extensions for VS Code](https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode): gives your code completion on your `force-app` and ability to excute commands against the CLI
229-
- [Jest](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest): run tests on save
203+
- [ViTest](https://marketplace.visualstudio.com/items?itemName=ZixuanChen.vitest-explorer): run tests in vscode
230204

231205
### helpful linkies
232206

233207
- [typescript deep dive](https://basarat.gitbooks.io/typescript/content/)
234208
- [react-redux-typescript-guide](https://github.com/piotrwitek/react-redux-typescript-guide)
235-
- [jest reference](https://facebook.github.io/jest/docs/en/getting-started.html#content)
209+
- [vite reference](https://vitejs.dev/)
210+
- [vitest reference](https://vitest.dev/)
236211
- [sfdx cli reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm)
237212
- [Where to Hold React Component Data: state, store, static, and this](https://medium.freecodecamp.org/where-do-i-belong-a-guide-to-saving-react-component-data-in-state-store-static-and-this-c49b335e2a00)
238213
- [Redux: How to chain async actions](https://github.com/reactjs/redux/issues/1676)

app/App.css

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#root {
2+
max-width: 1280px;
3+
margin: 0 auto;
4+
padding: 2rem;
5+
text-align: center;
6+
}
7+
8+
.logo {
9+
height: 6em;
10+
padding: 1.5em;
11+
will-change: filter;
12+
transition: filter 300ms;
13+
}
14+
.logo:hover {
15+
filter: drop-shadow(0 0 2em #646cffaa);
16+
}
17+
.logo.react:hover {
18+
filter: drop-shadow(0 0 2em #61dafbaa);
19+
}
20+
21+
@keyframes logo-spin {
22+
from {
23+
transform: rotate(0deg);
24+
}
25+
to {
26+
transform: rotate(360deg);
27+
}
28+
}
29+
30+
@media (prefers-reduced-motion: no-preference) {
31+
a:nth-of-type(2) .logo {
32+
animation: logo-spin infinite 20s linear;
33+
}
34+
}
35+
36+
.card {
37+
padding: 2em;
38+
}
39+
40+
.read-the-docs {
41+
color: #888;
42+
}

app/App.test.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import App from './App';
3+
import { render, screen, userEvent } from './test/utils';
4+
5+
describe('Simple working test', () => {
6+
it('the title is visible', () => {
7+
render(<App />);
8+
expect(screen.getByText(/Hello B.A.S.S. App/i)).toBeInTheDocument();
9+
});
10+
11+
it('should increment count on click', async () => {
12+
render(<App />);
13+
userEvent.click(screen.getByRole('button'));
14+
expect(await screen.findByText(/count is 1/i)).toBeInTheDocument();
15+
});
16+
});

app/app.tsx

+39-64
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
1-
import { Card, Drawer, Button } from 'antd';
2-
import { hot } from 'react-hot-loader'; // needs to be before react!
3-
import * as React from 'react';
4-
import { Account } from '@src/generated';
1+
import React, { useState, useEffect } from 'react';
2+
import { Card } from 'antd';
3+
import bassLogo from "./assets/images/bass-logo.jpg";
4+
import "./App.css";
55

6-
// example use of file loader to load image
7-
import bassLogo from '@src/assets/images/bass-logo.jpg';
6+
import { Account } from '@src/generated';
87

9-
interface AppState {
10-
acc: Account;
11-
drawerVisible: boolean;
12-
}
138

14-
class App extends React.Component<{}, AppState> {
9+
function App() {
10+
const [count, setCount] = useState(0);
1511

16-
constructor(props: any) {
17-
super(props);
18-
this.state = {
19-
acc: null,
20-
drawerVisible: false,
21-
};
22-
}
2312

24-
public async componentDidMount() {
25-
// example account with contacts query
26-
const accs = await Account.retrieve((fields) => {
13+
const [account, setAccount] = useState<Account>(null);
14+
useEffect(() => {
15+
Account.retrieve((fields) => {
2716
return {
2817
select: [
2918
...fields.select('id', 'name', 'website'),
@@ -35,52 +24,38 @@ class App extends React.Component<{}, AppState> {
3524
],
3625
limit: 1,
3726
};
27+
}).then((accs) => {
28+
if (accs.length > 0) {
29+
setAccount( accs[0] );
30+
}
3831
});
39-
if (accs.length > 0) {
40-
this.setState({ acc: accs[0] });
41-
}
42-
}
32+
}, []);
4333

44-
public render() {
45-
return (
46-
<Card title='B.A.S.S.'>
47-
<Drawer
48-
visible={this.state.drawerVisible}
49-
onClose={() => this.setState({drawerVisible: false})}
50-
title='An Account'
51-
width={600}
52-
>
53-
{this.state.acc && this.renderDrawerContent()}
54-
</Drawer>
55-
<img width={300} src={bassLogo} />
56-
<br />
57-
<Button type='primary' onClick={() => this.setState({drawerVisible: true})}>Click Me!</Button>
58-
</Card>
59-
);
60-
}
6134

62-
private renderDrawerContent = () => {
63-
const { acc } = this.state;
64-
65-
const contactsList = acc.contacts.map((c) => {
66-
return (
67-
<Card type='inner' key={c.id}>
68-
<p><b>Name:</b> {c.name}</p>
69-
<p><b>Email:</b> {c.email}</p>
70-
<p><b>Phone:</b> {c.phone}</p>
71-
</Card>
72-
);
73-
});
74-
return (
75-
<div>
76-
<p><b>Name:</b> {acc.name}</p>
77-
<p><b>Website:</b> {acc.website}</p>
78-
<Card title='Contacts' extra={acc.contacts.length}>
79-
{contactsList}
80-
</Card>
35+
return (
36+
<div className="App">
37+
<Card>
38+
<a href="https://github.com/ChuckJonas/bad-ass-salesforce-stack" target="_blank">
39+
<img src={bassLogo} className="logo react" alt="isa-fiish" />
40+
</a>
41+
</Card>
42+
<h1>Hello B.A.S.S. App</h1>
43+
<div className="card">
44+
<button onClick={() => setCount((count) => count + 1)}>
45+
count is {count}
46+
</button>
47+
<p>
48+
Edit <code>src/App.tsx</code> and save to test HMR
49+
</p>
8150
</div>
82-
);
83-
}
51+
<p className="read-the-docs">
52+
Click on the B.A.S.S.logo to learn more
53+
</p>
54+
55+
<p>Account: {account?.name}</p>
56+
57+
</div>
58+
);
8459
}
8560

86-
export default hot(module)(App);
61+
export default App;

0 commit comments

Comments
 (0)