-
Notifications
You must be signed in to change notification settings - Fork 397
BC Checkout fixes #2724
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
Closed
Closed
BC Checkout fixes #2724
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Node JS offcial image for Node 22 (specifically required for this repo) | ||
| # Also a Linux container to meet compiling requirement | ||
| FROM node:22 | ||
|
|
||
| # Set the working directory in the container | ||
| WORKDIR /usr/src/app | ||
|
|
||
| # Copy package.json and package-lock.json (or npm-shrinkwrap.json) | ||
| COPY package*.json ./ | ||
|
|
||
| # Install project dependencies using 'npm ci' (clean install) | ||
| RUN npm ci | ||
|
|
||
| # Bundle app source | ||
| COPY . . | ||
|
|
||
| # The app runs on port 8080 exposing it for the outside world | ||
| EXPOSE 8080 | ||
|
|
||
| # Define the command to run your app | ||
| CMD [ "npm", "run", "dev" ] | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,81 +1,108 @@ | ||
| # Checkout JS | ||
| [](https://deepwiki.com/bigcommerce/checkout-js) | ||
| # IAPP BigCommerce Checkout JS | ||
| Hello fellow IAPP developer. First of all, you might be like "Why all this nonsense for a single page on a third party site?". Wellp the BigCommerce storefront is pulling in tens of millions of dollars per year in revenue, and using the Storefront->Script Manager to over write the default login behavior frequently broke whenever BC updated their markup. Not exactly optimal uptime for an enterprise ecommerce app. We also wanted finer control over checkout experience (maybe add in some promotional code), so here we are! | ||
|
|
||
| Checkout JS is a browser-based application providing a seamless UI for BigCommerce shoppers to complete their checkout. It is also known as [Optimized One-Page Checkout](https://support.bigcommerce.com/s/article/Optimized-Single-Page-Checkout), which is currently the recommended checkout option for all BigCommerce stores. | ||
| ## Big Commerce Links | ||
| [](https://deepwiki.com/bigcommerce/checkout-js)\ | ||
| [Optimized One-Page Checkout](https://support.bigcommerce.com/s/article/Optimized-Single-Page-Checkout)\ | ||
| [Installing the checkout](https://developer.bigcommerce.com/stencil-docs/customizing-checkout/installing-custom-checkouts)\ | ||
| [BC CI/CD pipeline: CircleCI](https://circleci.com/gh/bigcommerce/workflows/checkout-js/tree/master)\ | ||
| [BigCommerce Checkout Git repo we forked](https://github.com/bigcommerce/checkout-js)\ | ||
|
|
||
| ## Requirements | ||
|
|
||
| In order to build from the source code, you must have the following set up in your development environment. | ||
| The repo requires the below environment to compile. | ||
|
|
||
| * Node >= v22. | ||
| * NPM >= v10. | ||
| * Unix-based operating system. (WSL on Windows) | ||
| * Unix-based operating system. (WSL on Windows (they are fibbing here)) | ||
|
|
||
| One of the simplest ways to install Node is using [NVM](https://github.com/nvm-sh/nvm#installation-and-update). You can follow their instructions to set up your environment if it is not already set up. | ||
| But that is really hard to get working on a standard IAPP development laptop because Nicole hates us having Macs. | ||
| To work around this we are going to install a docker environment locally and build from there. | ||
|
|
||
| ## Development | ||
| To install Docker on your local machine, use the "company portal" application installed on your machine (just type that into the search bar). | ||
| [Company Portal]( https://iappadmin.atlassian.net/servicedesk/customer/portal/30/article/2616819713?source=search) | ||
| You may need to install windows WSL and some other dependencies too, you can request local admin access using our PIM system. | ||
| [PIM](https://iappadmin.atlassian.net/servicedesk/customer/article/2921693187) | ||
|
|
||
| Once you have cloned the repository and set up your environment, you can start developing with it. | ||
|
|
||
| First, you have to pull in the dependencies required for the application. | ||
| ## Docker Setup | ||
|
|
||
| 1. Head on over to your local repo directory, which in my case is at: C:\Users\DavidOstrander\00_IappWork\ . | ||
| 2. Next open up a GitBash terminal. | ||
| 3. Run ``` git clone https://github.com/bigcommerce/checkout-js.git ``` to grab a local copy. | ||
| 4. RUN ``` cd bigcommerce-checkout-js ``` | ||
| 5. RUN | ||
| ```sh | ||
| # Build your local Linux/Node image | ||
| docker build -t bigcommerce-checkout . | ||
| ``` | ||
| 6. RUN | ||
| ```sh | ||
| npm ci | ||
| # Boot up your image into a working container | ||
| docker run -p 8080:8080 -d --name bc-checkout-dev bigcommerce-checkout | ||
| ``` | ||
|
|
||
| After that, you can make changes to the source code and run the following command to build it. | ||
|
|
||
| 7. RUN | ||
| ```sh | ||
| npm run build | ||
| # Login to our container and access a terminal | ||
| docker exec -it bc-checkout-dev sh | ||
| ``` | ||
|
|
||
| If you are developing the application locally and want to build the source code in watch mode, you can run the following command: | ||
|
|
||
| 8. RUN | ||
| ```sh | ||
| # install all dependencies | ||
| npm ci | ||
| ``` | ||
| 9. RUN | ||
| ```sh | ||
| # This will create the build folder in the container and should make your files available locally | ||
| npm run dev | ||
| ``` | ||
| 10. Test to see if your container is serving files: [Localhost](http://localhost:8080) . | ||
|
|
||
| If you want to create a prerelease (i.e.: `alpha`) for testing in the integration environment, you can run the following command: | ||
| If you see an "Index of / " web page, with a bunch of linked files including "auto-loader-dev.js". You are good to go! | ||
|
|
||
| ```sh | ||
| npm run release:alpha | ||
| ``` | ||
| ## Local Development | ||
|
|
||
| After that, you need to push the prerelease tag to your fork so it can be referenced remotely. | ||
| From [My Apps](https://myapps.microsoft.com/), click on BigCommerce, and login to the IAPP Akeneo Sandbox. This BC Instance is configured to import into your browser the files served at http://localhost:8080. So this instance of Sandbox will break for other people using it, as their computers won't be serving those files. | ||
|
|
||
| ### Testing | ||
| If you are familiar with Docker, most of the time you would mount your repo into the container, so that files you make on your local machine, would be treated as local files by the container. Because we need the NPM run build from the Linux environment, mounting the volume didn't work so hot. So we are going to make edits to our files in our local VS_Code IDE, Copy the files into the docker container via a terminal command, and manually run the NPM build inside of the container. | ||
|
|
||
| To run E2E tests, use the following command: | ||
| I suggest opening two gitbash terminals, one for copying the file, and one logged into the container to build the files. | ||
|
|
||
| ```sh | ||
| npm run e2e | ||
| ``` | ||
|
|
||
| The E2E tests in this project use HAR files to stub network calls. If you need to manually update the HAR files to make minor changes to the requests, you must run the command below to regenerate the ID for each updated request. Otherwise, the stubs will not function properly. | ||
|
|
||
| ```sh | ||
| npm run regenerate-har | ||
| # First terminal: copy files from your local machine to the container | ||
| docker cp ./packages/core/src/app/customer/LoginForm.tsx bc-checkout-dev:/usr/src/app/packages/core/src/app/customer/LoginForm.tsx | ||
| ``` | ||
|
|
||
| ## Custom Checkout installation | ||
|
|
||
| Follow [this guide](https://developer.bigcommerce.com/stencil-docs/customizing-checkout/installing-custom-checkouts) for instructions on how to fork and install this app as a Custom Checkout in your store. | ||
|
|
||
| If you want to test your checkout implementation, you can run: | ||
| ```sh | ||
| npm run dev:server | ||
| #Second terminal: Login to the container | ||
| docker exec -it bc-checkout-dev sh | ||
| ``` | ||
|
|
||
| And enter the local URL for `auto-loader-dev.js` in Checkout Settings, e.g `http://127.0.0.1:8080/auto-loader-dev.js` | ||
| ```sh | ||
| #Second terminal: After copying your files into ther container from your local, build them. | ||
| npm run build | ||
| ``` | ||
|
|
||
| ## Release | ||
| You should be able to view your changes in the checkout app inside of the IAPP Akeneo Sandbox instance, or (more likely) extremely verbose errors in your npm build terminal. | ||
|
|
||
| Everytime a PR is merged to the master branch, CircleCI will trigger a build automatically. However, it won't create a new Git release until it is approved by a person with write access to the repository. If you have write access, you can approve a release job by going to [CircleCI](https://circleci.com/gh/bigcommerce/workflows/checkout-js/tree/master) and look for the job you wish to approve. You can also navigate directly to the release job by clicking on the yellow dot next to the merged commit. | ||
| ## Custom Checkout installation into your store | ||
|
|
||
| Follow [this guide](https://developer.bigcommerce.com/stencil-docs/customizing-checkout/installing-custom-checkouts) for instructions on how to fork and install this app as a Custom Checkout in your store. | ||
|
|
||
| ## Contribution | ||
| And enter the local URL for `auto-loader-dev.js` in Checkout Settings, e.g `http://127.0.0.1:8080/auto-loader-dev.js` | ||
|
|
||
| More information can be found in the [contribution guide](CONTRIBUTING.md) and [code of conduct](CODE_OF_CONDUCT.md) for this project. | ||
| ## BC CI/CD Release | ||
|
|
||
| Everytime a BC PR is merged to the master branch, CircleCI will trigger a build automatically. However, it won't create a new Git release until it is approved by a person with write access to the repository. We should periodically merge in the BC master branch into our fork. That includes adding the parent repo as a git upstream repo and doing some git magic: | ||
| ```sh | ||
| git remote add upstream https://github.com/bigcommerce/checkout-js | ||
| git remote -v | ||
| git fetch upstream | ||
| git checkout master | ||
| git merge upstream/master | ||
| git push origin master | ||
| #at this point our remote fork will be synced with the BC main | ||
| ``` | ||
|
|
||
| Copyright (C) 2019-Present BigCommerce Inc. All rights reserved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| version: '3.8' | ||
| services: | ||
| checkout: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| ports: | ||
| # NODE Web server exposed | ||
| - '8080:8080' | ||
| volumes: | ||
| # This syncs your current directory on your host to /usr/src/app in the container | ||
| - .:/usr/src/app | ||
| # This prevents your local node_modules from overwriting the container's node_modules | ||
| - /usr/src/app/node_modules | ||
| # Override the Dockerfile's CMD to run the actual watch-and-rebuild process | ||
| command: npm run dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can this interface be removed now that it's empty?