This guide outlines the process for creating a custom website based on the public Swift GitHub repository.
It includes instructions for cloning the Swift repository, customizing it, and maintaining your custom project by incorporating updates from the original Swift repository.
To customize Swift, you’ll typically use regular frontend development tools like VS Code (available on Windows and Mac), Visual Studio (for Windows), or another popular code editor for Mac.
Before starting, ensure you have the required tools installed:
- Git: For cloning and managing repositories
- A code editor such as VS Code, Visual Studio, or another editor of your choice
1. Clone the Swift repository
To get started, clone the Swift repository to your local machine:
Open a terminal in VS Code or your preferred Git-enabled terminal
Run the following command:
git clone https://github.com/dynamicweb/Swift.gitNavigate to the cloned repository:
cd Swift
You now have a local copy of the Swift repository.
2. Create a custom repository
To store and manage your customized project, create a new Git repository:
Navigate to Azure DevOps
Create a new Git repository
Add the Azure DevOps repository as a remote:
git remote add origin <Your_Azure_DevOps_Repo_URL>Push your changes to the repository:
git push -u origin main
Your custom project is now stored in your own repository.
3. Customizing the Swift project
To customize the Swift project:
Modify Files: Edit the existing templates, CSS, and JavaScript files in the repository to fit your project requirements
Add New Files: Add any new files required for your project (e.g., custom styles or templates)
Create a Feature Branch and Make Changes:
To work on new features or customizations, create a feature branch:
git checkout -b feature/<feature-name>Make your changes in the branch.
Test your updates as described below.
Once satisfied, push the branch to your repository:
git push origin feature/<feature-name>Open a pull request from your feature branch to the
mainbranch on your repository platform (GitHub or Azure DevOps)Review and merge the pull request to integrate your changes into the main branch
Test Your Changes: Use the built-in testing tools in DynamicWeb 10 or your local environment to ensure your changes work as expected, for example:
- Run your project in a local development server (e.g., IIS Express or Kestrel) to preview and verify changes in real-time
- Use browser developer tools to debug issues with CSS or JavaScript
- If applicable, test integrations with DynamicWeb backend features like the product catalog or content management system
4. Updating the custom project with Swift updates
When new features and bug fixes are released for Swift they are published to the original Swift repository. To incorporate all updates from the Swift repository into your custom project, follow these steps:
Add the Swift Repository as an Upstream Remote
Add the original Swift repository as an upstream remote:
git remote add upstream https://github.com/dynamicweb/Swift.gitVerify the remotes:
git remote -vOutput:
origin <Your_Custom_Repo_URL> (fetch) origin <Your_Custom_Repo_URL> (push) upstream https://github.com/dynamicweb/Swift.git (fetch) upstream https://github.com/dynamicweb/Swift.git (push)
Create an Update Branch to handle the updates:
git checkout -b update-from-upstreamFetch the latest changes from the Swift Repository:
git fetch upstreamMerge updates into the update branch:
Merge the changes from the
mainbranch of the upstream repository:git merge upstream/mainResolve any merge conflicts:
Open the conflicted files in VS Code (Git highlights them automatically).
Resolve the conflicts manually by keeping or modifying changes as needed.
Mark resolved files as staged:
git add <conflicted_file>
Complete the merge:
git commit
Test the application in the
update-from-upstreambranch to ensure everything works correctlyCreate a pull request to merge updates:
Push the update branch to your custom repository:
git push origin update-from-upstreamOpen your repository on GitHub or Azure DevOps
Create a pull request from
update-from-upstreamintomainReview and merge the pull request after confirming the changes
5. Pulling specific PRs from the Swift repository
If you want to incorporate a specific bug fix or feature from the original Swift repository without merging all updates, you can cherry-pick a pull request. Follow these steps:
Identify the Pull Request
- Go to the original Swift repository on GitHub.
- Locate the pull request you want to incorporate.
- Note the commit hash associated with the pull request. You can find this in the "Commits" tab of the pull request (e.g.,
abc1234).
Add the Swift repository as an upstream remote and fetch the latest changes
git remote add upstream https://github.com/dynamicweb/Swift.gitgit fetch upstreamCherry-Pick the commit
Create a new branch for the changes:
git checkout -b update-specific-fixCherry-pick the commit from the pull request (replace
<commit-hash>with the actual hash of the commit, e.g.abc1234):git cherry-pick <commit-hash>
If conflicts arise during the cherry-pick resolve them
Open the conflicted files in VS Code.
Resolve conflicts manually.
Mark resolved files as staged:
git add <conflicted_file>Complete the cherry-pick:
git cherry-pick --continue
Test and push changes
Test your changes in the new branch to ensure they work as intended.
Push the branch to your custom repository:
git push origin update-specific-fix
Create a pull request
- Open your repository on GitHub or Azure DevOps.
- Create a pull request from
update-specific-fixintomain. - Review and merge the pull request after confirming the changes.
6. Best Practices
Use Tags or Branches: Track specific versions of your customizations by using tags or dedicated branches. This ensures you can reference or roll back to previous states if needed. Backup Before Updates: Always create a backup branch of your
mainbranch before merging updates:git checkout -b backup-mainFrequent Updates: Incorporate upstream updates regularly to avoid large, difficult merges.
Document Customizations: Maintain a clear record of your custom changes to simplify conflict resolution.
By following this process, you can efficiently customize the Swift repository and keep your project up to date with the latest features and improvements from the original repository.
Happy coding!