Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsoniv committed Mar 6, 2023
0 parents commit 57ecdde
Show file tree
Hide file tree
Showing 326 changed files with 32,738 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NEXT_PUBLIC_APP_NAME='Sitecore Commerce Seller App'
NEXT_PUBLIC_OC_CLIENT_ID='4A9F0BAC-EC1D-4711-B01F-1A394F72F2B6'
NEXT_PUBLIC_OC_API_URL='https://sandboxapi.ordercloud.io'
NEXT_PUBLIC_OC_MARKETPLACE_ID='SitecoreCommerce'
NEXT_PUBLIC_OC_MARKETPLACE_NAME='Sitecore Commerce'
NEXT_PUBLIC_OC_USELIVEANALYTICSDATA='false'


11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": ["next", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error", {"endOfLine": "auto"}]
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion" : 2020
}
}
12 changes: 12 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
workflow_dispatch:

name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
package-name: release-please-action
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 16.x

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

**/public/workbox-*.js
**/public/sw.js
**/public/service-worker.js

# sitemap
robots.txt
sitemap*.xml

# TS
*.tsbuildinfo
/.env
.env.vercelcommerce.local
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn run pre-commit
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# add some options to dissuade using npm

engine-strict = true # errors if using engine not defined in package.json (yarn)
package-lock=false # don't generate package-lock.json
11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth":120,
"tabWidth": 2,
"semi": false,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": false,
"jsxBracketSameLine": false,
"arrowParens": "always",
"endOfLine":"auto"
}
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"vivaxy.vscode-conventional-commits",
"dsznajder.es7-react-js-snippets",
"mhutchie.git-graph",
"oderwat.indent-rainbow"
]
}
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// https://nextjs.org/docs/advanced-features/debugging#debugging-with-vs-code
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "yarn dev",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"workbench.editor.wrapTabs": true,
"workbench.editor.scrollToSwitchTabs": true,
"liveServer.settings.port": 5501
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Sitecore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Sitecore Commerce Seller app
Welcome to Sitecore Commerce Seller App. This is a basic implementation of the Sitecore Commerce using the OrderCloud Javascript SDK.
You can use it as a starting point to discover, understand, and learn more about the Sitecore Commerce OrderCloud capabilities.

This app showcase different marketplace scenarios and commerce strategies: B2B, B2C, B2B2C.

## What is Sitecore Commerce OrderCloud?
----
[OrderCloud](https://ordercloud.io/discover/platform-overview) is a B2B, B2C, B2X commerce and marketplace development platform,
OrderCloud delivers cloud-based, API-first, headless eCommerce architecture. Limitless customizations and endless freedom for growth to support your complete commerce strategy.

## What is Sitecore Commerce Seller App?
----
A **simple**, **powerful** and **flexible** Commerce Seller Application built on top of Sitecore [OrderCloud API](https://ordercloud.io/api-reference) and the [Javascript SDK](https://www.npmjs.com/package/ordercloud-javascript-sdk) built with:
* React
* Next.JS
* Typescript
* Chakra UI
* Toolings for linting, formatting, and conventions configured `eslint`, `prettier`, `husky`, `lint-staged`, `commitlint`, `commitizen`, and `standard-version`
* SEO optimization configured with `next-seo` and `next-sitemap`. you'll need to reconfigure or tinker with it to get it right according to your needs, but it's there if you need it.

## What you can do with this app?
----
* Create, read, update delete product catalogs and categories
* Create, read, update delete products with Extended propreties
* Create, read, update delete promotions
* Create, read, update, delete buyers
* Create, read, update, delete user groups and users
* Read, Update Orders

## Requirement
Create an OrderCloud Marketplace instance (https://portal.ordercloud.io)

## How do I get started?
Using the Deploy Button below, you'll deploy on Vercel the Next.js project as well as connect it to your Sitecore Commerce OrderCloud sandbox.

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FSitecoreNA%2Fsitecore-commerce%2Ftree%2Fmain)

## Working locally
----
1. Pull the latest version from this github repository
2. Copy the `.env.local.example` file in the root directory to `.env.local` (ignored by default during your next Git commit):

```bash
cp .env.local.example .env.local
```

Then set each variable on `.env.local`:
`NEXT_PUBLIC_APP_NAME` Application Name used on Page title.
`NEXT_PUBLIC_OC_CLIENT_ID` ClientID from portal.ordercloud.io
`NEXT_PUBLIC_OC_API_URL`='https://sandboxapi.ordercloud.io' Sandbox URL from portal.ordercloud.io
`NEXT_PUBLIC_OC_MARKETPLACE_ID`
`NEXT_PUBLIC_OC_MARKETPLACE_NAME`
`NEXT_PUBLIC_OC_USELIVEANALYTICSDATA`='false'

Your `.env.local` file should look like this:

```bash
NEXT_PUBLIC_APP_NAME='Sitecore Commerce Seller App'
NEXT_PUBLIC_OC_CLIENT_ID='****0BAC-****-4711-B01F-1A**4F7*****'
NEXT_PUBLIC_OC_API_URL='https://sandboxapi.ordercloud.io'
NEXT_PUBLIC_OC_MARKETPLACE_ID='SitecoreCommerce'
NEXT_PUBLIC_OC_MARKETPLACE_NAME='Sitecore Commerce'
NEXT_PUBLIC_OC_USELIVEANALYTICSDATA='false'
```

3. Run Next.js in development mode
```bash
yarn install
yarn dev
```

Your app should be up and running on [http://localhost:3000](http://localhost:3000)!
If it doesn't work, post on [GitHub issues](https://github.com/medkrimi/commercenext.js/discussions).

### Seeding a new marketplace

In some cases it may be useful to have your own marketplace. Maybe you need to create data for a specific workflow, or perhaps you want to insulate yourself from unwanted data changes right before a demo. To make this easy we've included a CLI command that will create a marketplace for you and pre-populate it with products from the play shop marketplace.

```bash
npm run seed -- -u=YOUR_PORTAL_USERNAME -p=YOUR_PORTAL_PASSWORD -n=YOUR_MARKETPLACE_NAME
```

Next, find the admin client ID and set it as NEXT_PUBLIC_OC_CLIENT_ID in your .env file.

Finally log in as `initialadminuser` with the password `Testingsetup123!`

### Deploy on Vercel
To deploy your local project to Vercel, push it to public GitHub/GitLab/Bitbucket repository then [import to Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example).

## Not implemented / on the Roadmap
* Create, read, update, delete sellers and suppliers
* Create, read, update, delete addresses
* ....

## References
- [OrderCloud Javascript SDK](https://www.npmjs.com/package/ordercloud-javascript-sdk)
- [OrderCloud API Reference](https://ordercloud.io/api-reference)
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Chakra UI](https://chakra-ui.com)
- [TypeScript](https://www.typescriptlang.org)
5 changes: 5 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
26 changes: 26 additions & 0 deletions next-seo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @type {import('next-seo').DefaultSeoProps} */
const defaultSEOConfig = {
title: "",
titleTemplate: "",
defaultTitle: "",
description: "Next.js + chakra-ui + TypeScript",
canonical: "",
openGraph: {
url: "",
title: "",
description: "",
images: [
{
url: "",
alt: "",
},
],
site_name: "",
},
twitter: {
handle: "",
cardType: "",
},
};

export default defaultSEOConfig;
7 changes: 7 additions & 0 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('next-sitemap').IConfig} */
const NextSitemapConfig = {
siteUrl: "https://www.sitecore.com",
generateRobotsTxt: true,
};

module.exports = NextSitemapConfig;
30 changes: 30 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** @type {import('next').NextConfig} */

const withNextra = require("nextra")({
theme: "nextra-theme-docs",
themeConfig: "./theme.config.tsx"
})

module.exports = withNextra({
devIndicators: {
autoPrerender: true
},
pwa: {
disable:
process.env.NODE_ENV === "development" ||
process.env.NODE_ENV === "preview" ||
process.env.NODE_ENV === "production",
// delete two lines above to enable PWA in production deployment
// add your own icons to public/manifest.json
// to re-generate manifest.json, you can visit https://tomitm.github.io/appmanifest/
dest: "public",
register: true
},
swcMinify: true,
reactStrictMode: true,
eslint: {
dirs: ["src"]
},
// !! WARN !!
ignoreBuildErrors: true
})
Loading

0 comments on commit 57ecdde

Please sign in to comment.