Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Changeset, eslint config, vscode settings and docs and stay in root
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdixon committed Oct 3, 2023
1 parent 10cdea3 commit 72b863f
Show file tree
Hide file tree
Showing 22 changed files with 2,375 additions and 2,460 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions .changeset/sixty-months-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
File renamed without changes.
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
on:
push:
paths:
- 'packages/shopify-api'
pull_request:
paths:
- 'packages/shopify-api'
name: shopify-api CI
on: [push, pull_request]
name: CI
jobs:
CI:
name: CI_Node_${{ matrix.version }}
Expand All @@ -28,6 +22,6 @@ jobs:
- name: Test
run: yarn test
- name: Test REST resources
run: yarn test:rest_resources
run: cd packages/shopify-api && yarn test:rest_resources
- name: Run isomorphic adapter tests
run: yarn test:adapters
run: cd packages/shopify-api && yarn test:adapters
10 changes: 1 addition & 9 deletions .github/workflows/markdown_link_check.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
name: Check Markdown links

on:
push:
paths:
- 'packages/shopify-api'
pull_request:
paths:
- 'packages/shopify-api'
on: [push, pull_request]

jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- name: Change directory
run: cd packages/shopify-api
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
Expand Down
5 changes: 4 additions & 1 deletion packages/shopify-api/.gitignore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ bundle/
*.d.ts.map
*.js
*.js.map
*.mjs
*.esnext
*.tgz
.vscode/

.turbo
**/build/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "shopify-api-js--root",
"version": "1.0.0",
"license": "UNLICENSED",
"private": true,
"scripts": {
"build": "turbo build",
"dev": "turbo dev --no-cache --continue",
"lint": "turbo lint",
"clean": "turbo clean && rm -rf node_modules",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"changeset": "changeset",
"version-packages": "changeset version",
"release": "turbo build --filter=docs^... && changeset publish",
"test": "turbo run test --parallel"
},
"devDependencies": {
"@changesets/cli": "^2.22.0",
"@shopify/eslint-plugin": "^42.0.0",
"@shopify/prettier-config": "^1.1.2",
"eslint": "^7.32.0",
"jest": "^29.7.0",
"jest-runner-eslint": "^2.1.2",
"prettier": "^2.5.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"turbo": "^1.9.3"
},
"dependencies": {},
"workspaces": [
"packages/*"
]
}
2 changes: 1 addition & 1 deletion packages/shopify-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- ![Build Status]() -->

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](../../LICENSE.md)
[![npm version](https://badge.fury.io/js/%40shopify%2Fshopify-api.svg)](https://badge.fury.io/js/%40shopify%2Fshopify-api)

This library provides support for the backends of TypeScript/JavaScript [Shopify](https://www.shopify.com) apps to access the [Shopify Admin API](https://shopify.dev/docs/api/admin), by making it easier to perform the following actions:
Expand Down
16 changes: 9 additions & 7 deletions packages/shopify-api/lib/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ interface HttpResponseData {
interface HttpResponseErrorParams extends HttpResponseData {
message: string;
}
export class HttpResponseError extends ShopifyError {
readonly response: HttpResponseData;
export class HttpResponseError<
ResponseType extends HttpResponseData = HttpResponseData,
> extends ShopifyError {
readonly response: ResponseType;

public constructor({
message,
Expand All @@ -45,10 +47,12 @@ export class HttpResponseError extends ShopifyError {
statusText,
body,
headers,
};
} as ResponseType;
}
}
export class HttpRetriableError extends HttpResponseError {}
export class HttpRetriableError<
ResponseType extends HttpResponseData = HttpResponseData,
> extends HttpResponseError<ResponseType> {}
export class HttpInternalError extends HttpRetriableError {}

interface HttpThrottlingErrorData extends HttpResponseData {
Expand All @@ -57,9 +61,7 @@ interface HttpThrottlingErrorData extends HttpResponseData {
interface HttpThrottlingErrorParams extends HttpThrottlingErrorData {
message: string;
}
export class HttpThrottlingError extends HttpRetriableError {
readonly response: HttpThrottlingErrorData;

export class HttpThrottlingError extends HttpRetriableError<HttpThrottlingErrorData> {
public constructor({retryAfter, ...params}: HttpThrottlingErrorParams) {
super(params);
this.response.retryAfter = retryAfter;
Expand Down
8 changes: 0 additions & 8 deletions packages/shopify-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,22 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@changesets/cli": "^2.26.0",
"@cloudflare/workers-types": "^4.20230404.0",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@shopify/eslint-plugin": "^42.0.1",
"@shopify/prettier-config": "^1.1.2",
"@swc/core": "^1.3.3",
"@types/express": "^4.17.13",
"@types/jest": "^29.5.0",
"@types/node": "^14.18.12",
"@types/node-fetch": "^2.5.7",
"@types/supertest": "^2.0.10",
"@types/uuid": "^9.0.0",
"eslint": "^8.39.0",
"express": "^4.17.13",
"jest": "^29.1.2",
"jest-environment-miniflare": "^2.12.1",
"jest-runner-eslint": "^2.0.0",
"miniflare": "^2.6.0",
"rollup": "^2.79.1",
"rollup-plugin-swc": "^0.2.1",
"supertest": "^6.1.3",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "^4.6.3"
},
"files": [
Expand Down
34 changes: 1 addition & 33 deletions packages/shopify-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
{
"compileOnSave": false,
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"pretty": true,
"moduleResolution": "node",
"module": "commonjs",
"target": "es2015",
"downlevelIteration": true,
"esModuleInterop": true,
"sourceMap": true,
"noEmitOnError": false,
"experimentalDecorators": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"importHelpers": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"lib": [
"dom",
"dom.iterable",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020",
"esnext.asynciterable"
],
"typeRoots": ["./node_modules/@types"],
"types": ["@cloudflare/workers-types", "node", "jest"],
"baseUrl": ".",
"rootDir": "."
Expand All @@ -46,4 +13,5 @@
"exclude": [
"**/*.test.ts", "**/test/*", "**/__tests__/*",
],
"extends": "../../tsconfig.base.json",
}
8 changes: 8 additions & 0 deletions tests/setup/setup-jest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import fetchMock from 'jest-fetch-mock';

// Globally disable fetch requests so we don't risk making real ones
fetchMock.enableMocks();

beforeEach(() => {
fetchMock.mockReset();
});
43 changes: 43 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"compileOnSave": false,
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"pretty": true,
"moduleResolution": "node",
"module": "commonjs",
"target": "es2015",
"downlevelIteration": true,
"esModuleInterop": true,
"sourceMap": true,
"noEmitOnError": false,
"experimentalDecorators": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"importHelpers": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"lib": [
"dom",
"dom.iterable",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020",
"esnext.asynciterable"
],
"typeRoots": ["./node_modules/@types"],
"types": ["node", "jest"],
"baseUrl": ".",
"rootDir": "."
},
"references": [
{"path": "./packages/shopify-api"}
]
}
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": [],
"include": [],
"references": [
{"path": "./packages/shopify-api"}
]
}
26 changes: 26 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": [
"**/.env.*local"
],
"pipeline": {
"build": {
"outputs": [
"dist/**"
],
"dependsOn": [
"^build"
]
},
"test": {
},
"lint": {},
"dev": {
"cache": false,
"persistent": true
},
"clean": {
"cache": false
}
}
}
Loading

0 comments on commit 72b863f

Please sign in to comment.