Skip to content

Commit 1b5013e

Browse files
authored
sfdx project structure (#23)
* better windows readme * ability to change sfdx module path * #22 Refactored src -> app * added notes about upgrading
1 parent 555ee40 commit 1b5013e

18 files changed

+211
-159
lines changed

README.md

+57-4
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,29 @@ Make sure you have the following installed on your machine:
3232

3333
#### Windows
3434

35-
You will also need the following:
35+
You will also need the ability to execute the following bash commands: `zip`, `cp`, `mv`.
3636

37-
* A `bash` enumerator (one comes with `git`) OR [linux](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/). Basiclly you need your shell to be able to run standard GNU commands like `cp`, `mv`, `zip`, etc.
38-
** You may also need to tell npm to use bash: `npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"`
37+
There are several options:
38+
39+
* A `bash` enumerator (like the one included with `git`). You may need to [install `zip` binaries](https://stackoverflow.com/questions/38782928/how-to-add-man-and-zip-to-git-bash-installation-on-windows/55749636#55749636)
40+
* [linux](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/)
41+
* [mingw](http://www.mingw.org/wiki/Getting_Started)
42+
43+
You may also need to tell npm to use bash: `npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"`
3944

4045
### Clone this Starter
4146

4247
1. `git clone https://github.com/ChuckJonas/bad-ass-salesforce-stack bass`
4348
2. `cd bass`
4449
3. `npm install`
4550

51+
#### Project Structure
52+
53+
* `app`: The react Application source Folder
54+
* `force-app`: The Salesforce DX package. Store related metadata here
55+
* `config`: configurations for development, build & tests (some configuration files are in root)
56+
* `dist`: the build directory
57+
4658
### Authentication
4759

4860
To do much of anything you'll need to connect with one or more orgs. Use `sfdx force:org:list` to see a list of orgs you're already authenticated with. Connect to an existing sandbox using `sfdx force:auth:web:login -sr [ORG_URL] -a [ALIAS]`. You can also create a scratch org using: `npm run new-scratch-org`.
@@ -65,7 +77,6 @@ [email protected]
6577

6678
*NOTE: You might want to ignore `.npmrc` for your repo. Each contributor will manage this configuration separately and committing it could result in another user accidentally deploying to an unintended org. This is especially true if you use the sfdx alias over the username
6779

68-
6980
## DEVELOPMENT
7081

7182
1. Deploy your application by running `npm run deploy-dev` or `npm run deploy-scratch`. This step needs to happen whenever the contents of `force-app` change.
@@ -154,6 +165,48 @@ It is possible to debug right from vscode. To do so:
154165
4. `f5` or launch `debug locally` configuration
155166
5. you may need to Enable [Allow Insecure Localhost](chrome://flags/#allow-insecure-localhost) again if it opens in a different instance of chrome
156167

168+
## Upgrading to newer version of "BASS"
169+
170+
Overtime, this project has gotten both simpler AND objectively better.
171+
172+
Unfortunately upgrades are currently a very manual process. Over the many different enhancements:
173+
174+
* configuration files have been changed & moved around
175+
* Low Value / High Complexity: features have been removed
176+
* build scripts have changed
177+
* configuration files have changed
178+
* npm dependencies have been upgraded/added/removed
179+
180+
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.
181+
182+
I've tried to go back and tag `Release` to give a sense of breaking changes, but it's very incomplete.
183+
184+
### Things to consider when upgrading
185+
186+
* Most changes have happened in the following areas:
187+
* `package.json` (particularly the `scripts` & `config` sections)
188+
* `webpack.config.ts`
189+
* `tsconfig.json`
190+
191+
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.`.
192+
193+
* Lots of files have been moved around. In particular:
194+
* many files have been moved to `config` folder.
195+
* `src` has been renamed to `app`
196+
197+
* Features & dependencies have been removed. Examples:
198+
* there is no longer an `local` mode as it no longer has any advantages over using `Localhost assets on salesforce`
199+
* Redux was removed from the core of this project
200+
* Replaced `awesome-typescript-loader` with babel
201+
* self-signed cert generation script has been removed (manual instructions are in `config/cert`)
202+
203+
* Runtime dependencies have been upgraded to the latest and greatest. Which likely means breaking changes in these libraries:
204+
* react
205+
* antd
206+
* ts-force
207+
208+
In most cases you should just be able to continue using your runtime library versions with the latest version of `B.A.S.S.`.
209+
157210
## OTHER USEFUL STUFF
158211

159212
### vscode

src/app.tsx renamed to app/app.tsx

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/generated/Account.ts renamed to app/generated/Account.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Rest, RestObject, SObject, sField, SalesforceFieldType, SFLocation, SFieldProperties, FieldResolver, SOQLQueryParams, buildQuery, FieldProps } from "ts-force";
22
import { Contact } from "./";
33

4-
export type AccountFields = FieldProps<Account>;
4+
export type AccountFields = Partial<FieldProps<Account>>;
55

66
/**
77
* Generated class for Account
@@ -217,16 +217,16 @@ export class Account extends RestObject {
217217
this.upsellOpportunity = void 0;
218218
this.sLASerialNumber = void 0;
219219
this.sLAExpirationDate = void 0;
220-
Object.assign(this, fields);
220+
this.initObject(fields);
221221
return new Proxy(this, this.safeUpdateProxyHandler);
222222
}
223223

224224
public static API_NAME: 'Account' = 'Account';
225225
public readonly _TYPE_: 'Account' = 'Account';
226-
private static _fields: { [P in keyof AccountFields]: SFieldProperties; };
226+
private static _fields: { [P in keyof FieldProps<Account>]: SFieldProperties; };
227227

228228
public static get FIELDS() {
229-
return this._fields = this._fields ? this._fields : Account.getPropertiesMeta<AccountFields, Account>(Account)
229+
return this._fields = this._fields ? this._fields : Account.getPropertiesMeta<FieldProps<Account>, Account>(Account)
230230
}
231231

232232
public static async retrieve(qryParam: ((fields: FieldResolver<Account>) => SOQLQueryParams) | string): Promise<Account[]> {

src/generated/Contact.ts renamed to app/generated/Contact.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Rest, RestObject, SObject, sField, SalesforceFieldType, SFLocation, SFieldProperties, FieldResolver, SOQLQueryParams, buildQuery, FieldProps } from "ts-force";
22
import { Account } from "./";
33

4-
export type ContactFields = FieldProps<Contact>;
4+
export type ContactFields = Partial<FieldProps<Contact>>;
55

66
/**
77
* Generated class for Contact
@@ -199,16 +199,16 @@ export class Contact extends RestObject {
199199
this.cleanStatus = void 0;
200200
this.level = void 0;
201201
this.languages = void 0;
202-
Object.assign(this, fields);
202+
this.initObject(fields);
203203
return new Proxy(this, this.safeUpdateProxyHandler);
204204
}
205205

206206
public static API_NAME: 'Contact' = 'Contact';
207207
public readonly _TYPE_: 'Contact' = 'Contact';
208-
private static _fields: { [P in keyof ContactFields]: SFieldProperties; };
208+
private static _fields: { [P in keyof FieldProps<Contact>]: SFieldProperties; };
209209

210210
public static get FIELDS() {
211-
return this._fields = this._fields ? this._fields : Contact.getPropertiesMeta<ContactFields, Contact>(Contact)
211+
return this._fields = this._fields ? this._fields : Contact.getPropertiesMeta<FieldProps<Contact>, Contact>(Contact)
212212
}
213213

214214
public static async retrieve(qryParam: ((fields: FieldResolver<Contact>) => SOQLQueryParams) | string): Promise<Contact[]> {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

config/jest.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"moduleNameMapper": {
1313
"\\.(css|scss|less)$": "<rootDir>/config/__mocks__/styleMock.js",
1414
"\\.(png|jpg|gif|ttf|eot|svg)$": "<rootDir>/config/__mocks__/fileMock.js",
15-
"@src/(.*)": "<rootDir>/src/$1",
16-
"@gen/(.*)": "<rootDir>/src/generated/$1"
15+
"@src/(.*)": "<rootDir>/app/$1",
16+
"@gen/(.*)": "<rootDir>/app/generated/$1"
1717
},
18-
"testRegex": "/src/tests/.*\\.(ts|tsx|js)$",
18+
"testRegex": "/app/tests/.*\\.(ts|tsx|js)$",
1919
"unmockedModulePathPatterns": []
2020
}

config/ts-force-config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"username": "[email protected]"
44
},
55
"sObjects": ["Account", "Contact"],
6-
"outPath": "./src/generated"
6+
"outPath": "./app/generated"
77
}

config/webpack.config.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import lessToJs from 'less-vars-to-js';
66
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
77

88
/** Setup Paths */
9+
const root = path.resolve(__dirname, '..');
10+
const src = path.resolve(root, 'app');
911
const PATHS = {
10-
root: path.resolve(__dirname, '..'),
11-
src: path.resolve(__dirname, '../src'),
12-
assets: path.resolve(__dirname, '../src/assets'),
13-
dist: path.resolve(__dirname, '../dist'),
14-
styles: path.resolve(__dirname, '../src/styles')
12+
root,
13+
src,
14+
index: path.resolve(src, 'index.tsx'),
15+
assets: path.resolve(src, 'assets'),
16+
styles: path.resolve(src, 'styles'),
17+
dist: path.resolve(root, 'dist'),
1518
};
1619

1720
// for ant style overrides
@@ -54,7 +57,7 @@ module.exports = (env: any = {}) => {
5457
entry: {
5558
app: [
5659
'babel-polyfill',
57-
'./src/index.tsx',
60+
PATHS.index,
5861
],
5962
},
6063
output: {
@@ -86,7 +89,6 @@ module.exports = (env: any = {}) => {
8689
// externals: {
8790
// },
8891

89-
9092
/*** LOADERS ***/
9193
module: {
9294
rules: [
@@ -96,7 +98,7 @@ module.exports = (env: any = {}) => {
9698
test: /\.(ts|js)x?$/,
9799
exclude: /node_modules/,
98100
loader: 'babel-loader',
99-
options: require('./babelrc.json')
101+
options: require('./babelrc.json'),
100102
},
101103
// css
102104
{

0 commit comments

Comments
 (0)