Skip to content

Respect exit codes with bash commands #73

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

Merged
merged 4 commits into from
Aug 21, 2023
Merged
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
80 changes: 38 additions & 42 deletions .devcontainer/advanced-integration/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
// For more details, see https://aka.ms/devcontainer.json.
{
"name": "PayPal Advanced Integration",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/advanced-integration",
// Use 'onCreateCommand' to run commands when creating the container.
"onCreateCommand": "bash ../.devcontainer/advanced-integration/welcome-message.sh",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install",
// Use 'postAttachCommand' to run commands when attaching to the container.
"postAttachCommand": {
"Start server": "npm start"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8888
],
"portsAttributes": {
"8888": {
"label": "Preview of Advanced Checkout Flow",
"onAutoForward": "openBrowserOnce"
}
},
"secrets": {
"PAYPAL_CLIENT_ID": {
"description": "Sandbox client ID of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
},
"PAYPAL_CLIENT_SECRET": {
"description": "Sandbox secret of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
}
},
"customizations": {
"vscode": {
"extensions": [
"vsls-contrib.codetour"
],
"settings": {
"git.openRepositoryInParentFolders": "always"
}
}
}
}
"name": "PayPal Advanced Integration",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/advanced-integration",
// Use 'onCreateCommand' to run commands when creating the container.
"onCreateCommand": "bash ../.devcontainer/advanced-integration/welcome-message.sh",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install",
// Use 'postAttachCommand' to run commands when attaching to the container.
"postAttachCommand": {
"Start server": "npm start"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8888],
"portsAttributes": {
"8888": {
"label": "Preview of Advanced Checkout Flow",
"onAutoForward": "openBrowserOnce"
}
},
"secrets": {
"PAYPAL_CLIENT_ID": {
"description": "Sandbox client ID of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
},
"PAYPAL_CLIENT_SECRET": {
"description": "Sandbox secret of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
}
},
"customizations": {
"vscode": {
"extensions": ["vsls-contrib.codetour"],
"settings": {
"git.openRepositoryInParentFolders": "always"
}
}
}
}
80 changes: 38 additions & 42 deletions .devcontainer/standard-integration/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
// For more details, see https://aka.ms/devcontainer.json.
{
"name": "PayPal Standard Integration",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/standard-integration",
// Use 'onCreateCommand' to run commands when creating the container.
"onCreateCommand": "bash ../.devcontainer/standard-integration/welcome-message.sh",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install",
// Use 'postAttachCommand' to run commands when attaching to the container.
"postAttachCommand": {
"Start server": "npm start"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8888
],
"portsAttributes": {
"8888": {
"label": "Preview of Standard Checkout Flow",
"onAutoForward": "openBrowserOnce"
}
},
"secrets": {
"PAYPAL_CLIENT_ID": {
"description": "Sandbox client ID of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
},
"PAYPAL_CLIENT_SECRET": {
"description": "Sandbox secret of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
}
},
"customizations": {
"vscode": {
"extensions": [
"vsls-contrib.codetour"
],
"settings": {
"git.openRepositoryInParentFolders": "always"
}
}
}
}
"name": "PayPal Standard Integration",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/standard-integration",
// Use 'onCreateCommand' to run commands when creating the container.
"onCreateCommand": "bash ../.devcontainer/standard-integration/welcome-message.sh",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install",
// Use 'postAttachCommand' to run commands when attaching to the container.
"postAttachCommand": {
"Start server": "npm start"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8888],
"portsAttributes": {
"8888": {
"label": "Preview of Standard Checkout Flow",
"onAutoForward": "openBrowserOnce"
}
},
"secrets": {
"PAYPAL_CLIENT_ID": {
"description": "Sandbox client ID of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
},
"PAYPAL_CLIENT_SECRET": {
"description": "Sandbox secret of the application.",
"documentationUrl": "https://developer.paypal.com/dashboard/applications/sandbox"
}
},
"customizations": {
"vscode": {
"extensions": ["vsls-contrib.codetour"],
"settings": {
"git.openRepositoryInParentFolders": "always"
}
}
}
}
14 changes: 11 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ jobs:
node-version: 18

- name: 🧹 Check code formatting with Prettier
run: find . -name package.json -maxdepth 2 -type f -execdir npm run format:check ';'
run: >
find . -name package.json -maxdepth 2 -type f | while read -r file; do
directory=$(dirname "$file")
cd "$directory" && npm run format:check && cd -
done

- name: 👕 Lint Node.js code with ESLint
run: find . -name package.json -maxdepth 2 -type f -execdir npm run lint ';'
- name: 👕 Lint code with ESLint
run: >
find . -name package.json -maxdepth 2 -type f | while read -r file; do
directory=$(dirname "$file")
cd "$directory" && npm run lint && cd -
done
9 changes: 4 additions & 5 deletions advanced-integration/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function onApproveCallback(data, actions) {
}
}

paypal
window.paypal
.Buttons({
createOrder: createOrderCallback,
onApprove: onApproveCallback,
Expand All @@ -110,9 +110,9 @@ function resultMessage(message) {
}

// If this returns false or the card fields aren't visible, see Step #1.
if (paypal.HostedFields.isEligible()) {
if (window.paypal.HostedFields.isEligible()) {
// Renders card fields
paypal.HostedFields.render({
window.paypal.HostedFields.render({
// Call your server to set up the transaction
createOrder: createOrderCallback,
styles: {
Expand Down Expand Up @@ -172,10 +172,9 @@ if (paypal.HostedFields.isEligible()) {
return onApproveCallback(data);
})
.catch((orderData) => {
const { links, ...errorMessageData } = orderData;
resultMessage(
`Sorry, your transaction could not be processed...<br><br>${JSON.stringify(
errorMessageData,
orderData,
)}`,
);
});
Expand Down