diff --git a/README.md b/README.md index fb22ef4..2614274 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,14 @@ These are seeding files maintained as part of this repo that represent templates - Run `node ./dist/cli.js [command]` to debug a command. - Run `npm run test` to run unit tests. +## Json File Support +- Run `npm install` +- Run `npm run build` everytime you change source files. +- Run `node ./dist/cli.js validate ./seeds/Order-Cloud-seeding.json` to validate the json file. +- Run `node ./dist/cli.js seed ./seeds/Order-Cloud-seeding.json -u=[your user name] -p=[your ordercloud password] -n=[Your ordercloud market place name]` to seed the json file. ## Nice to Have features -- JSON as an option +- JSON as an option - Refer the above section - Reference other files - Template variables in YAML for imports. Including allowing OC to define an ID and then applying it later. diff --git a/package-lock.json b/package-lock.json index ab920b0..cb668ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ordercloud/seeding", - "version": "1.1.0-beta.2", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@ordercloud/seeding", - "version": "1.1.0-beta.2", + "version": "1.1.0", "license": "ISC", "dependencies": { "@ordercloud/portal-javascript-sdk": "0.0.1-beta.33", diff --git a/seeds/Order-Cloud-seeding.json b/seeds/Order-Cloud-seeding.json new file mode 100644 index 0000000..64668a0 --- /dev/null +++ b/seeds/Order-Cloud-seeding.json @@ -0,0 +1,1356 @@ +{ + "Objects": { + "SecurityProfiles": [ + { + "ID": "anon-shopper", + "Name": "Anonymous Shopper", + "Roles": ["Shopper"], + "CustomRoles": [], + "PasswordConfig": null + }, + { + "ID": "back-office-admin", + "Name": "Back Office Admin", + "Roles": ["FullAccess"], + "CustomRoles": [], + "PasswordConfig": null + }, + { + "ID": "shopper", + "Name": "Shopper", + "Roles": ["MeAddressAdmin", "MeAdmin", "MeCreditCardAdmin", "MeXpAdmin", "PasswordReset", "Shopper"], + "CustomRoles": [], + "PasswordConfig": null + } + ], + "ImpersonationConfigs": [], + "OpenIdConnects": [], + "AdminUsers": [ + { + "ID": "integrations-default-context-user", + "Username": "default-context-user", + "Password": null, + "FirstName": "Default", + "LastName": "Context", + "Email": "fake@email.com", + "Phone": null, + "TermsAccepted": null, + "Active": true, + "xp": null, + "AvailableRoles": ["FullAccess"], + "DateCreated": "2021-08-11T14:49:45.5+00:00", + "PasswordLastSetDate": null + } + ], + "AdminUserGroups": [], + "AdminAddresses": [], + "MessageSenders": [], + "ApiClients": [ + { + "ID": "35d0b898-c509-4b04-b08f-e4316a417a17", + "ClientSecret": "", + "AccessTokenDuration": 600, + "Active": true, + "AppName": "Middleware Integrations", + "RefreshTokenDuration": 5760, + "DefaultContextUserName": "default-context-user", + "xp": null, + "AllowAnyBuyer": false, + "AllowAnySupplier": false, + "AllowSeller": true, + "IsAnonBuyer": false, + "AssignedBuyerCount": 0, + "AssignedSupplierCount": 0, + "OrderCheckoutIntegrationEventID": null, + "OrderCheckoutIntegrationEventName": null, + "MinimumRequiredRoles": [], + "MinimumRequiredCustomRoles": [], + "MaximumGrantedRoles": [], + "MaximumGrantedCustomRoles": [] + }, + { + "ID": "9dfe083f-a675-4a3a-a39a-521511dac934", + "ClientSecret": null, + "AccessTokenDuration": 600, + "Active": true, + "AppName": "Back Office App", + "RefreshTokenDuration": 5760, + "DefaultContextUserName": null, + "xp": null, + "AllowAnyBuyer": false, + "AllowAnySupplier": false, + "AllowSeller": true, + "IsAnonBuyer": false, + "AssignedBuyerCount": 0, + "AssignedSupplierCount": 0, + "OrderCheckoutIntegrationEventID": null, + "OrderCheckoutIntegrationEventName": null, + "MinimumRequiredRoles": [], + "MinimumRequiredCustomRoles": [], + "MaximumGrantedRoles": [], + "MaximumGrantedCustomRoles": [] + }, + { + "ID": "e5a05785-caff-4f7d-9cc3-758f13865fc3", + "ClientSecret": null, + "AccessTokenDuration": 600, + "Active": true, + "AppName": "Storefront App", + "RefreshTokenDuration": 5760, + "DefaultContextUserName": "anonymous-shopper", + "xp": null, + "AllowAnyBuyer": false, + "AllowAnySupplier": false, + "AllowSeller": false, + "IsAnonBuyer": true, + "AssignedBuyerCount": 1, + "AssignedSupplierCount": 0, + "OrderCheckoutIntegrationEventID": "checkout-commerce-integrations", + "OrderCheckoutIntegrationEventName": "Checkout Commerce Integrations", + "MinimumRequiredRoles": [], + "MinimumRequiredCustomRoles": [], + "MaximumGrantedRoles": [], + "MaximumGrantedCustomRoles": [] + } + ], + "Incrementors": [], + "Webhooks": [], + "IntegrationEvents": [ + { + "ElevatedRoles": ["FullAccess"], + "ID": "checkout-commerce-integrations", + "ConfigData": null, + "EventType": "OrderCheckout", + "CustomImplementationUrl": "https://www.replace.this.com/api/checkout", + "Name": "Checkout Commerce Integrations", + "HashKey": "" + } + ], + "XpIndices": [], + "Buyers": [ + { + "ID": "solitary-storefront", + "Name": "Solitary Storefront", + "DefaultCatalogID": "solitary-storefront", + "Active": true, + "DateCreated": "2021-08-11T14:49:47.153+00:00", + "xp": null + } + ], + "Users": [ + { + "ID": "default-anonymous-shopper", + "Username": "anonymous-shopper", + "Password": null, + "FirstName": "anonymous", + "LastName": "shopper", + "Email": "fake@emai.com", + "Phone": null, + "TermsAccepted": null, + "Active": true, + "xp": { + "something": "else" + }, + "AvailableRoles": [ + "MeAddressAdmin", + "MeAdmin", + "MeCreditCardAdmin", + "MeXpAdmin", + "PasswordReset", + "Shopper" + ], + "DateCreated": "2021-08-11T14:49:51.217+00:00", + "PasswordLastSetDate": null, + "BuyerID": "solitary-storefront" + } + ], + "UserGroups": [], + "Addresses": [], + "CostCenters": [], + "CreditCards": [], + "SpendingAccounts": [], + "ApprovalRules": [], + "Catalogs": [ + { + "ID": "solitary-storefront", + "OwnerID": "", + "Name": "Solitary Storefront", + "Description": "Default catalog for Solitary Storefront", + "Active": true, + "CategoryCount": 15, + "xp": null + } + ], + "Categories": [ + { + "ID": "womens", + "Name": "Women's", + "Description": null, + "ListOrder": 1, + "Active": true, + "ParentID": null, + "ChildCount": 3, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "mens", + "Name": "Men's", + "Description": null, + "ListOrder": 2, + "Active": true, + "ParentID": null, + "ChildCount": 2, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "kids", + "Name": "Kid's", + "Description": null, + "ListOrder": 3, + "Active": true, + "ParentID": null, + "ChildCount": 3, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "general", + "Name": "General", + "Description": null, + "ListOrder": 4, + "Active": true, + "ParentID": null, + "ChildCount": 1, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "masks", + "Name": "Face Masks", + "Description": null, + "ListOrder": 1, + "Active": true, + "ParentID": "general", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "girls", + "Name": "Girls", + "Description": null, + "ListOrder": 1, + "Active": true, + "ParentID": "kids", + "ChildCount": 1, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "mens-jackets", + "Name": "Jackets", + "Description": null, + "ListOrder": 1, + "Active": true, + "ParentID": "mens", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "womens-jackets", + "Name": "Jackets", + "Description": null, + "ListOrder": 1, + "Active": true, + "ParentID": "womens", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "womens-bottoms", + "Name": "Bottoms", + "Description": null, + "ListOrder": 2, + "Active": true, + "ParentID": "womens", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "mens-bottoms", + "Name": "Bottoms", + "Description": null, + "ListOrder": 2, + "Active": true, + "ParentID": "mens", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "boys", + "Name": "Boys", + "Description": null, + "ListOrder": 2, + "Active": true, + "ParentID": "kids", + "ChildCount": 1, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "toddlers", + "Name": "Toddlers'", + "Description": null, + "ListOrder": 3, + "Active": true, + "ParentID": "kids", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "womens-socks", + "Name": "Socks", + "Description": null, + "ListOrder": 3, + "Active": true, + "ParentID": "womens", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "girls-shoes", + "Name": "Shoes", + "Description": null, + "ListOrder": 1, + "Active": true, + "ParentID": "girls", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + }, + { + "ID": "boys-shoes", + "Name": "Shoes", + "Description": null, + "ListOrder": 2, + "Active": true, + "ParentID": "boys", + "ChildCount": 0, + "xp": null, + "CatalogID": "solitary-storefront" + } + ], + "Products": [ + { + "OwnerID": "", + "DefaultPriceScheduleID": "mulberry-silk-facemask", + "AutoForward": false, + "ID": "mulberry-silk-facemask", + "Name": "Mulberry Silk Facemask", + "Description": "A luxurious fabric, mulberry silk is named for the mulberry leaves the uniquely bred silkworms feed on. A mask for your face.", + "QuantityMultiplier": 1, + "ShipWeight": 5, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 1, + "VariantCount": 3, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:51.513+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 35, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/face_mask.jpg" + } + ], + "Facets": { + "Color": [ + "yellow", + "red", + "blue" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": "boys-turkish-leather-caliage", + "AutoForward": false, + "ID": "boys-turkish-leather-caliage", + "Name": "Boy's Turkish Leather Caliage", + "Description": "Hobnailed sandal-boots used by the roman military, Caliage will go toe-to-toe with Air Jordans in intimidating your child's classmates.", + "QuantityMultiplier": 1, + "ShipWeight": 10, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 0, + "VariantCount": 0, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:51.607+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 75, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/sandels.jpg" + } + ], + "Facets": { + "Color": [ + "orange", + "black" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": "girls-turkish-leather-caliage", + "AutoForward": false, + "ID": "girls-turkish-leather-caliage", + "Name": "Girl's Turkish Leather Caliage", + "Description": "Hobnailed sandal-boots used by the roman military, Caliage will go toe-to-toe with Air Jordans in intimidating your child's classmates. Same as the boy's version, but comes in pink.", + "QuantityMultiplier": 1, + "ShipWeight": 10, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 0, + "VariantCount": 0, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:51.7+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 75, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/sandels.jpg" + } + ], + "Facets": { + "Color": [ + "orange", + "black" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": "mens-hellion-onyx-jacket", + "AutoForward": false, + "ID": "mens-hellion-onyx-jacket", + "Name": "Men's Helion Onyx Jacket", + "Description": "Bright like the sun and dark like midnight. A blindingly perfect jacket. Comes in colors.", + "QuantityMultiplier": 1, + "ShipWeight": 22, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 1, + "VariantCount": 0, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:51.793+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 120, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/jacket.jpg" + } + ], + "Facets": { + "Color": [ + "yellow", + "black" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": "mens-intrigue-active-shorts", + "AutoForward": false, + "ID": "mens-intrigue-active-shorts", + "Name": "Men's Intrigue(TM) Active Shorts", + "Description": "Intrigued? These shorts inspire curiosity, interest, even fascination.", + "QuantityMultiplier": 1, + "ShipWeight": 5, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 2, + "VariantCount": 12, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:51.903+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 50, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/purple_shorts.jpg" + } + ], + "Facets": { + "Color": [ + "purple", + "orange", + "green" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": "penquin-feather-onesie", + "AutoForward": false, + "ID": "penquin-feather-onesie", + "Name": "Penguin Feather Onesie", + "Description": "Material is 100% A-grade penquin feathers. Feather's harvested humanely and sustainably from free-range penguins.", + "QuantityMultiplier": 1, + "ShipWeight": 10, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 0, + "VariantCount": 0, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:52.013+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 80, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/penquin.jpg" + } + ], + "Facets": { + "Color": [ + "white", + "black" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": "womens-hellion-onyx-jacket", + "AutoForward": false, + "ID": "womens-hellion-onyx-jacket", + "Name": "Women's Helion Onyx Jacket", + "Description": "Bright like the sun and dark like midnight. A blindingly perfect jacket. Comes in colors.", + "QuantityMultiplier": 1, + "ShipWeight": 21, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 1, + "VariantCount": 0, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:52.107+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 120, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/jacket.jpg" + } + ], + "Facets": { + "Color": [ + "yellow", + "black" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": "womens-intrigue-active-shorts", + "AutoForward": false, + "ID": "womens-intrigue-active-shorts", + "Name": "Women's Intrigue(TM) Active Shorts", + "Description": "Intrigued? These shorts inspire curiosity, interest, even fascination.", + "QuantityMultiplier": 1, + "ShipWeight": 10, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 2, + "VariantCount": 12, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:52.183+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 50, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/purple_shorts.jpg" + } + ], + "Facets": { + "Color": [ + "purple", + "orange", + "green" + ] + } + } + }, + { + "OwnerID": "", + "DefaultPriceScheduleID": null, + "AutoForward": false, + "ID": "womens-spiked-wool-socks", + "Name": "Women's Spiked Wool Socks", + "Description": "Metal spikes embedded in a carbon fiber plate give these socks outstanding grip for navigating ice. Finally, traverse a frozen crevasse without sacrificing comfort.", + "QuantityMultiplier": 1, + "ShipWeight": 5, + "ShipHeight": null, + "ShipWidth": null, + "ShipLength": null, + "Active": true, + "SpecCount": 0, + "VariantCount": 0, + "ShipFromAddressID": null, + "Inventory": { + "Enabled": true, + "NotificationPoint": null, + "VariantLevelTracking": false, + "OrderCanExceed": false, + "QuantityAvailable": 30, + "LastUpdated": "2021-08-11T14:49:52.293+00:00" + }, + "DefaultSupplierID": null, + "AllSuppliersCanSell": false, + "xp": { + "Price": 25, + "PriceCurrency": "USD", + "Images": [ + { + "url": "https://ocdevops.blob.core.windows.net/vercel-integration-assets/socks.webp" + } + ] + } + } + ], + "PriceSchedules": [ + { + "ID": "boys-turkish-leather-caliage", + "Name": "boys-turkish-leather-caliage", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 75 + } + ], + "xp": null + }, + { + "ID": "girls-turkish-leather-caliage", + "Name": "girls-turkish-leather-caliage", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 75 + } + ], + "xp": null + }, + { + "ID": "mens-hellion-onyx-jacket", + "Name": "mens-hellion-onyx-jacket", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 120 + } + ], + "xp": null + }, + { + "ID": "mens-intrigue-active-shorts", + "Name": "mens-intrigue-active-shorts", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 50 + } + ], + "xp": null + }, + { + "ID": "mulberry-silk-facemask", + "Name": "mulberry-silk-facemask", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 35 + } + ], + "xp": null + }, + { + "ID": "penquin-feather-onesie", + "Name": "penquin-feather-onesie", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 80 + } + ], + "xp": null + }, + { + "ID": "womens-hellion-onyx-jacket", + "Name": "womens-hellion-onyx-jacket", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 120 + } + ], + "xp": null + }, + { + "ID": "womens-intrigue-active-shorts", + "Name": "womens-intrigue-active-shorts", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 50 + } + ], + "xp": null + }, + { + "ID": "womens-spiked-wool-socks", + "Name": "womens-spiked-wool-socks", + "ApplyTax": true, + "ApplyShipping": true, + "MinQuantity": 1, + "MaxQuantity": null, + "UseCumulativeQuantity": false, + "RestrictedQuantity": false, + "PriceBreaks": [ + { + "Quantity": 1, + "Price": 25 + } + ], + "xp": null + } + ], + "Specs": [ + { + "OwnerID": "", + "ID": "intrigue-active-shorts-color", + "ListOrder": 0, + "Name": "Color", + "DefaultValue": null, + "Required": true, + "AllowOpenText": false, + "DefaultOptionID": "obsession-umber", + "DefinesVariant": true, + "xp": null, + "OptionCount": 3, + "Options": [ + { + "ID": "mysterious-mint", + "Value": "Mysterious Mint", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#b6e3c2" + } + }, + { + "ID": "obsession-umber", + "Value": "Obsession Umber", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#db8b3b" + } + }, + { + "ID": "paranoid-purple", + "Value": "Paranoid Purple", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#752175" + } + } + ] + }, + { + "OwnerID": "", + "ID": "mulberry-silk-facemask-color", + "ListOrder": 0, + "Name": "Color", + "DefaultValue": null, + "Required": true, + "AllowOpenText": false, + "DefaultOptionID": "blue", + "DefinesVariant": true, + "xp": null, + "OptionCount": 3, + "Options": [ + { + "ID": "blue", + "Value": "Blue", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#2e53c9" + } + }, + { + "ID": "red", + "Value": "Red", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#c9382e" + } + }, + { + "ID": "yellow", + "Value": "Yellow", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#c9c42e" + } + } + ] + }, + { + "OwnerID": "", + "ID": "cross-product-size", + "ListOrder": 0, + "Name": "Size", + "DefaultValue": null, + "Required": true, + "AllowOpenText": false, + "DefaultOptionID": null, + "DefinesVariant": true, + "xp": null, + "OptionCount": 4, + "Options": [ + { + "ID": "L", + "Value": "Large", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null + }, + { + "ID": "m", + "Value": "Medium", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null + }, + { + "ID": "s", + "Value": "Small", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null + }, + { + "ID": "XL", + "Value": "Extra Large", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null + } + ] + } + ], + "SpecOptions": [ + { + "ID": "mysterious-mint", + "Value": "Mysterious Mint", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#b6e3c2" + }, + "SpecID": "intrigue-active-shorts-color" + }, + { + "ID": "obsession-umber", + "Value": "Obsession Umber", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#db8b3b" + }, + "SpecID": "intrigue-active-shorts-color" + }, + { + "ID": "paranoid-purple", + "Value": "Paranoid Purple", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#752175" + }, + "SpecID": "intrigue-active-shorts-color" + }, + { + "ID": "blue", + "Value": "Blue", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#2e53c9" + }, + "SpecID": "mulberry-silk-facemask-color" + }, + { + "ID": "red", + "Value": "Red", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#c9382e" + }, + "SpecID": "mulberry-silk-facemask-color" + }, + { + "ID": "yellow", + "Value": "Yellow", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": { + "hexColor": "#c9c42e" + }, + "SpecID": "mulberry-silk-facemask-color" + }, + { + "ID": "L", + "Value": "Large", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null, + "SpecID": "cross-product-size" + }, + { + "ID": "m", + "Value": "Medium", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null, + "SpecID": "cross-product-size" + }, + { + "ID": "s", + "Value": "Small", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null, + "SpecID": "cross-product-size" + }, + { + "ID": "XL", + "Value": "Extra Large", + "ListOrder": 0, + "IsOpenText": false, + "PriceMarkupType": "NoMarkup", + "PriceMarkup": null, + "xp": null, + "SpecID": "cross-product-size" + } + ], + "ProductFacets": [ + { + "ID": "color", + "Name": "Color", + "XpPath": "Facets.Color", + "ListOrder": 0, + "MinCount": 1, + "xp": { + "options": [ + "black", + "white", + "yellow", + "red", + "blue", + "green", + "orange", + "purple" + ] + } + } + ], + "Assignments": { + "UserGroupAssignments": [], + "SpendingAccountAssignments": [], + "AddressAssignments": [], + "CostCenterAssignments": [], + "CreditCardAssignments": [], + "CategoryAssignments": [], + "CategoryProductAssignments": [ + { + "CategoryID": "boys-shoes", + "ProductID": "boys-turkish-leather-caliage", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "girls-shoes", + "ProductID": "girls-turkish-leather-caliage", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "masks", + "ProductID": "mulberry-silk-facemask", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "mens-bottoms", + "ProductID": "mens-intrigue-active-shorts", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "mens-jackets", + "ProductID": "mens-hellion-onyx-jacket", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "toddlers", + "ProductID": "penquin-feather-onesie", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "womens-bottoms", + "ProductID": "womens-intrigue-active-shorts", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "womens-jackets", + "ProductID": "womens-hellion-onyx-jacket", + "ListOrder": null, + "CatalogID": "solitary-storefront" + }, + { + "CategoryID": "womens-socks", + "ProductID": "womens-spiked-wool-socks", + "ListOrder": null, + "CatalogID": "solitary-storefront" + } + ], + "SecurityProfileAssignments": [ + { + "SecurityProfileID": "anon-shopper", + "BuyerID": "solitary-storefront", + "SupplierID": null, + "UserID": null, + "UserGroupID": null + }, + { + "SecurityProfileID": "back-office-admin", + "BuyerID": null, + "SupplierID": null, + "UserID": null, + "UserGroupID": null + }, + { + "SecurityProfileID": "shopper", + "BuyerID": "solitary-storefront", + "SupplierID": null, + "UserID": null, + "UserGroupID": null + } + ], + "AdminUserGroupAssignments": [], + "ApiClientAssignments": [ + { + "ApiClientID": "e5a05785-caff-4f7d-9cc3-758f13865fc3", + "BuyerID": "solitary-storefront", + "SupplierID": null + } + ], + "ProductAssignments": [], + "CatalogAssignments": [ + { + "CatalogID": "solitary-storefront", + "BuyerID": "solitary-storefront", + "ViewAllCategories": true, + "ViewAllProducts": true + } + ], + "ProductCatalogAssignment": [ + { + "CatalogID": "solitary-storefront", + "ProductID": "boys-turkish-leather-caliage" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "girls-turkish-leather-caliage" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "mens-hellion-onyx-jacket" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "mens-intrigue-active-shorts" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "mulberry-silk-facemask" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "penquin-feather-onesie" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "womens-hellion-onyx-jacket" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "womens-intrigue-active-shorts" + }, + { + "CatalogID": "solitary-storefront", + "ProductID": "womens-spiked-wool-socks" + } + ], + "SpecProductAssignments": [ + { + "SpecID": "cross-product-size", + "ProductID": "mens-hellion-onyx-jacket", + "DefaultValue": null, + "DefaultOptionID": null + }, + { + "SpecID": "cross-product-size", + "ProductID": "mens-intrigue-active-shorts", + "DefaultValue": null, + "DefaultOptionID": null + }, + { + "SpecID": "cross-product-size", + "ProductID": "womens-hellion-onyx-jacket", + "DefaultValue": null, + "DefaultOptionID": null + }, + { + "SpecID": "cross-product-size", + "ProductID": "womens-intrigue-active-shorts", + "DefaultValue": null, + "DefaultOptionID": null + }, + { + "SpecID": "intrigue-active-shorts-color", + "ProductID": "mens-intrigue-active-shorts", + "DefaultValue": null, + "DefaultOptionID": "obsession-umber" + }, + { + "SpecID": "intrigue-active-shorts-color", + "ProductID": "womens-intrigue-active-shorts", + "DefaultValue": null, + "DefaultOptionID": "obsession-umber" + }, + { + "SpecID": "mulberry-silk-facemask-color", + "ProductID": "mulberry-silk-facemask", + "DefaultValue": null, + "DefaultOptionID": "blue" + } + ], + "PromotionAssignment": [] + } + } + } + \ No newline at end of file diff --git a/src/cli.ts b/src/cli.ts index d70374d..3f02914 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -53,15 +53,28 @@ yargs.scriptName("@ordercloud/seeding") var stringData; if (!dataUrl.startsWith('http')) { - try { + try { stringData = fs.readFileSync(dataUrl, 'utf8') // consider switching to streams defaultLogger(`Found file \"${dataUrl}\"`, MessageType.Success); + + //find the file extension from the path "./seeds/Order-Cloud-seeding.json" + var fileExtensionArray = dataUrl.split('.'); + var fileExtension = fileExtensionArray[fileExtensionArray.length - 1]; + defaultLogger(`The file type is \"${fileExtension}\"`, MessageType.Info); + } catch (err) { defaultLogger(`No such file \"${dataUrl}\" found`, MessageType.Error); return; } try { - var data = yaml.load(stringData) as SerializedMarketplace; + + if(fileExtension === 'json'){ + var data = JSON.parse(stringData) as SerializedMarketplace; + } + else{ + var data = yaml.load(stringData) as SerializedMarketplace; + } + seed({ username: argv.u as string, password: argv.p as string, @@ -134,12 +147,23 @@ yargs.scriptName("@ordercloud/seeding") var stringData; if (!filePath.startsWith('http')) { try { + defaultLogger(`starting point : Seeding local file = ${filePath}`, MessageType.Info); stringData = fs.readFileSync(filePath, 'utf8') // consider switching to streams defaultLogger(`Found file \"${filePath}\".`, MessageType.Success); + var fileExtensionArray = filePath.split('.'); + var fileExtension = fileExtensionArray[fileExtensionArray.length - 1]; + defaultLogger(`The file type is \"${fileExtension}\"`, MessageType.Info); + } catch (err) { return defaultLogger(`No such file \"${filePath}\" found`, MessageType.Error); } try { + if(fileExtension === 'json'){ + var data = JSON.parse(stringData) as SerializedMarketplace; + } + else{ + var data = yaml.load(stringData) as SerializedMarketplace; + } var data = yaml.load(stringData) as SerializedMarketplace; await validate({ rawData: data }) return defaultLogger(`Validation done!`, MessageType.Done);