Skip to content
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

Refactoring, gh workflow and type declarations #1

Merged
merged 7 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"space-before-function-paren": 0,
"comma-dangle": 0
}
}
}
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: storefront-js

on:
push:
branches: [main, dev-**]
tags:
- 'v*'
pull_request:
branches: [main, dev-**]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x] # Build on Node.js 16

steps:
- uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v3
id: npm-cache
with:
path: ~/.pnpm-store # Replace this with the path you want to cache
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: latest

- name: Install Dependencies
run: pnpm install

- name: Build
run: pnpm run bundle

npm_publish:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4

- name: Setup Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Setup pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: latest

- name: Install Dependencies
run: pnpm install

- name: Build
run: pnpm run bundle

- name: Set up npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc

- name: Publish
run: npm publish --access public

github_publish:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4

- name: Setup Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Setup pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: latest

- name: Install Dependencies
run: pnpm install

- name: Build
run: pnpm run bundle

- name: Configure npm for GitHub registry
run: |
echo "@fleetbase:registry=https://npm.pkg.github.com/" >> ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc

- name: Publish to GitHub registry
run: npm publish
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
/.reify-cache
/yarn.lock
/package-lock.json
.DS_Store
.DS_Store

# Ignore artifacts:
build
coverage
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm exec lint-staged
pnpm exec lint-staged
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# compiled output
/dist/
dist/
/tmp/

# dependencies
/node_modules/
LICENSE.md
README.md
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = {
trailingComma: 'es5',
tabWidth: 4,
semi: true,
singleQuote: true,
printWidth: 190,
};
8 changes: 4 additions & 4 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Copyright (c) 2021 Fleetbase Pte Ltd, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3) Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ If you would like to make contributions to the Fleetbase Javascript SDK document
## Quick Start for Browser

```js
import Storefront, { Product } from '@fleetbase/storefront';
import Storefront, { Product } from "@fleetbase/storefront";

const storefront = new Storefront('Your Store Key');
const storefront = new Storefront("Your Store Key");

// list products
storefront.products.findAll();
Expand All @@ -52,8 +52,8 @@ storefront.products.findAll();
const product = new Product({ name, description, price });

// retrieve cart & add item
storefront.cart.retrieve().then(cart => {
cart.add('product_xyxyxyx', 1);
storefront.cart.retrieve().then((cart) => {
cart.add("product_xyxyxyx", 1);

// empty cart
cart.empty();
Expand All @@ -63,9 +63,8 @@ storefront.cart.retrieve().then(cart => {
storefront.checkout.capture();
```


## Create a custom adapter

Storefront will eventually allow you to bring your own ecommerce adapter.

```@todo```
`@todo`
2 changes: 1 addition & 1 deletion dist/@fleetbase/storefront.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/@fleetbase/storefront.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/storefront.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/storefront.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/storefront.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/storefront.js.map

Large diffs are not rendered by default.

123 changes: 66 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,68 @@
{
"name": "@fleetbase/storefront",
"version": "1.1.5",
"description": "Fleetbase Storefront JS & Node SDK",
"main": "dist/cjs/storefront.js",
"module": "dist/esm/storefront.js",
"files": [
"dist",
"src"
],
"scripts": {
"prebuild": "npm run lint",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"lint:tests": "eslint tests",
"bundle": "rollup -c",
"dev": "rollup -c -w",
"test": "mocha --require @babel/polyfill --require @babel/register --require source-map-support/register tests/*.test.js"
},
"keywords": [
"fleetbase",
"ecommerce",
"api",
"ondemand",
"ecommerce",
"last",
"mile",
"delivery",
"logistics",
"ecommerce",
"app"
],
"author": "Ronald A. Richardson <ron@fleetbase.io> (https://ron.dev)",
"license": "BSD-3-Clause",
"devDependencies": {
"@babel/core": "^7.14.0",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-decorators": "^7.13.15",
"@babel/plugin-transform-spread": "^7.13.0",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.14.1",
"@babel/register": "^7.13.16",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"chai": "^4.3.4",
"eslint": "^7.26.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.16.0",
"mocha": "^8.4.0",
"rollup": "^2.61.0",
"rollup-plugin-eslint": "^5.1.0",
"rollup-plugin-terser": "^7.0.2",
"source-map-support": "^0.5.19"
},
"dependencies": {
"@fleetbase/sdk": "1.2.1",
"date-fns": "^2.22.1"
}
"name": "@fleetbase/storefront",
"version": "1.1.5",
"description": "Fleetbase Storefront JS & Node SDK",
"main": "dist/cjs/storefront.js",
"module": "dist/esm/storefront.js",
"files": [
"dist",
"src"
],
"scripts": {
"prebuild": "npm run lint",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"lint:tests": "eslint tests",
"bundle": "rollup -c",
"dev": "rollup -c -w",
"test": "mocha --require @babel/polyfill --require @babel/register --require source-map-support/register tests/**/*.test.js",
"prepare": "husky install",
"format": "prettier . --write"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
},
"keywords": [
"fleetbase",
"ecommerce",
"api",
"ondemand",
"ecommerce",
"last",
"mile",
"delivery",
"logistics",
"ecommerce",
"app"
],
"author": "Ronald A. Richardson <ron@fleetbase.io> (https://ron.dev)",
"license": "BSD-3-Clause",
"devDependencies": {
"@babel/core": "^7.23.6",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.23.6",
"@babel/plugin-transform-spread": "^7.23.3",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.23.6",
"@babel/register": "^7.22.15",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"chai": "^4.3.10",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.1",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"mocha": "^10.2.0",
"prettier": "3.1.1",
"rollup": "^4.9.1",
"rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-terser": "^7.0.2",
"source-map-support": "^0.5.21",
"typescript": "^5.3.3"
},
"dependencies": {
"@fleetbase/sdk": "1.2.7",
"date-fns": "^3.0.5"
}
}
Loading
Loading