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

test reference #173

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
39 changes: 20 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
/* @flow */

module.exports = {
extends:
"./node_modules/@krakenjs/grumbler-scripts/config/.eslintrc-browser.js",
"./node_modules/@krakenjs/eslint-config-grumbler/eslintrc-typescript.js",

globals: {
__STAGE__: true,
__VERSION__: true,
__TEST__: true,
},

rules: {
"no-mixed-operators": "off",
// off for initial ts conversion
"@typescript-eslint/no-implicit-any-catch": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/no-require-imports": "off",

__PROTOCOL__: true,
__SDK_HOST__: true,
__HOST__: true,
__HOSTNAME__: true,
__PORT__: true,
__PATH__: true,
__STAGE_HOST__: true,
__SERVICE_STAGE_HOST__: true,
__CORRELATION_ID__: true,
__NAMESPACE__: true,
__COMPONENTS__: true,
__FUNDING_ELIGIBILITY__: true,
__PAYPAL_DOMAIN__: true,
__PAYPAL_API_DOMAIN__: true,
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
},
};
18 changes: 0 additions & 18 deletions .flowconfig

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ jspm_packages
# Yarn Integrity file
.yarn-integrity

# Flow Typed
flow-typed

.idea

.DS_Store
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
build
dist
coverage
flow-typed
CHANGELOG.md
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Your client-side sdk component can take advantage of any common utilities or fun
- Running experiments.

```javascript
import { getClientID } from "@paypal/sdk-client/src";
import { getClientID } from "@paypal/sdk-client/dist/esm";

fetch("https://api.paypal.com/v1/foo", {
headers: {
Expand Down Expand Up @@ -83,7 +83,7 @@ app.get("/my-app", (req, res) => {
3. Ensure the `sdkMeta` payload is passed to the child window from the parent. If you are using [zoid](https://github.com/krakenjs/zoid) to construct your component, please add the following:

```javascript
import { getSdkMeta } from "@paypal/sdk-client/src";
import { getSdkMeta } from "@paypal/sdk-client/dist/esm";

let MyComponent = zoid.create({
tag: "my-component",
Expand Down
3 changes: 0 additions & 3 deletions __sdk__.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* @flow */
/* eslint unicorn/filename-case: 0, import/unambiguous: 0, import/no-commonjs: 0 */

module.exports = {
"__paypal-sdk-client__": {
entry: "./src/interface",
Expand Down
12 changes: 12 additions & 0 deletions allowModules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare module "@krakenjs/belter/dist/esm";
declare module "@krakenjs/jsx-pragmatic/dist/module";
declare module "@paypal/sdk-constants/dist/esm";
declare module "@krakenjs/beaver-logger/dist/esm";

declare namespace JSX {
// eslint-disable-next-line
interface IntrinsicElements {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[elemName: string]: any;
}
}
6 changes: 2 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* @flow */
/* eslint import/no-commonjs: off */

module.exports = {
extends: "@krakenjs/grumbler-scripts/config/.babelrc-node",
extends: "@krakenjs/babel-config-grumbler/babelrc-node",
presets: ["@krakenjs/babel-config-grumbler/flow-ts-babel-preset"],
};
3 changes: 0 additions & 3 deletions index.js → index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
/* @flow */

// $FlowFixMe
module.exports = require("./server"); // eslint-disable-line import/no-commonjs
25 changes: 0 additions & 25 deletions karma.conf.js

This file was deleted.

82 changes: 53 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@
"version": "4.0.168",
"description": "Shared config between PayPal/Braintree.",
"main": "index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"sideEffects": false,
"scripts": {
"babel": "babel ./server --ignore=node_modules --out-dir ./server",
"build": "npm run test && npm run doc",
"clean": "rimraf dist coverage",
"debug": "cross-env NODE_ENV=debug",
"doc": "esdoc",
"flow": "flow",
"flow-typed": "rm -rf ./flow-typed && flow-typed install",
"karma": "cross-env NODE_ENV=test babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/karma start",
"lint": "eslint src/ server/ test/ *.js",
"reinstall": "rimraf flow-typed && rimraf node_modules && npm install && flow-typed install",
"release": "./publish.sh",
"release:major": "./publish.sh major",
"release:minor": "./publish.sh minor",
"release:patch": "./publish.sh patch",
"setup": "npm install && npm run flow-typed",
"format": "prettier --write --ignore-unknown .",
"format:check": "prettier --check .",
"test": "npm run format:check && npm run lint && npm run flow-typed && npm run flow && npm run jest && npm run karma",
"webpack": "babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --progress",
"jest": "jest test/server --env=node --no-cache --collectCoverageFrom='server/' --coverageDirectory='coverage/jest' --coverage --verbose --runInBand --silent=false",
"setup": "npm install && npm run tsc",
"prepublishOnly": "npm run babel",
"postpublish": "rm -rf ./server && git checkout ./server",
"validate-codecov": "curl --data-binary @.github/codecov.yml https://codecov.io/validate",
"prepare": "husky install"
"build": "npm run test && npm run babel && npm run webpack && npm run build:types",
"build:flow": "find ./dist -type f -not -path './node_modules/*' -name '*.d.ts' -exec sh -c 'flowgen --add-flow-header $1 -o ${1%.*.*}.js.flow' _ '{}' \\;",
"build:tsc": "tsc src/* --outDir ./dist/esm --declaration --emitDeclarationOnly --strict",
"build:types": "npm run build:tsc && npm run build:flow",
"webpack": "cross-env NODE_ENV=production babel-node --plugins=transform-es2015-modules-commonjs ./node_modules/.bin/webpack --progress --output-path dist",
"babel": "cross-env NODE_ENV=production babel src/ --out-dir ./dist/esm/ --extensions .ts,.tsx",
"tsc": "tsc",
"lint": "eslint src/ test/ *.js *.ts --ext .js,.jsx,.ts,.tsx",
"format": "prettier --write --ignore-unknown .",
"format:check": "prettier --check .",
"test": "npm run format:check && npm run lint && npm run tsc --no-emit && npm run vitest",
"clean": "rimraf dist coverage",
"debug": "cross-env NODE_ENV=debug",
"prepare": "husky install",
"prerelease": "npm run clean && npm run build && git add dist && git commit -m 'ci: check in dist folder' || echo 'Nothing to distribute'",
"release": "standard-version",
"postrelease": "git push && git push --follow-tags && npm publish",
"vitest": "vitest run --coverage",
"vitest:watch": "vitest watch --coverage --ui"
},
"files": [
"dist/",
Expand All @@ -53,27 +60,44 @@
"license": "Apache-2.0",
"readmeFilename": "README.md",
"dependencies": {
"@krakenjs/beaver-logger": "^5.0.0",
"@krakenjs/belter": "^2.0.0",
"@krakenjs/cross-domain-utils": "^3.0.2",
"@krakenjs/beaver-logger": "6.0.0-typescript.2",
"@krakenjs/belter": "3.0.0-typescript.1",
"@krakenjs/cross-domain-utils": "4.0.0-typescript.1",
"@krakenjs/jsx-pragmatic": "^3.0.0",
"@krakenjs/zalgo-promise": "^2.0.0",
"@paypal/sdk-constants": "^1.0.94",
"bowser": "^2.0.0"
"@krakenjs/zalgo-promise": "3.0.0-typescript.1",
"@paypal/sdk-constants": "2.0.0-typescript.1",
"bowser": "^2.11.0"
},
"devDependencies": {
"@krakenjs/grumbler-scripts": "^7.0.0",
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@krakenjs/babel-config-grumbler": "^8.1.1",
"@krakenjs/eslint-config-grumbler": "^8.1.1",
"@krakenjs/grumbler-scripts": "^8.1.3",
"@krakenjs/sync-browser-mocks": "^3.0.0",
"@krakenjs/typescript-config-grumbler": "^8.1.3",
"@krakenjs/webpack-config-grumbler": "^8.1.1",
"@vitest/coverage-c8": "^0.25.8",
"@vitest/ui": "^0.25.8",
"babel-core": "7.0.0-bridge.0",
"cheerio": "1.0.0-rc.9",
"cheerio": "1.0.0-rc.12",
"cross-env": "^7.0.3",
"esdoc": "1.1.0",
"esdoc-flow-type-plugin": "1.1.0",
"esdoc-standard-plugin": "1.0.0",
"flow-bin": "0.155.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"mocha": "^4.1.0",
"prettier": "2.7.1"
"flow-bin": "0.196.0",
"flowgen": "^1.20.1",
"husky": "^8.0.2",
"jsdom": "^20.0.3",
"lint-staged": "^13.1.0",
"mocha": "^10.2.0",
"msw": "^0.49.2",
"prettier": "2.8.1",
"standard-version": "^9.5.0",
"ts-node": "^10.9.1",
"typescript": "4.9.4",
"vite": "^4.0.1",
"vitest": "^0.25.8"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
Expand Down
6 changes: 2 additions & 4 deletions server/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* @flow */
/* eslint import/no-commonjs: off */

module.exports = {
extends: "@krakenjs/grumbler-scripts/config/.babelrc-node",
extends: "@krakenjs/babel-config-grumbler/babelrc-node",
presets: ["@krakenjs/babel-config-grumbler/flow-ts-babel-preset"],
};
10 changes: 1 addition & 9 deletions server/constants.js → server/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* @flow */

export const HOST = {
LOCALHOST: "localhost.paypal.com",
PAYPAL: ".paypal.com",
Expand All @@ -11,26 +9,20 @@ export const HOST = {
LOCALHOST_8000: "localhost:8000",
LOCALHOST_8443: "localhost:8443",
};

export const PROTOCOL = {
HTTP: "http:",
HTTPS: "https:",
};

export const LEGACY_SDK_PATH: RegExp =
// eslint-disable-next-line security/detect-unsafe-regex
export const LEGACY_SDK_PATH = // eslint-disable-next-line security/detect-unsafe-regex
/^(\/[a-zA-Z0-9_-]+)*\/checkout(\.4\.0\.\d{1,3})?(\.min)?\.js$/;

export const DEFAULT_SDK_META = {
url: "",
attrs: {
"data-stage-host": "",
"data-api-stage-host": "",
},
};

export const DEFAULT_LEGACY_SDK_BASE_URL = "https://www.paypalobjects.com/api/";

export const DATA_ATTRIBUTES = {
PAYPAL_CHECKOUT: "data-paypal-checkout",
NO_BRIDGE: "data-no-bridge",
Expand Down
2 changes: 0 additions & 2 deletions server/index.js → server/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/* @flow */

export * from "./meta";
Loading