-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(README.md): add more comprehensive instructions for developing application kit bundles in readme #2346
base: main
Are you sure you want to change the base?
Changes from 8 commits
6486a18
8d2d1fb
fc07510
1b53cf8
b800d3c
6c40c94
33da242
101b461
07ed52e
7fef0fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -23,40 +23,119 @@ $ npx @commercetools-frontend/create-mc-app my-new-custom-application-project -- | |||||
|
||||||
## Developing application-kit packages | ||||||
|
||||||
Install the dependencies (uses yarn workspaces): | ||||||
### Initial Installation | ||||||
|
||||||
1. Clone this repo | ||||||
|
||||||
```bash | ||||||
$ git clone https://github.com/commercetools/merchant-center-application-kit.git | ||||||
``` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would omit this part to be honest, it does not seem relevant. |
||||||
|
||||||
2. Add necessary environment variables | ||||||
|
||||||
> Navigate to `merchant_center_application_kit/playground`, duplicate `.env.local.template`, name the duplicate `.env.local` and add these values: | ||||||
|
||||||
```bash | ||||||
MC_API_URL="https://mc-api.europe-west1.gcp.commercetools.com" # for prod | ||||||
APP_ID="" # can be an empty string for dev | ||||||
CTP_INITIAL_PROJECT_KEY=<your-project-name> # the name of any project you have access to on prod/stage | ||||||
``` | ||||||
|
||||||
3. Build and run the application kit | ||||||
|
||||||
> In a new terminal window, navigate to the project root directory - `/merchant_center_application_kit` - and run: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```bash | ||||||
$ yarn && yarn prebuild && yarn build && yarn build:watch | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This command does not make much sense. Simply run
Suggested change
FYI: |
||||||
``` | ||||||
|
||||||
> Confirm that the watch is running successfully, you should see: | ||||||
|
||||||
```bash | ||||||
> "info @commercetools-frontend/application-shell waiting for changes..." | ||||||
>... | ||||||
``` | ||||||
|
||||||
4. Remove fake permission: | ||||||
> `PERMISSIONS.ViewPlaygroundStateMachines` which is required by playground is a fake permission and you might need to remove it | ||||||
> in order to be able to run and view the application. You'll need to remove it twice in `custom-application-config.mjs` and once in | ||||||
> `routes.js` so that `permissions`/`demandedPermissions` are just empty objects: | ||||||
|
||||||
`custom-application-config.mjs` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand this point. Why fake? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @emmenko |
||||||
|
||||||
```bash | ||||||
$ yarn | ||||||
permissions: [PERMISSIONS.ViewPlaygroundStateMachines], | ||||||
submenuLinks: [ | ||||||
{ | ||||||
uriPath: 'echo-server', | ||||||
permissions: [PERMISSIONS.ViewPlaygroundStateMachines], | ||||||
defaultLabel: '${intl:en:Menu.EchoServer}', | ||||||
labelAllLocales: [ | ||||||
{ | ||||||
locale: 'en', | ||||||
value: '${intl:en:Menu.EchoServer}', | ||||||
}, | ||||||
{ | ||||||
locale: 'de', | ||||||
value: '${intl:de:Menu.EchoServer}', | ||||||
}, | ||||||
], | ||||||
}, | ||||||
], | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The custom app config does not need to change. You can omit this. |
||||||
``` | ||||||
|
||||||
To run the tests: | ||||||
`routes.js` | ||||||
|
||||||
```bash | ||||||
$ yarn test | ||||||
const canViewStateMachines = useIsAuthorized({ | ||||||
demandedPermissions: [PERMISSIONS.ViewPlaygroundStateMachines], | ||||||
}); | ||||||
``` | ||||||
|
||||||
# or | ||||||
$ yarn test:watch | ||||||
5. Build and run the [playground application](./playground): | ||||||
|
||||||
> In a new terminal window, navigate to the project root directory - `/merchant_center_application_kit`, and run: | ||||||
|
||||||
```bash | ||||||
$ yarn playground:build && yarn playground:start | ||||||
ByronDWall marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
``` | ||||||
|
||||||
Build the application bundles | ||||||
> This should open a browser window and the standard merchant cernter login prompt, login using your account, and then the playground should load in the browser if permissions are set correctly (I am unclear on what those perms are or how to set them, so this is completely theoretical on my part at this point) | ||||||
ByronDWall marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
### RUNNING THE APP KIT AND PLAYGROUND AFTER INITIAL INSTALLATION | ||||||
ByronDWall marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
> The playground application consumes the app-kit dependencies as es modules, which means you need to bundle the packages first. We recommend to bundle the packages in watch mode in one terminal process and start the playground app in another terminal process. | ||||||
|
||||||
- Open 2 terminal windows | ||||||
|
||||||
- In the first terminal run | ||||||
|
||||||
```bash | ||||||
$ yarn build:watch | ||||||
``` | ||||||
|
||||||
- Once the watch process has completed and is listening, in the second terminal window run | ||||||
|
||||||
```bash | ||||||
$ yarn playground:start | ||||||
``` | ||||||
|
||||||
## To run the tests: | ||||||
|
||||||
```bash | ||||||
$ yarn build | ||||||
$ yarn test | ||||||
|
||||||
# or | ||||||
$ yarn build:bundles:watch | ||||||
$ yarn test:watch | ||||||
``` | ||||||
|
||||||
Start the [playground application](./playground): | ||||||
|
||||||
> NOTE: the playground application consumes the app-kit dependencies's es modules, which means you need to bundle the packages first. We recommend to bundle the packages in watch mode in one terminal process and start the playground app in another terminal process. | ||||||
## To Build the application bundles: | ||||||
|
||||||
```bash | ||||||
// Terminal process 1 | ||||||
$ yarn build:bundles:watch | ||||||
$ yarn build | ||||||
|
||||||
// Terminal process 2 | ||||||
$ yarn playground:start | ||||||
# or | ||||||
$ yarn build:bundles:watch | ||||||
``` | ||||||
|
||||||
## Documentation | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all section can be removed to be honest. We can mention to check and ensure to have the
.env.local
file but I wouldn't document its content. Instead you can add more information and give hints in the template file itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emmenko
When you initially pull down the repo this is the result when you run yarn build:watch after adding the environment variables without running yarn build first.