Skip to content

Commit

Permalink
build-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
fnhipster committed Sep 19, 2024
1 parent 5fdefd3 commit 3d414c9
Show file tree
Hide file tree
Showing 42 changed files with 689 additions and 303 deletions.
1 change: 1 addition & 0 deletions .hlxignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package.json
package-lock.json
test/*
postinstall.js
build.mjs
tools/picker/src/*
cypress/
tools/pdp-metadata/*
9 changes: 9 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable import/no-extraneous-dependencies */
import { overrideGQLOperations } from '@dropins/build-tools/gql-extend.js';

overrideGQLOperations([
{
npm: '@dropins/storefront-cart',
operations: [],
},
]);
40 changes: 32 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint:css": "stylelint blocks/**/*.css styles/*.css",
"lint": "npm run lint:js && npm run lint:css",
"start": "aem up --print-index",
"install:dropins": "node postinstall.js",
"install:dropins": "node build.mjs && node postinstall.js",
"postinstall": "npm run install:dropins",
"postupdate": "npm run install:dropins"
},
Expand All @@ -25,6 +25,7 @@
"devDependencies": {
"@adobe/aem-cli": "^16.5.8",
"@babel/eslint-parser": "7.25.1",
"@dropins/build-tools": "0.1.0-alpha2",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.29.1",
Expand All @@ -34,11 +35,11 @@
"dependencies": {
"@adobe/magento-storefront-event-collector": "^1.8.0",
"@adobe/magento-storefront-events-sdk": "^1.8.0",
"@dropins/storefront-cart": "0.6.0",
"@dropins/storefront-checkout": "0.1.0-alpha49",
"@dropins/storefront-auth": "0.0.1-alpha20",
"@dropins/storefront-cart": "0.7.0-alpha007",
"@dropins/storefront-checkout": "0.1.0-alpha49",
"@dropins/storefront-order-confirmation": "0.1.0-alpha33",
"@dropins/storefront-pdp": "0.4.0-alpha3",
"@dropins/tools": "0.30.0"
"@dropins/tools": "0.31.0-alpha007"
}
}
9 changes: 8 additions & 1 deletion postinstall.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable import/extensions */
const fs = require('fs');
const path = require('path');
const { dependencies } = require('./package.json');

// Define the dropins folder
const dropinsDir = path.join('scripts', '__dropins__');
Expand All @@ -14,6 +16,11 @@ fs.mkdirSync(dropinsDir, { recursive: true });

// Copy specified files from node_modules/@dropins to scripts/__dropins__
fs.readdirSync('node_modules/@dropins', { withFileTypes: true }).forEach((file) => {
// Skip if package is not in package.json dependencies / skip devDependencies
if (!dependencies[`@dropins/${file.name}`]) {
return;
}

// Skip if is not folder
if (!file.isDirectory()) {
return;
Expand Down Expand Up @@ -56,7 +63,7 @@ function checkPackageLockForArtifactory() {
checkPackageLockForArtifactory()
.then((found) => {
if (!found) {
console.info('🫡 Drop-ins installed successfully!');
console.info(' Drop-ins installed successfully!', '\n');
process.exit(0);
} else {
console.error('🚨 Fix artifactory references before committing! 🚨');
Expand Down
13 changes: 7 additions & 6 deletions scripts/__dropins__/storefront-cart/api.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import{s,f as p,h as T}from"./chunks/resetCart.js";import{g as $,r as v,d as Q,a as H,b as k,c as z}from"./chunks/resetCart.js";import{C as g,a as l,t as f}from"./chunks/CartFragment.js";import{events as m}from"@dropins/tools/event-bus.js";import{c as h,p as I}from"./chunks/acdl.js";import{c as _,g as E,a as A}from"./chunks/getStoreConfig.js";import{b as j,e as q,i as B,d as J}from"./chunks/getStoreConfig.js";import{u as L}from"./chunks/updateProductsFromCart.js";import{g as W,b as X,a as Z}from"./chunks/getEstimateShipping.js";import{g as at}from"./chunks/getEstimatedTotals.js";import{g as et}from"./chunks/persisted-data.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const R=`
import{s,f as p,h as T}from"./chunks/resetCart.js";import{g as $,r as v,d as Q,a as H,b as k,c as z}from"./chunks/resetCart.js";import{C as l,t as f,c as g,g as h,a as I}from"./chunks/getStoreConfig.js";import{b as j,e as q,i as B,d as J}from"./chunks/getStoreConfig.js";import{events as d}from"@dropins/tools/event-bus.js";import{CART_FRAGMENT as _}from"./fragments.js";import{c as A,p as E}from"./chunks/acdl.js";import{u as L}from"./chunks/updateProductsFromCart.js";import{g as W,b as X,a as Z}from"./chunks/getEstimateShipping.js";import{g as rt}from"./chunks/getEstimatedTotals.js";import{g as et}from"./chunks/persisted-data.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const R=`
mutation ADD_PRODUCTS_TO_CART_MUTATION(
$cartId: String!,
$cartItems: [CartItemInput!]!,
${g}
${l}
) {
addProductsToCart(
cartId: $cartId
cartItems: $cartItems
) {
cart {
...CartFragment
...CART_FRAGMENT
}
user_errors {
code
message
}
}
}
${l}
`,b=async a=>{let o=!1;const n=s.cartId||await O().then(e=>(o=!0,e));return p(R,{variables:{cartId:n,cartItems:a.map(({sku:e,parentSku:r,quantity:c,optionsUIDs:t,enteredOptions:i})=>({sku:e,parent_sku:r,quantity:c,selected_options:t,entered_options:i}))}}).then(({errors:e,data:r})=>{var i;const c=[...((i=r==null?void 0:r.addProductsToCart)==null?void 0:i.user_errors)??[],...e??[]];if(c.length>0)return T(c);const t=f(r.addProductsToCart.cart);if(m.emit("cart/updated",t),m.emit("cart/data",t),t){const d=t.items.filter(C=>a.some(({sku:u})=>u===C.sku));o?h(t,d,s.locale??"en-US"):I(t,d,s.locale??"en-US")}return t})},P=`
${_}
`,b=async r=>{let o=!1;const c=s.cartId||await G().then(e=>(o=!0,e));return p(R,{variables:{cartId:c,cartItems:r.map(({sku:e,parentSku:a,quantity:n,optionsUIDs:t,enteredOptions:i})=>({sku:e,parent_sku:a,quantity:n,selected_options:t,entered_options:i}))}}).then(({errors:e,data:a})=>{var i;const n=[...((i=a==null?void 0:a.addProductsToCart)==null?void 0:i.user_errors)??[],...e??[]];if(n.length>0)return T(n);const t=f(a.addProductsToCart.cart);if(d.emit("cart/updated",t),d.emit("cart/data",t),t){const m=t.items.filter(C=>r.some(({sku:u})=>u===C.sku));o?A(t,m,s.locale??"en-US"):E(t,m,s.locale??"en-US")}return t})},P=`
mutation CREATE_EMPTY_CART_MUTATION {
createEmptyCart
}
`,O=async()=>{const{disableGuestCart:a}=_.getConfig();if(a)throw new Error("Guest cart is disabled");return await p(P).then(({data:o})=>{const n=o.createEmptyCart;return s.cartId=n,n})},F=async()=>{const a=s.authenticated?await E():await A();return m.emit("cart/updated",a),m.emit("cart/data",a),a};export{b as addProductsToCart,_ as config,O as createEmptyCart,p as fetchGraphQl,j as getCartData,et as getCartDataFromCache,$ as getConfig,W as getCountries,E as getCustomerCartPayload,X as getEstimateShipping,at as getEstimatedTotals,A as getGuestCartPayload,Z as getRegions,q as getStoreConfig,B as initialize,J as initializeCart,F as refreshCart,v as removeFetchGraphQlHeader,Q as resetCart,H as setEndpoint,k as setFetchGraphQlHeader,z as setFetchGraphQlHeaders,L as updateProductsFromCart};
`,G=async()=>{const{disableGuestCart:r}=g.getConfig();if(r)throw new Error("Guest cart is disabled");return await p(P).then(({data:o})=>{const c=o.createEmptyCart;return s.cartId=c,c})},F=async()=>{const r=s.authenticated?await h():await I();return d.emit("cart/updated",r),d.emit("cart/data",r),r};export{b as addProductsToCart,g as config,G as createEmptyCart,p as fetchGraphQl,j as getCartData,et as getCartDataFromCache,$ as getConfig,W as getCountries,h as getCustomerCartPayload,X as getEstimateShipping,rt as getEstimatedTotals,I as getGuestCartPayload,Z as getRegions,q as getStoreConfig,B as initialize,J as initializeCart,F as refreshCart,v as removeFetchGraphQlHeader,Q as resetCart,H as setEndpoint,k as setFetchGraphQlHeader,z as setFetchGraphQlHeaders,L as updateProductsFromCart};
3 changes: 3 additions & 0 deletions scripts/__dropins__/storefront-cart/api/fragments.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { CART_FRAGMENT } from './graphql/CartFragment';
export { CART_ITEM_FRAGMENT } from './graphql/CartItemFragment';
//# sourceMappingURL=fragments.d.ts.map
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@
* from Adobe.
*******************************************************************/
export declare const CART_FRAGMENT: string;
export declare const CART_ITEMS_PAGINATION_ARGUMENTS = "\n $pageSize: Int! = 100,\n $currentPage: Int! = 1,\n $itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}\n";
export declare const CUSTOMER_ACCOUNT_FRAGMENT = "\ncustomer {\n addresses {\n default_shipping\n country_id\n postcode\n region {\n region\n region_code\n region_id\n }\n }\n}";
//# sourceMappingURL=CartFragment.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const CART_ITEM_FRAGMENT: string;
//# sourceMappingURL=CartItemFragment.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const CUSTOMER_ACCOUNT_FRAGMENT = "\nfragment CUSTOMER_FRAGMENT on Customer {\n addresses {\n default_shipping\n country_id\n postcode\n region {\n region\n region_code\n region_id\n }\n }\n}";
//# sourceMappingURL=CustomerAccountFragment.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const CUSTOMIZABLE_OPTIONS_FRAGMENT = "\n fragment CUSTOMIZABLE_OPTIONS_FRAGMENT on SelectedCustomizableOption {\n type\n customizable_option_uid\n label\n is_required\n values {\n label\n value\n price{\n type\n units\n value\n }\n }\n }\n";
//# sourceMappingURL=CustomizableOptionsFragment.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const PRICE_RANGE_FRAGMENT = "\n fragment PRICE_RANGE_FRAGMENT on PriceRange {\n minimum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n discount {\n percent_off\n amount_off\n }\n }\n maximum_price {\n regular_price {\n value\n currency\n }\n final_price {\n value\n currency\n }\n discount {\n percent_off\n amount_off\n }\n }\n }\n";
//# sourceMappingURL=PriceRangeFragment.d.ts.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const CART_ITEMS_PAGINATION_ARGUMENTS = "\n $pageSize: Int! = 100,\n $currentPage: Int! = 1,\n $itemsSortInput: QuoteItemsSortInput! = {field: CREATED_AT, order: DESC}\n";
//# sourceMappingURL=arguments.d.ts.map
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Initializer } from '@dropins/tools/types/elsie/src/lib';
import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib';
import { Lang } from '@dropins/tools/types/elsie/src/i18n';
import { CartModel } from '../../data/models';

type ConfigProps = {
disableGuestCart?: boolean;
langDefinitions?: Lang;
models?: {
CartModel?: Model<CartModel>;
};
};
export declare const initialize: Initializer<ConfigProps>;
export declare const config: import('@dropins/tools/types/elsie/src/lib').Config<ConfigProps>;
Expand Down
Loading

0 comments on commit 3d414c9

Please sign in to comment.