Skip to content

Commit

Permalink
sfdx project structure (#23)
Browse files Browse the repository at this point in the history
* better windows readme

* ability to change sfdx module path

* #22 Refactored src -> app

* added notes about upgrading
  • Loading branch information
ChuckJonas authored Apr 21, 2019
1 parent 555ee40 commit 1b5013e
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 159 deletions.
61 changes: 57 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,29 @@ Make sure you have the following installed on your machine:

#### Windows

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

* 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.
** You may also need to tell npm to use bash: `npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"`
There are several options:

* 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)
* [linux](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/)
* [mingw](http://www.mingw.org/wiki/Getting_Started)

You may also need to tell npm to use bash: `npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"`

### Clone this Starter

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

#### Project Structure

* `app`: The react Application source Folder
* `force-app`: The Salesforce DX package. Store related metadata here
* `config`: configurations for development, build & tests (some configuration files are in root)
* `dist`: the build directory

### Authentication

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`.
Expand All @@ -65,7 +77,6 @@ [email protected]

*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


## DEVELOPMENT

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.
Expand Down Expand Up @@ -154,6 +165,48 @@ It is possible to debug right from vscode. To do so:
4. `f5` or launch `debug locally` configuration
5. you may need to Enable [Allow Insecure Localhost](chrome://flags/#allow-insecure-localhost) again if it opens in a different instance of chrome

## Upgrading to newer version of "BASS"

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

Unfortunately upgrades are currently a very manual process. Over the many different enhancements:

* configuration files have been changed & moved around
* Low Value / High Complexity: features have been removed
* build scripts have changed
* configuration files have changed
* npm dependencies have been upgraded/added/removed

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.

I've tried to go back and tag `Release` to give a sense of breaking changes, but it's very incomplete.

### Things to consider when upgrading

* Most changes have happened in the following areas:
* `package.json` (particularly the `scripts` & `config` sections)
* `webpack.config.ts`
* `tsconfig.json`

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.`.

* Lots of files have been moved around. In particular:
* many files have been moved to `config` folder.
* `src` has been renamed to `app`

* Features & dependencies have been removed. Examples:
* there is no longer an `local` mode as it no longer has any advantages over using `Localhost assets on salesforce`
* Redux was removed from the core of this project
* Replaced `awesome-typescript-loader` with babel
* self-signed cert generation script has been removed (manual instructions are in `config/cert`)

* Runtime dependencies have been upgraded to the latest and greatest. Which likely means breaking changes in these libraries:
* react
* antd
* ts-force

In most cases you should just be able to continue using your runtime library versions with the latest version of `B.A.S.S.`.

## OTHER USEFUL STUFF

### vscode
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
8 changes: 4 additions & 4 deletions src/generated/Account.ts → app/generated/Account.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rest, RestObject, SObject, sField, SalesforceFieldType, SFLocation, SFieldProperties, FieldResolver, SOQLQueryParams, buildQuery, FieldProps } from "ts-force";
import { Contact } from "./";

export type AccountFields = FieldProps<Account>;
export type AccountFields = Partial<FieldProps<Account>>;

/**
* Generated class for Account
Expand Down Expand Up @@ -217,16 +217,16 @@ export class Account extends RestObject {
this.upsellOpportunity = void 0;
this.sLASerialNumber = void 0;
this.sLAExpirationDate = void 0;
Object.assign(this, fields);
this.initObject(fields);
return new Proxy(this, this.safeUpdateProxyHandler);
}

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

public static get FIELDS() {
return this._fields = this._fields ? this._fields : Account.getPropertiesMeta<AccountFields, Account>(Account)
return this._fields = this._fields ? this._fields : Account.getPropertiesMeta<FieldProps<Account>, Account>(Account)
}

public static async retrieve(qryParam: ((fields: FieldResolver<Account>) => SOQLQueryParams) | string): Promise<Account[]> {
Expand Down
8 changes: 4 additions & 4 deletions src/generated/Contact.ts → app/generated/Contact.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rest, RestObject, SObject, sField, SalesforceFieldType, SFLocation, SFieldProperties, FieldResolver, SOQLQueryParams, buildQuery, FieldProps } from "ts-force";
import { Account } from "./";

export type ContactFields = FieldProps<Contact>;
export type ContactFields = Partial<FieldProps<Contact>>;

/**
* Generated class for Contact
Expand Down Expand Up @@ -199,16 +199,16 @@ export class Contact extends RestObject {
this.cleanStatus = void 0;
this.level = void 0;
this.languages = void 0;
Object.assign(this, fields);
this.initObject(fields);
return new Proxy(this, this.safeUpdateProxyHandler);
}

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

public static get FIELDS() {
return this._fields = this._fields ? this._fields : Contact.getPropertiesMeta<ContactFields, Contact>(Contact)
return this._fields = this._fields ? this._fields : Contact.getPropertiesMeta<FieldProps<Contact>, Contact>(Contact)
}

public static async retrieve(qryParam: ((fields: FieldResolver<Contact>) => SOQLQueryParams) | string): Promise<Contact[]> {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions config/jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"moduleNameMapper": {
"\\.(css|scss|less)$": "<rootDir>/config/__mocks__/styleMock.js",
"\\.(png|jpg|gif|ttf|eot|svg)$": "<rootDir>/config/__mocks__/fileMock.js",
"@src/(.*)": "<rootDir>/src/$1",
"@gen/(.*)": "<rootDir>/src/generated/$1"
"@src/(.*)": "<rootDir>/app/$1",
"@gen/(.*)": "<rootDir>/app/generated/$1"
},
"testRegex": "/src/tests/.*\\.(ts|tsx|js)$",
"testRegex": "/app/tests/.*\\.(ts|tsx|js)$",
"unmockedModulePathPatterns": []
}
2 changes: 1 addition & 1 deletion config/ts-force-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"username": "[email protected]"
},
"sObjects": ["Account", "Contact"],
"outPath": "./src/generated"
"outPath": "./app/generated"
}
18 changes: 10 additions & 8 deletions config/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import lessToJs from 'less-vars-to-js';
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

/** Setup Paths */
const root = path.resolve(__dirname, '..');
const src = path.resolve(root, 'app');
const PATHS = {
root: path.resolve(__dirname, '..'),
src: path.resolve(__dirname, '../src'),
assets: path.resolve(__dirname, '../src/assets'),
dist: path.resolve(__dirname, '../dist'),
styles: path.resolve(__dirname, '../src/styles')
root,
src,
index: path.resolve(src, 'index.tsx'),
assets: path.resolve(src, 'assets'),
styles: path.resolve(src, 'styles'),
dist: path.resolve(root, 'dist'),
};

// for ant style overrides
Expand Down Expand Up @@ -54,7 +57,7 @@ module.exports = (env: any = {}) => {
entry: {
app: [
'babel-polyfill',
'./src/index.tsx',
PATHS.index,
],
},
output: {
Expand Down Expand Up @@ -86,7 +89,6 @@ module.exports = (env: any = {}) => {
// externals: {
// },


/*** LOADERS ***/
module: {
rules: [
Expand All @@ -96,7 +98,7 @@ module.exports = (env: any = {}) => {
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: require('./babelrc.json')
options: require('./babelrc.json'),
},
// css
{
Expand Down
Loading

0 comments on commit 1b5013e

Please sign in to comment.